public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: John Fastabend <john.r.fastabend@intel•com>
To: John Fastabend <john.fastabend@gmail•com>,
	xiyou.wangcong@gmail•com, davem@davemloft•net,
	eric.dumazet@gmail•com
Cc: netdev@vger•kernel.org, jhs@mojatatu•com
Subject: Re: [net-next PATCH 2/3] net: sched: cls_u32 add missing rcu_assign_pointer and annotation
Date: Mon, 15 Sep 2014 23:25:20 -0700	[thread overview]
Message-ID: <5417D7D0.3080803@intel.com> (raw)
In-Reply-To: <20140916024759.3010.24175.stgit@nitbit.x32>

On 09/15/2014 07:48 PM, John Fastabend wrote:
> Add missing rcu_assign_pointer and missing  annotation for ht_up
> in cls_u32.c
> 
> Caught by kbuild bot,
> 
>>> net/sched/cls_u32.c:378:36: sparse: incorrect type in initializer (different address spaces)
>    net/sched/cls_u32.c:378:36:    expected struct tc_u_hnode *ht
>    net/sched/cls_u32.c:378:36:    got struct tc_u_hnode [noderef] <asn:4>*ht_up
>>> net/sched/cls_u32.c:610:54: sparse: incorrect type in argument 4 (different address spaces)
>    net/sched/cls_u32.c:610:54:    expected struct tc_u_hnode *ht
>    net/sched/cls_u32.c:610:54:    got struct tc_u_hnode [noderef] <asn:4>*ht_up
>>> net/sched/cls_u32.c:684:18: sparse: incorrect type in assignment (different address spaces)
>    net/sched/cls_u32.c:684:18:    expected struct tc_u_hnode [noderef] <asn:4>*ht_up
>    net/sched/cls_u32.c:684:18:    got struct tc_u_hnode *[assigned] ht
>>> net/sched/cls_u32.c:359:18: sparse: dereference of noderef expression
> 
> Signed-off-by: John Fastabend <john.r.fastabend@intel•com>
> ---
>  net/sched/cls_u32.c |    7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
> index 8cffe5a..19b2808 100644
> --- a/net/sched/cls_u32.c
> +++ b/net/sched/cls_u32.c
> @@ -375,7 +375,7 @@ static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key)
>  {
>  	struct tc_u_knode __rcu **kp;
>  	struct tc_u_knode *pkp;
> -	struct tc_u_hnode *ht = key->ht_up;
> +	struct tc_u_hnode *ht = rtnl_dereference(key->ht_up);
>  
>  	if (ht) {
>  		kp = &ht->ht[TC_U32_HASH(key->handle)];
> @@ -607,7 +607,8 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
>  		if (TC_U32_KEY(n->handle) == 0)
>  			return -EINVAL;
>  
> -		return u32_set_parms(net, tp, base, n->ht_up, n, tb,
> +		return u32_set_parms(net, tp, base,
> +				     rtnl_dereference(n->ht_up), n, tb,
>  				     tca[TCA_RATE], ovr);
>  	}
>  
> @@ -681,7 +682,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
>  #endif
>  
>  	memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
> -	n->ht_up = ht;
> +	rcu_assign_pointer(n->ht_up, ht);

also believe this should be RCU_INIT_POINTER() the rcu_assign_pointer() to attach
n to the hash table happens below so there are no concurrent readers until after
the assign.

however while reviewing this I realize there is a 'copy'/'update' pattern I
missed in the u32_set_parms case when the classid and ifindex is changed. So
a fix coming for that shortly.

>  	n->handle = handle;
>  	n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0;
>  	tcf_exts_init(&n->exts, TCA_U32_ACT, TCA_U32_POLICE);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger•kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

  reply	other threads:[~2014-09-16  6:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-16  2:47 [net-next PATCH 1/3] net: sched: fix unsued cpu variable John Fastabend
2014-09-16  2:48 ` [net-next PATCH 2/3] net: sched: cls_u32 add missing rcu_assign_pointer and annotation John Fastabend
2014-09-16  6:25   ` John Fastabend [this message]
2014-09-16  2:48 ` [net-next PATCH 3/3] net: sched: cls_cgroup fix possible memory leak of 'new' John Fastabend
2014-09-16  3:04   ` Cong Wang
2014-09-16  3:29     ` John Fastabend

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5417D7D0.3080803@intel.com \
    --to=john.r.fastabend@intel$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=eric.dumazet@gmail$(echo .)com \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=john.fastabend@gmail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=xiyou.wangcong@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox