svn commit: r355052 - in stable/12/sys: sys vm
Konstantin Belousov
kib at FreeBSD.org
Sun Nov 24 12:30:42 UTC 2019
Author: kib
Date: Sun Nov 24 12:30:41 2019
New Revision: 355052
URL: https://svnweb.freebsd.org/changeset/base/355052
Log:
MFC r354790:
Add elf image flag to disable stack gap.
Modified:
stable/12/sys/sys/elf_common.h
stable/12/sys/vm/vm_map.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/sys/elf_common.h
==============================================================================
--- stable/12/sys/sys/elf_common.h Sun Nov 24 12:27:13 2019 (r355051)
+++ stable/12/sys/sys/elf_common.h Sun Nov 24 12:30:41 2019 (r355052)
@@ -778,6 +778,7 @@ typedef struct {
/* NT_FREEBSD_FEATURE_CTL desc[0] bits */
#define NT_FREEBSD_FCTL_ASLR_DISABLE 0x00000001
+#define NT_FREEBSD_FCTL_STKGAP_DISABLE 0x00000004
/* Values for n_type. Used in core files. */
#define NT_PRSTATUS 1 /* Process status. */
Modified: stable/12/sys/vm/vm_map.c
==============================================================================
--- stable/12/sys/vm/vm_map.c Sun Nov 24 12:27:13 2019 (r355051)
+++ stable/12/sys/vm/vm_map.c Sun Nov 24 12:30:41 2019 (r355052)
@@ -69,6 +69,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/elf.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
@@ -4114,7 +4115,8 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos,
addrbos + max_ssize > vm_map_max(map) ||
addrbos + max_ssize <= addrbos)
return (KERN_INVALID_ADDRESS);
- sgp = (curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 ? 0 :
+ sgp = ((curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 ||
+ (curproc->p_fctl0 & NT_FREEBSD_FCTL_STKGAP_DISABLE) != 0) ? 0 :
(vm_size_t)stack_guard_page * PAGE_SIZE;
if (sgp >= max_ssize)
return (KERN_INVALID_ARGUMENT);
@@ -4251,7 +4253,8 @@ retry:
} else {
return (KERN_FAILURE);
}
- guard = (curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 ? 0 :
+ guard = ((curproc->p_flag2 & P2_STKGAP_DISABLE) != 0 ||
+ (curproc->p_fctl0 & NT_FREEBSD_FCTL_STKGAP_DISABLE) != 0) ? 0 :
gap_entry->next_read;
max_grow = gap_entry->end - gap_entry->start;
if (guard > max_grow)
More information about the svn-src-stable-12
mailing list