Skip to content

Commit 7d6beb7

Browse files
committed
Merge tag 'idmapped-mounts-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux
Pull idmapped mounts from Christian Brauner: "This introduces idmapped mounts which has been in the making for some time. Simply put, different mounts can expose the same file or directory with different ownership. This initial implementation comes with ports for fat, ext4 and with Christoph's port for xfs with more filesystems being actively worked on by independent people and maintainers. Idmapping mounts handle a wide range of long standing use-cases. Here are just a few: - Idmapped mounts make it possible to easily share files between multiple users or multiple machines especially in complex scenarios. For example, idmapped mounts will be used in the implementation of portable home directories in systemd-homed.service(8) where they allow users to move their home directory to an external storage device and use it on multiple computers where they are assigned different uids and gids. This effectively makes it possible to assign random uids and gids at login time. - It is possible to share files from the host with unprivileged containers without having to change ownership permanently through chown(2). - It is possible to idmap a container's rootfs and without having to mangle every file. For example, Chromebooks use it to share the user's Download folder with their unprivileged containers in their Linux subsystem. - It is possible to share files between containers with non-overlapping idmappings. - Filesystem that lack a proper concept of ownership such as fat can use idmapped mounts to implement discretionary access (DAC) permission checking. - They allow users to efficiently changing ownership on a per-mount basis without having to (recursively) chown(2) all files. In contrast to chown (2) changing ownership of large sets of files is instantenous with idmapped mounts. This is especially useful when ownership of a whole root filesystem of a virtual machine or container is changed. With idmapped mounts a single syscall mount_setattr syscall will be sufficient to change the ownership of all files. - Idmapped mounts always take the current ownership into account as idmappings specify what a given uid or gid is supposed to be mapped to. This contrasts with the chown(2) syscall which cannot by itself take the current ownership of the files it changes into account. It simply changes the ownership to the specified uid and gid. This is especially problematic when recursively chown(2)ing a large set of files which is commong with the aforementioned portable home directory and container and vm scenario. - Idmapped mounts allow to change ownership locally, restricting it to specific mounts, and temporarily as the ownership changes only apply as long as the mount exists. Several userspace projects have either already put up patches and pull-requests for this feature or will do so should you decide to pull this: - systemd: In a wide variety of scenarios but especially right away in their implementation of portable home directories. https://systemd.io/HOME_DIRECTORY/ - container runtimes: containerd, runC, LXD:To share data between host and unprivileged containers, unprivileged and privileged containers, etc. The pull request for idmapped mounts support in containerd, the default Kubernetes runtime is already up for quite a while now: containerd/containerd#4734 - The virtio-fs developers and several users have expressed interest in using this feature with virtual machines once virtio-fs is ported. - ChromeOS: Sharing host-directories with unprivileged containers. I've tightly synced with all those projects and all of those listed here have also expressed their need/desire for this feature on the mailing list. For more info on how people use this there's a bunch of talks about this too. Here's just two recent ones: https://www.cncf.io/wp-content/uploads/2020/12/Rootless-Containers-in-Gitpod.pdf https://fosdem.org/2021/schedule/event/containers_idmap/ This comes with an extensive xfstests suite covering both ext4 and xfs: https://git.kernel.org/brauner/xfstests-dev/h/idmapped_mounts It covers truncation, creation, opening, xattrs, vfscaps, setid execution, setgid inheritance and more both with idmapped and non-idmapped mounts. It already helped to discover an unrelated xfs setgid inheritance bug which has since been fixed in mainline. It will be sent for inclusion with the xfstests project should you decide to merge this. In order to support per-mount idmappings vfsmounts are marked with user namespaces. The idmapping of the user namespace will be used to map the ids of vfs objects when they are accessed through that mount. By default all vfsmounts are marked with the initial user namespace. The initial user namespace is used to indicate that a mount is not idmapped. All operations behave as before and this is verified in the testsuite. Based on prior discussions we want to attach the whole user namespace and not just a dedicated idmapping struct. This allows us to reuse all the helpers that already exist for dealing with idmappings instead of introducing a whole new range of helpers. In addition, if we decide in the future that we are confident enough to enable unprivileged users to setup idmapped mounts the permission checking can take into account whether the caller is privileged in the user namespace the mount is currently marked with. The user namespace the mount will be marked with can be specified by passing a file descriptor refering to the user namespace as an argument to the new mount_setattr() syscall together with the new MOUNT_ATTR_IDMAP flag. The system call follows the openat2() pattern of extensibility. The following conditions must be met in order to create an idmapped mount: - The caller must currently have the CAP_SYS_ADMIN capability in the user namespace the underlying filesystem has been mounted in. - The underlying filesystem must support idmapped mounts. - The mount must not already be idmapped. This also implies that the idmapping of a mount cannot be altered once it has been idmapped. - The mount must be a detached/anonymous mount, i.e. it must have been created by calling open_tree() with the OPEN_TREE_CLONE flag and it must not already have been visible in the filesystem. The last two points guarantee easier semantics for userspace and the kernel and make the implementation significantly simpler. By default vfsmounts are marked with the initial user namespace and no behavioral or performance changes are observed. The manpage with a detailed description can be found here: https://git.kernel.org/brauner/man-pages/c/1d7b902e2875a1ff342e036a9f866a995640aea8 In order to support idmapped mounts, filesystems need to be changed and mark themselves with the FS_ALLOW_IDMAP flag in fs_flags. The patches to convert individual filesystem are not very large or complicated overall as can be seen from the included fat, ext4, and xfs ports. Patches for other filesystems are actively worked on and will be sent out separately. The xfstestsuite can be used to verify that port has been done correctly. The mount_setattr() syscall is motivated independent of the idmapped mounts patches and it's been around since July 2019. One of the most valuable features of the new mount api is the ability to perform mounts based on file descriptors only. Together with the lookup restrictions available in the openat2() RESOLVE_* flag namespace which we added in v5.6 this is the first time we are close to hardened and race-free (e.g. symlinks) mounting and path resolution. While userspace has started porting to the new mount api to mount proper filesystems and create new bind-mounts it is currently not possible to change mount options of an already existing bind mount in the new mount api since the mount_setattr() syscall is missing. With the addition of the mount_setattr() syscall we remove this last restriction and userspace can now fully port to the new mount api, covering every use-case the old mount api could. We also add the crucial ability to recursively change mount options for a whole mount tree, both removing and adding mount options at the same time. This syscall has been requested multiple times by various people and projects. There is a simple tool available at https://github.com/brauner/mount-idmapped that allows to create idmapped mounts so people can play with this patch series. I'll add support for the regular mount binary should you decide to pull this in the following weeks: Here's an example to a simple idmapped mount of another user's home directory: u1001@f2-vm:/$ sudo ./mount --idmap both:1000:1001:1 /home/ubuntu/ /mnt u1001@f2-vm:/$ ls -al /home/ubuntu/ total 28 drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 28 22:07 . drwxr-xr-x 4 root root 4096 Oct 28 04:00 .. -rw------- 1 ubuntu ubuntu 3154 Oct 28 22:12 .bash_history -rw-r--r-- 1 ubuntu ubuntu 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 ubuntu ubuntu 3771 Feb 25 2020 .bashrc -rw-r--r-- 1 ubuntu ubuntu 807 Feb 25 2020 .profile -rw-r--r-- 1 ubuntu ubuntu 0 Oct 16 16:11 .sudo_as_admin_successful -rw------- 1 ubuntu ubuntu 1144 Oct 28 00:43 .viminfo u1001@f2-vm:/$ ls -al /mnt/ total 28 drwxr-xr-x 2 u1001 u1001 4096 Oct 28 22:07 . drwxr-xr-x 29 root root 4096 Oct 28 22:01 .. -rw------- 1 u1001 u1001 3154 Oct 28 22:12 .bash_history -rw-r--r-- 1 u1001 u1001 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 u1001 u1001 3771 Feb 25 2020 .bashrc -rw-r--r-- 1 u1001 u1001 807 Feb 25 2020 .profile -rw-r--r-- 1 u1001 u1001 0 Oct 16 16:11 .sudo_as_admin_successful -rw------- 1 u1001 u1001 1144 Oct 28 00:43 .viminfo u1001@f2-vm:/$ touch /mnt/my-file u1001@f2-vm:/$ setfacl -m u:1001:rwx /mnt/my-file u1001@f2-vm:/$ sudo setcap -n 1001 cap_net_raw+ep /mnt/my-file u1001@f2-vm:/$ ls -al /mnt/my-file -rw-rwxr--+ 1 u1001 u1001 0 Oct 28 22:14 /mnt/my-file u1001@f2-vm:/$ ls -al /home/ubuntu/my-file -rw-rwxr--+ 1 ubuntu ubuntu 0 Oct 28 22:14 /home/ubuntu/my-file u1001@f2-vm:/$ getfacl /mnt/my-file getfacl: Removing leading '/' from absolute path names # file: mnt/my-file # owner: u1001 # group: u1001 user::rw- user:u1001:rwx group::rw- mask::rwx other::r-- u1001@f2-vm:/$ getfacl /home/ubuntu/my-file getfacl: Removing leading '/' from absolute path names # file: home/ubuntu/my-file # owner: ubuntu # group: ubuntu user::rw- user:ubuntu:rwx group::rw- mask::rwx other::r--" * tag 'idmapped-mounts-v5.12' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux: (41 commits) xfs: remove the possibly unused mp variable in xfs_file_compat_ioctl xfs: support idmapped mounts ext4: support idmapped mounts fat: handle idmapped mounts tests: add mount_setattr() selftests fs: introduce MOUNT_ATTR_IDMAP fs: add mount_setattr() fs: add attr_flags_to_mnt_flags helper fs: split out functions to hold writers namespace: only take read lock in do_reconfigure_mnt() mount: make {lock,unlock}_mount_hash() static namespace: take lock_mount_hash() directly when changing flags nfs: do not export idmapped mounts overlayfs: do not mount on top of idmapped mounts ecryptfs: do not mount on top of idmapped mounts ima: handle idmapped mounts apparmor: handle idmapped mounts fs: make helpers idmap mount aware exec: handle idmapped mounts would_dump: handle idmapped mounts ...
2 parents aa8e329 + f69e809 commit 7d6beb7

