Generic infrastructure for acls
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 Generic infrastructure for acls
Add some infrastructure for access control lists on in-memory filesystems such as tmpfs.
fs/Kconfig +4 -0
@@ -1821,6 +1821,10 @@ config 9P_FS If unsure, say N. +config GENERIC_ACL + bool + select FS_POSIX_ACL + endmenu menu "Partition Types"
fs/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_BINFMT_FLAT) += binfmt_flat obj-$(CONFIG_FS_MBCACHE) += mbcache.o 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_QUOTA) += dquot.o obj-$(CONFIG_QFMT_V1) += quota_v1.o
include/linux/generic_acl.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* fs/generic_acl.c +* +* (C) 2006 Andreas Gruenbacher <[email protected]> +* +* This file is released under the GPL. +*/ + +#ifndef GENERIC_ACL_H +#define GENERIC_ACL_H + +#include <linux/posix_acl.h> +#include <linux/posix_acl_xattr.h> + +struct generic_acl_operations { +struct posix_acl *(*getacl)(struct inode *,int ); +void (*setacl)(struct inode *,int ,struct posix_acl *); +}; + +size_t generic_acl_list (struct inode *,struct generic_acl_operations *,int , +char *,size_t ); +int generic_acl_get (struct inode *,struct generic_acl_operations *,int , +void *,size_t ); +int generic_acl_set (struct inode *,struct generic_acl_operations *,int , +const void *,size_t ); +int generic_acl_init (struct inode *,struct inode *, +struct generic_acl_operations *); +int generic_acl_chmod (struct inode *,struct generic_acl_operations *); + +#endif
fs/generic_acl.c new file +175 -0
175 lines not on this page · raw message
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.
Quoted 4 lines · Andreas Gruenbacher
Add some infrastructure for access control lists on in-memory filesystems such as tmpfs.
Signed-off-by Andreas Gruenbacher <[email protected]>
- James
Signature · 2 lines
James Morris <[email protected]>
PATCH 2/2 Access Control Lists for tmpfs
In reply to a message not in the archiveAdd access control lists for tmpfs.
fs/Kconfig +13 -0
@@ -838,6 +838,19 @@ config TMPFS See <file:Documentation/filesystems/tmpfs.txt> for details. +config TMPFS_POSIX_ACL + bool "Tmpfs POSIX Access Control Lists" + depends on TMPFS + select GENERIC_ACL + help + POSIX Access Control Lists (ACLs) support permissions for users and + groups beyond the owner/group/world scheme. + + To learn more about Access Control Lists, visit the POSIX ACLs for + Linux website <http://acl.bestbits.at/>. + + If you don't know what Access Control Lists are, say N. + config HUGETLBFS bool "HugeTLB file system support" depends X86 || IA64 || PPC64 || SPARC64 || SUPERH || BROKEN
include/linux/shmem_fs.h +40 -0
@@ -3,6 +3,7 @@#include <linux/swap.h> #include <linux/mempolicy.h> +#include <linux/generic_acl.h> /* inode in-kernel data */
@@ -19,6 +20,10 @@ struct shmem_inode_info {swp_entry_t i_direct[SHMEM_NR_DIRECT ];/* first blocks */ struct list_head swaplist;/* chain of maybes on swap */ struct inode vfs_inode; +#ifdef CONFIG_TMPFS_POSIX_ACL +struct posix_acl *i_acl; +struct posix_acl *i_default_acl; +#endif };struct shmem_sb_info {
@@ -34,4 +39,39 @@ static inline struct shmem_inode_info *S return container_of(inode, struct shmem_inode_info, vfs_inode); } +#ifdef CONFIG_TMPFS_POSIX_ACL +extern struct generic_acl_operations shmem_acl_ops; +extern struct xattr_handler shmem_xattr_acl_access_handler; +extern struct xattr_handler shmem_xattr_acl_default_handler; + +int shmem_permission (struct inode *,int ,struct nameidata *); +void shmem_acl_destroy_inode (struct inode *); + +static inline int +shmem_acl_init (struct inode *inode,struct inode *dir) +{ +return generic_acl_init (inode, dir, &shmem_acl_ops); +} +static inline int +shmem_acl_chmod (struct inode *inode) +{ +return generic_acl_chmod (inode, &shmem_acl_ops); +} +#else +static inline void +shmem_acl_destroy_inode (struct inode *inode) +{ +} +static inline int +shmem_acl_init (struct inode *inode,struct inode *dir) +{ +return 0 ; +} +static inline int +shmem_acl_chmod (struct inode *inode) +{ +return 0 ; +} +#endif /* CONFIG_TMPFS_POSIX_ACL */ +#endif
mm/Makefile +1 -0
@@ -17,6 +17,7 @@ obj-$(CONFIG_HUGETLBFS) += hugetlb.o obj-$(CONFIG_NUMA) += mempolicy.o obj-$(CONFIG_SPARSEMEM) += sparse.o obj-$(CONFIG_SHMEM) += shmem.o +obj-$(CONFIG_TMPFS_POSIX_ACL) += shmem_acl.o obj-$(CONFIG_TINY_SHMEM) += tiny-shmem.o obj-$(CONFIG_MEMORY_HOTPLUG) += memory_hotplug.o obj-$(CONFIG_FS_XIP) += filemap_xip.o
mm/shmem.c +90 -2
164 lines not on this page · raw message
mm/shmem_acl.c new file +157 -0
157 lines not on this page · raw message
--
Andreas Gruenbacher <[email protected]>
SUSE Labs, SUSE LINUX Products GmbH / Novell Inc.
Re: [patch 2/2] Access Control Lists for tmpfs
Quoted 3 lines · Andreas Gruenbacher
Add access control lists for tmpfs.
Signed-off-by Andreas Gruenbacher <[email protected]>
- James
Signature · 2 lines
James Morris <[email protected]>
Re: [patch 2/2] Access Control Lists for tmpfs
In reply to Andreas GruenbacherQuoted 1 line · Andreas Gruenbacher
+config
TMPFS_POSIX_ACL
I always hated all these different ACL CONFIG options for different file systems. ACL is not different from many other features which don't have own options in every subsystem.
How about just making a single global ACL CONFIG and all the file systems just turn on ACL implicitely if that one is set?
-Andi
Re: [patch 2/2] Access Control Lists for tmpfs
In reply to Andreas GruenbacherQuoted 38 lines · Andreas Gruenbacher
plain text document attachment (tmpfs-acl.diff)
Add access control lists for tmpfs.Signed-off-by Andreas Gruenbacher <[email protected]>Index:
linux-2.6.15-git4/mm/shmem.c
===================================================================mm/shmem.c +25
-0@@ -1843,6 +1852,50 @@ static struct inode_operations shmem_sym .put_link = shmem_put_link, }; +#ifdef CONFIG_TMPFS_POSIX_ACL +/* The vfs implements defaults for the security.* xattr namespace for inodes +* that don't have xattr iops. We have xattr iops for the acls, so we must +* also implement the security.* defaults here. +*/ +static size_t shmem_xattr_security_list (struct inode *inode,char *list, +size_t list_len,const char *name, +size_t name_len) +{ +return security_inode_listsecurity (inode, list, list_len); +} + +static int shmem_xattr_security_get (struct inode *inode,const char *name, +void *buffer,size_t size) +{ +if (strcmp (name,"" ) ==0 ) +return -EINVAL ; +return security_inode_getsecurity (inode, name, buffer, size, + -EOPNOTSUPP ); +} + +static int shmem_xattr_security_set (struct inode *inode,const char *name, +const void *value,size_t size,int flags) +{ +if (strcmp (name,"" ) ==0 )
mm/shmem.c static struct inode_operations shmem_sym · line 1889
Quoted 10 lines
mm/shmem.c +10
-0+return -EINVAL ; +return security_inode_setsecurity (inode, name, value, size, flags); +} + +struct xattr_handler shmem_xattr_security_handler = { + .prefix =XATTR_SECURITY_PREFIX , + .list = shmem_xattr_security_list, + .get = shmem_xattr_security_get, + .set = shmem_xattr_security_set, +};
This seems like a regression, given that this code was just removed in 2.6.14 by the generic VFS fallback support for security xattrs,
http://marc.theaimsgroup.com/?l=git-commits-head&m=112597810414161&w=2
Could you instead provide a generic VFS fallback for ACLs as well?
Signature · 2 lines
Stephen Smalley National Security Agency
Re: [patch 2/2] Access Control Lists for tmpfs
Quoted 54 lines · Stephen Smalley
Quoted 38 lines · Andreas Gruenbacher
plain text document attachment (tmpfs-acl.diff)
Add access control lists for tmpfs.Signed-off-by Andreas Gruenbacher <[email protected]>Index:
linux-2.6.15-git4/mm/shmem.c
===================================================================mm/shmem.c +2
-0@@ -1843,6 +1852,50 @@ static struct inode_operations shmem_sym .put_link = shmem_put_link, }; +#ifdef CONFIG_TMPFS_POSIX_ACL +/* The vfs implements defaults for the security.* xattr namespace for inodes + * that don't have xattr iops. We have xattr iops for the acls, so we must + * also implement the security.* defaults here.
+ */mm/shmem.c +8
-0+static size_t shmem_xattr_security_list (struct inode *inode,char *list, +size_t list_len,const char *name, +size_t name_len) +{ +return security_inode_listsecurity (inode, list, list_len); +} + +static int shmem_xattr_security_get(struct inode *inode, const char*name, + void *buffer,
size_tsize)mm/shmem.c +8
-0+{ +if (strcmp (name,"" ) ==0 ) +return -EINVAL ; +return security_inode_getsecurity (inode, name, buffer, size, + -EOPNOTSUPP ); +} + +static int shmem_xattr_security_set(struct inode *inode, const char*name, + const void *value,
size_tsize, int flags)mm/shmem.c +2
-0+{ +if (strcmp (name,"" ) ==0 )mm/shmem.c static struct inode_operations shmem_sym · line 1889
Quoted 10 lines
mm/shmem.c +10
-0+return -EINVAL ; +return security_inode_setsecurity (inode, name, value, size, flags); +} + +struct xattr_handler shmem_xattr_security_handler = { + .prefix =XATTR_SECURITY_PREFIX , + .list = shmem_xattr_security_list, + .get = shmem_xattr_security_get, + .set = shmem_xattr_security_set, +};This seems like a regression, given that this code was just removed in 2.6.14 by the generic VFS fallback support for security xattrs,
http://marc.theaimsgroup.com/?l=git-commits-head&m=112597810414161&w=2
Quoted 1 line
Could you instead provide a generic VFS fallback for ACLs as well?
Correct, this was when tmpfs only supported security.* xattrs. I didn't like this cleanup very much: it removed some reasonably clean abstractions and piled up more crap in fs/xattr.c instead. The security.* xattr code in fs/xattr.c is not extensible, which is why this patch needs to bring back some of the code that was removed. It would be possible to change that code so that it works no matter if an inode has xattr iops, but this would require a super_block flag that indicates if an inode's xattr ops implement the security.* namespace.
Generic acl support would amount to adding i_acl and i_default_acl pointers to generic inodes. I'm not sure if this is acceptable: Ext2, ext3, reiserfs, jfs have those pointers in their in-memory inodes but others don't, and generic acls only makes sense for memory-based filesystems. The wiring code needed in filesystems doesn't seem so horrible to me.
ACLs are slightly different from security labels, too: labeled security protection needs a label on everything, ACLs are not needed everywhere.
Thanks,
Andreas.