Skip to contentSkip to conversation

New ACL format for better NFSv4 acl interoperability

PATCH In review Aneesh Kumar K.V 5 participants 40 messages Feb 23, 2011 – May 13, 2011 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover New ACL format for better NFSv4 acl interoperability

Hi,

The following set of patches implements VFS and ext4 changes needed to implement a new acl model for linux. Rich ACLs are an implementation of NFSv4 ACLs, extended by file masks to fit into the standard POSIX file permission model. They are designed to work seamlessly locally as well as across the NFSv4 and CIFS/SMB2 network file system protocols.

Full patch series including NFS server and client changes can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/agruen/linux-2.6-richacl.git richacl or
git://git.kernel.org/pub/scm/linux/kernel/git/kvaneesh/linux-richacl.git richacl

A user-space utility for displaying and changing richacls is available at [4] (a number of examples can be found at http://acl.bestbits.at/richacl/examples.html).

[4] git://git.kernel.org/pub/scm/linux/kernel/git/agruen/richacl.git master

To test richacl on ext4 use -o richacl mount option. This mount option may later be dropped in favour of a feature flag.

More details regarding richacl can be found at
http://acl.bestbits.at/richacl/

Changes from v4:
a) rebase to 2.6.38-rc6
b) Fixes for MAY_DELETE_CHILD and MAY_DELETE_SELF when directory have sticky bits
c) Fixes for NFsv4 permission checking to make it work better with new MAY_* flags

-aneesh

#1 lore raw

PATCH 1/24 vfs: Indicate that the permission functions take all the MAY_* flags

From: Andreas Gruenbacher <[email protected]>

---
 fs/namei.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/namei.c +3 -3
index 0087cf9..b01eab8 100644
@@ -200,7 +200,7 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
 /**
  * generic_permission -  check for access rights on a Posix-like filesystem
  * @inode:	inode to check access rights for
- * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
+ * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC, ...)
  * @check_acl:	optional callback to check for Posix ACLs
  * @flags:	IPERM_FLAG_ flags.
  *
@@ -247,7 +247,7 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags,
 /**
  * inode_permission  -  check for access rights to a given inode
  * @inode:	inode to check permission on
- * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
+ * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC, ...)
  *
  * Used to check for read/write/execute permissions on an inode.
  * We use "fsuid" for this, letting us set arbitrary permissions
@@ -294,7 +294,7 @@ int inode_permission(struct inode *inode, int mask)
 /**
  * file_permission  -  check for additional access rights to a given file
  * @file:	file to check access rights for
- * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC)
+ * @mask:	right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC, ...)
  *
  * Used to check for read/write/execute permissions on an already opened
  * file.
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/24 vfs: Pass all mask flags down to iop->check_acl

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Some file permission models differentiate between writing to a file (MAY_WRITE) and appending to it (MAY_WRITE | MAY_APPEND). Pass all the mask flags down to iop->check_acl so that filesystems can distinguish between writing and appending.

All users of iop->check_acl pass the mask value back into posix_acl_permission(); strip off the additional mask flags there.

---
 fs/namei.c     |    4 +---
 fs/posix_acl.c |    2 ++
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/namei.c +1 -3
index b01eab8..f09ab1f 100644
@@ -174,8 +174,6 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
 {
 	umode_t			mode = inode->i_mode;
 
-	mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
-
 	if (current_fsuid() == inode->i_uid)
 		mode >>= 6;
 	else {
@@ -192,7 +190,7 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
 	/*
 	 * If the DACs are ok we don't need any capability check.
 	 */
-	if ((mask & ~mode) == 0)
+	if ((mask & (MAY_READ | MAY_WRITE | MAY_EXEC) & ~mode) == 0)
 		return 0;
 	return -EACCES;
 }
fs/posix_acl.c +2 -0
index b1cf6bf..ad40df2 100644
@@ -222,6 +222,8 @@ posix_acl_permission(struct inode *inode, const struct posix_acl *acl, int want)
 	const struct posix_acl_entry *pa, *pe, *mask_obj;
 	int found = 0;
 
