| .. | .. |
|---|
| 448 | 448 | |
|---|
| 449 | 449 | void free_task(struct task_struct *tsk) |
|---|
| 450 | 450 | { |
|---|
| 451 | +#ifdef CONFIG_SECCOMP |
|---|
| 452 | + WARN_ON_ONCE(tsk->seccomp.filter); |
|---|
| 453 | +#endif |
|---|
| 451 | 454 | cpufreq_task_times_exit(tsk); |
|---|
| 452 | 455 | scs_release(tsk); |
|---|
| 453 | 456 | |
|---|
| .. | .. |
|---|
| 776 | 779 | free_task(tsk); |
|---|
| 777 | 780 | } |
|---|
| 778 | 781 | EXPORT_SYMBOL_GPL(__put_task_struct); |
|---|
| 782 | + |
|---|
| 783 | +void __put_task_struct_rcu_cb(struct rcu_head *rhp) |
|---|
| 784 | +{ |
|---|
| 785 | + struct task_struct *task = container_of(rhp, struct task_struct, rcu); |
|---|
| 786 | + |
|---|
| 787 | + __put_task_struct(task); |
|---|
| 788 | +} |
|---|
| 789 | +EXPORT_SYMBOL_GPL(__put_task_struct_rcu_cb); |
|---|
| 779 | 790 | |
|---|
| 780 | 791 | void __init __weak arch_task_cache_init(void) { } |
|---|
| 781 | 792 | |
|---|
| .. | .. |
|---|
| 2307 | 2318 | |
|---|
| 2308 | 2319 | spin_lock(¤t->sighand->siglock); |
|---|
| 2309 | 2320 | |
|---|
| 2310 | | - /* |
|---|
| 2311 | | - * Copy seccomp details explicitly here, in case they were changed |
|---|
| 2312 | | - * before holding sighand lock. |
|---|
| 2313 | | - */ |
|---|
| 2314 | | - copy_seccomp(p); |
|---|
| 2315 | | - |
|---|
| 2316 | 2321 | rseq_fork(p, clone_flags); |
|---|
| 2317 | 2322 | |
|---|
| 2318 | 2323 | /* Don't start children in a dying pid namespace */ |
|---|
| .. | .. |
|---|
| 2326 | 2331 | retval = -EINTR; |
|---|
| 2327 | 2332 | goto bad_fork_cancel_cgroup; |
|---|
| 2328 | 2333 | } |
|---|
| 2334 | + |
|---|
| 2335 | + /* No more failure paths after this point. */ |
|---|
| 2336 | + |
|---|
| 2337 | + /* |
|---|
| 2338 | + * Copy seccomp details explicitly here, in case they were changed |
|---|
| 2339 | + * before holding sighand lock. |
|---|
| 2340 | + */ |
|---|
| 2341 | + copy_seccomp(p); |
|---|
| 2329 | 2342 | |
|---|
| 2330 | 2343 | init_task_pid_links(p); |
|---|
| 2331 | 2344 | if (likely(p->pid)) { |
|---|
| .. | .. |
|---|
| 2476 | 2489 | } |
|---|
| 2477 | 2490 | |
|---|
| 2478 | 2491 | return task; |
|---|
| 2479 | | -} |
|---|
| 2480 | | - |
|---|
| 2481 | | -struct mm_struct *copy_init_mm(void) |
|---|
| 2482 | | -{ |
|---|
| 2483 | | - return dup_mm(NULL, &init_mm); |
|---|
| 2484 | 2492 | } |
|---|
| 2485 | 2493 | |
|---|
| 2486 | 2494 | /* |
|---|
| .. | .. |
|---|
| 2787 | 2795 | * - make the CLONE_DETACHED bit reuseable for clone3 |
|---|
| 2788 | 2796 | * - make the CSIGNAL bits reuseable for clone3 |
|---|
| 2789 | 2797 | */ |
|---|
| 2790 | | - if (kargs->flags & (CLONE_DETACHED | CSIGNAL)) |
|---|
| 2798 | + if (kargs->flags & (CLONE_DETACHED | (CSIGNAL & (~CLONE_NEWTIME)))) |
|---|
| 2791 | 2799 | return false; |
|---|
| 2792 | 2800 | |
|---|
| 2793 | 2801 | if ((kargs->flags & (CLONE_SIGHAND | CLONE_CLEAR_SIGHAND)) == |
|---|
| .. | .. |
|---|
| 2879 | 2887 | init_waitqueue_head(&sighand->signalfd_wqh); |
|---|
| 2880 | 2888 | } |
|---|
| 2881 | 2889 | |
|---|
| 2882 | | -void __init proc_caches_init(void) |
|---|
| 2890 | +void __init mm_cache_init(void) |
|---|
| 2883 | 2891 | { |
|---|
| 2884 | 2892 | unsigned int mm_size; |
|---|
| 2885 | 2893 | |
|---|
| 2894 | + /* |
|---|
| 2895 | + * The mm_cpumask is located at the end of mm_struct, and is |
|---|
| 2896 | + * dynamically sized based on the maximum CPU number this system |
|---|
| 2897 | + * can have, taking hotplug into account (nr_cpu_ids). |
|---|
| 2898 | + */ |
|---|
| 2899 | + mm_size = sizeof(struct mm_struct) + cpumask_size(); |
|---|
| 2900 | + |
|---|
| 2901 | + mm_cachep = kmem_cache_create_usercopy("mm_struct", |
|---|
| 2902 | + mm_size, ARCH_MIN_MMSTRUCT_ALIGN, |
|---|
| 2903 | + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, |
|---|
| 2904 | + offsetof(struct mm_struct, saved_auxv), |
|---|
| 2905 | + sizeof_field(struct mm_struct, saved_auxv), |
|---|
| 2906 | + NULL); |
|---|
| 2907 | +} |
|---|
| 2908 | + |
|---|
| 2909 | +void __init proc_caches_init(void) |
|---|
| 2910 | +{ |
|---|
| 2886 | 2911 | sighand_cachep = kmem_cache_create("sighand_cache", |
|---|
| 2887 | 2912 | sizeof(struct sighand_struct), 0, |
|---|
| 2888 | 2913 | SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TYPESAFE_BY_RCU| |
|---|
| .. | .. |
|---|
| 2900 | 2925 | SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, |
|---|
| 2901 | 2926 | NULL); |
|---|
| 2902 | 2927 | |
|---|
| 2903 | | - /* |
|---|
| 2904 | | - * The mm_cpumask is located at the end of mm_struct, and is |
|---|
| 2905 | | - * dynamically sized based on the maximum CPU number this system |
|---|
| 2906 | | - * can have, taking hotplug into account (nr_cpu_ids). |
|---|
| 2907 | | - */ |
|---|
| 2908 | | - mm_size = sizeof(struct mm_struct) + cpumask_size(); |
|---|
| 2909 | | - |
|---|
| 2910 | | - mm_cachep = kmem_cache_create_usercopy("mm_struct", |
|---|
| 2911 | | - mm_size, ARCH_MIN_MMSTRUCT_ALIGN, |
|---|
| 2912 | | - SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT, |
|---|
| 2913 | | - offsetof(struct mm_struct, saved_auxv), |
|---|
| 2914 | | - sizeof_field(struct mm_struct, saved_auxv), |
|---|
| 2915 | | - NULL); |
|---|
| 2916 | 2928 | vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC|SLAB_ACCOUNT); |
|---|
| 2917 | 2929 | mmap_init(); |
|---|
| 2918 | 2930 | nsproxy_cache_init(); |
|---|