Skip to content

Commit

Permalink
nfsd: fix NULL dereference in nfs3svc_encode_getaclres
Browse files Browse the repository at this point in the history
In error cases the dentry may be NULL.

Before 20798df, the encoder also checked dentry and
d_really_is_positive(dentry), but that looks like overkill to me--zero
status should be enough to guarantee a positive dentry.

This isn't the first time we've seen an error-case NULL dereference
hidden in the initialization of a local variable in an xdr encoder.  But
I went back through the other recent rewrites and didn't spot any
similar bugs.

Reported-by: JianHong Yin <[email protected]>
Reviewed-by: Chuck Lever III <[email protected]>
Fixes: 20798df ("NFSD: Update the NFSv3 GETACL result encoder...")
Signed-off-by: J. Bruce Fields <[email protected]>
  • Loading branch information
J. Bruce Fields committed Jul 7, 2021
1 parent 7b08cf6 commit ab1016d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion fs/nfsd/nfs3acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
struct nfsd3_getaclres *resp = rqstp->rq_resp;
struct dentry *dentry = resp->fh.fh_dentry;
struct kvec *head = rqstp->rq_res.head;
struct inode *inode = d_inode(dentry);
struct inode *inode;
unsigned int base;
int n;
int w;
Expand All @@ -181,6 +181,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
return 0;
switch (resp->status) {
case nfs_ok:
inode = d_inode(dentry);
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
return 0;
if (xdr_stream_encode_u32(xdr, resp->mask) < 0)
Expand Down

0 comments on commit ab1016d

Please sign in to comment.