Re: [PATCH 4/5] [V2] Define is_global_init() and is_container_init()
Andrew Morton [EMAIL PROTECTED] wrote: | On Thu, 19 Jul 2007 00:21:58 -0700 | [EMAIL PROTECTED] wrote: | | > --- lx26-22-rc6-mm1a.orig/kernel/pid.c 2007-07-16 12:55:15.0 -0700 | > +++ lx26-22-rc6-mm1a/kernel/pid.c 2007-07-16 13:10:48.0 -0700 | > @@ -69,6 +69,13 @@ struct pid_namespace init_pid_ns = { | > .last_pid = 0, | > .child_reaper = _task | > }; | > +EXPORT_SYMBOL(init_pid_ns); | > + | > +int is_global_init(struct task_struct *tsk) | > +{ | > + return tsk == init_pid_ns.child_reaper; | > +} | > +EXPORT_SYMBOL(is_global_init); | | I don't immediately see why init_pid_ns was exported to modules. | | It would need to be exported if is_global_init() was made static inline in a | header (which seems like a sensible thing to do), but it wasn't. It did not need to be exported in this patch. I have a couple of follow-on patches that cleaned up some header-file dependencies and made is_global_init() inline. Those patches are changing a bit as I merge them with Pavel Emelianov's pid ns changes. I will send a separate patch to inline is_global_init(). Suka - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] [V2] Define is_global_init() and is_container_init()
On Thu, 19 Jul 2007 00:21:58 -0700 [EMAIL PROTECTED] wrote: > --- lx26-22-rc6-mm1a.orig/kernel/pid.c2007-07-16 12:55:15.0 > -0700 > +++ lx26-22-rc6-mm1a/kernel/pid.c 2007-07-16 13:10:48.0 -0700 > @@ -69,6 +69,13 @@ struct pid_namespace init_pid_ns = { > .last_pid = 0, > .child_reaper = _task > }; > +EXPORT_SYMBOL(init_pid_ns); > + > +int is_global_init(struct task_struct *tsk) > +{ > + return tsk == init_pid_ns.child_reaper; > +} > +EXPORT_SYMBOL(is_global_init); I don't immediately see why init_pid_ns was exported to modules. It would need to be exported if is_global_init() was made static inline in a header (which seems like a sensible thing to do), but it wasn't. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] [V2] Define is_global_init() and is_container_init()
On Thu, 19 Jul 2007 00:21:58 -0700 [EMAIL PROTECTED] wrote: --- lx26-22-rc6-mm1a.orig/kernel/pid.c2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/kernel/pid.c 2007-07-16 13:10:48.0 -0700 @@ -69,6 +69,13 @@ struct pid_namespace init_pid_ns = { .last_pid = 0, .child_reaper = init_task }; +EXPORT_SYMBOL(init_pid_ns); + +int is_global_init(struct task_struct *tsk) +{ + return tsk == init_pid_ns.child_reaper; +} +EXPORT_SYMBOL(is_global_init); I don't immediately see why init_pid_ns was exported to modules. It would need to be exported if is_global_init() was made static inline in a header (which seems like a sensible thing to do), but it wasn't. - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH 4/5] [V2] Define is_global_init() and is_container_init()
Andrew Morton [EMAIL PROTECTED] wrote: | On Thu, 19 Jul 2007 00:21:58 -0700 | [EMAIL PROTECTED] wrote: | | --- lx26-22-rc6-mm1a.orig/kernel/pid.c 2007-07-16 12:55:15.0 -0700 | +++ lx26-22-rc6-mm1a/kernel/pid.c 2007-07-16 13:10:48.0 -0700 | @@ -69,6 +69,13 @@ struct pid_namespace init_pid_ns = { | .last_pid = 0, | .child_reaper = init_task | }; | +EXPORT_SYMBOL(init_pid_ns); | + | +int is_global_init(struct task_struct *tsk) | +{ | + return tsk == init_pid_ns.child_reaper; | +} | +EXPORT_SYMBOL(is_global_init); | | I don't immediately see why init_pid_ns was exported to modules. | | It would need to be exported if is_global_init() was made static inline in a | header (which seems like a sensible thing to do), but it wasn't. It did not need to be exported in this patch. I have a couple of follow-on patches that cleaned up some header-file dependencies and made is_global_init() inline. Those patches are changing a bit as I merge them with Pavel Emelianov's pid ns changes. I will send a separate patch to inline is_global_init(). Suka - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH 4/5] [V2] Define is_global_init() and is_container_init()
Subject: [PATCH 4/5] Define is_global_init() and is_container_init(). From: Serge E. Hallyn <[EMAIL PROTECTED]> is_init() is an ambiguous name for the pid==1 check. Split it into is_global_init() and is_container_init(). A container init has it's tsk->pid == 1. A global init also has it's tsk->pid == 1 and it's active pid namespace is the init_pid_ns. But rather than check the active pid namespace, compare the task structure with 'init_pid_ns.child_reaper', which is initialized during boot to the /sbin/init process and never changes. Changelog: 2.6.22-rc4-mm2-pidns1: - Use 'init_pid_ns.child_reaper' to determine if a given task is the global init (/sbin/init) process. This would improve performance and remove dependence on the task_pid(). 2.6.21-mm2-pidns2: - [Sukadev Bhattiprolu] Changed is_container_init() calls in {powerpc, ppc,avr32}/traps.c for the _exception() call to is_global_init(). This way, we kill only the container if the container's init has a bug rather than force a kernel panic. Signed-off-by: Serge E. Hallyn <[EMAIL PROTECTED]> Signed-off-by: Sukadev Bhattiprolu <[EMAIL PROTECTED]> Acked-by: Pavel Emelianov <[EMAIL PROTECTED]> Cc: Eric W. Biederman <[EMAIL PROTECTED]> Cc: Cedric Le Goater <[EMAIL PROTECTED]> Cc: Dave Hansen <[EMAIL PROTECTED]> Cc: Herbert Poetzel <[EMAIL PROTECTED]> --- arch/alpha/mm/fault.c|2 +- arch/arm/mm/fault.c |2 +- arch/arm26/mm/fault.c|2 +- arch/avr32/kernel/traps.c|2 +- arch/avr32/mm/fault.c|6 +++--- arch/i386/lib/usercopy.c |2 +- arch/i386/mm/fault.c |2 +- arch/ia64/mm/fault.c |2 +- arch/m68k/mm/fault.c |2 +- arch/mips/mm/fault.c |2 +- arch/powerpc/kernel/traps.c |2 +- arch/powerpc/mm/fault.c |2 +- arch/powerpc/platforms/pseries/ras.c |2 +- arch/ppc/kernel/traps.c |2 +- arch/ppc/mm/fault.c |2 +- arch/s390/lib/uaccess_pt.c |2 +- arch/s390/mm/fault.c |2 +- arch/sh/mm/fault.c |2 +- arch/sh64/mm/fault.c |6 +++--- arch/um/kernel/trap.c|2 +- arch/x86_64/mm/fault.c |2 +- arch/xtensa/mm/fault.c |2 +- drivers/char/sysrq.c |2 +- include/linux/sched.h| 12 ++-- kernel/capability.c |3 ++- kernel/exit.c|2 +- kernel/kexec.c |2 +- kernel/pid.c |7 +++ kernel/signal.c |2 +- kernel/sysctl.c |2 +- mm/oom_kill.c|4 ++-- security/commoncap.c |3 ++- 32 files changed, 54 insertions(+), 37 deletions(-) Index: lx26-22-rc6-mm1a/include/linux/sched.h === --- lx26-22-rc6-mm1a.orig/include/linux/sched.h 2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/include/linux/sched.h 2007-07-16 13:10:48.0 -0700 @@ -1219,12 +1219,20 @@ static inline int pid_alive(struct task_ } /** - * is_init - check if a task structure is init + * is_global_init - check if a task structure is init * @tsk: Task structure to be checked. * * Check if a task structure is the first user space task the kernel created. + * + * TODO: We should inline this function after some cleanups in pid_namespace.h + */ +extern int is_global_init(struct task_struct *tsk); + +/* + * is_container_init: + * check whether in the task is init in it's own pid namespace. */ -static inline int is_init(struct task_struct *tsk) +static inline int is_container_init(struct task_struct *tsk) { return tsk->pid == 1; } Index: lx26-22-rc6-mm1a/kernel/pid.c === --- lx26-22-rc6-mm1a.orig/kernel/pid.c 2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/kernel/pid.c 2007-07-16 13:10:48.0 -0700 @@ -69,6 +69,13 @@ struct pid_namespace init_pid_ns = { .last_pid = 0, .child_reaper = _task }; +EXPORT_SYMBOL(init_pid_ns); + +int is_global_init(struct task_struct *tsk) +{ + return tsk == init_pid_ns.child_reaper; +} +EXPORT_SYMBOL(is_global_init); /* * Note: disable interrupts while the pidmap_lock is held as an Index: lx26-22-rc6-mm1a/arch/alpha/mm/fault.c === --- lx26-22-rc6-mm1a.orig/arch/alpha/mm/fault.c 2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/arch/alpha/mm/fault.c 2007-07-16 13:10:48.0 -0700 @@ -192,7 +192,7 @@ do_page_fault(unsigned long address, uns /* We ran out of memory, or
[PATCH 4/5] [V2] Define is_global_init() and is_container_init()
Subject: [PATCH 4/5] Define is_global_init() and is_container_init(). From: Serge E. Hallyn [EMAIL PROTECTED] is_init() is an ambiguous name for the pid==1 check. Split it into is_global_init() and is_container_init(). A container init has it's tsk-pid == 1. A global init also has it's tsk-pid == 1 and it's active pid namespace is the init_pid_ns. But rather than check the active pid namespace, compare the task structure with 'init_pid_ns.child_reaper', which is initialized during boot to the /sbin/init process and never changes. Changelog: 2.6.22-rc4-mm2-pidns1: - Use 'init_pid_ns.child_reaper' to determine if a given task is the global init (/sbin/init) process. This would improve performance and remove dependence on the task_pid(). 2.6.21-mm2-pidns2: - [Sukadev Bhattiprolu] Changed is_container_init() calls in {powerpc, ppc,avr32}/traps.c for the _exception() call to is_global_init(). This way, we kill only the container if the container's init has a bug rather than force a kernel panic. Signed-off-by: Serge E. Hallyn [EMAIL PROTECTED] Signed-off-by: Sukadev Bhattiprolu [EMAIL PROTECTED] Acked-by: Pavel Emelianov [EMAIL PROTECTED] Cc: Eric W. Biederman [EMAIL PROTECTED] Cc: Cedric Le Goater [EMAIL PROTECTED] Cc: Dave Hansen [EMAIL PROTECTED] Cc: Herbert Poetzel [EMAIL PROTECTED] --- arch/alpha/mm/fault.c|2 +- arch/arm/mm/fault.c |2 +- arch/arm26/mm/fault.c|2 +- arch/avr32/kernel/traps.c|2 +- arch/avr32/mm/fault.c|6 +++--- arch/i386/lib/usercopy.c |2 +- arch/i386/mm/fault.c |2 +- arch/ia64/mm/fault.c |2 +- arch/m68k/mm/fault.c |2 +- arch/mips/mm/fault.c |2 +- arch/powerpc/kernel/traps.c |2 +- arch/powerpc/mm/fault.c |2 +- arch/powerpc/platforms/pseries/ras.c |2 +- arch/ppc/kernel/traps.c |2 +- arch/ppc/mm/fault.c |2 +- arch/s390/lib/uaccess_pt.c |2 +- arch/s390/mm/fault.c |2 +- arch/sh/mm/fault.c |2 +- arch/sh64/mm/fault.c |6 +++--- arch/um/kernel/trap.c|2 +- arch/x86_64/mm/fault.c |2 +- arch/xtensa/mm/fault.c |2 +- drivers/char/sysrq.c |2 +- include/linux/sched.h| 12 ++-- kernel/capability.c |3 ++- kernel/exit.c|2 +- kernel/kexec.c |2 +- kernel/pid.c |7 +++ kernel/signal.c |2 +- kernel/sysctl.c |2 +- mm/oom_kill.c|4 ++-- security/commoncap.c |3 ++- 32 files changed, 54 insertions(+), 37 deletions(-) Index: lx26-22-rc6-mm1a/include/linux/sched.h === --- lx26-22-rc6-mm1a.orig/include/linux/sched.h 2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/include/linux/sched.h 2007-07-16 13:10:48.0 -0700 @@ -1219,12 +1219,20 @@ static inline int pid_alive(struct task_ } /** - * is_init - check if a task structure is init + * is_global_init - check if a task structure is init * @tsk: Task structure to be checked. * * Check if a task structure is the first user space task the kernel created. + * + * TODO: We should inline this function after some cleanups in pid_namespace.h + */ +extern int is_global_init(struct task_struct *tsk); + +/* + * is_container_init: + * check whether in the task is init in it's own pid namespace. */ -static inline int is_init(struct task_struct *tsk) +static inline int is_container_init(struct task_struct *tsk) { return tsk-pid == 1; } Index: lx26-22-rc6-mm1a/kernel/pid.c === --- lx26-22-rc6-mm1a.orig/kernel/pid.c 2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/kernel/pid.c 2007-07-16 13:10:48.0 -0700 @@ -69,6 +69,13 @@ struct pid_namespace init_pid_ns = { .last_pid = 0, .child_reaper = init_task }; +EXPORT_SYMBOL(init_pid_ns); + +int is_global_init(struct task_struct *tsk) +{ + return tsk == init_pid_ns.child_reaper; +} +EXPORT_SYMBOL(is_global_init); /* * Note: disable interrupts while the pidmap_lock is held as an Index: lx26-22-rc6-mm1a/arch/alpha/mm/fault.c === --- lx26-22-rc6-mm1a.orig/arch/alpha/mm/fault.c 2007-07-16 12:55:15.0 -0700 +++ lx26-22-rc6-mm1a/arch/alpha/mm/fault.c 2007-07-16 13:10:48.0 -0700 @@ -192,7 +192,7 @@ do_page_fault(unsigned long address, uns /* We ran out of memory, or some other thing