diff options
Diffstat (limited to 'fs/open.c')
| -rw-r--r-- | fs/open.c | 27 |
1 files changed, 20 insertions, 7 deletions
| @@ -587,6 +587,9 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename) | |||
| 587 | error = -EPERM; | 587 | error = -EPERM; |
| 588 | if (!capable(CAP_SYS_CHROOT)) | 588 | if (!capable(CAP_SYS_CHROOT)) |
| 589 | goto dput_and_out; | 589 | goto dput_and_out; |
| 590 | error = security_path_chroot(&path); | ||
| 591 | if (error) | ||
| 592 | goto dput_and_out; | ||
| 590 | 593 | ||
| 591 | set_fs_root(current->fs, &path); | 594 | set_fs_root(current->fs, &path); |
| 592 | error = 0; | 595 | error = 0; |
| @@ -617,11 +620,15 @@ SYSCALL_DEFINE2(fchmod, unsigned int, fd, mode_t, mode) | |||
| 617 | if (err) | 620 | if (err) |
| 618 | goto out_putf; | 621 | goto out_putf; |
| 619 | mutex_lock(&inode->i_mutex); | 622 | mutex_lock(&inode->i_mutex); |
| 623 | err = security_path_chmod(dentry, file->f_vfsmnt, mode); | ||
| 624 | if (err) | ||
| 625 | goto out_unlock; | ||
| 620 | if (mode == (mode_t) -1) | 626 | if (mode == (mode_t) -1) |
| 621 | mode = inode->i_mode; | 627 | mode = inode->i_mode; |
| 622 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | 628 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
| 623 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 629 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
| 624 | err = notify_change(dentry, &newattrs); | 630 | err = notify_change(dentry, &newattrs); |
| 631 | out_unlock: | ||
| 625 | mutex_unlock(&inode->i_mutex); | 632 | mutex_unlock(&inode->i_mutex); |
| 626 | mnt_drop_write(file->f_path.mnt); | 633 | mnt_drop_write(file->f_path.mnt); |
| 627 | out_putf: | 634 | out_putf: |
| @@ -646,11 +653,15 @@ SYSCALL_DEFINE3(fchmodat, int, dfd, const char __user *, filename, mode_t, mode) | |||
| 646 | if (error) | 653 | if (error) |
| 647 | goto dput_and_out; | 654 | goto dput_and_out; |
| 648 | mutex_lock(&inode->i_mutex); | 655 | mutex_lock(&inode->i_mutex); |
| 656 | error = security_path_chmod(path.dentry, path.mnt, mode); | ||
| 657 | if (error) | ||
| 658 | goto out_unlock; | ||
| 649 | if (mode == (mode_t) -1) | 659 | if (mode == (mode_t) -1) |
| 650 | mode = inode->i_mode; | 660 | mode = inode->i_mode; |
| 651 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | 661 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); |
| 652 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; | 662 | newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; |
| 653 | error = notify_change(path.dentry, &newattrs); | 663 | error = notify_change(path.dentry, &newattrs); |
| 664 | out_unlock: | ||
| 654 | mutex_unlock(&inode->i_mutex); | 665 | mutex_unlock(&inode->i_mutex); |
| 655 | mnt_drop_write(path.mnt); | 666 | mnt_drop_write(path.mnt); |
| 656 | dput_and_out: | 667 | dput_and_out: |
| @@ -664,9 +675,9 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, mode_t, mode) | |||
| 664 | return sys_fchmodat(AT_FDCWD, filename, mode); | 675 | return sys_fchmodat(AT_FDCWD, filename, mode); |
| 665 | } | 676 | } |
| 666 | 677 | ||
| 667 | static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | 678 | static int chown_common(struct path *path, uid_t user, gid_t group) |
| 668 | { | 679 | { |
| 669 | struct inode *inode = dentry->d_inode; | 680 | struct inode *inode = path->dentry->d_inode; |
| 670 | int error; | 681 | int error; |
| 671 | struct iattr newattrs; | 682 | struct iattr newattrs; |
| 672 | 683 | ||
| @@ -683,7 +694,9 @@ static int chown_common(struct dentry * dentry, uid_t user, gid_t group) | |||
| 683 | newattrs.ia_valid |= | 694 | newattrs.ia_valid |= |
| 684 | ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV; | 695 | ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_KILL_PRIV; |
| 685 | mutex_lock(&inode->i_mutex); | 696 | mutex_lock(&inode->i_mutex); |
| 686 | error = notify_change(dentry, &newattrs); | 697 | error = security_path_chown(path, user, group); |
| 698 | if (!error) | ||
| 699 | error = notify_change(path->dentry, &newattrs); | ||
| 687 | mutex_unlock(&inode->i_mutex); | 700 | mutex_unlock(&inode->i_mutex); |
| 688 | 701 | ||
| 689 | return error; | 702 | return error; |
| @@ -700,7 +713,7 @@ SYSCALL_DEFINE3(chown, const char __user *, filename, uid_t, user, gid_t, group) | |||
| 700 | error = mnt_want_write(path.mnt); | 713 | error = mnt_want_write(path.mnt); |
| 701 | if (error) | 714 | if (error) |
| 702 | goto out_release; | 715 | goto out_release; |
| 703 | error = chown_common(path.dentry, user, group); | 716 | error = chown_common(&path, user, group); |
| 704 | mnt_drop_write(path.mnt); | 717 | mnt_drop_write(path.mnt); |
| 705 | out_release: | 718 | out_release: |
| 706 | path_put(&path); | 719 | path_put(&path); |
| @@ -725,7 +738,7 @@ SYSCALL_DEFINE5(fchownat, int, dfd, const char __user *, filename, uid_t, user, | |||
| 725 | error = mnt_want_write(path.mnt); | 738 | error = mnt_want_write(path.mnt); |
| 726 | if (error) | 739 | if (error) |
| 727 | goto out_release; | 740 | goto out_release; |
| 728 | error = chown_common(path.dentry, user, group); | 741 | error = chown_common(&path, user, group); |
| 729 | mnt_drop_write(path.mnt); | 742 | mnt_drop_write(path.mnt); |
| 730 | out_release: | 743 | out_release: |
| 731 | path_put(&path); | 744 | path_put(&path); |
| @@ -744,7 +757,7 @@ SYSCALL_DEFINE3(lchown, const char __user *, filename, uid_t, user, gid_t, group | |||
| 744 | error = mnt_want_write(path.mnt); | 757 | error = mnt_want_write(path.mnt); |
| 745 | if (error) | 758 | if (error) |
| 746 | goto out_release; | 759 | goto out_release; |
| 747 | error = chown_common(path.dentry, user, group); | 760 | error = chown_common(&path, user, group); |
| 748 | mnt_drop_write(path.mnt); | 761 | mnt_drop_write(path.mnt); |
| 749 | out_release: | 762 | out_release: |
| 750 | path_put(&path); | 763 | path_put(&path); |
| @@ -767,7 +780,7 @@ SYSCALL_DEFINE3(fchown, unsigned int, fd, uid_t, user, gid_t, group) | |||
| 767 | goto out_fput; | 780 | goto out_fput; |
| 768 | dentry = file->f_path.dentry; | 781 | dentry = file->f_path.dentry; |
| 769 | audit_inode(NULL, dentry); | 782 | audit_inode(NULL, dentry); |
| 770 | error = chown_common(dentry, user, group); | 783 | error = chown_common(&file->f_path, user, group); |
| 771 | mnt_drop_write(file->f_path.mnt); | 784 | mnt_drop_write(file->f_path.mnt); |
| 772 | out_fput: | 785 | out_fput: |
| 773 | fput(file); | 786 | fput(file); |
