Add elf image flag to disable stack gap.
Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D22379
This commit is contained in:
parent
01a2b5679b
commit
156e865494
@ -784,6 +784,7 @@ typedef struct {
|
||||
/* NT_FREEBSD_FEATURE_CTL desc[0] bits */
|
||||
#define NT_FREEBSD_FCTL_ASLR_DISABLE 0x00000001
|
||||
#define NT_FREEBSD_FCTL_PROTMAX_DISABLE 0x00000002
|
||||
#define NT_FREEBSD_FCTL_STKGAP_DISABLE 0x00000004
|
||||
|
||||
/* Values for n_type. Used in core files. */
|
||||
#define NT_PRSTATUS 1 /* Process status. */
|
||||
|
@ -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>
|
||||
@ -4136,7 +4137,8 @@ vm_map_stack_locked(vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize,
|
||||
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);
|
||||
@ -4273,7 +4275,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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user