diff options
Diffstat (limited to 'fs/open.c')
-rw-r--r-- | fs/open.c | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -316,7 +316,8 @@ SYSCALL_DEFINE3(faccessat, int, dfd, const char __user *, filename, int, mode) | |||
316 | 316 | ||
317 | if (!issecure(SECURE_NO_SETUID_FIXUP)) { | 317 | if (!issecure(SECURE_NO_SETUID_FIXUP)) { |
318 | /* Clear the capabilities if we switch to a non-root user */ | 318 | /* Clear the capabilities if we switch to a non-root user */ |
319 | if (override_cred->uid) | 319 | kuid_t root_uid = make_kuid(override_cred->user_ns, 0); |
320 | if (!uid_eq(override_cred->uid, root_uid)) | ||
320 | cap_clear(override_cred->cap_effective); | 321 | cap_clear(override_cred->cap_effective); |
321 | else | 322 | else |
322 | override_cred->cap_effective = | 323 | override_cred->cap_effective = |
@@ -505,15 +506,24 @@ static int chown_common(struct path *path, uid_t user, gid_t group) | |||
505 | struct inode *inode = path->dentry->d_inode; | 506 | struct inode *inode = path->dentry->d_inode; |
506 | int error; | 507 | int error; |
507 | struct iattr newattrs; | 508 | struct iattr newattrs; |
509 | kuid_t uid; | ||
510 | kgid_t gid; | ||
511 | |||
512 | uid = make_kuid(current_user_ns(), user); | ||
513 | gid = make_kgid(current_user_ns(), group); | ||
508 | 514 | ||
509 | newattrs.ia_valid = ATTR_CTIME; | 515 | newattrs.ia_valid = ATTR_CTIME; |
510 | if (user != (uid_t) -1) { | 516 | if (user != (uid_t) -1) { |
517 | if (!uid_valid(uid)) | ||
518 | return -EINVAL; | ||
511 | newattrs.ia_valid |= ATTR_UID; | 519 | newattrs.ia_valid |= ATTR_UID; |
512 | newattrs.ia_uid = user; | 520 | newattrs.ia_uid = uid; |
513 | } | 521 | } |
514 | if (group != (gid_t) -1) { | 522 | if (group != (gid_t) -1) { |
523 | if (!gid_valid(gid)) | ||
524 | return -EINVAL; | ||
515 | newattrs.ia_valid |= ATTR_GID; | 525 | newattrs.ia_valid |= ATTR_GID; |
516 | newattrs.ia_gid = group; | 526 | newattrs.ia_gid = gid; |
517 | } | 527 | } |
518 | if (!S_ISDIR(inode->i_mode)) | 528 | if (!S_ISDIR(inode->i_mode)) |
519 | newattrs.ia_valid |= | 529 | newattrs.ia_valid |= |
@@ -681,7 +691,7 @@ static struct file *__dentry_open(struct dentry *dentry, struct vfsmount *mnt, | |||
681 | 691 | ||
682 | f->f_op = fops_get(inode->i_fop); | 692 | f->f_op = fops_get(inode->i_fop); |
683 | 693 | ||
684 | error = security_dentry_open(f, cred); | 694 | error = security_file_open(f, cred); |
685 | if (error) | 695 | if (error) |
686 | goto cleanup_all; | 696 | goto cleanup_all; |
687 | 697 | ||