From 94ee5f0ac5ec30458a7835695b4d17520a36ab31 Mon Sep 17 00:00:00 2001 From: jake Date: Sat, 4 Jan 2003 07:54:23 +0000 Subject: 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. --- sys/kern/kern_exec.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'sys/kern/kern_exec.c') 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. -- cgit v1.1