All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] net, sk_msg: Don't use RCU_INIT_POINTER on sk_user_data
@ 2020-04-02 12:55 Jakub Sitnicki
  2020-04-02 22:52 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Sitnicki @ 2020-04-02 12:55 UTC (permalink / raw)
  To: bpf; +Cc: netdev, kernel-team, Daniel Borkmann, kbuild test robot

sparse reports an error due to use of RCU_INIT_POINTER helper to assign to
sk_user_data pointer, which is not tagged with __rcu:

net/core/sock.c:1875:25: error: incompatible types in comparison expression (different address spaces):
net/core/sock.c:1875:25:    void [noderef] <asn:4> *
net/core/sock.c:1875:25:    void *

... and rightfully so. sk_user_data is not always treated as a pointer to
an RCU-protected data. When it is used to point at an RCU-protected object,
we access it with __sk_user_data to inform sparse about it.

In this case, when the child socket does not inherit sk_user_data from the
parent, there is no reason to treat it as an RCU-protected pointer.

Use a regular assignment to clear the pointer value.

Fixes: f1ff5ce2cd5e ("net, sk_msg: Clear sk_user_data pointer on clone if tagged")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
 net/core/sock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index da32d9b6d09f..0510826bf860 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1872,7 +1872,7 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority)
 		 * as not suitable for copying when cloning.
 		 */
 		if (sk_user_data_is_nocopy(newsk))
-			RCU_INIT_POINTER(newsk->sk_user_data, NULL);
+			newsk->sk_user_data = NULL;
 
 		newsk->sk_err	   = 0;
 		newsk->sk_err_soft = 0;
-- 
2.25.1


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

* Re: [PATCH bpf] net, sk_msg: Don't use RCU_INIT_POINTER on sk_user_data
  2020-04-02 12:55 [PATCH bpf] net, sk_msg: Don't use RCU_INIT_POINTER on sk_user_data Jakub Sitnicki
@ 2020-04-02 22:52 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2020-04-02 22:52 UTC (permalink / raw)
  To: Jakub Sitnicki, bpf; +Cc: netdev, kernel-team, kbuild test robot

On 4/2/20 2:55 PM, Jakub Sitnicki wrote:
> sparse reports an error due to use of RCU_INIT_POINTER helper to assign to
> sk_user_data pointer, which is not tagged with __rcu:
> 
> net/core/sock.c:1875:25: error: incompatible types in comparison expression (different address spaces):
> net/core/sock.c:1875:25:    void [noderef] <asn:4> *
> net/core/sock.c:1875:25:    void *
> 
> ... and rightfully so. sk_user_data is not always treated as a pointer to
> an RCU-protected data. When it is used to point at an RCU-protected object,
> we access it with __sk_user_data to inform sparse about it.
> 
> In this case, when the child socket does not inherit sk_user_data from the
> parent, there is no reason to treat it as an RCU-protected pointer.
> 
> Use a regular assignment to clear the pointer value.
> 
> Fixes: f1ff5ce2cd5e ("net, sk_msg: Clear sk_user_data pointer on clone if tagged")
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>

LGTM, applied, thanks!

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

end of thread, other threads:[~2020-04-02 22:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-02 12:55 [PATCH bpf] net, sk_msg: Don't use RCU_INIT_POINTER on sk_user_data Jakub Sitnicki
2020-04-02 22:52 ` Daniel Borkmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.