FAILED: patch "[PATCH] net: rds: acquire refcount on TCP sockets" failed to apply to 5.15-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 3a58f13a881ed351198ffab4cf9953cf19d2ab3a Mon Sep 17 00:00:00 2001
From: Tetsuo Handa <[email protected]>
Date: Mon, 2 May 2022 10:40:18 +0900
Subject: [PATCH] net: rds: acquire refcount on TCP sockets
syzbot is reporting use-after-free read in tcp_retransmit_timer() [1], for TCP socket used by RDS is accessing sock_net() without acquiring a refcount on net namespace. Since TCP's retransmission can happen after a process which created net namespace terminated, we need to explicitly acquire a refcount.
net/rds/tcp.c +8 -0
@@ -495,6 +495,14 @@ void rds_tcp_tune(struct socket *sock)tcp_sock_set_nodelay (sock->sk);lock_sock (sk); +/* TCP timer functions might access net namespace even after +* a process which created this net namespace terminated. +*/ +if (!sk->sk_net_refcnt) { + sk->sk_net_refcnt =1 ; +get_net_track (net, &sk->ns_tracker,GFP_KERNEL ); +sock_inuse_add (net,1 ); + }if (rtn->sndbuf_size >0 ) { sk->sk_sndbuf = rtn->sndbuf_size; sk->sk_userlocks |=SOCK_SNDBUF_LOCK ;