Eric W. Biederman df7342b240 mount: Don't allow copying MNT_UNBINDABLE|MNT_LOCKED mounts
Jonathan Calmels from NVIDIA reported that he's able to bypass the
mount visibility security check in place in the Linux kernel by using
a combination of the unbindable property along with the private mount
propagation option to allow a unprivileged user to see a path which
was purposefully hidden by the root user.

Reproducer:
  # Hide a path to all users using a tmpfs
  root@castiana:~# mount -t tmpfs tmpfs /sys/devices/
  root@castiana:~#

  # As an unprivileged user, unshare user namespace and mount namespace
  stgraber@castiana:~$ unshare -U -m -r

  # Confirm the path is still not accessible
  root@castiana:~# ls /sys/devices/

  # Make /sys recursively unbindable and private
  root@castiana:~# mount --make-runbindable /sys
  root@castiana:~# mount --make-private /sys

  # Recursively bind-mount the rest of /sys over to /mnnt
  root@castiana:~# mount --rbind /sys/ /mnt

  # Access our hidden /sys/device as an unprivileged user
  root@castiana:~# ls /mnt/devices/
  breakpoint cpu cstate_core cstate_pkg i915 intel_pt isa kprobe
  LNXSYSTM:00 msr pci0000:00 platform pnp0 power software system
  tracepoint uncore_arb uncore_cbox_0 uncore_cbox_1 uprobe virtual

Solve this by teaching copy_tree to fail if a mount turns out to be
both unbindable and locked.

Cc: stable@vger.kernel.org
Fixes: 5ff9d8a65ce8 ("vfs: Lock in place mounts from more privileged users")
Reported-by: Jonathan Calmels <jcalmels@nvidia.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2018-11-08 00:30:30 -06:00
..
2018-09-04 11:35:03 +08:00
2018-08-21 23:54:17 -04:00
\n
2018-10-29 10:23:36 -07:00
2018-11-02 11:25:48 -07:00
2018-08-17 16:20:28 -07:00
2018-09-29 22:47:48 -04:00
2018-10-26 16:26:33 -07:00
2018-11-04 08:20:09 -08:00
2018-10-21 10:46:42 -04:00
2018-10-12 22:46:50 -04:00
2018-11-01 11:46:27 -07:00
2018-10-31 08:54:15 -07:00
2018-08-18 11:44:53 -07:00
2018-10-23 13:49:02 +02:00
2018-09-07 10:32:23 +02:00
2018-10-24 00:40:44 +01:00
2018-11-02 11:25:48 -07:00
2018-10-29 14:29:58 -07:00
2018-10-31 08:54:16 -07:00
2018-10-24 00:40:44 +01:00
2018-08-21 18:19:09 -07:00
2018-10-21 10:46:42 -04:00
2018-10-31 08:54:16 -07:00
2018-08-21 18:19:09 -07:00
2018-08-21 18:19:09 -07:00
2018-08-21 18:19:09 -07:00
2018-09-03 15:14:01 +02:00