summaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 23:16:07 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-26 23:16:07 -0500
commitd895cb1af15c04c522a25c79cc429076987c089b (patch)
tree895dc9157e28f603d937a58be664e4e440d5530c /fs/namespace.c
parent9626357371b519f2b955fef399647181034a77fe (diff)
parentd3d009cb965eae7e002ea5badf603ea8f4c34915 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs pile (part one) from Al Viro: "Assorted stuff - cleaning namei.c up a bit, fixing ->d_name/->d_parent locking violations, etc. The most visible changes here are death of FS_REVAL_DOT (replaced with "has ->d_weak_revalidate()") and a new helper getting from struct file to inode. Some bits of preparation to xattr method interface changes. Misc patches by various people sent this cycle *and* ocfs2 fixes from several cycles ago that should've been upstream right then. PS: the next vfs pile will be xattr stuff." * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (46 commits) saner proc_get_inode() calling conventions proc: avoid extra pde_put() in proc_fill_super() fs: change return values from -EACCES to -EPERM fs/exec.c: make bprm_mm_init() static ocfs2/dlm: use GFP_ATOMIC inside a spin_lock ocfs2: fix possible use-after-free with AIO ocfs2: Fix oops in ocfs2_fast_symlink_readpage() code path get_empty_filp()/alloc_file() leave both ->f_pos and ->f_version zero target: writev() on single-element vector is pointless export kernel_write(), convert open-coded instances fs: encode_fh: return FILEID_INVALID if invalid fid_type kill f_vfsmnt vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op nfsd: handle vfs_getattr errors in acl protocol switch vfs_getattr() to struct path default SET_PERSONALITY() in linux/elf.h ceph: prepopulate inodes only when request is aborted d_hash_and_lookup(): export, switch open-coded instances 9p: switch v9fs_set_create_acl() to inode+fid, do it before d_instantiate() 9p: split dropping the acls from v9fs_set_create_acl() ...
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c42
1 files changed, 8 insertions, 34 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index edac42c6eff2..50ca17d3cb45 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -384,7 +384,7 @@ EXPORT_SYMBOL_GPL(mnt_clone_write);
384 */ 384 */
385int __mnt_want_write_file(struct file *file) 385int __mnt_want_write_file(struct file *file)
386{ 386{
387 struct inode *inode = file->f_dentry->d_inode; 387 struct inode *inode = file_inode(file);
388 388
389 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode)) 389 if (!(file->f_mode & FMODE_WRITE) || special_file(inode->i_mode))
390 return __mnt_want_write(file->f_path.mnt); 390 return __mnt_want_write(file->f_path.mnt);
@@ -1300,24 +1300,6 @@ SYSCALL_DEFINE1(oldumount, char __user *, name)
1300 1300
1301#endif 1301#endif
1302 1302
1303static 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
1321static bool mnt_ns_loop(struct path *path) 1303static 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;