Patch "net: add missing data-race annotations around sk->sk_peek_off" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: add missing data-race annotations around sk->sk_peek_off

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-add-missing-data-race-annotations-around-sk-sk_p.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 368ba963fa4cc93203e2db975a4bf03cb7aaed27
Author: Eric Dumazet <edumazet@xxxxxxxxxx>
Date:   Fri Jul 28 15:03:16 2023 +0000

    net: add missing data-race annotations around sk->sk_peek_off
    
    [ Upstream commit 11695c6e966b0ec7ed1d16777d294cef865a5c91 ]
    
    sk_getsockopt() runs locklessly, thus we need to annotate the read
    of sk->sk_peek_off.
    
    While we are at it, add corresponding annotations to sk_set_peek_off()
    and unix_set_peek_off().
    
    Fixes: b9bb53f3836f ("sock: convert sk_peek_offset functions to WRITE_ONCE")
    Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx>
    Cc: Willem de Bruijn <willemb@xxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/core/sock.c b/net/core/sock.c
index 708018b58e906..a241734b10240 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1517,7 +1517,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 		if (!sock->ops->set_peek_off)
 			return -EOPNOTSUPP;
 
-		v.val = sk->sk_peek_off;
+		v.val = READ_ONCE(sk->sk_peek_off);
 		break;
 	case SO_NOFCS:
 		v.val = sock_flag(sk, SOCK_NOFCS);
@@ -2745,7 +2745,7 @@ EXPORT_SYMBOL(__sk_mem_reclaim);
 
 int sk_set_peek_off(struct sock *sk, int val)
 {
-	sk->sk_peek_off = val;
+	WRITE_ONCE(sk->sk_peek_off, val);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(sk_set_peek_off);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 2fe0efcbfed16..3aa783a23c5f6 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -697,7 +697,7 @@ static int unix_set_peek_off(struct sock *sk, int val)
 	if (mutex_lock_interruptible(&u->iolock))
 		return -EINTR;
 
-	sk->sk_peek_off = val;
+	WRITE_ONCE(sk->sk_peek_off, val);
 	mutex_unlock(&u->iolock);
 
 	return 0;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux