[PATCH 0/2] Fix a few memory bugs in RPC-with-TLS
From: Chuck Lever <cel@kernel.org>
Date: 2026-05-04 10:28:43
Also in:
linux-nfs
xs_tcp_tls_setup_socket() leaks the lower rpc_clnt when a signal interrupts its TASK_KILLABLE wait for XPRT_LOCKED: the killed-wait path jumps to out_unlock without calling rpc_shutdown_client(), so the clnt and its xprt leak. Patch 1 calls rpc_shutdown_client() before joining out_unlock. Patch 2 fixes a use-after-free Michael Nemanov hit on an mTLS mount whose client certificate the server rejected. Nothing pins the upper rpc_clnt across the delayed connect_worker, so a fatal handshake failure can let the mount caller free the clnt before xs_tcp_tls_setup_socket() runs; the worker then dereferences freed memory. A new rpc_hold_client() helper takes a reference for TLS transports only and drops it on the worker's exit path. Compile-tested only. Recent related threads: [1] https://lore.kernel.org/linux-nfs/20260309112041.1336519-1-bsdhenrymartin@gmail.com/T/#u (local) [2] https://lore.kernel.org/linux-nfs/a57879782d2d383e2d1af292fe2b9005a43ea06c.1773263233.git.bcodding@hammerspace.com/T/#u (local) --- Chuck Lever (2): SUNRPC: release lower rpc_clnt if killed waiting for XPRT_LOCKED SUNRPC: pin upper rpc_clnt across the TLS connect_worker include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 19 +++++++++++++++++-- net/sunrpc/xprtsock.c | 16 ++++++++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) --- base-commit: 22ca5f8e836e43f49c9b622f60e7ee48012a81c3 change-id: 20260504-sunrpc-tls-clnt-pin-c1c678775ade Best regards, -- Chuck Lever [off-list ref]