From 68b89c96a435a2d436fda459b2c9a4e6571c9929 Mon Sep 17 00:00:00 2001 From: kib Date: Fri, 7 Jul 2017 06:29:18 +0000 Subject: Add MAP_GUARD and use it for stack grow area protection. Bump __FreeBSD_version. This is an MFS of stable/11 r320666. MFC r320317: Implement address space guards. MFC r320338: Remove stale part of the comment. MFC r320339: Correctly handle small MAP_STACK requests. MFC r320344: For now, allow mprotect(2) over the guards to succeed regardless of the requested protection. MFC r320430: Treat the addr argument for mmap(2) request without MAP_FIXED flag as a hint. MFC r320560 (by alc): Modify vm_map_growstack() to protect itself from the possibility of the gap entry in the vm map being smaller than the sysctl-derived stack guard size. Approved by: re (delphij) --- sys/sys/mman.h | 1 + sys/sys/param.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'sys/sys') diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 414de02..199b519 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -90,6 +90,7 @@ /* * Extended flags */ +#define MAP_GUARD 0x00002000 /* reserve but don't map address range */ #define MAP_EXCL 0x00004000 /* for MAP_FIXED, fail if address is used */ #define MAP_NOCORE 0x00020000 /* dont include these pages in a coredump */ #define MAP_PREFAULT_READ 0x00040000 /* prefault mapping for reading */ diff --git a/sys/sys/param.h b/sys/sys/param.h index 0f2799e..16d3d6f 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1101000 /* Master, propagated to newvers */ +#define __FreeBSD_version 1101001 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, @@ -76,12 +76,15 @@ #undef __FreeBSD_kernel__ #define __FreeBSD_kernel__ -#ifdef _KERNEL +#if defined(_KERNEL) || defined(IN_RTLD) #define P_OSREL_SIGWAIT 700000 #define P_OSREL_SIGSEGV 700004 #define P_OSREL_MAP_ANON 800104 #define P_OSREL_MAP_FSTRICT 1100036 #define P_OSREL_SHUTDOWN_ENOTCONN 1100077 +#define P_OSREL_MAP_GUARD 1200035 +#define P_OSREL_MAP_GUARD_11 1101501 +#define P_OSREL_MAP_GUARD_11_1 1101001 #define P_OSREL_MAJOR(x) ((x) / 100000) #endif -- cgit v1.1