memory leak in rds_sendmsg

Status: upstream: reported C repro on 2026/11/29 23:17
Subsystems: rds
Labels: prio:high
[Documentation on labels]
Reported-by: syzbot+b3f058b8e3b0d80d5bfb@syzkaller.appspotmail.com
First crash: 1d01h, last: 1d01h
✨ AI cause bisection: introduced by (AI job) :
commit 401910db4cd425899832a093539222b6174f92a2
Author: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Date: Tue Feb 27 17:52:43 2018 +0000

  rds: deliver zerocopy completion notification with data

✨ AI-generated root cause summary:

A struct rds_msg_zcopy_info object allocated in rds_message_zcopy_from_user() can be leaked when an RDS socket is closed before all of its queued zerocopy rds_message objects have been freed. rds_release() purges rs->rs_zcookie_queue after rds_send_drop_to(), which removes messages from the socket and connection queues but does not clear rm->m_rs or wait for transport references such as cp->cp_xmit_rm to be dropped. When the last reference to the rds_message is later released, rds_message_purge() unconditionally calls rds_rm_zerocopy_callback(), inserting the rds_msg_zcopy_info into rs->rs_zcookie_queue before calling sock_put() to drop the final socket reference. Because rds_sock_destruct() does not purge rs->rs_zcookie_queue, the socket is freed while the zcopy notification object remains linked in the now-freed queue.

▶ ▼ ✨ Full AI root cause analysis
Based on kernel commit 7cd8495c0f16:

Root Cause Analysis

The leaked 64-byte object is a struct rds_msg_zcopy_info allocated in rds_message_zcopy_from_user() (net/rds/message.c:456), with zcookies.num == 1, zcookies.cookies[0] == 0x42, and rs_zcookie_next pointing to &rs->rs_zcookie_queue.zcookie_head of a freed struct rds_sock.

Triggering Sequence and Violated Lifecycle Invariant

  1. Zerocopy allocation and queuing (rds_sendmsg -> rds_message_zcopy_from_user -> rds_send_queue_rm):

    • When sendmsg() is called on an AF_RDS socket with SO_ZEROCOPY and MSG_ZEROCOPY, rds_message_zcopy_from_user() (net/rds/message.c:442) allocates struct rds_msg_zcopy_info *info and stores &info->znotif in rm->data.op_mmp_znotifier.
    • rds_cmsg_send() -> rds_cmsg_zcopy() (net/rds/send.c:1057) records the user cookie (0x42) in rm->data.op_mmp_znotifier->z_cookie.
    • rds_send_queue_rm() (net/rds/send.c:905) queues rm onto rs->rs_send_queue and cp->cp_send_queue, sets rm->m_rs = rs, and takes a socket reference via sock_hold(rds_rs_to_sk(rs)).
  2. Transmission reference outliving socket close (rds_send_xmit):

    • rds_send_xmit() (net/rds/send.c:192) dequeues rm from cp->cp_send_queue, moves it to cp->cp_retrans, takes an additional reference via rds_message_addref(rm) (net/rds/send.c:332), and assigns cp->cp_xmit_rm = rm (net/rds/send.c:392).
    • If conn->c_trans->xmit() returns <= 0 (e.g., -EAGAIN turned into 0 or a connection error in rds_tcp_xmit()), rds_send_xmit() breaks out of its loop without clearing cp->cp_xmit_rm (net/rds/send.c:457-458), or rds_send_xmit() may still be running concurrently when the socket is closed.
  3. Premature zcopy queue purge in rds_release() (net/rds/af_rds.c:59):

    • On close(), rds_release() marks the socket SOCK_DEAD (sock_orphan(sk)), calls rds_send_drop_to(rs, NULL) (net/rds/af_rds.c:78), and then calls rds_notify_msg_zcopy_purge(&rs->rs_zcookie_queue) (net/rds/af_rds.c:81), followed by sock_put(sk) (net/rds/af_rds.c:90).
    • rds_send_drop_to() (net/rds/send.c:809) removes rm from rs->rs_send_queue and cp->cp_send_queue/cp->cp_retrans, drops those list references, and waits in rds_message_wait(rm) (net/rds/message.c:587) only for RDS_MSG_MAPPED (which is only set for RDMA/atomic operations, never for data payloads). It neither clears rm->m_rs nor waits for cp->cp_xmit_rm (or any concurrent rds_send_xmit()) to drop its reference.
    • As a result, rm remains alive with rm->m_rs == rs (keeping sk alive via sock_hold) after rds_notify_msg_zcopy_purge(&rs->rs_zcookie_queue) has already run.
  4. Post-release queuing in rds_message_purge() and missing cleanup in rds_sock_destruct():

    • When the final reference to rm is later dropped (for instance, in rds_send_path_reset() at net/rds/send.c:70-79 or rds_conn_path_destroy() at net/rds/connection.c:549-550), rds_message_put() calls rds_message_purge(rm) (net/rds/message.c:132).
    • Unlike the RDMA/atomic notification paths (rds_rdma_send_complete(), rds_send_remove_from_sock()), which check RDS_MSG_ON_SOCK before adding to rs->rs_notify_queue, rds_message_purge() (net/rds/message.c:146-155) unconditionally calls rds_rm_zerocopy_callback(rs, znotifier) whenever rm->m_rs is non-NULL, without checking sock_flag(rds_rs_to_sk(rs), SOCK_DEAD).
    • rds_rm_zerocopy_callback() (net/rds/message.c:94) initializes info->zcookies (num = 1, cookies[0] = 0x42) and links info->rs_zcookie_next onto rs->rs_zcookie_queue.zcookie_head.
    • rds_message_purge() then calls sock_put(rds_rs_to_sk(rs)), dropping the last reference to sk and invoking rds_sock_destruct() (net/rds/af_rds.c:669), which does not call rds_notify_msg_zcopy_purge(&rs->rs_zcookie_queue).
    • Consequently, rs is freed while info remains linked in rs->rs_zcookie_queue.zcookie_head, leaking the struct rds_msg_zcopy_info object.
