* [PATCH 1/1] sunrpc: clear rq_procinfo in svc_release_rqst to prevent double-free
[not found] <cover.1779253342.git.rakukuip@gmail.com>
@ 2026-05-20 8:13 ` Ren Wei
2026-05-20 10:46 ` Jeff Layton
0 siblings, 1 reply; 2+ messages in thread
From: Ren Wei @ 2026-05-20 8:13 UTC (permalink / raw)
To: linux-nfs, netdev
Cc: trondmy, anna, chuck.lever, jlayton, neil, okorniev, Dai.Ngo, tom,
yuantan098, yifanwucs, tomapufckgml, bird, rakukuip, n05ec
From: Luxiao Xu <rakukuip@gmail.com>
The svc_release_rqst() function unconditionally calls
rqstp->rq_procinfo->pc_release. However, svc_process_common()
does not clear rq_procinfo when a worker thread starts processing
a new request.
If a previous RPC selected a procedure with a non-idempotent
release hook, and the subsequent RPC takes an early error path
before a new rq_procinfo is installed (e.g., due to an oversized
RPC fragment, bad auth, or unknown program), the stale release
hook will run against reused state from the earlier RPC. This
leads to a double-free or use-after-free vulnerability.
Fix this by setting rqstp->rq_procinfo to NULL immediately after
executing the release hook in svc_release_rqst(), ensuring that
stale procedure hooks cannot be re-triggered on early errors.
Fixes: d9adbb6e10bf ("sunrpc: delay pc_release callback until after the reply is sent")
Cc: stable@kernel.org
Reported-by: Yuan Tan <yuantan098@gmail.com>
Reported-by: Yifan Wu <yifanwucs@gmail.com>
Reported-by: Juefei Pu <tomapufckgml@gmail.com>
Reported-by: Xin Liu <bird@lzu.edu.cn>
Signed-off-by: Luxiao Xu <rakukuip@gmail.com>
Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
---
net/sunrpc/svc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index d8ccb8e4b5c2..0332f05e7061 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -1572,8 +1572,10 @@ static void svc_release_rqst(struct svc_rqst *rqstp)
{
const struct svc_procedure *procp = rqstp->rq_procinfo;
- if (procp && procp->pc_release)
+ if (procp && procp->pc_release) {
procp->pc_release(rqstp);
+ rqstp->rq_procinfo = NULL;
+ }
}
/**
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/1] sunrpc: clear rq_procinfo in svc_release_rqst to prevent double-free
2026-05-20 8:13 ` [PATCH 1/1] sunrpc: clear rq_procinfo in svc_release_rqst to prevent double-free Ren Wei
@ 2026-05-20 10:46 ` Jeff Layton
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2026-05-20 10:46 UTC (permalink / raw)
To: Ren Wei, linux-nfs, netdev
Cc: trondmy, anna, chuck.lever, neil, okorniev, Dai.Ngo, tom,
yuantan098, yifanwucs, tomapufckgml, bird, rakukuip
On Wed, 2026-05-20 at 16:13 +0800, Ren Wei wrote:
> From: Luxiao Xu <rakukuip@gmail.com>
>
> The svc_release_rqst() function unconditionally calls
> rqstp->rq_procinfo->pc_release. However, svc_process_common()
> does not clear rq_procinfo when a worker thread starts processing
> a new request.
>
> If a previous RPC selected a procedure with a non-idempotent
> release hook, and the subsequent RPC takes an early error path
> before a new rq_procinfo is installed (e.g., due to an oversized
> RPC fragment, bad auth, or unknown program), the stale release
> hook will run against reused state from the earlier RPC. This
> leads to a double-free or use-after-free vulnerability.
>
> Fix this by setting rqstp->rq_procinfo to NULL immediately after
> executing the release hook in svc_release_rqst(), ensuring that
> stale procedure hooks cannot be re-triggered on early errors.
>
> Fixes: d9adbb6e10bf ("sunrpc: delay pc_release callback until after the reply is sent")
> Cc: stable@kernel.org
> Reported-by: Yuan Tan <yuantan098@gmail.com>
> Reported-by: Yifan Wu <yifanwucs@gmail.com>
> Reported-by: Juefei Pu <tomapufckgml@gmail.com>
> Reported-by: Xin Liu <bird@lzu.edu.cn>
> Signed-off-by: Luxiao Xu <rakukuip@gmail.com>
> Signed-off-by: Ren Wei <n05ec@lzu.edu.cn>
> ---
> net/sunrpc/svc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
> index d8ccb8e4b5c2..0332f05e7061 100644
> --- a/net/sunrpc/svc.c
> +++ b/net/sunrpc/svc.c
> @@ -1572,8 +1572,10 @@ static void svc_release_rqst(struct svc_rqst *rqstp)
> {
> const struct svc_procedure *procp = rqstp->rq_procinfo;
>
> - if (procp && procp->pc_release)
> + if (procp && procp->pc_release) {
> procp->pc_release(rqstp);
> + rqstp->rq_procinfo = NULL;
> + }
> }
>
> /**
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-20 10:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1779253342.git.rakukuip@gmail.com>
2026-05-20 8:13 ` [PATCH 1/1] sunrpc: clear rq_procinfo in svc_release_rqst to prevent double-free Ren Wei
2026-05-20 10:46 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox