Skip to content

Commit 435ac62

Browse files
author
Christian Brauner
committed
would_dump: handle idmapped mounts
When determining whether or not to create a coredump the vfs will verify that the caller is privileged over the inode. Make the would_dump() helper handle idmapped mounts by passing down the mount's user namespace of the exec file. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before. Link: https://lore.kernel.org/r/20210121131959.646623-23-christian.brauner@ubuntu.com Cc: Christoph Hellwig <hch@lst.de> Cc: David Howells <dhowells@redhat.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: linux-fsdevel@vger.kernel.org Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
1 parent 0f5d220 commit 435ac62

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎fs/exec.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,15 +1404,15 @@ EXPORT_SYMBOL(begin_new_exec);
14041404
void would_dump(struct linux_binprm *bprm, struct file *file)
14051405
{
14061406
struct inode *inode = file_inode(file);
1407-
if (inode_permission(&init_user_ns, inode, MAY_READ) < 0) {
1407+
struct user_namespace *mnt_userns = file_mnt_user_ns(file);
1408+
if (inode_permission(mnt_userns, inode, MAY_READ) < 0) {
14081409
struct user_namespace *old, *user_ns;
14091410
bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
14101411

14111412
/* Ensure mm->user_ns contains the executable */
14121413
user_ns = old = bprm->mm->user_ns;
14131414
while ((user_ns != &init_user_ns) &&
1414-
!privileged_wrt_inode_uidgid(user_ns, &init_user_ns,
1415-
inode))
1415+
!privileged_wrt_inode_uidgid(user_ns, mnt_userns, inode))
14161416
user_ns = user_ns->parent;
14171417

14181418
if (old != user_ns) {

0 commit comments

Comments
 (0)