Skip to content

Commit 35e634b

Browse files
kinglongmeeJ. Bruce Fields
authored andcommitted
NFSD: Check acl returned from get_acl/posix_acl_from_mode
Commit 4ac7249 (nfsd: use get_acl and ->set_acl) don't check the acl returned from get_acl()/posix_acl_from_mode(). Signed-off-by: Kinglong Mee <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 2559429 commit 35e634b

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

fs/nfsd/nfs2acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
5454

5555
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
5656
acl = get_acl(inode, ACL_TYPE_ACCESS);
57-
if (IS_ERR(acl)) {
58-
nfserr = nfserrno(PTR_ERR(acl));
59-
goto fail;
60-
}
6157
if (acl == NULL) {
6258
/* Solaris returns the inode's minimum ACL. */
6359
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
6460
}
61+
if (IS_ERR(acl)) {
62+
nfserr = nfserrno(PTR_ERR(acl));
63+
goto fail;
64+
}
6565
resp->acl_access = acl;
6666
}
6767
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {

fs/nfsd/nfs3acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
4747

4848
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
4949
acl = get_acl(inode, ACL_TYPE_ACCESS);
50-
if (IS_ERR(acl)) {
51-
nfserr = nfserrno(PTR_ERR(acl));
52-
goto fail;
53-
}
5450
if (acl == NULL) {
5551
/* Solaris returns the inode's minimum ACL. */
5652
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
5753
}
54+
if (IS_ERR(acl)) {
55+
nfserr = nfserrno(PTR_ERR(acl));
56+
goto fail;
57+
}
5858
resp->acl_access = acl;
5959
}
6060
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {

fs/nfsd/nfs4acl.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,17 +146,23 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
146146
int size = 0;
147147

148148
pacl = get_acl(inode, ACL_TYPE_ACCESS);
149-
if (!pacl) {
149+
if (!pacl)
150150
pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
151-
if (IS_ERR(pacl))
152-
return PTR_ERR(pacl);
153-
}
151+
152+
if (IS_ERR(pacl))
153+
return PTR_ERR(pacl);
154+
154155
/* allocate for worst case: one (deny, allow) pair each: */
155156
size += 2 * pacl->a_count;
156157

157158
if (S_ISDIR(inode->i_mode)) {
158159
flags = NFS4_ACL_DIR;
159160
dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
161+
if (IS_ERR(dpacl)) {
162+
error = PTR_ERR(dpacl);
163+
goto rel_pacl;
164+
}
165+
160166
if (dpacl)
161167
size += 2 * dpacl->a_count;
162168
}
@@ -173,9 +179,10 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
173179
if (dpacl)
174180
_posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);
175181

176-
out:
177-
posix_acl_release(pacl);
182+
out:
178183
posix_acl_release(dpacl);
184+
rel_pacl:
185+
posix_acl_release(pacl);
179186
return error;
180187
}
181188

0 commit comments

Comments
 (0)