fork.c (015f1e4297ad32f83251f3f4cee2389ce5516e9e) | fork.c (c415c3b47ea2754659d915cca387a20999044163) |
---|---|
1/* 2 * linux/kernel/fork.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * 'fork.c' contains the help-routines for the 'fork' system call --- 52 unchanged lines hidden (view full) --- 61#include <linux/blkdev.h> 62#include <linux/fs_struct.h> 63#include <linux/magic.h> 64#include <linux/perf_event.h> 65#include <linux/posix-timers.h> 66#include <linux/user-return-notifier.h> 67#include <linux/oom.h> 68#include <linux/khugepaged.h> | 1/* 2 * linux/kernel/fork.c 3 * 4 * Copyright (C) 1991, 1992 Linus Torvalds 5 */ 6 7/* 8 * 'fork.c' contains the help-routines for the 'fork' system call --- 52 unchanged lines hidden (view full) --- 61#include <linux/blkdev.h> 62#include <linux/fs_struct.h> 63#include <linux/magic.h> 64#include <linux/perf_event.h> 65#include <linux/posix-timers.h> 66#include <linux/user-return-notifier.h> 67#include <linux/oom.h> 68#include <linux/khugepaged.h> |
69#include <linux/signalfd.h> |
|
69 70#include <asm/pgtable.h> 71#include <asm/pgalloc.h> 72#include <asm/uaccess.h> 73#include <asm/mmu_context.h> 74#include <asm/cacheflush.h> 75#include <asm/tlbflush.h> 76 --- 585 unchanged lines hidden (view full) --- 662 mmput(mm); 663 mm = ERR_PTR(-EACCES); 664 } 665 mutex_unlock(&task->signal->cred_guard_mutex); 666 667 return mm; 668} 669 | 70 71#include <asm/pgtable.h> 72#include <asm/pgalloc.h> 73#include <asm/uaccess.h> 74#include <asm/mmu_context.h> 75#include <asm/cacheflush.h> 76#include <asm/tlbflush.h> 77 --- 585 unchanged lines hidden (view full) --- 663 mmput(mm); 664 mm = ERR_PTR(-EACCES); 665 } 666 mutex_unlock(&task->signal->cred_guard_mutex); 667 668 return mm; 669} 670 |
671void complete_vfork_done(struct task_struct *tsk) 672{ 673 struct completion *vfork_done = tsk->vfork_done; 674 675 tsk->vfork_done = NULL; 676 complete(vfork_done); 677} 678 |
|
670/* Please note the differences between mmput and mm_release. 671 * mmput is called whenever we stop holding onto a mm_struct, 672 * error success whatever. 673 * 674 * mm_release is called after a mm_struct has been removed 675 * from the current process. 676 * 677 * This difference is important for error handling, when we 678 * only half set up a mm_struct for a new process and need to restore 679 * the old one. Because we mmput the new mm_struct before 680 * restoring the old one. . . 681 * Eric Biederman 10 January 1998 682 */ 683void mm_release(struct task_struct *tsk, struct mm_struct *mm) 684{ | 679/* Please note the differences between mmput and mm_release. 680 * mmput is called whenever we stop holding onto a mm_struct, 681 * error success whatever. 682 * 683 * mm_release is called after a mm_struct has been removed 684 * from the current process. 685 * 686 * This difference is important for error handling, when we 687 * only half set up a mm_struct for a new process and need to restore 688 * the old one. Because we mmput the new mm_struct before 689 * restoring the old one. . . 690 * Eric Biederman 10 January 1998 691 */ 692void mm_release(struct task_struct *tsk, struct mm_struct *mm) 693{ |
685 struct completion *vfork_done = tsk->vfork_done; 686 | |
687 /* Get rid of any futexes when releasing the mm */ 688#ifdef CONFIG_FUTEX 689 if (unlikely(tsk->robust_list)) { 690 exit_robust_list(tsk); 691 tsk->robust_list = NULL; 692 } 693#ifdef CONFIG_COMPAT 694 if (unlikely(tsk->compat_robust_list)) { 695 compat_exit_robust_list(tsk); 696 tsk->compat_robust_list = NULL; 697 } 698#endif 699 if (unlikely(!list_empty(&tsk->pi_state_list))) 700 exit_pi_state_list(tsk); 701#endif 702 703 /* Get rid of any cached register state */ 704 deactivate_mm(tsk, mm); 705 | 694 /* Get rid of any futexes when releasing the mm */ 695#ifdef CONFIG_FUTEX 696 if (unlikely(tsk->robust_list)) { 697 exit_robust_list(tsk); 698 tsk->robust_list = NULL; 699 } 700#ifdef CONFIG_COMPAT 701 if (unlikely(tsk->compat_robust_list)) { 702 compat_exit_robust_list(tsk); 703 tsk->compat_robust_list = NULL; 704 } 705#endif 706 if (unlikely(!list_empty(&tsk->pi_state_list))) 707 exit_pi_state_list(tsk); 708#endif 709 710 /* Get rid of any cached register state */ 711 deactivate_mm(tsk, mm); 712 |
706 /* notify parent sleeping on vfork() */ 707 if (vfork_done) { 708 tsk->vfork_done = NULL; 709 complete(vfork_done); 710 } | 713 if (tsk->vfork_done) 714 complete_vfork_done(tsk); |
711 712 /* 713 * If we're exiting normally, clear a user-space tid field if 714 * requested. We leave this alone when dying by signal, to leave 715 * the value intact in a core dump, and to save the unnecessary 716 * trouble otherwise. Userland only wants this done for a sys_exit. 717 */ 718 if (tsk->clear_child_tid) { --- 211 unchanged lines hidden (view full) --- 930 return -ENOMEM; 931 atomic_set(&sig->count, 1); 932 memcpy(sig->action, current->sighand->action, sizeof(sig->action)); 933 return 0; 934} 935 936void __cleanup_sighand(struct sighand_struct *sighand) 937{ | 715 716 /* 717 * If we're exiting normally, clear a user-space tid field if 718 * requested. We leave this alone when dying by signal, to leave 719 * the value intact in a core dump, and to save the unnecessary 720 * trouble otherwise. Userland only wants this done for a sys_exit. 721 */ 722 if (tsk->clear_child_tid) { --- 211 unchanged lines hidden (view full) --- 934 return -ENOMEM; 935 atomic_set(&sig->count, 1); 936 memcpy(sig->action, current->sighand->action, sizeof(sig->action)); 937 return 0; 938} 939 940void __cleanup_sighand(struct sighand_struct *sighand) 941{ |
938 if (atomic_dec_and_test(&sighand->count)) | 942 if (atomic_dec_and_test(&sighand->count)) { 943 signalfd_cleanup(sighand); |
939 kmem_cache_free(sighand_cachep, sighand); | 944 kmem_cache_free(sighand_cachep, sighand); |
945 } |
|
940} 941 942 943/* 944 * Initialize POSIX timer handling for a thread group. 945 */ 946static void posix_cpu_timers_init_group(struct signal_struct *sig) 947{ --- 847 unchanged lines hidden --- | 946} 947 948 949/* 950 * Initialize POSIX timer handling for a thread group. 951 */ 952static void posix_cpu_timers_init_group(struct signal_struct *sig) 953{ --- 847 unchanged lines hidden --- |