hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/kernel/fork.c
....@@ -448,6 +448,9 @@
448448
449449 void free_task(struct task_struct *tsk)
450450 {
451
+#ifdef CONFIG_SECCOMP
452
+ WARN_ON_ONCE(tsk->seccomp.filter);
453
+#endif
451454 cpufreq_task_times_exit(tsk);
452455 scs_release(tsk);
453456
....@@ -776,6 +779,14 @@
776779 free_task(tsk);
777780 }
778781 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);
779790
780791 void __init __weak arch_task_cache_init(void) { }
781792
....@@ -2307,12 +2318,6 @@
23072318
23082319 spin_lock(&current->sighand->siglock);
23092320
2310
- /*
2311
- * Copy seccomp details explicitly here, in case they were changed
2312
- * before holding sighand lock.
2313
- */
2314
- copy_seccomp(p);
2315
-
23162321 rseq_fork(p, clone_flags);
23172322
23182323 /* Don't start children in a dying pid namespace */
....@@ -2326,6 +2331,14 @@
23262331 retval = -EINTR;
23272332 goto bad_fork_cancel_cgroup;
23282333 }
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);
23292342
23302343 init_task_pid_links(p);
23312344 if (likely(p->pid)) {
....@@ -2476,11 +2489,6 @@
24762489 }
24772490
24782491 return task;
2479
-}
2480
-
2481
-struct mm_struct *copy_init_mm(void)
2482
-{
2483
- return dup_mm(NULL, &init_mm);
24842492 }
24852493
24862494 /*
....@@ -2787,7 +2795,7 @@
27872795 * - make the CLONE_DETACHED bit reuseable for clone3
27882796 * - make the CSIGNAL bits reuseable for clone3
27892797 */
2790
- if (kargs->flags & (CLONE_DETACHED | CSIGNAL))
2798
+ if (kargs->flags & (CLONE_DETACHED | (CSIGNAL & (~CLONE_NEWTIME))))
27912799 return false;
27922800
27932801 if ((kargs->flags & (CLONE_SIGHAND | CLONE_CLEAR_SIGHAND)) ==
....@@ -2879,10 +2887,27 @@
28792887 init_waitqueue_head(&sighand->signalfd_wqh);
28802888 }
28812889
2882
-void __init proc_caches_init(void)
2890
+void __init mm_cache_init(void)
28832891 {
28842892 unsigned int mm_size;
28852893
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
+{
28862911 sighand_cachep = kmem_cache_create("sighand_cache",
28872912 sizeof(struct sighand_struct), 0,
28882913 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_TYPESAFE_BY_RCU|
....@@ -2900,19 +2925,6 @@
29002925 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_ACCOUNT,
29012926 NULL);
29022927
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);
29162928 vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC|SLAB_ACCOUNT);
29172929 mmap_init();
29182930 nsproxy_cache_init();