Message ID | 20210630164244.2180977-1-eric.dumazet@gmail.com |
---|---|
State | New |
Headers | show |
Series | [net] udp: annotate data races around unix_sk(sk)->gso_size | expand |
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Wed, 30 Jun 2021 09:42:44 -0700 you wrote: > From: Eric Dumazet <edumazet@google.com> > > Accesses to unix_sk(sk)->gso_size are lockless. > Add READ_ONCE()/WRITE_ONCE() around them. > > BUG: KCSAN: data-race in udp_lib_setsockopt / udpv6_sendmsg > > [...] Here is the summary with links: - [net] udp: annotate data races around unix_sk(sk)->gso_size https://git.kernel.org/netdev/net/c/18a419bad63b You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 62682807b4b2b8bdc2baf2205395ff78f253acf9..62cd4cd52e8481599f5e98c6022c96067e800f2d 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1102,7 +1102,7 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } ipcm_init_sk(&ipc, inet); - ipc.gso_size = up->gso_size; + ipc.gso_size = READ_ONCE(up->gso_size); if (msg->msg_controllen) { err = udp_cmsg_send(sk, msg, &ipc.gso_size); @@ -2695,7 +2695,7 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname, case UDP_SEGMENT: if (val < 0 || val > USHRT_MAX) return -EINVAL; - up->gso_size = val; + WRITE_ONCE(up->gso_size, val); break; case UDP_GRO: @@ -2790,7 +2790,7 @@ int udp_lib_getsockopt(struct sock *sk, int level, int optname, break; case UDP_SEGMENT: - val = up->gso_size; + val = READ_ONCE(up->gso_size); break; case UDP_GRO: diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 368972dbd91961e9915d4f6b1fd9542a8d8ed139..0cc7ba531b34157feca74b876b3aa5a4013fec04 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -1296,7 +1296,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) int (*getfrag)(void *, char *, int, int, int, struct sk_buff *); ipcm6_init(&ipc6); - ipc6.gso_size = up->gso_size; + ipc6.gso_size = READ_ONCE(up->gso_size); ipc6.sockc.tsflags = sk->sk_tsflags; ipc6.sockc.mark = sk->sk_mark;