Skip to content

Commit c2deb2e

Browse files
linke lidavem330
authored andcommitted
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>
1 parent d6c30c5 commit c2deb2e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

net/core/sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ int __sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
482482
unsigned long flags;
483483
struct sk_buff_head *list = &sk->sk_receive_queue;
484484

485-
if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
485+
if (atomic_read(&sk->sk_rmem_alloc) >= READ_ONCE(sk->sk_rcvbuf)) {
486486
atomic_inc(&sk->sk_drops);
487487
trace_sock_rcvqueue_full(sk, skb);
488488
return -ENOMEM;
@@ -552,7 +552,7 @@ int __sk_receive_skb(struct sock *sk, struct sk_buff *skb,
552552

553553
skb->dev = NULL;
554554

555-
if (sk_rcvqueues_full(sk, sk->sk_rcvbuf)) {
555+
if (sk_rcvqueues_full(sk, READ_ONCE(sk->sk_rcvbuf))) {
556556
atomic_inc(&sk->sk_drops);
557557
goto discard_and_relse;
558558
}

0 commit comments

Comments
 (0)