Skip to content

Commit 804d8e0

Browse files
committed
NFSD: Avoid calling OPDESC() with ops->opnum == OP_ILLEGAL
OPDESC() simply indexes into nfsd4_ops[] by the op's operation number, without range checking that value. It assumes callers are careful to avoid calling it with an out-of-bounds opnum value. nfsd4_decode_compound() is not so careful, and can invoke OPDESC() with opnum set to OP_ILLEGAL, which is 10044 -- well beyond the end of nfsd4_ops[]. Reported-by: Jeff Layton <[email protected]> Fixes: f4f9ef4 ("nfsd4: opdesc will be useful outside nfs4proc.c") Signed-off-by: Chuck Lever <[email protected]>
1 parent 5f24a87 commit 804d8e0

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2476,10 +2476,12 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
24762476
for (i = 0; i < argp->opcnt; i++) {
24772477
op = &argp->ops[i];
24782478
op->replay = NULL;
2479+
op->opdesc = NULL;
24792480

24802481
if (xdr_stream_decode_u32(argp->xdr, &op->opnum) < 0)
24812482
return false;
24822483
if (nfsd4_opnum_in_range(argp, op)) {
2484+
op->opdesc = OPDESC(op);
24832485
op->status = nfsd4_dec_ops[op->opnum](argp, &op->u);
24842486
if (op->status != nfs_ok)
24852487
trace_nfsd_compound_decode_err(argp->rqstp,
@@ -2490,7 +2492,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp)
24902492
op->opnum = OP_ILLEGAL;
24912493
op->status = nfserr_op_illegal;
24922494
}
2493-
op->opdesc = OPDESC(op);
2495+
24942496
/*
24952497
* We'll try to cache the result in the DRC if any one
24962498
* op in the compound wants to be cached:

0 commit comments

Comments
 (0)