]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net/rds: Fix NULL pointer dereference in rds_tcp_accept_one
authorAllison Henderson <achender@kernel.org>
Mon, 16 Feb 2026 22:26:43 +0000 (15:26 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 19 Feb 2026 14:57:56 +0000 (15:57 +0100)
commit6bf45704a92a128a8bfb2dd4d550c61b257c8f9a
treec566dd75887c6a9424173091d4ca0806b268a73f
parent45be47bf5d7db0f762a93e9c0ede6cb3c91edf3b
net/rds: Fix NULL pointer dereference in rds_tcp_accept_one

Save a local pointer to new_sock->sk and hold a reference before
installing callbacks in rds_tcp_accept_one. After
rds_tcp_set_callbacks() or rds_tcp_reset_callbacks(), tc->t_sock is
set to new_sock which may race with the shutdown path.  A concurrent
rds_tcp_conn_path_shutdown() may call sock_release(), which sets
new_sock->sk = NULL and may eventually free sk when the refcount
reaches zero.

Subsequent accesses to new_sock->sk->sk_state would dereference NULL,
causing the crash. The fix saves a local sk pointer before callbacks
are installed so that sk_state can be accessed safely even after
new_sock->sk is nulled, and uses sock_hold()/sock_put() to ensure
sk itself remains valid for the duration.

Fixes: 826c1004d4ae ("net/rds: rds_tcp_conn_path_shutdown must not discard messages")
Reported-by: syzbot+96046021045ffe6d7709@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=96046021045ffe6d7709
Signed-off-by: Allison Henderson <achender@kernel.org>
Link: https://patch.msgid.link/20260216222643.2391390-1-achender@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/rds/tcp_listen.c