diff options
-rw-r--r-- | fs/namespace.c | 40 |
1 files changed, 7 insertions, 33 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index edac42c6eff2..269919fa116d 100644 --- a/fs/namespace.c +++ b/fs/namespace.c | |||
@@ -1300,24 +1300,6 @@ SYSCALL_DEFINE1(oldumount, char __user *, name) | |||
1300 | 1300 | ||
1301 | #endif | 1301 | #endif |
1302 | 1302 | ||
1303 | static int mount_is_safe(struct path *path) | ||
1304 | { | ||
1305 | if (may_mount()) | ||
1306 | return 0; | ||
1307 | return -EPERM; | ||
1308 | #ifdef notyet | ||
1309 | if (S_ISLNK(path->dentry->d_inode->i_mode)) | ||
1310 | return -EPERM; | ||
1311 | if (path->dentry->d_inode->i_mode & S_ISVTX) { | ||
1312 | if (current_uid() != path->dentry->d_inode->i_uid) | ||
1313 | return -EPERM; | ||
1314 | } | ||
1315 | if (inode_permission(path->dentry->d_inode, MAY_WRITE)) | ||
1316 | return -EPERM; | ||
1317 | return 0; | ||
1318 | #endif | ||
1319 | } | ||
1320 | |||
1321 | static bool mnt_ns_loop(struct path *path) | 1303 | static bool mnt_ns_loop(struct path *path) |
1322 | { | 1304 | { |
1323 | /* Could bind mounting the mount namespace inode cause a | 1305 | /* Could bind mounting the mount namespace inode cause a |
@@ -1640,9 +1622,6 @@ static int do_change_type(struct path *path, int flag) | |||
1640 | int type; | 1622 | int type; |
1641 | int err = 0; | 1623 | int err = 0; |
1642 | 1624 | ||
1643 | if (!may_mount()) | ||
1644 | return -EPERM; | ||
1645 | |||
1646 | if (path->dentry != path->mnt->mnt_root) | 1625 | if (path->dentry != path->mnt->mnt_root) |
1647 | return -EINVAL; | 1626 | return -EINVAL; |
1648 | 1627 | ||
@@ -1676,9 +1655,7 @@ static int do_loopback(struct path *path, const char *old_name, | |||
1676 | LIST_HEAD(umount_list); | 1655 | LIST_HEAD(umount_list); |
1677 | struct path old_path; | 1656 | struct path old_path; |
1678 | struct mount *mnt = NULL, *old; | 1657 | struct mount *mnt = NULL, *old; |
1679 | int err = mount_is_safe(path); | 1658 | int err; |
1680 | if (err) | ||
1681 | return err; | ||
1682 | if (!old_name || !*old_name) | 1659 | if (!old_name || !*old_name) |
1683 | return -EINVAL; | 1660 | return -EINVAL; |
1684 | err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path); | 1661 | err = kern_path(old_name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &old_path); |
@@ -1755,9 +1732,6 @@ static int do_remount(struct path *path, int flags, int mnt_flags, | |||
1755 | struct super_block *sb = path->mnt->mnt_sb; | 1732 | struct super_block *sb = path->mnt->mnt_sb; |
1756 | struct mount *mnt = real_mount(path->mnt); | 1733 | struct mount *mnt = real_mount(path->mnt); |
1757 | 1734 | ||
1758 | if (!capable(CAP_SYS_ADMIN)) | ||
1759 | return -EPERM; | ||
1760 | |||
1761 | if (!check_mnt(mnt)) | 1735 | if (!check_mnt(mnt)) |
1762 | return -EINVAL; | 1736 | return -EINVAL; |
1763 | 1737 | ||
@@ -1771,6 +1745,8 @@ static int do_remount(struct path *path, int flags, int mnt_flags, | |||
1771 | down_write(&sb->s_umount); | 1745 | down_write(&sb->s_umount); |
1772 | if (flags & MS_BIND) | 1746 | if (flags & MS_BIND) |
1773 | err = change_mount_flags(path->mnt, flags); | 1747 | err = change_mount_flags(path->mnt, flags); |
1748 | else if (!capable(CAP_SYS_ADMIN)) | ||
1749 | err = -EPERM; | ||
1774 | else | 1750 | else |
1775 | err = do_remount_sb(sb, flags, data, 0); | 1751 | err = do_remount_sb(sb, flags, data, 0); |
1776 | if (!err) { | 1752 | if (!err) { |
@@ -1803,9 +1779,7 @@ static int do_move_mount(struct path *path, const char *old_name) | |||
1803 | struct path old_path, parent_path; | 1779 | struct path old_path, parent_path; |
1804 | struct mount *p; | 1780 | struct mount *p; |
1805 | struct mount *old; | 1781 | struct mount *old; |
1806 | int err = 0; | 1782 | int err; |
1807 | if (!may_mount()) | ||
1808 | return -EPERM; | ||
1809 | if (!old_name || !*old_name) | 1783 | if (!old_name || !*old_name) |
1810 | return -EINVAL; | 1784 | return -EINVAL; |
1811 | err = kern_path(old_name, LOOKUP_FOLLOW, &old_path); | 1785 | err = kern_path(old_name, LOOKUP_FOLLOW, &old_path); |
@@ -1947,9 +1921,6 @@ static int do_new_mount(struct path *path, const char *fstype, int flags, | |||
1947 | if (!fstype) | 1921 | if (!fstype) |
1948 | return -EINVAL; | 1922 | return -EINVAL; |
1949 | 1923 | ||
1950 | if (!may_mount()) | ||
1951 | return -EPERM; | ||
1952 | |||
1953 | type = get_fs_type(fstype); | 1924 | type = get_fs_type(fstype); |
1954 | if (!type) | 1925 | if (!type) |
1955 | return -ENODEV; | 1926 | return -ENODEV; |
@@ -2263,6 +2234,9 @@ long do_mount(const char *dev_name, const char *dir_name, | |||
2263 | if (retval) | 2234 | if (retval) |
2264 | goto dput_out; | 2235 | goto dput_out; |
2265 | 2236 | ||
2237 | if (!may_mount()) | ||
2238 | return -EPERM; | ||
2239 | |||
2266 | /* Default to relatime unless overriden */ | 2240 | /* Default to relatime unless overriden */ |
2267 | if (!(flags & MS_NOATIME)) | 2241 | if (!(flags & MS_NOATIME)) |
2268 | mnt_flags |= MNT_RELATIME; | 2242 | mnt_flags |= MNT_RELATIME; |