▶ ▼ ✨ AI Jobs (2)
ID Workflow Result Correct Bug Created Started Finished Revision
3aeb77a2 bisect-cause IsRelease: ❌ ❓ memory leak in rds_sendmsg 2026/11/28 21:55 2026/11/28 21:56 2026/11/28 22:29 e1f06033
88cce323 assessment-security DenialOfService: ✅ Exploitable: ❌ FilesystemTrigger: ❌ FuzzingArtifact: ❌ MemoryCorruption: ❌ NetworkNeedsSetup: ✅ NetworkTrigger: ✅ PeripheralTrigger: ❌ RemoteTrigger: ❌ Unprivileged: ✅ UserNamespace: ✅ VMGuestTrigger: ❌ VMHostTrigger: ❌ ❓ memory leak in rds_sendmsg 2026/11/28 21:47 2026/11/28 21:48 2026/11/28 22:25 e1f06033
▶ ▼ Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [rds?] memory leak in rds_sendmsg 0 (1) 2026/11/29 23:17

Sample crash report:
BUG: memory leak
unreferenced object 0xffff88812a3e1880 (size 64):
  comm "syz.5.22", pid 5979, jiffies 4294947590
  hex dump (first 32 bytes):
    d8 2c fa 09 81 88 ff ff d8 2c fa 09 81 88 ff ff  .,.......,......
    01 00 00 00 42 00 00 00 00 00 00 00 00 00 00 00  ....B...........
  backtrace (crc cc362ab):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4733 [inline]
    slab_alloc_node mm/slub.c:5033 [inline]
    __kmalloc_cache_noprof+0x35f/0x3f0 mm/slub.c:5676
    _kmalloc_noprof include/linux/slab.h:991 [inline]
    _kzalloc_noprof include/linux/slab.h:1312 [inline]
    rds_message_zcopy_from_user net/rds/message.c:456 [inline]
    rds_message_copy_from_user+0x219/0x4d0 net/rds/message.c:513
    rds_sendmsg+0x1486/0x1d00 net/rds/send.c:1338
    sock_sendmsg_nosec net/socket.c:800 [inline]
    __sock_sendmsg net/socket.c:818 [inline]
    ____sys_sendmsg+0x54a/0x580 net/socket.c:2713
    ___sys_sendmsg+0x12c/0x160 net/socket.c:2770
    __sys_sendmsg+0xcd/0x140 net/socket.c:2802
    do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
    do_syscall_64+0xe9/0x540 arch/x86/entry/syscall_64.c:89
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

BUG: memory leak
unreferenced object 0xffff8881274f96c0 (size 64):
  comm "syz.2.19", pid 6180, jiffies 4294947912
  hex dump (first 32 bytes):
    d8 1a 5b 03 81 88 ff ff d8 1a 5b 03 81 88 ff ff  ..[.......[.....
    01 00 00 00 42 00 00 00 00 00 00 00 00 00 00 00  ....B...........
  backtrace (crc fce564):
    kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
    slab_post_alloc_hook mm/slub.c:4733 [inline]
    slab_alloc_node mm/slub.c:5033 [inline]
    __kmalloc_cache_noprof+0x35f/0x3f0 mm/slub.c:5676
    _kmalloc_noprof include/linux/slab.h:991 [inline]
    _kzalloc_noprof include/linux/slab.h:1312 [inline]
    rds_message_zcopy_from_user net/rds/message.c:456 [inline]
    rds_message_copy_from_user+0x219/0x4d0 net/rds/message.c:513
    rds_sendmsg+0x1486/0x1d00 net/rds/send.c:1338
    sock_sendmsg_nosec net/socket.c:800 [inline]
    __sock_sendmsg net/socket.c:818 [inline]
    ____sys_sendmsg+0x54a/0x580 net/socket.c:2713
    ___sys_sendmsg+0x12c/0x160 net/socket.c:2770
    __sys_sendmsg+0xcd/0x140 net/socket.c:2802
    do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
    do_syscall_64+0xe9/0x540 arch/x86/entry/syscall_64.c:89
    entry_SYSCALL_64_after_hwframe+0x77/0x7f

connection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF

Crashes (1):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2026/11/28 21:47 upstream 7cd8495c0f16 e1f06033 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-gce-leak memory leak in rds_sendmsg
* Struck through repros no longer work on HEAD.