Skip to content

Commit e38da9d

Browse files
committed
ovl: add config to disable unprivileged user namespace mounts
When disabled, unprivileged users will not be able to create new overlayfs mounts. This cuts the attack surface if no unprivileged user namespace mounts are required like for running rootless containers. Signed-off-by: Levente Polyak <[email protected]>
1 parent fa413dd commit e38da9d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

fs/overlayfs/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,19 @@ config OVERLAY_FS_METACOPY
124124
that doesn't support this feature will have unexpected results.
125125

126126
If unsure, say N.
127+
128+
config OVERLAY_FS_UNPRIVILEGED
129+
bool "Overlayfs: turn on unprivileged user namespace mounts"
130+
default n
131+
depends on OVERLAY_FS
132+
help
133+
When disabled, unprivileged users will not be able to create
134+
new overlayfs mounts. This cuts the attack surface if no
135+
unprivileged user namespace mounts are required like for
136+
running rootless containers.
137+
138+
Overlayfs has been part of several recent local privilege
139+
escalation exploits, so if you are security-conscious
140+
you want to disable this.
141+
142+
If unsure, say N.

fs/overlayfs/super.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,9 @@ static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
21292129
static struct file_system_type ovl_fs_type = {
21302130
.owner = THIS_MODULE,
21312131
.name = "overlay",
2132+
#ifdef CONFIG_OVERLAY_FS_UNPRIVILEGED
21322133
.fs_flags = FS_USERNS_MOUNT,
2134+
#endif
21332135
.mount = ovl_mount,
21342136
.kill_sb = kill_anon_super,
21352137
};

0 commit comments

Comments
 (0)