]> git.ipfire.org Git - thirdparty/linux.git/commit
rds_tcp: close NULL deref window in rds_tcp_set_callbacks
authorMaoyi Xie <maoyixie.tju@gmail.com>
Tue, 12 May 2026 14:28:07 +0000 (22:28 +0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 May 2026 00:06:59 +0000 (17:06 -0700)
commitd2bfdbb69cf87676981b1043010b6224d84c6d3a
tree1a032d5aa5fa0e4a35b61502f44d9c98052eeccc
parent66182ca873a4e87b3496eca79d57f86b76d7f52d
rds_tcp: close NULL deref window in rds_tcp_set_callbacks

rds_tcp_set_callbacks() links a new rds_tcp_connection onto
rds_tcp_tc_list under rds_tcp_tc_list_lock. It releases the
lock, then assigns tc->t_sock = sock outside the lock.

rds_tcp_tc_info() and rds6_tcp_tc_info() walk rds_tcp_tc_list
under the same lock. Both dereference tc->t_sock->sk without
a NULL check.

A reader can acquire rds_tcp_tc_list_lock between the writer's
spin_unlock and the t_sock store. It then sees a list entry
whose t_sock is NULL. The dereference of tc->t_sock->sk is a
NULL access.

Move tc->t_sock = sock inside rds_tcp_tc_list_lock, before
list_add_tail. A reader holding the lock then observes the
linkage and the t_sock store together.

The restore path is safe. rds_tcp_restore_callbacks() does
list_del_init inside the lock. The matching tc->t_sock = NULL
after unlink is harmless to readers holding the lock.

Fixes: 70041088e3b9 ("RDS: Add TCP transport to RDS")
Suggested-by: Simon Horman <horms@kernel.org>
Signed-off-by: Maoyi Xie <maoyi.xie@ntu.edu.sg>
Reviewed-by: Allison Henderson <achender@kernel.org>
Link: https://patch.msgid.link/20260512142807.1855619-1-maoyi.xie@ntu.edu.sg
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/rds/tcp.c