Skip to contentSkip to conversation

ext4: check the acl's validity before setting

PATCH In review ZhangZhen 2 participants 4 messages Apr 8, 2014 1 message not in the archive ext4 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

ZhangZhen

author
#1 lore raw

PATCH 1/1 ext4: check the acl's validity before setting

Before setting the acl, call posix_acl_valid() to check if it is valid or not.

---
 fs/ext4/acl.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
fs/ext4/acl.c +6 -0
index d40c8db..97f7650 100644
@@ -197,6 +197,12 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
 	size_t size = 0;
 	int error;
 
+	if (acl) {
+		error = posix_acl_valid(acl);
+		if (error < 0)
+			return error;
+	}
+
 	switch (type) {
 	case ACL_TYPE_ACCESS:
 		name_index = EXT4_XATTR_INDEX_POSIX_ACL_ACCESS;
Signature · 1 line
1.6.0.2
#2 lore raw
Quoted 2 lines · ZhangZhen

Before setting the acl, call posix_acl_valid() to check if it is valid or not.

Why? posix_acl_xattr_set already does that for you, and it's the only way to feed in an ACL from userspace.

author
#3 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 2 lines · ZhangZhen

Before setting the acl, call posix_acl_valid() to check if it is valid or not.

Why? posix_acl_xattr_set already does that for you, and it's the only way to feed in an ACL from userspace.

Hi Hellwig,

You are right, this patch is useless. I'm sorry for this spam mail.

But btrfs_set_acl checks the validity of the ACL too. Should we delete it? Another choice is we can check the validity in every fs tree, and delete the check from posix_acl_xattr_set.

How should we do?

Thanks!

#4 lore raw
Quoted 5 lines · ZhangZhen

You are right, this patch is useless. I'm sorry for this spam mail.

But btrfs_set_acl checks the validity of the ACL too. Should we delete it? Another choice is we can check the validity in every fs tree, and delete the check from posix_acl_xattr_set.

Doing it in common code is the right thing. I suspect btrfs having it is an oversight, but please verify it with the btrfs maintainers.