mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
zend call stack adjust case for freebsd to calculate the guard size. (#13586)
it was not wrong but there is a sysctl oid storing the number of guard pages, which is 1 by default but is modifiable at runtime.
This commit is contained in:
parent
3d4cb1da3e
commit
e3b6872b51
1 changed files with 8 additions and 1 deletions
|
@ -313,6 +313,7 @@ static bool zend_call_stack_get_freebsd_sysctl(zend_call_stack *stack)
|
||||||
int mib[2] = {CTL_KERN, KERN_USRSTACK};
|
int mib[2] = {CTL_KERN, KERN_USRSTACK};
|
||||||
size_t len = sizeof(stack_base);
|
size_t len = sizeof(stack_base);
|
||||||
struct rlimit rlim;
|
struct rlimit rlim;
|
||||||
|
size_t numguards = 0;
|
||||||
|
|
||||||
/* This method is relevant only for the main thread */
|
/* This method is relevant only for the main thread */
|
||||||
ZEND_ASSERT(zend_call_stack_is_main_thread());
|
ZEND_ASSERT(zend_call_stack_is_main_thread());
|
||||||
|
@ -329,7 +330,13 @@ static bool zend_call_stack_get_freebsd_sysctl(zend_call_stack *stack)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t guard_size = getpagesize();
|
len = sizeof(numguards);
|
||||||
|
/* For most of the cases, we do not necessarily need to do so as, by default, it is `1` page, but is user writable */
|
||||||
|
if (sysctlbyname("security.bsd.stack_guard_page", &numguards, &len, NULL, 0) != 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t guard_size = numguards * getpagesize();
|
||||||
|
|
||||||
stack->base = stack_base;
|
stack->base = stack_base;
|
||||||
stack->max_size = rlim.rlim_cur - guard_size;
|
stack->max_size = rlim.rlim_cur - guard_size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue