Commit 2dc164f2 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers

xfs: fix memory allocation failures with ACLs

Ever since increasing the number of supported ACLs from 25 to as
many as can fit in an xattr, there have been reports of order 4
memory allocations failing in the ACL code. Fix it in the same way
we've fixed all the xattr read/write code that has the same problem.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarMark Tinguely <tinguely@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 0a4edc8f
...@@ -152,9 +152,12 @@ xfs_get_acl(struct inode *inode, int type) ...@@ -152,9 +152,12 @@ xfs_get_acl(struct inode *inode, int type)
* go out to the disk. * go out to the disk.
*/ */
len = XFS_ACL_MAX_SIZE(ip->i_mount); len = XFS_ACL_MAX_SIZE(ip->i_mount);
xfs_acl = kzalloc(len, GFP_KERNEL); xfs_acl = kmem_zalloc(len, KM_SLEEP | KM_MAYFAIL);
if (!xfs_acl) {
xfs_acl = kmem_zalloc_large(len);
if (!xfs_acl) if (!xfs_acl)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
}
error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl, error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
&len, ATTR_ROOT); &len, ATTR_ROOT);
...@@ -175,9 +178,12 @@ xfs_get_acl(struct inode *inode, int type) ...@@ -175,9 +178,12 @@ xfs_get_acl(struct inode *inode, int type)
if (IS_ERR(acl)) if (IS_ERR(acl))
goto out; goto out;
out_update_cache: out_update_cache:
set_cached_acl(inode, type, acl); set_cached_acl(inode, type, acl);
out: out:
if (is_vmalloc_addr(xfs_acl))
kmem_free_large(xfs_acl);
else
kfree(xfs_acl); kfree(xfs_acl);
return acl; return acl;
} }
...@@ -209,9 +215,12 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) ...@@ -209,9 +215,12 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
struct xfs_acl *xfs_acl; struct xfs_acl *xfs_acl;
int len = XFS_ACL_MAX_SIZE(ip->i_mount); int len = XFS_ACL_MAX_SIZE(ip->i_mount);
xfs_acl = kzalloc(len, GFP_KERNEL); xfs_acl = kmem_zalloc(len, KM_SLEEP | KM_MAYFAIL);
if (!xfs_acl) {
xfs_acl = kmem_zalloc_large(len);
if (!xfs_acl) if (!xfs_acl)
return -ENOMEM; return -ENOMEM;
}
xfs_acl_to_disk(xfs_acl, acl); xfs_acl_to_disk(xfs_acl, acl);
...@@ -222,6 +231,9 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl) ...@@ -222,6 +231,9 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl, error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
len, ATTR_ROOT); len, ATTR_ROOT);
if (is_vmalloc_addr(xfs_acl))
kmem_free_large(xfs_acl);
else
kfree(xfs_acl); kfree(xfs_acl);
} else { } else {
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment