Skip to content

Commit

Permalink
sunrpc: fix prog selection loop in svc_process_common
Browse files Browse the repository at this point in the history
If the rq_prog is not in the list of programs, then we use the last
program in the list and we don't get the expected rpc_prog_unavail error
as the subsequent tests on 'progp' being NULL are ineffective.

We should only assign progp when we find the right program, and we
should initialize it to NULL

Reported-by: Dan Carpenter <[email protected]>
Fixes: 86ab08b ("SUNRPC: replace program list with program array")
Signed-off-by: NeilBrown <[email protected]>
Acked-by: Chuck Lever <[email protected]>
Signed-off-by: Anna Schumaker <[email protected]>
  • Loading branch information
neilbrown authored and Anna Schumaker committed Sep 30, 2024
1 parent 37578c6 commit 1d498df
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions net/sunrpc/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ static int
svc_process_common(struct svc_rqst *rqstp)
{
struct xdr_stream *xdr = &rqstp->rq_res_stream;
struct svc_program *progp;
struct svc_program *progp = NULL;
const struct svc_procedure *procp = NULL;
struct svc_serv *serv = rqstp->rq_server;
struct svc_process_info process;
Expand Down Expand Up @@ -1351,12 +1351,9 @@ svc_process_common(struct svc_rqst *rqstp)
rqstp->rq_vers = be32_to_cpup(p++);
rqstp->rq_proc = be32_to_cpup(p);

for (pr = 0; pr < serv->sv_nprogs; pr++) {
progp = &serv->sv_programs[pr];

if (rqstp->rq_prog == progp->pg_prog)
break;
}
for (pr = 0; pr < serv->sv_nprogs; pr++)
if (rqstp->rq_prog == serv->sv_programs[pr].pg_prog)
progp = &serv->sv_programs[pr];

/*
* Decode auth data, and add verifier to reply buffer.
Expand Down

0 comments on commit 1d498df

Please sign in to comment.