Skip to content

Commit c0019b7

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
NFSD: Fix exposure in nfsd4_decode_bitmap()
[email protected] reports: > nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC > directs it to do so. This can cause nfsd4_decode_state_protect4_a() > to write client-supplied data beyond the end of > nfsd4_exchange_id.spo_must_allow[] when called by > nfsd4_decode_exchange_id(). Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond @bmlen. Reported by: [email protected] Fixes: d1c263a ("NFSD: Replace READ* macros in nfsd4_decode_fattr()") Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 80479eb commit c0019b7

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen)
288288
p = xdr_inline_decode(argp->xdr, count << 2);
289289
if (!p)
290290
return nfserr_bad_xdr;
291-
i = 0;
292-
while (i < count)
293-
bmval[i++] = be32_to_cpup(p++);
294-
while (i < bmlen)
295-
bmval[i++] = 0;
291+
for (i = 0; i < bmlen; i++)
292+
bmval[i] = (i < count) ? be32_to_cpup(p++) : 0;
296293

297294
return nfs_ok;
298295
}

0 commit comments

Comments
 (0)