File tree

343 files changed

+4902
-1761
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

343 files changed

+4902
-1761
lines changed

Documentation/filesystems/locking.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ prototypes::
126126
int (*get)(const struct xattr_handler *handler, struct dentry *dentry,
127127
struct inode *inode, const char *name, void *buffer,
128128
size_t size);
129-
int (*set)(const struct xattr_handler *handler, struct dentry *dentry,
130-
struct inode *inode, const char *name, const void *buffer,
131-
size_t size, int flags);
129+
int (*set)(const struct xattr_handler *handler,
130+
struct user_namespace *mnt_userns,
131+
struct dentry *dentry, struct inode *inode, const char *name,
132+
const void *buffer, size_t size, int flags);
132133

133134
locking rules:
134135
all may block

Documentation/filesystems/porting.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@ be removed. Switch while you still can; the old one won't stay.
717717
**mandatory**
718718

719719
->setxattr() and xattr_handler.set() get dentry and inode passed separately.
720+
The xattr_handler.set() gets passed the user namespace of the mount the inode
721+
is seen from so filesystems can idmap the i_uid and i_gid accordingly.
720722
dentry might be yet to be attached to inode, so do _not_ use its ->d_inode
721723
in the instances. Rationale: !@#!@# security_d_instantiate() needs to be
722724
called before we attach dentry to inode and !@#!@##!@$!$#!@#$!@$!@$ smack

