mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
fs: port ->permission() to pass mnt_idmap
Convert to struct mnt_idmap.
Last cycle we merged the necessary infrastructure in
256c8aed2b
("fs: introduce dedicated idmap type for mounts").
This is just the conversion to struct mnt_idmap.
Currently we still pass around the plain namespace that was attached to a
mount. This is in general pretty convenient but it makes it easy to
conflate namespaces that are relevant on the filesystem with namespaces
that are relevent on the mount level. Especially for non-vfs developers
without detailed knowledge in this area this can be a potential source for
bugs.
Once the conversion to struct mnt_idmap is done all helpers down to the
really low-level helpers will take a struct mnt_idmap argument instead of
two namespace arguments. This way it becomes impossible to conflate the two
eliminating the possibility of any bugs. All of the vfs and all filesystems
only operate on struct mnt_idmap.
Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
This commit is contained in:
committed by
Christian Brauner (Microsoft)
parent
8782a9aea3
commit
4609e1f18e
@@ -168,7 +168,6 @@ int __init init_link(const char *oldname, const char *newname)
|
||||
struct dentry *new_dentry;
|
||||
struct path old_path, new_path;
|
||||
struct mnt_idmap *idmap;
|
||||
struct user_namespace *mnt_userns;
|
||||
int error;
|
||||
|
||||
error = kern_path(oldname, 0, &old_path);
|
||||
@@ -184,8 +183,7 @@ int __init init_link(const char *oldname, const char *newname)
|
||||
if (old_path.mnt != new_path.mnt)
|
||||
goto out_dput;
|
||||
idmap = mnt_idmap(new_path.mnt);
|
||||
mnt_userns = mnt_idmap_owner(idmap);
|
||||
error = may_linkat(mnt_userns, &old_path);
|
||||
error = may_linkat(idmap, &old_path);
|
||||
if (unlikely(error))
|
||||
goto out_dput;
|
||||
error = security_path_link(old_path.dentry, &new_path, new_dentry);
|
||||
|
Reference in New Issue
Block a user