Skip to content

Commit b460cbc

Browse files
Serge E. HallynLinus Torvalds
authored andcommitted
pid namespaces: define is_global_init() and is_container_init()
is_init() is an ambiguous name for the pid==1 check. Split it into is_global_init() and is_container_init(). A cgroup 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 cgroup if the cgroup's init has a bug rather than force a kernel panic. [akpm@linux-foundation.org: fix comment] [sukadev@us.ibm.com: Use is_global_init() in arch/m32r/mm/fault.c] [bunk@stusta.de: kernel/pid.c: remove unused exports] [sukadev@us.ibm.com: Fix capability.c to work with threaded init] Signed-off-by: Serge E. Hallyn <serue@us.ibm.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> Acked-by: Pavel Emelianov <xemul@openvz.org> Cc: Eric W. Biederman <ebiederm@xmission.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Herbert Poetzel <herbert@13thfloor.at> Cc: Kirill Korotaev <dev@sw.ru> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3743ca0 commit b460cbc

32 files changed

Lines changed: 52 additions & 37 deletions

File tree

‎arch/alpha/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
188188
/* We ran out of memory, or some other thing happened to us that
189189
made us unable to handle the page fault gracefully. */
190190
out_of_memory:
191-
if (is_init(current)) {
191+
if (is_global_init(current)) {
192192
yield();
193193
down_read(&mm->mmap_sem);
194194
goto survive;

‎arch/arm/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
197197
return fault;
198198

199199
out_of_memory:
200-
if (!is_init(tsk))
200+
if (!is_global_init(tsk))
201201
goto out;
202202

203203
/*

‎arch/avr32/kernel/traps.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void _exception(long signr, struct pt_regs *regs, int code,
8989
* generate the same exception over and over again and we get
9090
* nowhere. Better to kill it and let the kernel panic.
9191
*/
92-
if (is_init(current)) {
92+
if (is_global_init(current)) {
9393
__sighandler_t handler;
9494

9595
spin_lock_irq(&current->sighand->siglock);

‎arch/avr32/mm/fault.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
160160
if (exception_trace && printk_ratelimit())
161161
printk("%s%s[%d]: segfault at %08lx pc %08lx "
162162
"sp %08lx ecr %lu\n",
163-
is_init(tsk) ? KERN_EMERG : KERN_INFO,
163+
is_global_init(tsk) ? KERN_EMERG : KERN_INFO,
164164
tsk->comm, tsk->pid, address, regs->pc,
165165
regs->sp, ecr);
166166
_exception(SIGSEGV, regs, code, address);
@@ -209,7 +209,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
209209
*/
210210
out_of_memory:
211211
up_read(&mm->mmap_sem);
212-
if (is_init(current)) {
212+
if (is_global_init(current)) {
213213
yield();
214214
down_read(&mm->mmap_sem);
215215
goto survive;
@@ -231,7 +231,7 @@ asmlinkage void do_page_fault(unsigned long ecr, struct pt_regs *regs)
231231
if (exception_trace)
232232
printk("%s%s[%d]: bus error at %08lx pc %08lx "
233233
"sp %08lx ecr %lu\n",
234-
is_init(tsk) ? KERN_EMERG : KERN_INFO,
234+
is_global_init(tsk) ? KERN_EMERG : KERN_INFO,
235235
tsk->comm, tsk->pid, address, regs->pc,
236236
regs->sp, ecr);
237237

‎arch/ia64/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re
274274

275275
out_of_memory:
276276
up_read(&mm->mmap_sem);
277-
if (is_init(current)) {
277+
if (is_global_init(current)) {
278278
yield();
279279
down_read(&mm->mmap_sem);
280280
goto survive;

‎arch/m32r/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code,
271271
*/
272272
out_of_memory:
273273
up_read(&mm->mmap_sem);
274-
if (is_init(tsk)) {
274+
if (is_global_init(tsk)) {
275275
yield();
276276
down_read(&mm->mmap_sem);
277277
goto survive;

‎arch/m68k/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,
180180
*/
181181
out_of_memory:
182182
up_read(&mm->mmap_sem);
183-
if (is_init(current)) {
183+
if (is_global_init(current)) {
184184
yield();
185185
down_read(&mm->mmap_sem);
186186
goto survive;

‎arch/mips/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
173173
*/
174174
out_of_memory:
175175
up_read(&mm->mmap_sem);
176-
if (is_init(tsk)) {
176+
if (is_global_init(tsk)) {
177177
yield();
178178
down_read(&mm->mmap_sem);
179179
goto survive;

‎arch/powerpc/kernel/traps.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
201201
* generate the same exception over and over again and we get
202202
* nowhere. Better to kill it and let the kernel panic.
203203
*/
204-
if (is_init(current)) {
204+
if (is_global_init(current)) {
205205
__sighandler_t handler;
206206

207207
spin_lock_irq(&current->sighand->siglock);

‎arch/powerpc/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
375375
*/
376376
out_of_memory:
377377
up_read(&mm->mmap_sem);
378-
if (is_init(current)) {
378+
if (is_global_init(current)) {
379379
yield();
380380
down_read(&mm->mmap_sem);
381381
goto survive;

0 commit comments

Comments
 (0)