aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2011-05-24 20:12:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-05-25 11:39:31 -0400
commitb09e0fa4b4ea66266058eead43350bd7d55fec67 (patch)
tree35eed2e1bc39bbbca1c041b69e1e12e826241ccf /include
parent4eb317072be81bd93906f768679f745bc574e6b7 (diff)
tmpfs: implement generic xattr support
Implement generic xattrs for tmpfs filesystems. The Feodra project, while trying to replace suid apps with file capabilities, realized that tmpfs, which is used on the build systems, does not support file capabilities and thus cannot be used to build packages which use file capabilities. Xattrs are also needed for overlayfs. The xattr interface is a bit odd. If a filesystem does not implement any {get,set,list}xattr functions the VFS will call into some random LSM hooks and the running LSM can then implement some method for handling xattrs. SELinux for example provides a method to support security.selinux but no other security.* xattrs. As it stands today when one enables CONFIG_TMPFS_POSIX_ACL tmpfs will have xattr handler routines specifically to handle acls. Because of this tmpfs would loose the VFS/LSM helpers to support the running LSM. To make up for that tmpfs had stub functions that did nothing but call into the LSM hooks which implement the helpers. This new patch does not use the LSM fallback functions and instead just implements a native get/set/list xattr feature for the full security.* and trusted.* namespace like a normal filesystem. This means that tmpfs can now support both security.selinux and security.capability, which was not previously possible. The basic implementation is that I attach a: struct shmem_xattr { struct list_head list; /* anchored by shmem_inode_info->xattr_list */ char *name; size_t size; char value[0]; }; Into the struct shmem_inode_info for each xattr that is set. This implementation could easily support the user.* namespace as well, except some care needs to be taken to prevent large amounts of unswappable memory being allocated for unprivileged users. [mszeredi@suse.cz: new config option, suport trusted.*, support symlinks] Signed-off-by: Eric Paris <eparis@redhat.com> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com> Tested-by: Serge Hallyn <serge.hallyn@ubuntu.com> Cc: Kyle McMartin <kyle@mcmartin.ca> Acked-by: Hugh Dickins <hughd@google.com> Tested-by: Jordi Pujol <jordipujolp@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/shmem_fs.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h
index 399be5ad2f99..2b7fec840517 100644
--- a/include/linux/shmem_fs.h
+++ b/include/linux/shmem_fs.h
@@ -9,6 +9,8 @@
9 9
10#define SHMEM_NR_DIRECT 16 10#define SHMEM_NR_DIRECT 16
11 11
12#define SHMEM_SYMLINK_INLINE_LEN (SHMEM_NR_DIRECT * sizeof(swp_entry_t))
13
12struct shmem_inode_info { 14struct shmem_inode_info {
13 spinlock_t lock; 15 spinlock_t lock;
14 unsigned long flags; 16 unsigned long flags;
@@ -17,8 +19,12 @@ struct shmem_inode_info {
17 unsigned long next_index; /* highest alloced index + 1 */ 19 unsigned long next_index; /* highest alloced index + 1 */
18 struct shared_policy policy; /* NUMA memory alloc policy */ 20 struct shared_policy policy; /* NUMA memory alloc policy */
19 struct page *i_indirect; /* top indirect blocks page */ 21 struct page *i_indirect; /* top indirect blocks page */
20 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */ 22 union {
23 swp_entry_t i_direct[SHMEM_NR_DIRECT]; /* first blocks */
24 char inline_symlink[SHMEM_SYMLINK_INLINE_LEN];
25 };
21 struct list_head swaplist; /* chain of maybes on swap */ 26 struct list_head swaplist; /* chain of maybes on swap */
27 struct list_head xattr_list; /* list of shmem_xattr */
22 struct inode vfs_inode; 28 struct inode vfs_inode;
23}; 29};
24 30