diff -Nur linux-2.4.20-quota-ctx/arch/i386/config.in linux-2.4.20/arch/i386/config.in --- linux-2.4.20-quota-ctx/arch/i386/config.in 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/arch/i386/config.in 2003-02-20 14:10:41.000000000 +0000 @@ -286,6 +286,9 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + if [ "$CONFIG_PROC_FS" = "y" ]; then choice 'Kernel core (/proc/kcore) format' \ "ELF CONFIG_KCORE_ELF \ diff -Nur linux-2.4.20-quota-ctx/arch/ppc/config.in linux-2.4.20/arch/ppc/config.in --- linux-2.4.20-quota-ctx/arch/ppc/config.in 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/arch/ppc/config.in 2003-02-18 13:28:35.000000000 +0000 @@ -161,6 +161,9 @@ bool 'Networking support' CONFIG_NET bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT diff -Nur linux-2.4.20-quota-ctx/arch/sparc/config.in linux-2.4.20/arch/sparc/config.in --- linux-2.4.20-quota-ctx/arch/sparc/config.in 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/arch/sparc/config.in 2003-02-18 13:28:35.000000000 +0000 @@ -65,6 +65,9 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + if [ "$CONFIG_PROC_FS" = "y" ]; then define_bool CONFIG_KCORE_ELF y fi diff -Nur linux-2.4.20-quota-ctx/arch/sparc64/config.in linux-2.4.20/arch/sparc64/config.in --- linux-2.4.20-quota-ctx/arch/sparc64/config.in 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/arch/sparc64/config.in 2003-02-18 13:28:35.000000000 +0000 @@ -64,6 +64,9 @@ bool 'System V IPC' CONFIG_SYSVIPC bool 'BSD Process Accounting' CONFIG_BSD_PROCESS_ACCT bool 'Sysctl support' CONFIG_SYSCTL + +source kernel/ctx.Config.in + if [ "$CONFIG_PROC_FS" = "y" ]; then define_bool CONFIG_KCORE_ELF y fi diff -Nur linux-2.4.20-quota-ctx/Documentation/Configure.help linux-2.4.20/Documentation/Configure.help --- linux-2.4.20-quota-ctx/Documentation/Configure.help 2003-01-30 14:40:57.000000000 +0000 +++ linux-2.4.20/Documentation/Configure.help 2003-02-20 14:10:41.000000000 +0000 @@ -526,6 +526,12 @@ The umem driver has been allocated block major number 116. See Documentation/devices.txt for recommended device naming. +Context Patch Sysctls +CONFIG_CTX_SYSCTLS + Saying Y here will allow you to configure some of the behaviour of + the Jacques Gelinas Context Patch + + See http://www.solucorp.qc.ca/miscprj/s_context.hc Network block device support CONFIG_BLK_DEV_NBD Saying Y here will allow your computer to be a client for network diff -Nur linux-2.4.20-quota-ctx/fs/proc/generic.c linux-2.4.20/fs/proc/generic.c --- linux-2.4.20-quota-ctx/fs/proc/generic.c 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/fs/proc/generic.c 2003-02-20 13:39:23.000000000 +0000 @@ -249,6 +249,9 @@ * Don't create negative dentries here, return -ENOENT by hand * instead. */ +#if defined CONFIG_CTX_SYSCTLS +extern int sysctl_ctx_unsafe_sysctrls; +#endif struct dentry *proc_lookup(struct inode * dir, struct dentry *dentry) { struct inode *inode; @@ -264,6 +267,12 @@ continue; if (de->namelen != dentry->d_name.len) continue; +#if defined CONFIG_CTX_SYSCTLS + // Cloak /proc/sys/kernel/ctx outside of root ctx unless explicitly visible + if( de->namelen == 3 && !strcmp("ctx", de->name) && + current->s_context != 0 && current->s_context != 1 && !sysctl_ctx_unsafe_sysctrls ) + continue; +#endif if (!memcmp(dentry->d_name.name, de->name, de->namelen)) { int ino = de->low_ino; error = -EINVAL; @@ -281,6 +290,10 @@ return ERR_PTR(error); } +#if defined CONFIG_CTX_SYSCTLS +int sysctl_ctx_unsafe_sysctrls = 0; // Default to safe +#endif + /* * This returns non-zero if at EOF, so that the /proc * root directory can use this and check if it should @@ -331,6 +344,10 @@ } do { +#if defined CONFIG_CTX_SYSCTLS + // Ctx sysctls only visible to root context (by default) + if( current->s_context == 0 || current->s_context == 1 || sysctl_ctx_unsafe_sysctrls || strcmp(de->name, "ctx") ) +#endif if (filldir(dirent, de->name, de->namelen, filp->f_pos, de->low_ino, de->mode >> 12) < 0) return 0; Binary files linux-2.4.20-quota-ctx/fs/proc/.generic.c.swp and linux-2.4.20/fs/proc/.generic.c.swp differ diff -Nur a/include/linux/sysctl.h b/include/linux/sysctl.h --- a/include/linux/sysctl.h 2003-01-30 14:40:56.000000000 +0000 +++ b/include/linux/sysctl.h 2003-02-20 09:53:20.000000000 +0000 @@ -112,6 +112,7 @@ KERN_RANDOM=40, /* Random driver */ KERN_SHMALL=41, /* int: Maximum size of shared memory */ KERN_MSGMNI=42, /* int: msg queue identifiers */ + KERN_CTX=113, /* Context Patch */ KERN_SEM=43, /* struct: sysv semaphore limits */ KERN_SPARC_STOP_A=44, /* int: Sparc Stop-A enable */ KERN_SHMMNI=45, /* int: shm array identifiers */ diff -Nur linux-2.4.20-quota-ctx/kernel/sysctl.c linux-2.4.20/kernel/sysctl.c --- linux-2.4.20-quota-ctx/kernel/sysctl.c 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/kernel/sysctl.c 2003-02-20 09:34:08.000000000 +0000 @@ -86,6 +86,18 @@ extern int sysctl_userprocess_debug; #endif +#ifdef CONFIG_CTX_SYSCTLS + +enum +{ + CTX_SYSCTRL_CTX_PLACEHOLDER = 0, +}; + +static ctl_table ctx_table[] = { + {0} +}; +#endif + #ifdef CONFIG_PPC32 extern unsigned long zero_paged_on, powersave_nap; int proc_dol2crvec(ctl_table *table, int write, struct file *filp, @@ -256,6 +268,9 @@ {KERN_S390_USER_DEBUG_LOGGING,"userprocess_debug", &sysctl_userprocess_debug,sizeof(int),0644,NULL,&proc_dointvec}, #endif +#ifdef CONFIG_CTX_SYSCTLS + {KERN_CTX, "ctx", NULL, 0, 0700, ctx_table}, +#endif {0} }; diff -Nur linux-2.4.20-quota-ctx/kernel/ctx.Config.in linux-2.4.20/kernel/ctx.Config.in --- linux-2.4.20-quota-ctx/kernel/ctx.Config.in 2003-01-30 14:40:56.000000000 +0000 +++ linux-2.4.20/kernel/ctx.Config.in 2003-02-20 09:53:20.000000000 +0000 @@ -0,0 +1,11 @@ +# +# Context configuration +# +mainmenu_option next_comment +comment 'Context Options' + +if [ "$CONFIG_SYSCTL" = "y" ]; then + bool 'Sysctl support for Context Patch' CONFIG_CTX_SYSCTLS +fi + +endmenu