Use __MAP_NOFAULT such that a client cannot use ftruncate and make the

X server crash.

ok deraadt@, matthieu@
This commit is contained in:
kettenis 2018-07-11 06:59:03 +00:00
parent 2c8cd3e507
commit 323f3c34c5

View File

@ -26,6 +26,10 @@
#include "xshmfenceint.h"
#ifndef __MAP_NOFAULT
#define __MAP_NOFAULT 0
#endif
#if !HAVE_MEMFD_CREATE
#if HAVE_DECL___NR_MEMFD_CREATE
#include <asm/unistd.h>
@ -105,7 +109,7 @@ struct xshmfence *
xshmfence_map_shm(int fd)
{
struct xshmfence *addr;
addr = mmap (NULL, sizeof (struct xshmfence) , PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
addr = mmap (NULL, sizeof (struct xshmfence) , PROT_READ|PROT_WRITE, MAP_SHARED | __MAP_NOFAULT, fd, 0);
if (addr == MAP_FAILED) {
close (fd);
return 0;