Commit fa46d143 authored by Paolo Abeni's avatar Paolo Abeni Committed by Greg Kroah-Hartman

cls_u32: add missing RCU annotation.


[ Upstream commit 058a6c03 ]

In a couple of points of the control path, n->ht_down is currently
accessed without the required RCU annotation. The accesses are
safe, but sparse complaints. Since we already held the
rtnl lock, let use rtnl_dereference().

Fixes: a1b7c5fd ("net: sched: add cls_u32 offload hooks for netdevs")
Fixes: de5df632 ("net: sched: cls_u32 changes to knode must appear atomic to readers")
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Acked-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b980f718
...@@ -496,6 +496,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h) ...@@ -496,6 +496,7 @@ static void u32_clear_hw_hnode(struct tcf_proto *tp, struct tc_u_hnode *h)
static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
u32 flags) u32 flags)
{ {
struct tc_u_hnode *ht = rtnl_dereference(n->ht_down);
struct net_device *dev = tp->q->dev_queue->dev; struct net_device *dev = tp->q->dev_queue->dev;
struct tc_cls_u32_offload u32_offload = {0}; struct tc_cls_u32_offload u32_offload = {0};
struct tc_to_netdev offload; struct tc_to_netdev offload;
...@@ -520,7 +521,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, ...@@ -520,7 +521,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
offload.cls_u32->knode.sel = &n->sel; offload.cls_u32->knode.sel = &n->sel;
offload.cls_u32->knode.exts = &n->exts; offload.cls_u32->knode.exts = &n->exts;
if (n->ht_down) if (n->ht_down)
offload.cls_u32->knode.link_handle = n->ht_down->handle; offload.cls_u32->knode.link_handle = ht->handle;
err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
tp->protocol, &offload); tp->protocol, &offload);
...@@ -788,8 +789,9 @@ static void u32_replace_knode(struct tcf_proto *tp, struct tc_u_common *tp_c, ...@@ -788,8 +789,9 @@ static void u32_replace_knode(struct tcf_proto *tp, struct tc_u_common *tp_c,
static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp, static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp,
struct tc_u_knode *n) struct tc_u_knode *n)
{ {
struct tc_u_knode *new; struct tc_u_hnode *ht = rtnl_dereference(n->ht_down);
struct tc_u32_sel *s = &n->sel; struct tc_u32_sel *s = &n->sel;
struct tc_u_knode *new;
new = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), new = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key),
GFP_KERNEL); GFP_KERNEL);
...@@ -807,11 +809,11 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp, ...@@ -807,11 +809,11 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp,
new->fshift = n->fshift; new->fshift = n->fshift;
new->res = n->res; new->res = n->res;
new->flags = n->flags; new->flags = n->flags;
RCU_INIT_POINTER(new->ht_down, n->ht_down); RCU_INIT_POINTER(new->ht_down, ht);
/* bump reference count as long as we hold pointer to structure */ /* bump reference count as long as we hold pointer to structure */
if (new->ht_down) if (ht)
new->ht_down->refcnt++; ht->refcnt++;
#ifdef CONFIG_CLS_U32_PERF #ifdef CONFIG_CLS_U32_PERF
/* Statistics may be incremented by readers during update /* Statistics may be incremented by readers during update
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment