Skip to content

Commit f400e19

Browse files
Sukadev BhattiproluLinus Torvalds
authored andcommitted
[PATCH] pidspace: is_init()
This is an updated version of Eric Biederman's is_init() patch. (http://lkml.org/lkml/2006/2/6/280). It applies cleanly to 2.6.18-rc3 and replaces a few more instances of ->pid == 1 with is_init(). Further, is_init() checks pid and thus removes dependency on Eric's other patches for now. Eric's original description: There are a lot of places in the kernel where we test for init because we give it special properties. Most significantly init must not die. This results in code all over the kernel test ->pid == 1. Introduce is_init to capture this case. With multiple pid spaces for all of the cases affected we are looking for only the first process on the system, not some other process that has pid == 1. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Sukadev Bhattiprolu <sukadev@us.ibm.com> Cc: Dave Hansen <haveblue@us.ibm.com> Cc: Serge Hallyn <serue@us.ibm.com> Cc: Cedric Le Goater <clg@fr.ibm.com> Cc: <lxc-devel@lists.sourceforge.net> Acked-by: Paul Mackerras <paulus@samba.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 959ed34 commit f400e19

29 files changed

Lines changed: 41 additions & 30 deletions

File tree

‎arch/alpha/mm/fault.c‎

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

‎arch/arm/mm/fault.c‎

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

201-
if (tsk->pid != 1)
201+
if (!is_init(tsk))
202202
goto out;
203203

204204
/*

‎arch/arm26/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
185185
}
186186

187187
fault = -3; /* out of memory */
188-
if (tsk->pid != 1)
188+
if (!is_init(tsk))
189189
goto out;
190190

191191
/*

‎arch/i386/lib/usercopy.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
739739
retval = get_user_pages(current, current->mm,
740740
(unsigned long )to, 1, 1, 0, &pg, NULL);
741741

742-
if (retval == -ENOMEM && current->pid == 1) {
742+
if (retval == -ENOMEM && is_init(current)) {
743743
up_read(&current->mm->mmap_sem);
744744
blk_congestion_wait(WRITE, HZ/50);
745745
goto survive;

‎arch/i386/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ fastcall void __kprobes do_page_fault(struct pt_regs *regs,
589589
*/
590590
out_of_memory:
591591
up_read(&mm->mmap_sem);
592-
if (tsk->pid == 1) {
592+
if (is_init(tsk)) {
593593
yield();
594594
down_read(&mm->mmap_sem);
595595
goto survive;

‎arch/ia64/mm/fault.c‎

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

281281
out_of_memory:
282282
up_read(&mm->mmap_sem);
283-
if (current->pid == 1) {
283+
if (is_init(current)) {
284284
yield();
285285
down_read(&mm->mmap_sem);
286286
goto survive;

‎arch/m32r/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long error_code,
299299
*/
300300
out_of_memory:
301301
up_read(&mm->mmap_sem);
302-
if (tsk->pid == 1) {
302+
if (is_init(tsk)) {
303303
yield();
304304
down_read(&mm->mmap_sem);
305305
goto survive;

‎arch/m68k/mm/fault.c‎

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

‎arch/mips/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,
171171
*/
172172
out_of_memory:
173173
up_read(&mm->mmap_sem);
174-
if (tsk->pid == 1) {
174+
if (is_init(tsk)) {
175175
yield();
176176
down_read(&mm->mmap_sem);
177177
goto survive;

‎arch/powerpc/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
386386
*/
387387
out_of_memory:
388388
up_read(&mm->mmap_sem);
389-
if (current->pid == 1) {
389+
if (is_init(current)) {
390390
yield();
391391
down_read(&mm->mmap_sem);
392392
goto survive;

0 commit comments

Comments
 (0)