diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 15:22:13 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-12 15:22:13 -0500 |
commit | 9977d9b379cb77e0f67bd6f4563618106e58e11d (patch) | |
tree | 0191accfddf578edb52c69c933d64521e3dce297 /kernel/exit.c | |
parent | cf4af01221579a4e895f43dbfc47598fbfc5a731 (diff) | |
parent | 541880d9a2c7871f6370071d55aa6662d329c51e (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
Pull big execve/kernel_thread/fork unification series from Al Viro:
"All architectures are converted to new model. Quite a bit of that
stuff is actually shared with architecture trees; in such cases it's
literally shared branch pulled by both, not a cherry-pick.
A lot of ugliness and black magic is gone (-3KLoC total in this one):
- kernel_thread()/kernel_execve()/sys_execve() redesign.
We don't do syscalls from kernel anymore for either kernel_thread()
or kernel_execve():
kernel_thread() is essentially clone(2) with callback run before we
return to userland, the callbacks either never return or do
successful do_execve() before returning.
kernel_execve() is a wrapper for do_execve() - it doesn't need to
do transition to user mode anymore.
As a result kernel_thread() and kernel_execve() are
arch-independent now - they live in kernel/fork.c and fs/exec.c
resp. sys_execve() is also in fs/exec.c and it's completely
architecture-independent.
- daemonize() is gone, along with its parts in fs/*.c
- struct pt_regs * is no longer passed to do_fork/copy_process/
copy_thread/do_execve/search_binary_handler/->load_binary/do_coredump.
- sys_fork()/sys_vfork()/sys_clone() unified; some architectures
still need wrappers (ones with callee-saved registers not saved in
pt_regs on syscall entry), but the main part of those suckers is in
kernel/fork.c now."
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal: (113 commits)
do_coredump(): get rid of pt_regs argument
print_fatal_signal(): get rid of pt_regs argument
ptrace_signal(): get rid of unused arguments
get rid of ptrace_signal_deliver() arguments
new helper: signal_pt_regs()
unify default ptrace_signal_deliver
flagday: kill pt_regs argument of do_fork()
death to idle_regs()
don't pass regs to copy_process()
flagday: don't pass regs to copy_thread()
bfin: switch to generic vfork, get rid of pointless wrappers
xtensa: switch to generic clone()
openrisc: switch to use of generic fork and clone
unicore32: switch to generic clone(2)
score: switch to generic fork/vfork/clone
c6x: sanitize copy_thread(), get rid of clone(2) wrapper, switch to generic clone()
take sys_fork/sys_vfork/sys_clone prototypes to linux/syscalls.h
mn10300: switch to generic fork/vfork/clone
h8300: switch to generic fork/vfork/clone
tile: switch to generic clone()
...
Conflicts:
arch/microblaze/include/asm/Kbuild
Diffstat (limited to 'kernel/exit.c')
-rw-r--r-- | kernel/exit.c | 92 |
1 files changed, 0 insertions, 92 deletions
diff --git a/kernel/exit.c b/kernel/exit.c index 618f7ee56003..50d2e93c36ea 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -322,43 +322,6 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent) | |||
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | /** | ||
326 | * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd | ||
327 | * | ||
328 | * If a kernel thread is launched as a result of a system call, or if | ||
329 | * it ever exits, it should generally reparent itself to kthreadd so it | ||
330 | * isn't in the way of other processes and is correctly cleaned up on exit. | ||
331 | * | ||
332 | * The various task state such as scheduling policy and priority may have | ||
333 | * been inherited from a user process, so we reset them to sane values here. | ||
334 | * | ||
335 | * NOTE that reparent_to_kthreadd() gives the caller full capabilities. | ||
336 | */ | ||
337 | static void reparent_to_kthreadd(void) | ||
338 | { | ||
339 | write_lock_irq(&tasklist_lock); | ||
340 | |||
341 | ptrace_unlink(current); | ||
342 | /* Reparent to init */ | ||
343 | current->real_parent = current->parent = kthreadd_task; | ||
344 | list_move_tail(¤t->sibling, ¤t->real_parent->children); | ||
345 | |||
346 | /* Set the exit signal to SIGCHLD so we signal init on exit */ | ||
347 | current->exit_signal = SIGCHLD; | ||
348 | |||
349 | if (task_nice(current) < 0) | ||
350 | set_user_nice(current, 0); | ||
351 | /* cpus_allowed? */ | ||
352 | /* rt_priority? */ | ||
353 | /* signals? */ | ||
354 | memcpy(current->signal->rlim, init_task.signal->rlim, | ||
355 | sizeof(current->signal->rlim)); | ||
356 | |||
357 | atomic_inc(&init_cred.usage); | ||
358 | commit_creds(&init_cred); | ||
359 | write_unlock_irq(&tasklist_lock); | ||
360 | } | ||
361 | |||
362 | void __set_special_pids(struct pid *pid) | 325 | void __set_special_pids(struct pid *pid) |
363 | { | 326 | { |
364 | struct task_struct *curr = current->group_leader; | 327 | struct task_struct *curr = current->group_leader; |
@@ -370,13 +333,6 @@ void __set_special_pids(struct pid *pid) | |||
370 | change_pid(curr, PIDTYPE_PGID, pid); | 333 | change_pid(curr, PIDTYPE_PGID, pid); |
371 | } | 334 | } |
372 | 335 | ||
373 | static void set_special_pids(struct pid *pid) | ||
374 | { | ||
375 | write_lock_irq(&tasklist_lock); | ||
376 | __set_special_pids(pid); | ||
377 | write_unlock_irq(&tasklist_lock); | ||
378 | } | ||
379 | |||
380 | /* | 336 | /* |
381 | * Let kernel threads use this to say that they allow a certain signal. | 337 | * Let kernel threads use this to say that they allow a certain signal. |
382 | * Must not be used if kthread was cloned with CLONE_SIGHAND. | 338 | * Must not be used if kthread was cloned with CLONE_SIGHAND. |
@@ -416,54 +372,6 @@ int disallow_signal(int sig) | |||
416 | 372 | ||
417 | EXPORT_SYMBOL(disallow_signal); | 373 | EXPORT_SYMBOL(disallow_signal); |
418 | 374 | ||
419 | /* | ||
420 | * Put all the gunge required to become a kernel thread without | ||
421 | * attached user resources in one place where it belongs. | ||
422 | */ | ||
423 | |||
424 | void daemonize(const char *name, ...) | ||
425 | { | ||
426 | va_list args; | ||
427 | sigset_t blocked; | ||
428 | |||
429 | va_start(args, name); | ||
430 | vsnprintf(current->comm, sizeof(current->comm), name, args); | ||
431 | va_end(args); | ||
432 | |||
433 | /* | ||
434 | * If we were started as result of loading a module, close all of the | ||
435 | * user space pages. We don't need them, and if we didn't close them | ||
436 | * they would be locked into memory. | ||
437 | */ | ||
438 | exit_mm(current); | ||
439 | /* | ||
440 | * We don't want to get frozen, in case system-wide hibernation | ||
441 | * or suspend transition begins right now. | ||
442 | */ | ||
443 | current->flags |= (PF_NOFREEZE | PF_KTHREAD); | ||
444 | |||
445 | if (current->nsproxy != &init_nsproxy) { | ||
446 | get_nsproxy(&init_nsproxy); | ||
447 | switch_task_namespaces(current, &init_nsproxy); | ||
448 | } | ||
449 | set_special_pids(&init_struct_pid); | ||
450 | proc_clear_tty(current); | ||
451 | |||
452 | /* Block and flush all signals */ | ||
453 | sigfillset(&blocked); | ||
454 | sigprocmask(SIG_BLOCK, &blocked, NULL); | ||
455 | flush_signals(current); | ||
456 | |||
457 | /* Become as one with the init task */ | ||
458 | |||
459 | daemonize_fs_struct(); | ||
460 | daemonize_descriptors(); | ||
461 | |||
462 | reparent_to_kthreadd(); | ||
463 | } | ||
464 | |||
465 | EXPORT_SYMBOL(daemonize); | ||
466 | |||
467 | #ifdef CONFIG_MM_OWNER | 375 | #ifdef CONFIG_MM_OWNER |
468 | /* | 376 | /* |
469 | * A task is exiting. If it owned this mm, find a new owner for the mm. | 377 | * A task is exiting. If it owned this mm, find a new owner for the mm. |