bpf: restore the ebpf program ID for BPF_AUDIT_UNLOAD and PERF_BPF_EVENT_PROG_UNLOAD
[platform/kernel/linux-starfive.git] / kernel / fork.c
index 08969f5..844dfdc 100644 (file)
@@ -535,6 +535,9 @@ void put_task_stack(struct task_struct *tsk)
 
 void free_task(struct task_struct *tsk)
 {
+#ifdef CONFIG_SECCOMP
+       WARN_ON_ONCE(tsk->seccomp.filter);
+#endif
        release_user_cpus_ptr(tsk);
        scs_release(tsk);
 
@@ -2406,12 +2409,6 @@ static __latent_entropy struct task_struct *copy_process(
 
        spin_lock(&current->sighand->siglock);
 
-       /*
-        * Copy seccomp details explicitly here, in case they were changed
-        * before holding sighand lock.
-        */
-       copy_seccomp(p);
-
        rv_task_fork(p);
 
        rseq_fork(p, clone_flags);
@@ -2428,6 +2425,14 @@ static __latent_entropy struct task_struct *copy_process(
                goto bad_fork_cancel_cgroup;
        }
 
+       /* No more failure paths after this point. */
+
+       /*
+        * Copy seccomp details explicitly here, in case they were changed
+        * before holding sighand lock.
+        */
+       copy_seccomp(p);
+
        init_task_pid_links(p);
        if (likely(p->pid)) {
                ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);