Module Name: src Committed By: christos Date: Sat Oct 13 15:35:56 UTC 2012
Modified Files: src/sys/kern: kern_exec.c src/sys/sys: sysctl.h Log Message: add KERN_USRSTACK (this is not dynamically defined for FreeBSD compatibility) To generate a diff of this commit: cvs rdiff -u -r1.355 -r1.356 src/sys/kern/kern_exec.c cvs rdiff -u -r1.201 -r1.202 src/sys/sys/sysctl.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.355 src/sys/kern/kern_exec.c:1.356 --- src/sys/kern/kern_exec.c:1.355 Wed Aug 29 14:56:39 2012 +++ src/sys/kern/kern_exec.c Sat Oct 13 11:35:55 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.355 2012/08/29 18:56:39 dholland Exp $ */ +/* $NetBSD: kern_exec.c,v 1.356 2012/10/13 15:35:55 christos Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.355 2012/08/29 18:56:39 dholland Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.356 2012/10/13 15:35:55 christos Exp $"); #include "opt_exec.h" #include "opt_ktrace.h" @@ -104,6 +104,7 @@ __KERNEL_RCSID(0, "$NetBSD: kern_exec.c, #include <sys/spawn.h> #include <sys/prot.h> #include <sys/cprng.h> +#include <sys/sysctl.h> #include <uvm/uvm_extern.h> @@ -1617,6 +1618,30 @@ exec_remove(struct execsw *esp, int coun return 0; } +static int +sysctl_kern_usrstack(SYSCTLFN_ARGS) +{ + u_long ptr; + struct sysctlnode node = *rnode; + node.sysctl_data = &ptr; + ptr = l->l_proc->p_stackbase; + return sysctl_lookup(SYSCTLFN_CALL(&node)); +} + +static void +sysctl_kern_usrstack_setup(void) +{ + struct sysctllog *kern_usrstack_sysctllog; + + kern_usrstack_sysctllog = NULL; + sysctl_createv(&kern_usrstack_sysctllog, 0, NULL, NULL, + CTLFLAG_PERMANENT|CTLFLAG_READONLY, + CTLTYPE_LONG, "usrstack", + SYSCTL_DESCR("User process stack base"), + sysctl_kern_usrstack, 0, NULL, 0, + CTL_KERN, KERN_USRSTACK, CTL_EOL); +} + /* * Initialize exec structures. If init_boot is true, also does necessary * one-time initialization (it's called from main() that way). @@ -1640,6 +1665,7 @@ exec_init(int init_boot) pool_init(&exec_pool, NCARGS, 0, 0, PR_NOALIGN|PR_NOTOUCH, "execargs", &exec_palloc, IPL_NONE); pool_sethardlimit(&exec_pool, maxexec, "should not happen", 0); + sysctl_kern_usrstack_setup(); } else { KASSERT(rw_write_held(&exec_lock)); } Index: src/sys/sys/sysctl.h diff -u src/sys/sys/sysctl.h:1.201 src/sys/sys/sysctl.h:1.202 --- src/sys/sys/sysctl.h:1.201 Fri Jun 8 22:31:15 2012 +++ src/sys/sys/sysctl.h Sat Oct 13 11:35:56 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: sysctl.h,v 1.201 2012/06/09 02:31:15 christos Exp $ */ +/* $NetBSD: sysctl.h,v 1.202 2012/10/13 15:35:56 christos Exp $ */ /* * Copyright (c) 1989, 1993 @@ -273,7 +273,8 @@ struct ctlname { #define KERN_SYSVIPC 82 /* node: SysV IPC parameters */ #define KERN_BOOTTIME 83 /* struct: time kernel was booted */ #define KERN_EVCNT 84 /* struct: evcnts */ -#define KERN_MAXID 85 /* number of valid kern ids */ +#define KERN_USRSTACK 85 /* long: user stack base */ +#define KERN_MAXID 86 /* number of valid kern ids */ #define CTL_KERN_NAMES { \ @@ -362,6 +363,7 @@ struct ctlname { { "sysvipc", CTLTYPE_STRUCT }, \ { "boottime", CTLTYPE_STRUCT }, \ { "evcnt", CTLTYPE_STRUCT }, \ + { "usrstack", CTLTYPE_LONG }, \ } /*