netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] cls_u32: add missing RCU annotation.
@ 2018-02-02 15:02 Paolo Abeni
  2018-02-02 21:59 ` Cong Wang
  2018-02-03  0:26 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2018-02-02 15:02 UTC (permalink / raw)
  To: netdev
  Cc: David S. Miller, Jamal Hadi Salim, Cong Wang, Jiri Pirko, John Fastabend

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: a1b7c5fd7fe9 ("net: sched: add cls_u32 offload hooks for netdevs")
Fixes: de5df63228fc ("net: sched: cls_u32 changes to knode must appear atomic to readers")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/sched/cls_u32.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 10440fbf3c68..f189fcaaeeb1 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -550,6 +550,7 @@ static void u32_remove_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, struct netlink_ext_ack *extack)
 {
+	struct tc_u_hnode *ht = rtnl_dereference(n->ht_down);
 	struct tcf_block *block = tp->chain->block;
 	struct tc_cls_u32_offload cls_u32 = {};
 	bool skip_sw = tc_skip_sw(flags);
@@ -569,7 +570,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n,
 	cls_u32.knode.sel = &n->sel;
 	cls_u32.knode.exts = &n->exts;
 	if (n->ht_down)
-		cls_u32.knode.link_handle = n->ht_down->handle;
+		cls_u32.knode.link_handle = ht->handle;
 
 	err = tc_setup_cb_call(block, NULL, TC_SETUP_CLSU32, &cls_u32, skip_sw);
 	if (err < 0) {
@@ -866,8 +867,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,
 					 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_u_knode *new;
 
 	new = kzalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key),
 		      GFP_KERNEL);
@@ -885,11 +887,11 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp,
 	new->fshift = n->fshift;
 	new->res = n->res;
 	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 */
-	if (new->ht_down)
-		new->ht_down->refcnt++;
+	if (ht)
+		ht->refcnt++;
 
 #ifdef CONFIG_CLS_U32_PERF
 	/* Statistics may be incremented by readers during update
-- 
2.14.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] cls_u32: add missing RCU annotation.
  2018-02-02 15:02 [PATCH net] cls_u32: add missing RCU annotation Paolo Abeni
@ 2018-02-02 21:59 ` Cong Wang
  2018-02-03  0:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Cong Wang @ 2018-02-02 21:59 UTC (permalink / raw)
  To: Paolo Abeni
  Cc: Linux Kernel Network Developers, David S. Miller,
	Jamal Hadi Salim, Jiri Pirko, John Fastabend

On Fri, Feb 2, 2018 at 7:02 AM, Paolo Abeni <pabeni@redhat.com> wrote:
> 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: a1b7c5fd7fe9 ("net: sched: add cls_u32 offload hooks for netdevs")
> Fixes: de5df63228fc ("net: sched: cls_u32 changes to knode must appear atomic to readers")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] cls_u32: add missing RCU annotation.
  2018-02-02 15:02 [PATCH net] cls_u32: add missing RCU annotation Paolo Abeni
  2018-02-02 21:59 ` Cong Wang
@ 2018-02-03  0:26 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2018-02-03  0:26 UTC (permalink / raw)
  To: pabeni; +Cc: netdev, jhs, xiyou.wangcong, jiri, john.fastabend

From: Paolo Abeni <pabeni@redhat.com>
Date: Fri,  2 Feb 2018 16:02:22 +0100

> 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: a1b7c5fd7fe9 ("net: sched: add cls_u32 offload hooks for netdevs")
> Fixes: de5df63228fc ("net: sched: cls_u32 changes to knode must appear atomic to readers")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Applied and queued up for -stable.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-03  0:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-02 15:02 [PATCH net] cls_u32: add missing RCU annotation Paolo Abeni
2018-02-02 21:59 ` Cong Wang
2018-02-03  0:26 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).