Skip to content

Commit 0d4d717

Browse files
committed
vfs: Verify acls are valid within superblock's s_user_ns.
Update posix_acl_valid to verify that an acl is within a user namespace. Update the callers of posix_acl_valid to pass in an appropriate user namespace. For posix_acl_xattr_set and v9fs_xattr_set_acl pass in inode->i_sb->s_user_ns to posix_acl_valid. For md_unpack_acl pass in &init_user_ns as no inode or superblock is in sight. Acked-by: Seth Forshee <[email protected]> Signed-off-by: "Eric W. Biederman" <[email protected]>
1 parent 37b1180 commit 0d4d717

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

drivers/staging/lustre/lustre/mdc/mdc_request.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
434434
return rc;
435435
}
436436

437-
rc = posix_acl_valid(acl);
437+
rc = posix_acl_valid(&init_user_ns, acl);
438438
if (rc) {
439439
CERROR("validate acl: %d\n", rc);
440440
posix_acl_release(acl);

fs/9p/acl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
266266
if (IS_ERR(acl))
267267
return PTR_ERR(acl);
268268
else if (acl) {
269-
retval = posix_acl_valid(acl);
269+
retval = posix_acl_valid(inode->i_sb->s_user_ns, acl);
270270
if (retval)
271271
goto err_out;
272272
}

fs/posix_acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ posix_acl_clone(const struct posix_acl *acl, gfp_t flags)
205205
* Check if an acl is valid. Returns 0 if it is, or -E... otherwise.
206206
*/
207207
int
208-
posix_acl_valid(const struct posix_acl *acl)
208+
posix_acl_valid(struct user_namespace *user_ns, const struct posix_acl *acl)
209209
{
210210
const struct posix_acl_entry *pa, *pe;
211211
int state = ACL_USER_OBJ;
@@ -225,7 +225,7 @@ posix_acl_valid(const struct posix_acl *acl)
225225
case ACL_USER:
226226
if (state != ACL_USER)
227227
return -EINVAL;
228-
if (!uid_valid(pa->e_uid))
228+
if (!kuid_has_mapping(user_ns, pa->e_uid))
229229
return -EINVAL;
230230
needs_mask = 1;
231231
break;
@@ -240,7 +240,7 @@ posix_acl_valid(const struct posix_acl *acl)
240240
case ACL_GROUP:
241241
if (state != ACL_GROUP)
242242
return -EINVAL;
243-
if (!gid_valid(pa->e_gid))
243+
if (!kgid_has_mapping(user_ns, pa->e_gid))
244244
return -EINVAL;
245245
needs_mask = 1;
246246
break;
@@ -845,7 +845,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
845845
return PTR_ERR(acl);
846846

847847
if (acl) {
848-
ret = posix_acl_valid(acl);
848+
ret = posix_acl_valid(inode->i_sb->s_user_ns, acl);
849849
if (ret)
850850
goto out;
851851
}

include/linux/posix_acl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ posix_acl_release(struct posix_acl *acl)
8181

8282
extern void posix_acl_init(struct posix_acl *, int);
8383
extern struct posix_acl *posix_acl_alloc(int, gfp_t);
84-
extern int posix_acl_valid(const struct posix_acl *);
84+
extern int posix_acl_valid(struct user_namespace *, const struct posix_acl *);
8585
extern int posix_acl_permission(struct inode *, const struct posix_acl *, int);
8686
extern struct posix_acl *posix_acl_from_mode(umode_t, gfp_t);
8787
extern int posix_acl_equiv_mode(const struct posix_acl *, umode_t *);

0 commit comments

Comments
 (0)