Patch "net: annotate data-race around sk->sk_txrehash" has been added to the 6.4-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: annotate data-race around sk->sk_txrehash

to the 6.4-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-annotate-data-race-around-sk-sk_txrehash.patch
and it can be found in the queue-6.4 subdirectory.

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



commit 61540bad61147bf9a5bf03c521e702f2bbbec2ba
Author: Eric Dumazet <edumazet@xxxxxxxxxx>
Date:   Fri Jul 28 15:03:09 2023 +0000

    net: annotate data-race around sk->sk_txrehash
    
    [ Upstream commit c76a0328899bbe226f8adeb88b8da9e4167bd316 ]
    
    sk_getsockopt() runs locklessly. This means sk->sk_txrehash
    can be read while other threads are changing its value.
    
    Other locations were handled in commit cb6cd2cec799
    ("tcp: Change SYN ACK retransmit behaviour to account for rehash")
    
    Fixes: 26859240e4ee ("txhash: Add socket option to control TX hash rethink behavior")
    Signed-off-by: Eric Dumazet <edumazet@xxxxxxxxxx>
    Cc: Akhmat Karakotov <hmukos@xxxxxxxxxxxxxx>
    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 7b88290ddc6e7..b25511e7e8103 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1523,7 +1523,9 @@ int sk_setsockopt(struct sock *sk, int level, int optname,
 		}
 		if ((u8)val == SOCK_TXREHASH_DEFAULT)
 			val = READ_ONCE(sock_net(sk)->core.sysctl_txrehash);
-		/* Paired with READ_ONCE() in tcp_rtx_synack() */
+		/* Paired with READ_ONCE() in tcp_rtx_synack()
+		 * and sk_getsockopt().
+		 */
 		WRITE_ONCE(sk->sk_txrehash, (u8)val);
 		break;
 
@@ -1930,7 +1932,8 @@ int sk_getsockopt(struct sock *sk, int level, int optname,
 		break;
 
 	case SO_TXREHASH:
-		v.val = sk->sk_txrehash;
+		/* Paired with WRITE_ONCE() in sk_setsockopt() */
+		v.val = READ_ONCE(sk->sk_txrehash);
 		break;
 
 	default:



[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