Skip to content

Commit ab1016d

Browse files
author
J. Bruce Fields
committed
nfsd: fix NULL dereference in nfs3svc_encode_getaclres
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]>
1 parent 7b08cf6 commit ab1016d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/nfsd/nfs3acl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
172172
struct nfsd3_getaclres *resp = rqstp->rq_resp;
173173
struct dentry *dentry = resp->fh.fh_dentry;
174174
struct kvec *head = rqstp->rq_res.head;
175-
struct inode *inode = d_inode(dentry);
175+
struct inode *inode;
176176
unsigned int base;
177177
int n;
178178
int w;
@@ -181,6 +181,7 @@ static int nfs3svc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p)
181181
return 0;
182182
switch (resp->status) {
183183
case nfs_ok:
184+
inode = d_inode(dentry);
184185
if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh))
185186
return 0;
186187
if (xdr_stream_encode_u32(xdr, resp->mask) < 0)

0 commit comments

Comments
 (0)