diff options
author | jake <jake@FreeBSD.org> | 2003-01-04 07:54:23 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2003-01-04 07:54:23 +0000 |
commit | 94ee5f0ac5ec30458a7835695b4d17520a36ab31 (patch) | |
tree | 8693673620209b7b426b6c63f12a1c07eb78cd9c /sys | |
parent | 30246458a278eb3e11456eeea0448fb05e2a3b69 (diff) | |
download | FreeBSD-src-94ee5f0ac5ec30458a7835695b4d17520a36ab31.zip FreeBSD-src-94ee5f0ac5ec30458a7835695b4d17520a36ab31.tar.gz |
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.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_exec.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index acb12ee..f8bf341 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -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. |