+	want &= MAY_READ | MAY_WRITE | MAY_EXEC;
+
 	FOREACH_ACL_ENTRY(pa, acl, pe) {
                 switch(pa->e_tag) {
                         case ACL_USER_OBJ:
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

PATCH 3/24 vfs: Add a comment to inode_permission()

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

---
 fs/namei.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
fs/namei.c +4 -2
index f09ab1f..0bfc546 100644
@@ -167,7 +167,7 @@ EXPORT_SYMBOL(putname);
 #endif
 
 /*
- * This does basic POSIX ACL permission checking
+ * This does the basic permission checking
  */
 static int acl_permission_check(struct inode *inode, int mask, unsigned int flags,
 		int (*check_acl)(struct inode *inode, int mask, unsigned int flags))
@@ -217,7 +217,7 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags,
 	int ret;
 
 	/*
-	 * Do the basic POSIX ACL permission checks.
+	 * Do the basic permission checks.
 	 */
 	ret = acl_permission_check(inode, mask, flags, check_acl);
 	if (ret != -EACCES)
@@ -251,6 +251,8 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags,
  * We use "fsuid" for this, letting us set arbitrary permissions
  * for filesystem access without changing the "normal" uids which
  * are used for other things.
+ *
+ * When checking for MAY_APPEND, MAY_WRITE must also be set in @mask.
  */
 int inode_permission(struct inode *inode, int mask)
 {
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

PATCH 4/24 vfs: Add generic IS_ACL() test for acl support

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

When IS_POSIXACL() is true, the vfs does not apply the umask. Other acl models will need the same exception, so introduce a separate IS_ACL() test.

The IS_POSIX_ACL() test is still needed so that nfsd can determine when the underlying file system supports POSIX ACLs (as opposed to some other kind).

---
 fs/namei.c         |    6 +++---
 include/linux/fs.h |    8 +++++++-
 2 files changed, 10 insertions(+), 4 deletions(-)
fs/namei.c +3 -3
index 0bfc546..b1e5104 100644
@@ -2161,7 +2161,7 @@ static int __open_namei_create(struct nameidata *nd, struct path *path,
 	int error;
 	struct dentry *dir = nd->path.dentry;
 
-	if (!IS_POSIXACL(dir->d_inode))
+	if (!IS_ACL(dir->d_inode))
 		mode &= ~current_umask();
 	error = security_path_mknod(&nd->path, path->dentry, mode, 0);
 	if (error)
@@ -2691,7 +2691,7 @@ SYSCALL_DEFINE4(mknodat, int, dfd, const char __user *, filename, int, mode,
 		error = PTR_ERR(dentry);
 		goto out_unlock;
 	}
-	if (!IS_POSIXACL(nd.path.dentry->d_inode))
+	if (!IS_ACL(nd.path.dentry->d_inode))
 		mode &= ~current_umask();
 	error = may_mknod(mode);
 	if (error)
@@ -2768,7 +2768,7 @@ SYSCALL_DEFINE3(mkdirat, int, dfd, const char __user *, pathname, int, mode)
 	if (IS_ERR(dentry))
 		goto out_unlock;
 
-	if (!IS_POSIXACL(nd.path.dentry->d_inode))
+	if (!IS_ACL(nd.path.dentry->d_inode))
 		mode &= ~current_umask();
 	error = mnt_want_write(nd.path.mnt);
 	if (error)
include/linux/fs.h +7 -1
index bd32159..70c7779 100644
@@ -205,7 +205,7 @@ struct inodes_stat_t {
 #define MS_VERBOSE	32768	/* War is peace. Verbosity is silence.
 				   MS_VERBOSE is deprecated. */
 #define MS_SILENT	32768
-#define MS_POSIXACL	(1<<16)	/* VFS does not apply the umask */
+#define MS_POSIXACL	(1<<16) /* Supports POSIX ACLs */
 #define MS_UNBINDABLE	(1<<17)	/* change to unbindable */
 #define MS_PRIVATE	(1<<18)	/* change to private */
 #define MS_SLAVE	(1<<19)	/* change to slave */
@@ -280,6 +280,12 @@ struct inodes_stat_t {
 #define IS_IMA(inode)		((inode)->i_flags & S_IMA)
 #define IS_AUTOMOUNT(inode)	((inode)->i_flags & S_AUTOMOUNT)
 
+/*
+ * IS_ACL() tells the VFS to not apply the umask
+ * and use iop->check_acl for acl permission checks when defined.
+ */
+#define IS_ACL(inode)		__IS_FLG(inode, MS_POSIXACL)
+
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
 
Signature · 1 line
1.7.1
#5 lore raw

PATCH 5/24 vfs: Add IS_RICHACL() test for richacl support

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Introduce a new MS_RICHACL super-block flag and a new IS_RICHACL() test which file systems like nfs can use. IS_ACL() is true if IS_POSIXACL() or IS_RICHACL() is true.

---
 include/linux/fs.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
include/linux/fs.h +3 -1
index 70c7779..e542157 100644
@@ -214,6 +214,7 @@ struct inodes_stat_t {
 #define MS_KERNMOUNT	(1<<22) /* this is a kern_mount call */
 #define MS_I_VERSION	(1<<23) /* Update inode I_version field */
 #define MS_STRICTATIME	(1<<24) /* Always perform atime updates */
+#define MS_RICHACL	(1<<25) /* Supports richacls */
 #define MS_BORN		(1<<29)
 #define MS_ACTIVE	(1<<30)
 #define MS_NOUSER	(1<<31)
@@ -272,6 +273,7 @@ struct inodes_stat_t {
 #define IS_APPEND(inode)	((inode)->i_flags & S_APPEND)
 #define IS_IMMUTABLE(inode)	((inode)->i_flags & S_IMMUTABLE)
 #define IS_POSIXACL(inode)	__IS_FLG(inode, MS_POSIXACL)
+#define IS_RICHACL(inode)	__IS_FLG(inode, MS_RICHACL)
 
 #define IS_DEADDIR(inode)	((inode)->i_flags & S_DEAD)
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)
@@ -284,7 +286,7 @@ struct inodes_stat_t {
  * IS_ACL() tells the VFS to not apply the umask
  * and use iop->check_acl for acl permission checks when defined.
  */
-#define IS_ACL(inode)		__IS_FLG(inode, MS_POSIXACL)
+#define IS_ACL(inode)		__IS_FLG(inode, MS_POSIXACL | MS_RICHACL)
 
 /* the read-only stuff doesn't really belong here, but any other place is
    probably as bad and I don't want to create yet another include file. */
Signature · 1 line
1.7.1
#6 lore raw

PATCH 6/24 vfs: Optimize out IS_RICHACL() if CONFIG_FS_RICHACL is not defined

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

if CONFIG_FS_RICHACL is not defined optimize out
the ACL check function.

---
 fs/Kconfig         |    3 +++
 include/linux/fs.h |    5 +++++
 2 files changed, 8 insertions(+), 0 deletions(-)
fs/Kconfig +3 -0
index 3db9caa..753b194 100644
@@ -46,6 +46,9 @@ endif # BLOCK
 config FS_POSIX_ACL
 	def_bool n
 
+config FS_RICHACL
+	def_bool n
+
 config EXPORTFS
 	tristate
 
include/linux/fs.h +5 -0
index e542157..1dc6e72 100644
@@ -273,7 +273,12 @@ struct inodes_stat_t {
 #define IS_APPEND(inode)	((inode)->i_flags & S_APPEND)
 #define IS_IMMUTABLE(inode)	((inode)->i_flags & S_IMMUTABLE)
 #define IS_POSIXACL(inode)	__IS_FLG(inode, MS_POSIXACL)
+
+#ifdef CONFIG_FS_RICHACL
 #define IS_RICHACL(inode)	__IS_FLG(inode, MS_RICHACL)
+#else
+#define IS_RICHACL(inode)	0
+#endif
 
 #define IS_DEADDIR(inode)	((inode)->i_flags & S_DEAD)
 #define IS_NOCMTIME(inode)	((inode)->i_flags & S_NOCMTIME)
Signature · 1 line
1.7.1
#7 lore raw

PATCH 7/24 vfs: Add new file and directory create permission flags

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Some permission models distinguish between the permission to create a non-directory and a directory. Pass this information down to inode_permission() as mask flags

---
 fs/namei.c         |   26 +++++++++++++++-----------
 include/linux/fs.h |    2 ++
 2 files changed, 17 insertions(+), 11 deletions(-)
fs/namei.c +15 -11
index b1e5104..b4f7198 100644
@@ -252,7 +252,8 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags,
  * for filesystem access without changing the "normal" uids which
  * are used for other things.
  *
- * When checking for MAY_APPEND, MAY_WRITE must also be set in @mask.
+ * When checking for MAY_APPEND, MAY_CREATE_FILE, MAY_CREATE_DIR,
+ * MAY_WRITE must also be set in @mask.
  */
 int inode_permission(struct inode *inode, int mask)
 {
@@ -2005,13 +2006,15 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
  *  3. We should have write and exec permissions on dir
  *  4. We can't do it if dir is immutable (done in permission())
  */
-static inline int may_create(struct inode *dir, struct dentry *child)
+static inline int may_create(struct inode *dir, struct dentry *child, int isdir)
 {
+	int mask = isdir ? MAY_CREATE_DIR : MAY_CREATE_FILE;
+
 	if (child->d_inode)
 		return -EEXIST;
 	if (IS_DEADDIR(dir))
 		return -ENOENT;
-	return inode_permission(dir, MAY_WRITE | MAY_EXEC);
+	return inode_permission(dir, MAY_WRITE | MAY_EXEC | mask);
 }
 
 /*
@@ -2059,7 +2062,7 @@ void unlock_rename(struct dentry *p1, struct dentry *p2)
 int vfs_create(struct inode *dir, struct dentry *dentry, int mode,
 		struct nameidata *nd)
 {
-	int error = may_create(dir, dentry);
+	int error = may_create(dir, dentry, 0);
 
 	if (error)
 		return error;
@@ -2629,7 +2632,7 @@ EXPORT_SYMBOL_GPL(lookup_create);
 
 int vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t dev)
 {
-	int error = may_create(dir, dentry);
+	int error = may_create(dir, dentry, 0);
 
 	if (error)
 		return error;
@@ -2733,7 +2736,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, int, mode, unsigned, dev)
 
 int vfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
 {
-	int error = may_create(dir, dentry);
+	int error = may_create(dir, dentry, 1);
 
 	if (error)
 		return error;
@@ -3016,7 +3019,7 @@ SYSCALL_DEFINE1(unlink, const char __user *, pathname)
 
 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
 {
-	int error = may_create(dir, dentry);
+	int error = may_create(dir, dentry, 0);
 
 	if (error)
 		return error;
@@ -3089,7 +3092,10 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
 	if (!inode)
 		return -ENOENT;
 
-	error = may_create(dir, new_dentry);
+	if (S_ISDIR(inode->i_mode))
+		return -EPERM;
+
+	error = may_create(dir, new_dentry, 0);
 	if (error)
 		return error;
 
@@ -3103,8 +3109,6 @@ int vfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_de
 		return -EPERM;
 	if (!dir->i_op->link)
 		return -EPERM;
-	if (S_ISDIR(inode->i_mode))
-		return -EPERM;
 
 	error = security_inode_link(old_dentry, dir, new_dentry);
 	if (error)
@@ -3305,7 +3309,7 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 		return error;
 
 	if (!new_dentry->d_inode)
-		error = may_create(new_dir, new_dentry);
+		error = may_create(new_dir, new_dentry, is_dir);
 	else
 		error = may_delete(new_dir, new_dentry, is_dir);
 	if (error)
include/linux/fs.h +2 -0
index 1dc6e72..a86afc0 100644
@@ -62,6 +62,8 @@ struct inodes_stat_t {
 #define MAY_ACCESS 16
 #define MAY_OPEN 32
 #define MAY_CHDIR 64
+#define MAY_CREATE_FILE 128
+#define MAY_CREATE_DIR 256
 
 /*
  * flags in file.f_mode.  Note that FMODE_READ and FMODE_WRITE must correspond
Signature · 1 line
1.7.1
#8 lore raw

PATCH 8/24 vfs: Add delete child and delete self permission flags

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Normally, deleting a file requires write access to the parent directory. Some permission models use a different permission on the parent directory to indicate delete access. In addition, a process can have per-file delete access even without delete access on the parent directory.

Introduce two new inode_permission() mask flags and use them in may_delete()

---
 fs/namei.c         |   40 ++++++++++++++++++++++++++--------------
 include/linux/fs.h |    2 ++
 2 files changed, 28 insertions(+), 14 deletions(-)
fs/namei.c +26 -14
index b4f7198..1b6dbc9 100644
@@ -253,7 +253,7 @@ int generic_permission(struct inode *inode, int mask, unsigned int flags,
  * are used for other things.
  *
  * When checking for MAY_APPEND, MAY_CREATE_FILE, MAY_CREATE_DIR,
- * MAY_WRITE must also be set in @mask.
+ * MAY_DELETE_CHILD, MAY_DELETE_SELF, MAY_WRITE must also be set in @mask.
  */
 int inode_permission(struct inode *inode, int mask)
 {
@@ -1944,7 +1944,7 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
 		return 0;
 	if (dir->i_uid == fsuid)
 		return 0;
-	return !capable(CAP_FOWNER);
+	return 1;
 }
 
 /*
@@ -1966,30 +1966,42 @@ static inline int check_sticky(struct inode *dir, struct inode *inode)
  * 10. We don't allow removal of NFS sillyrenamed files; it's handled by
  *     nfs_async_unlink().
  */
-static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
+static int may_delete(struct inode *dir, struct dentry *victim,
+		      int isdir, int replace)
 {
-	int error;
+	int mask, error, is_sticky;
+	struct inode *inode = victim->d_inode;
 
-	if (!victim->d_inode)
+	if (!inode)
 		return -ENOENT;
 
 	BUG_ON(victim->d_parent->d_inode != dir);
 	audit_inode_child(victim, dir);
 
-	error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
+	mask = MAY_WRITE | MAY_EXEC | MAY_DELETE_CHILD;
+	if (replace)
+		mask |= S_ISDIR(inode->i_mode) ?
+			MAY_CREATE_DIR : MAY_CREATE_FILE;
+	is_sticky = check_sticky(dir, inode);
+	error = inode_permission(dir, mask);
+	if ((error || is_sticky) && IS_RICHACL(inode) &&
+	    !inode_permission(dir, mask & ~(MAY_WRITE | MAY_DELETE_CHILD)) &&
+	    !inode_permission(inode, MAY_DELETE_SELF))
+		error = 0;
+	else if (!error && is_sticky && !capable(CAP_FOWNER))
+		error = -EPERM;
 	if (error)
 		return error;
 	if (IS_APPEND(dir))
 		return -EPERM;
-	if (check_sticky(dir, victim->d_inode)||IS_APPEND(victim->d_inode)||
-	    IS_IMMUTABLE(victim->d_inode) || IS_SWAPFILE(victim->d_inode))
+	if (IS_APPEND(inode) || IS_IMMUTABLE(inode) || IS_SWAPFILE(inode))
 		return -EPERM;
 	if (isdir) {
-		if (!S_ISDIR(victim->d_inode->i_mode))
+		if (!S_ISDIR(inode->i_mode))
 			return -ENOTDIR;
 		if (IS_ROOT(victim))
 			return -EBUSY;
-	} else if (S_ISDIR(victim->d_inode->i_mode))
+	} else if (S_ISDIR(inode->i_mode))
 		return -EISDIR;
 	if (IS_DEADDIR(dir))
 		return -ENOENT;
@@ -2824,7 +2836,7 @@ void dentry_unhash(struct dentry *dentry)
 
 int vfs_rmdir(struct inode *dir, struct dentry *dentry)
 {
-	int error = may_delete(dir, dentry, 1);
+	int error = may_delete(dir, dentry, 1, 0);
 
 	if (error)
 		return error;
@@ -2911,7 +2923,7 @@ SYSCALL_DEFINE1(rmdir, const char __user *, pathname)
 
 int vfs_unlink(struct inode *dir, struct dentry *dentry)
 {
-	int error = may_delete(dir, dentry, 0);
+	int error = may_delete(dir, dentry, 0, 0);
 
 	if (error)
 		return error;
@@ -3304,14 +3316,14 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	if (old_dentry->d_inode == new_dentry->d_inode)
  		return 0;
  
-	error = may_delete(old_dir, old_dentry, is_dir);
+	error = may_delete(old_dir, old_dentry, is_dir, 0);
 	if (error)
 		return error;
 
 	if (!new_dentry->d_inode)
 		error = may_create(new_dir, new_dentry, is_dir);
 	else
-		error = may_delete(new_dir, new_dentry, is_dir);
+		error = may_delete(new_dir, new_dentry, is_dir, 1);
 	if (error)
 		return error;
 
include/linux/fs.h +2 -0
index a86afc0..6a6e017 100644
@@ -64,6 +64,8 @@ struct inodes_stat_t {
 #define MAY_CHDIR 64
 #define MAY_CREATE_FILE 128
 #define MAY_CREATE_DIR 256
+#define MAY_DELETE_CHILD 512
+#define MAY_DELETE_SELF 1024
 
 /*
  * flags in file.f_mode.  Note that FMODE_READ and FMODE_WRITE must correspond
Signature · 1 line
1.7.1
#9 lore raw

PATCH 9/24 vfs: Make the inode passed to inode_change_ok non-const

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

We will need to call iop->permission and iop->change_acl from inode_change_ok() for additional permission checks, and both take a non-const inode.

---
 fs/attr.c          |    2 +-
 include/linux/fs.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/attr.c +1 -1
index 7ca4181..f081b5a 100644
@@ -26,7 +26,7 @@
  * Should be called as the first thing in ->setattr implementations,
  * possibly after taking additional locks.
  */
-int inode_change_ok(const struct inode *inode, struct iattr *attr)
+int inode_change_ok(struct inode *inode, struct iattr *attr)
 {
 	unsigned int ia_valid = attr->ia_valid;
 
include/linux/fs.h +1 -1
index 6a6e017..3ae23a2 100644
@@ -2472,7 +2472,7 @@ extern int buffer_migrate_page(struct address_space *,
 #define buffer_migrate_page NULL
 #endif
 
-extern int inode_change_ok(const struct inode *, struct iattr *);
+extern int inode_change_ok(struct inode *, struct iattr *);
 extern int inode_newsize_ok(const struct inode *, loff_t offset);
 extern void setattr_copy(struct inode *inode, const struct iattr *attr);
 
Signature · 1 line
1.7.1
#10 lore raw

PATCH 10/24 vfs: Add permission flags for setting file attributes

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Some permission models can allow processes to take ownership of a file, change the file permissions, and set the file timestamps. Introduce new permission mask flags and check for those permissions in inode_change_ok().

---
 fs/attr.c          |   49 ++++++++++++++++++++++++++++++++++++++-----------
 include/linux/fs.h |    3 +++
 2 files changed, 41 insertions(+), 11 deletions(-)
fs/attr.c +38 -11
index f081b5a..793f34c 100644
@@ -13,6 +13,20 @@
 #include <linux/fsnotify.h>
 #include <linux/fcntl.h>
 #include <linux/security.h>
+#include <linux/richacl.h>
+
+static int richacl_change_ok(struct inode *inode, int mask)
+{
+	if (!IS_RICHACL(inode))
+		return -EPERM;
+
+	if (inode->i_op->permission)
+		return inode->i_op->permission(inode, mask, 0);
+	else if (inode->i_op->check_acl)
+		return inode->i_op->check_acl(inode, mask, 0);
+	else
+		return -EPERM;
+}
 
 /**
  * inode_change_ok - check if attribute changes to an inode are allowed
@@ -47,20 +61,29 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
 	/* Make sure a caller can chown. */
 	if ((ia_valid & ATTR_UID) &&
 	    (current_fsuid() != inode->i_uid ||
-	     attr->ia_uid != inode->i_uid) && !capable(CAP_CHOWN))
-		return -EPERM;
+	     attr->ia_uid != inode->i_uid) &&
+	    (current_fsuid() != attr->ia_uid ||
+	     richacl_change_ok(inode, MAY_TAKE_OWNERSHIP)) &&
+	    !capable(CAP_CHOWN))
+		goto error;
 
 	/* Make sure caller can chgrp. */
-	if ((ia_valid & ATTR_GID) &&
-	    (current_fsuid() != inode->i_uid ||
-	    (!in_group_p(attr->ia_gid) && attr->ia_gid != inode->i_gid)) &&
-	    !capable(CAP_CHOWN))
-		return -EPERM;
+	if (ia_valid & ATTR_GID) {
+		int in_group = in_group_p(attr->ia_gid);
+		if ((current_fsuid() != inode->i_uid ||
+		     (!in_group && attr->ia_gid != inode->i_gid)) &&
+		    (!in_group ||
+		     richacl_change_ok(inode, MAY_TAKE_OWNERSHIP)) &&
+		    !capable(CAP_CHOWN))
+			goto error;
+	}
 
 	/* Make sure a caller can chmod. */
 	if (ia_valid & ATTR_MODE) {
-		if (!is_owner_or_cap(inode))
-			return -EPERM;
+		if (current_fsuid() != inode->i_uid &&
+		    richacl_change_ok(inode, MAY_CHMOD) &&
+		    !capable(CAP_FOWNER))
+			goto error;
 		/* Also check the setgid bit! */
 		if (!in_group_p((ia_valid & ATTR_GID) ? attr->ia_gid :
 				inode->i_gid) && !capable(CAP_FSETID))
@@ -69,11 +92,15 @@ int inode_change_ok(struct inode *inode, struct iattr *attr)
 
 	/* Check for setting the inode time. */
 	if (ia_valid & (ATTR_MTIME_SET | ATTR_ATIME_SET | ATTR_TIMES_SET)) {
-		if (!is_owner_or_cap(inode))
-			return -EPERM;
+		if (current_fsuid() != inode->i_uid &&
+		    richacl_change_ok(inode, MAY_SET_TIMES) &&
+		    !capable(CAP_FOWNER))
+			goto error;
 	}
 
 	return 0;
+error:
+	return -EPERM;
 }
 EXPORT_SYMBOL(inode_change_ok);
 
include/linux/fs.h +3 -0
index 3ae23a2..1627592 100644
@@ -66,6 +66,9 @@ struct inodes_stat_t {
 #define MAY_CREATE_DIR 256
 #define MAY_DELETE_CHILD 512
 #define MAY_DELETE_SELF 1024
+#define MAY_TAKE_OWNERSHIP 2048
+#define MAY_CHMOD 4096
+#define MAY_SET_TIMES 8192
 
 /*
  * flags in file.f_mode.  Note that FMODE_READ and FMODE_WRITE must correspond
Signature · 1 line
1.7.1
#11 lore raw

PATCH 11/24 vfs: Make acl_permission_check() work for richacls

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

---
 fs/namei.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
fs/namei.c +14 -0
index 1b6dbc9..d7ff419 100644
@@ -174,6 +174,20 @@ static int acl_permission_check(struct inode *inode, int mask, unsigned int flag
 {
 	umode_t			mode = inode->i_mode;
 
+	if (IS_RICHACL(inode)) {
+		int error = check_acl(inode, mask, flags);
+		if (error != -EAGAIN)
+			return error;
+		if (mask & (MAY_DELETE_SELF | MAY_TAKE_OWNERSHIP |
+			    MAY_CHMOD | MAY_SET_TIMES)) {
+			/*
+			 * The file permission bit cannot grant these
+			 * permissions.
+			 */
+			return -EACCES;
+		}
+	}
+
 	if (current_fsuid() == inode->i_uid)
 		mode >>= 6;
 	else {
Signature · 1 line
1.7.1
#12 lore raw

PATCH 12/24 richacl: In-memory representation and helper functions

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

A richacl consists of an NFSv4 acl and an owner, group, and other mask. These three masks correspond to the owner, group, and other file permission bits, but they contain NFSv4 permissions instead of POSIX permissions.

Each entry in the NFSv4 acl applies to the file owner (OWNER@), the owning group (GROUP@), literally everyone (EVERYONE@), or to a specific uid or gid.

As in the standard POSIX file permission model, each process is the owner, group, or other file class. A richacl grants a requested access only if the NFSv4 acl in the richacl grants the access (according to the NFSv4 permission check algorithm), and the file mask that applies to the process includes the requested permissions.

---
 fs/Makefile             |    3 +
 fs/richacl_base.c       |  109 +++++++++++++++++++++
 include/linux/richacl.h |  245 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 357 insertions(+), 0 deletions(-)
 create mode 100644 fs/richacl_base.c
 create mode 100644 include/linux/richacl.h
fs/Makefile +3 -0
index a7f7cef..ed79438 100644
@@ -48,6 +48,9 @@ obj-$(CONFIG_FS_POSIX_ACL)	+= posix_acl.o xattr_acl.o
 obj-$(CONFIG_NFS_COMMON)	+= nfs_common/
 obj-$(CONFIG_GENERIC_ACL)	+= generic_acl.o
 
+obj-$(CONFIG_FS_RICHACL)	+= richacl.o
+richacl-y			:= richacl_base.o
+
 obj-y				+= quota/
 
 obj-$(CONFIG_PROC_FS)		+= proc/
fs/richacl_base.c new file +109 -0

109 lines not on this page · raw message

include/linux/richacl.h new file +245 -0

245 lines not on this page · raw message

Signature · 1 line
1.7.1
#13 lore raw

PATCH 13/24 richacl: Permission mapping functions

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

We need to map from POSIX permissions to NFSv4 permissions when a chmod() is done, from NFSv4 permissions to POSIX permissions when an acl is set (which implicitly sets the file permission bits), and from the MAY_READ/MAY_WRITE/MAY_EXEC/MAY_APPEND flags to NFSv4 permissions when doing an access check in a richacl.

---
 fs/richacl_base.c       |  118 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl.h |   46 ++++++++++++++++++
 2 files changed, 164 insertions(+), 0 deletions(-)
fs/richacl_base.c +118 -0
index 99ed0ca..50ba645 100644
@@ -69,6 +69,124 @@ richacl_clone(const struct richacl *acl)
 }
 
 /**
+ * richacl_mask_to_mode  -  compute the file permission bits which correspond to @mask
+ * @mask:	%ACE4_* permission mask
+ *
+ * See richacl_masks_to_mode().
+ */
+static int
+richacl_mask_to_mode(unsigned int mask)
+{
+	int mode = 0;
+
+	if (mask & ACE4_POSIX_MODE_READ)
+		mode |= MAY_READ;
+	if (mask & ACE4_POSIX_MODE_WRITE)
+		mode |= MAY_WRITE;
+	if (mask & ACE4_POSIX_MODE_EXEC)
+		mode |= MAY_EXEC;
+
+	return mode;
+}
+
+/**
+ * richacl_masks_to_mode  -  compute the file permission bits from the file masks
+ *
+ * When setting a richacl, we set the file permission bits to indicate maximum
+ * permissions: for example, we set the Write permission when a mask contains
+ * ACE4_APPEND_DATA even if it does not also contain ACE4_WRITE_DATA.
+ *
+ * Permissions which are not in ACE4_POSIX_MODE_READ, ACE4_POSIX_MODE_WRITE, or
+ * ACE4_POSIX_MODE_EXEC cannot be represented in the file permission bits.
+ * Such permissions can still be effective, but not for new files or after a
+ * chmod(), and only if they were set explicitly, for example, by setting a
+ * richacl.
+ */
+int
+richacl_masks_to_mode(const struct richacl *acl)
+{
+	return richacl_mask_to_mode(acl->a_owner_mask) << 6 |
+	       richacl_mask_to_mode(acl->a_group_mask) << 3 |
+	       richacl_mask_to_mode(acl->a_other_mask);
+}
+EXPORT_SYMBOL_GPL(richacl_masks_to_mode);
+
+/**
+ * richacl_mode_to_mask  - compute a file mask from the lowest three mode bits
+ *
+ * When the file permission bits of a file are set with chmod(), this specifies
+ * the maximum permissions that processes will get.  All permissions beyond
+ * that will be removed from the file masks, and become ineffective.
+ *
+ * We also add in the permissions which are always allowed no matter what the
+ * acl says.
+ */
+unsigned int
+richacl_mode_to_mask(mode_t mode)
+{
+	unsigned int mask = ACE4_POSIX_ALWAYS_ALLOWED;
+
+	if (mode & MAY_READ)
+		mask |= ACE4_POSIX_MODE_READ;
+	if (mode & MAY_WRITE)
+		mask |= ACE4_POSIX_MODE_WRITE;
+	if (mode & MAY_EXEC)
+		mask |= ACE4_POSIX_MODE_EXEC;
+
+	return mask;
+}
+
+/**
+ * richacl_want_to_mask  - convert the iop->permission want argument to a mask
+ * @want:	@want argument of the permission inode operation
+ *
+ * When checking for append, @want is (MAY_WRITE | MAY_APPEND).
+ *
+ * Richacls use the iop->may_create and iop->may_delete hooks which are
+ * used for checking if creating and deleting files is allowed.  These hooks do
+ * not use richacl_want_to_mask(), so we do not have to deal with mapping
+ * MAY_WRITE to ACE4_ADD_FILE, ACE4_ADD_SUBDIRECTORY, and ACE4_DELETE_CHILD
+ * here.
+ */
+unsigned int
+richacl_want_to_mask(int want)
+{
+	unsigned int mask = 0;
+
+	if (want & MAY_READ)
+		mask |= ACE4_READ_DATA;
+	if (want & (MAY_APPEND |
+		    MAY_CREATE_FILE | MAY_CREATE_DIR |
+		    MAY_DELETE_CHILD | MAY_DELETE_SELF |
+		    MAY_TAKE_OWNERSHIP | MAY_CHMOD | MAY_SET_TIMES)) {
+		if (want & MAY_APPEND)
+			mask |= ACE4_APPEND_DATA;
+		else if (want & MAY_DELETE_SELF)
+			mask |= ACE4_DELETE;
+		else if (want & MAY_TAKE_OWNERSHIP)
+			mask |= ACE4_WRITE_OWNER;
+		else if (want & MAY_CHMOD)
+			mask |= ACE4_WRITE_ACL;
+		else if (want & MAY_SET_TIMES)
+			mask |= ACE4_WRITE_ATTRIBUTES;
+		else {
+			if (want & MAY_CREATE_FILE)
+				mask |= ACE4_ADD_FILE;
+			if (want & MAY_CREATE_DIR)
+				mask |= ACE4_ADD_SUBDIRECTORY;
+			if (want & MAY_DELETE_CHILD)
+				mask |= ACE4_DELETE_CHILD;
+		}
+	} else if (want & MAY_WRITE)
+		mask |= ACE4_WRITE_DATA;
+	if (want & MAY_EXEC)
+		mask |= ACE4_EXECUTE;
+
+	return mask;
+}
+EXPORT_SYMBOL_GPL(richacl_want_to_mask);
+
+/**
  * richace_is_same_identifier  -  are both identifiers the same?
  */
 int
include/linux/richacl.h +46 -0

57 lines not on this page · raw message

Signature · 1 line
1.7.1
#14 lore raw

PATCH 14/24 richacl: Compute maximum file masks from an acl

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Compute upper bound owner, group, and other file masks with as few permissions as possible without denying any permissions that the NFSv4 acl in a richacl grants.

This algorithm is used when a file inherits an acl at create time and when an acl is set via a mechanism that does not specify file modes (such as via nfsd). When user-space sets an acl, the file masks are passed in as part of the xattr.

When setting a richacl, the file masks determine what the file permission bits will be set to; see richacl_masks_to_mode().

---
 fs/richacl_base.c       |  128 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl.h |    1 +
 2 files changed, 129 insertions(+), 0 deletions(-)
fs/richacl_base.c +128 -0
index 50ba645..69ddb00 100644
@@ -225,3 +225,131 @@ richace_set_who(struct richace *ace, const char *who)
 	return 0;
 }
 EXPORT_SYMBOL_GPL(richace_set_who);
+
+/**
+ * richacl_allowed_to_who  -  mask flags allowed to a specific who value
+ *
+ * Computes the mask values allowed to a specific who value, taking
+ * EVERYONE@ entries into account.
+ */
+static unsigned int richacl_allowed_to_who(struct richacl *acl,
+					   struct richace *who)
+{
+	struct richace *ace;
+	unsigned int allowed = 0;
+
+	richacl_for_each_entry_reverse(ace, acl) {
+		if (richace_is_inherit_only(ace))
+			continue;
+		if (richace_is_same_identifier(ace, who) ||
+		    richace_is_everyone(ace)) {
+			if (richace_is_allow(ace))
+				allowed |= ace->e_mask;
+			else if (richace_is_deny(ace))
+				allowed &= ~ace->e_mask;
+		}
+	}
+	return allowed;
+}
+
+/**
+ * richacl_group_class_allowed  -  maximum permissions the group class is allowed
+ *
+ * See richacl_compute_max_masks().
+ */
+static unsigned int richacl_group_class_allowed(struct richacl *acl)
+{
+	struct richace *ace;
+	unsigned int everyone_allowed = 0, group_class_allowed = 0;
+	int had_group_ace = 0;
+
+	richacl_for_each_entry_reverse(ace, acl) {
+		if (richace_is_inherit_only(ace) ||
+		    richace_is_owner(ace))
+			continue;
+
+		if (richace_is_everyone(ace)) {
+			if (richace_is_allow(ace))
+				everyone_allowed |= ace->e_mask;
+			else if (richace_is_deny(ace))
+				everyone_allowed &= ~ace->e_mask;
+		} else {
+			group_class_allowed |=
+				richacl_allowed_to_who(acl, ace);
+
+			if (richace_is_group(ace))
+				had_group_ace = 1;
+		}
+	}
+	if (!had_group_ace)
+		group_class_allowed |= everyone_allowed;
+	return group_class_allowed;
+}
+
+/**
+ * richacl_compute_max_masks  -  compute upper bound masks
+ *
+ * Computes upper bound owner, group, and other masks so that none of
+ * the mask flags allowed by the acl are disabled (for any choice of the
+ * file owner or group membership).
+ */
+void richacl_compute_max_masks(struct richacl *acl)
+{
+	unsigned int gmask = ~0;
+	struct richace *ace;
+
+	/*
+	 * @gmask contains all permissions which the group class is ever
+	 * allowed.  We use it to avoid adding permissions to the group mask
+	 * from everyone@ allow aces which the group class is always denied
+	 * through other aces.  For example, the following acl would otherwise
+	 * result in a group mask or rw:
+	 *
+	 *	group@:w::deny
+	 *	everyone@:rw::allow
+	 *
+	 * Avoid computing @gmask for acls which do not include any group class
+	 * deny aces: in such acls, the group class is never denied any
+	 * permissions from everyone@ allow aces.
+	 */
+
+restart:
+	acl->a_owner_mask = 0;
+	acl->a_group_mask = 0;
+	acl->a_other_mask = 0;
+
+	richacl_for_each_entry_reverse(ace, acl) {
+		if (richace_is_inherit_only(ace))
+			continue;
+
+		if (richace_is_owner(ace)) {
+			if (richace_is_allow(ace))
+				acl->a_owner_mask |= ace->e_mask;
+			else if (richace_is_deny(ace))
+				acl->a_owner_mask &= ~ace->e_mask;
+		} else if (richace_is_everyone(ace)) {
+			if (richace_is_allow(ace)) {
+				acl->a_owner_mask |= ace->e_mask;
+				acl->a_group_mask |= ace->e_mask & gmask;
+				acl->a_other_mask |= ace->e_mask;
+			} else if (richace_is_deny(ace)) {
+				acl->a_owner_mask &= ~ace->e_mask;
+				acl->a_group_mask &= ~ace->e_mask;
+				acl->a_other_mask &= ~ace->e_mask;
+			}
+		} else {
+			if (richace_is_allow(ace)) {
+				acl->a_owner_mask |= ace->e_mask & gmask;
+				acl->a_group_mask |= ace->e_mask & gmask;
+			} else if (richace_is_deny(ace) && gmask == ~0) {
+				gmask = richacl_group_class_allowed(acl);
+				if (likely(gmask != ~0))
+					/* should always be true */
+					goto restart;
+			}
+		}
+	}
+
+	acl->a_flags &= ~ACL4_MASKED;
+}
+EXPORT_SYMBOL_GPL(richacl_compute_max_masks);
include/linux/richacl.h +1 -0
index 399dbc9..f491e59 100644
@@ -287,5 +287,6 @@ extern int richace_set_who(struct richace *, const char *);
 extern int richacl_masks_to_mode(const struct richacl *);
 extern unsigned int richacl_mode_to_mask(mode_t);
 extern unsigned int richacl_want_to_mask(int);
+extern void richacl_compute_max_masks(struct richacl *);
 
 #endif /* __RICHACL_H */
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#15 lore raw

PATCH 15/24 richacl: Update the file masks in chmod()

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Doing a chmod() sets the file mode, which includes the file permission bits. When a file has a richacl, the permissions that the richacl grants need to be limited to what the new file permission bits allow.

This is done by setting the file masks in the richacl to what the file permission bits map to. The richacl access check algorithm takes the file masks into account, which ensures that the richacl cannot grant too many permissions.

It is possible to explicitly add permissions to the file masks which go beyond what the file permission bits can grant (like the ACE4_WRITE_ACL permission). The POSIX.1 standard calls this an alternate file access control mechanism. A subsequent chmod() would ensure that those permissions are disabled again.

---
 fs/richacl_base.c       |   40 ++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl.h |    1 +
 2 files changed, 41 insertions(+), 0 deletions(-)
fs/richacl_base.c +40 -0
index 69ddb00..b59c75c 100644
@@ -353,3 +353,43 @@ restart:
 	acl->a_flags &= ~ACL4_MASKED;
 }
 EXPORT_SYMBOL_GPL(richacl_compute_max_masks);
+
+/**
+ * richacl_chmod  -  update the file masks to reflect the new mode
+ * @mode:	new file permission bits
+ *
+ * Return a copy of @acl where the file masks have been replaced by the file
+ * masks corresponding to the file permission bits in @mode, or returns @acl
+ * itself if the file masks are already up to date.  Takes over a reference
+ * to @acl.
+ */
+struct richacl *
+richacl_chmod(struct richacl *acl, mode_t mode)
+{
+	unsigned int owner_mask, group_mask, other_mask;
+	struct richacl *clone;
+
+	owner_mask = richacl_mode_to_mask(mode >> 6) |
+		     ACE4_POSIX_OWNER_ALLOWED;
+	group_mask = richacl_mode_to_mask(mode >> 3);
+	other_mask = richacl_mode_to_mask(mode);
+
+	if (acl->a_owner_mask == owner_mask &&
+	    acl->a_group_mask == group_mask &&
+	    acl->a_other_mask == other_mask &&
+	    (acl->a_flags & ACL4_MASKED))
+		return acl;
+
+	clone = richacl_clone(acl);
+	richacl_put(acl);
+	if (!clone)
+		return ERR_PTR(-ENOMEM);
+
+	clone->a_flags |= ACL4_MASKED;
+	clone->a_owner_mask = owner_mask;
+	clone->a_group_mask = group_mask;
+	clone->a_other_mask = other_mask;
+
+	return clone;
+}
+EXPORT_SYMBOL_GPL(richacl_chmod);
include/linux/richacl.h +1 -0
index f491e59..3aa165b 100644
@@ -288,5 +288,6 @@ extern int richacl_masks_to_mode(const struct richacl *);
 extern unsigned int richacl_mode_to_mask(mode_t);
 extern unsigned int richacl_want_to_mask(int);
 extern void richacl_compute_max_masks(struct richacl *);
+extern struct richacl *richacl_chmod(struct richacl *, mode_t);
 
 #endif /* __RICHACL_H */
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#16 lore raw

PATCH 16/24 richacl: Permission check algorithm

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

As in the standard POSIX file permission model, each process is the owner, group, or other file class. A process is

- in the owner file class if it owns the file,
- in the group file class if it is in the file's owning group or it matches any of the user or group entries, and
- in the other file class otherwise.

Each file class is associated with a file mask.

A richacl grants a requested access if the NFSv4 acl in the richacl grants the requested permissions (according to the NFSv4 permission check algorithm) and the file mask that applies to the process includes the requested permissions.

---
 fs/richacl_base.c       |   99 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl.h |    2 +
 2 files changed, 101 insertions(+), 0 deletions(-)
fs/richacl_base.c +99 -0
index b59c75c..a6e3199 100644
@@ -393,3 +393,102 @@ richacl_chmod(struct richacl *acl, mode_t mode)
 	return clone;
 }
 EXPORT_SYMBOL_GPL(richacl_chmod);
+
+/**
+ * richacl_permission  -  richacl permission check algorithm
+ * @inode:	inode to check
+ * @acl:	rich acl of the inode
+ * @mask:	requested access (ACE4_* bitmask)
+ *
+ * Checks if the current process is granted @mask flags in @acl.
+ */
+int
+richacl_permission(struct inode *inode, const struct richacl *acl,
+		   unsigned int mask)
+{
+	const struct richace *ace;
+	unsigned int requested = mask, denied = 0;
+	int in_owning_group = in_group_p(inode->i_gid);
+	int in_owner_or_group_class = in_owning_group;
+
+	/*
+	 * We don't need to know which class the process is in when the acl is
+	 * not masked.
+	 */
+	if (!(acl->a_flags & ACL4_MASKED))
+		in_owner_or_group_class = 1;
+
+	/*
+	 * A process is
+	 *   - in the owner file class if it owns the file,
+	 *   - in the group file class if it is in the file's owning group or
+	 *     it matches any of the user or group entries, and
+	 *   - in the other file class otherwise.
+	 */
+
+	/*
+	 * Check if the acl grants the requested access and determine which
+	 * file class the process is in.
+	 */
+	richacl_for_each_entry(ace, acl) {
+		unsigned int ace_mask = ace->e_mask;
+
+		if (richace_is_inherit_only(ace))
+			continue;
+		if (richace_is_owner(ace)) {
+			if (current_fsuid() != inode->i_uid)
+				continue;
+			goto is_owner;
+		} else if (richace_is_group(ace)) {
+			if (!in_owning_group)
+				continue;
+		} else if (richace_is_unix_id(ace)) {
+			if (ace->e_flags & ACE4_IDENTIFIER_GROUP) {
+				if (!in_group_p(ace->u.e_id))
+					continue;
+			} else {
+				if (current_fsuid() != ace->u.e_id)
+					continue;
+			}
+		} else
+			goto is_everyone;
+
+is_owner:
+		/* The process is in the owner or group file class. */
+		in_owner_or_group_class = 1;
+
+is_everyone:
+		/* Check which mask flags the ACE allows or denies. */
+		if (richace_is_deny(ace))
+			denied |= ace_mask & mask;
+		mask &= ~ace_mask;
+
+		/*
+		 * Keep going until we know which file class
+		 * the process is in.
+		 */
+		if (!mask && in_owner_or_group_class)
+			break;
+	}
+	denied |= mask;
+
+	if (acl->a_flags & ACL4_MASKED) {
+		unsigned int file_mask;
+
+		/*
+		 * The file class a process is in determines which file mask
+		 * applies.  Check if that file mask also grants the requested
+		 * access.
+		 */
+		if (current_fsuid() == inode->i_uid)
+			file_mask = acl->a_owner_mask;
+		else if (in_owner_or_group_class)
+			file_mask = acl->a_group_mask;
+		else
+			file_mask = acl->a_other_mask;
+		denied |= requested & ~file_mask;
+	}
+
+	return denied ? -EACCES : 0;
+}
+EXPORT_SYMBOL_GPL(richacl_permission);
include/linux/richacl.h +2 -0
index 3aa165b..c9d2761 100644
@@ -289,5 +289,7 @@ extern unsigned int richacl_mode_to_mask(mode_t);
 extern unsigned int richacl_want_to_mask(int);
 extern void richacl_compute_max_masks(struct richacl *);
 extern struct richacl *richacl_chmod(struct richacl *, mode_t);
+extern int richacl_permission(struct inode *, const struct richacl *,
+			      unsigned int);
 
 #endif /* __RICHACL_H */
Signature · 1 line
1.7.1
#17 lore raw

PATCH 17/24 richacl: Create-time inheritance

In reply to Aneesh Kumar K.V

When a new file is created, it can inherit an acl from its parent directory; this is similar to how default acls work in POSIX (draft) ACLs.

As with POSIX ACLs, if a file inherits an acl from its parent directory, the intersection between the create mode and the permissions granted by the inherited acl determines the file masks and file permission bits, and the umask is ignored.

---
 fs/Makefile             |    2 +-
 fs/richacl_base.c       |   69 +++++++++++++++++++++++++++++++++++++++++++++++
 fs/richacl_inode.c      |   59 ++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl.h |    4 +++
 4 files changed, 133 insertions(+), 1 deletions(-)
 create mode 100644 fs/richacl_inode.c
fs/Makefile +1 -1
index ed79438..e313219 100644
@@ -49,7 +49,7 @@ obj-$(CONFIG_NFS_COMMON)	+= nfs_common/
 obj-$(CONFIG_GENERIC_ACL)	+= generic_acl.o
 
 obj-$(CONFIG_FS_RICHACL)	+= richacl.o
-richacl-y			:= richacl_base.o
+richacl-y			:= richacl_base.o richacl_inode.o
 
 obj-y				+= quota/
 
fs/richacl_base.c +69 -0

72 lines not on this page · raw message

fs/richacl_inode.c new file +59 -0

59 lines not on this page · raw message

include/linux/richacl.h +4 -0
index c9d2761..630bf86 100644
@@ -291,5 +291,9 @@ extern void richacl_compute_max_masks(struct richacl *);
 extern struct richacl *richacl_chmod(struct richacl *, mode_t);
 extern int richacl_permission(struct inode *, const struct richacl *,
 			      unsigned int);
+extern struct richacl *richacl_inherit(const struct richacl *, int);
 
+/* richacl_inode.c */
+extern struct richacl *richacl_inherit_inode(const struct richacl *,
+					     struct inode *);
 #endif /* __RICHACL_H */
Signature · 1 line
1.7.1
#18 lore raw

PATCH 18/24 richacl: Check if an acl is equivalent to a file mode

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

This function is used to avoid storing richacls on disk if the acl can be computed from the file permission bits.

---
 fs/richacl_base.c       |   54 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl.h |    1 +
 2 files changed, 55 insertions(+), 0 deletions(-)
fs/richacl_base.c +54 -0
index 5e926ad..e60440b 100644
@@ -561,3 +561,57 @@ richacl_inherit(const struct richacl *dir_acl, int isdir)
 
 	return acl;
 }
+
+/**
+ * richacl_equiv_mode  -  check if @acl is equivalent to file permission bits
+ * @mode_p:	the file mode (including the file type)
+ *
+ * If @acl can be fully represented by file permission bits, this function
+ * returns 0, and the file permission bits in @mode_p are set to the equivalent
+ * of @acl.
+ *
+ * This function is used to avoid storing richacls on disk if the acl can be
+ * computed from the file permission bits.  It allows user-space to make sure
+ * that a file has no explicit richacl set.
+ */
+int
+richacl_equiv_mode(const struct richacl *acl, mode_t *mode_p)
+{
+	const struct richace *ace = acl->a_entries;
+	unsigned int x;
+	mode_t mode;
+
+	if (acl->a_count != 1 ||
+	    acl->a_flags != ACL4_MASKED ||
+	    !richace_is_everyone(ace) ||
+	    !richace_is_allow(ace) ||
+	    ace->e_flags & ~ACE4_SPECIAL_WHO)
+		return -1;
+
+	/*
+	 * Figure out the permissions we care about: ACE4_DELETE_CHILD is
+	 * meaningless for non-directories, so we ignore it.
+	 */
+	x = ~ACE4_POSIX_ALWAYS_ALLOWED;
+	if (!S_ISDIR(*mode_p))
+		x &= ~ACE4_DELETE_CHILD;
+
+	mode = richacl_masks_to_mode(acl);
+	if ((acl->a_group_mask & x) != (richacl_mode_to_mask(mode >> 3) & x) ||
+	    (acl->a_other_mask & x) != (richacl_mode_to_mask(mode) & x))
+		return -1;
+
+	/*
+	 * Ignore permissions which the owner is always allowed.
+	 */
+	x &= ~ACE4_POSIX_OWNER_ALLOWED;
+	if ((acl->a_owner_mask & x) != (richacl_mode_to_mask(mode >> 6) & x))
+		return -1;
+
+	if ((ace->e_mask & x) != (ACE4_POSIX_MODE_ALL & x))
+		return -1;
+
+	*mode_p = (*mode_p & ~S_IRWXUGO) | mode;
+	return 0;
+}
+EXPORT_SYMBOL_GPL(richacl_equiv_mode);
include/linux/richacl.h +1 -0
index 630bf86..12a79f1 100644
@@ -292,6 +292,7 @@ extern struct richacl *richacl_chmod(struct richacl *, mode_t);
 extern int richacl_permission(struct inode *, const struct richacl *,
 			      unsigned int);
 extern struct richacl *richacl_inherit(const struct richacl *, int);
+extern int richacl_equiv_mode(const struct richacl *, mode_t *);
 
 /* richacl_inode.c */
 extern struct richacl *richacl_inherit_inode(const struct richacl *,
Signature · 1 line
1.7.1
#19 lore raw

PATCH 19/24 richacl: Automatic Inheritance

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Automatic Inheritance (AI) allows changes to the acl of a directory to recursively propagate down to files and directories in the directory.

To implement this, the kernel keeps track of which permissions have been inherited, and makes sure that permission propagation is turned off when the file permission bits of a file are changed (upon create or chmod).

The actual permission propagation is implemented in user space.

AI works as follows:

- When the ACL4_AUTO_INHERIT flag in the acl of a file is cleared, the file is not affected by AI.

- When the ACL4_AUTO_INHERIT flag in the acl of a directory is set and a file or subdirectory is created in that directory, files created in the directory will have the ACL4_AUTO_INHERIT flag set, and all inherited aces will have the ACE4_INHERITED_ACE flag set. This allows user space to distinguish between aces which have been inherited, and aces which have been explicitly added.

- When the ACL4_PROTECTED acl flag in the acl of a file is set, AI will not modify the acl of the file. This does not affect propagation of permissions from the file to its children (if the file is a directory).

Linux does not have a way of creating files without setting the file permission bits, so all files created inside a directory with ACL4_AUTO_INHERIT set will also have the ACL4_PROTECTED flag set. This effectively disables AI.

Protocols which support creating files without specifying permissions can explicitly clear the ACL4_PROTECTED flag after creating a file (and reset the file masks to "undo" applying the create mode; see richacl_compute_max_masks()). This is a workaround; a per-create or per-process flag indicating to ignore the create mode when AI is in effect would fix this problem.

---
 fs/richacl_base.c       |   10 +++++++++-
 fs/richacl_inode.c      |    7 ++++++-
 include/linux/richacl.h |   25 +++++++++++++++++++++++--
 3 files changed, 38 insertions(+), 4 deletions(-)
fs/richacl_base.c +9 -1
index e60440b..c064c90 100644
@@ -377,7 +377,8 @@ richacl_chmod(struct richacl *acl, mode_t mode)
 	if (acl->a_owner_mask == owner_mask &&
 	    acl->a_group_mask == group_mask &&
 	    acl->a_other_mask == other_mask &&
-	    (acl->a_flags & ACL4_MASKED))
+	    (acl->a_flags & ACL4_MASKED) &&
+	    (!richacl_is_auto_inherit(acl) || richacl_is_protected(acl)))
 		return acl;
 
 	clone = richacl_clone(acl);
@@ -389,6 +390,8 @@ richacl_chmod(struct richacl *acl, mode_t mode)
 	clone->a_owner_mask = owner_mask;
 	clone->a_group_mask = group_mask;
 	clone->a_other_mask = other_mask;
+	if (richacl_is_auto_inherit(clone))
+		clone->a_flags |= ACL4_PROTECTED;
 
 	return clone;
 }
@@ -558,6 +561,11 @@ richacl_inherit(const struct richacl *dir_acl, int isdir)
 			ace++;
 		}
 	}
+	if (richacl_is_auto_inherit(dir_acl)) {
+		acl->a_flags = ACL4_AUTO_INHERIT;
+		richacl_for_each_entry(ace, acl)
+			ace->e_flags |= ACE4_INHERITED_ACE;
+	}
 
 	return acl;
 }
fs/richacl_inode.c +6 -1
index 31e6925..5ae6326 100644
@@ -37,9 +37,14 @@ richacl_inherit_inode(const struct richacl *dir_acl, struct inode *inode)
 
 	acl = richacl_inherit(dir_acl, S_ISDIR(inode->i_mode));
 	if (acl) {
+		/*
+		 * We need to set ACL4_PROTECTED because we are
+		 * doing an implicit chmod
+		 */
+		if (richacl_is_auto_inherit(acl))
+			acl->a_flags |= ACL4_PROTECTED;
 
 		richacl_compute_max_masks(acl);
-
 		/*
 		 * Ensure that the acl will not grant any permissions beyond
 		 * the create mode.
include/linux/richacl.h +23 -2
index 12a79f1..23befbc 100644
@@ -47,10 +47,16 @@ struct richacl {
 	     _ace != _acl->a_entries - 1; \
 	     _ace--)
 
+/* a_flags values */
+#define ACL4_AUTO_INHERIT		0x01
+#define ACL4_PROTECTED			0x02
+/* #define ACL4_DEFAULTED			0x04 */
 /* Flag values defined by rich-acl */
 #define ACL4_MASKED			0x80
 
 #define ACL4_VALID_FLAGS (			\
+		ACL4_AUTO_INHERIT |		\
+		ACL4_PROTECTED |		\
 		ACL4_MASKED)
 
 /* e_type values */
@@ -67,6 +73,7 @@ struct richacl {
 /*#define ACE4_SUCCESSFUL_ACCESS_ACE_FLAG	0x0010*/
 /*#define ACE4_FAILED_ACCESS_ACE_FLAG	0x0020*/
 #define ACE4_IDENTIFIER_GROUP		0x0040
+#define ACE4_INHERITED_ACE		0x0080
 /* in-memory representation only */
 #define ACE4_SPECIAL_WHO		0x4000
 
@@ -75,7 +82,8 @@ struct richacl {
 	ACE4_DIRECTORY_INHERIT_ACE |		\
 	ACE4_NO_PROPAGATE_INHERIT_ACE |		\
 	ACE4_INHERIT_ONLY_ACE |			\
-	ACE4_IDENTIFIER_GROUP)
+	ACE4_IDENTIFIER_GROUP |			\
+	ACE4_INHERITED_ACE)
 
 /* e_mask bitflags */
 #define ACE4_READ_DATA			0x00000001
@@ -181,6 +189,18 @@ richacl_put(struct richacl *acl)
 		kfree(acl);
 }
 
+static inline int
+richacl_is_auto_inherit(const struct richacl *acl)
+{
+	return acl->a_flags & ACL4_AUTO_INHERIT;
+}
+
+static inline int
+richacl_is_protected(const struct richacl *acl)
+{
+	return acl->a_flags & ACL4_PROTECTED;
+}
+
 /*
  * Special e_who identifiers: we use these pointer values in comparisons
  * instead of doing a strcmp.
@@ -259,7 +279,8 @@ richace_clear_inheritance_flags(struct richace *ace)
 	ace->e_flags &= ~(ACE4_FILE_INHERIT_ACE |
 			  ACE4_DIRECTORY_INHERIT_ACE |
 			  ACE4_NO_PROPAGATE_INHERIT_ACE |
-			  ACE4_INHERIT_ONLY_ACE);
+			  ACE4_INHERIT_ONLY_ACE |
+			  ACE4_INHERITED_ACE);
 }
 
 /**
Signature · 1 line
1.7.1
#20 lore raw

PATCH 20/24 richacl: xattr mapping functions

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Map between "system.richacl" xattrs and the in-kernel representation.

---
 fs/Makefile                   |    2 +-
 fs/richacl_xattr.c            |  156 +++++++++++++++++++++++++++++++++++++++++
 include/linux/richacl_xattr.h |   47 ++++++++++++
 3 files changed, 204 insertions(+), 1 deletions(-)
 create mode 100644 fs/richacl_xattr.c
 create mode 100644 include/linux/richacl_xattr.h
fs/Makefile +1 -1
index e313219..4e52702 100644
@@ -49,7 +49,7 @@ obj-$(CONFIG_NFS_COMMON)	+= nfs_common/
 obj-$(CONFIG_GENERIC_ACL)	+= generic_acl.o
 
 obj-$(CONFIG_FS_RICHACL)	+= richacl.o
-richacl-y			:= richacl_base.o richacl_inode.o
+richacl-y			:= richacl_base.o richacl_inode.o richacl_xattr.o
 
 obj-y				+= quota/
 
fs/richacl_xattr.c new file +156 -0

156 lines not on this page · raw message

include/linux/richacl_xattr.h new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.7.1
#21 lore raw

PATCH 21/24 ext4: Use IS_POSIXACL() to check for POSIX ACL support

In reply to Aneesh Kumar K.V

Use IS_POSIXACL() instead of a file system specific mount flag since we have IS_POSIXACL() in the vfs already, anyway.

---
 fs/ext4/acl.c   |   16 ++++++++--------
 fs/ext4/ext4.h  |    1 -
 fs/ext4/super.c |   16 +++++-----------
 3 files changed, 13 insertions(+), 20 deletions(-)
fs/ext4/acl.c +8 -8
index e0270d1..364514c 100644
@@ -139,7 +139,7 @@ ext4_get_acl(struct inode *inode, int type)
 	struct posix_acl *acl;
 	int retval;
 
-	if (!test_opt(inode->i_sb, POSIX_ACL))
+	if (!IS_POSIXACL(inode))
 		return NULL;
 
 	acl = get_cached_acl(inode, type);
@@ -273,7 +273,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
 	int error = 0;
 
 	if (!S_ISLNK(inode->i_mode)) {
-		if (test_opt(dir->i_sb, POSIX_ACL)) {
+		if (IS_POSIXACL(inode)) {
 			acl = ext4_get_acl(dir, ACL_TYPE_DEFAULT);
 			if (IS_ERR(acl))
 				return PTR_ERR(acl);
@@ -281,7 +281,7 @@ ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)
 		if (!acl)
 			inode->i_mode &= ~current_umask();
 	}
-	if (test_opt(inode->i_sb, POSIX_ACL) && acl) {
+	if (IS_POSIXACL(inode) && acl) {
 		struct posix_acl *clone;
 		mode_t mode;
 
@@ -335,7 +335,7 @@ ext4_acl_chmod(struct inode *inode)
 
 	if (S_ISLNK(inode->i_mode))
 		return -EOPNOTSUPP;
-	if (!test_opt(inode->i_sb, POSIX_ACL))
+	if (!IS_POSIXACL(inode))
 		return 0;
 	acl = ext4_get_acl(inode, ACL_TYPE_ACCESS);
 	if (IS_ERR(acl) || !acl)
@@ -377,7 +377,7 @@ ext4_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_len,
 {
 	const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);
 
-	if (!test_opt(dentry->d_sb, POSIX_ACL))
+	if (!IS_POSIXACL(dentry->d_inode))
 		return 0;
 	if (list && size <= list_len)
 		memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
@@ -390,7 +390,7 @@ ext4_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_len,
 {
 	const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);
 
-	if (!test_opt(dentry->d_sb, POSIX_ACL))
+	if (!IS_POSIXACL(dentry->d_inode))
 		return 0;
 	if (list && size <= list_len)
 		memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
@@ -406,7 +406,7 @@ ext4_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
 
 	if (strcmp(name, "") != 0)
 		return -EINVAL;
-	if (!test_opt(dentry->d_sb, POSIX_ACL))
+	if (!IS_POSIXACL(dentry->d_inode))
 		return -EOPNOTSUPP;
 
 	acl = ext4_get_acl(dentry->d_inode, type);
@@ -431,7 +431,7 @@ ext4_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
 
 	if (strcmp(name, "") != 0)
 		return -EINVAL;
-	if (!test_opt(inode->i_sb, POSIX_ACL))
+	if (!IS_POSIXACL(dentry->d_inode))
 		return -EOPNOTSUPP;
 	if (!is_owner_or_cap(inode))
 		return -EPERM;
fs/ext4/ext4.h +0 -1
index 3aa0b72..5d1f56a 100644
@@ -892,7 +892,6 @@ struct ext4_inode_info {
 #define EXT4_MOUNT_UPDATE_JOURNAL	0x01000	/* Update the journal format */
 #define EXT4_MOUNT_NO_UID32		0x02000  /* Disable 32-bit UIDs */
 #define EXT4_MOUNT_XATTR_USER		0x04000	/* Extended user attributes */
-#define EXT4_MOUNT_POSIX_ACL		0x08000	/* POSIX Access Control Lists */
 #define EXT4_MOUNT_NO_AUTO_DA_ALLOC	0x10000	/* No auto delalloc mapping */
 #define EXT4_MOUNT_BARRIER		0x20000 /* Use block barriers */
 #define EXT4_MOUNT_QUOTA		0x80000 /* Some quota option set */
fs/ext4/super.c +5 -11
index f6a318f..adc97b7 100644
@@ -1006,9 +1006,9 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
 	}
 #endif
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
-	if (test_opt(sb, POSIX_ACL) && !(def_mount_opts & EXT4_DEFM_ACL))
+	if ((sb->s_flags & MS_POSIXACL) && !(def_mount_opts & EXT4_DEFM_ACL))
 		seq_puts(seq, ",acl");
-	if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT4_DEFM_ACL))
+	if (!(sb->s_flags & MS_POSIXACL) && (def_mount_opts & EXT4_DEFM_ACL))
 		seq_puts(seq, ",noacl");
 #endif
 	if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) {
@@ -1529,10 +1529,10 @@ static int parse_options(char *options, struct super_block *sb,
 #endif
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
 		case Opt_acl:
-			set_opt(sb, POSIX_ACL);
+			sb->s_flags |= MS_POSIXACL;
 			break;
 		case Opt_noacl:
-			clear_opt(sb, POSIX_ACL);
+			sb->s_flags &= ~MS_POSIXACL;
 			break;
 #else
 		case Opt_acl:
@@ -3101,7 +3101,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 #endif
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
 	if (def_mount_opts & EXT4_DEFM_ACL)
-		set_opt(sb, POSIX_ACL);
+		sb->s_flags |= MS_POSIXACL;
 #endif
 	if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
 		set_opt(sb, JOURNAL_DATA);
@@ -3148,9 +3148,6 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 			   &journal_ioprio, NULL, 0))
 		goto failed_mount;
 
