NFSD: Check acl returned from get_acl/posix_acl_from_mode
Commit 4ac7249ea5
(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 <kinglongmee@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
This commit is contained in:
parent
255942907e
commit
35e634b83c
3 changed files with 21 additions and 14 deletions
|
@ -54,14 +54,14 @@ static __be32 nfsacld_proc_getacl(struct svc_rqst * rqstp,
|
||||||
|
|
||||||
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
|
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
|
||||||
acl = get_acl(inode, ACL_TYPE_ACCESS);
|
acl = get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl)) {
|
|
||||||
nfserr = nfserrno(PTR_ERR(acl));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (acl == NULL) {
|
if (acl == NULL) {
|
||||||
/* Solaris returns the inode's minimum ACL. */
|
/* Solaris returns the inode's minimum ACL. */
|
||||||
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
||||||
}
|
}
|
||||||
|
if (IS_ERR(acl)) {
|
||||||
|
nfserr = nfserrno(PTR_ERR(acl));
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
resp->acl_access = acl;
|
resp->acl_access = acl;
|
||||||
}
|
}
|
||||||
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
|
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
|
||||||
|
|
|
@ -47,14 +47,14 @@ static __be32 nfsd3_proc_getacl(struct svc_rqst * rqstp,
|
||||||
|
|
||||||
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
|
if (resp->mask & (NFS_ACL|NFS_ACLCNT)) {
|
||||||
acl = get_acl(inode, ACL_TYPE_ACCESS);
|
acl = get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (IS_ERR(acl)) {
|
|
||||||
nfserr = nfserrno(PTR_ERR(acl));
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
if (acl == NULL) {
|
if (acl == NULL) {
|
||||||
/* Solaris returns the inode's minimum ACL. */
|
/* Solaris returns the inode's minimum ACL. */
|
||||||
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
||||||
}
|
}
|
||||||
|
if (IS_ERR(acl)) {
|
||||||
|
nfserr = nfserrno(PTR_ERR(acl));
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
resp->acl_access = acl;
|
resp->acl_access = acl;
|
||||||
}
|
}
|
||||||
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
|
if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) {
|
||||||
|
|
|
@ -146,17 +146,23 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
pacl = get_acl(inode, ACL_TYPE_ACCESS);
|
pacl = get_acl(inode, ACL_TYPE_ACCESS);
|
||||||
if (!pacl) {
|
if (!pacl)
|
||||||
pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
pacl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
|
||||||
if (IS_ERR(pacl))
|
|
||||||
return PTR_ERR(pacl);
|
if (IS_ERR(pacl))
|
||||||
}
|
return PTR_ERR(pacl);
|
||||||
|
|
||||||
/* allocate for worst case: one (deny, allow) pair each: */
|
/* allocate for worst case: one (deny, allow) pair each: */
|
||||||
size += 2 * pacl->a_count;
|
size += 2 * pacl->a_count;
|
||||||
|
|
||||||
if (S_ISDIR(inode->i_mode)) {
|
if (S_ISDIR(inode->i_mode)) {
|
||||||
flags = NFS4_ACL_DIR;
|
flags = NFS4_ACL_DIR;
|
||||||
dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
|
dpacl = get_acl(inode, ACL_TYPE_DEFAULT);
|
||||||
|
if (IS_ERR(dpacl)) {
|
||||||
|
error = PTR_ERR(dpacl);
|
||||||
|
goto rel_pacl;
|
||||||
|
}
|
||||||
|
|
||||||
if (dpacl)
|
if (dpacl)
|
||||||
size += 2 * dpacl->a_count;
|
size += 2 * dpacl->a_count;
|
||||||
}
|
}
|
||||||
|
@ -173,9 +179,10 @@ nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
|
||||||
if (dpacl)
|
if (dpacl)
|
||||||
_posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);
|
_posix_to_nfsv4_one(dpacl, *acl, flags | NFS4_ACL_TYPE_DEFAULT);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
posix_acl_release(pacl);
|
|
||||||
posix_acl_release(dpacl);
|
posix_acl_release(dpacl);
|
||||||
|
rel_pacl:
|
||||||
|
posix_acl_release(pacl);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue