Skip to content

Commit

Permalink
ovl: add config to disable unprivileged user namespace mounts
Browse files Browse the repository at this point in the history
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 <levente@leventepolyak.net>
  • Loading branch information
anthraxx committed Mar 30, 2024
1 parent e9358bc commit e6733bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fs/overlayfs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,19 @@ config OVERLAY_FS_METACOPY
that doesn't support this feature will have unexpected results.

If unsure, say N.

config OVERLAY_FS_UNPRIVILEGED
bool "Overlayfs: turn on unprivileged user namespace mounts"
default n
depends on OVERLAY_FS
help
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.

Overlayfs has been part of several recent local privilege
escalation exploits, so if you are security-conscious
you want to disable this.

If unsure, say N.
2 changes: 2 additions & 0 deletions fs/overlayfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,9 @@ static struct dentry *ovl_mount(struct file_system_type *fs_type, int flags,
static struct file_system_type ovl_fs_type = {
.owner = THIS_MODULE,
.name = "overlay",
#ifdef CONFIG_OVERLAY_FS_UNPRIVILEGED
.fs_flags = FS_USERNS_MOUNT,
#endif
.mount = ovl_mount,
.kill_sb = kill_anon_super,
};
Expand Down

0 comments on commit e6733bd

Please sign in to comment.