Commit 10658a35 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Remove arbitrary #acl entries limits on ext[23] when reading

From: Andreas Gruenbacher <agruen@suse.de>

Remove the arbitrary limit of 32 ACL entries on ext[23] when reading from
disk.  This change is backward compatible; we need to have this change in
to be able to also allow writing big ACLs.

The second patch that removes the ACL entry limit for writes is not
included.  I don't want to push that patch now, because large ACLs would
cause 2.4 and current 2.6 kernels to fail.  My plan is to remove the second
limit later, in a half-year or year or so.
parent c833cc5a
...@@ -154,10 +154,9 @@ ext2_iset_acl(struct inode *inode, struct posix_acl **i_acl, ...@@ -154,10 +154,9 @@ ext2_iset_acl(struct inode *inode, struct posix_acl **i_acl,
static struct posix_acl * static struct posix_acl *
ext2_get_acl(struct inode *inode, int type) ext2_get_acl(struct inode *inode, int type)
{ {
const size_t max_size = ext2_acl_size(EXT2_ACL_MAX_ENTRIES);
struct ext2_inode_info *ei = EXT2_I(inode); struct ext2_inode_info *ei = EXT2_I(inode);
int name_index; int name_index;
char *value; char *value = NULL;
struct posix_acl *acl; struct posix_acl *acl;
int retval; int retval;
...@@ -182,17 +181,21 @@ ext2_get_acl(struct inode *inode, int type) ...@@ -182,17 +181,21 @@ ext2_get_acl(struct inode *inode, int type)
default: default:
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
value = kmalloc(max_size, GFP_KERNEL); retval = ext2_xattr_get(inode, name_index, "", NULL, 0);
if (!value) if (retval > 0) {
return ERR_PTR(-ENOMEM); value = kmalloc(retval, GFP_KERNEL);
if (!value)
retval = ext2_xattr_get(inode, name_index, "", value, max_size); return ERR_PTR(-ENOMEM);
acl = ERR_PTR(retval); retval = ext2_xattr_get(inode, name_index, "", value, retval);
if (retval >= 0) }
if (retval > 0)
acl = ext2_acl_from_disk(value, retval); acl = ext2_acl_from_disk(value, retval);
else if (retval == -ENODATA || retval == -ENOSYS) else if (retval == -ENODATA || retval == -ENOSYS)
acl = NULL; acl = NULL;
kfree(value); else
acl = ERR_PTR(retval);
if (value)
kfree(value);
if (!IS_ERR(acl)) { if (!IS_ERR(acl)) {
switch(type) { switch(type) {
......
...@@ -157,10 +157,9 @@ ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl, ...@@ -157,10 +157,9 @@ ext3_iset_acl(struct inode *inode, struct posix_acl **i_acl,
static struct posix_acl * static struct posix_acl *
ext3_get_acl(struct inode *inode, int type) ext3_get_acl(struct inode *inode, int type)
{ {
const size_t max_size = ext3_acl_size(EXT3_ACL_MAX_ENTRIES);
struct ext3_inode_info *ei = EXT3_I(inode); struct ext3_inode_info *ei = EXT3_I(inode);
int name_index; int name_index;
char *value; char *value = NULL;
struct posix_acl *acl; struct posix_acl *acl;
int retval; int retval;
...@@ -185,17 +184,21 @@ ext3_get_acl(struct inode *inode, int type) ...@@ -185,17 +184,21 @@ ext3_get_acl(struct inode *inode, int type)
default: default:
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
value = kmalloc(max_size, GFP_KERNEL); retval = ext3_xattr_get(inode, name_index, "", NULL, 0);
if (!value) if (retval > 0) {
return ERR_PTR(-ENOMEM); value = kmalloc(retval, GFP_KERNEL);
if (!value)
retval = ext3_xattr_get(inode, name_index, "", value, max_size); return ERR_PTR(-ENOMEM);
acl = ERR_PTR(retval); retval = ext3_xattr_get(inode, name_index, "", value, retval);
}
if (retval > 0) if (retval > 0)
acl = ext3_acl_from_disk(value, retval); acl = ext3_acl_from_disk(value, retval);
else if (retval == -ENODATA || retval == -ENOSYS) else if (retval == -ENODATA || retval == -ENOSYS)
acl = NULL; acl = NULL;
kfree(value); else
acl = ERR_PTR(retval);
if (value)
kfree(value);
if (!IS_ERR(acl)) { if (!IS_ERR(acl)) {
switch(type) { switch(type) {
......
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