mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	sched: Fix fork() error path to not crash
In dup_task_struct(), if arch_dup_task_struct() fails, the clean up code fails to clean up correctly. That's because the clean up code depends on unininitalized ti->task pointer. We fix this by making sure that the task and thread_info know about each other before we attempt to take the error path. Signed-off-by: Salman Qazi <sqazi@google.com> Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/20120626011815.11323.5533.stgit@dungbeetle.mtv.corp.google.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
		
							parent
							
								
									9e85a6f9dc
								
							
						
					
					
						commit
						164c33c6ad
					
				
					 1 changed files with 8 additions and 3 deletions
				
			
		| 
						 | 
					@ -304,12 +304,17 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = arch_dup_task_struct(tsk, orig);
 | 
						err = arch_dup_task_struct(tsk, orig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * We defer looking at err, because we will need this setup
 | 
				
			||||||
 | 
						 * for the clean up path to work correctly.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						tsk->stack = ti;
 | 
				
			||||||
 | 
						setup_thread_stack(tsk, orig);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	tsk->stack = ti;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	setup_thread_stack(tsk, orig);
 | 
					 | 
				
			||||||
	clear_user_return_notifier(tsk);
 | 
						clear_user_return_notifier(tsk);
 | 
				
			||||||
	clear_tsk_need_resched(tsk);
 | 
						clear_tsk_need_resched(tsk);
 | 
				
			||||||
	stackend = end_of_stack(tsk);
 | 
						stackend = end_of_stack(tsk);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue