OSDN Git Service

[PATCH] sysctl to prevent normal processes from mapping NULL
authorWilly Tarreau <w@1wt.eu>
Mon, 13 Aug 2007 08:50:08 +0000 (10:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 8 Sep 2007 17:41:48 +0000 (19:41 +0200)
commit97fdf52693285f9344973da3fa4e936068b3b4f3
treebd31672fcdb0a17969e84fd69017e18aa3fbe0fd
parente56ce115f0d4fc815b2eeac51c6d1c51e85d9d42
[PATCH] sysctl to prevent normal processes from mapping NULL

After a patch proposal from Solar Designer, and discussions with
Alan Cox and Chris Wright, I modeled this patch which permits to
restrict mapping of lower virtual addresses to CAP_RAW_IO capable
processes only.

This makes it harder for processes to try to exploit NULL pointer
dereference bugs in the kernel.

In order to ease transition from 2.4 to 2.6, the patch has also
been inspired by Eric Paris's patch now present in 2.6, which
adds the sys/vm/mmap_min_addr sysctl by which the lowest mappable
address is set. This sysctl defaults to zero, meaning NULL is
allowed by default.

According to test ran by Solar Designer, both Xorg and Wine run
correctly as a normal user with the restriction enabled. There
should be very few regressions when enabling it, and it is
recommended to enable it on servers after the obviously needed
validation.

Alan points that some rare programs use a trick consisting in
mapping this page in order to reduce the number of NULL checks
in linked lists for instance.

Signed-off-by: Willy Tarreau <w@1wt.eu>
include/linux/mm.h
include/linux/sysctl.h
kernel/sysctl.c
mm/mmap.c
mm/mremap.c