Documentation/filesystems/vfs.rst

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -418,28 +418,29 @@ As of kernel 2.6.22, the following members are defined:
418418
.. code-block:: c
419419
420420
struct inode_operations {
421-
int (*create) (struct inode *,struct dentry *, umode_t, bool);
421+
int (*create) (struct user_namespace *, struct inode *,struct dentry *, umode_t, bool);
422422
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
423423
int (*link) (struct dentry *,struct inode *,struct dentry *);
424424
int (*unlink) (struct inode *,struct dentry *);
425-
int (*symlink) (struct inode *,struct dentry *,const char *);
426-
int (*mkdir) (struct inode *,struct dentry *,umode_t);
425+
int (*symlink) (struct user_namespace *, struct inode *,struct dentry *,const char *);
426+
int (*mkdir) (struct user_namespace *, struct inode *,struct dentry *,umode_t);
427427
int (*rmdir) (struct inode *,struct dentry *);
428-
int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
429-
int (*rename) (struct inode *, struct dentry *,
428+
int (*mknod) (struct user_namespace *, struct inode *,struct dentry *,umode_t,dev_t);
429+
int (*rename) (struct user_namespace *, struct inode *, struct dentry *,
430430
struct inode *, struct dentry *, unsigned int);
431431
int (*readlink) (struct dentry *, char __user *,int);
432432
const char *(*get_link) (struct dentry *, struct inode *,
433433
struct delayed_call *);
434-
int (*permission) (struct inode *, int);
434+
int (*permission) (struct user_namespace *, struct inode *, int);
435435
int (*get_acl)(struct inode *, int);
436-
int (*setattr) (struct dentry *, struct iattr *);
437-
int (*getattr) (const struct path *, struct kstat *, u32, unsigned int);
436+
int (*setattr) (struct user_namespace *, struct dentry *, struct iattr *);
437+
int (*getattr) (struct user_namespace *, const struct path *, struct kstat *, u32, unsigned int);
438438
ssize_t (*listxattr) (struct dentry *, char *, size_t);
439439
void (*update_time)(struct inode *, struct timespec *, int);
440440
int (*atomic_open)(struct inode *, struct dentry *, struct file *,
441441
unsigned open_flag, umode_t create_mode);
442-
int (*tmpfile) (struct inode *, struct dentry *, umode_t);
442+
int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t);
443+
int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int);
443444
};
444445
445446
Again, all methods are called without any locks being held, unless

