* [PATCH v2] net: mark racy access on sk->sk_rcvbuf
@ 2024-03-21 8:44 linke li
2024-03-25 13:59 ` Eric Dumazet
2024-03-25 15:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: linke li @ 2024-03-21 8:44 UTC (permalink / raw)
Cc: xujianhao01, linke li, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Kuniyuki Iwashima, Willem de Bruijn,
Abel Wu, Breno Leitao, Alexander Mikhalitsyn, David Howells,
netdev, linux-kernel
sk->sk_rcvbuf in __sock_queue_rcv_skb() and __sk_receive_skb() can be
changed by other threads. Mark this as benign using READ_ONCE().
This patch is aimed at reducing the number of benign races reported by
KCSAN in order to focus future debugging effort on harmful races.
Signed-off-by: linke li <lilinke99@qq.com>
---
v1 -> v2: include sk->sk_rcvbuf in __sock_queue_rcv_skb()
net/core/sock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index 5e78798456fd..61c14623a218 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -481,7 +481,7 @@ int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
unsigned long flags;
struct sk_buff_head *list = &sk->sk_receive_queue;
- if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
+ if (atomic_read(&sk->sk_rmem_alloc) >= READ_ONCE(sk->sk_rcvbuf)) {
atomic_inc(&sk->sk_drops);
trace_sock_rcvqueue_full(sk, skb);
return -ENOMEM;
@@ -551,7 +551,7 @@ int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
skb->dev = NULL;
- if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {
+ if (sk_rcvqueues_full(sk, READ_ONCE(sk->sk_rcvbuf))) {
atomic_inc(&sk->sk_drops);
goto discard_and_relse;
}
--
2.39.3 (Apple Git-146)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: mark racy access on sk->sk_rcvbuf
2024-03-21 8:44 [PATCH v2] net: mark racy access on sk->sk_rcvbuf linke li
@ 2024-03-25 13:59 ` Eric Dumazet
2024-03-25 15:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2024-03-25 13:59 UTC (permalink / raw)
To: linke li
Cc: xujianhao01, David S. Miller, Jakub Kicinski, Paolo Abeni,
Kuniyuki Iwashima, Willem de Bruijn, Abel Wu, Breno Leitao,
Alexander Mikhalitsyn, David Howells, netdev, linux-kernel
On Thu, Mar 21, 2024 at 9:44 AM linke li <lilinke99@qq.com> wrote:
>
> sk->sk_rcvbuf in __sock_queue_rcv_skb() and __sk_receive_skb() can be
> changed by other threads. Mark this as benign using READ_ONCE().
>
> This patch is aimed at reducing the number of benign races reported by
> KCSAN in order to focus future debugging effort on harmful races.
>
> Signed-off-by: linke li <lilinke99@qq.com>
> ---
> v1 -> v2: include sk->sk_rcvbuf in __sock_queue_rcv_skb()
Reviewed-by: Eric Dumazet <edumazet@google.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] net: mark racy access on sk->sk_rcvbuf
2024-03-21 8:44 [PATCH v2] net: mark racy access on sk->sk_rcvbuf linke li
2024-03-25 13:59 ` Eric Dumazet
@ 2024-03-25 15:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-25 15:00 UTC (permalink / raw)
To: linke li
Cc: xujianhao01, davem, edumazet, kuba, pabeni, kuniyu, willemb,
wuyun.abel, leitao, alexander, dhowells, netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Thu, 21 Mar 2024 16:44:10 +0800 you wrote:
> sk->sk_rcvbuf in __sock_queue_rcv_skb() and __sk_receive_skb() can be
> changed by other threads. Mark this as benign using READ_ONCE().
>
> This patch is aimed at reducing the number of benign races reported by
> KCSAN in order to focus future debugging effort on harmful races.
>
> Signed-off-by: linke li <lilinke99@qq.com>
>
> [...]
Here is the summary with links:
- [v2] net: mark racy access on sk->sk_rcvbuf
https://git.kernel.org/netdev/net/c/c2deb2e971f5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-03-25 15:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21 8:44 [PATCH v2] net: mark racy access on sk->sk_rcvbuf linke li
2024-03-25 13:59 ` Eric Dumazet
2024-03-25 15:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).