mirror-linux/net/rds
Maoyi Xie d2bfdbb69c 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: 70041088e3 ("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>
2026-05-14 17:06:59 -07:00
..
Kconfig net: rds: add option for GCOV profiling 2024-08-09 13:18:46 +01:00
Makefile net: rds: add option for GCOV profiling 2024-08-09 13:18:46 +01:00
af_rds.c net/rds: Restrict use of RDS/IB to the initial network namespace 2026-04-12 13:33:19 -07:00
bind.c net: Convert proto_ops bind() callbacks to use sockaddr_unsized 2025-11-04 19:10:32 -08:00
cong.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
connection.c net/rds: zero per-item info buffer before handing it to visitors 2026-04-22 21:05:16 -07:00
ib.c net/rds: Restrict use of RDS/IB to the initial network namespace 2026-04-12 13:33:19 -07:00
ib.h net/rds: Optimize rds_ib_laddr_check 2026-04-12 13:33:19 -07:00
ib_cm.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
ib_frmr.c rds: ib: Increment i_fastreg_wrs before bailing out 2025-09-15 16:47:53 -07:00
ib_mr.h rds: ib: Remove unused extern definition 2025-09-08 18:16:49 -07:00
ib_rdma.c net/rds: Optimize rds_ib_laddr_check 2026-04-12 13:33:19 -07:00
ib_recv.c net/rds: Add per cp work queue 2026-01-13 12:27:03 +01:00
ib_ring.c rds: Fix spelling mistakes 2021-05-31 22:45:05 -07:00
ib_send.c net/rds: new extension header: rdma bytes 2026-02-04 20:46:38 -08:00
ib_stats.c
ib_sysctl.c net: rds: Remove the now superfluous sentinel elements from ctl_table array 2024-05-03 13:29:42 +01:00
info.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
info.h
loop.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
loop.h
message.c net/rds: reset op_nents when zerocopy page pin fails 2026-05-11 17:20:02 -07:00
page.c rds: Use nested-BH locking for rds_page_remainder 2025-05-15 15:23:31 +02:00
rdma.c net: rds: fix MR cleanup on copy error 2026-04-23 12:18:08 -07:00
rdma_transport.c net: rds: Fix possible NULL-pointer dereference 2023-09-20 08:49:03 +01:00
rdma_transport.h net/rds: Remove unused function declarations 2023-08-13 12:25:42 +01:00
rds.h net/rds: Trigger rds_send_ping() more than once 2026-02-04 20:46:39 -08:00
rds_single_path.h
recv.c net/rds: Trigger rds_send_ping() more than once 2026-02-04 20:46:39 -08:00
send.c rds: update outdated comment 2026-02-25 19:03:55 -08:00
stats.c net/rds: Use the first lane until RDS_EXTHDR_NPATHS arrives 2026-02-04 20:46:39 -08:00
sysctl.c net: rds: Remove the now superfluous sentinel elements from ctl_table array 2024-05-03 13:29:42 +01:00
tcp.c rds_tcp: close NULL deref window in rds_tcp_set_callbacks 2026-05-14 17:06:59 -07:00
tcp.h net/rds: Trigger rds_send_ping() more than once 2026-02-04 20:46:39 -08:00
tcp_connect.c net/rds: rds_tcp_conn_path_shutdown must not discard messages 2026-02-04 20:46:38 -08:00
tcp_listen.c net/rds: fix recursive lock in rds_tcp_conn_slots_available 2026-02-24 10:11:04 +01:00
tcp_recv.c net/rds: rds_tcp_conn_path_shutdown must not discard messages 2026-02-04 20:46:38 -08:00
tcp_send.c net/rds: rds_tcp_conn_path_shutdown must not discard messages 2026-02-04 20:46:38 -08:00
tcp_stats.c
threads.c net/rds: Add per cp work queue 2026-01-13 12:27:03 +01:00
transport.c