net: xfrm: Add '_rcu' tag for rcu protected pointer in netns_xfrm

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>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Su Yanjun
2019-03-08 13:17:31 +01:00
committed by Steffen Klassert
parent 6ed69184ed
commit f10e0010fa
2 changed files with 24 additions and 8 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ struct netns_xfrm {
struct list_head inexact_bins;
struct sock *nlsk;
struct sock __rcu *nlsk;
struct sock *nlsk_stash;
u32 sysctl_aevent_etime;