-	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-		(test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
-
 	if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV &&
 	    (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) ||
 	     EXT4_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
@@ -4235,9 +4232,6 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data)
 	if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED)
 		ext4_abort(sb, "Abort forced by user");
 
-	sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
-		(test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0);
-
 	es = sbi->s_es;
 
 	if (sbi->s_journal) {
Signature · 1 line
1.7.1
#22 lore raw

PATCH 22/24 vfs: Cache richacl in struct inode

In reply to Aneesh Kumar K.V

From: Andreas Gruenbacher <[email protected]>

Cache richacls in struct inode so that this doesn't have to be done individually in each filesystem.

---
 fs/inode.c              |   24 ++++++++++++++++----
 include/linux/fs.h      |   12 ++++++++-
 include/linux/richacl.h |   53 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 7 deletions(-)
fs/inode.c +19 -5
index da85e56..381edca 100644
@@ -25,6 +25,7 @@
 #include <linux/async.h>
 #include <linux/posix_acl.h>
 #include <linux/ima.h>
+#include <linux/richacl.h>
 
 /*
  * This is needed for the following functions:
@@ -219,7 +220,12 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
 	inode->i_private = NULL;
 	inode->i_mapping = mapping;
 #ifdef CONFIG_FS_POSIX_ACL
-	inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
+	if (IS_POSIXACL(inode))
+		inode->i_acl = inode->i_default_acl = ACL_NOT_CACHED;
+#endif
+#ifdef CONFIG_FS_RICHACL
+	if (IS_RICHACL(inode))
+		inode->i_richacl = ACL_NOT_CACHED;
 #endif
 
 #ifdef CONFIG_FSNOTIFY
@@ -269,10 +275,18 @@ void __destroy_inode(struct inode *inode)
 	security_inode_free(inode);
 	fsnotify_inode_delete(inode);
 #ifdef CONFIG_FS_POSIX_ACL
-	if (inode->i_acl && inode->i_acl != ACL_NOT_CACHED)
-		posix_acl_release(inode->i_acl);
-	if (inode->i_default_acl && inode->i_default_acl != ACL_NOT_CACHED)
-		posix_acl_release(inode->i_default_acl);
+	if (IS_POSIXACL(inode)) {
+		if (inode->i_acl != ACL_NOT_CACHED)
+			posix_acl_release(inode->i_acl);
+		if (inode->i_default_acl != ACL_NOT_CACHED)
+			posix_acl_release(inode->i_default_acl);
+	}
+#endif
+#ifdef CONFIG_FS_RICHACL
+	if (IS_RICHACL(inode)) {
+		if (inode->i_richacl != ACL_NOT_CACHED)
+			richacl_put(inode->i_richacl);
+	}
 #endif
 	this_cpu_dec(nr_inodes);
 }
include/linux/fs.h +10 -2
index 1627592..77ce324 100644
@@ -754,6 +754,7 @@ static inline int mapping_writably_mapped(struct address_space *mapping)
 #endif
 
 struct posix_acl;
+struct richacl;
 #define ACL_NOT_CACHED ((void *)(-1))
 
 struct inode {
@@ -824,10 +825,17 @@ struct inode {
 #ifdef CONFIG_SECURITY
 	void			*i_security;
 #endif
+	union {
 #ifdef CONFIG_FS_POSIX_ACL
-	struct posix_acl	*i_acl;
-	struct posix_acl	*i_default_acl;
+		struct {
+			struct posix_acl *i_acl;
+			struct posix_acl *i_default_acl;
+		};
 #endif
+#ifdef CONFIG_FS_RICHACL
+		struct richacl	*i_richacl;
+#endif
+	};
 	void			*i_private; /* fs or device private pointer */
 };
 
