Linux kernel automount attachment outside mount namespaces
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ df820f8de4e481222b17f9bcee7b909ae8167529 · < 494c57572d2d5bc2839553ed41aabe92ed0f587c| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
namespace: refuse an automount below a mount that is in no namespace
It's possible to add autmounts even when the parent mount isn't in the mount namespace of the caller. The only requirement we have is that the parent mount namespace must not be NULL, i.e., unmounted.
Problem is that clone_private_mount() has MNT_NS_INTERNAL which makes that trivially true. So that passes the test and attach_recursive_mnt() accepts that as a mount point and funny enough, count_mounts() dereferences MNT_NS_INTERNAL. The problem is it is an error pointer...
So we can reach this in userspace via fanotify. A filesystem mark on the lower filesystem of an overlay reports paths on the layer clone and reading the event hands out a descriptor on it. For example with debugfs as the lower layer it goes kaboom:
openat(evfd, "tracing", O_DIRECTORY)
Oops: general protection fault KASAN: null-ptr-deref in range [0x1d0-0x1d7] RIP: 0010:count_mounts+0x35/0x200 attach_recursive_mnt finish_automount
And since that sleeping beauty happens under namespace_sem held for writing every mount operation on the system blocks from then on. Congrats.
From the CVE record · Linux
The Linux kernel can accept an automount beneath an internal mount that is not in the caller’s mount namespace. A local user can reach this through fanotify when a filesystem mark on an overlay’s lower layer exposes a path on a layer clone; opening the path can crash the kernel and block subsequent mount operations. The input does not specify authentication requirements.
Engineers running Linux kernels with the affected namespace automount behavior should check their systems; affected versions are not specified.