arch/alpha/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,4 @@
481481
549 common faccessat2 sys_faccessat2
482482
550 common process_madvise sys_process_madvise
483483
551 common epoll_pwait2 sys_epoll_pwait2
484+
552 common mount_setattr sys_mount_setattr

arch/arm/tools/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,4 @@
455455
439 common faccessat2 sys_faccessat2
456456
440 common process_madvise sys_process_madvise
457457
441 common epoll_pwait2 sys_epoll_pwait2
458+
442 common mount_setattr sys_mount_setattr

arch/arm64/include/asm/unistd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#define __ARM_NR_compat_set_tls (__ARM_NR_COMPAT_BASE + 5)
3939
#define __ARM_NR_COMPAT_END (__ARM_NR_COMPAT_BASE + 0x800)
4040

41-
#define __NR_compat_syscalls 442
41+
#define __NR_compat_syscalls 443
4242
#endif
4343

4444
#define __ARCH_WANT_SYS_CLONE

arch/arm64/include/asm/unistd32.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,8 @@ __SYSCALL(__NR_faccessat2, sys_faccessat2)
891891
__SYSCALL(__NR_process_madvise, sys_process_madvise)
892892
#define __NR_epoll_pwait2 441
893893
__SYSCALL(__NR_epoll_pwait2, compat_sys_epoll_pwait2)
894+
#define __NR_mount_setattr 442
895+
__SYSCALL(__NR_mount_setattr, sys_mount_setattr)
894896