include/linux/richacl.h +53 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.1
#23 lore raw

PATCH 23/24 ext4: Implement rich acl for ext4

In reply to Aneesh Kumar K.V

Support the richacl permission model in ext4. The richacls are stored in "system.richacl" xattrs.This need to be enabled by tune2fs or during mkfs.ext4

---
 fs/ext4/Kconfig   |   15 +++
 fs/ext4/Makefile  |    3 +-
 fs/ext4/acl.c     |    2 +-
 fs/ext4/acl.h     |    3 +-
 fs/ext4/acls.c    |   20 ++++
 fs/ext4/ext4.h    |    6 ++
 fs/ext4/file.c    |    1 +
 fs/ext4/ialloc.c  |    7 ++-
 fs/ext4/inode.c   |   10 ++-
 fs/ext4/richacl.c |  255 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ext4/richacl.h |   45 ++++++++++
 fs/ext4/xattr.c   |    6 ++
 fs/ext4/xattr.h   |    2 +
 13 files changed, 367 insertions(+), 8 deletions(-)
 create mode 100644 fs/ext4/acls.c
 create mode 100644 fs/ext4/richacl.c
 create mode 100644 fs/ext4/richacl.h
fs/ext4/Kconfig +15 -0
index 9ed1bb1..a22b8f1 100644
@@ -83,3 +83,18 @@ config EXT4_DEBUG
 
 	  If you select Y here, then you will be able to turn on debugging
 	  with a command such as "echo 1 > /sys/kernel/debug/ext4/mballoc-debug"
