aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xattr_acl.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-09-10 23:17:44 -0400
committerEric W. Biederman <ebiederm@xmission.com>2012-09-18 04:01:35 -0400
commit5f3a4a28ec140a90e6058d1d09f6b1f235d485e5 (patch)
treea8fc30f22d94033bd5bb4ccfe5218b01bfafcc50 /fs/xattr_acl.c
parent2f6f0654ab61961fd0f7701fe3be89ea111f0cda (diff)
userns: Pass a userns parameter into posix_acl_to_xattr and posix_acl_from_xattr
- Pass the user namespace the uid and gid values in the xattr are stored in into posix_acl_from_xattr. - Pass the user namespace kuid and kgid values should be converted into when storing uid and gid values in an xattr in posix_acl_to_xattr. - Modify all callers of posix_acl_from_xattr and posix_acl_to_xattr to pass in &init_user_ns. In the short term this change is not strictly needed but it makes the code clearer. In the longer term this change is necessary to be able to mount filesystems outside of the initial user namespace that natively store posix acls in the linux xattr format. Cc: Theodore Tso <tytso@mit.edu> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Andreas Dilger <adilger.kernel@dilger.ca> Cc: Jan Kara <jack@suse.cz> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Diffstat (limited to 'fs/xattr_acl.c')
-rw-r--r--fs/xattr_acl.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
index bf472ca1b34..11efd830b5f 100644
--- a/fs/xattr_acl.c
+++ b/fs/xattr_acl.c
@@ -73,7 +73,8 @@ void posix_acl_fix_xattr_to_user(void *value, size_t size)
73 * Convert from extended attribute to in-memory representation. 73 * Convert from extended attribute to in-memory representation.
74 */ 74 */
75struct posix_acl * 75struct posix_acl *
76posix_acl_from_xattr(const void *value, size_t size) 76posix_acl_from_xattr(struct user_namespace *user_ns,
77 const void *value, size_t size)
77{ 78{
78 posix_acl_xattr_header *header = (posix_acl_xattr_header *)value; 79 posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
79 posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end; 80 posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
@@ -112,14 +113,14 @@ posix_acl_from_xattr(const void *value, size_t size)
112 113
113 case ACL_USER: 114 case ACL_USER:
114 acl_e->e_uid = 115 acl_e->e_uid =
115 make_kuid(&init_user_ns, 116 make_kuid(user_ns,
116 le32_to_cpu(entry->e_id)); 117 le32_to_cpu(entry->e_id));
117 if (!uid_valid(acl_e->e_uid)) 118 if (!uid_valid(acl_e->e_uid))
118 goto fail; 119 goto fail;
119 break; 120 break;
120 case ACL_GROUP: 121 case ACL_GROUP:
121 acl_e->e_gid = 122 acl_e->e_gid =
122 make_kgid(&init_user_ns, 123 make_kgid(user_ns,
123 le32_to_cpu(entry->e_id)); 124 le32_to_cpu(entry->e_id));
124 if (!gid_valid(acl_e->e_gid)) 125 if (!gid_valid(acl_e->e_gid))
125 goto fail; 126 goto fail;
@@ -141,7 +142,8 @@ EXPORT_SYMBOL (posix_acl_from_xattr);
141 * Convert from in-memory to extended attribute representation. 142 * Convert from in-memory to extended attribute representation.
142 */ 143 */
143int 144int
144posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size) 145posix_acl_to_xattr(struct user_namespace *user_ns, const struct posix_acl *acl,
146 void *buffer, size_t size)
145{ 147{
146 posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer; 148 posix_acl_xattr_header *ext_acl = (posix_acl_xattr_header *)buffer;
147 posix_acl_xattr_entry *ext_entry = ext_acl->a_entries; 149 posix_acl_xattr_entry *ext_entry = ext_acl->a_entries;
@@ -162,11 +164,11 @@ posix_acl_to_xattr(const struct posix_acl *acl, void *buffer, size_t size)
162 switch(acl_e->e_tag) { 164 switch(acl_e->e_tag) {
163 case ACL_USER: 165 case ACL_USER:
164 ext_entry->e_id = 166 ext_entry->e_id =
165 cpu_to_le32(from_kuid(&init_user_ns, acl_e->e_uid)); 167 cpu_to_le32(from_kuid(user_ns, acl_e->e_uid));
166 break; 168 break;
167 case ACL_GROUP: 169 case ACL_GROUP:
168 ext_entry->e_id = 170 ext_entry->e_id =
169 cpu_to_le32(from_kgid(&init_user_ns, acl_e->e_gid)); 171 cpu_to_le32(from_kgid(user_ns, acl_e->e_gid));
170 break; 172 break;
171 default: 173 default:
172 ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID); 174 ext_entry->e_id = cpu_to_le32(ACL_UNDEFINED_ID);