linux/net/sunrpc
Jeff Layton f18c1f2a88 sunrpc: fix cache_request leak in cache_release
commit 17ad31b3a4 upstream.

When a reader's file descriptor is closed while in the middle of reading
a cache_request (rp->offset != 0), cache_release() decrements the
request's readers count but never checks whether it should free the
request.

In cache_read(), when readers drops to 0 and CACHE_PENDING is clear, the
cache_request is removed from the queue and freed along with its buffer
and cache_head reference. cache_release() lacks this cleanup.

The only other path that frees requests with readers == 0 is
cache_dequeue(), but it runs only when CACHE_PENDING transitions from
set to clear. If that transition already happened while readers was
still non-zero, cache_dequeue() will have skipped the request, and no
subsequent call will clean it up.

Add the same cleanup logic from cache_read() to cache_release(): after
decrementing readers, check if it reached 0 with CACHE_PENDING clear,
and if so, dequeue and free the cache_request.

Reported-by: NeilBrown <neilb@ownmail.net>
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable@kernel.org
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-04-18 10:33:17 +02:00
..
auth_gss SUNRPC: fix gss_auth kref leak in gss_alloc_msg error path 2026-03-04 07:19:55 -05:00
xprtrdma xprtrdma: Decrement re_receiving on the early exit paths 2026-04-18 10:33:11 +02:00
addr.c net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() 2024-03-26 18:21:33 -04:00
auth.c sunrpc: fix expiry of auth creds 2022-08-25 11:40:05 +02:00
auth_null.c SUNRPC: Add rpc_auth::au_ralign field 2019-02-14 11:48:36 -05:00
auth_unix.c SUNRPC: Use the client user namespace when encoding creds 2019-04-26 16:24:32 -04:00
backchannel_rqst.c SUNRPC: Reinitialise the backchannel request buffers before reuse 2022-08-25 11:40:05 +02:00
cache.c sunrpc: fix cache_request leak in cache_release 2026-04-18 10:33:17 +02:00
clnt.c SUNRPC: rpc_clnt_set_transport() must not change the autobind setting 2025-06-04 14:37:55 +02:00
debugfs.c NFS Client Updates for Linux 5.15 2021-09-04 10:25:26 -07:00
fail.h SUNRPC: Server-side disconnect injection 2021-08-20 13:50:33 -04:00
Kconfig SUNRPC: remove RC4-HMAC-MD5 support from KerberosV 2020-09-11 14:39:15 +10:00
Makefile sunrpc: Create a sunrpc directory under /sys/kernel/ 2021-07-08 14:03:23 -04:00
netns.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
rpc_pipe.c fsnotify: fix fsnotify hooks in pseudo filesystems 2022-02-01 17:27:01 +01:00
rpcb_clnt.c SUNRPC: rpcbind should never reset the port to the value '0' 2025-06-04 14:37:55 +02:00
sched.c SUNRPC: Fix a race to wake a sync task 2024-08-19 05:45:39 +02:00
socklib.c skb_copy_and_csum_bits(): don't bother with the last argument 2020-08-20 15:45:13 -04:00
socklib.h SUNRPC: Refactor xs_sendpages() 2020-03-16 12:04:33 -04:00
stats.c sunrpc: use the struct net as the svc proc private 2024-09-04 13:23:30 +02:00
sunrpc.h Replace HTTP links with HTTPS ones: NFS, SUNRPC, and LOCKD clients 2020-09-21 10:21:10 -04:00
sunrpc_syms.c sunrpc: add IDs to multipath 2021-07-08 14:03:23 -04:00
svc.c sunrpc: pass in the sv_stats struct through svc_create_pooled 2024-09-04 13:23:30 +02:00
svc_xprt.c sunrpc: exclude from freezer when waiting for requests: 2024-06-16 13:39:55 +02:00
svcauth.c SUNRPC: Add svc_rqst::rq_auth_stat 2021-08-10 14:18:35 -04:00
svcauth_unix.c sunrpc: only free unix grouplist after RCU settles 2023-04-13 16:48:19 +02:00
svcsock.c nfsd: fix double fget() bug in __write_ports_addfd() 2024-04-10 16:19:28 +02:00
sysctl.c net/sunrpc: fix useless comparison in proc_do_xprt() 2020-11-08 16:28:25 -05:00
sysfs.c SUNRPC: Fix null-ptr-deref when xps sysfs alloc failed 2022-11-10 18:15:26 +01:00
sysfs.h SUNRPC: take a xprt offline using sysfs 2021-07-08 14:03:24 -04:00
timer.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00
xdr.c NFSD: Refactor common code out of dirlist helpers 2024-04-10 16:19:17 +02:00
xprt.c timers: Get rid of del_singleshot_timer_sync() 2026-02-11 13:35:27 +01:00
xprtmultipath.c SUNRPC: Fix a suspicious RCU usage warning 2024-02-23 08:54:40 +01:00
xprtsock.c sunrpc: clear XPRT_SOCK_UPD_TIMEOUT when reset transport 2024-12-14 19:51:21 +01:00