+
+config EXT4_FS_RICHACL
+      bool "Ext4 Rich Access Control Lists (EXPERIMENTAL)"
+      depends on EXT4_FS_XATTR && EXPERIMENTAL
+      select FS_RICHACL
+      help
+	Rich ACLs are an implementation of NFSv4 ACLs, extended by file masks
+	to fit into the standard POSIX file permission model.  They are
+	designed to work seamlessly locally as well as across the NFSv4 and
+	CIFS/SMB2 network file system protocols.
+
+	To learn more about Rich ACL, visit
+	http://acl.bestbits.at/richacl/
+
+	If you don't know what Rich ACLs are, say N
fs/ext4/Makefile +2 -1
index c947e36..a37e439 100644
@@ -9,5 +9,6 @@ ext4-y	:= balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \
 		ext4_jbd2.o migrate.o mballoc.o block_validity.o move_extent.o
 
 ext4-$(CONFIG_EXT4_FS_XATTR)		+= xattr.o xattr_user.o xattr_trusted.o
-ext4-$(CONFIG_EXT4_FS_POSIX_ACL)	+= acl.o
+ext4-$(CONFIG_EXT4_FS_POSIX_ACL)	+= acls.o acl.o
 ext4-$(CONFIG_EXT4_FS_SECURITY)		+= xattr_security.o
