Re: [PATCH] selftests/proc: include linux/mman.h for MREMAP_DONTUNMAP
From: Andrew Morton
Date: Thu Nov 19 2026 - 22:24:18 EST
On Fri, 20 Nov 2026 10:27:10 +0800 Qingshuang Fu <fuqingshuang@xxxxxxxxxx> wrote:
> glibc versions before 2.32 do not define MREMAP_DONTUNMAP in
> <sys/mman.h>, so proc-maps-race fails to build against them (e.g.
> glibc 2.31):
>
> $ make -C tools/testing/selftests TARGETS=proc
> ...
> proc-maps-race.c:691:58: error: 'MREMAP_DONTUNMAP' undeclared
> (first use in this function)
>
> Include <linux/mman.h> to get the flag from the kernel UAPI headers
> instead of depending on the libc version. The proc Makefile already
> adds those headers to the include path via $(TOOLS_INCLUDES).
Boy, anyone who is running 6 year old glibc has bigger problems than
this. 2.31 is full of scary-looking CVEs.
> --- a/tools/testing/selftests/proc/proc-maps-race.c
> +++ b/tools/testing/selftests/proc/proc-maps-race.c
> @@ -33,6 +33,7 @@
> #include <string.h>
> #include <unistd.h>
> #include <linux/fs.h>
> +#include <linux/mman.h>
> #include <sys/ioctl.h>
> #include <sys/mman.h>
> #include <sys/stat.h>
but OK, patch looks harmless enough and lots of selftests/ are including
linux/mman.h.