Add a sysctl to get the vm protections for the stack of the current process.
On architectures with a non-executable stack, eg sparc64, this is used by libgcc to determine at runtime if its necessary to enable execute permissions on a region of the stack which will be used to execute code, allowing the call to mprotect to be avoided if the kernel is configured to map the stack executable.
This commit is contained in:
parent
33c0e6ef8b
commit
5dadd17b08
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=108645
@ -76,6 +76,7 @@ static MALLOC_DEFINE(M_ATEXEC, "atexec", "atexec callback");
|
||||
|
||||
static int sysctl_kern_ps_strings(SYSCTL_HANDLER_ARGS);
|
||||
static int sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS);
|
||||
static int sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS);
|
||||
static int kern_execve(struct thread *td, char *fname, char **argv,
|
||||
char **envv, struct mac *mac_p);
|
||||
|
||||
@ -98,6 +99,9 @@ SYSCTL_PROC(_kern, KERN_PS_STRINGS, ps_strings, CTLTYPE_ULONG|CTLFLAG_RD,
|
||||
SYSCTL_PROC(_kern, KERN_USRSTACK, usrstack, CTLTYPE_ULONG|CTLFLAG_RD,
|
||||
NULL, 0, sysctl_kern_usrstack, "LU", "");
|
||||
|
||||
SYSCTL_PROC(_kern, OID_AUTO, stackprot, CTLTYPE_INT|CTLFLAG_RD,
|
||||
NULL, 0, sysctl_kern_stackprot, "I", "");
|
||||
|
||||
u_long ps_arg_cache_limit = PAGE_SIZE / 16;
|
||||
SYSCTL_ULONG(_kern, OID_AUTO, ps_arg_cache_limit, CTLFLAG_RW,
|
||||
&ps_arg_cache_limit, 0, "");
|
||||
@ -131,6 +135,16 @@ sysctl_kern_usrstack(SYSCTL_HANDLER_ARGS)
|
||||
sizeof(p->p_sysent->sv_usrstack)));
|
||||
}
|
||||
|
||||
static int
|
||||
sysctl_kern_stackprot(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct proc *p;
|
||||
|
||||
p = curproc;
|
||||
return (SYSCTL_OUT(req, &p->p_sysent->sv_stackprot,
|
||||
sizeof(p->p_sysent->sv_stackprot)));
|
||||
}
|
||||
|
||||
/*
|
||||
* Each of the items is a pointer to a `const struct execsw', hence the
|
||||
* double pointer here.
|
||||
|
Loading…
Reference in New Issue
Block a user