+ext4-$(CONFIG_EXT4_FS_RICHACL)  	+= acls.o richacl.o
fs/ext4/acl.c +1 -1
index 364514c..aa9257e 100644
@@ -238,7 +238,7 @@ ext4_set_acl(handle_t *handle, struct inode *inode, int type,
 }
 
 int
-ext4_check_acl(struct inode *inode, int mask, unsigned int flags)
+ext4_check_posix_acl(struct inode *inode, int mask, unsigned int flags)
 {
 	struct posix_acl *acl;
 
fs/ext4/acl.h +1 -2
index dec8211..296ee5b 100644
@@ -54,13 +54,12 @@ static inline int ext4_acl_count(size_t size)
 #ifdef CONFIG_EXT4_FS_POSIX_ACL
 
 /* acl.c */
-extern int ext4_check_acl(struct inode *, int, unsigned int);
+extern int ext4_check_posix_acl(struct inode *, int, unsigned int);
 extern int ext4_acl_chmod(struct inode *);
 extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
 
 #else  /* CONFIG_EXT4_FS_POSIX_ACL */
 #include <linux/sched.h>
-#define ext4_check_acl NULL
 
 static inline int
 ext4_acl_chmod(struct inode *inode)
fs/ext4/acls.c new file +20 -0
new file mode 100644
index 0000000..c23fcef
@@ -0,0 +1,20 @@
+#include <linux/fs.h>
+#include "ext4.h"
+#include "acl.h"
+#include "richacl.h"
+
+int
+ext4_check_acl(struct inode *inode, int mask, unsigned int flags)
+{
+#ifdef CONFIG_EXT4_FS_POSIX_ACL
+	if (IS_POSIXACL(inode))
+		return ext4_check_posix_acl(inode, mask, flags);
+	else
+#endif
+#ifdef CONFIG_EXT4_FS_RICHACL
+	if (IS_RICHACL(inode))
+		return ext4_check_richacl(inode, mask, flags);
+	else
+#endif
+		return -EAGAIN;
+}
fs/ext4/ext4.h +6 -0
index 5d1f56a..f0e09ba 100644
@@ -1754,6 +1754,12 @@ extern int ext4_orphan_del(handle_t *, struct inode *);
 extern int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
 				__u32 start_minor_hash, __u32 *next_hash);
 
+#if defined(CONFIG_EXT4_FS_POSIX_ACL) || defined(CONFIG_EXT4_FS_RICHACL)
+extern int ext4_check_acl(struct inode *, int, unsigned int);
+#else
+# define ext4_check_acl NULL
+#endif
+
 /* resize.c */
 extern int ext4_group_add(struct super_block *sb,
 				struct ext4_new_group_data *input);
fs/ext4/file.c +1 -0
index 7b80d54..0df1da6 100644
@@ -28,6 +28,7 @@
 #include "ext4_jbd2.h"
 #include "xattr.h"
 #include "acl.h"
+#include "richacl.h"
 
 /*
  * Called when an inode is released. Note that this is different
fs/ext4/ialloc.c +6 -1
index eb9097a..245e22f 100644
@@ -28,6 +28,7 @@
 #include "ext4_jbd2.h"
 #include "xattr.h"
 #include "acl.h"
+#include "richacl.h"
 
 #include <trace/events/ext4.h>
 
@@ -1038,7 +1039,11 @@ got:
 	if (err)
 		goto fail_drop;
 
-	err = ext4_init_acl(handle, inode, dir);
+	if (EXT4_IS_RICHACL(dir))
+		err = ext4_init_richacl(handle, inode, dir);
+	else
+		err = ext4_init_acl(handle, inode, dir);
+
 	if (err)
 		goto fail_free_drop;
 
fs/ext4/inode.c +7 -3
index 9f7f9e4..7fb0920 100644
@@ -47,6 +47,7 @@
 #include "xattr.h"
 #include "acl.h"
 #include "ext4_extents.h"
+#include "richacl.h"
 
 #include <trace/events/ext4.h>
 
@@ -5417,9 +5418,12 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
 	if (orphan && inode->i_nlink)
 		ext4_orphan_del(NULL, inode);
 
-	if (!rc && (ia_valid & ATTR_MODE))
-		rc = ext4_acl_chmod(inode);
-
+	if (!rc && (ia_valid & ATTR_MODE)) {
+		if (EXT4_IS_RICHACL(inode))
+			rc = ext4_richacl_chmod(inode);
+		else
+			rc = ext4_acl_chmod(inode);
+	}
 err_out:
 	ext4_std_error(inode->i_sb, error);
 	if (!error)
fs/ext4/richacl.c new file +255 -0

255 lines not on this page · raw message

fs/ext4/richacl.h new file +45 -0

45 lines not on this page · raw message

fs/ext4/xattr.c +6 -0
index fc32176..1984bb9 100644
@@ -107,6 +107,9 @@ static const struct xattr_handler *ext4_xattr_handler_map[] = {
 #ifdef CONFIG_EXT4_FS_SECURITY
 	[EXT4_XATTR_INDEX_SECURITY]	     = &ext4_xattr_security_handler,
 #endif
+#ifdef CONFIG_EXT4_FS_RICHACL
+	[EXT4_XATTR_INDEX_RICHACL]           = &ext4_richacl_xattr_handler,
+#endif
 };
 
 const struct xattr_handler *ext4_xattr_handlers[] = {
@@ -119,6 +122,9 @@ const struct xattr_handler *ext4_xattr_handlers[] = {
 #ifdef CONFIG_EXT4_FS_SECURITY
 	&ext4_xattr_security_handler,
 #endif
+#ifdef CONFIG_EXT4_FS_RICHACL
+	&ext4_richacl_xattr_handler,
+#endif
 	NULL
 };
 
fs/ext4/xattr.h +2 -0
index 1ef1652..5cede1a 100644
@@ -21,6 +21,7 @@
 #define EXT4_XATTR_INDEX_TRUSTED		4
 #define	EXT4_XATTR_INDEX_LUSTRE			5
 #define EXT4_XATTR_INDEX_SECURITY	        6
+#define EXT4_XATTR_INDEX_RICHACL		7
 
 struct ext4_xattr_header {
 	__le32	h_magic;	/* magic number for identification */
@@ -70,6 +71,7 @@ extern const struct xattr_handler ext4_xattr_trusted_handler;
 extern const struct xattr_handler ext4_xattr_acl_access_handler;
 extern const struct xattr_handler ext4_xattr_acl_default_handler;
 extern const struct xattr_handler ext4_xattr_security_handler;
+extern const struct xattr_handler ext4_richacl_xattr_handler;
 
 extern ssize_t ext4_listxattr(struct dentry *, char *, size_t);
 
Signature · 1 line
1.7.1
#24 lore raw

PATCH 24/24 ext4: Add temporary richacl mount option for ext4

In reply to Aneesh Kumar K.V

This helps in easy testing of the patchset. The mount option will be later removed in favour of a feature flag.

***Should be folded before merging***

---
 fs/ext4/super.c |   52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 41 insertions(+), 11 deletions(-)
fs/ext4/super.c +41 -11
index adc97b7..9f3fe61 100644
@@ -1011,6 +1011,10 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
 	if (!(sb->s_flags & MS_POSIXACL) && (def_mount_opts & EXT4_DEFM_ACL))
 		seq_puts(seq, ",noacl");
 #endif
