nfsd: fix NULL dereference in setattr()
Subsystems (3)
PATCH 1/1 nfsd: fix NULL dereference in setattr()
The original code would oops if this were called from nfsd4_setattr() because "filpp" is NULL.
fs/nfsd/nfs4state.c +3 -2
@@ -3083,9 +3083,10 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,if (status) goto out;renew_client (dp->dl_client); -if (filpp) +if (filpp) { *filpp =find_readable_file (dp->dl_file); -BUG_ON (!*filpp); +BUG_ON (!*filpp); + } }else {/* open or lock stateid */ stp =find_stateid (stateid, flags);if (!stp)
Quoted 2 lines · Dan Carpenter
The original code would oops if this were called from
nfsd4_setattr()because "filpp" is NULL.
I believe it's impossible to reach this case: we never give out write delegations, so the preceding nfs4_check_delegmode will always fail when called from setattr.
We should do this anyway, but I'll probably queue it up for the next merge window.
--b.
Quoted 20 lines
Signed-off-by Dan Carpenter <[email protected]>fs/nfsd/nfs4state.c +3
-2@@ -3083,9 +3083,10 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,if (status) goto out;renew_client (dp->dl_client); -if (filpp) +if (filpp) { *filpp =find_readable_file (dp->dl_file); -BUG_ON (!*filpp); +BUG_ON (!*filpp); + } }else {/* open or lock stateid */ stp =find_stateid (stateid, flags);if (!stp)
Quoted 10 lines · J. Bruce Fields
Quoted 2 lines · Dan Carpenter
The original code would oops if this were called from
nfsd4_setattr()because "filpp" is NULL.I believe it's impossible to reach this case: we never give out write delegations, so the preceding
nfs4_check_delegmodewill always fail when called from setattr.We should do this anyway, but I'll probably queue it up for the next merge window.
Sounds good. This was a static checker patch not a run time bug (as you obviously realized).
regards,
dan carpenter