Skip to content

Commit fdbc1df

Browse files
committed
add CONFIG for unprivileged_userfaultfd
When disabled, unprivileged users will not be able to use the userfaultfd syscall. Userfaultfd provide attackers with a way to stall a kernel thread in the middle of memory accesses from userspace by initiating an access on an unmapped page. To avoid various heap grooming and heap spraying techniques for exploiting use-after-free flaws this should be disabled by default. This setting can be overridden at runtime via the vm.unprivileged_userfaultfd sysctl. Signed-off-by: Levente Polyak <[email protected]>
1 parent 4838fea commit fdbc1df

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

fs/userfaultfd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@
2828
#include <linux/security.h>
2929
#include <linux/hugetlb.h>
3030

31+
#ifdef CONFIG_USERFAULTFD_UNPRIVILEGED
3132
int sysctl_unprivileged_userfaultfd __read_mostly = 1;
33+
#else
34+
int sysctl_unprivileged_userfaultfd __read_mostly;
35+
#endif
3236

3337
static struct kmem_cache *userfaultfd_ctx_cachep __read_mostly;
3438

init/Kconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,6 +1733,23 @@ config USERFAULTFD
17331733
Enable the userfaultfd() system call that allows to intercept and
17341734
handle page faults in userland.
17351735

1736+
config USERFAULTFD_UNPRIVILEGED
1737+
bool "Allow unprivileged users to use the userfaultfd syscall"
1738+
depends on USERFAULTFD
1739+
default n
1740+
help
1741+
When disabled, unprivileged users will not be able to use the userfaultfd
1742+
syscall. Userfaultfd provide attackers with a way to stall a kernel
1743+
thread in the middle of memory accesses from userspace by initiating an
1744+
access on an unmapped page. To avoid various heap grooming and heap
1745+
spraying techniques for exploiting use-after-free flaws this should be
1746+
disabled by default.
1747+
1748+
This setting can be overridden at runtime via the
1749+
vm.unprivileged_userfaultfd sysctl.
1750+
1751+
If unsure, say N.
1752+
17361753
config ARCH_HAS_MEMBARRIER_CALLBACKS
17371754
bool
17381755

0 commit comments

Comments
 (0)