895897
/*
896898
* Please add new compat syscalls above this comment and update

arch/ia64/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,3 +362,4 @@
362362
439 common faccessat2 sys_faccessat2
363363
440 common process_madvise sys_process_madvise
364364
441 common epoll_pwait2 sys_epoll_pwait2
365+
442 common mount_setattr sys_mount_setattr

arch/m68k/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,3 +441,4 @@
441441
439 common faccessat2 sys_faccessat2
442442
440 common process_madvise sys_process_madvise
443443
441 common epoll_pwait2 sys_epoll_pwait2
444+
442 common mount_setattr sys_mount_setattr

arch/microblaze/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,3 +447,4 @@
447447
439 common faccessat2 sys_faccessat2
448448
440 common process_madvise sys_process_madvise
449449
441 common epoll_pwait2 sys_epoll_pwait2
450+
442 common mount_setattr sys_mount_setattr

arch/mips/kernel/syscalls/syscall_n32.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,4 @@
380380
439 n32 faccessat2 sys_faccessat2
381381
440 n32 process_madvise sys_process_madvise
382382
441 n32 epoll_pwait2 compat_sys_epoll_pwait2
383+
442 n32 mount_setattr sys_mount_setattr

arch/mips/kernel/syscalls/syscall_n64.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,4 @@
356356
439 n64 faccessat2 sys_faccessat2
357357
440 n64 process_madvise sys_process_madvise
358358
441 n64 epoll_pwait2 sys_epoll_pwait2
359+
442 n64 mount_setattr sys_mount_setattr

arch/mips/kernel/syscalls/syscall_o32.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,3 +429,4 @@
429429
439 o32 faccessat2 sys_faccessat2
430430
440 o32 process_madvise sys_process_madvise
431431
441 o32 epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2
432+
442 o32 mount_setattr sys_mount_setattr

arch/parisc/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,3 +439,4 @@
439439
439 common faccessat2 sys_faccessat2
440440
440 common process_madvise sys_process_madvise
441441
441 common epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2
442+
442 common mount_setattr sys_mount_setattr

arch/powerpc/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,4 @@
521521
439 common faccessat2 sys_faccessat2
522522
440 common process_madvise sys_process_madvise
523523
441 common epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2
524+
442 common mount_setattr sys_mount_setattr

arch/powerpc/platforms/cell/spufs/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,15 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
9191
}
9292

9393
static int
94-
spufs_setattr(struct dentry *dentry, struct iattr *attr)
94+
spufs_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
95+
struct iattr *attr)
9596
{
9697
struct inode *inode = d_inode(dentry);
9798

9899
if ((attr->ia_valid & ATTR_SIZE) &&
99100
(attr->ia_size != inode->i_size))
100101
return -EINVAL;
101-
setattr_copy(inode, attr);
102+
setattr_copy(&init_user_ns, inode, attr);
102103
mark_inode_dirty(inode);
103104
return 0;
104105
}

arch/s390/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,4 @@
444444
439 common faccessat2 sys_faccessat2 sys_faccessat2
445445
440 common process_madvise sys_process_madvise sys_process_madvise
446446
441 common epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2
447+
442 common mount_setattr sys_mount_setattr sys_mount_setattr

arch/sh/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,4 @@
444444
439 common faccessat2 sys_faccessat2
445445
440 common process_madvise sys_process_madvise
446446
441 common epoll_pwait2 sys_epoll_pwait2
447+
442 common mount_setattr sys_mount_setattr

arch/sparc/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,3 +487,4 @@
487487
439 common faccessat2 sys_faccessat2
488488
440 common process_madvise sys_process_madvise
489489
441 common epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2
490+
442 common mount_setattr sys_mount_setattr

arch/x86/entry/syscalls/syscall_32.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,3 +446,4 @@
446446
439 i386 faccessat2 sys_faccessat2
447447
440 i386 process_madvise sys_process_madvise
448448
441 i386 epoll_pwait2 sys_epoll_pwait2 compat_sys_epoll_pwait2
449+
442 i386 mount_setattr sys_mount_setattr

arch/x86/entry/syscalls/syscall_64.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@
363363
439 common faccessat2 sys_faccessat2
364364
440 common process_madvise sys_process_madvise
365365
441 common epoll_pwait2 sys_epoll_pwait2
366+
442 common mount_setattr sys_mount_setattr
366367

367368
#
368369
# Due to a historical design error, certain syscalls are numbered differently

arch/xtensa/kernel/syscalls/syscall.tbl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,4 @@
412412
439 common faccessat2 sys_faccessat2
413413
440 common process_madvise sys_process_madvise
414414
441 common epoll_pwait2 sys_epoll_pwait2
415+
442 common mount_setattr sys_mount_setattr

drivers/android/binderfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,15 +355,17 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
355355
return info->control_dentry == dentry;
356356
}
357357

358-
static int binderfs_rename(struct inode *old_dir, struct dentry *old_dentry,
358+
static int binderfs_rename(struct user_namespace *mnt_userns,
359+
struct inode *old_dir, struct dentry *old_dentry,
359360
struct inode *new_dir, struct dentry *new_dentry,
360361
unsigned int flags)
361362
{
362363
if (is_binderfs_control_device(old_dentry) ||
363364
is_binderfs_control_device(new_dentry))
364365
return -EPERM;
365366

366-
return simple_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
367+
return simple_rename(&init_user_ns, old_dir, old_dentry, new_dir,
368+
new_dentry, flags);
367369
}
368370

369371
static int binderfs_unlink(struct inode *dir, struct dentry *dentry)

drivers/base/devtmpfs.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ static int dev_mkdir(const char *name, umode_t mode)
162162
if (IS_ERR(dentry))
163163
return PTR_ERR(dentry);
164164

165-
err = vfs_mkdir(d_inode(path.dentry), dentry, mode);
165+
err = vfs_mkdir(&init_user_ns, d_inode(path.dentry), dentry, mode);
166166
if (!err)
167167
/* mark as kernel-created inode */
168168
d_inode(dentry)->i_private = &thread;
@@ -212,7 +212,8 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
212212
if (IS_ERR(dentry))
213213
return PTR_ERR(dentry);
214214

