diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2019-05-12 18:16:04 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2019-05-25 18:00:01 -0400 |
commit | 059338aae33165179352a26b58d815801072c87d (patch) | |
tree | ad75b40c28596ac0ccd50a2588f7e1444243a811 /fs/super.c | |
parent | d5f68d330c156774bf69059e434b5d8acea3b92e (diff) |
move mount_capable() calls to vfs_get_tree()
sget_fc() is called only from ->get_tree() instances and
the only instance not calling it is legacy_get_tree(),
which calls mount_capable() directly.
In all sget_fc() callers the checks could be moved to the
very beginning of ->get_tree() - ->user_ns is not changed
in between. So lifting the checks to the only caller of
->get_tree() is OK.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/super.c')
-rw-r--r-- | fs/super.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/super.c b/fs/super.c index d1e2f46bad7e..2c38541cd89f 100644 --- a/fs/super.c +++ b/fs/super.c | |||
@@ -514,12 +514,6 @@ struct super_block *sget_fc(struct fs_context *fc, | |||
514 | struct user_namespace *user_ns = fc->global ? &init_user_ns : fc->user_ns; | 514 | struct user_namespace *user_ns = fc->global ? &init_user_ns : fc->user_ns; |
515 | int err; | 515 | int err; |
516 | 516 | ||
517 | if (!(fc->sb_flags & SB_KERNMOUNT) && | ||
518 | fc->purpose != FS_CONTEXT_FOR_SUBMOUNT) { | ||
519 | if (!mount_capable(fc)) | ||
520 | return ERR_PTR(-EPERM); | ||
521 | } | ||
522 | |||
523 | retry: | 517 | retry: |
524 | spin_lock(&sb_lock); | 518 | spin_lock(&sb_lock); |
525 | if (test) { | 519 | if (test) { |
@@ -1421,6 +1415,12 @@ int vfs_get_tree(struct fs_context *fc) | |||
1421 | if (fc->root) | 1415 | if (fc->root) |
1422 | return -EBUSY; | 1416 | return -EBUSY; |
1423 | 1417 | ||
1418 | if (!(fc->sb_flags & SB_KERNMOUNT) && | ||
1419 | fc->purpose != FS_CONTEXT_FOR_SUBMOUNT) { | ||
1420 | if (!mount_capable(fc)) | ||
1421 | return -EPERM; | ||
1422 | } | ||
1423 | |||
1424 | /* Get the mountable root in fc->root, with a ref on the root and a ref | 1424 | /* Get the mountable root in fc->root, with a ref on the root and a ref |
1425 | * on the superblock. | 1425 | * on the superblock. |
1426 | */ | 1426 | */ |