linux/net/rds
Weiming Shi a54ecccfae rds: ib: reject FRMR registration before IB connection is established
rds_ib_get_mr() extracts the rds_ib_connection from conn->c_transport_data
and passes it to rds_ib_reg_frmr() for FRWR memory registration. On a
fresh outgoing connection, ic is allocated in rds_ib_conn_alloc() with
i_cm_id = NULL because the connection worker has not yet called
rds_ib_conn_path_connect() to create the rdma_cm_id. When sendmsg() with
RDS_CMSG_RDMA_MAP is called on such a connection, the sendmsg path parses
the control message before any connection establishment, allowing
rds_ib_post_reg_frmr() to dereference ic->i_cm_id->qp and crash the
kernel.

The existing guard in rds_ib_reg_frmr() only checks for !ic (added in
commit 9e630bcb77), which does not catch this case since ic is allocated
early and is always non-NULL once the connection object exists.

 KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
 RIP: 0010:rds_ib_post_reg_frmr+0x50e/0x920
 Call Trace:
  rds_ib_post_reg_frmr (net/rds/ib_frmr.c:167)
  rds_ib_map_frmr (net/rds/ib_frmr.c:252)
  rds_ib_reg_frmr (net/rds/ib_frmr.c:430)
  rds_ib_get_mr (net/rds/ib_rdma.c:615)
  __rds_rdma_map (net/rds/rdma.c:295)
  rds_cmsg_rdma_map (net/rds/rdma.c:860)
  rds_sendmsg (net/rds/send.c:1363)
  ____sys_sendmsg
  do_syscall_64

Add a check in rds_ib_get_mr() that verifies ic, i_cm_id, and qp are all
non-NULL before proceeding with FRMR registration, mirroring the guard
already present in rds_ib_post_inv(). Return -ENODEV when the connection
is not ready, which the existing error handling in rds_cmsg_send() converts
to -EAGAIN for userspace retry and triggers rds_conn_connect_if_down() to
start the connection worker.

Fixes: 1659185fb4 ("RDS: IB: Support Fastreg MR (FRMR) memory registration mode")
Reported-by: Xiang Mei <xmei5@asu.edu>
Signed-off-by: Weiming Shi <bestswngs@gmail.com>
Reviewed-by: Allison Henderson <achender@kernel.org>
Link: https://patch.msgid.link/20260330163237.2752440-2-bestswngs@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-04-01 17:52:40 -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: Convert proto_ops connect() callbacks to use sockaddr_unsized 2025-11-04 19:10:32 -08: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 Including fixes from IPsec, Bluetooth and netfilter 2026-02-26 08:00:13 -08:00
ib.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
ib.h RDS: IB: Remove unused declarations 2024-08-01 09:03:28 -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 rds: ib: reject FRMR registration before IB connection is established 2026-04-01 17:52:40 -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 net/rds: Fix 'ib_evt_handler_call' element in 'rds_ib_stat_names' 2019-09-15 20:56:19 +02:00
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 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
loop.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
loop.h rds: clean up loopback rds_connections on netns deletion 2018-06-27 10:11:03 +09:00
message.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
page.c rds: Use nested-BH locking for rds_page_remainder 2025-05-15 15:23:31 +02:00
rdma.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08: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 License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
recv.c net/rds: Trigger rds_send_ping() more than once 2026-02-04 20:46:39 -08:00
send.c net/rds: rds_sendmsg should not discard payload_len 2026-02-17 12:03:57 +01: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 net/rds: Fix circular locking dependency in rds_tcp_tune 2026-03-03 12:57:06 +01: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 rds: transport module should be auto loaded when transport is set 2020-06-25 16:26:25 -07:00