]> git.baikalelectronics.ru Git - kernel.git/commit
usermodehelper: reset umask to default before executing user process
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 5 Oct 2020 17:56:22 +0000 (10:56 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Oct 2020 17:31:52 +0000 (10:31 -0700)
commitccd6b9dcf82e951d884783110eb8001c0dcbf9b8
tree6344952ae342d6f9021515b59c12c9f2f5c52f4e
parent3211f2cb3615f68fb3e09b8fac6695aa2f5d6a32
usermodehelper: reset umask to default before executing user process

Kernel threads intentionally do CLONE_FS in order to follow any changes
that 'init' does to set up the root directory (or cwd).

It is admittedly a bit odd, but it avoids the situation where 'init'
does some extensive setup to initialize the system environment, and then
we execute a usermode helper program, and it uses the original FS setup
from boot time that may be very limited and incomplete.

[ Both Al Viro and Eric Biederman point out that 'pivot_root()' will
  follow the root regardless, since it fixes up other users of root (see
  chroot_fs_refs() for details), but overmounting root and doing a
  chroot() would not. ]

However, Vegard Nossum noticed that the CLONE_FS not only means that we
follow the root and current working directories, it also means we share
umask with whatever init changed it to. That wasn't intentional.

Just reset umask to the original default (0022) before actually starting
the usermode helper program.

Reported-by: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Acked-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/umh.c