mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Su Yanjun <suyj.fnst@cn.fujitsu.com>" <suyj.fnst@cn.fujitsu.com>
To: Steffen Klassert <steffen.klassert@secunet.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Cc: <davem@davemloft.net>, <fw@strlen.de>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] net: xfrm: Add '_rcu' tag for rcu protected pointer in netns_xfrm
Date: Wed, 20 Mar 2019 08:53:54 +0800	[thread overview]
Message-ID: <91cf303a-7d44-2c15-8b7a-8b2eb797a234@cn.fujitsu.com> (raw)
In-Reply-To: <20190319151503.GW6035@gauss3.secunet.de>


On 2019/3/19 23:15, Steffen Klassert wrote:
> On Mon, Mar 18, 2019 at 10:22:46AM -0700, Eric Dumazet wrote:
>>
>> On 03/11/2019 03:10 AM, Steffen Klassert wrote:
>>> On Wed, Mar 06, 2019 at 08:54:08PM -0500, Su Yanjun wrote:
>>>> For rcu protected pointers, we'd better add '__rcu' for them.
>>>>
>>>> Once added '__rcu' tag for rcu protected pointer, the sparse tool reports
>>>> warnings.
>>>>
>>>> net/xfrm/xfrm_user.c:1198:39: sparse:    expected struct sock *sk
>>>> net/xfrm/xfrm_user.c:1198:39: sparse:    got struct sock [noderef] <asn:4> *nlsk
>>>> [...]
>>>>
>>>> So introduce a new wrapper function of nlmsg_unicast  to handle type
>>>> conversions.
>>>>
>>>> This patch also fixes a direct access of a rcu protected socket.
>>>>
>>>> Fixes: be33690d8fcf("[XFRM]: Fix aevent related crash")
>>>> Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
>>> Patch applied, thanks!
>>>
>> Has this patch ever been tested ?
> I had this on your testing system and it did
> not complain. But maybe my testcases did not
> trigger that codepath. Su, can you answer
> on Eric question?
>
Firs of all, I didn't produce it on my test machine.

Maybe we need recompile the kernel with Eric Dumazet's advise.

CONFIG_LOCKDEP=y
CONFIG_PROVE_RCU=y

The second the code path indeed doesn't do as below:
rcu_read_lock()
rcu_dereference()
...
rcu_read_unlock()

All rcu_dereference are in the follow code path:
xfrm_user_rcv_msg
  link->doit(skb, nlh, attrs)
     rcu_dereference()

I think we can add rcu protection for nlsock

xfrm_user_rcv_msg
   rcu_read_lock()
   link->doit(skb, nlh, attrs)
   rcu_read_unlock()

Any advise?




  parent reply	other threads:[~2019-03-20  0:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  1:54 Su Yanjun
2019-03-11 10:10 ` Steffen Klassert
2019-03-18 17:22   ` Eric Dumazet
2019-03-19 15:15     ` Steffen Klassert
2019-03-19 15:52       ` Eric Dumazet
2019-03-20  0:53       ` Su Yanjun <suyj.fnst@cn.fujitsu.com> [this message]
2019-03-20 17:16         ` Steffen Klassert

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=91cf303a-7d44-2c15-8b7a-8b2eb797a234@cn.fujitsu.com \
    --to=suyj.fnst@cn.fujitsu.com \
    --cc=davem@davemloft.net \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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

all inboxes | Powered by JetHome®