diff options
Diffstat (limited to 'kernel/fork.c')
| -rw-r--r-- | kernel/fork.c | 57 | 
1 files changed, 13 insertions, 44 deletions
| diff --git a/kernel/fork.c b/kernel/fork.c index 17bbf093356d..1beb6c303c41 100644 --- a/kernel/fork.c +++ b/kernel/fork.c | |||
| @@ -329,15 +329,17 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm) | |||
| 329 | if (!tmp) | 329 | if (!tmp) | 
| 330 | goto fail_nomem; | 330 | goto fail_nomem; | 
| 331 | *tmp = *mpnt; | 331 | *tmp = *mpnt; | 
| 332 | INIT_LIST_HEAD(&tmp->anon_vma_chain); | ||
| 332 | pol = mpol_dup(vma_policy(mpnt)); | 333 | pol = mpol_dup(vma_policy(mpnt)); | 
| 333 | retval = PTR_ERR(pol); | 334 | retval = PTR_ERR(pol); | 
| 334 | if (IS_ERR(pol)) | 335 | if (IS_ERR(pol)) | 
| 335 | goto fail_nomem_policy; | 336 | goto fail_nomem_policy; | 
| 336 | vma_set_policy(tmp, pol); | 337 | vma_set_policy(tmp, pol); | 
| 338 | if (anon_vma_fork(tmp, mpnt)) | ||
| 339 | goto fail_nomem_anon_vma_fork; | ||
| 337 | tmp->vm_flags &= ~VM_LOCKED; | 340 | tmp->vm_flags &= ~VM_LOCKED; | 
| 338 | tmp->vm_mm = mm; | 341 | tmp->vm_mm = mm; | 
| 339 | tmp->vm_next = NULL; | 342 | tmp->vm_next = NULL; | 
| 340 | anon_vma_link(tmp); | ||
| 341 | file = tmp->vm_file; | 343 | file = tmp->vm_file; | 
| 342 | if (file) { | 344 | if (file) { | 
| 343 | struct inode *inode = file->f_path.dentry->d_inode; | 345 | struct inode *inode = file->f_path.dentry->d_inode; | 
| @@ -392,6 +394,8 @@ out: | |||
| 392 | flush_tlb_mm(oldmm); | 394 | flush_tlb_mm(oldmm); | 
| 393 | up_write(&oldmm->mmap_sem); | 395 | up_write(&oldmm->mmap_sem); | 
| 394 | return retval; | 396 | return retval; | 
| 397 | fail_nomem_anon_vma_fork: | ||
| 398 | mpol_put(pol); | ||
| 395 | fail_nomem_policy: | 399 | fail_nomem_policy: | 
| 396 | kmem_cache_free(vm_area_cachep, tmp); | 400 | kmem_cache_free(vm_area_cachep, tmp); | 
| 397 | fail_nomem: | 401 | fail_nomem: | 
| @@ -455,8 +459,7 @@ static struct mm_struct * mm_init(struct mm_struct * mm, struct task_struct *p) | |||
| 455 | (current->mm->flags & MMF_INIT_MASK) : default_dump_filter; | 459 | (current->mm->flags & MMF_INIT_MASK) : default_dump_filter; | 
| 456 | mm->core_state = NULL; | 460 | mm->core_state = NULL; | 
| 457 | mm->nr_ptes = 0; | 461 | mm->nr_ptes = 0; | 
| 458 | set_mm_counter(mm, file_rss, 0); | 462 | memset(&mm->rss_stat, 0, sizeof(mm->rss_stat)); | 
| 459 | set_mm_counter(mm, anon_rss, 0); | ||
| 460 | spin_lock_init(&mm->page_table_lock); | 463 | spin_lock_init(&mm->page_table_lock); | 
| 461 | mm->free_area_cache = TASK_UNMAPPED_BASE; | 464 | mm->free_area_cache = TASK_UNMAPPED_BASE; | 
| 462 | mm->cached_hole_size = ~0UL; | 465 | mm->cached_hole_size = ~0UL; | 
| @@ -825,23 +828,14 @@ void __cleanup_sighand(struct sighand_struct *sighand) | |||
| 825 | */ | 828 | */ | 
| 826 | static void posix_cpu_timers_init_group(struct signal_struct *sig) | 829 | static void posix_cpu_timers_init_group(struct signal_struct *sig) | 
| 827 | { | 830 | { | 
| 831 | unsigned long cpu_limit; | ||
| 832 | |||
| 828 | /* Thread group counters. */ | 833 | /* Thread group counters. */ | 
| 829 | thread_group_cputime_init(sig); | 834 | thread_group_cputime_init(sig); | 
| 830 | 835 | ||
| 831 | /* Expiration times and increments. */ | 836 | cpu_limit = ACCESS_ONCE(sig->rlim[RLIMIT_CPU].rlim_cur); | 
| 832 | sig->it[CPUCLOCK_PROF].expires = cputime_zero; | 837 | if (cpu_limit != RLIM_INFINITY) { | 
| 833 | sig->it[CPUCLOCK_PROF].incr = cputime_zero; | 838 | sig->cputime_expires.prof_exp = secs_to_cputime(cpu_limit); | 
| 834 | sig->it[CPUCLOCK_VIRT].expires = cputime_zero; | ||
| 835 | sig->it[CPUCLOCK_VIRT].incr = cputime_zero; | ||
| 836 | |||
| 837 | /* Cached expiration times. */ | ||
| 838 | sig->cputime_expires.prof_exp = cputime_zero; | ||
| 839 | sig->cputime_expires.virt_exp = cputime_zero; | ||
| 840 | sig->cputime_expires.sched_exp = 0; | ||
| 841 | |||
| 842 | if (sig->rlim[RLIMIT_CPU].rlim_cur != RLIM_INFINITY) { | ||
| 843 | sig->cputime_expires.prof_exp = | ||
| 844 | secs_to_cputime(sig->rlim[RLIMIT_CPU].rlim_cur); | ||
| 845 | sig->cputimer.running = 1; | 839 | sig->cputimer.running = 1; | 
| 846 | } | 840 | } | 
| 847 | 841 | ||
| @@ -858,7 +852,7 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
| 858 | if (clone_flags & CLONE_THREAD) | 852 | if (clone_flags & CLONE_THREAD) | 
| 859 | return 0; | 853 | return 0; | 
| 860 | 854 | ||
| 861 | sig = kmem_cache_alloc(signal_cachep, GFP_KERNEL); | 855 | sig = kmem_cache_zalloc(signal_cachep, GFP_KERNEL); | 
| 862 | tsk->signal = sig; | 856 | tsk->signal = sig; | 
| 863 | if (!sig) | 857 | if (!sig) | 
| 864 | return -ENOMEM; | 858 | return -ENOMEM; | 
| @@ -866,46 +860,21 @@ static int copy_signal(unsigned long clone_flags, struct task_struct *tsk) | |||
| 866 | atomic_set(&sig->count, 1); | 860 | atomic_set(&sig->count, 1); | 
| 867 | atomic_set(&sig->live, 1); | 861 | atomic_set(&sig->live, 1); | 
| 868 | init_waitqueue_head(&sig->wait_chldexit); | 862 | init_waitqueue_head(&sig->wait_chldexit); | 
| 869 | sig->flags = 0; | ||
| 870 | if (clone_flags & CLONE_NEWPID) | 863 | if (clone_flags & CLONE_NEWPID) | 
| 871 | sig->flags |= SIGNAL_UNKILLABLE; | 864 | sig->flags |= SIGNAL_UNKILLABLE; | 
| 872 | sig->group_exit_code = 0; | ||
| 873 | sig->group_exit_task = NULL; | ||
| 874 | sig->group_stop_count = 0; | ||
| 875 | sig->curr_target = tsk; | 865 | sig->curr_target = tsk; | 
| 876 | init_sigpending(&sig->shared_pending); | 866 | init_sigpending(&sig->shared_pending); | 
| 877 | INIT_LIST_HEAD(&sig->posix_timers); | 867 | INIT_LIST_HEAD(&sig->posix_timers); | 
| 878 | 868 | ||
| 879 | hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 869 | hrtimer_init(&sig->real_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); | 
| 880 | sig->it_real_incr.tv64 = 0; | ||
| 881 | sig->real_timer.function = it_real_fn; | 870 | sig->real_timer.function = it_real_fn; | 
| 882 | 871 | ||
| 883 | sig->leader = 0; /* session leadership doesn't inherit */ | ||
| 884 | sig->tty_old_pgrp = NULL; | ||
| 885 | sig->tty = NULL; | ||
| 886 | |||
| 887 | sig->utime = sig->stime = sig->cutime = sig->cstime = cputime_zero; | ||
| 888 | sig->gtime = cputime_zero; | ||
| 889 | sig->cgtime = cputime_zero; | ||
| 890 | #ifndef CONFIG_VIRT_CPU_ACCOUNTING | ||
| 891 | sig->prev_utime = sig->prev_stime = cputime_zero; | ||
| 892 | #endif | ||
| 893 | sig->nvcsw = sig->nivcsw = sig->cnvcsw = sig->cnivcsw = 0; | ||
| 894 | sig->min_flt = sig->maj_flt = sig->cmin_flt = sig->cmaj_flt = 0; | ||
| 895 | sig->inblock = sig->oublock = sig->cinblock = sig->coublock = 0; | ||
| 896 | sig->maxrss = sig->cmaxrss = 0; | ||
| 897 | task_io_accounting_init(&sig->ioac); | ||
| 898 | sig->sum_sched_runtime = 0; | ||
| 899 | taskstats_tgid_init(sig); | ||
| 900 | |||
| 901 | task_lock(current->group_leader); | 872 | task_lock(current->group_leader); | 
| 902 | memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim); | 873 | memcpy(sig->rlim, current->signal->rlim, sizeof sig->rlim); | 
| 903 | task_unlock(current->group_leader); | 874 | task_unlock(current->group_leader); | 
| 904 | 875 | ||
| 905 | posix_cpu_timers_init_group(sig); | 876 | posix_cpu_timers_init_group(sig); | 
| 906 | 877 | ||
| 907 | acct_init_pacct(&sig->pacct); | ||
| 908 | |||
| 909 | tty_audit_fork(sig); | 878 | tty_audit_fork(sig); | 
| 910 | 879 | ||
| 911 | sig->oom_adj = current->signal->oom_adj; | 880 | sig->oom_adj = current->signal->oom_adj; | 
| @@ -1034,7 +1003,7 @@ static struct task_struct *copy_process(unsigned long clone_flags, | |||
| 1034 | #endif | 1003 | #endif | 
| 1035 | retval = -EAGAIN; | 1004 | retval = -EAGAIN; | 
| 1036 | if (atomic_read(&p->real_cred->user->processes) >= | 1005 | if (atomic_read(&p->real_cred->user->processes) >= | 
| 1037 | p->signal->rlim[RLIMIT_NPROC].rlim_cur) { | 1006 | task_rlimit(p, RLIMIT_NPROC)) { | 
| 1038 | if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) && | 1007 | if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) && | 
| 1039 | p->real_cred->user != INIT_USER) | 1008 | p->real_cred->user != INIT_USER) | 
| 1040 | goto bad_fork_free; | 1009 | goto bad_fork_free; | 