+#ifdef CONFIG_EXT4_FS_RICHACL
+	if (sb->s_flags & MS_RICHACL)
+		seq_puts(seq, ",richacl");
+#endif
 	if (sbi->s_commit_interval != JBD2_DEFAULT_MAX_COMMIT_AGE*HZ) {
 		seq_printf(seq, ",commit=%u",
 			   (unsigned) (sbi->s_commit_interval / HZ));
@@ -1262,6 +1266,7 @@ enum {
 	Opt_dioread_nolock, Opt_dioread_lock,
 	Opt_discard, Opt_nodiscard,
 	Opt_init_inode_table, Opt_noinit_inode_table,
+	Opt_richacl,
 };
 
 static const match_table_t tokens = {
@@ -1337,6 +1342,7 @@ static const match_table_t tokens = {
 	{Opt_init_inode_table, "init_itable=%u"},
 	{Opt_init_inode_table, "init_itable"},
 	{Opt_noinit_inode_table, "noinit_itable"},
+	{Opt_richacl, "richacl"},
 	{Opt_err, NULL},
 };
 
@@ -1363,6 +1369,35 @@ static ext4_fsblk_t get_sb_block(void **data)
 	return sb_block;
 }
 
+static void enable_acl(struct super_block *sb)
+{
+#if !defined(CONFIG_EXT4_FS_POSIX_ACL)
+	ext4_msg(sb, KERN_ERR, "acl options not supported");
+	return;
+#endif
+	sb->s_flags |= MS_POSIXACL;
+}
+
+static void disable_acl(struct super_block *sb)
+{
+#if !defined(CONFIG_EXT4_FS_POSIX_ACL)
+	ext4_msg(sb, KERN_ERR, "acl options not supported");
+	return;
+#endif
+	sb->s_flags &= ~MS_POSIXACL;
+	return;
+}
+
+static void enable_richacl(struct super_block *sb)
+{
+#if !defined(CONFIG_EXT4_FS_RICHACL)
+	ext4_msg(sb, KERN_ERR, "richacl options not supported");
+	return;
+#endif
+	sb->s_flags |= MS_RICHACL;
+	return;
+}
+
 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
 static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
 	"Contact [email protected] if you think we should keep it.\n";
@@ -1527,19 +1562,12 @@ static int parse_options(char *options, struct super_block *sb,
 			ext4_msg(sb, KERN_ERR, "(no)user_xattr options not supported");
 			break;
 #endif
-#ifdef CONFIG_EXT4_FS_POSIX_ACL
 		case Opt_acl:
-			sb->s_flags |= MS_POSIXACL;
+			enable_acl(sb);
 			break;
 		case Opt_noacl:
-			sb->s_flags &= ~MS_POSIXACL;
+			disable_acl(sb);
 			break;
-#else
-		case Opt_acl:
-		case Opt_noacl:
-			ext4_msg(sb, KERN_ERR, "(no)acl options not supported");
-			break;
-#endif
 		case Opt_journal_update:
 			/* @@@ FIXME */
 			/* Eventually we will want to be able to create
@@ -1826,6 +1854,8 @@ set_qf_format:
 			break;
 		case Opt_noinit_inode_table:
 			clear_opt(sb, INIT_INODE_TABLE);
+		case Opt_richacl:
+			enable_richacl(sb);
 			break;
 		default:
 			ext4_msg(sb, KERN_ERR,
@@ -3099,9 +3129,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
 	if (def_mount_opts & EXT4_DEFM_XATTR_USER)
 		set_opt(sb, XATTR_USER);
 #endif
-#ifdef CONFIG_EXT4_FS_POSIX_ACL
+#if defined(CONFIG_EXT4_FS_POSIX_ACL)
 	if (def_mount_opts & EXT4_DEFM_ACL)
-		sb->s_flags |= MS_POSIXACL;
+		enable_acl(sb);
 #endif
 	if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA)
 		set_opt(sb, JOURNAL_DATA);
Signature · 1 line
1.7.1
maintainer
#25 lore raw
In reply to Aneesh Kumar K.V

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#26 lore raw
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 5 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

vfs: Make acl_permission_check() work for richacls
vfs: Add permission flags for setting file attributes
vfs: Make the inode passed to inode_change_ok non-const
vfs: Add delete child and delete self permission flags
vfs: Add new file and directory create permission flags
vfs: Optimize out IS_RICHACL() if CONFIG_FS_RICHACL is not defined
vfs: Add IS_RICHACL() test for richacl support
vfs: Add generic IS_ACL() test for acl support
vfs: Add a comment to inode_permission()
vfs: Pass all mask flags down to iop->check_acl
vfs: Indicate that the permission functions take all the MAY_* flags

-aneesh

#27 lore raw
Quoted 21 lines · Aneesh Kumar K. V
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

Why aren't all of them ready?

--b.

Quoted 14 lines

vfs: Make acl_permission_check() work for richacls
vfs: Add permission flags for setting file attributes
vfs: Make the inode passed to inode_change_ok non-const
vfs: Add delete child and delete self permission flags
vfs: Add new file and directory create permission flags
vfs: Optimize out IS_RICHACL() if CONFIG_FS_RICHACL is not defined
vfs: Add IS_RICHACL() test for richacl support
vfs: Add generic IS_ACL() test for acl support
vfs: Add a comment to inode_permission()
vfs: Pass all mask flags down to iop->check_acl
vfs: Indicate that the permission functions take all the MAY_* flags

-aneesh

#28 lore raw
Quoted 27 lines · J. Bruce Fields
Quoted 26 lines · Aneesh Kumar K. V
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 5 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

Quoted 5 lines
Quoted 2 lines

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

Why aren't all of them ready?

All except how to enable richacl in local file system is ready. I actually floated two ideas in the patch series

1) mount option
2) Ext4 compat flags.

If we can get to decide which one, then the entire set can go in. We also want others to review the richacl format. If that cannot be completed by next merge window there is no reason to prevent the vfs changes from going in. VFS changes are independent of richacl format.

-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#29 lore raw
Quoted 31 lines · Aneesh Kumar K. V
Quoted 30 lines · J. Bruce Fields
Quoted 28 lines · Aneesh Kumar K. V
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 5 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

Quoted 8 lines
Quoted 2 lines

Why aren't all of them ready?

All except how to enable richacl in local file system is ready. I actually floated two ideas in the patch series

1) mount option
2) Ext4 compat flags.

The choice of ACL format is a persistant property of the filesystem, not of a single mount of the filesystem: for example, people can't try out richacls for one mount and then decide to revert bacak to posix acls.

(Right?) So I'm assuming we should use the latter--but I don't understand what ext4 compat flags are.... Is there some disadvantage to using them?

--b.

Quoted 5 lines

If we can get to decide which one, then the entire set can go in. We also want others to review the richacl format. If that cannot be completed by next merge window there is no reason to prevent the vfs changes from going in. VFS changes are independent of richacl format.

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#30 lore raw
Quoted 41 lines · J. Bruce Fields
Quoted 31 lines · Aneesh Kumar K. V
Quoted 30 lines · J. Bruce Fields
Quoted 28 lines · Aneesh Kumar K. V
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 5 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

Quoted 8 lines
Quoted 2 lines

Why aren't all of them ready?

All except how to enable richacl in local file system is ready. I actually floated two ideas in the patch series

1) mount option
2) Ext4 compat flags.

Quoted 8 lines

The choice of ACL format is a persistant property of the filesystem, not of a single mount of the filesystem: for example, people can't try out richacls for one mount and then decide to revert bacak to posix acls.

(Right?) So I'm assuming we should use the latter--but I don't understand what ext4 compat flags are.... Is there some disadvantage to using them?

We already have a mount option to enable posix acl (-o acl|noacl). So along the same line should we have -o richacl|norichacl or should we have richacl as a ext4 compat flag EXT4_FEATURE_COMPAT_RICHACL. The compat feature can be enabled via tune2fs for an already created file system. Once the compat feature is enabled a -o acl mount option cause the richacl access check to be enabled. That can also result in mapping the existing posix acl in the file system to richacl and using mapped richacl for access restriction. With compat flag once set we will never be able to mount the file system again to use posix acl access restriction. (We cannot map richacl to posixacl because richacl support advanced access masks)

With mount option (-o richacl) we can still mount the file system with -o acl which implies we will have to ignore the richacl associated with files and only evaluate the posix acl stored.

-aneesh

#31 lore raw
Quoted 51 lines · Aneesh Kumar K. V
Quoted 41 lines · J. Bruce Fields
Quoted 31 lines · Aneesh Kumar K. V
Quoted 30 lines · J. Bruce Fields
Quoted 28 lines · Aneesh Kumar K. V
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 5 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

Quoted 8 lines
Quoted 2 lines

Why aren't all of them ready?

All except how to enable richacl in local file system is ready. I actually floated two ideas in the patch series

1) mount option
2) Ext4 compat flags.

Quoted 8 lines

The choice of ACL format is a persistant property of the filesystem, not of a single mount of the filesystem: for example, people can't try out richacls for one mount and then decide to revert bacak to posix acls.

(Right?) So I'm assuming we should use the latter--but I don't understand what ext4 compat flags are.... Is there some disadvantage to using them?

Quoted 11 lines

We already have a mount option to enable posix acl (-o acl|noacl). So along the same line should we have -o richacl|norichacl or should we have richacl as a ext4 compat flag EXT4_FEATURE_COMPAT_RICHACL. The compat feature can be enabled via tune2fs for an already created file system. Once the compat feature is enabled a -o acl mount option cause the richacl access check to be enabled. That can also result in mapping the existing posix acl in the file system to richacl and using mapped richacl for access restriction. With compat flag once set we will never be able to mount the file system again to use posix acl access restriction. (We cannot map richacl to posixacl because richacl support advanced access masks)

Sounds fine to me. I'm not sure you answered my question. Is there any disadvantage to doing it this way?

--b.

Quoted 3 lines

With mount option (-o richacl) we can still mount the file system with -o acl which implies we will have to ignore the richacl associated with files and only evaluate the posix acl stored.

#32 lore raw
Quoted 64 lines · J. Bruce Fields
Quoted 51 lines · Aneesh Kumar K. V
Quoted 41 lines · J. Bruce Fields
Quoted 31 lines · Aneesh Kumar K. V
Quoted 30 lines · J. Bruce Fields
Quoted 28 lines · Aneesh Kumar K. V
Quoted 5 lines · Ted Ts'o

Hi Aneesh,

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

The main objection raised was the use of may_delete and may_create inode operations callback. They are gone now and we have MAY_* flags as favoured by Al Viro. The new MAY_* flags added are

#define MAY_CREATE_FILE 128
#define MAY_CREATE_DIR 256
#define MAY_DELETE_CHILD 512
#define MAY_DELETE_SELF 1024
#define MAY_TAKE_OWNERSHIP 2048
#define MAY_CHMOD 4096
#define MAY_SET_TIMES 8192

Quoted 5 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

IMHO we are ready to get first 11 patches upstream in the next merge window. ie the below set of patches.

Quoted 8 lines
Quoted 2 lines

Why aren't all of them ready?

All except how to enable richacl in local file system is ready. I actually floated two ideas in the patch series

1) mount option
2) Ext4 compat flags.

Quoted 8 lines

The choice of ACL format is a persistant property of the filesystem, not of a single mount of the filesystem: for example, people can't try out richacls for one mount and then decide to revert bacak to posix acls.

(Right?) So I'm assuming we should use the latter--but I don't understand what ext4 compat flags are.... Is there some disadvantage to using them?

Quoted 11 lines

We already have a mount option to enable posix acl (-o acl|noacl). So along the same line should we have -o richacl|norichacl or should we have richacl as a ext4 compat flag EXT4_FEATURE_COMPAT_RICHACL. The compat feature can be enabled via tune2fs for an already created file system. Once the compat feature is enabled a -o acl mount option cause the richacl access check to be enabled. That can also result in mapping the existing posix acl in the file system to richacl and using mapped richacl for access restriction. With compat flag once set we will never be able to mount the file system again to use posix acl access restriction. (We cannot map richacl to posixacl because richacl support advanced access masks)

Quoted 3 lines

Sounds fine to me. I'm not sure you answered my question. Is there any disadvantage to doing it this way?

Andreas didn't like the compat feature flag patch. I don't remember why though. Andreas can you comment on why you didn't want the compat feature flag ?

-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#33 lore raw

Aneesh,

Quoted 3 lines · On Saturday 05 March 2011 18:58:12 Aneesh Kumar K. V wrote:

Andreas didn't like the compat feature flag patch. I don't remember why though. Andreas can you comment on why you didn't want the compat feature flag ?

The mount option made developing and testing of the patch set easier because it didn't require a modification to e2fsprogs. For upstream, the feature flag (*) makes a lot more sense, though.

(*) http://git.kernel.org/?p=linux/kernel/git/kvaneesh/linux-richacl.git;h=fb5c519

Thanks,
Andreas

#34 lore raw
In reply to Ted Ts'o

Hi,

On 2011-02-28 at 16:11 -0500 Ted Ts'o sent off:

Quoted 7 lines

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

after the discussion of this path submission thread are there any major or minor issues left that prevent these to go upstream? I'd really love to see NFSv4 ACLs being available on Linux, too.

Cheers
Björn

#35 lore raw
Quoted 7 lines · Björn JACKE

Hi,

On 2011-02-28 at 16:11 -0500 Ted Ts'o sent off:

Quoted 4 lines

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

Quoted 8 lines
Quoted 3 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

after the discussion of this path submission thread are there any major or minor issues left that prevent these to go upstream? I'd really love to see NFSv4 ACLs being available on Linux, too.

I updated richaclv23 branch at

http://git.kernel.org/?p=linux/kernel/git/kvaneesh/linux-richacl.git;a=summary

which is rebased against latest linus tree. The changes pass richacl test against local file system. I am yet to test richacl on NFS client. Once i get the results i will repost the series again.

-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#36 lore raw
In reply to Björn JACKE
Quoted 7 lines · Björn JACKE

Hi,

On 2011-02-28 at 16:11 -0500 Ted Ts'o sent off:

Quoted 4 lines

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

Quoted 8 lines
Quoted 3 lines

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

after the discussion of this path submission thread are there any major or minor issues left that prevent these to go upstream? I'd really love to see NFSv4 ACLs being available on Linux, too.

I updated richaclv23 branch at

http://git.kernel.org/?p=linux/kernel/git/kvaneesh/linux-richacl.git;a=summary

which is rebased against latest linus tree. The changes pass richacl test against local file system. I am yet to test richacl on NFS client. Once i get the results i will repost the series again.

-aneesh
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

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

#38 lore raw

On Thu, 12 May 2011 00:16:13 +0200, Bj=C3=B6rn JACKE <[email protected]> wro= te:

Quoted 4 lines

Hi,
=20
On 2011-02-28 at 16:11 -0500 Ted Ts'o sent off:

Quoted 1 line

What is the current status of this patch series? I seem to remembe=

r

Quoted 4 lines
Quoted 4 lines

that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are? =20
To be honest I haven't been paying super close attention to this pa=

tch

Quoted 4 lines
Quoted 2 lines

series, and I'm curious what needs to happen with it one way or another.

=20
after the discussion of this path submission thread are there any maj=

or or

Quoted 1 line

minor issues left that prevent these to go upstream? I'd really love =

to see

Quoted 2 lines

NFSv4 ACLs being available on Linux, too.
=20

I updated richaclv23 branch at=20

http://git.kernel.org/?p=3Dlinux/kernel/git/kvaneesh/linux-richacl.git;=
a=3Dsummary

which is rebased against latest linus tree. The changes pass richacl test against local file system. I am yet to test richacl on NFS client. Once i get the results i will repost the series again.=20

-aneesh

#39 lore raw
In reply to Ted Ts'o

Hi,

On 2011-02-28 at 16:11 -0500 Ted Ts'o sent off:

Quoted 7 lines

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

after the discussion of this path submission thread are there any major or minor issues left that prevent these to go upstream? I'd really love to see NFSv4 ACLs being available on Linux, too.

Cheers
Björn

#40 lore raw
In reply to Ted Ts'o

Hi,

On 2011-02-28 at 16:11 -0500 Ted Ts'o sent off:

Quoted 7 lines

What is the current status of this patch series? I seem to remember that Christoph and Al Viro had some objections; have those been cleared yet? If not, can you summarize what their objections are?

To be honest I haven't been paying super close attention to this patch series, and I'm curious what needs to happen with it one way or another.

after the discussion of this path submission thread are there any major or minor issues left that prevent these to go upstream? I'd really love to see NFSv4 ACLs being available on Linux, too.

Cheers
Björn