Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: mark racy access on sk->sk_rcvbuf

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>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

linke li and committed by
David S. Miller
c2deb2e9 d6c30c5a

+2 -2
+2 -2
net/core/sock.c
··· 482 482 unsigned long flags; 483 483 struct sk_buff_head *list = &sk->sk_receive_queue; 484 484 485 - if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) { 485 + if (atomic_read(&sk->sk_rmem_alloc) >= READ_ONCE(sk->sk_rcvbuf)) { 486 486 atomic_inc(&sk->sk_drops); 487 487 trace_sock_rcvqueue_full(sk, skb); 488 488 return -ENOMEM; ··· 552 552 553 553 skb->dev = NULL; 554 554 555 - if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) { 555 + if (sk_rcvqueues_full(sk, READ_ONCE(sk->sk_rcvbuf))) { 556 556 atomic_inc(&sk->sk_drops); 557 557 goto discard_and_relse; 558 558 }