215-
err = vfs_mknod(d_inode(path.dentry), dentry, mode, dev->devt);
215+
err = vfs_mknod(&init_user_ns, d_inode(path.dentry), dentry, mode,
216+
dev->devt);
216217
if (!err) {
217218
struct iattr newattrs;
218219

@@ -221,7 +222,7 @@ static int handle_create(const char *nodename, umode_t mode, kuid_t uid,
221222
newattrs.ia_gid = gid;
222223
newattrs.ia_valid = ATTR_MODE|ATTR_UID|ATTR_GID;
223224
inode_lock(d_inode(dentry));
224-
notify_change(dentry, &newattrs, NULL);
225+
notify_change(&init_user_ns, dentry, &newattrs, NULL);
225226
inode_unlock(d_inode(dentry));
226227

227228
/* mark as kernel-created inode */
@@ -242,7 +243,8 @@ static int dev_rmdir(const char *name)
242243
return PTR_ERR(dentry);
243244
if (d_really_is_positive(dentry)) {
244245
if (d_inode(dentry)->i_private == &thread)
245-
err = vfs_rmdir(d_inode(parent.dentry), dentry);
246+
err = vfs_rmdir(&init_user_ns, d_inode(parent.dentry),
247+
dentry);
246248
else
247249
err = -EPERM;
248250
} else {
@@ -328,9 +330,10 @@ static int handle_remove(const char *nodename, struct device *dev)
328330
newattrs.ia_valid =
329331
ATTR_UID|ATTR_GID|ATTR_MODE;
330332
inode_lock(d_inode(dentry));
331-
notify_change(dentry, &newattrs, NULL);
333+
notify_change(&init_user_ns, dentry, &newattrs, NULL);
332334
inode_unlock(d_inode(dentry));
333-
err = vfs_unlink(d_inode(parent.dentry), dentry, NULL);
335+
err = vfs_unlink(&init_user_ns, d_inode(parent.dentry),
336+
dentry, NULL);
334337
if (!err || err == -ENOENT)
335338
deleted = 1;
336339
}

fs/9p/acl.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
239239
}
240240

241241
static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
242+
struct user_namespace *mnt_userns,
242243
struct dentry *dentry, struct inode *inode,
243244
const char *name, const void *value,
244245
size_t size, int flags)
@@ -258,7 +259,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
258259

259260
if (S_ISLNK(inode->i_mode))
260261
return -EOPNOTSUPP;
261-
if (!inode_owner_or_capable(inode))
262+
if (!inode_owner_or_capable(&init_user_ns, inode))
262263
return -EPERM;
263264
if (value) {
264265
/* update the cached acl value */
@@ -279,7 +280,8 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
279280
struct iattr iattr = { 0 };
280281
struct posix_acl *old_acl = acl;
281282

282-
retval = posix_acl_update_mode(inode, &iattr.ia_mode, &acl);
283+
retval = posix_acl_update_mode(&init_user_ns, inode,
284+
&iattr.ia_mode, &acl);
283285
if (retval)
284286
goto err_out;
285287
if (!acl) {
@@ -297,7 +299,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
297299
* What is the following setxattr update the
298300
* mode ?
299301
*/
300-
v9fs_vfs_setattr_dotl(dentry, &iattr);
302+
v9fs_vfs_setattr_dotl(&init_user_ns, dentry, &iattr);
301303
}
302304
break;
303305
case ACL_TYPE_DEFAULT:

fs/9p/v9fs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
135135
unsigned int flags);
136136
extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
137137
extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
138-
extern int v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
138+
extern int v9fs_vfs_rename(struct user_namespace *mnt_userns,
139+
struct inode *old_dir, struct dentry *old_dentry,
139140
struct inode *new_dir, struct dentry *new_dentry,
140141
unsigned int flags);
141142
extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,

fs/9p/v9fs_vfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);
5959
int v9fs_uflags2omode(int uflags, int extended);
6060

6161
void v9fs_blank_wstat(struct p9_wstat *wstat);
62-
int v9fs_vfs_setattr_dotl(struct dentry *, struct iattr *);
62+
int v9fs_vfs_setattr_dotl(struct user_namespace *, struct dentry *,
63+
struct iattr *);
6364
int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
6465
int datasync);
6566
int v9fs_refresh_inode(struct p9_fid *fid, struct inode *inode);

0 commit comments

Comments
 (0)