| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/23 11:34 | flow | patch-triage |
5mArgs:null Results: {
"EnableConfigs": [
"COREDUMP",
"IO_URING",
"SYSCTL",
"UNIX"
],
"FocusSymbols": [
"vfs_coredump",
"coredump_signal_pending",
"proc_dostring_coredump",
"create_io_thread",
"io_wq_exit_start",
"close_cloexec_files",
"ptrace_request",
"__set_current_blocked"
],
"KMSANReasoning": "The patch series focuses on race conditions, process lifecycle, signal masks, and file descriptor closing order during coredump, exec, fork, and exit paths:\n1. fs/coredump.c: Introduces a spinlock (`core_pattern_lock`) protecting reads and writes to `core_pattern`. The local stack buffers `pattern` in `coredump_parse()` and `proc_dostring_coredump()` are populated using `strscpy()`, and subsequent string processing is strictly null-terminated or length-checked. The sysctl read/write handlers operate strictly on the string length (`strlen`), so uninitialized stack bytes are never copied to userspace.\n2. fs/coredump.c: Protects exiting threads with RCU during wakeup in `coredump_finish()` (guards against use-after-free, which is a KASAN domain).\n3. fs/file.c: Changes the iteration order when closing fds (using `__fls()` and `find_last_bit()` from highest to lowest fd) on existing bitmap structures without altering allocation or initialization.\n4. kernel/fork.c, kernel/exit.c, fs/exec.c, io_uring/io-wq.c: Reorders teardown steps, initializes `p-\u003efiles = NULL`, and cancels io_uring tasks earlier to prevent deadlocks and races with user workers.\n5. kernel/signal.c: `floor` and `floored` sigset_t variables in `__set_task_blocked()` are fully initialized via `siginitsetinv()` and `sigorsets()`.\n\nNone of the changes introduce uninitialized memory reads, info-leaks to userspace, or uninitialized padding exposure. The concerns addressed by this patch relate to synchronization, lifecycle/UAF, and deadlock prevention, which are covered by KASAN and LOCKDEP rather than KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false,
"Reasoning": "The patch series modifies core kernel subsystems including coredump handling, signal retargeting, io_uring worker thread lifecycle, ptrace restrictions, and file descriptor teardown. It adds synchronization via spinlocks and barriers, reverses the fd closing order in close_files/close_cloexec_files, introduces a new runtime assertion (WARN_ON_ONCE) in __set_task_blocked, and restructures coredump/io_uring cancellation. All changes are in highly reachable code paths and warrant fuzzing.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/23 11:34 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 992c6a755e67237899965b09325acaeaceeef2ea\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Sep 23 11:34:41 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/fs/coredump.c b/fs/coredump.c\nindex 16b331b686fbe..d5d76704df810 100644\n--- a/fs/coredump.c\n+++ b/fs/coredump.c\n@@ -85,6 +85,8 @@ static int core_uses_pid;\n static unsigned int core_pipe_limit;\n static unsigned int core_sort_vma;\n static char core_pattern[CORENAME_MAX_SIZE] = \"core\";\n+/* Taken around every copy in and out of core_pattern. */\n+static DEFINE_SPINLOCK(core_pattern_lock);\n static int core_name_size = CORENAME_MAX_SIZE;\n unsigned int core_file_note_size_limit = CORE_FILE_NOTE_SIZE_DEFAULT;\n static atomic_t core_pipe_count = ATOMIC_INIT(0);\n@@ -240,11 +242,16 @@ static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,\n \t\t\t size_t **argv, int *argc)\n {\n \tconst struct cred *cred = current_cred();\n-\tconst char *pat_ptr = core_pattern;\n+\tchar pattern[CORENAME_MAX_SIZE];\n+\tconst char *pat_ptr = pattern;\n \tbool was_space = false;\n \tint pid_in_pattern = 0;\n \tint err = 0;\n \n+\t/* The sysctl handler may be publishing a new pattern. */\n+\tscoped_guard(spinlock, \u0026core_pattern_lock)\n+\t\tstrscpy(pattern, core_pattern);\n+\n \tcprm-\u003emask = COREDUMP_KERNEL;\n \tif (core_pipe_limit)\n \t\tcprm-\u003emask |= COREDUMP_WAIT;\n@@ -561,6 +568,8 @@ static void coredump_finish(enum coredump_state state)\n \tcurrent-\u003esignal-\u003ecore_state = NULL;\n \tspin_unlock_irq(\u0026current-\u003esighand-\u003esiglock);\n \n+\t/* A released thread may exit and be freed before it is woken. */\n+\tguard(rcu)();\n \twhile ((curr = next) != NULL) {\n \t\tnext = curr-\u003enext;\n \t\ttask = curr-\u003etask;\n@@ -569,6 +578,7 @@ static void coredump_finish(enum coredump_state state)\n \t\t * -\u003etask == NULL before we read -\u003enext.\n \t\t */\n \t\tsmp_mb();\n+\t\t/* Any wakeup now lets the thread exit, rcu keeps it alive. */\n \t\tcurr-\u003etask = NULL;\n \t\twake_up_process(task);\n \t}\n@@ -577,12 +587,13 @@ static void coredump_finish(enum coredump_state state)\n static bool dump_interrupted(void)\n {\n \t/*\n-\t * SIGKILL or freezing() interrupt the coredumping. Perhaps we\n-\t * can do try_to_freeze() and check __fatal_signal_pending(),\n-\t * but then we need to teach dump_write() to restart and clear\n-\t * TIF_SIGPENDING.\n+\t * SIGKILL, freezing() or the cgroup v2 freezer trap interrupt the\n+\t * coredumping. Perhaps we can do try_to_freeze() and check\n+\t * __fatal_signal_pending(), but then we need to teach dump_write()\n+\t * to restart and clear TIF_SIGPENDING.\n \t */\n-\treturn fatal_signal_pending(current) || freezing(current);\n+\treturn fatal_signal_pending(current) || freezing(current) ||\n+\t (READ_ONCE(current-\u003ejobctl) \u0026 JOBCTL_TRAP_FREEZE);\n }\n \n static void wait_for_dump_helpers(struct file *file)\n@@ -1636,11 +1647,11 @@ void validate_coredump_safety(void)\n \t}\n }\n \n-static inline bool check_coredump_socket(void)\n+static inline bool check_coredump_socket(const char *pattern)\n {\n \tconst char *p;\n \n-\tif (core_pattern[0] != '@')\n+\tif (pattern[0] != '@')\n \t\treturn true;\n \n \t/*\n@@ -1652,16 +1663,16 @@ static inline bool check_coredump_socket(void)\n \t\treturn false;\n \n \t/* Must be an absolute path... */\n-\tif (core_pattern[1] != '/') {\n+\tif (pattern[1] != '/') {\n \t\t/* ... or the socket request protocol... */\n-\t\tif (core_pattern[1] != '@')\n+\t\tif (pattern[1] != '@')\n \t\t\treturn false;\n \t\t/* ... and if so must be an absolute path. */\n-\t\tif (core_pattern[2] != '/')\n+\t\tif (pattern[2] != '/')\n \t\t\treturn false;\n-\t\tp = \u0026core_pattern[2];\n+\t\tp = \u0026pattern[2];\n \t} else {\n-\t\tp = \u0026core_pattern[1];\n+\t\tp = \u0026pattern[1];\n \t}\n \n \t/* The path obviously cannot exceed UNIX_PATH_MAX. */\n@@ -1669,7 +1680,7 @@ static inline bool check_coredump_socket(void)\n \t\treturn false;\n \n \t/* Must not contain \"..\" in the path. */\n-\tif (name_contains_dotdot(core_pattern))\n+\tif (name_contains_dotdot(pattern))\n \t\treturn false;\n \n \treturn true;\n@@ -1678,27 +1689,35 @@ static inline bool check_coredump_socket(void)\n static int proc_dostring_coredump(const struct ctl_table *table, int write,\n \t\t void *buffer, size_t *lenp, loff_t *ppos)\n {\n+\tchar pattern[CORENAME_MAX_SIZE];\n+\tconst struct ctl_table tmp = {\n+\t\t.procname\t= table-\u003eprocname,\n+\t\t.data\t\t= pattern,\n+\t\t.maxlen\t\t= sizeof(pattern),\n+\t};\n+\tbool changed = false;\n \tint error;\n-\tssize_t retval;\n-\tchar old_core_pattern[CORENAME_MAX_SIZE];\n-\n-\tif (!write)\n-\t\treturn proc_dostring(table, write, buffer, lenp, ppos);\n \n-\tretval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);\n+\t/* Work on a copy, proc_dostring() appends at *ppos. */\n+\tscoped_guard(spinlock, \u0026core_pattern_lock)\n+\t\tstrscpy(pattern, core_pattern);\n \n-\terror = proc_dostring(table, write, buffer, lenp, ppos);\n-\tif (error)\n+\terror = proc_dostring(\u0026tmp, write, buffer, lenp, ppos);\n+\tif (error || !write)\n \t\treturn error;\n \n-\tif (!check_coredump_socket()) {\n-\t\tstrscpy(core_pattern, old_core_pattern, retval + 1);\n+\tif (!check_coredump_socket(pattern))\n \t\treturn -EINVAL;\n-\t}\n \n-\tif (strncmp(old_core_pattern, core_pattern, CORENAME_MAX_SIZE))\n+\t/* Publish the validated pattern whole. */\n+\tscoped_guard(spinlock, \u0026core_pattern_lock) {\n+\t\tchanged = strncmp(pattern, core_pattern, CORENAME_MAX_SIZE);\n+\t\tif (changed)\n+\t\t\tstrscpy(core_pattern, pattern);\n+\t}\n+\tif (changed)\n \t\tvalidate_coredump_safety();\n-\treturn error;\n+\treturn 0;\n }\n \n static const unsigned int core_file_note_size_min = CORE_FILE_NOTE_SIZE_DEFAULT;\ndiff --git a/fs/exec.c b/fs/exec.c\nindex 075a744421e14..334e6d358c567 100644\n--- a/fs/exec.c\n+++ b/fs/exec.c\n@@ -1149,16 +1149,19 @@ int begin_new_exec(struct linux_binprm * bprm)\n \t */\n \tbprm-\u003epoint_of_no_return = true;\n \n+\t/*\n+\t * Cancel any io_uring activity across execve. This runs task work\n+\t * that may still create an io-wq worker, so do it while de_thread()\n+\t * can still zap it.\n+\t */\n+\tio_uring_task_cancel();\n+\n \t/* Make this the only thread in the thread group */\n \tretval = de_thread(me);\n \tif (retval)\n \t\tgoto out;\n \t/* see the comment in check_unsafe_exec() */\n \tcurrent-\u003efs-\u003ein_exec = 0;\n-\t/*\n-\t * Cancel any io_uring activity across execve\n-\t */\n-\tio_uring_task_cancel();\n \n \t/* Ensure the files table is not shared. */\n \tretval = unshare_fd(CLONE_FILES, \u0026files);\ndiff --git a/fs/file.c b/fs/file.c\nindex 76e328edf6305..7f8d0afd8807a 100644\n--- a/fs/file.c\n+++ b/fs/file.c\n@@ -497,24 +497,21 @@ static struct fdtable *close_files(struct files_struct *files)\n \t * files structure.\n \t */\n \tstruct fdtable *fdt = rcu_dereference_raw(files-\u003efdt);\n-\tunsigned int i, j = 0;\n+\tunsigned int j = fdt-\u003emax_fds / BITS_PER_LONG;\n+\n+\t/* Highest fd first, the order the deferred puts ran in. */\n+\twhile (j--) {\n+\t\tunsigned long set = fdt-\u003eopen_fds[j];\n \n-\tfor (;;) {\n-\t\tunsigned long set;\n-\t\ti = j * BITS_PER_LONG;\n-\t\tif (i \u003e= fdt-\u003emax_fds)\n-\t\t\tbreak;\n-\t\tset = fdt-\u003eopen_fds[j++];\n \t\twhile (set) {\n-\t\t\tif (set \u0026 1) {\n-\t\t\t\tstruct file *file = fdt-\u003efd[i];\n-\t\t\t\tif (file) {\n-\t\t\t\t\tfilp_close_sync(file, files);\n-\t\t\t\t\tcond_resched();\n-\t\t\t\t}\n+\t\t\tunsigned int bit = __fls(set);\n+\t\t\tstruct file *file = fdt-\u003efd[j * BITS_PER_LONG + bit];\n+\n+\t\t\tset ^= 1UL \u003c\u003c bit;\n+\t\t\tif (file) {\n+\t\t\t\tfilp_close_sync(file, files);\n+\t\t\t\tcond_resched();\n \t\t\t}\n-\t\t\ti++;\n-\t\t\tset \u003e\u003e= 1;\n \t\t}\n \t}\n \n@@ -801,10 +798,14 @@ static inline void __range_close(struct files_struct *files, unsigned int fd,\n \tn = last_fd(fdt);\n \tmax_fd = min(max_fd, n);\n \n-\tfor (fd = find_next_bit(fdt-\u003eopen_fds, max_fd + 1, fd);\n-\t fd \u003c= max_fd;\n-\t fd = find_next_bit(fdt-\u003eopen_fds, max_fd + 1, fd + 1)) {\n-\t\tfile = file_close_fd_locked(files, fd);\n+\t/* Highest fd first, see close_files(). */\n+\tfor (n = max_fd + 1; n \u003e fd; ) {\n+\t\tunsigned int cur = find_last_bit(fdt-\u003eopen_fds, n);\n+\n+\t\tif (cur \u003e= n || cur \u003c fd)\n+\t\t\tbreak;\n+\t\tn = cur;\n+\t\tfile = file_close_fd_locked(files, cur);\n \t\tif (file) {\n \t\t\tspin_unlock(\u0026files-\u003efile_lock);\n \t\t\tfilp_close_sync(file, files);\n@@ -908,20 +909,22 @@ void close_cloexec_files(struct files_struct *files)\n \n \t/* exec unshares first */\n \tspin_lock(\u0026files-\u003efile_lock);\n-\tfor (i = 0; ; i++) {\n+\tfdt = files_fdtable(files);\n+\t/* Highest fd first, see close_files(). */\n+\tfor (i = fdt-\u003emax_fds / BITS_PER_LONG; i--; ) {\n \t\tunsigned long set;\n-\t\tunsigned fd = i * BITS_PER_LONG;\n+\n \t\tfdt = files_fdtable(files);\n-\t\tif (fd \u003e= fdt-\u003emax_fds)\n-\t\t\tbreak;\n \t\tset = fdt-\u003eclose_on_exec[i];\n \t\tif (!set)\n \t\t\tcontinue;\n \t\tfdt-\u003eclose_on_exec[i] = 0;\n-\t\tfor ( ; set ; fd++, set \u003e\u003e= 1) {\n+\t\twhile (set) {\n+\t\t\tunsigned int bit = __fls(set);\n+\t\t\tunsigned fd = i * BITS_PER_LONG + bit;\n \t\t\tstruct file *file;\n-\t\t\tif (!(set \u0026 1))\n-\t\t\t\tcontinue;\n+\n+\t\t\tset ^= 1UL \u003c\u003c bit;\n \t\t\tfile = fdt-\u003efd[fd];\n \t\t\tif (!file)\n \t\t\t\tcontinue;\ndiff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h\nindex e039e29cd8c58..3835fbf7d80f2 100644\n--- a/include/linux/sched/signal.h\n+++ b/include/linux/sched/signal.h\n@@ -384,6 +384,13 @@ static inline int task_sigpending(struct task_struct *p)\n \treturn unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));\n }\n \n+static inline int __fatal_signal_pending(struct task_struct *p)\n+{\n+\treturn unlikely(sigismember(\u0026p-\u003epending.signal, SIGKILL));\n+}\n+\n+bool coredump_signal_pending(struct task_struct *p);\n+\n static inline int signal_pending(struct task_struct *p)\n {\n \t/*\n@@ -393,12 +400,12 @@ static inline int signal_pending(struct task_struct *p)\n \t */\n \tif (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL)))\n \t\treturn 1;\n-\treturn task_sigpending(p);\n-}\n-\n-static inline int __fatal_signal_pending(struct task_struct *p)\n-{\n-\treturn unlikely(sigismember(\u0026p-\u003epending.signal, SIGKILL));\n+\tif (!task_sigpending(p))\n+\t\treturn 0;\n+\t/* A coredumping task only stops for SIGKILL or the freezer. */\n+\tif (unlikely(READ_ONCE(p-\u003eflags) \u0026 PF_DUMPCORE))\n+\t\treturn coredump_signal_pending(p);\n+\treturn 1;\n }\n \n static inline int fatal_signal_pending(struct task_struct *p)\ndiff --git a/io_uring/io-wq.c b/io_uring/io-wq.c\nindex 2ca223e47d41f..2a980e86dd940 100644\n--- a/io_uring/io-wq.c\n+++ b/io_uring/io-wq.c\n@@ -1324,6 +1324,8 @@ static bool io_task_work_match(struct callback_head *cb, void *data)\n void io_wq_exit_start(struct io_wq *wq)\n {\n \tset_bit(IO_WQ_BIT_EXIT, \u0026wq-\u003estate);\n+\t/* Pairs with task_work_add() in io_queue_worker_create(). */\n+\tsmp_mb__after_atomic();\n }\n \n static void io_wq_cancel_tw_create(struct io_wq *wq)\ndiff --git a/kernel/exit.c b/kernel/exit.c\nindex 55dbea3b242e1..9ed5eb03d0e19 100644\n--- a/kernel/exit.c\n+++ b/kernel/exit.c\n@@ -1003,10 +1003,11 @@ void __noreturn do_exit(long code)\n \n \texit_sem(tsk);\n \texit_shm(tsk);\n-\texit_files(tsk);\n-\texit_fs(tsk);\n+\t/* Hang the tty up before the last close of it can clear the session. */\n \tif (group_dead)\n \t\tdisassociate_ctty(1);\n+\texit_files(tsk);\n+\texit_fs(tsk);\n \texit_nsproxy_namespaces(tsk);\n \texit_task_work(tsk);\n \texit_thread(tsk);\ndiff --git a/kernel/fork.c b/kernel/fork.c\nindex 10be4a0ecb3f1..be5980d0dd9f3 100644\n--- a/kernel/fork.c\n+++ b/kernel/fork.c\n@@ -1676,6 +1676,7 @@ static int copy_files(u64 clone_flags, struct task_struct *tsk,\n \n \tif (clone_flags \u0026 CLONE_FILES) {\n \t\tatomic_inc(\u0026oldf-\u003ecount);\n+\t\ttsk-\u003efiles = oldf;\n \t\treturn 0;\n \t}\n \n@@ -2145,12 +2146,9 @@ __latent_entropy struct task_struct *copy_process(\n \tif (args-\u003ekthread)\n \t\tp-\u003eflags |= PF_KTHREAD;\n \tif (args-\u003euser_worker) {\n-\t\t/*\n-\t\t * Mark us a user worker, and block any signal that isn't\n-\t\t * fatal or STOP\n-\t\t */\n+\t\t/* A user worker takes only the signals nobody can block. */\n \t\tp-\u003eflags |= PF_USER_WORKER;\n-\t\tsiginitsetinv(\u0026p-\u003eblocked, sigmask(SIGKILL)|sigmask(SIGSTOP));\n+\t\tsiginitsetinv(\u0026p-\u003eblocked, SIG_KERNEL_ONLY_MASK);\n \t}\n \tif (args-\u003eio_thread)\n \t\tp-\u003eflags |= PF_IO_WORKER;\n@@ -2199,6 +2197,8 @@ __latent_entropy struct task_struct *copy_process(\n \tINIT_LIST_HEAD(\u0026p-\u003esibling);\n \trcu_copy_process(p);\n \tp-\u003evfork_done = NULL;\n+\t/* Set by copy_files(), exit_files() on the error path skips NULL. */\n+\tp-\u003efiles = NULL;\n \tspin_lock_init(\u0026p-\u003ealloc_lock);\n \n \tinit_sigpending(\u0026p-\u003epending);\n@@ -2300,7 +2300,7 @@ __latent_entropy struct task_struct *copy_process(\n \t\tgoto bad_fork_cleanup_semundo;\n \tretval = copy_fs(clone_flags, p, args-\u003eumh);\n \tif (retval)\n-\t\tgoto bad_fork_cleanup_files;\n+\t\tgoto bad_fork_cleanup_semundo;\n \tretval = copy_sighand(clone_flags, p);\n \tif (retval)\n \t\tgoto bad_fork_cleanup_fs;\n@@ -2613,8 +2613,6 @@ __latent_entropy struct task_struct *copy_process(\n \t__cleanup_sighand(p-\u003esighand);\n bad_fork_cleanup_fs:\n \texit_fs(p); /* blocking */\n-bad_fork_cleanup_files:\n-\texit_files(p); /* blocking */\n bad_fork_cleanup_semundo:\n \texit_sem(p);\n bad_fork_cleanup_security:\n@@ -2625,6 +2623,8 @@ __latent_entropy struct task_struct *copy_process(\n \tperf_event_free_task(p);\n bad_fork_sched_cancel_fork:\n \tsched_cancel_fork(p);\n+\t/* -\u003erelease() of a file may need scx_fork_rwsem for write. */\n+\texit_files(p); /* blocking */\n bad_fork_cleanup_policy:\n \tlockdep_free_task(p);\n #ifdef CONFIG_NUMA\n@@ -2703,6 +2703,10 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)\n \t\t.user_worker\t= 1,\n \t};\n \n+\t/* A creator past its fatal signal or its coredump point gets no thread. */\n+\tif (current-\u003eflags \u0026 (PF_SIGNALED | PF_POSTCOREDUMP))\n+\t\treturn ERR_PTR(-EINTR);\n+\n \treturn copy_process(NULL, 0, node, \u0026args);\n }\n \ndiff --git a/kernel/ptrace.c b/kernel/ptrace.c\nindex d041645d9d17d..4e9822a87aabb 100644\n--- a/kernel/ptrace.c\n+++ b/kernel/ptrace.c\n@@ -1227,6 +1227,12 @@ int ptrace_request(struct task_struct *child, long request,\n \tcase PTRACE_SETSIGMASK: {\n \t\tsigset_t new_set;\n \n+\t\t/* A user worker only ever takes SIGKILL and SIGSTOP. */\n+\t\tif (child-\u003eflags \u0026 PF_USER_WORKER) {\n+\t\t\tret = -EPERM;\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tif (addr != sizeof(sigset_t)) {\n \t\t\tret = -EINVAL;\n \t\t\tbreak;\ndiff --git a/kernel/signal.c b/kernel/signal.c\nindex ec30550951ecf..137002445b0dc 100644\n--- a/kernel/signal.c\n+++ b/kernel/signal.c\n@@ -717,6 +717,14 @@ void signal_wake_up_state(struct task_struct *t, unsigned int state)\n \t\tkick_process(t);\n }\n \n+/* Only SIGKILL or a freezer interrupt a coredump, see dump_interrupted(). */\n+bool coredump_signal_pending(struct task_struct *p)\n+{\n+\treturn __fatal_signal_pending(p) || freezing(p) ||\n+\t (READ_ONCE(p-\u003ejobctl) \u0026 JOBCTL_TRAP_FREEZE);\n+}\n+EXPORT_SYMBOL(coredump_signal_pending);\n+\n static inline void posixtimer_sig_ignore(struct task_struct *tsk, struct sigqueue *q);\n \n static void sigqueue_free_ignored(struct task_struct *tsk, struct sigqueue *q)\n@@ -3109,6 +3117,10 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)\n \tsigset_t retarget;\n \tstruct task_struct *t;\n \n+\t/* Nobody dequeues them in a dying group, see get_signal(). */\n+\tif (tsk-\u003esignal-\u003eflags \u0026 SIGNAL_GROUP_EXIT)\n+\t\treturn;\n+\n \tsigandsets(\u0026retarget, \u0026tsk-\u003esignal-\u003eshared_pending.signal, which);\n \tif (sigisemptyset(\u0026retarget))\n \t\treturn;\n@@ -3200,6 +3212,16 @@ long do_no_restart_syscall(struct restart_block *param)\n \n static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)\n {\n+\tsigset_t floor, floored;\n+\n+\t/* A user worker never unblocks anything but SIGKILL and SIGSTOP. */\n+\tif (unlikely(tsk-\u003eflags \u0026 PF_USER_WORKER)) {\n+\t\tsiginitsetinv(\u0026floor, SIG_KERNEL_ONLY_MASK);\n+\t\tsigorsets(\u0026floored, newset, \u0026floor);\n+\t\tWARN_ON_ONCE(!sigequalsets(\u0026floored, newset));\n+\t\tnewset = \u0026floored;\n+\t}\n+\n \tif (task_sigpending(tsk) \u0026\u0026 !thread_group_empty(tsk)) {\n \t\tsigset_t newblocked;\n \t\t/* A set of now blocked but previously unblocked signals. */\ndiff --git a/tools/testing/selftests/coredump/.gitignore b/tools/testing/selftests/coredump/.gitignore\nindex 097f52db0be96..e32f6e9006f6e 100644\n--- a/tools/testing/selftests/coredump/.gitignore\n+++ b/tools/testing/selftests/coredump/.gitignore\n@@ -2,3 +2,5 @@\n stackdump_test\n coredump_socket_test\n coredump_socket_protocol_test\n+coredump_signal_test\n+coredump_worker_test\ndiff --git a/tools/testing/selftests/coredump/Makefile b/tools/testing/selftests/coredump/Makefile\nindex dece1a31d561b..57ec331f03a76 100644\n--- a/tools/testing/selftests/coredump/Makefile\n+++ b/tools/testing/selftests/coredump/Makefile\n@@ -3,7 +3,9 @@ CFLAGS += -Wall -O0 -g $(KHDR_INCLUDES) $(TOOLS_INCLUDES)\n \n TEST_GEN_PROGS := stackdump_test \\\n \t\t coredump_socket_test \\\n-\t\t coredump_socket_protocol_test\n+\t\t coredump_socket_protocol_test \\\n+\t\t coredump_signal_test \\\n+\t\t coredump_worker_test\n TEST_FILES := stackdump\n \n include ../lib.mk\n@@ -11,3 +13,5 @@ include ../lib.mk\n $(OUTPUT)/stackdump_test: coredump_test_helpers.c\n $(OUTPUT)/coredump_socket_test: coredump_test_helpers.c\n $(OUTPUT)/coredump_socket_protocol_test: coredump_test_helpers.c\n+$(OUTPUT)/coredump_signal_test: coredump_test_helpers.c\n+$(OUTPUT)/coredump_worker_test: coredump_test_helpers.c\ndiff --git a/tools/testing/selftests/coredump/coredump_signal_test.c b/tools/testing/selftests/coredump/coredump_signal_test.c\nnew file mode 100644\nindex 0000000000000..fdf48b1447811\n--- /dev/null\n+++ b/tools/testing/selftests/coredump/coredump_signal_test.c\n@@ -0,0 +1,238 @@\n+// SPDX-License-Identifier: GPL-2.0\n+\n+#include \u003cfcntl.h\u003e\n+#include \u003cpthread.h\u003e\n+#include \u003csignal.h\u003e\n+#include \u003csys/mman.h\u003e\n+#include \u003csys/socket.h\u003e\n+#include \u003csys/stat.h\u003e\n+#include \u003csys/syscall.h\u003e\n+#include \u003csys/un.h\u003e\n+#include \u003cunistd.h\u003e\n+\n+#include \"coredump_test.h\"\n+\n+/* Big enough to fill the socket buffer many times over. */\n+#define CRASH_MAPPING_SIZE (32 * 1024 * 1024)\n+\n+FIXTURE_SETUP(coredump)\n+{\n+\tFILE *file;\n+\tint ret;\n+\n+\tself-\u003epid_coredump_server = -ESRCH;\n+\tself-\u003efd_tmpfs_detached = -1;\n+\tfile = fopen(\"/proc/sys/kernel/core_pattern\", \"r\");\n+\tASSERT_NE(NULL, file);\n+\n+\tret = fread(self-\u003eoriginal_core_pattern, 1, sizeof(self-\u003eoriginal_core_pattern), file);\n+\tASSERT_TRUE(ret || feof(file));\n+\tASSERT_LT(ret, sizeof(self-\u003eoriginal_core_pattern));\n+\n+\tself-\u003eoriginal_core_pattern[ret] = '\\0';\n+\n+\tret = fclose(file);\n+\tASSERT_EQ(0, ret);\n+}\n+\n+FIXTURE_TEARDOWN(coredump)\n+{\n+\tconst char *reason;\n+\tFILE *file;\n+\tint ret, status;\n+\n+\tif (self-\u003epid_coredump_server \u003e 0) {\n+\t\tkill(self-\u003epid_coredump_server, SIGTERM);\n+\t\twaitpid(self-\u003epid_coredump_server, \u0026status, 0);\n+\t}\n+\tunlink(\"/tmp/coredump.file\");\n+\tunlink(\"/tmp/coredump.socket\");\n+\n+\tfile = fopen(\"/proc/sys/kernel/core_pattern\", \"w\");\n+\tif (!file) {\n+\t\treason = \"Unable to open core_pattern\";\n+\t\tgoto fail;\n+\t}\n+\n+\tret = fprintf(file, \"%s\", self-\u003eoriginal_core_pattern);\n+\tif (ret \u003c 0) {\n+\t\treason = \"Unable to write to core_pattern\";\n+\t\tgoto fail;\n+\t}\n+\n+\tret = fclose(file);\n+\tif (ret) {\n+\t\treason = \"Unable to close core_pattern\";\n+\t\tgoto fail;\n+\t}\n+\n+\treturn;\n+fail:\n+\t/* This should never happen */\n+\tfprintf(stderr, \"Failed to cleanup coredump test: %s\\n\", reason);\n+}\n+\n+static volatile int waiter_ready;\n+\n+static void usr1_handler(int sig)\n+{\n+}\n+\n+/* Sleeps in sigtimedwait() with SIGUSR1 unblocked only inside the kernel. */\n+static void *sigwaiter(void *arg)\n+{\n+\tsigset_t set;\n+\tsiginfo_t info;\n+\n+\tsigemptyset(\u0026set);\n+\tsigaddset(\u0026set, SIGUSR1);\n+\t__atomic_store_n(\u0026waiter_ready, 1, __ATOMIC_RELEASE);\n+\tfor (;;)\n+\t\tsigtimedwait(\u0026set, \u0026info, NULL);\n+\treturn NULL;\n+}\n+\n+/*\n+ * Crash with a shared SIGUSR1 still queued for this thread. The vfork()\n+ * child queues it while we sleep killably and then the SIGSEGV that is\n+ * dequeued first. The zap wakes the sibling out of sigtimedwait() and its\n+ * mask restore retargets SIGUSR1 to the dumper.\n+ */\n+static void crashing_child_retarget(bool queue_shared)\n+{\n+\tsigset_t all, old;\n+\tpthread_t thread;\n+\tpid_t pid, tid;\n+\tchar *p;\n+\n+\tp = mmap(NULL, CRASH_MAPPING_SIZE, PROT_READ | PROT_WRITE,\n+\t\t MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);\n+\tif (p == MAP_FAILED)\n+\t\t_exit(EXIT_FAILURE);\n+\tmemset(p, 0x5a, CRASH_MAPPING_SIZE);\n+\n+\tsignal(SIGUSR1, usr1_handler);\n+\tsigfillset(\u0026all);\n+\tpthread_sigmask(SIG_BLOCK, \u0026all, \u0026old);\n+\t/* One waiter only, retarget stops at the first thread not blocking it. */\n+\tif (pthread_create(\u0026thread, NULL, sigwaiter, NULL))\n+\t\t_exit(EXIT_FAILURE);\n+\tpthread_sigmask(SIG_SETMASK, \u0026old, NULL);\n+\twhile (!__atomic_load_n(\u0026waiter_ready, __ATOMIC_ACQUIRE))\n+\t\tusleep(1000);\n+\tusleep(50 * 1000);\n+\n+\tpid = getpid();\n+\ttid = syscall(SYS_gettid);\n+\tif (vfork() == 0) {\n+\t\tif (queue_shared)\n+\t\t\tsyscall(SYS_kill, pid, SIGUSR1);\n+\t\tsyscall(SYS_tgkill, pid, tid, SIGSEGV);\n+\t\tsyscall(SYS_exit, 0);\n+\t}\n+\n+\t/* Not reached, the pending SIGSEGV dumps core. */\n+\tfor (;;)\n+\t\tpause();\n+}\n+\n+/*\n+ * Dump the crashing child into /tmp/coredump.file through a server that\n+ * holds the read back so the dumper blocks on the full socket buffer.\n+ */\n+static void run_coredump(struct __test_metadata *const _metadata,\n+\t\t\t FIXTURE_DATA(coredump) *self, bool queue_shared)\n+{\n+\tpid_t pid, pid_coredump_server;\n+\tint ipc_sockets[2];\n+\tint status;\n+\tchar c;\n+\n+\tunlink(\"/tmp/coredump.file\");\n+\tunlink(\"/tmp/coredump.socket\");\n+\tASSERT_TRUE(set_core_pattern(\"@/tmp/coredump.socket\"));\n+\tASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, ipc_sockets), 0);\n+\n+\tpid_coredump_server = fork();\n+\tASSERT_GE(pid_coredump_server, 0);\n+\tif (pid_coredump_server == 0) {\n+\t\tint fd_server = -1, fd_coredump = -1, fd_core_file = -1;\n+\t\tint exit_code = EXIT_FAILURE;\n+\n+\t\tclose(ipc_sockets[0]);\n+\n+\t\tfd_server = create_and_listen_unix_socket(\"/tmp/coredump.socket\");\n+\t\tif (fd_server \u003c 0)\n+\t\t\tgoto out;\n+\n+\t\tif (write_nointr(ipc_sockets[1], \"1\", 1) \u003c 0)\n+\t\t\tgoto out;\n+\t\tclose(ipc_sockets[1]);\n+\n+\t\tfd_coredump = accept4(fd_server, NULL, NULL, SOCK_CLOEXEC);\n+\t\tif (fd_coredump \u003c 0) {\n+\t\t\tfprintf(stderr, \"%s: accept4 failed: %m\\n\", __func__);\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\t/* Let the dumper run into the full socket buffer first. */\n+\t\tsleep(1);\n+\n+\t\tfd_core_file = creat(\"/tmp/coredump.file\", 0644);\n+\t\tif (fd_core_file \u003c 0) {\n+\t\t\tfprintf(stderr, \"%s: creat failed: %m\\n\", __func__);\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (recv_coredump_bytes(fd_coredump, fd_core_file) \u003c 0)\n+\t\t\tgoto out;\n+\n+\t\texit_code = EXIT_SUCCESS;\n+out:\n+\t\tif (fd_core_file \u003e= 0)\n+\t\t\tclose(fd_core_file);\n+\t\tif (fd_coredump \u003e= 0)\n+\t\t\tclose(fd_coredump);\n+\t\tif (fd_server \u003e= 0)\n+\t\t\tclose(fd_server);\n+\t\t_exit(exit_code);\n+\t}\n+\tself-\u003epid_coredump_server = pid_coredump_server;\n+\n+\tEXPECT_EQ(close(ipc_sockets[1]), 0);\n+\tASSERT_EQ(read_nointr(ipc_sockets[0], \u0026c, 1), 1);\n+\tEXPECT_EQ(close(ipc_sockets[0]), 0);\n+\n+\tpid = fork();\n+\tASSERT_GE(pid, 0);\n+\tif (pid == 0)\n+\t\tcrashing_child_retarget(queue_shared);\n+\n+\twaitpid(pid, \u0026status, 0);\n+\tASSERT_TRUE(WIFSIGNALED(status));\n+\tASSERT_EQ(WTERMSIG(status), SIGSEGV);\n+\tASSERT_TRUE(WCOREDUMP(status));\n+\n+\twait_and_check_coredump_server(pid_coredump_server, _metadata, self);\n+}\n+\n+static void check_coredump_complete(struct __test_metadata *const _metadata)\n+{\n+\tint fd;\n+\n+\tfd = open(\"/tmp/coredump.file\", O_RDONLY | O_CLOEXEC);\n+\tASSERT_GE(fd, 0);\n+\tASSERT_TRUE(check_coredump_extent(fd));\n+\tclose(fd);\n+}\n+\n+TEST_F(coredump, retarget_shared_pending)\n+{\n+\trun_coredump(_metadata, self, false);\n+\tcheck_coredump_complete(_metadata);\n+\n+\trun_coredump(_metadata, self, true);\n+\tcheck_coredump_complete(_metadata);\n+}\n+\n+TEST_HARNESS_MAIN\ndiff --git a/tools/testing/selftests/coredump/coredump_worker_test.c b/tools/testing/selftests/coredump/coredump_worker_test.c\nnew file mode 100644\nindex 0000000000000..9a4270b65a6e6\n--- /dev/null\n+++ b/tools/testing/selftests/coredump/coredump_worker_test.c\n@@ -0,0 +1,447 @@\n+// SPDX-License-Identifier: GPL-2.0\n+\n+/*\n+ * A user worker as the coredumping thread.\n+ *\n+ * io-wq workers and SQPOLL threads are threads of the process that never\n+ * return to userspace. They block every signal but SIGKILL and SIGSTOP,\n+ * but a tracer can replace that mask with PTRACE_SETSIGMASK and inject a\n+ * coredump signal. get_signal() then runs vfs_coredump() in the worker.\n+ * The worker's own exit bookkeeping runs only after the dump, so a\n+ * zapped sibling that waits for it in its exit path deadlocks with the\n+ * dumper and the whole thread group is stuck in D state.\n+ *\n+ * Inject SIGSEGV into a chosen thread and require that the thread group\n+ * is gone in bounded time, either because the dump completed or because\n+ * SIGKILL still works. A failure leaves the stuck process behind.\n+ */\n+#include \u003cctype.h\u003e\n+#include \u003cerrno.h\u003e\n+#include \u003cdirent.h\u003e\n+#include \u003cfcntl.h\u003e\n+#include \u003csys/mman.h\u003e\n+#include \u003csys/ptrace.h\u003e\n+#include \u003csys/resource.h\u003e\n+#include \u003csys/stat.h\u003e\n+#include \u003csys/syscall.h\u003e\n+#include \u003csys/wait.h\u003e\n+#include \u003cunistd.h\u003e\n+#include \u003clinux/io_uring.h\u003e\n+\n+#include \"coredump_test.h\"\n+\n+#ifndef PTRACE_SETSIGMASK\n+#define PTRACE_SETSIGMASK 0x420b\n+#endif\n+\n+/* The dump of the tiny child takes well under a second. */\n+#define EXIT_TIMEOUT_MS 5000\n+\n+FIXTURE_SETUP(coredump)\n+{\n+\tFILE *file;\n+\tint ret;\n+\n+\tself-\u003epid_coredump_server = -ESRCH;\n+\tself-\u003efd_tmpfs_detached = -1;\n+\tfile = fopen(\"/proc/sys/kernel/core_pattern\", \"r\");\n+\tASSERT_NE(NULL, file);\n+\n+\tret = fread(self-\u003eoriginal_core_pattern, 1, sizeof(self-\u003eoriginal_core_pattern), file);\n+\tASSERT_TRUE(ret || feof(file));\n+\tASSERT_LT(ret, sizeof(self-\u003eoriginal_core_pattern));\n+\n+\tself-\u003eoriginal_core_pattern[ret] = '\\0';\n+\n+\tret = fclose(file);\n+\tASSERT_EQ(0, ret);\n+}\n+\n+FIXTURE_TEARDOWN(coredump)\n+{\n+\tconst char *reason;\n+\tFILE *file;\n+\tint ret;\n+\n+\tfile = fopen(\"/proc/sys/kernel/core_pattern\", \"w\");\n+\tif (!file) {\n+\t\treason = \"Unable to open core_pattern\";\n+\t\tgoto fail;\n+\t}\n+\n+\tret = fprintf(file, \"%s\", self-\u003eoriginal_core_pattern);\n+\tif (ret \u003c 0) {\n+\t\treason = \"Unable to write to core_pattern\";\n+\t\tgoto fail;\n+\t}\n+\n+\tret = fclose(file);\n+\tif (ret) {\n+\t\treason = \"Unable to close core_pattern\";\n+\t\tgoto fail;\n+\t}\n+\n+\treturn;\n+fail:\n+\t/* This should never happen */\n+\tfprintf(stderr, \"Failed to cleanup coredump test: %s\\n\", reason);\n+}\n+\n+/* A raw ring, no liburing. */\n+struct uring {\n+\tint fd;\n+\tstruct io_uring_params params;\n+\tvoid *sq;\n+\tsize_t sq_len;\n+\tstruct io_uring_sqe *sqes;\n+\tsize_t sqes_len;\n+\tunsigned int *sq_tail, *sq_mask, *sq_array;\n+\tunsigned int *cq_head, *cq_tail, *cq_mask;\n+\tstruct io_uring_cqe *cqes;\n+};\n+\n+static int uring_setup(struct uring *r, unsigned int flags)\n+{\n+\tsize_t cq_len;\n+\n+\tmemset(r, 0, sizeof(*r));\n+\tr-\u003eparams.flags = flags;\n+\tif (flags \u0026 IORING_SETUP_SQPOLL)\n+\t\tr-\u003eparams.sq_thread_idle = 2000;\n+\tr-\u003efd = syscall(__NR_io_uring_setup, 8, \u0026r-\u003eparams);\n+\tif (r-\u003efd \u003c 0)\n+\t\treturn -1;\n+\tif (!(r-\u003eparams.features \u0026 IORING_FEAT_SINGLE_MMAP))\n+\t\treturn -1;\n+\n+\tr-\u003esq_len = r-\u003eparams.sq_off.array + r-\u003eparams.sq_entries * sizeof(unsigned int);\n+\tcq_len = r-\u003eparams.cq_off.cqes + r-\u003eparams.cq_entries * sizeof(struct io_uring_cqe);\n+\tif (cq_len \u003e r-\u003esq_len)\n+\t\tr-\u003esq_len = cq_len;\n+\tr-\u003esq = mmap(NULL, r-\u003esq_len, PROT_READ | PROT_WRITE,\n+\t\t MAP_SHARED | MAP_POPULATE, r-\u003efd, IORING_OFF_SQ_RING);\n+\tif (r-\u003esq == MAP_FAILED)\n+\t\treturn -1;\n+\tr-\u003esqes_len = r-\u003eparams.sq_entries * sizeof(struct io_uring_sqe);\n+\tr-\u003esqes = mmap(NULL, r-\u003esqes_len, PROT_READ | PROT_WRITE,\n+\t\t MAP_SHARED | MAP_POPULATE, r-\u003efd, IORING_OFF_SQES);\n+\tif (r-\u003esqes == MAP_FAILED)\n+\t\treturn -1;\n+\n+\tr-\u003esq_tail = r-\u003esq + r-\u003eparams.sq_off.tail;\n+\tr-\u003esq_mask = r-\u003esq + r-\u003eparams.sq_off.ring_mask;\n+\tr-\u003esq_array = r-\u003esq + r-\u003eparams.sq_off.array;\n+\tr-\u003ecq_head = r-\u003esq + r-\u003eparams.cq_off.head;\n+\tr-\u003ecq_tail = r-\u003esq + r-\u003eparams.cq_off.tail;\n+\tr-\u003ecq_mask = r-\u003esq + r-\u003eparams.cq_off.ring_mask;\n+\tr-\u003ecqes = r-\u003esq + r-\u003eparams.cq_off.cqes;\n+\treturn 0;\n+}\n+\n+/* Submit one sqe, wait for its completion and return the result. */\n+static int uring_submit_wait(struct uring *r, const struct io_uring_sqe *sqe)\n+{\n+\tunsigned int tail = *r-\u003esq_tail, idx = tail \u0026 *r-\u003esq_mask;\n+\tunsigned int flags = IORING_ENTER_GETEVENTS;\n+\tint i;\n+\n+\tr-\u003esqes[idx] = *sqe;\n+\tr-\u003esq_array[idx] = idx;\n+\t__atomic_store_n(r-\u003esq_tail, tail + 1, __ATOMIC_RELEASE);\n+\n+\tif (r-\u003eparams.flags \u0026 IORING_SETUP_SQPOLL)\n+\t\tflags |= IORING_ENTER_SQ_WAKEUP;\n+\n+\tfor (i = 0; i \u003c 100; i++) {\n+\t\tif (syscall(__NR_io_uring_enter, r-\u003efd, 1, 1, flags, NULL, 0) \u003c 0 \u0026\u0026\n+\t\t errno != EINTR)\n+\t\t\treturn -1;\n+\t\tif (__atomic_load_n(r-\u003ecq_tail, __ATOMIC_ACQUIRE) != *r-\u003ecq_head) {\n+\t\t\tunsigned int head = *r-\u003ecq_head;\n+\t\t\tint res = r-\u003ecqes[head \u0026 *r-\u003ecq_mask].res;\n+\n+\t\t\t__atomic_store_n(r-\u003ecq_head, head + 1, __ATOMIC_RELEASE);\n+\t\t\treturn res;\n+\t\t}\n+\t\tflags \u0026= ~IORING_ENTER_SQ_WAKEUP;\n+\t\tusleep(10 * 1000);\n+\t}\n+\treturn -1;\n+}\n+\n+static bool uring_available(unsigned int flags)\n+{\n+\tstruct io_uring_params params = { .flags = flags };\n+\tint fd;\n+\n+\tfd = syscall(__NR_io_uring_setup, 2, \u0026params);\n+\tif (fd \u003c 0)\n+\t\treturn false;\n+\tclose(fd);\n+\treturn true;\n+}\n+\n+/*\n+ * Keep a ring, an idle io-wq worker and with SQPOLL an SQPOLL thread\n+ * alive. The last worker of a ring never exits on its idle timeout.\n+ */\n+static void worker_child(bool sqpoll, int fd_ipc)\n+{\n+\tstruct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };\n+\tstruct io_uring_sqe sqe = {};\n+\tstatic char buf[64];\n+\tstruct uring ring;\n+\tint memfd;\n+\n+\tif (setrlimit(RLIMIT_CORE, \u0026rl))\n+\t\t_exit(EXIT_FAILURE);\n+\n+\tmemfd = memfd_create(\"coredump_worker\", 0);\n+\tif (memfd \u003c 0 || write(memfd, \"hello\", 5) != 5)\n+\t\t_exit(EXIT_FAILURE);\n+\n+\tif (uring_setup(\u0026ring, sqpoll ? IORING_SETUP_SQPOLL : 0))\n+\t\t_exit(EXIT_FAILURE);\n+\n+\t/* IOSQE_ASYNC forces the read through io-wq so a worker appears. */\n+\tsqe.opcode = IORING_OP_READ;\n+\tsqe.fd = memfd;\n+\tsqe.addr = (__u64)(uintptr_t)buf;\n+\tsqe.len = sizeof(buf);\n+\tsqe.flags = IOSQE_ASYNC;\n+\tif (uring_submit_wait(\u0026ring, \u0026sqe) != 5)\n+\t\t_exit(EXIT_FAILURE);\n+\n+\tif (write_nointr(fd_ipc, \"1\", 1) != 1)\n+\t\t_exit(EXIT_FAILURE);\n+\tclose(fd_ipc);\n+\n+\tfor (;;)\n+\t\tpause();\n+}\n+\n+/* Find the thread of @pid whose comm starts with @prefix. */\n+static pid_t find_thread(pid_t pid, const char *prefix)\n+{\n+\tchar path[64], comm[64];\n+\tpid_t tid = -1;\n+\tstruct dirent *de;\n+\tssize_t bytes;\n+\tDIR *dir;\n+\tint fd;\n+\n+\tsnprintf(path, sizeof(path), \"/proc/%d/task\", pid);\n+\tdir = opendir(path);\n+\tif (!dir)\n+\t\treturn -1;\n+\n+\twhile (tid \u003c 0 \u0026\u0026 (de = readdir(dir))) {\n+\t\tif (!isdigit(de-\u003ed_name[0]))\n+\t\t\tcontinue;\n+\t\tsnprintf(path, sizeof(path), \"/proc/%d/task/%s/comm\", pid, de-\u003ed_name);\n+\t\tfd = open(path, O_RDONLY | O_CLOEXEC);\n+\t\tif (fd \u003c 0)\n+\t\t\tcontinue;\n+\t\tbytes = read(fd, comm, sizeof(comm) - 1);\n+\t\tclose(fd);\n+\t\tif (bytes \u003c= 0)\n+\t\t\tcontinue;\n+\t\tcomm[bytes] = '\\0';\n+\t\tif (!strncmp(comm, prefix, strlen(prefix)))\n+\t\t\ttid = atoi(de-\u003ed_name);\n+\t}\n+\tclosedir(dir);\n+\treturn tid;\n+}\n+\n+/*\n+ * Attach, stop the thread with SIGSTOP, drop the signal mask that\n+ * copy_process() gave it and resume it with SIGSEGV. Returns 1 when the\n+ * mask was changed, 0 when PTRACE_SETSIGMASK was refused (a user worker\n+ * keeps its mask and the SIGSEGV stays pending), -1 on any other failure.\n+ */\n+static int inject_coredump_signal(pid_t pid, pid_t tid)\n+{\n+\t__u64 mask = 0;\n+\tint status, ret = 1;\n+\n+\tif (ptrace(PTRACE_SEIZE, tid, NULL, NULL))\n+\t\treturn -1;\n+\tif (syscall(SYS_tgkill, pid, tid, SIGSTOP))\n+\t\treturn -1;\n+\tif (waitpid(tid, \u0026status, __WALL) != tid)\n+\t\treturn -1;\n+\tif (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)\n+\t\treturn -1;\n+\tif (ptrace(PTRACE_SETSIGMASK, tid, sizeof(mask), \u0026mask)) {\n+\t\tif (errno != EPERM)\n+\t\t\treturn -1;\n+\t\tret = 0;\n+\t}\n+\tif (ptrace(PTRACE_DETACH, tid, NULL, (void *)(long)SIGSEGV))\n+\t\treturn -1;\n+\treturn ret;\n+}\n+\n+/* Reap @pid within @timeout_ms, -1 when it is still there. */\n+static int wait_exit(pid_t pid, int *status, int timeout_ms)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i \u003c timeout_ms / 10; i++) {\n+\t\tpid_t ret = waitpid(pid, status, WNOHANG);\n+\n+\t\tif (ret == pid)\n+\t\t\treturn 0;\n+\t\tif (ret \u003c 0)\n+\t\t\treturn -1;\n+\t\tusleep(10 * 1000);\n+\t}\n+\treturn -1;\n+}\n+\n+static void log_threads(struct __test_metadata *const _metadata, pid_t pid)\n+{\n+\tchar path[64], line[256], comm[64] = {};\n+\tstruct dirent *de;\n+\tDIR *dir;\n+\tFILE *f;\n+\n+\tsnprintf(path, sizeof(path), \"/proc/%d/task\", pid);\n+\tdir = opendir(path);\n+\tif (!dir)\n+\t\treturn;\n+\twhile ((de = readdir(dir))) {\n+\t\tif (!isdigit(de-\u003ed_name[0]))\n+\t\t\tcontinue;\n+\t\tsnprintf(path, sizeof(path), \"/proc/%d/task/%s/status\", pid, de-\u003ed_name);\n+\t\tf = fopen(path, \"r\");\n+\t\tif (!f)\n+\t\t\tcontinue;\n+\t\twhile (fgets(line, sizeof(line), f)) {\n+\t\t\tline[strcspn(line, \"\\n\")] = '\\0';\n+\t\t\tif (!strncmp(line, \"Name:\", 5))\n+\t\t\t\tsnprintf(comm, sizeof(comm), \"%s\", line + 6);\n+\t\t\telse if (!strncmp(line, \"State:\", 6))\n+\t\t\t\tTH_LOG(\"tid %s (%s) %s\", de-\u003ed_name, comm, line + 7);\n+\t\t}\n+\t\tfclose(f);\n+\t}\n+\tclosedir(dir);\n+}\n+\n+enum dumper {\n+\tDUMPER_MAIN,\n+\tDUMPER_WORKER,\n+\tDUMPER_SQPOLL,\n+};\n+\n+static void run_dumper(struct __test_metadata *const _metadata, bool sqpoll,\n+\t\t enum dumper dumper)\n+{\n+\tbool killed = false;\n+\tchar path[64], c;\n+\tint ipc[2], status, fd, ret;\n+\tpid_t pid, tid;\n+\n+\tASSERT_TRUE(set_core_pattern(\"/tmp/coredump.file.%p\"));\n+\tASSERT_EQ(pipe2(ipc, O_CLOEXEC), 0);\n+\n+\tpid = fork();\n+\tASSERT_GE(pid, 0);\n+\tif (pid == 0) {\n+\t\tclose(ipc[0]);\n+\t\tworker_child(sqpoll, ipc[1]);\n+\t}\n+\tclose(ipc[1]);\n+\tASSERT_EQ(read_nointr(ipc[0], \u0026c, 1), 1);\n+\tclose(ipc[0]);\n+\n+\tswitch (dumper) {\n+\tcase DUMPER_MAIN:\n+\t\ttid = pid;\n+\t\tbreak;\n+\tcase DUMPER_WORKER:\n+\t\ttid = find_thread(pid, \"iou-wrk-\");\n+\t\tbreak;\n+\tcase DUMPER_SQPOLL:\n+\t\ttid = find_thread(pid, \"iou-sqp-\");\n+\t\tbreak;\n+\t}\n+\tASSERT_GT(tid, 0);\n+\tret = inject_coredump_signal(pid, tid);\n+\tASSERT_GE(ret, 0);\n+\tif (!ret) {\n+\t\t/* The signal sits on the worker, the group must be untouched. */\n+\t\tASSERT_NE(dumper, DUMPER_MAIN);\n+\t\tTH_LOG(\"PTRACE_SETSIGMASK refused for tid %d, the SIGSEGV stays pending\", tid);\n+\t\tASSERT_EQ(wait_exit(pid, \u0026status, 1000), -1);\n+\t\tkill(pid, SIGKILL);\n+\t\tASSERT_EQ(wait_exit(pid, \u0026status, EXIT_TIMEOUT_MS), 0);\n+\t\tASSERT_TRUE(WIFSIGNALED(status));\n+\t\tASSERT_EQ(WTERMSIG(status), SIGKILL);\n+\t\treturn;\n+\t}\n+\n+\tif (wait_exit(pid, \u0026status, EXIT_TIMEOUT_MS)) {\n+\t\t/* No dump. Whatever happened, SIGKILL must still work. */\n+\t\tlog_threads(_metadata, pid);\n+\t\tkill(pid, SIGKILL);\n+\t\tkilled = true;\n+\t\tASSERT_EQ(wait_exit(pid, \u0026status, EXIT_TIMEOUT_MS), 0) {\n+\t\t\tTH_LOG(\"thread group %d is stuck after SIGSEGV to tid %d\",\n+\t\t\t pid, tid);\n+\t\t}\n+\t}\n+\n+\tASSERT_TRUE(WIFSIGNALED(status));\n+\tif (killed) {\n+\t\tTH_LOG(\"tid %d did not dump, the group was killed instead\", tid);\n+\t\tASSERT_EQ(WTERMSIG(status), SIGKILL);\n+\t\treturn;\n+\t}\n+\tASSERT_EQ(WTERMSIG(status), SIGSEGV);\n+\tASSERT_TRUE(WCOREDUMP(status));\n+\n+\tsnprintf(path, sizeof(path), \"/tmp/coredump.file.%d\", pid);\n+\tfd = open(path, O_RDONLY | O_CLOEXEC);\n+\tunlink(path);\n+\tASSERT_GE(fd, 0);\n+\tASSERT_TRUE(check_coredump_extent(fd));\n+\tclose(fd);\n+}\n+\n+/* The mechanics: an injected SIGSEGV into a normal thread dumps core. */\n+TEST_F(coredump, main_thread_dumper)\n+{\n+\tif (!uring_available(0))\n+\t\tSKIP(return, \"io_uring is not available\");\n+\trun_dumper(_metadata, false, DUMPER_MAIN);\n+}\n+\n+TEST_F(coredump, plain_worker_dumper)\n+{\n+\tif (!uring_available(0))\n+\t\tSKIP(return, \"io_uring is not available\");\n+\trun_dumper(_metadata, false, DUMPER_WORKER);\n+}\n+\n+TEST_F(coredump, sqpoll_thread_dumper)\n+{\n+\tif (!uring_available(IORING_SETUP_SQPOLL))\n+\t\tSKIP(return, \"io_uring SQPOLL is not available\");\n+\trun_dumper(_metadata, true, DUMPER_SQPOLL);\n+}\n+\n+/*\n+ * The SQPOLL thread leaves its loop on the zap and waits for its io-wq\n+ * workers to exit before it parks. The dumping worker never does.\n+ */\n+TEST_F(coredump, sqpoll_worker_dumper)\n+{\n+\tif (!uring_available(IORING_SETUP_SQPOLL))\n+\t\tSKIP(return, \"io_uring SQPOLL is not available\");\n+\trun_dumper(_metadata, true, DUMPER_WORKER);\n+}\n+\n+TEST_HARNESS_MAIN\n"
} |
| 2/1 | 2026/09/23 11:34 | agent | patch-evaluator |
3mModel:core Args: null Results: {
"EnableConfigs": [
"COREDUMP",
"IO_URING",
"SYSCTL",
"UNIX"
],
"FocusSymbols": [
"vfs_coredump",
"coredump_signal_pending",
"proc_dostring_coredump",
"create_io_thread",
"io_wq_exit_start",
"close_cloexec_files",
"ptrace_request",
"__set_current_blocked"
],
"Reasoning": "The patch series modifies core kernel subsystems including coredump handling, signal retargeting, io_uring worker thread lifecycle, ptrace restrictions, and file descriptor teardown. It adds synchronization via spinlocks and barriers, reverses the fd closing order in close_files/close_cloexec_files, introduces a new runtime assertion (WARN_ON_ONCE) in __set_task_blocked, and restructures coredump/io_uring cancellation. All changes are in highly reachable code paths and warrant fuzzing.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 992c6a755e67237899965b09325acaeaceeef2ea
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Sep 23 11:34:41 2026 +0000
syz-cluster: applied patch under review
diff --git a/fs/coredump.c b/fs/coredump.c
index 16b331b686fbe..d5d76704df810 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -85,6 +85,8 @@ static int core_uses_pid;
static unsigned int core_pipe_limit;
static unsigned int core_sort_vma;
static char core_pattern[CORENAME_MAX_SIZE] = "core";
+/* Taken around every copy in and out of core_pattern. */
+static DEFINE_SPINLOCK(core_pattern_lock);
static int core_name_size = CORENAME_MAX_SIZE;
unsigned int core_file_note_size_limit = CORE_FILE_NOTE_SIZE_DEFAULT;
static atomic_t core_pipe_count = ATOMIC_INIT(0);
@@ -240,11 +242,16 @@ static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,
size_t **argv, int *argc)
{
const struct cred *cred = current_cred();
- const char *pat_ptr = core_pattern;
+ char pattern[CORENAME_MAX_SIZE];
+ const char *pat_ptr = pattern;
bool was_space = false;
int pid_in_pattern = 0;
int err = 0;
+ /* The sysctl handler may be publishing a new pattern. */
+ scoped_guard(spinlock, &core_pattern_lock)
+ strscpy(pattern, core_pattern);
+
cprm->mask = COREDUMP_KERNEL;
if (core_pipe_limit)
cprm->mask |= COREDUMP_WAIT;
@@ -561,6 +568,8 @@ static void coredump_finish(enum coredump_state state)
current->signal->core_state = NULL;
spin_unlock_irq(¤t->sighand->siglock);
+ /* A released thread may exit and be freed before it is woken. */
+ guard(rcu)();
while ((curr = next) != NULL) {
next = curr->next;
task = curr->task;
@@ -569,6 +578,7 @@ static void coredump_finish(enum coredump_state state)
* ->task == NULL before we read ->next.
*/
smp_mb();
+ /* Any wakeup now lets the thread exit, rcu keeps it alive. */
curr->task = NULL;
wake_up_process(task);
}
@@ -577,12 +587,13 @@ static void coredump_finish(enum coredump_state state)
static bool dump_interrupted(void)
{
/*
- * SIGKILL or freezing() interrupt the coredumping. Perhaps we
- * can do try_to_freeze() and check __fatal_signal_pending(),
- * but then we need to teach dump_write() to restart and clear
- * TIF_SIGPENDING.
+ * SIGKILL, freezing() or the cgroup v2 freezer trap interrupt the
+ * coredumping. Perhaps we can do try_to_freeze() and check
+ * __fatal_signal_pending(), but then we need to teach dump_write()
+ * to restart and clear TIF_SIGPENDING.
*/
- return fatal_signal_pending(current) || freezing(current);
+ return fatal_signal_pending(current) || freezing(current) ||
+ (READ_ONCE(current->jobctl) & JOBCTL_TRAP_FREEZE);
}
static void wait_for_dump_helpers(struct file *file)
@@ -1636,11 +1647,11 @@ void validate_coredump_safety(void)
}
}
-static inline bool check_coredump_socket(void)
+static inline bool check_coredump_socket(const char *pattern)
{
const char *p;
- if (core_pattern[0] != '@')
+ if (pattern[0] != '@')
return true;
/*
@@ -1652,16 +1663,16 @@ static inline bool check_coredump_socket(void)
return false;
/* Must be an absolute path... */
- if (core_pattern[1] != '/') {
+ if (pattern[1] != '/') {
/* ... or the socket request protocol... */
- if (core_pattern[1] != '@')
+ if (pattern[1] != '@')
return false;
/* ... and if so must be an absolute path. */
- if (core_pattern[2] != '/')
+ if (pattern[2] != '/')
return false;
- p = &core_pattern[2];
+ p = &pattern[2];
} else {
- p = &core_pattern[1];
+ p = &pattern[1];
}
/* The path obviously cannot exceed UNIX_PATH_MAX. */
@@ -1669,7 +1680,7 @@ static inline bool check_coredump_socket(void)
return false;
/* Must not contain ".." in the path. */
- if (name_contains_dotdot(core_pattern))
+ if (name_contains_dotdot(pattern))
return false;
return true;
@@ -1678,27 +1689,35 @@ static inline bool check_coredump_socket(void)
static int proc_dostring_coredump(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
+ char pattern[CORENAME_MAX_SIZE];
+ const struct ctl_table tmp = {
+ .procname = table->procname,
+ .data = pattern,
+ .maxlen = sizeof(pattern),
+ };
+ bool changed = false;
int error;
- ssize_t retval;
- char old_core_pattern[CORENAME_MAX_SIZE];
-
- if (!write)
- return proc_dostring(table, write, buffer, lenp, ppos);
- retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
+ /* Work on a copy, proc_dostring() appends at *ppos. */
+ scoped_guard(spinlock, &core_pattern_lock)
+ strscpy(pattern, core_pattern);
- error = proc_dostring(table, write, buffer, lenp, ppos);
- if (error)
+ error = proc_dostring(&tmp, write, buffer, lenp, ppos);
+ if (error || !write)
return error;
- if (!check_coredump_socket()) {
- strscpy(core_pattern, old_core_pattern, retval + 1);
+ if (!check_coredump_socket(pattern))
return -EINVAL;
- }
- if (strncmp(old_core_pattern, core_pattern, CORENAME_MAX_SIZE))
+ /* Publish the validated pattern whole. */
+ scoped_guard(spinlock, &core_pattern_lock) {
+ changed = strncmp(pattern, core_pattern, CORENAME_MAX_SIZE);
+ if (changed)
+ strscpy(core_pattern, pattern);
+ }
+ if (changed)
validate_coredump_safety();
- return error;
+ return 0;
}
static const unsigned int core_file_note_size_min = CORE_FILE_NOTE_SIZE_DEFAULT;
diff --git a/fs/exec.c b/fs/exec.c
index 075a744421e14..334e6d358c567 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1149,16 +1149,19 @@ int begin_new_exec(struct linux_binprm * bprm)
*/
bprm->point_of_no_return = true;
+ /*
+ * Cancel any io_uring activity across execve. This runs task work
+ * that may still create an io-wq worker, so do it while de_thread()
+ * can still zap it.
+ */
+ io_uring_task_cancel();
+
/* Make this the only thread in the thread group */
retval = de_thread(me);
if (retval)
goto out;
/* see the comment in check_unsafe_exec() */
current->fs->in_exec = 0;
- /*
- * Cancel any io_uring activity across execve
- */
- io_uring_task_cancel();
/* Ensure the files table is not shared. */
retval = unshare_fd(CLONE_FILES, &files);
diff --git a/fs/file.c b/fs/file.c
index 76e328edf6305..7f8d0afd8807a 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -497,24 +497,21 @@ static struct fdtable *close_files(struct files_struct *files)
* files structure.
*/
struct fdtable *fdt = rcu_dereference_raw(files->fdt);
- unsigned int i, j = 0;
+ unsigned int j = fdt->max_fds / BITS_PER_LONG;
+
+ /* Highest fd first, the order the deferred puts ran in. */
+ while (j--) {
+ unsigned long set = fdt->open_fds[j];
- for (;;) {
- unsigned long set;
- i = j * BITS_PER_LONG;
- if (i >= fdt->max_fds)
- break;
- set = fdt->open_fds[j++];
while (set) {
- if (set & 1) {
- struct file *file = fdt->fd[i];
- if (file) {
- filp_close_sync(file, files);
- cond_resched();
- }
+ unsigned int bit = __fls(set);
+ struct file *file = fdt->fd[j * BITS_PER_LONG + bit];
+
+ set ^= 1UL << bit;
+ if (file) {
+ filp_close_sync(file, files);
+ cond_resched();
}
- i++;
- set >>= 1;
}
}
@@ -801,10 +798,14 @@ static inline void __range_close(struct files_struct *files, unsigned int fd,
n = last_fd(fdt);
max_fd = min(max_fd, n);
- for (fd = find_next_bit(fdt->open_fds, max_fd + 1, fd);
- fd <= max_fd;
- fd = find_next_bit(fdt->open_fds, max_fd + 1, fd + 1)) {
- file = file_close_fd_locked(files, fd);
+ /* Highest fd first, see close_files(). */
+ for (n = max_fd + 1; n > fd; ) {
+ unsigned int cur = find_last_bit(fdt->open_fds, n);
+
+ if (cur >= n || cur < fd)
+ break;
+ n = cur;
+ file = file_close_fd_locked(files, cur);
if (file) {
spin_unlock(&files->file_lock);
filp_close_sync(file, files);
@@ -908,20 +909,22 @@ void close_cloexec_files(struct files_struct *files)
/* exec unshares first */
spin_lock(&files->file_lock);
- for (i = 0; ; i++) {
+ fdt = files_fdtable(files);
+ /* Highest fd first, see close_files(). */
+ for (i = fdt->max_fds / BITS_PER_LONG; i--; ) {
unsigned long set;
- unsigned fd = i * BITS_PER_LONG;
+
fdt = files_fdtable(files);
- if (fd >= fdt->max_fds)
- break;
set = fdt->close_on_exec[i];
if (!set)
continue;
fdt->close_on_exec[i] = 0;
- for ( ; set ; fd++, set >>= 1) {
+ while (set) {
+ unsigned int bit = __fls(set);
+ unsigned fd = i * BITS_PER_LONG + bit;
struct file *file;
- if (!(set & 1))
- continue;
+
+ set ^= 1UL << bit;
file = fdt->fd[fd];
if (!file)
continue;
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index e039e29cd8c58..3835fbf7d80f2 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -384,6 +384,13 @@ static inline int task_sigpending(struct task_struct *p)
return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
}
+static inline int __fatal_signal_pending(struct task_struct *p)
+{
+ return unlikely(sigismember(&p->pending.signal, SIGKILL));
+}
+
+bool coredump_signal_pending(struct task_struct *p);
+
static inline int signal_pending(struct task_struct *p)
{
/*
@@ -393,12 +400,12 @@ static inline int signal_pending(struct task_struct *p)
*/
if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL)))
return 1;
- return task_sigpending(p);
-}
-
-static inline int __fatal_signal_pending(struct task_struct *p)
-{
- return unlikely(sigismember(&p->pending.signal, SIGKILL));
+ if (!task_sigpending(p))
+ return 0;
+ /* A coredumping task only stops for SIGKILL or the freezer. */
+ if (unlikely(READ_ONCE(p->flags) & PF_DUMPCORE))
+ return coredump_signal_pending(p);
+ return 1;
}
static inline int fatal_signal_pending(struct task_struct *p)
diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index 2ca223e47d41f..2a980e86dd940 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -1324,6 +1324,8 @@ static bool io_task_work_match(struct callback_head *cb, void *data)
void io_wq_exit_start(struct io_wq *wq)
{
set_bit(IO_WQ_BIT_EXIT, &wq->state);
+ /* Pairs with task_work_add() in io_queue_worker_create(). */
+ smp_mb__after_atomic();
}
static void io_wq_cancel_tw_create(struct io_wq *wq)
diff --git a/kernel/exit.c b/kernel/exit.c
index 55dbea3b242e1..9ed5eb03d0e19 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1003,10 +1003,11 @@ void __noreturn do_exit(long code)
exit_sem(tsk);
exit_shm(tsk);
- exit_files(tsk);
- exit_fs(tsk);
+ /* Hang the tty up before the last close of it can clear the session. */
if (group_dead)
disassociate_ctty(1);
+ exit_files(tsk);
+ exit_fs(tsk);
exit_nsproxy_namespaces(tsk);
exit_task_work(tsk);
exit_thread(tsk);
diff --git a/kernel/fork.c b/kernel/fork.c
index 10be4a0ecb3f1..be5980d0dd9f3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1676,6 +1676,7 @@ static int copy_files(u64 clone_flags, struct task_struct *tsk,
if (clone_flags & CLONE_FILES) {
atomic_inc(&oldf->count);
+ tsk->files = oldf;
return 0;
}
@@ -2145,12 +2146,9 @@ __latent_entropy struct task_struct *copy_process(
if (args->kthread)
p->flags |= PF_KTHREAD;
if (args->user_worker) {
- /*
- * Mark us a user worker, and block any signal that isn't
- * fatal or STOP
- */
+ /* A user worker takes only the signals nobody can block. */
p->flags |= PF_USER_WORKER;
- siginitsetinv(&p->blocked, sigmask(SIGKILL)|sigmask(SIGSTOP));
+ siginitsetinv(&p->blocked, SIG_KERNEL_ONLY_MASK);
}
if (args->io_thread)
p->flags |= PF_IO_WORKER;
@@ -2199,6 +2197,8 @@ __latent_entropy struct task_struct *copy_process(
INIT_LIST_HEAD(&p->sibling);
rcu_copy_process(p);
p->vfork_done = NULL;
+ /* Set by copy_files(), exit_files() on the error path skips NULL. */
+ p->files = NULL;
spin_lock_init(&p->alloc_lock);
init_sigpending(&p->pending);
@@ -2300,7 +2300,7 @@ __latent_entropy struct task_struct *copy_process(
goto bad_fork_cleanup_semundo;
retval = copy_fs(clone_flags, p, args->umh);
if (retval)
- goto bad_fork_cleanup_files;
+ goto bad_fork_cleanup_semundo;
retval = copy_sighand(clone_flags, p);
if (retval)
goto bad_fork_cleanup_fs;
@@ -2613,8 +2613,6 @@ __latent_entropy struct task_struct *copy_process(
__cleanup_sighand(p->sighand);
bad_fork_cleanup_fs:
exit_fs(p); /* blocking */
-bad_fork_cleanup_files:
- exit_files(p); /* blocking */
bad_fork_cleanup_semundo:
exit_sem(p);
bad_fork_cleanup_security:
@@ -2625,6 +2623,8 @@ __latent_entropy struct task_struct *copy_process(
perf_event_free_task(p);
bad_fork_sched_cancel_fork:
sched_cancel_fork(p);
+ /* ->release() of a file may need scx_fork_rwsem for write. */
+ exit_files(p); /* blocking */
bad_fork_cleanup_policy:
lockdep_free_task(p);
#ifdef CONFIG_NUMA
@@ -2703,6 +2703,10 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)
.user_worker = 1,
};
+ /* A creator past its fatal signal or its coredump point gets no thread. */
+ if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP))
+ return ERR_PTR(-EINTR);
+
return copy_process(NULL, 0, node, &args);
}
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d041645d9d17d..4e9822a87aabb 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1227,6 +1227,12 @@ int ptrace_request(struct task_struct *child, long request,
case PTRACE_SETSIGMASK: {
sigset_t new_set;
+ /* A user worker only ever takes SIGKILL and SIGSTOP. */
+ if (child->flags & PF_USER_WORKER) {
+ ret = -EPERM;
+ break;
+ }
+
if (addr != sizeof(sigset_t)) {
ret = -EINVAL;
break;
diff --git a/kernel/signal.c b/kernel/signal.c
index ec30550951ecf..137002445b0dc 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -717,6 +717,14 @@ void signal_wake_up_state(struct task_struct *t, unsigned int state)
kick_process(t);
}
+/* Only SIGKILL or a freezer interrupt a coredump, see dump_interrupted(). */
+bool coredump_signal_pending(struct task_struct *p)
+{
+ return __fatal_signal_pending(p) || freezing(p) ||
+ (READ_ONCE(p->jobctl) & JOBCTL_TRAP_FREEZE);
+}
+EXPORT_SYMBOL(coredump_signal_pending);
+
static inline void posixtimer_sig_ignore(struct task_struct *tsk, struct sigqueue *q);
static void sigqueue_free_ignored(struct task_struct *tsk, struct sigqueue *q)
@@ -3109,6 +3117,10 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
sigset_t retarget;
struct task_struct *t;
+ /* Nobody dequeues them in a dying group, see get_signal(). */
+ if (tsk->signal->flags & SIGNAL_GROUP_EXIT)
+ return;
+
sigandsets(&retarget, &tsk->signal->shared_pending.signal, which);
if (sigisemptyset(&retarget))
return;
@@ -3200,6 +3212,16 @@ long do_no_restart_syscall(struct restart_block *param)
static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)
{
+ sigset_t floor, floored;
+
+ /* A user worker never unblocks anything but SIGKILL and SIGSTOP. */
+ if (unlikely(tsk->flags & PF_USER_WORKER)) {
+ siginitsetinv(&floor, SIG_KERNEL_ONLY_MASK);
+ sigorsets(&floored, newset, &floor);
+ WARN_ON_ONCE(!sigequalsets(&floored, newset));
+ newset = &floored;
+ }
+
if (task_sigpending(tsk) && !thread_group_empty(tsk)) {
sigset_t newblocked;
/* A set of now blocked but previously unblocked signals. */
diff --git a/tools/testing/selftests/coredump/.gitignore b/tools/testing/selftests/coredump/.gitignore
index 097f52db0be96..e32f6e9006f6e 100644
--- a/tools/testing/selftests/coredump/.gitignore
+++ b/tools/testing/selftests/coredump/.gitignore
@@ -2,3 +2,5 @@
stackdump_test
coredump_socket_test
coredump_socket_protocol_test
+coredump_signal_test
+coredump_worker_test
diff --git a/tools/testing/selftests/coredump/Makefile b/tools/testing/selftests/coredump/Makefile
index dece1a31d561b..57ec331f03a76 100644
--- a/tools/testing/selftests/coredump/Makefile
+++ b/tools/testing/selftests/coredump/Makefile
@@ -3,7 +3,9 @@ CFLAGS += -Wall -O0 -g $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
TEST_GEN_PROGS := stackdump_test \
coredump_socket_test \
- coredump_socket_protocol_test
+ coredump_socket_protocol_test \
+ coredump_signal_test \
+ coredump_worker_test
TEST_FILES := stackdump
include ../lib.mk
@@ -11,3 +13,5 @@ include ../lib.mk
$(OUTPUT)/stackdump_test: coredump_test_helpers.c
$(OUTPUT)/coredump_socket_test: coredump_test_helpers.c
$(OUTPUT)/coredump_socket_protocol_test: coredump_test_helpers.c
+$(OUTPUT)/coredump_signal_test: coredump_test_helpers.c
+$(OUTPUT)/coredump_worker_test: coredump_test_helpers.c
diff --git a/tools/testing/selftests/coredump/coredump_signal_test.c b/tools/testing/selftests/coredump/coredump_signal_test.c
new file mode 100644
index 0000000000000..fdf48b1447811
--- /dev/null
+++ b/tools/testing/selftests/coredump/coredump_signal_test.c
@@ -0,0 +1,238 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+#include "coredump_test.h"
+
+/* Big enough to fill the socket buffer many times over. */
+#define CRASH_MAPPING_SIZE (32 * 1024 * 1024)
+
+FIXTURE_SETUP(coredump)
+{
+ FILE *file;
+ int ret;
+
+ self->pid_coredump_server = -ESRCH;
+ self->fd_tmpfs_detached = -1;
+ file = fopen("/proc/sys/kernel/core_pattern", "r");
+ ASSERT_NE(NULL, file);
+
+ ret = fread(self->original_core_pattern, 1, sizeof(self->original_core_pattern), file);
+ ASSERT_TRUE(ret || feof(file));
+ ASSERT_LT(ret, sizeof(self->original_core_pattern));
+
+ self->original_core_pattern[ret] = '\0';
+
+ ret = fclose(file);
+ ASSERT_EQ(0, ret);
+}
+
+FIXTURE_TEARDOWN(coredump)
+{
+ const char *reason;
+ FILE *file;
+ int ret, status;
+
+ if (self->pid_coredump_server > 0) {
+ kill(self->pid_coredump_server, SIGTERM);
+ waitpid(self->pid_coredump_server, &status, 0);
+ }
+ unlink("/tmp/coredump.file");
+ unlink("/tmp/coredump.socket");
+
+ file = fopen("/proc/sys/kernel/core_pattern", "w");
+ if (!file) {
+ reason = "Unable to open core_pattern";
+ goto fail;
+ }
+
+ ret = fprintf(file, "%s", self->original_core_pattern);
+ if (ret < 0) {
+ reason = "Unable to write to core_pattern";
+ goto fail;
+ }
+
+ ret = fclose(file);
+ if (ret) {
+ reason = "Unable to close core_pattern";
+ goto fail;
+ }
+
+ return;
+fail:
+ /* This should never happen */
+ fprintf(stderr, "Failed to cleanup coredump test: %s\n", reason);
+}
+
+static volatile int waiter_ready;
+
+static void usr1_handler(int sig)
+{
+}
+
+/* Sleeps in sigtimedwait() with SIGUSR1 unblocked only inside the kernel. */
+static void *sigwaiter(void *arg)
+{
+ sigset_t set;
+ siginfo_t info;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGUSR1);
+ __atomic_store_n(&waiter_ready, 1, __ATOMIC_RELEASE);
+ for (;;)
+ sigtimedwait(&set, &info, NULL);
+ return NULL;
+}
+
+/*
+ * Crash with a shared SIGUSR1 still queued for this thread. The vfork()
+ * child queues it while we sleep killably and then the SIGSEGV that is
+ * dequeued first. The zap wakes the sibling out of sigtimedwait() and its
+ * mask restore retargets SIGUSR1 to the dumper.
+ */
+static void crashing_child_retarget(bool queue_shared)
+{
+ sigset_t all, old;
+ pthread_t thread;
+ pid_t pid, tid;
+ char *p;
+
+ p = mmap(NULL, CRASH_MAPPING_SIZE, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED)
+ _exit(EXIT_FAILURE);
+ memset(p, 0x5a, CRASH_MAPPING_SIZE);
+
+ signal(SIGUSR1, usr1_handler);
+ sigfillset(&all);
+ pthread_sigmask(SIG_BLOCK, &all, &old);
+ /* One waiter only, retarget stops at the first thread not blocking it. */
+ if (pthread_create(&thread, NULL, sigwaiter, NULL))
+ _exit(EXIT_FAILURE);
+ pthread_sigmask(SIG_SETMASK, &old, NULL);
+ while (!__atomic_load_n(&waiter_ready, __ATOMIC_ACQUIRE))
+ usleep(1000);
+ usleep(50 * 1000);
+
+ pid = getpid();
+ tid = syscall(SYS_gettid);
+ if (vfork() == 0) {
+ if (queue_shared)
+ syscall(SYS_kill, pid, SIGUSR1);
+ syscall(SYS_tgkill, pid, tid, SIGSEGV);
+ syscall(SYS_exit, 0);
+ }
+
+ /* Not reached, the pending SIGSEGV dumps core. */
+ for (;;)
+ pause();
+}
+
+/*
+ * Dump the crashing child into /tmp/coredump.file through a server that
+ * holds the read back so the dumper blocks on the full socket buffer.
+ */
+static void run_coredump(struct __test_metadata *const _metadata,
+ FIXTURE_DATA(coredump) *self, bool queue_shared)
+{
+ pid_t pid, pid_coredump_server;
+ int ipc_sockets[2];
+ int status;
+ char c;
+
+ unlink("/tmp/coredump.file");
+ unlink("/tmp/coredump.socket");
+ ASSERT_TRUE(set_core_pattern("@/tmp/coredump.socket"));
+ ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, ipc_sockets), 0);
+
+ pid_coredump_server = fork();
+ ASSERT_GE(pid_coredump_server, 0);
+ if (pid_coredump_server == 0) {
+ int fd_server = -1, fd_coredump = -1, fd_core_file = -1;
+ int exit_code = EXIT_FAILURE;
+
+ close(ipc_sockets[0]);
+
+ fd_server = create_and_listen_unix_socket("/tmp/coredump.socket");
+ if (fd_server < 0)
+ goto out;
+
+ if (write_nointr(ipc_sockets[1], "1", 1) < 0)
+ goto out;
+ close(ipc_sockets[1]);
+
+ fd_coredump = accept4(fd_server, NULL, NULL, SOCK_CLOEXEC);
+ if (fd_coredump < 0) {
+ fprintf(stderr, "%s: accept4 failed: %m\n", __func__);
+ goto out;
+ }
+
+ /* Let the dumper run into the full socket buffer first. */
+ sleep(1);
+
+ fd_core_file = creat("/tmp/coredump.file", 0644);
+ if (fd_core_file < 0) {
+ fprintf(stderr, "%s: creat failed: %m\n", __func__);
+ goto out;
+ }
+
+ if (recv_coredump_bytes(fd_coredump, fd_core_file) < 0)
+ goto out;
+
+ exit_code = EXIT_SUCCESS;
+out:
+ if (fd_core_file >= 0)
+ close(fd_core_file);
+ if (fd_coredump >= 0)
+ close(fd_coredump);
+ if (fd_server >= 0)
+ close(fd_server);
+ _exit(exit_code);
+ }
+ self->pid_coredump_server = pid_coredump_server;
+
+ EXPECT_EQ(close(ipc_sockets[1]), 0);
+ ASSERT_EQ(read_nointr(ipc_sockets[0], &c, 1), 1);
+ EXPECT_EQ(close(ipc_sockets[0]), 0);
+
+ pid = fork();
+ ASSERT_GE(pid, 0);
+ if (pid == 0)
+ crashing_child_retarget(queue_shared);
+
+ waitpid(pid, &status, 0);
+ ASSERT_TRUE(WIFSIGNALED(status));
+ ASSERT_EQ(WTERMSIG(status), SIGSEGV);
+ ASSERT_TRUE(WCOREDUMP(status));
+
+ wait_and_check_coredump_server(pid_coredump_server, _metadata, self);
+}
+
+static void check_coredump_complete(struct __test_metadata *const _metadata)
+{
+ int fd;
+
+ fd = open("/tmp/coredump.file", O_RDONLY | O_CLOEXEC);
+ ASSERT_GE(fd, 0);
+ ASSERT_TRUE(check_coredump_extent(fd));
+ close(fd);
+}
+
+TEST_F(coredump, retarget_shared_pending)
+{
+ run_coredump(_metadata, self, false);
+ check_coredump_complete(_metadata);
+
+ run_coredump(_metadata, self, true);
+ check_coredump_complete(_metadata);
+}
+
+TEST_HARNESS_MAIN
diff --git a/tools/testing/selftests/coredump/coredump_worker_test.c b/tools/testing/selftests/coredump/coredump_worker_test.c
new file mode 100644
index 0000000000000..9a4270b65a6e6
--- /dev/null
+++ b/tools/testing/selftests/coredump/coredump_worker_test.c
@@ -0,0 +1,447 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * A user worker as the coredumping thread.
+ *
+ * io-wq workers and SQPOLL threads are threads of the process that never
+ * return to userspace. They block every signal but SIGKILL and SIGSTOP,
+ * but a tracer can replace that mask with PTRACE_SETSIGMASK and inject a
+ * coredump signal. get_signal() then runs vfs_coredump() in the worker.
+ * The worker's own exit bookkeeping runs only after the dump, so a
+ * zapped sibling that waits for it in its exit path deadlocks with the
+ * dumper and the whole thread group is stuck in D state.
+ *
+ * Inject SIGSEGV into a chosen thread and require that the thread group
+ * is gone in bounded time, either because the dump completed or because
+ * SIGKILL still works. A failure leaves the stuck process behind.
+ */
+#include <ctype.h>
+#include <errno.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/ptrace.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <linux/io_uring.h>
+
+#include "coredump_test.h"
+
+#ifndef PTRACE_SETSIGMASK
+#define PTRACE_SETSIGMASK 0x420b
+#endif
+
+/* The dump of the tiny child takes well under a second. */
+#define EXIT_TIMEOUT_MS 5000
+
+FIXTURE_SETUP(coredump)
+{
+ FILE *file;
+ int ret;
+
+ self->pid_coredump_server = -ESRCH;
+ self->fd_tmpfs_detached = -1;
+ file = fopen("/proc/sys/kernel/core_pattern", "r");
+ ASSERT_NE(NULL, file);
+
+ ret = fread(self->original_core_pattern, 1, sizeof(self->original_core_pattern), file);
+ ASSERT_TRUE(ret || feof(file));
+ ASSERT_LT(ret, sizeof(self->original_core_pattern));
+
+ self->original_core_pattern[ret] = '\0';
+
+ ret = fclose(file);
+ ASSERT_EQ(0, ret);
+}
+
+FIXTURE_TEARDOWN(coredump)
+{
+ const char *reason;
+ FILE *file;
+ int ret;
+
+ file = fopen("/proc/sys/kernel/core_pattern", "w");
+ if (!file) {
+ reason = "Unable to open core_pattern";
+ goto fail;
+ }
+
+ ret = fprintf(file, "%s", self->original_core_pattern);
+ if (ret < 0) {
+ reason = "Unable to write to core_pattern";
+ goto fail;
+ }
+
+ ret = fclose(file);
+ if (ret) {
+ reason = "Unable to close core_pattern";
+ goto fail;
+ }
+
+ return;
+fail:
+ /* This should never happen */
+ fprintf(stderr, "Failed to cleanup coredump test: %s\n", reason);
+}
+
+/* A raw ring, no liburing. */
+struct uring {
+ int fd;
+ struct io_uring_params params;
+ void *sq;
+ size_t sq_len;
+ struct io_uring_sqe *sqes;
+ size_t sqes_len;
+ unsigned int *sq_tail, *sq_mask, *sq_array;
+ unsigned int *cq_head, *cq_tail, *cq_mask;
+ struct io_uring_cqe *cqes;
+};
+
+static int uring_setup(struct uring *r, unsigned int flags)
+{
+ size_t cq_len;
+
+ memset(r, 0, sizeof(*r));
+ r->params.flags = flags;
+ if (flags & IORING_SETUP_SQPOLL)
+ r->params.sq_thread_idle = 2000;
+ r->fd = syscall(__NR_io_uring_setup, 8, &r->params);
+ if (r->fd < 0)
+ return -1;
+ if (!(r->params.features & IORING_FEAT_SINGLE_MMAP))
+ return -1;
+
+ r->sq_len = r->params.sq_off.array + r->params.sq_entries * sizeof(unsigned int);
+ cq_len = r->params.cq_off.cqes + r->params.cq_entries * sizeof(struct io_uring_cqe);
+ if (cq_len > r->sq_len)
+ r->sq_len = cq_len;
+ r->sq = mmap(NULL, r->sq_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_POPULATE, r->fd, IORING_OFF_SQ_RING);
+ if (r->sq == MAP_FAILED)
+ return -1;
+ r->sqes_len = r->params.sq_entries * sizeof(struct io_uring_sqe);
+ r->sqes = mmap(NULL, r->sqes_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_POPULATE, r->fd, IORING_OFF_SQES);
+ if (r->sqes == MAP_FAILED)
+ return -1;
+
+ r->sq_tail = r->sq + r->params.sq_off.tail;
+ r->sq_mask = r->sq + r->params.sq_off.ring_mask;
+ r->sq_array = r->sq + r->params.sq_off.array;
+ r->cq_head = r->sq + r->params.cq_off.head;
+ r->cq_tail = r->sq + r->params.cq_off.tail;
+ r->cq_mask = r->sq + r->params.cq_off.ring_mask;
+ r->cqes = r->sq + r->params.cq_off.cqes;
+ return 0;
+}
+
+/* Submit one sqe, wait for its completion and return the result. */
+static int uring_submit_wait(struct uring *r, const struct io_uring_sqe *sqe)
+{
+ unsigned int tail = *r->sq_tail, idx = tail & *r->sq_mask;
+ unsigned int flags = IORING_ENTER_GETEVENTS;
+ int i;
+
+ r->sqes[idx] = *sqe;
+ r->sq_array[idx] = idx;
+ __atomic_store_n(r->sq_tail, tail + 1, __ATOMIC_RELEASE);
+
+ if (r->params.flags & IORING_SETUP_SQPOLL)
+ flags |= IORING_ENTER_SQ_WAKEUP;
+
+ for (i = 0; i < 100; i++) {
+ if (syscall(__NR_io_uring_enter, r->fd, 1, 1, flags, NULL, 0) < 0 &&
+ errno != EINTR)
+ return -1;
+ if (__atomic_load_n(r->cq_tail, __ATOMIC_ACQUIRE) != *r->cq_head) {
+ unsigned int head = *r->cq_head;
+ int res = r->cqes[head & *r->cq_mask].res;
+
+ __atomic_store_n(r->cq_head, head + 1, __ATOMIC_RELEASE);
+ return res;
+ }
+ flags &= ~IORING_ENTER_SQ_WAKEUP;
+ usleep(10 * 1000);
+ }
+ return -1;
+}
+
+static bool uring_available(unsigned int flags)
+{
+ struct io_uring_params params = { .flags = flags };
+ int fd;
+
+ fd = syscall(__NR_io_uring_setup, 2, ¶ms);
+ if (fd < 0)
+ return false;
+ close(fd);
+ return true;
+}
+
+/*
+ * Keep a ring, an idle io-wq worker and with SQPOLL an SQPOLL thread
+ * alive. The last worker of a ring never exits on its idle timeout.
+ */
+static void worker_child(bool sqpoll, int fd_ipc)
+{
+ struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+ struct io_uring_sqe sqe = {};
+ static char buf[64];
+ struct uring ring;
+ int memfd;
+
+ if (setrlimit(RLIMIT_CORE, &rl))
+ _exit(EXIT_FAILURE);
+
+ memfd = memfd_create("coredump_worker", 0);
+ if (memfd < 0 || write(memfd, "hello", 5) != 5)
+ _exit(EXIT_FAILURE);
+
+ if (uring_setup(&ring, sqpoll ? IORING_SETUP_SQPOLL : 0))
+ _exit(EXIT_FAILURE);
+
+ /* IOSQE_ASYNC forces the read through io-wq so a worker appears. */
+ sqe.opcode = IORING_OP_READ;
+ sqe.fd = memfd;
+ sqe.addr = (__u64)(uintptr_t)buf;
+ sqe.len = sizeof(buf);
+ sqe.flags = IOSQE_ASYNC;
+ if (uring_submit_wait(&ring, &sqe) != 5)
+ _exit(EXIT_FAILURE);
+
+ if (write_nointr(fd_ipc, "1", 1) != 1)
+ _exit(EXIT_FAILURE);
+ close(fd_ipc);
+
+ for (;;)
+ pause();
+}
+
+/* Find the thread of @pid whose comm starts with @prefix. */
+static pid_t find_thread(pid_t pid, const char *prefix)
+{
+ char path[64], comm[64];
+ pid_t tid = -1;
+ struct dirent *de;
+ ssize_t bytes;
+ DIR *dir;
+ int fd;
+
+ snprintf(path, sizeof(path), "/proc/%d/task", pid);
+ dir = opendir(path);
+ if (!dir)
+ return -1;
+
+ while (tid < 0 && (de = readdir(dir))) {
+ if (!isdigit(de->d_name[0]))
+ continue;
+ snprintf(path, sizeof(path), "/proc/%d/task/%s/comm", pid, de->d_name);
+ fd = open(path, O_RDONLY | O_CLOEXEC);
+ if (fd < 0)
+ continue;
+ bytes = read(fd, comm, sizeof(comm) - 1);
+ close(fd);
+ if (bytes <= 0)
+ continue;
+ comm[bytes] = '\0';
+ if (!strncmp(comm, prefix, strlen(prefix)))
+ tid = atoi(de->d_name);
+ }
+ closedir(dir);
+ return tid;
+}
+
+/*
+ * Attach, stop the thread with SIGSTOP, drop the signal mask that
+ * copy_process() gave it and resume it with SIGSEGV. Returns 1 when the
+ * mask was changed, 0 when PTRACE_SETSIGMASK was refused (a user worker
+ * keeps its mask and the SIGSEGV stays pending), -1 on any other failure.
+ */
+static int inject_coredump_signal(pid_t pid, pid_t tid)
+{
+ __u64 mask = 0;
+ int status, ret = 1;
+
+ if (ptrace(PTRACE_SEIZE, tid, NULL, NULL))
+ return -1;
+ if (syscall(SYS_tgkill, pid, tid, SIGSTOP))
+ return -1;
+ if (waitpid(tid, &status, __WALL) != tid)
+ return -1;
+ if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
+ return -1;
+ if (ptrace(PTRACE_SETSIGMASK, tid, sizeof(mask), &mask)) {
+ if (errno != EPERM)
+ return -1;
+ ret = 0;
+ }
+ if (ptrace(PTRACE_DETACH, tid, NULL, (void *)(long)SIGSEGV))
+ return -1;
+ return ret;
+}
+
+/* Reap @pid within @timeout_ms, -1 when it is still there. */
+static int wait_exit(pid_t pid, int *status, int timeout_ms)
+{
+ int i;
+
+ for (i = 0; i < timeout_ms / 10; i++) {
+ pid_t ret = waitpid(pid, status, WNOHANG);
+
+ if (ret == pid)
+ return 0;
+ if (ret < 0)
+ return -1;
+ usleep(10 * 1000);
+ }
+ return -1;
+}
+
+static void log_threads(struct __test_metadata *const _metadata, pid_t pid)
+{
+ char path[64], line[256], comm[64] = {};
+ struct dirent *de;
+ DIR *dir;
+ FILE *f;
+
+ snprintf(path, sizeof(path), "/proc/%d/task", pid);
+ dir = opendir(path);
+ if (!dir)
+ return;
+ while ((de = readdir(dir))) {
+ if (!isdigit(de->d_name[0]))
+ continue;
+ snprintf(path, sizeof(path), "/proc/%d/task/%s/status", pid, de->d_name);
+ f = fopen(path, "r");
+ if (!f)
+ continue;
+ while (fgets(line, sizeof(line), f)) {
+ line[strcspn(line, "\n")] = '\0';
+ if (!strncmp(line, "Name:", 5))
+ snprintf(comm, sizeof(comm), "%s", line + 6);
+ else if (!strncmp(line, "State:", 6))
+ TH_LOG("tid %s (%s) %s", de->d_name, comm, line + 7);
+ }
+ fclose(f);
+ }
+ closedir(dir);
+}
+
+enum dumper {
+ DUMPER_MAIN,
+ DUMPER_WORKER,
+ DUMPER_SQPOLL,
+};
+
+static void run_dumper(struct __test_metadata *const _metadata, bool sqpoll,
+ enum dumper dumper)
+{
+ bool killed = false;
+ char path[64], c;
+ int ipc[2], status, fd, ret;
+ pid_t pid, tid;
+
+ ASSERT_TRUE(set_core_pattern("/tmp/coredump.file.%p"));
+ ASSERT_EQ(pipe2(ipc, O_CLOEXEC), 0);
+
+ pid = fork();
+ ASSERT_GE(pid, 0);
+ if (pid == 0) {
+ close(ipc[0]);
+ worker_child(sqpoll, ipc[1]);
+ }
+ close(ipc[1]);
+ ASSERT_EQ(read_nointr(ipc[0], &c, 1), 1);
+ close(ipc[0]);
+
+ switch (dumper) {
+ case DUMPER_MAIN:
+ tid = pid;
+ break;
+ case DUMPER_WORKER:
+ tid = find_thread(pid, "iou-wrk-");
+ break;
+ case DUMPER_SQPOLL:
+ tid = find_thread(pid, "iou-sqp-");
+ break;
+ }
+ ASSERT_GT(tid, 0);
+ ret = inject_coredump_signal(pid, tid);
+ ASSERT_GE(ret, 0);
+ if (!ret) {
+ /* The signal sits on the worker, the group must be untouched. */
+ ASSERT_NE(dumper, DUMPER_MAIN);
+ TH_LOG("PTRACE_SETSIGMASK refused for tid %d, the SIGSEGV stays pending", tid);
+ ASSERT_EQ(wait_exit(pid, &status, 1000), -1);
+ kill(pid, SIGKILL);
+ ASSERT_EQ(wait_exit(pid, &status, EXIT_TIMEOUT_MS), 0);
+ ASSERT_TRUE(WIFSIGNALED(status));
+ ASSERT_EQ(WTERMSIG(status), SIGKILL);
+ return;
+ }
+
+ if (wait_exit(pid, &status, EXIT_TIMEOUT_MS)) {
+ /* No dump. Whatever happened, SIGKILL must still work. */
+ log_threads(_metadata, pid);
+ kill(pid, SIGKILL);
+ killed = true;
+ ASSERT_EQ(wait_exit(pid, &status, EXIT_TIMEOUT_MS), 0) {
+ TH_LOG("thread group %d is stuck after SIGSEGV to tid %d",
+ pid, tid);
+ }
+ }
+
+ ASSERT_TRUE(WIFSIGNALED(status));
+ if (killed) {
+ TH_LOG("tid %d did not dump, the group was killed instead", tid);
+ ASSERT_EQ(WTERMSIG(status), SIGKILL);
+ return;
+ }
+ ASSERT_EQ(WTERMSIG(status), SIGSEGV);
+ ASSERT_TRUE(WCOREDUMP(status));
+
+ snprintf(path, sizeof(path), "/tmp/coredump.file.%d", pid);
+ fd = open(path, O_RDONLY | O_CLOEXEC);
+ unlink(path);
+ ASSERT_GE(fd, 0);
+ ASSERT_TRUE(check_coredump_extent(fd));
+ close(fd);
+}
+
+/* The mechanics: an injected SIGSEGV into a normal thread dumps core. */
+TEST_F(coredump, main_thread_dumper)
+{
+ if (!uring_available(0))
+ SKIP(return, "io_uring is not available");
+ run_dumper(_metadata, false, DUMPER_MAIN);
+}
+
+TEST_F(coredump, plain_worker_dumper)
+{
+ if (!uring_available(0))
+ SKIP(return, "io_uring is not available");
+ run_dumper(_metadata, false, DUMPER_WORKER);
+}
+
+TEST_F(coredump, sqpoll_thread_dumper)
+{
+ if (!uring_available(IORING_SETUP_SQPOLL))
+ SKIP(return, "io_uring SQPOLL is not available");
+ run_dumper(_metadata, true, DUMPER_SQPOLL);
+}
+
+/*
+ * The SQPOLL thread leaves its loop on the zap and waits for its io-wq
+ * workers to exit before it parks. The dumping worker never does.
+ */
+TEST_F(coredump, sqpoll_worker_dumper)
+{
+ if (!uring_available(IORING_SETUP_SQPOLL))
+ SKIP(return, "io_uring SQPOLL is not available");
+ run_dumper(_metadata, true, DUMPER_WORKER);
+}
+
+TEST_HARNESS_MAIN
|
| 3/2 | 2026/09/23 11:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17077 output: 29 thoughts: 1585 Thoughts: **Patch Analysis and Fuzzing Strategy** Okay, let's break this down. This patch series is hitting a *lot* of core areas – file systems, signals, process lifecycle, and io_uring. This means high reachability and a strong potential for uncovering regressions or new bugs, making it a prime candidate for fuzzing. The changes are broad enough that I'd say "WorthFuzzing = true" without a doubt. Specifically, I see modifications to: * **VFS/Core File Handling:** `fs/coredump.c`, `fs/exec.c`, `fs/file.c` are all affected. We have changes to how coredumps are handled, file descriptors closed (a big red flag!), and execution is initialized. * **Signal Handling:** Changes in `kernel/signal.c`, `include/linux/sched/signal.h` concerning signal delivery, pending signals, and coredumps are present. * **Process Lifecycle:** `kernel/exit.c`, `kernel/fork.c`, `kernel/ptrace.c` see modifications to `fork`, `exit`, `ptrace`, and the interactions with the file system. These touch extremely fundamental operations. * **io_uring:** `io_uring/io-wq.c` is updated, potentially altering I/O worker behavior. The introduction of assertions like `WARN_ON_ONCE` always grabs my attention. Those are direct indicators of code that the developers were concerned about. Now, concerning the "FocusSymbols": I need to be *precise* here. Avoiding ubiquitous functions is critical. I'm seeing changes to functions like `coredump_parse`, `coredump_finish`, `dump_interrupted`, `proc_dostring_coredump`, `close_files`, and `copy_process`. We need to avoid listing high level common functions, and instead focus on the specific changes to *those* functions and their callers. My immediate question is: what are the *non-static* or exported functions in `fs/coredump.c` that call these functions? I need to understand the entry points. I'll be reaching for `grepper` (or similar tools) to quickly explore `fs/coredump.c` and other touched files to identify those important caller functions or entrypoints. Then I'll focus my symbols on those specific, modified entry points. We're looking for feature-specific entry points and logic, not generic system calls like `fork` itself. |
| 4/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "coredump_",
"PathPrefix": "fs/coredump.c"
}Results: {
"Output": "fs/coredump.c-68-\nfs/coredump.c:69:static bool dump_vma_snapshot(struct coredump_params *cprm);\nfs/coredump.c:70:static void free_vma_snapshot(struct coredump_params *cprm);\nfs/coredump.c:71:static void dump_end_record(struct coredump_params *cprm);\nfs/coredump.c:72:static bool dump_flush_skip(struct coredump_params *cprm);\nfs/coredump.c-73-\n--\nfs/coredump.c=92=static atomic_t core_pipe_count = ATOMIC_INIT(0);\nfs/coredump.c-93-\nfs/coredump.c:94:enum coredump_type_t {\nfs/coredump.c-95-\tCOREDUMP_FILE\t\t= 1,\n--\nfs/coredump.c=101=struct core_name {\n--\nfs/coredump.c-104-\tunsigned int core_pipe_limit;\nfs/coredump.c:105:\tenum coredump_type_t core_type;\nfs/coredump.c-106-};\n--\nfs/coredump.c=200=static int cn_print_exe_file(struct core_name *cn, bool name_only)\n--\nfs/coredump.c-236-/*\nfs/coredump.c:237: * coredump_parse will inspect the pattern parameter, and output a name\nfs/coredump.c-238- * into corename, which must have space for at least CORENAME_MAX_SIZE\n--\nfs/coredump.c-240- */\nfs/coredump.c:241:static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,\nfs/coredump.c-242-\t\t\t size_t **argv, int *argc)\n--\nfs/coredump.c-308-\t\tif (strchr(cn-\u003ecorename, ' ')) {\nfs/coredump.c:309:\t\t\tcoredump_report_failure(\"Coredump socket may not %s contain spaces\", cn-\u003ecorename);\nfs/coredump.c-310-\t\t\treturn false;\n--\nfs/coredump.c-314-\t\tif (name_contains_dotdot(cn-\u003ecorename)) {\nfs/coredump.c:315:\t\t\tcoredump_report_failure(\"Coredump socket may not %s contain '..' spaces\", cn-\u003ecorename);\nfs/coredump.c-316-\t\t\treturn false;\n--\nfs/coredump.c-319-\t\tif (strlen(cn-\u003ecorename) \u003e= UNIX_PATH_MAX) {\nfs/coredump.c:320:\t\t\tcoredump_report_failure(\"Coredump socket path %s too long\", cn-\u003ecorename);\nfs/coredump.c-321-\t\t\treturn false;\n--\nfs/coredump.c=510=static int zap_threads(struct task_struct *tsk,\n--\nfs/coredump.c-528-\nfs/coredump.c:529:static void coredump_wait_inactive(struct core_state *core_state)\nfs/coredump.c-530-{\n--\nfs/coredump.c-544-\nfs/coredump.c:545:static int coredump_wait(int exit_code, struct core_state *core_state)\nfs/coredump.c-546-{\n--\nfs/coredump.c-553-\tif (core_waiters \u003e 0)\nfs/coredump.c:554:\t\tcoredump_wait_inactive(core_state);\nfs/coredump.c-555-\n--\nfs/coredump.c-558-\nfs/coredump.c:559:static void coredump_finish(enum coredump_state state)\nfs/coredump.c-560-{\n--\nfs/coredump.c-576-\t\t/*\nfs/coredump.c:577:\t\t * see coredump_task_exit(), curr-\u003etask must not see\nfs/coredump.c-578-\t\t * -\u003etask == NULL before we read -\u003enext.\n--\nfs/coredump.c=599=static void wait_for_dump_helpers(struct file *file)\n--\nfs/coredump.c-622-/*\nfs/coredump.c:623: * umh_coredump_setup\nfs/coredump.c-624- * helper function to customize the process used\n--\nfs/coredump.c-632- */\nfs/coredump.c:633:static int umh_coredump_setup(struct subprocess_info *info, struct cred *new)\nfs/coredump.c-634-{\nfs/coredump.c-635-\tstruct file *files[2];\nfs/coredump.c:636:\tstruct coredump_params *cp = (struct coredump_params *)info-\u003edata;\nfs/coredump.c-637-\tint err;\n--\nfs/coredump.c-676-\nfs/coredump.c:677:static_assert(sizeof(struct coredump_record_header) == COREDUMP_RECORD_HEADER_SIZE_VER0);\nfs/coredump.c-678-\n--\nfs/coredump.c-682-\nfs/coredump.c:683:static bool coredump_sock_connect(struct core_name *cn, struct coredump_params *cprm)\nfs/coredump.c-684-{\n--\nfs/coredump.c-736-\t\tif (retval == -EAGAIN)\nfs/coredump.c:737:\t\t\tcoredump_report_failure(\"Coredump socket %s receive queue full\", addr.sun_path);\nfs/coredump.c-738-\t\telse\nfs/coredump.c:739:\t\t\tcoredump_report_failure(\"Coredump socket connection %s failed %d\", addr.sun_path, retval);\nfs/coredump.c-740-\t\treturn false;\n--\nfs/coredump.c-752-\nfs/coredump.c:753:static inline bool coredump_sock_recv(struct file *file, struct coredump_ack *ack, size_t size, int flags)\nfs/coredump.c-754-{\n--\nfs/coredump.c-763-\nfs/coredump.c:764:static inline bool coredump_sock_send(struct file *file, struct coredump_req *req)\nfs/coredump.c-765-{\n--\nfs/coredump.c-773-\nfs/coredump.c:774:static_assert(sizeof(struct coredump_req) == COREDUMP_REQ_SIZE_VER1);\nfs/coredump.c:775:static_assert(sizeof(struct coredump_ack) == COREDUMP_ACK_SIZE_VER1);\nfs/coredump.c:776:static_assert(sizeof(enum coredump_mark) == sizeof(__u32));\nfs/coredump.c-777-\n--\nfs/coredump.c=804=static_assert(COREDUMP_MEMORY_DAX_SHARED ==\n--\nfs/coredump.c-806-\nfs/coredump.c:807:static inline bool coredump_sock_mark(struct file *file, enum coredump_mark mark)\nfs/coredump.c-808-{\n--\nfs/coredump.c-816-\nfs/coredump.c:817:static inline void coredump_sock_wait(struct file *file)\nfs/coredump.c-818-{\n--\nfs/coredump.c-827-\tif (n \u003e 0)\nfs/coredump.c:828:\t\tcoredump_report_failure(\"Coredump socket had unexpected data\");\nfs/coredump.c-829-\telse if (n \u003c 0)\nfs/coredump.c:830:\t\tcoredump_report_failure(\"Coredump socket failed\");\nfs/coredump.c-831-}\nfs/coredump.c-832-\nfs/coredump.c:833:static inline void coredump_sock_shutdown(struct file *file)\nfs/coredump.c-834-{\n--\nfs/coredump.c-844-\nfs/coredump.c:845:static bool coredump_sock_request(struct core_name *cn, struct coredump_params *cprm)\nfs/coredump.c-846-{\nfs/coredump.c:847:\tstruct coredump_req req = {\nfs/coredump.c:848:\t\t.size\t\t\t= sizeof(struct coredump_req),\nfs/coredump.c-849-\t\t.mask\t\t\t= COREDUMP_KERNEL | COREDUMP_USERSPACE |\n--\nfs/coredump.c-852-\t\t\t\t\t COREDUMP_MEMORY_TYPES,\nfs/coredump.c:853:\t\t.size_ack\t\t= sizeof(struct coredump_ack),\nfs/coredump.c-854-\t\t.memory_types\t\t= cprm-\u003ememory_types,\n--\nfs/coredump.c-856-\t};\nfs/coredump.c:857:\tstruct coredump_ack ack = {};\nfs/coredump.c-858-\tssize_t usize;\n--\nfs/coredump.c-863-\t/* Let userspace know what we support. */\nfs/coredump.c:864:\tif (!coredump_sock_send(cprm-\u003efile, \u0026req))\nfs/coredump.c-865-\t\treturn false;\nfs/coredump.c-866-\nfs/coredump.c:867:\t/* Peek the size of the coredump_ack. */\nfs/coredump.c:868:\tif (!coredump_sock_recv(cprm-\u003efile, \u0026ack, sizeof(ack.size),\nfs/coredump.c-869-\t\t\t\tMSG_PEEK | MSG_WAITALL))\n--\nfs/coredump.c-871-\nfs/coredump.c:872:\t/* Refuse unknown coredump_ack sizes. */\nfs/coredump.c-873-\tusize = ack.size;\nfs/coredump.c-874-\tif (usize \u003c COREDUMP_ACK_SIZE_VER0) {\nfs/coredump.c:875:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_MINSIZE);\nfs/coredump.c-876-\t\treturn false;\n--\nfs/coredump.c-879-\tif (usize \u003e sizeof(ack)) {\nfs/coredump.c:880:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_MAXSIZE);\nfs/coredump.c-881-\t\treturn false;\n--\nfs/coredump.c-883-\nfs/coredump.c:884:\t/* Now retrieve the coredump_ack. */\nfs/coredump.c:885:\tif (!coredump_sock_recv(cprm-\u003efile, \u0026ack, usize, MSG_WAITALL))\nfs/coredump.c-886-\t\treturn false;\n--\nfs/coredump.c-889-\nfs/coredump.c:890:\t/* Refuse unknown coredump_ack flags. */\nfs/coredump.c-891-\tif (ack.mask \u0026 ~req.mask) {\nfs/coredump.c:892:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_UNSUPPORTED);\nfs/coredump.c-893-\t\treturn false;\n--\nfs/coredump.c-898-\t\t\t\t COREDUMP_REJECT)) != 1) {\nfs/coredump.c:899:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_CONFLICTING);\nfs/coredump.c-900-\t\treturn false;\n--\nfs/coredump.c-903-\tif (ack.spare) {\nfs/coredump.c:904:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_UNSUPPORTED);\nfs/coredump.c-905-\t\treturn false;\n--\nfs/coredump.c-909-\tif ((ack.mask \u0026 COREDUMP_RECORDS) \u0026\u0026 !(ack.mask \u0026 COREDUMP_KERNEL)) {\nfs/coredump.c:910:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_CONFLICTING);\nfs/coredump.c-911-\t\treturn false;\n--\nfs/coredump.c-915-\tif ((ack.mask \u0026 COREDUMP_SPARSE) \u0026\u0026 !(ack.mask \u0026 COREDUMP_RECORDS)) {\nfs/coredump.c:916:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_CONFLICTING);\nfs/coredump.c-917-\t\treturn false;\n--\nfs/coredump.c-922-\t\tif (usize \u003c COREDUMP_ACK_SIZE_VER1) {\nfs/coredump.c:923:\t\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_MINSIZE);\nfs/coredump.c-924-\t\t\treturn false;\n--\nfs/coredump.c-928-\t\tif (!(ack.mask \u0026 COREDUMP_KERNEL)) {\nfs/coredump.c:929:\t\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_CONFLICTING);\nfs/coredump.c-930-\t\t\treturn false;\n--\nfs/coredump.c-934-\t\tif (ack.memory_types \u0026 ~req.memory_types_mask) {\nfs/coredump.c:935:\t\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_UNSUPPORTED);\nfs/coredump.c-936-\t\t\treturn false;\n--\nfs/coredump.c-939-\t\t/* Like @spare the field must be zero when it isn't used. */\nfs/coredump.c:940:\t\tcoredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_UNSUPPORTED);\nfs/coredump.c-941-\t\treturn false;\n--\nfs/coredump.c-955-\tcprm-\u003emask = ack.mask;\nfs/coredump.c:956:\treturn coredump_sock_mark(cprm-\u003efile, COREDUMP_MARK_REQACK);\nfs/coredump.c-957-}\nfs/coredump.c-958-\nfs/coredump.c:959:static bool coredump_socket(struct core_name *cn, struct coredump_params *cprm)\nfs/coredump.c-960-{\nfs/coredump.c:961:\tif (!coredump_sock_connect(cn, cprm))\nfs/coredump.c-962-\t\treturn false;\nfs/coredump.c-963-\nfs/coredump.c:964:\treturn coredump_sock_request(cn, cprm);\nfs/coredump.c-965-}\nfs/coredump.c-966-#else\nfs/coredump.c:967:static inline void coredump_sock_wait(struct file *file) { }\nfs/coredump.c:968:static inline void coredump_sock_shutdown(struct file *file) { }\nfs/coredump.c:969:static inline bool coredump_socket(struct core_name *cn, struct coredump_params *cprm) { return false; }\nfs/coredump.c-970-#endif\n--\nfs/coredump.c-972-/* cprm-\u003edumpable is the snapshot of task dumpability at dump start. */\nfs/coredump.c:973:static inline bool coredump_force_suid_safe(const struct coredump_params *cprm)\nfs/coredump.c-974-{\n--\nfs/coredump.c-978-\nfs/coredump.c:979:static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,\nfs/coredump.c-980-\t\t\t const struct linux_binfmt *binfmt)\n--\nfs/coredump.c-989-\nfs/coredump.c:990:\tif (coredump_force_suid_safe(cprm) \u0026\u0026 cn-\u003ecorename[0] != '/') {\nfs/coredump.c:991:\t\tcoredump_report_failure(\"this process can only dump core to a fully qualified path, skipping core dump\");\nfs/coredump.c-992-\t\treturn false;\n--\nfs/coredump.c-999-\t */\nfs/coredump.c:1000:\tif (!coredump_force_suid_safe(cprm)) {\nfs/coredump.c-1001-\t\tCLASS(filename_kernel, name)(cn-\u003ecorename);\n--\nfs/coredump.c-1016-\t */\nfs/coredump.c:1017:\tif (coredump_force_suid_safe(cprm)) {\nfs/coredump.c-1018-\t\t/*\n--\nfs/coredump.c-1053-\tif (!vfsuid_eq_kuid(i_uid_into_vfsuid(idmap, inode), current_fsuid())) {\nfs/coredump.c:1054:\t\tcoredump_report_failure(\"Core dump to %s aborted: cannot preserve file owner\", cn-\u003ecorename);\nfs/coredump.c-1055-\t\treturn false;\n--\nfs/coredump.c-1057-\tif ((inode-\u003ei_mode \u0026 0677) != 0600) {\nfs/coredump.c:1058:\t\tcoredump_report_failure(\"Core dump to %s aborted: cannot preserve file permissions\", cn-\u003ecorename);\nfs/coredump.c-1059-\t\treturn false;\n--\nfs/coredump.c-1069-\nfs/coredump.c:1070:static bool coredump_pipe(struct core_name *cn, struct coredump_params *cprm,\nfs/coredump.c-1071-\t\t\t size_t *argv, int argc)\n--\nfs/coredump.c-1077-\tif (cprm-\u003elimit == 1) {\nfs/coredump.c:1078:\t\t/* See umh_coredump_setup() which sets RLIMIT_CORE = 1.\nfs/coredump.c-1079-\t\t *\n--\nfs/coredump.c-1092-\t\t */\nfs/coredump.c:1093:\t\tcoredump_report_failure(\"RLIMIT_CORE is set to 1, aborting core\");\nfs/coredump.c-1094-\t\treturn false;\n--\nfs/coredump.c-1099-\tif (core_pipe_limit \u0026\u0026 (core_pipe_limit \u003c cn-\u003ecore_pipe_limit)) {\nfs/coredump.c:1100:\t\tcoredump_report_failure(\"over core_pipe_limit, skipping core dump\");\nfs/coredump.c-1101-\t\treturn false;\n--\nfs/coredump.c-1105-\tif (!helper_argv) {\nfs/coredump.c:1106:\t\tcoredump_report_failure(\"%s failed to allocate memory\", __func__);\nfs/coredump.c-1107-\t\treturn false;\n--\nfs/coredump.c-1113-\tsub_info = call_usermodehelper_setup(helper_argv[0], helper_argv, NULL,\nfs/coredump.c:1114:\t\t\t\t\t GFP_KERNEL, umh_coredump_setup,\nfs/coredump.c-1115-\t\t\t\t\t NULL, cprm);\n--\nfs/coredump.c-1119-\tif (call_usermodehelper_exec(sub_info, UMH_WAIT_EXEC)) {\nfs/coredump.c:1120:\t\tcoredump_report_failure(\"|%s pipe failed\", cn-\u003ecorename);\nfs/coredump.c-1121-\t\treturn false;\n--\nfs/coredump.c-1128-\tif (!cprm-\u003efile) {\nfs/coredump.c:1129:\t\tcoredump_report_failure(\"Core dump to |%s disabled\", cn-\u003ecorename);\nfs/coredump.c-1130-\t\treturn false;\n--\nfs/coredump.c-1135-\nfs/coredump.c:1136:static bool coredump_write(struct coredump_params *cprm,\nfs/coredump.c-1137-\t\t\t const struct linux_binfmt *binfmt)\n--\nfs/coredump.c-1175-\nfs/coredump.c:1176:static void coredump_cleanup(struct core_name *cn, struct coredump_params *cprm)\nfs/coredump.c-1177-{\n--\nfs/coredump.c-1185-\tkfree(cprm-\u003erecord_hdr);\nfs/coredump.c:1186:\tcoredump_finish(cprm-\u003estate);\nfs/coredump.c-1187-}\nfs/coredump.c-1188-\nfs/coredump.c:1189:static inline bool coredump_skip(const struct coredump_params *cprm,\nfs/coredump.c-1190-\t\t\t\t const struct linux_binfmt *binfmt)\n--\nfs/coredump.c-1200-\nfs/coredump.c:1201:static void do_coredump(struct core_name *cn, struct coredump_params *cprm,\nfs/coredump.c-1202-\t\t\tsize_t **argv, int *argc, const struct linux_binfmt *binfmt)\n--\nfs/coredump.c-1205-\nfs/coredump.c:1206:\tif (!coredump_parse(cn, cprm, argv, argc)) {\nfs/coredump.c:1207:\t\tcoredump_report_failure(\"format_corename failed, aborting core\");\nfs/coredump.c-1208-\t\treturn;\n--\nfs/coredump.c-1212-\tcase COREDUMP_FILE:\nfs/coredump.c:1213:\t\tif (!coredump_file(cn, cprm, binfmt))\nfs/coredump.c-1214-\t\t\treturn;\n--\nfs/coredump.c-1216-\tcase COREDUMP_PIPE:\nfs/coredump.c:1217:\t\tif (!coredump_pipe(cn, cprm, *argv, *argc))\nfs/coredump.c-1218-\t\t\treturn;\n--\nfs/coredump.c-1222-\tcase COREDUMP_SOCK:\nfs/coredump.c:1223:\t\tif (!coredump_socket(cn, cprm))\nfs/coredump.c-1224-\t\t\treturn;\n--\nfs/coredump.c-1234-\nfs/coredump.c:1235:\tif ((cprm-\u003emask \u0026 COREDUMP_KERNEL) \u0026\u0026 !coredump_write(cprm, binfmt))\nfs/coredump.c-1236-\t\treturn;\nfs/coredump.c-1237-\nfs/coredump.c:1238:\tcoredump_sock_shutdown(cprm-\u003efile);\nfs/coredump.c-1239-\n--\nfs/coredump.c-1256-\t\tcase COREDUMP_SOCK:\nfs/coredump.c:1257:\t\t\tcoredump_sock_wait(cprm-\u003efile);\nfs/coredump.c-1258-\t\t\tbreak;\n--\nfs/coredump.c=1269=void vfs_coredump(const kernel_siginfo_t *siginfo)\n--\nfs/coredump.c-1276-\tint argc = 0;\nfs/coredump.c:1277:\tstruct coredump_params cprm = {\nfs/coredump.c-1278-\t\t.siginfo = siginfo,\n--\nfs/coredump.c-1288-\nfs/coredump.c:1289:\tif (coredump_skip(\u0026cprm, binfmt))\nfs/coredump.c-1290-\t\treturn;\n--\nfs/coredump.c-1300-\t */\nfs/coredump.c:1301:\tif (coredump_force_suid_safe(\u0026cprm))\nfs/coredump.c-1302-\t\tcred-\u003efsuid = GLOBAL_ROOT_UID;\nfs/coredump.c-1303-\nfs/coredump.c:1304:\tif (coredump_wait(siginfo-\u003esi_signo, \u0026core_state) \u003c 0)\nfs/coredump.c-1305-\t\treturn;\n--\nfs/coredump.c-1308-\t\tdo_coredump(\u0026cn, \u0026cprm, \u0026argv, \u0026argc, binfmt);\nfs/coredump.c:1309:\tcoredump_cleanup(\u0026cn, \u0026cprm);\nfs/coredump.c-1310-\treturn;\n--\nfs/coredump.c-1317- */\nfs/coredump.c:1318:static bool dump_records(const struct coredump_params *cprm)\nfs/coredump.c-1319-{\n--\nfs/coredump.c-1322-\nfs/coredump.c:1323:static bool dump_sparse(const struct coredump_params *cprm)\nfs/coredump.c-1324-{\n--\nfs/coredump.c-1328-/* Describe the next @len bytes of the coredump. Returns the header size. */\nfs/coredump.c:1329:static size_t dump_record_init(struct coredump_params *cprm,\nfs/coredump.c:1330:\t\t\t enum coredump_record_type type, u64 flags,\nfs/coredump.c-1331-\t\t\t u64 len)\n--\nfs/coredump.c-1335-\nfs/coredump.c:1336:\t*cprm-\u003erecord_hdr = (struct coredump_record_header) {\nfs/coredump.c-1337-\t\t.size\t= sizeof(*cprm-\u003erecord_hdr),\n--\nfs/coredump.c-1347-/* Write @iter whole or fail. @len is what it advances the coredump by. */\nfs/coredump.c:1348:static bool dump_write_iter(struct coredump_params *cprm, struct iov_iter *iter,\nfs/coredump.c-1349-\t\t\t size_t len)\n--\nfs/coredump.c-1366-/* One record, never more than a page. See __dump_emit(). */\nfs/coredump.c:1367:static bool dump_emit_chunk(struct coredump_params *cprm, const void *addr,\nfs/coredump.c-1368-\t\t\t int nr)\n--\nfs/coredump.c-1392-\nfs/coredump.c:1393:static bool __dump_emit(struct coredump_params *cprm, const void *addr, int nr)\nfs/coredump.c-1394-{\n--\nfs/coredump.c-1411-/* Send a record that stands on its own: a header and nothing else. */\nfs/coredump.c:1412:static bool dump_emit_record(struct coredump_params *cprm,\nfs/coredump.c:1413:\t\t\t enum coredump_record_type type, u64 flags, u64 len)\nfs/coredump.c-1414-{\n--\nfs/coredump.c-1430-/* Close the record stream. Only a whole coredump gets an end record. */\nfs/coredump.c:1431:static void dump_end_record(struct coredump_params *cprm)\nfs/coredump.c-1432-{\n--\nfs/coredump.c-1438-\nfs/coredump.c:1439:static bool __dump_skip(struct coredump_params *cprm, size_t nr)\nfs/coredump.c-1440-{\n--\nfs/coredump.c-1470-/* Flush the accumulated hole before writing data. */\nfs/coredump.c:1471:static bool dump_flush_skip(struct coredump_params *cprm)\nfs/coredump.c-1472-{\n--\nfs/coredump.c-1480-\nfs/coredump.c:1481:bool dump_emit(struct coredump_params *cprm, const void *addr, int nr)\nfs/coredump.c-1482-{\n--\nfs/coredump.c=1487=EXPORT_SYMBOL(dump_emit);\nfs/coredump.c-1488-\nfs/coredump.c:1489:void dump_skip_to(struct coredump_params *cprm, unsigned long pos)\nfs/coredump.c-1490-{\n--\nfs/coredump.c=1495=EXPORT_SYMBOL(dump_skip_to);\nfs/coredump.c-1496-\nfs/coredump.c:1497:void dump_skip(struct coredump_params *cprm, size_t nr)\nfs/coredump.c-1498-{\n--\nfs/coredump.c=1501=EXPORT_SYMBOL(dump_skip);\n--\nfs/coredump.c-1503-#ifdef CONFIG_ELF_CORE\nfs/coredump.c:1504:static bool dump_emit_page(struct coredump_params *cprm, struct page *page)\nfs/coredump.c-1505-{\n--\nfs/coredump.c=1555=static inline struct page *dump_page_copy(struct page *src, struct page *dst)\n--\nfs/coredump.c-1560-\nfs/coredump.c:1561:bool dump_user_range(struct coredump_params *cprm, unsigned long start,\nfs/coredump.c-1562-\t\t unsigned long len)\n--\nfs/coredump.c-1625-\nfs/coredump.c:1626:bool dump_align(struct coredump_params *cprm, int align)\nfs/coredump.c-1627-{\n--\nfs/coredump.c=1635=EXPORT_SYMBOL(dump_align);\n--\nfs/coredump.c-1638-\nfs/coredump.c:1639:void validate_coredump_safety(void)\nfs/coredump.c-1640-{\n--\nfs/coredump.c-1643-\nfs/coredump.c:1644:\t\tcoredump_report_failure(\"Unsafe core_pattern used with fs.suid_dumpable=2: \"\nfs/coredump.c-1645-\t\t\t\"pipe handler or fully qualified core dump path required. \"\n--\nfs/coredump.c-1649-\nfs/coredump.c:1650:static inline bool check_coredump_socket(const char *pattern)\nfs/coredump.c-1651-{\n--\nfs/coredump.c=1689=static int proc_dostring_coredump(const struct ctl_table *table, int write,\n--\nfs/coredump.c-1708-\nfs/coredump.c:1709:\tif (!check_coredump_socket(pattern))\nfs/coredump.c-1710-\t\treturn -EINVAL;\n--\nfs/coredump.c-1718-\tif (changed)\nfs/coredump.c:1719:\t\tvalidate_coredump_safety();\nfs/coredump.c-1720-\treturn 0;\n--\nfs/coredump.c=1725=static char core_modes[] = {\n--\nfs/coredump.c-1731-\nfs/coredump.c:1732:static const struct ctl_table coredump_sysctls[] = {\nfs/coredump.c-1733-\t{\n--\nfs/coredump.c-1782-\nfs/coredump.c:1783:static int __init init_fs_coredump_sysctls(void)\nfs/coredump.c-1784-{\nfs/coredump.c:1785:\tregister_sysctl_init(\"kernel\", coredump_sysctls);\nfs/coredump.c-1786-\treturn 0;\nfs/coredump.c-1787-}\nfs/coredump.c:1788:fs_initcall(init_fs_coredump_sysctls);\nfs/coredump.c-1789-#endif /* CONFIG_SYSCTL */\n--\nfs/coredump.c=1829=static unsigned long vma_dump_size(struct vm_area_struct *vma,\n--\nfs/coredump.c-1913- */\nfs/coredump.c:1914:static struct vm_area_struct *coredump_next_vma(struct vma_iterator *vmi,\nfs/coredump.c-1915-\t\t\t\t struct vm_area_struct *vma,\n--\nfs/coredump.c-1926-\nfs/coredump.c:1927:static void free_vma_snapshot(struct coredump_params *cprm)\nfs/coredump.c-1928-{\n--\nfs/coredump.c=1941=static int cmp_vma_size(const void *vma_meta_lhs_ptr, const void *vma_meta_rhs_ptr)\n--\nfs/coredump.c-1956- */\nfs/coredump.c:1957:static bool dump_vma_snapshot(struct coredump_params *cprm)\nfs/coredump.c-1958-{\n--\nfs/coredump.c-1981-\nfs/coredump.c:1982:\twhile ((vma = coredump_next_vma(\u0026vmi, vma, gate_vma)) != NULL) {\nfs/coredump.c-1983-\t\tstruct core_vma_metadata *m = cprm-\u003evma_meta + i;\n"
} |
| 5/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28030 output: 40 thoughts: 73 Thoughts: Okay, let's dive into this. Here's how I'm thinking about it: **Examining File Closing Mechanisms in the Kernel** Right, I need to get a clear picture of the file closing procedures in the kernel. My initial thought is to zero in on the `fs/file.c` file. I need to understand how files are closed. So, let's start with a list. I see three key functions here: `close_files()`, `__range_close()`, and `close_cloexec_files()`. They sound like they handle different aspects of file closure, potentially related to ranges of file descriptors or file descriptors marked with `CLOEXEC`. Now, the next logical step, given my familiarity with kernel code, is to trace the usage of these functions. I'll need to identify which parts of the `fs/file.c` file call `__range_close()`, `close_files()`, and `close_cloexec_files()`. This will tell me *where* these file closure functions are being used, and *why*, which is critical to understanding their purpose within the larger system. I'll be able to infer how different parts of the kernel interact with these core file closing mechanisms. |
| 6/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "__range_close|close_cloexec_files|close_files",
"PathPrefix": "fs/file.c"
}Results: {
"Output": "fs/file.c=477=int unshare_fd(unsigned long unshare_flags, struct files_struct **new_fdp)\n--\nfs/file.c-491-\nfs/file.c:492:static struct fdtable *close_files(struct files_struct *files)\nfs/file.c-493-{\n--\nfs/file.c=521=void put_files_struct(struct files_struct *files)\n--\nfs/file.c-523-\tif (atomic_dec_and_test(\u0026files-\u003ecount)) {\nfs/file.c:524:\t\tstruct fdtable *fdt = close_files(files);\nfs/file.c-525-\n--\nfs/file.c=775=static inline void __range_cloexec(struct files_struct *cur_fds,\n--\nfs/file.c-788-\nfs/file.c:789:static inline void __range_close(struct files_struct *files, unsigned int fd,\nfs/file.c-790-\t\t\t\t unsigned int max_fd)\n--\nfs/file.c-800-\nfs/file.c:801:\t/* Highest fd first, see close_files(). */\nfs/file.c-802-\tfor (n = max_fd + 1; n \u003e fd; ) {\n--\nfs/file.c=836=SYSCALL_DEFINE3(close_range, unsigned int, fd, unsigned int, max_fd,\n--\nfs/file.c-871-\telse\nfs/file.c:872:\t\t__range_close(cur_fds, fd, max_fd);\nfs/file.c-873-\n--\nfs/file.c=893=struct file *file_close_fd(unsigned int fd)\n--\nfs/file.c-904-\nfs/file.c:905:void close_cloexec_files(struct files_struct *files)\nfs/file.c-906-{\n--\nfs/file.c-912-\tfdt = files_fdtable(files);\nfs/file.c:913:\t/* Highest fd first, see close_files(). */\nfs/file.c-914-\tfor (i = fdt-\u003emax_fds / BITS_PER_LONG; i--; ) {\n"
} |
| 7/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29000 output: 38 thoughts: 371 Thoughts: **Analyzing Potential Concurrency Issues and Resource Management** Okay, so `close_cloexec_files()` is either exported or not static – that's a red flag. I need to see what's calling it to understand the scope of its impact. I'll need to check the callers of `close_cloexec_files()`. Also, I see `__range_close()` is part of the `sys_close_range` system call (`SYSCALL_DEFINE3(close_range)`). `close_files()` gets called by `put_files_struct()` which I'll take a look at later. Now, let's dive into some specific areas. First, `io_uring/io-wq.c`. Looks like `io_wq_exit_start()` saw some modifications, specifically around `smp_mb__after_atomic()`. Interesting, worth a deeper look to see if this is related. Then, I see `kernel/exit.c`'s `do_exit()` was touched, but that function is so fundamental that a modification there is almost expected. Not necessarily a smoking gun, but something to keep in mind. Next, `kernel/fork.c`. `copy_files()`, `copy_process()`, and `create_io_thread()` all saw changes. That suggests there might be some file descriptor handling or threading interactions that need careful scrutiny, especially with the earlier concerns about file closure. In `kernel/ptrace.c`, `ptrace_request()`'s handling of `PTRACE_SETSIGMASK` was modified. Back in signal handling, `kernel/signal.c`, I see `coredump_signal_pending()` is non-static and exported. Also, `retarget_shared_pending()` was modified. And, importantly, `__set_task_blocked()` was touched, now including `WARN_ON_ONCE(!sigequalsets(&floored, newset));` and floor logic for `PF_USER_WORKER`. This is critical. Finally, in `fs/exec.c`, `begin_new_exec()` had `io_uring_task_cancel()` moved before `de_thread(me)`. That order might have implications in terms of resource cleanup. Given the modifications around signal handling and file descriptors, I need to understand the impact of the changes to `__set_task_blocked()` and `retarget_shared_pending()` in `kernel/signal.c`. I need to figure out which other parts of the kernel are calling them, and how those calls interact. I'll need to trace the call paths. |
| 8/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "__set_task_blocked|retarget_shared_pending",
"PathPrefix": "kernel/signal.c"
}Results: {
"Output": "kernel/signal.c=3102=void signal_setup_done(int failed, struct ksignal *ksig, int stepping)\n--\nkernel/signal.c-3114- */\nkernel/signal.c:3115:static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)\nkernel/signal.c-3116-{\n--\nkernel/signal.c=3145=void exit_signals(struct task_struct *tsk)\n--\nkernel/signal.c-3175-\tsignotset(\u0026unblocked);\nkernel/signal.c:3176:\tretarget_shared_pending(tsk, \u0026unblocked);\nkernel/signal.c-3177-\n--\nkernel/signal.c=3208=long do_no_restart_syscall(struct restart_block *param)\n--\nkernel/signal.c-3212-\nkernel/signal.c:3213:static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)\nkernel/signal.c-3214-{\n--\nkernel/signal.c-3228-\t\tsigandnsets(\u0026newblocked, newset, \u0026current-\u003eblocked);\nkernel/signal.c:3229:\t\tretarget_shared_pending(tsk, \u0026newblocked);\nkernel/signal.c-3230-\t}\n--\nkernel/signal.c=3248=void __set_current_blocked(const sigset_t *newset)\n--\nkernel/signal.c-3259-\tspin_lock_irq(\u0026tsk-\u003esighand-\u003esiglock);\nkernel/signal.c:3260:\t__set_task_blocked(tsk, newset);\nkernel/signal.c-3261-\tspin_unlock_irq(\u0026tsk-\u003esighand-\u003esiglock);\n--\nkernel/signal.c=3782=static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,\n--\nkernel/signal.c-3821-\t\tspin_lock_irq(\u0026tsk-\u003esighand-\u003esiglock);\nkernel/signal.c:3822:\t\t__set_task_blocked(tsk, \u0026tsk-\u003ereal_blocked);\nkernel/signal.c-3823-\t\tsigemptyset(\u0026tsk-\u003ereal_blocked);\n"
} |
| 9/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30561 output: 31 thoughts: 56 Thoughts: Here's my take on the thought process, as requested: **Navigating Kernel Blocking and Signal Masking** Okay, so I'm digging into how blocking works within the kernel. My initial thought process is leading me to the specific functions responsible for manipulating the blocking state of a task. The key functions I'm focusing on are `__set_current_blocked()` and `set_current_blocked()`, as defined in `kernel/signal.c`. My next step is to perform a code inspection, essentially tracing the calls. I want to understand the control flow, so I'll be looking for any functions that *call* either `__set_current_blocked` or other related functions such as `__set_task_blocked`. This will reveal the context in which blocking is initiated and potentially provide clues about the conditions that trigger a blocking state. I'll need to understand where and how the signal mask is being modified. |
| 10/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "__set_current_blocked",
"PathPrefix": "kernel/signal.c"
}Results: {
"Output": "kernel/signal.c=3242=void set_current_blocked(sigset_t *newset)\n--\nkernel/signal.c-3244-\tsigdelsetmask(newset, sigmask(SIGKILL) | sigmask(SIGSTOP));\nkernel/signal.c:3245:\t__set_current_blocked(newset);\nkernel/signal.c-3246-}\nkernel/signal.c-3247-\nkernel/signal.c:3248:void __set_current_blocked(const sigset_t *newset)\nkernel/signal.c-3249-{\n--\nkernel/signal.c=3272=int sigprocmask(int how, sigset_t *set, sigset_t *oldset)\n--\nkernel/signal.c-3294-\nkernel/signal.c:3295:\t__set_current_blocked(\u0026newset);\nkernel/signal.c-3296-\treturn 0;\n"
} |
| 11/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31099 output: 32 thoughts: 141 Thoughts: **Analyzing Ptrace and Signal Masking** Okay, let's dive into this `ptrace_request` function within `kernel/ptrace.c`. Specifically, I'm focusing on the `PTRACE_SETSIGMASK` case. It looks like we have a `sigset_t new_set` being manipulated here, which is standard. But wait, I see this conditional check that immediately triggers my attention: `(child->flags & PF_USER_WORKER)`. It appears that if the child process is flagged as a `PF_USER_WORKER`, the function immediately returns with an `-EPERM` error code, effectively preventing the signal mask from being set. I am now immediately interested in where `__set_task_blocked()` is called. This function is important when dealing with signal masking; I need to know how the signal mask is being manipulated in relation to the `ptrace` system call. The immediate goal is to understand how signals are handled and blocked when using `ptrace`. I'm starting by meticulously examining the `ptrace_request` function around the `PTRACE_SETSIGMASK` case to identify the relationship. |
| 12/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "PTRACE_SETSIGMASK",
"PathPrefix": "kernel/ptrace.c"
}Results: {
"Output": "kernel/ptrace.c=1162=int ptrace_request(struct task_struct *child, long request,\n--\nkernel/ptrace.c-1226-\nkernel/ptrace.c:1227:\tcase PTRACE_SETSIGMASK: {\nkernel/ptrace.c-1228-\t\tsigset_t new_set;\n"
} |
| 13/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31619 output: 35 thoughts: 24 Thoughts: Okay, let's dive into this. I'm going to focus on lines 1227-1250 of `kernel/ptrace.c`. My immediate thought is, "What's the context here? What functionality are these lines likely to address within the PTRACE framework?" Given the file and the range, it's probably related to some aspect of process tracing, debugging, or potentially manipulation of registers or memory. I expect it's something relatively low-level, intimately tied to the kernel's interaction with user-space processes under tracing. Specifically, I'm thinking I'll be looking for things like: * **Error Handling:** Are there checks for invalid PTRACE requests, bad addresses, or permission issues? `ptrace` is notorious for needing robust error handling. * **Data Structures:** Will I see references to `task_struct`, `pt_regs` (or architecture-specific equivalent), or other kernel data structures crucial to process state? * **Architecture Specifics:** I'll be alert for `#ifdef` or similar conditional compilation, assuming this section is potentially architecture-dependent, perhaps involving reading or writing register values. * **Synchronization:** Might there be locking mechanisms, semaphores, or atomic operations involved to prevent race conditions during tracing? I’m anticipating that these lines will either be the core implementation of a particular `ptrace` request (like `PTRACE_PEEKDATA` or `PTRACE_GETREGS`), or perhaps a helper function used by several such requests. I'll be mentally parsing the code for control flow: conditional branches, loops, and function calls. I'll want to see how the code is structured and how it manages the kernel's interaction with the targeted process. I am ready to absorb the specifics and analyze it accordingly. |
| 14/2 | 2026/09/23 11:35 | tool | read-file |
0mArgs:{
"File": "kernel/ptrace.c",
"FirstLine": 1227,
"LineCount": 30
}Results: {
"Contents": "1227:\t\tcase PTRACE_SETSIGMASK: {\n1228:\t\t\tsigset_t new_set;\n1229:\t\n1230:\t\t\t/* A user worker only ever takes SIGKILL and SIGSTOP. */\n1231:\t\t\tif (child-\u003eflags \u0026 PF_USER_WORKER) {\n1232:\t\t\t\tret = -EPERM;\n1233:\t\t\t\tbreak;\n1234:\t\t\t}\n1235:\t\n1236:\t\t\tif (addr != sizeof(sigset_t)) {\n1237:\t\t\t\tret = -EINVAL;\n1238:\t\t\t\tbreak;\n1239:\t\t\t}\n1240:\t\n1241:\t\t\tif (copy_from_user(\u0026new_set, datavp, sizeof(sigset_t))) {\n1242:\t\t\t\tret = -EFAULT;\n1243:\t\t\t\tbreak;\n1244:\t\t\t}\n1245:\t\n1246:\t\t\tsigdelsetmask(\u0026new_set, sigmask(SIGKILL)|sigmask(SIGSTOP));\n1247:\t\n1248:\t\t\t/*\n1249:\t\t\t * Every thread does recalc_sigpending() after resume, so\n1250:\t\t\t * retarget_shared_pending() and recalc_sigpending() are not\n1251:\t\t\t * called here.\n1252:\t\t\t */\n1253:\t\t\tspin_lock_irq(\u0026child-\u003esighand-\u003esiglock);\n1254:\t\t\tchild-\u003eblocked = new_set;\n1255:\t\t\tspin_unlock_irq(\u0026child-\u003esighand-\u003esiglock);\n1256:\t\n"
} |
| 15/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32490 output: 28 thoughts: 41 Thoughts: Okay, here's my take on those thoughts, framed as my own mental processing: **Tracing a Blocked Task: Deep Dive** Right, so I'm digging into how task blocking works, specifically within the ptrace context. I see this `child->blocked = new_set;` line. That's the core assignment – setting the `blocked` signal mask for a child process. But I'm not satisfied with just that. I need to understand the *why* and the *how*. The key question now is: Where does the kernel actually call `__set_task_blocked()`? I know that function's responsible for the underlying mechanics of setting the blocked signals, but knowing *where* it's called offers critical context. I need to trace the call chain. It's time to check in the signaling core, `kernel/signal.c`. That's where I expect to find the relevant logic. Let's see what's in there. |
| 16/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "__set_task_blocked",
"PathPrefix": "kernel/"
}Results: {
"Output": "kernel/locking/mutex.c=609=__mutex_lock_common(struct mutex *lock, unsigned int state, unsigned int subclass,\n--\nkernel/locking/mutex.c-691-\traw_spin_lock(\u0026current-\u003eblocked_lock);\nkernel/locking/mutex.c:692:\t__set_task_blocked_on(current, lock);\nkernel/locking/mutex.c-693-\tset_current_state(state);\n--\nkernel/locking/mutex.c-736-\t\t */\nkernel/locking/mutex.c:737:\t\t__set_task_blocked_on(current, lock);\nkernel/locking/mutex.c-738-\t\tset_current_state(state);\n--\nkernel/locking/mutex.c-764-\t\t\traw_spin_lock(\u0026current-\u003eblocked_lock);\nkernel/locking/mutex.c:765:\t\t\t__set_task_blocked_on(current, lock);\nkernel/locking/mutex.c-766-\t\t\tset_current_state(state);\n--\nkernel/signal.c=3208=long do_no_restart_syscall(struct restart_block *param)\n--\nkernel/signal.c-3212-\nkernel/signal.c:3213:static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)\nkernel/signal.c-3214-{\n--\nkernel/signal.c=3248=void __set_current_blocked(const sigset_t *newset)\n--\nkernel/signal.c-3259-\tspin_lock_irq(\u0026tsk-\u003esighand-\u003esiglock);\nkernel/signal.c:3260:\t__set_task_blocked(tsk, newset);\nkernel/signal.c-3261-\tspin_unlock_irq(\u0026tsk-\u003esighand-\u003esiglock);\n--\nkernel/signal.c=3782=static int do_sigtimedwait(const sigset_t *which, kernel_siginfo_t *info,\n--\nkernel/signal.c-3821-\t\tspin_lock_irq(\u0026tsk-\u003esighand-\u003esiglock);\nkernel/signal.c:3822:\t\t__set_task_blocked(tsk, \u0026tsk-\u003ereal_blocked);\nkernel/signal.c-3823-\t\tsigemptyset(\u0026tsk-\u003ereal_blocked);\n"
} |
| 17/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33359 output: 28 thoughts: 666 Thoughts: **Analyzing Kernel Changes Related to Core Dumps and Signal Handling** Okay, let's break this down. My initial focus is on understanding the ripple effects of these kernel modifications, specifically concerning core dumps and signal handling. I see that `__set_current_blocked` is crucial, being invoked by `set_current_blocked`, `sigprocmask`, and `do_sigtimedwait`. That's a good starting point to investigate possible race conditions or unexpected side effects of blocking signals. Now, let's drill into the patch itself. The key functions impacted are: * **File System (fs/):** `coredump_parse`, `coredump_finish`, `dump_interrupted`, `check_coredump_socket`, `proc_dostring_coredump` (in `fs/coredump.c`), `begin_new_exec` (in `fs/exec.c`), `close_files`, `__range_close`, and `close_cloexec_files` (in `fs/file.c`). * **IO_URING:** `io_wq_exit_start` (in `io_uring/io-wq.c`) * **Kernel Core:** `do_exit` (in `kernel/exit.c`) * **Forking:** `copy_files`, `copy_process`, and `create_io_thread` (in `kernel/fork.c`) * **Tracing:** `ptrace_request` (in `kernel/ptrace.c`) * **Signal Handling:** `coredump_signal_pending`, `retarget_shared_pending`, and `__set_task_blocked` (in `kernel/signal.c`). A key area of concern is `coredump_signal_pending`. I see that it is called when a task is flagged with `PF_DUMPCORE` (meaning it's in the process of generating a core dump) and if it has signals pending. The code explicitly states that only SIGKILL or the freezer should interrupt a core dump. Specifically, it seems that if `p->flags` has the `PF_DUMPCORE` set, it jumps to `coredump_signal_pending`, which is exported as a symbol. This means that a core dump only stops for `__fatal_signal_pending`, when it is freezing, or when `JOBCTL_TRAP_FREEZE` is set. This is important to ensure that signals that arise during a core dump don't corrupt the data being written. I'm also paying close attention to `/proc/sys/kernel/core_pattern` and how it's modified by writing to `proc_dostring_coredump`. That's the control point for where the core dumps are actually written. The interaction of all these components—signal handling, core dump process, and the core pattern—is where the real magic happens. Finally, I need to know where `close_cloexec_files` is called, since this is a potentially dangerous function for resource management during a core dump. I need to understand its context. |
| 18/2 | 2026/09/23 11:35 | tool | grepper |
0mArgs:{
"Expression": "close_cloexec_files",
"PathPrefix": "fs/"
}Results: {
"Output": "fs/exec.c=1124=int begin_new_exec(struct linux_binprm * bprm)\n--\nfs/exec.c-1184-\t */\nfs/exec.c:1185:\tclose_cloexec_files(me-\u003efiles);\nfs/exec.c-1186-\n--\nfs/file.c=893=struct file *file_close_fd(unsigned int fd)\n--\nfs/file.c-904-\nfs/file.c:905:void close_cloexec_files(struct files_struct *files)\nfs/file.c-906-{\n"
} |
| 19/2 | 2026/09/23 11:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34884 output: 33 thoughts: 136 Thoughts: **Tracing File Descriptor Closure in the Kernel** Okay, so I'm looking at how file descriptors get closed within the kernel. My initial thought process revolves around a few key functions: `begin_new_exec` which calls `close_cloexec_files`, then there's `close_range` which goes to `__range_close`, and finally `put_files_struct` which uses `close_files`. I'm starting to get a picture, but I need to dive deeper into how these pieces fit together, and how efficient this process is. The real question I need to answer is if `__range_close` is inlined into `sys_close_range`, specifically `__do_sys_close_range`. Considering that `__range_close` is declared as static inline within `fs/file.c`, I have a pretty strong suspicion that the compiler optimizes this, effectively embedding the code directly. Now, I need to confirm this. I think the answer is located somewhere between lines 830 and 880 of `fs/file.c`. I will have to start to dig in there for the answer. |
| 20/2 | 2026/09/23 11:36 | tool | read-file |
0mArgs:{
"File": "fs/file.c",
"FirstLine": 830,
"LineCount": 55
}Results: {
"Contents": " 830:\t * @flags: CLOSE_RANGE flags.\n 831:\t *\n 832:\t * This closes a range of file descriptors. All file descriptors\n 833:\t * from @fd up to and including @max_fd are closed.\n 834:\t * Currently, errors to close a given file descriptor are ignored.\n 835:\t */\n 836:\tSYSCALL_DEFINE3(close_range, unsigned int, fd, unsigned int, max_fd,\n 837:\t\t\tunsigned int, flags)\n 838:\t{\n 839:\t\tstruct task_struct *me = current;\n 840:\t\tstruct files_struct *cur_fds = me-\u003efiles, *fds = NULL;\n 841:\t\n 842:\t\tif (flags \u0026 ~(CLOSE_RANGE_UNSHARE | CLOSE_RANGE_CLOEXEC))\n 843:\t\t\treturn -EINVAL;\n 844:\t\n 845:\t\tif (fd \u003e max_fd)\n 846:\t\t\treturn -EINVAL;\n 847:\t\n 848:\t\tif ((flags \u0026 CLOSE_RANGE_UNSHARE) \u0026\u0026 atomic_read(\u0026cur_fds-\u003ecount) \u003e 1) {\n 849:\t\t\tstruct fd_range range = {fd, max_fd}, *punch_hole = \u0026range;\n 850:\t\n 851:\t\t\t/*\n 852:\t\t\t * If the caller requested all fds to be made cloexec we always\n 853:\t\t\t * copy all of the file descriptors since they still want to\n 854:\t\t\t * use them.\n 855:\t\t\t */\n 856:\t\t\tif (flags \u0026 CLOSE_RANGE_CLOEXEC)\n 857:\t\t\t\tpunch_hole = NULL;\n 858:\t\n 859:\t\t\tfds = dup_fd(cur_fds, punch_hole);\n 860:\t\t\tif (IS_ERR(fds))\n 861:\t\t\t\treturn PTR_ERR(fds);\n 862:\t\t\t/*\n 863:\t\t\t * We used to share our file descriptor table, and have now\n 864:\t\t\t * created a private one, make sure we're using it below.\n 865:\t\t\t */\n 866:\t\t\tswap(cur_fds, fds);\n 867:\t\t}\n 868:\t\n 869:\t\tif (flags \u0026 CLOSE_RANGE_CLOEXEC)\n 870:\t\t\t__range_cloexec(cur_fds, fd, max_fd);\n 871:\t\telse\n 872:\t\t\t__range_close(cur_fds, fd, max_fd);\n 873:\t\n 874:\t\tif (fds) {\n 875:\t\t\t/*\n 876:\t\t\t * We're done closing the files we were supposed to. Time to install\n 877:\t\t\t * the new file descriptor table and drop the old one.\n 878:\t\t\t */\n 879:\t\t\tswitch_files_struct(me, cur_fds);\n 880:\t\t}\n 881:\t\n 882:\t\treturn 0;\n 883:\t}\n 884:\t\n"
} |
| 21/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36105 output: 31 thoughts: 88 Thoughts: Okay, let's break this down. **Investigating File Descriptor Handling in the Kernel** Alright, so I'm digging into how file descriptors are managed, specifically around `close_range`. I see that the core functionality, `__range_close`, is cleverly inlined as `static inline` within `close_range`, which itself is just a wrapper for `__do_sys_close_range`. That's standard practice, optimizing the most common path. Interesting. Now, `close_cloexec_files`... that's *not* static, which means it's likely intended for broader use than just within the immediate file-closing context. I need to keep that in mind. And `close_files`, that's `static`, which means it’s tightly coupled with the `put_files_struct` function. It seems to be part of the cleanup mechanism. Good to know. Now, let's shift gears and look at `io_wq_exit_start`. I need to understand the relationship between I/O workqueues and file descriptor closing. Where is `io_wq_exit_start` actually *called*? That's going to tell me what's happening when a process is exiting and how that's tied into these file descriptor operations. I need to trace those call sites. |
| 22/2 | 2026/09/23 11:36 | tool | grepper |
0mArgs:{
"Expression": "io_wq_exit_start",
"PathPrefix": "io_uring/"
}Results: {
"Output": "io_uring/cancel.c=582=__cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd)\n--\nio_uring/cancel.c-595-\tif (tctx-\u003eio_wq)\nio_uring/cancel.c:596:\t\tio_wq_exit_start(tctx-\u003eio_wq);\nio_uring/cancel.c-597-\n--\nio_uring/io-wq.c=1314=static bool io_task_work_match(struct callback_head *cb, void *data)\n--\nio_uring/io-wq.c-1323-\nio_uring/io-wq.c:1324:void io_wq_exit_start(struct io_wq *wq)\nio_uring/io-wq.c-1325-{\n--\nio_uring/io-wq.h=42=struct io_wq *io_wq_create(unsigned bounded, struct io_wq_data *data);\nio_uring/io-wq.h:43:void io_wq_exit_start(struct io_wq *wq);\nio_uring/io-wq.h-44-void io_wq_put_and_exit(struct io_wq *wq);\n--\nio_uring/tctx.c=145=int __io_uring_add_tctx_node(struct io_ring_ctx *ctx)\n--\nio_uring/tctx.c-188-\t\tif (tctx-\u003eio_wq) {\nio_uring/tctx.c:189:\t\t\tio_wq_exit_start(tctx-\u003eio_wq);\nio_uring/tctx.c-190-\t\t\tio_wq_put_and_exit(tctx-\u003eio_wq);\n"
} |
| 23/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36959 output: 30 thoughts: 34 Thoughts: Here's my take on those thoughts: **Reflecting on Kernel Thread Management** Okay, so I'm digging into this kernel code and something's bugging me about `io_wq_exit_start`. The fact that it's *not* declared as static really stands out. Why isn't it scoped internally? What's the design rationale here? Is it intended for some external module to hook into the I/O workqueue shutdown sequence? I need to understand the implications of its visibility and if this exposes any potential race conditions I should be aware of. Then my mind drifts to `create_io_thread` in `kernel/fork.c`. That function's role in initiating a dedicated I/O thread is critical. How does this thread interact with `io_wq_exit_start`? What happens during the teardown of a process or a workqueue? Are there synchronization primitives involved to make sure there's no data corruption or missed signals? I'll probably need to chase down the call graph from that function to see how the I/O threads are created, how they're managed, and if `io_wq_exit_start` plays a role there. This is a potential hot spot and I need to fully understand the interplay. |
| 24/2 | 2026/09/23 11:36 | tool | grepper |
0mArgs:{
"Expression": "create_io_thread",
"PathPrefix": "kernel/fork.c"
}Results: {
"Output": "kernel/fork.c=2668=struct task_struct * __init fork_idle(int cpu)\n--\nkernel/fork.c-2693- */\nkernel/fork.c:2694:struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)\nkernel/fork.c-2695-{\n"
} |
| 25/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37394 output: 29 thoughts: 29 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Analyzing the `create_io_thread` Function** Alright, so `create_io_thread` is *not* a static function. That immediately piques my interest. It implies some level of state or dependency within the class it's defined in, or that its behavior might be tied to specific object instances. I need to understand the context. My next immediate step is clear: I need to trace *all* calls to `create_io_thread`. I need to figure out where and how this function is being invoked. Is it being called within the same module, or does it cross module boundaries? What are the arguments passed to it? The answers to those questions are absolutely crucial. Knowing the caller context will give me clues about its purpose and potential side effects. I need to understand the scope and implications of this non-static declaration. This is a critical point to verify to avoid any future potential concurrency or resource-related issues. |
| 26/2 | 2026/09/23 11:36 | tool | grepper |
0mArgs:{
"Expression": "create_io_thread",
"PathPrefix": "io_uring/"
}Results: {
"Output": "io_uring/io-wq.c=849=static void create_worker_cont(struct callback_head *cb)\n--\nio_uring/io-wq.c-859-\tacct = io_wq_get_acct(worker);\nio_uring/io-wq.c:860:\ttsk = create_io_thread(io_wq_worker, worker, NUMA_NO_NODE);\nio_uring/io-wq.c-861-\tif (!IS_ERR(tsk)) {\n--\nio_uring/io-wq.c=901=static bool create_io_worker(struct io_wq *wq, struct io_wq_acct *acct)\n--\nio_uring/io-wq.c-924-\nio_uring/io-wq.c:925:\ttsk = create_io_thread(io_wq_worker, worker, NUMA_NO_NODE);\nio_uring/io-wq.c-926-\tif (!IS_ERR(tsk)) {\n--\nio_uring/sqpoll.c=441=__cold int io_sq_offload_create(struct io_ring_ctx *ctx,\n--\nio_uring/sqpoll.c-512-\t\tsqd-\u003etask_tgid = current-\u003etgid;\nio_uring/sqpoll.c:513:\t\ttsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE);\nio_uring/sqpoll.c-514-\t\tif (IS_ERR(tsk)) {\n"
} |
| 27/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38058 output: 26 thoughts: 1969 Thoughts: **Focusing on Core Dump and Thread Lifecycle Improvements** Okay, let's break this down. My goal here is to identify key functions for the fuzzer, specifically those that implement the logic being added or altered related to coredumps, and general thread lifecycle management, while avoiding ubiquitous functions that would dilute fuzzing efforts. I started by looking at `create_io_thread` – that's called when io_uring io-wq workers and SQPOLL threads are created, and seems like a possible candidate since there are changes for coredump-related thread flags. Similarly `ptrace_request` seems relevant for handling `PTRACE_SETSIGMASK`, which can now reject `PF_USER_WORKER` - that has to be in the focus list. And related: `coredump_signal_pending`, which is newly exported, that function specifically checks if coredump is interrupted by SIGKILL/freezer, is definitely a good choice. I want to avoid the common lifecycle functions like `do_exit`, `copy_process`, and `copy_files` that are called by almost every program. Focusing on the `fs/coredump.c` changes, I've identified `vfs_coredump` as the direct entrypoint to core dump handling, and therefore a very important candidate. `vfs_coredump` calls `do_coredump`, `coredump_parse`, and calls `coredump_cleanup` then `coredump_finish`, and `dump_interrupted` is called during `coredump_write` or dumping. Also `proc_dostring_coredump` is the sysctl handler for core_pattern where locking and socket check were rewritten. I'm also considering `__set_current_blocked` and its callers, particularly `__set_task_blocked` - handles changing blocked signals, where `WARN_ON_ONCE` for user workers was added. Beyond those in `fs/coredump.c`, I'm looking at other potentially important functions. `create_io_thread` that creates io-wq worker or SQPOLL thread, modified to check `PF_SIGNALED | PF_POSTCOREDUMP`. Also `io_wq_exit_start` - io-wq cancellation / exit start, memory barrier added; `close_cloexec_files` - closing cloexec fds in reverse order. Also `__set_current_blocked` - handles changing blocked signals, where `WARN_ON_ONCE` for user workers was added via `__set_task_blocked`. Now, regarding the patch series itself, it appears to be a comprehensive fix/hardening addressing coredumps, io_uring worker threads, signal retargeting during group exit, and fd closing order! The reverse FD closing order (`close_files`, `__range_close`, `close_cloexec_files` in `fs/file.c`) is likely crucial for preventing deadlocks or leaks due to deferred puts and specific thread dependencies. This series is about more than just coredumps, but how coredumps interact with thread exit and signal handling. I need to make sure I take the right entrypoints. And remember the Kconfig options, this also applies to the configuration. `COREDUMP` seems like the relevant configuration. |
| 28/2 | 2026/09/23 11:36 | tool | grepper |
0mArgs:{
"Expression": "coredump\\.o",
"PathPrefix": "fs/"
}Results: {
"Output": "fs/Makefile=46=obj-$(CONFIG_NFS_COMMON)\t+= nfs_common/\nfs/Makefile:47:obj-$(CONFIG_COREDUMP)\t\t+= coredump.o\nfs/Makefile-48-obj-$(CONFIG_SYSCTL)\t\t+= drop_caches.o sysctls.o\n"
} |
| 29/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40839 output: 26 thoughts: 30 Thoughts: Okay, here's my interpretation of those thoughts, tailored for an expert audience, presented in the first person: **Kernel Configuration and Core Dumps: A Quick Diagnostic** Right, let's see... `CONFIG_COREDUMP` just flashed into my mind. I need to quickly establish if the core dump feature is enabled or disabled. My initial hunch is that it's going to be defined in one of the binfmt Kconfig files. Specifically, I'm thinking the `fs/Kconfig.binfmt` file is the most logical place to look first. That's the one I'd check for the `CONFIG_COREDUMP` option definition. It feels like a key parameter for dealing with file format handlers. |
| 30/2 | 2026/09/23 11:36 | tool | grepper |
0mArgs:{
"Expression": "config COREDUMP",
"PathPrefix": "fs/"
}Results: {
"Output": "fs/Kconfig.binfmt=171=config BINFMT_MISC_BPF\n--\nfs/Kconfig.binfmt-184-\nfs/Kconfig.binfmt:185:config COREDUMP\nfs/Kconfig.binfmt-186-\tbool \"Enable core dump support\" if EXPERT\n"
} |
| 31/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41143 output: 35 thoughts: 20 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Diving into `Kconfig.binfmt`** Okay, let's pull up `fs/Kconfig.binfmt`. I'm specifically interested in what's going on around line 185. I'm guessing that's where they're defining or configuring a binfmt-related option. Given the file name, it's likely a kernel configuration option. I'm betting it’s something to do with loading and executing non-native binaries. Knowing the surrounding context will be key, but starting with that specific section is a good entry point. I want to see how this particular binfmt is integrated into the kernel's build process and what dependencies or options it touches on. Time to get my hands dirty. |
| 32/2 | 2026/09/23 11:36 | tool | read-file |
0mArgs:{
"File": "fs/Kconfig.binfmt",
"FirstLine": 180,
"LineCount": 20
}Results: {
"Contents": " 180:\t\t interpreter to use per binary, e.g. relative to the location of\n 181:\t\t the binary itself.\n 182:\t\n 183:\t\t If you don't know what to answer at this point, say N.\n 184:\t\n 185:\tconfig COREDUMP\n 186:\t\tbool \"Enable core dump support\" if EXPERT\n 187:\t\tdefault y\n 188:\t\thelp\n 189:\t\t This option enables support for performing core dumps. You almost\n 190:\t\t certainly want to say Y here. Not necessary on systems that never\n 191:\t\t need debugging or only ever run flawless code.\n 192:\t\n 193:\tconfig EXEC_KUNIT_TEST\n 194:\t\tbool \"Build execve tests\" if !KUNIT_ALL_TESTS\n 195:\t\tdepends on KUNIT=y\n 196:\t\tdefault KUNIT_ALL_TESTS\n 197:\t\thelp\n 198:\t\t This builds the exec KUnit tests, which tests boundary conditions\n 199:\t\t of various aspects of the exec internals.\n"
} |
| 33/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41677 output: 26 thoughts: 44 Thoughts: Okay, here's my thought process laid out, assuming I'm already pretty familiar with kernel internals and async I/O. **Investigating a Potential Async I/O Strategy: io_uring** Right, so I'm thinking about the most performant asynchronous I/O options we have available, and `io_uring` immediately jumps to mind. I'm considering it as a candidate for this specific use case. The question is, can we actually *use* it? Are the pieces in place in this environment? My mental model takes me right to the code; specifically, I'm thinking about the implementation details. Let's start with where the rubber meets the road: I recall that the core logic, or at least a significant portion of it, is in `io_uring/io-wq.c`. My experience tells me that is the best place to start. I know it will depend on the correct flags being enabled. Okay, I'm pretty certain there's a Kconfig option that enables this. Therefore, I need to check the Kconfig file. I need to be sure `CONFIG_IO_URING` is set to "y" or something similar to make sure it will be included in the build. I'll need to confirm that setting. |
| 34/2 | 2026/09/23 11:36 | tool | grepper |
0mArgs:{
"Expression": "config IO_URING",
"PathPrefix": "init/"
}Results: {
"Output": "init/Kconfig=1952=config AIO\n--\ninit/Kconfig-1959-\ninit/Kconfig:1960:config IO_URING\ninit/Kconfig-1961-\tbool \"Enable IO uring support\" if EXPERT\n--\ninit/Kconfig=1969=config GCOV_PROFILE_URING\n--\ninit/Kconfig-1981-\ninit/Kconfig:1982:config IO_URING_MOCK_FILE\ninit/Kconfig-1983-\ttristate \"Enable io_uring mock files (Experimental)\" if EXPERT\n"
} |
| 35/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42176 output: 34 thoughts: 162 Thoughts: **Analyzing Core Dump Configuration Requirements** Okay, so I'm digging into the core dump functionality in the kernel, specifically within `fs/coredump.c`. My initial thought is about the `proc_dostring_coredump` function, which I seem to recall having a configuration dependency. Let's see… Ah, yes, there it is! I'm verifying the requirement of `CONFIG_SYSCTL` for `proc_dostring_coredump`, confirming that it is indeed dependent on that config option by looking around line 1789 in the file. Now, let's broaden the search a bit. I need to ensure I'm getting the complete picture on configuration dependencies. I'll look at the `check_coredump_socket` function to see if it's got any other prerequisites. I'll search around for instances of `#ifdef CONFIG_...` around the `check_coredump_socket` function. Okay, let me zero in on lines 960-975 in `fs/coredump.c`, that should give me what I need. |
| 36/2 | 2026/09/23 11:36 | tool | read-file |
0mArgs:{
"File": "fs/coredump.c",
"FirstLine": 960,
"LineCount": 20
}Results: {
"Contents": " 960:\t{\n 961:\t\tif (!coredump_sock_connect(cn, cprm))\n 962:\t\t\treturn false;\n 963:\t\n 964:\t\treturn coredump_sock_request(cn, cprm);\n 965:\t}\n 966:\t#else\n 967:\tstatic inline void coredump_sock_wait(struct file *file) { }\n 968:\tstatic inline void coredump_sock_shutdown(struct file *file) { }\n 969:\tstatic inline bool coredump_socket(struct core_name *cn, struct coredump_params *cprm) { return false; }\n 970:\t#endif\n 971:\t\n 972:\t/* cprm-\u003edumpable is the snapshot of task dumpability at dump start. */\n 973:\tstatic inline bool coredump_force_suid_safe(const struct coredump_params *cprm)\n 974:\t{\n 975:\t\t/* Require nonrelative corefile path and be extra careful. */\n 976:\t\treturn cprm-\u003edumpable == TASK_DUMPABLE_ROOT;\n 977:\t}\n 978:\t\n 979:\tstatic bool coredump_file(struct core_name *cn, struct coredump_params *cprm,\n"
} |
| 37/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42964 output: 34 thoughts: 21 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Diving into `fs/coredump.c`** Okay, let's get down to brass tacks. I need to understand what's happening around line 680 in the `fs/coredump.c` file. My gut feeling is this is probably going to be a key area for handling the core dump process itself, or possibly a crucial decision point during the write. Given the context of core dumps, this likely deals with a section of the dump writing or perhaps some critical error checking related to permissions, limits, or disk space. I'm expecting to find a conditional statement or a function call related to dumping memory maps, registers, or signal information. The precise location around the code might provide a specific context, maybe file or process-related data handling. I'm hoping to quickly identify the crucial logic flow at that point. I'm looking for the "how" and the "why" of the core dump creation. |
| 38/2 | 2026/09/23 11:36 | tool | read-file |
0mArgs:{
"File": "fs/coredump.c",
"FirstLine": 670,
"LineCount": 20
}Results: {
"Contents": " 670:\t\n 671:\t\t/* and disallow core files too */\n 672:\t\tcurrent-\u003esignal-\u003erlim[RLIMIT_CORE] = (struct rlimit){1, 1};\n 673:\t\n 674:\t\treturn 0;\n 675:\t}\n 676:\t\n 677:\tstatic_assert(sizeof(struct coredump_record_header) == COREDUMP_RECORD_HEADER_SIZE_VER0);\n 678:\t\n 679:\t#ifdef CONFIG_UNIX\n 680:\t/* af_unix halves the send buffer to size a single skb. */\n 681:\t#define COREDUMP_SOCK_SNDBUF_MIN (3 * PAGE_SIZE)\n 682:\t\n 683:\tstatic bool coredump_sock_connect(struct core_name *cn, struct coredump_params *cprm)\n 684:\t{\n 685:\t\tstruct file *file __free(fput) = NULL;\n 686:\t\tstruct sockaddr_un addr = {\n 687:\t\t\t.sun_family = AF_UNIX,\n 688:\t\t};\n 689:\t\tssize_t addr_len;\n"
} |
| 39/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 43562 output: 35 thoughts: 35 Thoughts: Here's my take on those code snippets, focusing on what I find significant as a fellow expert: **Navigating Preprocessor Directives and Core Dumps** Right off the bat, I see that `#ifdef CONFIG_UNIX` on line 679. Okay, I instantly recognize this as a conditional compilation flag. Depending on the build configuration, this suggests that the code block dependent on `CONFIG_UNIX` might only be compiled when a UNIX-like environment is targeted. Makes me start thinking about the implications for portability and platform-specific behavior in this codebase. I need to keep this in mind. Then, my attention snaps to `fs/coredump.c` around line 1640. Now, coredumps are critical for debugging, particularly in complex system environments. I'm immediately interested in the context surrounding that line. Is it related to signal handling? Perhaps it's dealing with writing out process memory to the dump file. I want to understand what specific error condition or data structure is in play. The details there will paint a clear picture of how core dumps are created or handled in this particular filesystem context. Knowing that part of the system is in `fs/` means I need to be aware of the storage or filesystem it is interacting with when a core dump is generated. |
| 40/2 | 2026/09/23 11:36 | tool | read-file |
0mArgs:{
"File": "fs/coredump.c",
"FirstLine": 1640,
"LineCount": 25
}Results: {
"Contents": "1640:\t{\n1641:\t\tif (suid_dumpable == TASK_DUMPABLE_ROOT \u0026\u0026\n1642:\t\t core_pattern[0] != '/' \u0026\u0026 core_pattern[0] != '|' \u0026\u0026 core_pattern[0] != '@') {\n1643:\t\n1644:\t\t\tcoredump_report_failure(\"Unsafe core_pattern used with fs.suid_dumpable=2: \"\n1645:\t\t\t\t\"pipe handler or fully qualified core dump path required. \"\n1646:\t\t\t\t\"Set kernel.core_pattern before fs.suid_dumpable.\");\n1647:\t\t}\n1648:\t}\n1649:\t\n1650:\tstatic inline bool check_coredump_socket(const char *pattern)\n1651:\t{\n1652:\t\tconst char *p;\n1653:\t\n1654:\t\tif (pattern[0] != '@')\n1655:\t\t\treturn true;\n1656:\t\n1657:\t\t/*\n1658:\t\t * Coredump socket must be located in the initial mount\n1659:\t\t * namespace. Don't give the impression that anything else is\n1660:\t\t * supported right now.\n1661:\t\t */\n1662:\t\tif (current-\u003ensproxy-\u003emnt_ns != init_task.nsproxy-\u003emnt_ns)\n1663:\t\t\treturn false;\n1664:\t\n"
} |
| 41/2 | 2026/09/23 11:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44287 output: 32 thoughts: 41 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **Analyzing the Conditional Compilation of `check_coredump_socket()`** Alright, my immediate thought is that `check_coredump_socket()` is wrapped within an `#ifdef CONFIG_SYSCTL` preprocessor directive. That's a key observation. Given its placement, I'm going to quickly pinpoint the *beginning* of that `#ifdef` block. Knowing the scope of that conditional compilation is crucial for understanding the overall build configuration and how this function is potentially enabled or disabled. Specifically, I need to trace back from line 1640 to find where this conditional block is defined, which will provide context around the availability of the function at compile time. |
| 42/2 | 2026/09/23 11:37 | tool | grepper |
0mArgs:{
"Expression": "#ifdef CONFIG_SYSCTL",
"PathPrefix": "fs/coredump.c"
}Results: {
"Output": "fs/coredump.c=1635=EXPORT_SYMBOL(dump_align);\nfs/coredump.c-1636-\nfs/coredump.c:1637:#ifdef CONFIG_SYSCTL\nfs/coredump.c-1638-\n"
} |
| 43/2 | 2026/09/23 11:37 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44601 output: 28 thoughts: 516 Thoughts: **My Analysis of Coredump and Related Kernel Functionality** Okay, so I've pinpointed that the `#ifdef CONFIG_SYSCTL` guard for `proc_dostring_coredump` begins way down at line 1637. This means enabling `CONFIG_SYSCTL` is *essential* for that specific core dump configuration. And to get unix domain socket support for coredumps, I'll need `CONFIG_UNIX=y`, of course. With `CONFIG_COREDUMP=y`, core dump support is compiled generally, and with `CONFIG_IO_URING=y` the io_uring worker support becomes available. Now, let's make sure I'm not missing anything else that might be built conditionally. It looks like `fs/exec.c`, `fs/file.c`, `kernel/exit.c`, `kernel/fork.c`, `kernel/ptrace.c`, and `kernel/signal.c` all seem to be built unconditionally. Good to know. Next, I need to zero in on the relevant symbols – the ones that are specific and non-ubiquitous, and that are *directly* involved in the logic that's been modified. Time to evaluate: 1. `vfs_coredump` – This is the primary entry point for coredumping, so it's a critical function, exercising `coredump_parse`, `coredump_finish`, and `dump_interrupted`. Worth a deeper look. 2. `coredump_signal_pending` – This is a *new* exported function that directly implements the signal check during core dump processes. Very interesting, and definitely needs scrutiny. 3. `proc_dostring_coredump` – This is a sysctl handler for `kernel.core_pattern` that has had some modifications. It uses a spinlock, copy-in operation, and it validates through `check_coredump_socket`. This needs to be considered. 4. `create_io_thread` – Entrypoint for io_uring worker thread creation. Looks like it now checks `PF_SIGNALED | PF_POSTCOREDUMP`. That's a key detail. 5. `io_wq_exit_start` – I need to remember the io-wq cancellation logic is likely affected by this. 6. `ptrace_request` – The ptrace request handler has been modified for `PTRACE_SETSIGMASK` if `PF_USER_WORKER`. Definitely relevant for this investigation. 7. `close_cloexec_files` – This function closes cloexec files in reverse order in `fs/file.c`. 8. `__range_close` or `__do_sys_close_range`? Okay, `__range_close` is static inline in `fs/file.c`. But what about `close_range`? I should check with `nm` or the symbol name. Now I've got a solid list of the key areas to probe, I'm ready to proceed with more specific testing and analysis. |
| 44/2 | 2026/09/23 11:37 | tool | grepper |
0mArgs:{
"Expression": "close_range",
"PathPrefix": "fs/file.c"
}Results: {
"Output": "fs/file.c-21-#include \u003clinux/rcupdate.h\u003e\nfs/file.c:22:#include \u003clinux/close_range.h\u003e\nfs/file.c-23-#include \u003clinux/file_ref.h\u003e\n--\nfs/file.c=350=static inline bool fd_is_open(unsigned int fd, const struct fdtable *fdt)\n--\nfs/file.c-358- *\nfs/file.c:359: * punch_hole is optional - when close_range() is asked to unshare\nfs/file.c-360- * and close, we don't need to copy descriptors in that range, so\n--\nfs/file.c=789=static inline void __range_close(struct files_struct *files, unsigned int fd,\n--\nfs/file.c-825-/**\nfs/file.c:826: * sys_close_range() - Close all file descriptors in a given range.\nfs/file.c-827- *\n--\nfs/file.c-835- */\nfs/file.c:836:SYSCALL_DEFINE3(close_range, unsigned int, fd, unsigned int, max_fd,\nfs/file.c-837-\t\tunsigned int, flags)\n"
} |
| 45/2 | 2026/09/23 11:37 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46135 output: 29 thoughts: 457 Thoughts: **Dissecting Kernel Signal and File Operations**
Okay, so I'm diving into some kernel code, specifically focusing on signal handling and file operations, and a few things are catching my attention.
First, in `fs/file.c`, I see `__range_close` defined as `static inline`. The syscall side of things, `close_range`, is implemented as `__do_sys_close_range` and `__x64_sys_close_range`. Nothing particularly strange there, although it's always good to be aware of the syscall wrappers. `close_cloexec_files` is non-static, so it's accessible outside the file. Makes sense. But what's the connection, if any, to functions like `__set_current_blocked` or `set_current_blocked`? I'll need to follow the cross-references and understand if there's any interplay here.
Now, shifting gears to `kernel/signal.c`, I spot that `__set_task_blocked` is `static` and that it's called by `__set_current_blocked` and `do_sigtimedwait`. That's a pretty standard pattern.
But look at this! Inside `__set_task_blocked`, there's a section with this code snippet:
```c
static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)
{
sigset_t floor, floored;
/* A user worker never unblocks anything but SIGKILL and SIGSTOP. */
if (unlikely(tsk->flags & PF_USER_WORKER)) {
siginitsetinv(&floor, SIG_KERNEL_ONLY_MASK);
sigorsets(&floored, newset, &floor);
WARN_ON_ONCE(!sigequalsets(&floored, newset));
newset = &floored;
}
...
```
Ah, a `WARN_ON_ONCE`! That means a potential logic issue was identified and a warning was added. That's always a flag, I'll have to dig into the rationale behind that. Seems like it is related to the handling of signals in user workers. It has to do with how the signal mask is handled for user workers, and how they cannot unblock anything other than SIGKILL and SIGSTOP.
Then I see that `retarget_shared_pending` was modified. Let's see:
```c
static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
{
sigset_t retarget;
struct task_struct *t;
/* Nobody dequeues them in a dying group, see get_signal(). */
if (tsk->signal->flags & SIGNAL_GROUP_EXIT)
return;
...
```
`retarget_shared_pending` is also `static`, and it's called by `exit_signals` and, interestingly, `__set_task_blocked`. This suggests they're related in some capacity. And aha! `exit_signals` is *not* `static`. That's a key detail. This suggests that the signal handling code, particularly in regards to blocked tasks and how pending signals are shared, are intertwined. I need to understand this connection and how they affect each other, and look deeper into `exit_signals`, to understand it fully. I'll take a look at the definition of `exit_signals` in `kernel/signal.c`.
|
| 46/2 | 2026/09/23 11:37 | tool | grepper |
0mArgs:{
"Expression": "void exit_signals",
"PathPrefix": "kernel/signal.c"
}Results: {
"Output": "kernel/signal.c=3115=static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)\n--\nkernel/signal.c-3144-\nkernel/signal.c:3145:void exit_signals(struct task_struct *tsk)\nkernel/signal.c-3146-{\n"
} |
| 47/2 | 2026/09/23 11:37 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47494 output: 229 thoughts: 1245 Thoughts: **Focus Symbol Selection and Dependency Verification** Okay, let's break this down. I need to identify the key functions—the *FocusSymbols*—that are most relevant to fuzzing this patch series. My initial thought process led me to consider `exit_signals`, but then I realized it's called from `do_exit`, and I need to target specific logic, not overly ubiquitous functions. The same goes for `begin_new_exec` from `fs/exec.c`, although it is important, it's called by *every* `execve`, making it too generic. I'm focusing on "TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS," as the guidelines state. So, I've compiled a refined list: * `vfs_coredump` (fs/coredump.c) * `coredump_signal_pending` (kernel/signal.c) * `proc_dostring_coredump` (fs/coredump.c) * `create_io_thread` (kernel/fork.c) * `io_wq_exit_start` (io_uring/io-wq.c) * `close_cloexec_files` (fs/file.c) * `ptrace_request` (kernel/ptrace.c) * `__set_current_blocked` (kernel/signal.c) Next, I need to verify that these are actual kernel functions. A quick cross-reference confirms their existence and signatures in the codebase. Satisfied that they're real, I'm checking the relevant kernel configurations. I'm noting that `COREDUMP`, `SYSCTL`, `IO_URING`, and `UNIX` need to be enabled for these symbols to be relevant. After a quick look at the configuration, I'm verifying the dependencies, seeing that `COREDUMP` and `IO_URING` default to `EXPERT=y` and `UNIX` depends on `NET`. This solidifies the relevance of these symbols to the fuzzer. Finally, I've got to ensure the reasoning behind my selection aligns with the patch series' content. This patch series tackles coredump, io_uring worker threads (`io-wq`), signal delivery/retargeting during group exit, and file descriptor teardown, with changes that include assertions (`WARN_ON_ONCE`), synchronization, and order of operations, enforcement of ptrace restrictions and a new `coredump_signal_pending` check. These core subsystems (VFS, signals, coredump, ptrace, io_uring) are all reachable and warrant focused fuzzing. I'm confident that this approach adheres to the guidelines and provides a sound basis for fuzzing these key areas. Time to call `set-results`. |
| 48/2 | 2026/09/23 11:37 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"COREDUMP",
"IO_URING",
"SYSCTL",
"UNIX"
],
"FocusSymbols": [
"vfs_coredump",
"coredump_signal_pending",
"proc_dostring_coredump",
"create_io_thread",
"io_wq_exit_start",
"close_cloexec_files",
"ptrace_request",
"__set_current_blocked"
],
"Reasoning": "The patch series modifies core kernel subsystems including coredump handling, signal retargeting, io_uring worker thread lifecycle, ptrace restrictions, and file descriptor teardown. It adds synchronization via spinlocks and barriers, reverses the fd closing order in close_files/close_cloexec_files, introduces a new runtime assertion (WARN_ON_ONCE) in __set_task_blocked, and restructures coredump/io_uring cancellation. All changes are in highly reachable code paths and warrant fuzzing.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"COREDUMP",
"IO_URING",
"SYSCTL",
"UNIX"
],
"FocusSymbols": [
"vfs_coredump",
"coredump_signal_pending",
"proc_dostring_coredump",
"create_io_thread",
"io_wq_exit_start",
"close_cloexec_files",
"ptrace_request",
"__set_current_blocked"
],
"Reasoning": "The patch series modifies core kernel subsystems including coredump handling, signal retargeting, io_uring worker thread lifecycle, ptrace restrictions, and file descriptor teardown. It adds synchronization via spinlocks and barriers, reverses the fd closing order in close_files/close_cloexec_files, introduces a new runtime assertion (WARN_ON_ONCE) in __set_task_blocked, and restructures coredump/io_uring cancellation. All changes are in highly reachable code paths and warrant fuzzing.",
"WorthFuzzing": true
} |
| 49/1 | 2026/09/23 11:37 | action | If |
2mArgs:{
"WorthFuzzing": true
}Results: null |
| 50/2 | 2026/09/23 11:37 | agent | kmsan-evaluator |
2mModel:core Args: null Results: {
"KMSANReasoning": "The patch series focuses on race conditions, process lifecycle, signal masks, and file descriptor closing order during coredump, exec, fork, and exit paths:\n1. fs/coredump.c: Introduces a spinlock (`core_pattern_lock`) protecting reads and writes to `core_pattern`. The local stack buffers `pattern` in `coredump_parse()` and `proc_dostring_coredump()` are populated using `strscpy()`, and subsequent string processing is strictly null-terminated or length-checked. The sysctl read/write handlers operate strictly on the string length (`strlen`), so uninitialized stack bytes are never copied to userspace.\n2. fs/coredump.c: Protects exiting threads with RCU during wakeup in `coredump_finish()` (guards against use-after-free, which is a KASAN domain).\n3. fs/file.c: Changes the iteration order when closing fds (using `__fls()` and `find_last_bit()` from highest to lowest fd) on existing bitmap structures without altering allocation or initialization.\n4. kernel/fork.c, kernel/exit.c, fs/exec.c, io_uring/io-wq.c: Reorders teardown steps, initializes `p-\u003efiles = NULL`, and cancels io_uring tasks earlier to prevent deadlocks and races with user workers.\n5. kernel/signal.c: `floor` and `floored` sigset_t variables in `__set_task_blocked()` are fully initialized via `siginitsetinv()` and `sigorsets()`.\n\nNone of the changes introduce uninitialized memory reads, info-leaks to userspace, or uninitialized padding exposure. The concerns addressed by this patch relate to synchronization, lifecycle/UAF, and deadlock prevention, which are covered by KASAN and LOCKDEP rather than KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 992c6a755e67237899965b09325acaeaceeef2ea
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Sep 23 11:34:41 2026 +0000
syz-cluster: applied patch under review
diff --git a/fs/coredump.c b/fs/coredump.c
index 16b331b686fbe..d5d76704df810 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -85,6 +85,8 @@ static int core_uses_pid;
static unsigned int core_pipe_limit;
static unsigned int core_sort_vma;
static char core_pattern[CORENAME_MAX_SIZE] = "core";
+/* Taken around every copy in and out of core_pattern. */
+static DEFINE_SPINLOCK(core_pattern_lock);
static int core_name_size = CORENAME_MAX_SIZE;
unsigned int core_file_note_size_limit = CORE_FILE_NOTE_SIZE_DEFAULT;
static atomic_t core_pipe_count = ATOMIC_INIT(0);
@@ -240,11 +242,16 @@ static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,
size_t **argv, int *argc)
{
const struct cred *cred = current_cred();
- const char *pat_ptr = core_pattern;
+ char pattern[CORENAME_MAX_SIZE];
+ const char *pat_ptr = pattern;
bool was_space = false;
int pid_in_pattern = 0;
int err = 0;
+ /* The sysctl handler may be publishing a new pattern. */
+ scoped_guard(spinlock, &core_pattern_lock)
+ strscpy(pattern, core_pattern);
+
cprm->mask = COREDUMP_KERNEL;
if (core_pipe_limit)
cprm->mask |= COREDUMP_WAIT;
@@ -561,6 +568,8 @@ static void coredump_finish(enum coredump_state state)
current->signal->core_state = NULL;
spin_unlock_irq(¤t->sighand->siglock);
+ /* A released thread may exit and be freed before it is woken. */
+ guard(rcu)();
while ((curr = next) != NULL) {
next = curr->next;
task = curr->task;
@@ -569,6 +578,7 @@ static void coredump_finish(enum coredump_state state)
* ->task == NULL before we read ->next.
*/
smp_mb();
+ /* Any wakeup now lets the thread exit, rcu keeps it alive. */
curr->task = NULL;
wake_up_process(task);
}
@@ -577,12 +587,13 @@ static void coredump_finish(enum coredump_state state)
static bool dump_interrupted(void)
{
/*
- * SIGKILL or freezing() interrupt the coredumping. Perhaps we
- * can do try_to_freeze() and check __fatal_signal_pending(),
- * but then we need to teach dump_write() to restart and clear
- * TIF_SIGPENDING.
+ * SIGKILL, freezing() or the cgroup v2 freezer trap interrupt the
+ * coredumping. Perhaps we can do try_to_freeze() and check
+ * __fatal_signal_pending(), but then we need to teach dump_write()
+ * to restart and clear TIF_SIGPENDING.
*/
- return fatal_signal_pending(current) || freezing(current);
+ return fatal_signal_pending(current) || freezing(current) ||
+ (READ_ONCE(current->jobctl) & JOBCTL_TRAP_FREEZE);
}
static void wait_for_dump_helpers(struct file *file)
@@ -1636,11 +1647,11 @@ void validate_coredump_safety(void)
}
}
-static inline bool check_coredump_socket(void)
+static inline bool check_coredump_socket(const char *pattern)
{
const char *p;
- if (core_pattern[0] != '@')
+ if (pattern[0] != '@')
return true;
/*
@@ -1652,16 +1663,16 @@ static inline bool check_coredump_socket(void)
return false;
/* Must be an absolute path... */
- if (core_pattern[1] != '/') {
+ if (pattern[1] != '/') {
/* ... or the socket request protocol... */
- if (core_pattern[1] != '@')
+ if (pattern[1] != '@')
return false;
/* ... and if so must be an absolute path. */
- if (core_pattern[2] != '/')
+ if (pattern[2] != '/')
return false;
- p = &core_pattern[2];
+ p = &pattern[2];
} else {
- p = &core_pattern[1];
+ p = &pattern[1];
}
/* The path obviously cannot exceed UNIX_PATH_MAX. */
@@ -1669,7 +1680,7 @@ static inline bool check_coredump_socket(void)
return false;
/* Must not contain ".." in the path. */
- if (name_contains_dotdot(core_pattern))
+ if (name_contains_dotdot(pattern))
return false;
return true;
@@ -1678,27 +1689,35 @@ static inline bool check_coredump_socket(void)
static int proc_dostring_coredump(const struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
+ char pattern[CORENAME_MAX_SIZE];
+ const struct ctl_table tmp = {
+ .procname = table->procname,
+ .data = pattern,
+ .maxlen = sizeof(pattern),
+ };
+ bool changed = false;
int error;
- ssize_t retval;
- char old_core_pattern[CORENAME_MAX_SIZE];
-
- if (!write)
- return proc_dostring(table, write, buffer, lenp, ppos);
- retval = strscpy(old_core_pattern, core_pattern, CORENAME_MAX_SIZE);
+ /* Work on a copy, proc_dostring() appends at *ppos. */
+ scoped_guard(spinlock, &core_pattern_lock)
+ strscpy(pattern, core_pattern);
- error = proc_dostring(table, write, buffer, lenp, ppos);
- if (error)
+ error = proc_dostring(&tmp, write, buffer, lenp, ppos);
+ if (error || !write)
return error;
- if (!check_coredump_socket()) {
- strscpy(core_pattern, old_core_pattern, retval + 1);
+ if (!check_coredump_socket(pattern))
return -EINVAL;
- }
- if (strncmp(old_core_pattern, core_pattern, CORENAME_MAX_SIZE))
+ /* Publish the validated pattern whole. */
+ scoped_guard(spinlock, &core_pattern_lock) {
+ changed = strncmp(pattern, core_pattern, CORENAME_MAX_SIZE);
+ if (changed)
+ strscpy(core_pattern, pattern);
+ }
+ if (changed)
validate_coredump_safety();
- return error;
+ return 0;
}
static const unsigned int core_file_note_size_min = CORE_FILE_NOTE_SIZE_DEFAULT;
diff --git a/fs/exec.c b/fs/exec.c
index 075a744421e14..334e6d358c567 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1149,16 +1149,19 @@ int begin_new_exec(struct linux_binprm * bprm)
*/
bprm->point_of_no_return = true;
+ /*
+ * Cancel any io_uring activity across execve. This runs task work
+ * that may still create an io-wq worker, so do it while de_thread()
+ * can still zap it.
+ */
+ io_uring_task_cancel();
+
/* Make this the only thread in the thread group */
retval = de_thread(me);
if (retval)
goto out;
/* see the comment in check_unsafe_exec() */
current->fs->in_exec = 0;
- /*
- * Cancel any io_uring activity across execve
- */
- io_uring_task_cancel();
/* Ensure the files table is not shared. */
retval = unshare_fd(CLONE_FILES, &files);
diff --git a/fs/file.c b/fs/file.c
index 76e328edf6305..7f8d0afd8807a 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -497,24 +497,21 @@ static struct fdtable *close_files(struct files_struct *files)
* files structure.
*/
struct fdtable *fdt = rcu_dereference_raw(files->fdt);
- unsigned int i, j = 0;
+ unsigned int j = fdt->max_fds / BITS_PER_LONG;
+
+ /* Highest fd first, the order the deferred puts ran in. */
+ while (j--) {
+ unsigned long set = fdt->open_fds[j];
- for (;;) {
- unsigned long set;
- i = j * BITS_PER_LONG;
- if (i >= fdt->max_fds)
- break;
- set = fdt->open_fds[j++];
while (set) {
- if (set & 1) {
- struct file *file = fdt->fd[i];
- if (file) {
- filp_close_sync(file, files);
- cond_resched();
- }
+ unsigned int bit = __fls(set);
+ struct file *file = fdt->fd[j * BITS_PER_LONG + bit];
+
+ set ^= 1UL << bit;
+ if (file) {
+ filp_close_sync(file, files);
+ cond_resched();
}
- i++;
- set >>= 1;
}
}
@@ -801,10 +798,14 @@ static inline void __range_close(struct files_struct *files, unsigned int fd,
n = last_fd(fdt);
max_fd = min(max_fd, n);
- for (fd = find_next_bit(fdt->open_fds, max_fd + 1, fd);
- fd <= max_fd;
- fd = find_next_bit(fdt->open_fds, max_fd + 1, fd + 1)) {
- file = file_close_fd_locked(files, fd);
+ /* Highest fd first, see close_files(). */
+ for (n = max_fd + 1; n > fd; ) {
+ unsigned int cur = find_last_bit(fdt->open_fds, n);
+
+ if (cur >= n || cur < fd)
+ break;
+ n = cur;
+ file = file_close_fd_locked(files, cur);
if (file) {
spin_unlock(&files->file_lock);
filp_close_sync(file, files);
@@ -908,20 +909,22 @@ void close_cloexec_files(struct files_struct *files)
/* exec unshares first */
spin_lock(&files->file_lock);
- for (i = 0; ; i++) {
+ fdt = files_fdtable(files);
+ /* Highest fd first, see close_files(). */
+ for (i = fdt->max_fds / BITS_PER_LONG; i--; ) {
unsigned long set;
- unsigned fd = i * BITS_PER_LONG;
+
fdt = files_fdtable(files);
- if (fd >= fdt->max_fds)
- break;
set = fdt->close_on_exec[i];
if (!set)
continue;
fdt->close_on_exec[i] = 0;
- for ( ; set ; fd++, set >>= 1) {
+ while (set) {
+ unsigned int bit = __fls(set);
+ unsigned fd = i * BITS_PER_LONG + bit;
struct file *file;
- if (!(set & 1))
- continue;
+
+ set ^= 1UL << bit;
file = fdt->fd[fd];
if (!file)
continue;
diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index e039e29cd8c58..3835fbf7d80f2 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -384,6 +384,13 @@ static inline int task_sigpending(struct task_struct *p)
return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING));
}
+static inline int __fatal_signal_pending(struct task_struct *p)
+{
+ return unlikely(sigismember(&p->pending.signal, SIGKILL));
+}
+
+bool coredump_signal_pending(struct task_struct *p);
+
static inline int signal_pending(struct task_struct *p)
{
/*
@@ -393,12 +400,12 @@ static inline int signal_pending(struct task_struct *p)
*/
if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL)))
return 1;
- return task_sigpending(p);
-}
-
-static inline int __fatal_signal_pending(struct task_struct *p)
-{
- return unlikely(sigismember(&p->pending.signal, SIGKILL));
+ if (!task_sigpending(p))
+ return 0;
+ /* A coredumping task only stops for SIGKILL or the freezer. */
+ if (unlikely(READ_ONCE(p->flags) & PF_DUMPCORE))
+ return coredump_signal_pending(p);
+ return 1;
}
static inline int fatal_signal_pending(struct task_struct *p)
diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c
index 2ca223e47d41f..2a980e86dd940 100644
--- a/io_uring/io-wq.c
+++ b/io_uring/io-wq.c
@@ -1324,6 +1324,8 @@ static bool io_task_work_match(struct callback_head *cb, void *data)
void io_wq_exit_start(struct io_wq *wq)
{
set_bit(IO_WQ_BIT_EXIT, &wq->state);
+ /* Pairs with task_work_add() in io_queue_worker_create(). */
+ smp_mb__after_atomic();
}
static void io_wq_cancel_tw_create(struct io_wq *wq)
diff --git a/kernel/exit.c b/kernel/exit.c
index 55dbea3b242e1..9ed5eb03d0e19 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1003,10 +1003,11 @@ void __noreturn do_exit(long code)
exit_sem(tsk);
exit_shm(tsk);
- exit_files(tsk);
- exit_fs(tsk);
+ /* Hang the tty up before the last close of it can clear the session. */
if (group_dead)
disassociate_ctty(1);
+ exit_files(tsk);
+ exit_fs(tsk);
exit_nsproxy_namespaces(tsk);
exit_task_work(tsk);
exit_thread(tsk);
diff --git a/kernel/fork.c b/kernel/fork.c
index 10be4a0ecb3f1..be5980d0dd9f3 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -1676,6 +1676,7 @@ static int copy_files(u64 clone_flags, struct task_struct *tsk,
if (clone_flags & CLONE_FILES) {
atomic_inc(&oldf->count);
+ tsk->files = oldf;
return 0;
}
@@ -2145,12 +2146,9 @@ __latent_entropy struct task_struct *copy_process(
if (args->kthread)
p->flags |= PF_KTHREAD;
if (args->user_worker) {
- /*
- * Mark us a user worker, and block any signal that isn't
- * fatal or STOP
- */
+ /* A user worker takes only the signals nobody can block. */
p->flags |= PF_USER_WORKER;
- siginitsetinv(&p->blocked, sigmask(SIGKILL)|sigmask(SIGSTOP));
+ siginitsetinv(&p->blocked, SIG_KERNEL_ONLY_MASK);
}
if (args->io_thread)
p->flags |= PF_IO_WORKER;
@@ -2199,6 +2197,8 @@ __latent_entropy struct task_struct *copy_process(
INIT_LIST_HEAD(&p->sibling);
rcu_copy_process(p);
p->vfork_done = NULL;
+ /* Set by copy_files(), exit_files() on the error path skips NULL. */
+ p->files = NULL;
spin_lock_init(&p->alloc_lock);
init_sigpending(&p->pending);
@@ -2300,7 +2300,7 @@ __latent_entropy struct task_struct *copy_process(
goto bad_fork_cleanup_semundo;
retval = copy_fs(clone_flags, p, args->umh);
if (retval)
- goto bad_fork_cleanup_files;
+ goto bad_fork_cleanup_semundo;
retval = copy_sighand(clone_flags, p);
if (retval)
goto bad_fork_cleanup_fs;
@@ -2613,8 +2613,6 @@ __latent_entropy struct task_struct *copy_process(
__cleanup_sighand(p->sighand);
bad_fork_cleanup_fs:
exit_fs(p); /* blocking */
-bad_fork_cleanup_files:
- exit_files(p); /* blocking */
bad_fork_cleanup_semundo:
exit_sem(p);
bad_fork_cleanup_security:
@@ -2625,6 +2623,8 @@ __latent_entropy struct task_struct *copy_process(
perf_event_free_task(p);
bad_fork_sched_cancel_fork:
sched_cancel_fork(p);
+ /* ->release() of a file may need scx_fork_rwsem for write. */
+ exit_files(p); /* blocking */
bad_fork_cleanup_policy:
lockdep_free_task(p);
#ifdef CONFIG_NUMA
@@ -2703,6 +2703,10 @@ struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node)
.user_worker = 1,
};
+ /* A creator past its fatal signal or its coredump point gets no thread. */
+ if (current->flags & (PF_SIGNALED | PF_POSTCOREDUMP))
+ return ERR_PTR(-EINTR);
+
return copy_process(NULL, 0, node, &args);
}
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d041645d9d17d..4e9822a87aabb 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1227,6 +1227,12 @@ int ptrace_request(struct task_struct *child, long request,
case PTRACE_SETSIGMASK: {
sigset_t new_set;
+ /* A user worker only ever takes SIGKILL and SIGSTOP. */
+ if (child->flags & PF_USER_WORKER) {
+ ret = -EPERM;
+ break;
+ }
+
if (addr != sizeof(sigset_t)) {
ret = -EINVAL;
break;
diff --git a/kernel/signal.c b/kernel/signal.c
index ec30550951ecf..137002445b0dc 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -717,6 +717,14 @@ void signal_wake_up_state(struct task_struct *t, unsigned int state)
kick_process(t);
}
+/* Only SIGKILL or a freezer interrupt a coredump, see dump_interrupted(). */
+bool coredump_signal_pending(struct task_struct *p)
+{
+ return __fatal_signal_pending(p) || freezing(p) ||
+ (READ_ONCE(p->jobctl) & JOBCTL_TRAP_FREEZE);
+}
+EXPORT_SYMBOL(coredump_signal_pending);
+
static inline void posixtimer_sig_ignore(struct task_struct *tsk, struct sigqueue *q);
static void sigqueue_free_ignored(struct task_struct *tsk, struct sigqueue *q)
@@ -3109,6 +3117,10 @@ static void retarget_shared_pending(struct task_struct *tsk, sigset_t *which)
sigset_t retarget;
struct task_struct *t;
+ /* Nobody dequeues them in a dying group, see get_signal(). */
+ if (tsk->signal->flags & SIGNAL_GROUP_EXIT)
+ return;
+
sigandsets(&retarget, &tsk->signal->shared_pending.signal, which);
if (sigisemptyset(&retarget))
return;
@@ -3200,6 +3212,16 @@ long do_no_restart_syscall(struct restart_block *param)
static void __set_task_blocked(struct task_struct *tsk, const sigset_t *newset)
{
+ sigset_t floor, floored;
+
+ /* A user worker never unblocks anything but SIGKILL and SIGSTOP. */
+ if (unlikely(tsk->flags & PF_USER_WORKER)) {
+ siginitsetinv(&floor, SIG_KERNEL_ONLY_MASK);
+ sigorsets(&floored, newset, &floor);
+ WARN_ON_ONCE(!sigequalsets(&floored, newset));
+ newset = &floored;
+ }
+
if (task_sigpending(tsk) && !thread_group_empty(tsk)) {
sigset_t newblocked;
/* A set of now blocked but previously unblocked signals. */
diff --git a/tools/testing/selftests/coredump/.gitignore b/tools/testing/selftests/coredump/.gitignore
index 097f52db0be96..e32f6e9006f6e 100644
--- a/tools/testing/selftests/coredump/.gitignore
+++ b/tools/testing/selftests/coredump/.gitignore
@@ -2,3 +2,5 @@
stackdump_test
coredump_socket_test
coredump_socket_protocol_test
+coredump_signal_test
+coredump_worker_test
diff --git a/tools/testing/selftests/coredump/Makefile b/tools/testing/selftests/coredump/Makefile
index dece1a31d561b..57ec331f03a76 100644
--- a/tools/testing/selftests/coredump/Makefile
+++ b/tools/testing/selftests/coredump/Makefile
@@ -3,7 +3,9 @@ CFLAGS += -Wall -O0 -g $(KHDR_INCLUDES) $(TOOLS_INCLUDES)
TEST_GEN_PROGS := stackdump_test \
coredump_socket_test \
- coredump_socket_protocol_test
+ coredump_socket_protocol_test \
+ coredump_signal_test \
+ coredump_worker_test
TEST_FILES := stackdump
include ../lib.mk
@@ -11,3 +13,5 @@ include ../lib.mk
$(OUTPUT)/stackdump_test: coredump_test_helpers.c
$(OUTPUT)/coredump_socket_test: coredump_test_helpers.c
$(OUTPUT)/coredump_socket_protocol_test: coredump_test_helpers.c
+$(OUTPUT)/coredump_signal_test: coredump_test_helpers.c
+$(OUTPUT)/coredump_worker_test: coredump_test_helpers.c
diff --git a/tools/testing/selftests/coredump/coredump_signal_test.c b/tools/testing/selftests/coredump/coredump_signal_test.c
new file mode 100644
index 0000000000000..fdf48b1447811
--- /dev/null
+++ b/tools/testing/selftests/coredump/coredump_signal_test.c
@@ -0,0 +1,238 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <fcntl.h>
+#include <pthread.h>
+#include <signal.h>
+#include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/un.h>
+#include <unistd.h>
+
+#include "coredump_test.h"
+
+/* Big enough to fill the socket buffer many times over. */
+#define CRASH_MAPPING_SIZE (32 * 1024 * 1024)
+
+FIXTURE_SETUP(coredump)
+{
+ FILE *file;
+ int ret;
+
+ self->pid_coredump_server = -ESRCH;
+ self->fd_tmpfs_detached = -1;
+ file = fopen("/proc/sys/kernel/core_pattern", "r");
+ ASSERT_NE(NULL, file);
+
+ ret = fread(self->original_core_pattern, 1, sizeof(self->original_core_pattern), file);
+ ASSERT_TRUE(ret || feof(file));
+ ASSERT_LT(ret, sizeof(self->original_core_pattern));
+
+ self->original_core_pattern[ret] = '\0';
+
+ ret = fclose(file);
+ ASSERT_EQ(0, ret);
+}
+
+FIXTURE_TEARDOWN(coredump)
+{
+ const char *reason;
+ FILE *file;
+ int ret, status;
+
+ if (self->pid_coredump_server > 0) {
+ kill(self->pid_coredump_server, SIGTERM);
+ waitpid(self->pid_coredump_server, &status, 0);
+ }
+ unlink("/tmp/coredump.file");
+ unlink("/tmp/coredump.socket");
+
+ file = fopen("/proc/sys/kernel/core_pattern", "w");
+ if (!file) {
+ reason = "Unable to open core_pattern";
+ goto fail;
+ }
+
+ ret = fprintf(file, "%s", self->original_core_pattern);
+ if (ret < 0) {
+ reason = "Unable to write to core_pattern";
+ goto fail;
+ }
+
+ ret = fclose(file);
+ if (ret) {
+ reason = "Unable to close core_pattern";
+ goto fail;
+ }
+
+ return;
+fail:
+ /* This should never happen */
+ fprintf(stderr, "Failed to cleanup coredump test: %s\n", reason);
+}
+
+static volatile int waiter_ready;
+
+static void usr1_handler(int sig)
+{
+}
+
+/* Sleeps in sigtimedwait() with SIGUSR1 unblocked only inside the kernel. */
+static void *sigwaiter(void *arg)
+{
+ sigset_t set;
+ siginfo_t info;
+
+ sigemptyset(&set);
+ sigaddset(&set, SIGUSR1);
+ __atomic_store_n(&waiter_ready, 1, __ATOMIC_RELEASE);
+ for (;;)
+ sigtimedwait(&set, &info, NULL);
+ return NULL;
+}
+
+/*
+ * Crash with a shared SIGUSR1 still queued for this thread. The vfork()
+ * child queues it while we sleep killably and then the SIGSEGV that is
+ * dequeued first. The zap wakes the sibling out of sigtimedwait() and its
+ * mask restore retargets SIGUSR1 to the dumper.
+ */
+static void crashing_child_retarget(bool queue_shared)
+{
+ sigset_t all, old;
+ pthread_t thread;
+ pid_t pid, tid;
+ char *p;
+
+ p = mmap(NULL, CRASH_MAPPING_SIZE, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (p == MAP_FAILED)
+ _exit(EXIT_FAILURE);
+ memset(p, 0x5a, CRASH_MAPPING_SIZE);
+
+ signal(SIGUSR1, usr1_handler);
+ sigfillset(&all);
+ pthread_sigmask(SIG_BLOCK, &all, &old);
+ /* One waiter only, retarget stops at the first thread not blocking it. */
+ if (pthread_create(&thread, NULL, sigwaiter, NULL))
+ _exit(EXIT_FAILURE);
+ pthread_sigmask(SIG_SETMASK, &old, NULL);
+ while (!__atomic_load_n(&waiter_ready, __ATOMIC_ACQUIRE))
+ usleep(1000);
+ usleep(50 * 1000);
+
+ pid = getpid();
+ tid = syscall(SYS_gettid);
+ if (vfork() == 0) {
+ if (queue_shared)
+ syscall(SYS_kill, pid, SIGUSR1);
+ syscall(SYS_tgkill, pid, tid, SIGSEGV);
+ syscall(SYS_exit, 0);
+ }
+
+ /* Not reached, the pending SIGSEGV dumps core. */
+ for (;;)
+ pause();
+}
+
+/*
+ * Dump the crashing child into /tmp/coredump.file through a server that
+ * holds the read back so the dumper blocks on the full socket buffer.
+ */
+static void run_coredump(struct __test_metadata *const _metadata,
+ FIXTURE_DATA(coredump) *self, bool queue_shared)
+{
+ pid_t pid, pid_coredump_server;
+ int ipc_sockets[2];
+ int status;
+ char c;
+
+ unlink("/tmp/coredump.file");
+ unlink("/tmp/coredump.socket");
+ ASSERT_TRUE(set_core_pattern("@/tmp/coredump.socket"));
+ ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, ipc_sockets), 0);
+
+ pid_coredump_server = fork();
+ ASSERT_GE(pid_coredump_server, 0);
+ if (pid_coredump_server == 0) {
+ int fd_server = -1, fd_coredump = -1, fd_core_file = -1;
+ int exit_code = EXIT_FAILURE;
+
+ close(ipc_sockets[0]);
+
+ fd_server = create_and_listen_unix_socket("/tmp/coredump.socket");
+ if (fd_server < 0)
+ goto out;
+
+ if (write_nointr(ipc_sockets[1], "1", 1) < 0)
+ goto out;
+ close(ipc_sockets[1]);
+
+ fd_coredump = accept4(fd_server, NULL, NULL, SOCK_CLOEXEC);
+ if (fd_coredump < 0) {
+ fprintf(stderr, "%s: accept4 failed: %m\n", __func__);
+ goto out;
+ }
+
+ /* Let the dumper run into the full socket buffer first. */
+ sleep(1);
+
+ fd_core_file = creat("/tmp/coredump.file", 0644);
+ if (fd_core_file < 0) {
+ fprintf(stderr, "%s: creat failed: %m\n", __func__);
+ goto out;
+ }
+
+ if (recv_coredump_bytes(fd_coredump, fd_core_file) < 0)
+ goto out;
+
+ exit_code = EXIT_SUCCESS;
+out:
+ if (fd_core_file >= 0)
+ close(fd_core_file);
+ if (fd_coredump >= 0)
+ close(fd_coredump);
+ if (fd_server >= 0)
+ close(fd_server);
+ _exit(exit_code);
+ }
+ self->pid_coredump_server = pid_coredump_server;
+
+ EXPECT_EQ(close(ipc_sockets[1]), 0);
+ ASSERT_EQ(read_nointr(ipc_sockets[0], &c, 1), 1);
+ EXPECT_EQ(close(ipc_sockets[0]), 0);
+
+ pid = fork();
+ ASSERT_GE(pid, 0);
+ if (pid == 0)
+ crashing_child_retarget(queue_shared);
+
+ waitpid(pid, &status, 0);
+ ASSERT_TRUE(WIFSIGNALED(status));
+ ASSERT_EQ(WTERMSIG(status), SIGSEGV);
+ ASSERT_TRUE(WCOREDUMP(status));
+
+ wait_and_check_coredump_server(pid_coredump_server, _metadata, self);
+}
+
+static void check_coredump_complete(struct __test_metadata *const _metadata)
+{
+ int fd;
+
+ fd = open("/tmp/coredump.file", O_RDONLY | O_CLOEXEC);
+ ASSERT_GE(fd, 0);
+ ASSERT_TRUE(check_coredump_extent(fd));
+ close(fd);
+}
+
+TEST_F(coredump, retarget_shared_pending)
+{
+ run_coredump(_metadata, self, false);
+ check_coredump_complete(_metadata);
+
+ run_coredump(_metadata, self, true);
+ check_coredump_complete(_metadata);
+}
+
+TEST_HARNESS_MAIN
diff --git a/tools/testing/selftests/coredump/coredump_worker_test.c b/tools/testing/selftests/coredump/coredump_worker_test.c
new file mode 100644
index 0000000000000..9a4270b65a6e6
--- /dev/null
+++ b/tools/testing/selftests/coredump/coredump_worker_test.c
@@ -0,0 +1,447 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * A user worker as the coredumping thread.
+ *
+ * io-wq workers and SQPOLL threads are threads of the process that never
+ * return to userspace. They block every signal but SIGKILL and SIGSTOP,
+ * but a tracer can replace that mask with PTRACE_SETSIGMASK and inject a
+ * coredump signal. get_signal() then runs vfs_coredump() in the worker.
+ * The worker's own exit bookkeeping runs only after the dump, so a
+ * zapped sibling that waits for it in its exit path deadlocks with the
+ * dumper and the whole thread group is stuck in D state.
+ *
+ * Inject SIGSEGV into a chosen thread and require that the thread group
+ * is gone in bounded time, either because the dump completed or because
+ * SIGKILL still works. A failure leaves the stuck process behind.
+ */
+#include <ctype.h>
+#include <errno.h>
+#include <dirent.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <sys/ptrace.h>
+#include <sys/resource.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+#include <sys/wait.h>
+#include <unistd.h>
+#include <linux/io_uring.h>
+
+#include "coredump_test.h"
+
+#ifndef PTRACE_SETSIGMASK
+#define PTRACE_SETSIGMASK 0x420b
+#endif
+
+/* The dump of the tiny child takes well under a second. */
+#define EXIT_TIMEOUT_MS 5000
+
+FIXTURE_SETUP(coredump)
+{
+ FILE *file;
+ int ret;
+
+ self->pid_coredump_server = -ESRCH;
+ self->fd_tmpfs_detached = -1;
+ file = fopen("/proc/sys/kernel/core_pattern", "r");
+ ASSERT_NE(NULL, file);
+
+ ret = fread(self->original_core_pattern, 1, sizeof(self->original_core_pattern), file);
+ ASSERT_TRUE(ret || feof(file));
+ ASSERT_LT(ret, sizeof(self->original_core_pattern));
+
+ self->original_core_pattern[ret] = '\0';
+
+ ret = fclose(file);
+ ASSERT_EQ(0, ret);
+}
+
+FIXTURE_TEARDOWN(coredump)
+{
+ const char *reason;
+ FILE *file;
+ int ret;
+
+ file = fopen("/proc/sys/kernel/core_pattern", "w");
+ if (!file) {
+ reason = "Unable to open core_pattern";
+ goto fail;
+ }
+
+ ret = fprintf(file, "%s", self->original_core_pattern);
+ if (ret < 0) {
+ reason = "Unable to write to core_pattern";
+ goto fail;
+ }
+
+ ret = fclose(file);
+ if (ret) {
+ reason = "Unable to close core_pattern";
+ goto fail;
+ }
+
+ return;
+fail:
+ /* This should never happen */
+ fprintf(stderr, "Failed to cleanup coredump test: %s\n", reason);
+}
+
+/* A raw ring, no liburing. */
+struct uring {
+ int fd;
+ struct io_uring_params params;
+ void *sq;
+ size_t sq_len;
+ struct io_uring_sqe *sqes;
+ size_t sqes_len;
+ unsigned int *sq_tail, *sq_mask, *sq_array;
+ unsigned int *cq_head, *cq_tail, *cq_mask;
+ struct io_uring_cqe *cqes;
+};
+
+static int uring_setup(struct uring *r, unsigned int flags)
+{
+ size_t cq_len;
+
+ memset(r, 0, sizeof(*r));
+ r->params.flags = flags;
+ if (flags & IORING_SETUP_SQPOLL)
+ r->params.sq_thread_idle = 2000;
+ r->fd = syscall(__NR_io_uring_setup, 8, &r->params);
+ if (r->fd < 0)
+ return -1;
+ if (!(r->params.features & IORING_FEAT_SINGLE_MMAP))
+ return -1;
+
+ r->sq_len = r->params.sq_off.array + r->params.sq_entries * sizeof(unsigned int);
+ cq_len = r->params.cq_off.cqes + r->params.cq_entries * sizeof(struct io_uring_cqe);
+ if (cq_len > r->sq_len)
+ r->sq_len = cq_len;
+ r->sq = mmap(NULL, r->sq_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_POPULATE, r->fd, IORING_OFF_SQ_RING);
+ if (r->sq == MAP_FAILED)
+ return -1;
+ r->sqes_len = r->params.sq_entries * sizeof(struct io_uring_sqe);
+ r->sqes = mmap(NULL, r->sqes_len, PROT_READ | PROT_WRITE,
+ MAP_SHARED | MAP_POPULATE, r->fd, IORING_OFF_SQES);
+ if (r->sqes == MAP_FAILED)
+ return -1;
+
+ r->sq_tail = r->sq + r->params.sq_off.tail;
+ r->sq_mask = r->sq + r->params.sq_off.ring_mask;
+ r->sq_array = r->sq + r->params.sq_off.array;
+ r->cq_head = r->sq + r->params.cq_off.head;
+ r->cq_tail = r->sq + r->params.cq_off.tail;
+ r->cq_mask = r->sq + r->params.cq_off.ring_mask;
+ r->cqes = r->sq + r->params.cq_off.cqes;
+ return 0;
+}
+
+/* Submit one sqe, wait for its completion and return the result. */
+static int uring_submit_wait(struct uring *r, const struct io_uring_sqe *sqe)
+{
+ unsigned int tail = *r->sq_tail, idx = tail & *r->sq_mask;
+ unsigned int flags = IORING_ENTER_GETEVENTS;
+ int i;
+
+ r->sqes[idx] = *sqe;
+ r->sq_array[idx] = idx;
+ __atomic_store_n(r->sq_tail, tail + 1, __ATOMIC_RELEASE);
+
+ if (r->params.flags & IORING_SETUP_SQPOLL)
+ flags |= IORING_ENTER_SQ_WAKEUP;
+
+ for (i = 0; i < 100; i++) {
+ if (syscall(__NR_io_uring_enter, r->fd, 1, 1, flags, NULL, 0) < 0 &&
+ errno != EINTR)
+ return -1;
+ if (__atomic_load_n(r->cq_tail, __ATOMIC_ACQUIRE) != *r->cq_head) {
+ unsigned int head = *r->cq_head;
+ int res = r->cqes[head & *r->cq_mask].res;
+
+ __atomic_store_n(r->cq_head, head + 1, __ATOMIC_RELEASE);
+ return res;
+ }
+ flags &= ~IORING_ENTER_SQ_WAKEUP;
+ usleep(10 * 1000);
+ }
+ return -1;
+}
+
+static bool uring_available(unsigned int flags)
+{
+ struct io_uring_params params = { .flags = flags };
+ int fd;
+
+ fd = syscall(__NR_io_uring_setup, 2, ¶ms);
+ if (fd < 0)
+ return false;
+ close(fd);
+ return true;
+}
+
+/*
+ * Keep a ring, an idle io-wq worker and with SQPOLL an SQPOLL thread
+ * alive. The last worker of a ring never exits on its idle timeout.
+ */
+static void worker_child(bool sqpoll, int fd_ipc)
+{
+ struct rlimit rl = { RLIM_INFINITY, RLIM_INFINITY };
+ struct io_uring_sqe sqe = {};
+ static char buf[64];
+ struct uring ring;
+ int memfd;
+
+ if (setrlimit(RLIMIT_CORE, &rl))
+ _exit(EXIT_FAILURE);
+
+ memfd = memfd_create("coredump_worker", 0);
+ if (memfd < 0 || write(memfd, "hello", 5) != 5)
+ _exit(EXIT_FAILURE);
+
+ if (uring_setup(&ring, sqpoll ? IORING_SETUP_SQPOLL : 0))
+ _exit(EXIT_FAILURE);
+
+ /* IOSQE_ASYNC forces the read through io-wq so a worker appears. */
+ sqe.opcode = IORING_OP_READ;
+ sqe.fd = memfd;
+ sqe.addr = (__u64)(uintptr_t)buf;
+ sqe.len = sizeof(buf);
+ sqe.flags = IOSQE_ASYNC;
+ if (uring_submit_wait(&ring, &sqe) != 5)
+ _exit(EXIT_FAILURE);
+
+ if (write_nointr(fd_ipc, "1", 1) != 1)
+ _exit(EXIT_FAILURE);
+ close(fd_ipc);
+
+ for (;;)
+ pause();
+}
+
+/* Find the thread of @pid whose comm starts with @prefix. */
+static pid_t find_thread(pid_t pid, const char *prefix)
+{
+ char path[64], comm[64];
+ pid_t tid = -1;
+ struct dirent *de;
+ ssize_t bytes;
+ DIR *dir;
+ int fd;
+
+ snprintf(path, sizeof(path), "/proc/%d/task", pid);
+ dir = opendir(path);
+ if (!dir)
+ return -1;
+
+ while (tid < 0 && (de = readdir(dir))) {
+ if (!isdigit(de->d_name[0]))
+ continue;
+ snprintf(path, sizeof(path), "/proc/%d/task/%s/comm", pid, de->d_name);
+ fd = open(path, O_RDONLY | O_CLOEXEC);
+ if (fd < 0)
+ continue;
+ bytes = read(fd, comm, sizeof(comm) - 1);
+ close(fd);
+ if (bytes <= 0)
+ continue;
+ comm[bytes] = '\0';
+ if (!strncmp(comm, prefix, strlen(prefix)))
+ tid = atoi(de->d_name);
+ }
+ closedir(dir);
+ return tid;
+}
+
+/*
+ * Attach, stop the thread with SIGSTOP, drop the signal mask that
+ * copy_process() gave it and resume it with SIGSEGV. Returns 1 when the
+ * mask was changed, 0 when PTRACE_SETSIGMASK was refused (a user worker
+ * keeps its mask and the SIGSEGV stays pending), -1 on any other failure.
+ */
+static int inject_coredump_signal(pid_t pid, pid_t tid)
+{
+ __u64 mask = 0;
+ int status, ret = 1;
+
+ if (ptrace(PTRACE_SEIZE, tid, NULL, NULL))
+ return -1;
+ if (syscall(SYS_tgkill, pid, tid, SIGSTOP))
+ return -1;
+ if (waitpid(tid, &status, __WALL) != tid)
+ return -1;
+ if (!WIFSTOPPED(status) || WSTOPSIG(status) != SIGSTOP)
+ return -1;
+ if (ptrace(PTRACE_SETSIGMASK, tid, sizeof(mask), &mask)) {
+ if (errno != EPERM)
+ return -1;
+ ret = 0;
+ }
+ if (ptrace(PTRACE_DETACH, tid, NULL, (void *)(long)SIGSEGV))
+ return -1;
+ return ret;
+}
+
+/* Reap @pid within @timeout_ms, -1 when it is still there. */
+static int wait_exit(pid_t pid, int *status, int timeout_ms)
+{
+ int i;
+
+ for (i = 0; i < timeout_ms / 10; i++) {
+ pid_t ret = waitpid(pid, status, WNOHANG);
+
+ if (ret == pid)
+ return 0;
+ if (ret < 0)
+ return -1;
+ usleep(10 * 1000);
+ }
+ return -1;
+}
+
+static void log_threads(struct __test_metadata *const _metadata, pid_t pid)
+{
+ char path[64], line[256], comm[64] = {};
+ struct dirent *de;
+ DIR *dir;
+ FILE *f;
+
+ snprintf(path, sizeof(path), "/proc/%d/task", pid);
+ dir = opendir(path);
+ if (!dir)
+ return;
+ while ((de = readdir(dir))) {
+ if (!isdigit(de->d_name[0]))
+ continue;
+ snprintf(path, sizeof(path), "/proc/%d/task/%s/status", pid, de->d_name);
+ f = fopen(path, "r");
+ if (!f)
+ continue;
+ while (fgets(line, sizeof(line), f)) {
+ line[strcspn(line, "\n")] = '\0';
+ if (!strncmp(line, "Name:", 5))
+ snprintf(comm, sizeof(comm), "%s", line + 6);
+ else if (!strncmp(line, "State:", 6))
+ TH_LOG("tid %s (%s) %s", de->d_name, comm, line + 7);
+ }
+ fclose(f);
+ }
+ closedir(dir);
+}
+
+enum dumper {
+ DUMPER_MAIN,
+ DUMPER_WORKER,
+ DUMPER_SQPOLL,
+};
+
+static void run_dumper(struct __test_metadata *const _metadata, bool sqpoll,
+ enum dumper dumper)
+{
+ bool killed = false;
+ char path[64], c;
+ int ipc[2], status, fd, ret;
+ pid_t pid, tid;
+
+ ASSERT_TRUE(set_core_pattern("/tmp/coredump.file.%p"));
+ ASSERT_EQ(pipe2(ipc, O_CLOEXEC), 0);
+
+ pid = fork();
+ ASSERT_GE(pid, 0);
+ if (pid == 0) {
+ close(ipc[0]);
+ worker_child(sqpoll, ipc[1]);
+ }
+ close(ipc[1]);
+ ASSERT_EQ(read_nointr(ipc[0], &c, 1), 1);
+ close(ipc[0]);
+
+ switch (dumper) {
+ case DUMPER_MAIN:
+ tid = pid;
+ break;
+ case DUMPER_WORKER:
+ tid = find_thread(pid, "iou-wrk-");
+ break;
+ case DUMPER_SQPOLL:
+ tid = find_thread(pid, "iou-sqp-");
+ break;
+ }
+ ASSERT_GT(tid, 0);
+ ret = inject_coredump_signal(pid, tid);
+ ASSERT_GE(ret, 0);
+ if (!ret) {
+ /* The signal sits on the worker, the group must be untouched. */
+ ASSERT_NE(dumper, DUMPER_MAIN);
+ TH_LOG("PTRACE_SETSIGMASK refused for tid %d, the SIGSEGV stays pending", tid);
+ ASSERT_EQ(wait_exit(pid, &status, 1000), -1);
+ kill(pid, SIGKILL);
+ ASSERT_EQ(wait_exit(pid, &status, EXIT_TIMEOUT_MS), 0);
+ ASSERT_TRUE(WIFSIGNALED(status));
+ ASSERT_EQ(WTERMSIG(status), SIGKILL);
+ return;
+ }
+
+ if (wait_exit(pid, &status, EXIT_TIMEOUT_MS)) {
+ /* No dump. Whatever happened, SIGKILL must still work. */
+ log_threads(_metadata, pid);
+ kill(pid, SIGKILL);
+ killed = true;
+ ASSERT_EQ(wait_exit(pid, &status, EXIT_TIMEOUT_MS), 0) {
+ TH_LOG("thread group %d is stuck after SIGSEGV to tid %d",
+ pid, tid);
+ }
+ }
+
+ ASSERT_TRUE(WIFSIGNALED(status));
+ if (killed) {
+ TH_LOG("tid %d did not dump, the group was killed instead", tid);
+ ASSERT_EQ(WTERMSIG(status), SIGKILL);
+ return;
+ }
+ ASSERT_EQ(WTERMSIG(status), SIGSEGV);
+ ASSERT_TRUE(WCOREDUMP(status));
+
+ snprintf(path, sizeof(path), "/tmp/coredump.file.%d", pid);
+ fd = open(path, O_RDONLY | O_CLOEXEC);
+ unlink(path);
+ ASSERT_GE(fd, 0);
+ ASSERT_TRUE(check_coredump_extent(fd));
+ close(fd);
+}
+
+/* The mechanics: an injected SIGSEGV into a normal thread dumps core. */
+TEST_F(coredump, main_thread_dumper)
+{
+ if (!uring_available(0))
+ SKIP(return, "io_uring is not available");
+ run_dumper(_metadata, false, DUMPER_MAIN);
+}
+
+TEST_F(coredump, plain_worker_dumper)
+{
+ if (!uring_available(0))
+ SKIP(return, "io_uring is not available");
+ run_dumper(_metadata, false, DUMPER_WORKER);
+}
+
+TEST_F(coredump, sqpoll_thread_dumper)
+{
+ if (!uring_available(IORING_SETUP_SQPOLL))
+ SKIP(return, "io_uring SQPOLL is not available");
+ run_dumper(_metadata, true, DUMPER_SQPOLL);
+}
+
+/*
+ * The SQPOLL thread leaves its loop on the zap and waits for its io-wq
+ * workers to exit before it parks. The dumping worker never does.
+ */
+TEST_F(coredump, sqpoll_worker_dumper)
+{
+ if (!uring_available(IORING_SETUP_SQPOLL))
+ SKIP(return, "io_uring SQPOLL is not available");
+ run_dumper(_metadata, true, DUMPER_WORKER);
+}
+
+TEST_HARNESS_MAIN
|
| 51/3 | 2026/09/23 11:37 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 16289 output: 30 thoughts: 555 Thoughts: **KMSAN Evaluation: Patch Analysis** Okay, here's the deal. I need to figure out if this kernel patch warrants its own KMSAN fuzzing session. That means I have to be absolutely sure that it *exclusively* introduces uninitialized memory risks that *only* KMSAN would catch. The rule is clear: dedicated KMSAN is expensive, so I can only flag it if there's a genuine need. The core of my analysis hinges on these key areas: does the patch touch kernel structures sent to userspace, introduce logic that depends on potentially uninitialized variables, involve allocation/initialization of complex data structures where uninitialized fields could be read later, or manipulate bounds checks in a way that risks exposing uninitialized bytes? If not, then it probably doesn't need dedicated KMSAN. Bugs like out-of-bounds access, use-after-free, etc., are already covered by other tools. Now, let's dive into this `fs/coredump.c` patch. It's adding a spinlock (`core_pattern_lock`) which is a red herring. Then there is this `coredump_parse()` function: I'm seeing this: ```c - const char *pat_ptr = core_pattern; + char pattern[CORENAME_MAX_SIZE]; + const char *pat_ptr = pattern; ... + /* The sysctl handler may be publishing a new pattern. */ + scoped_guard(spinlock, &core_pattern_lock) + strscpy(pattern, core_pattern); ``` My initial question is, is `pattern` properly initialized by that `strscpy` call? That’s the critical point. Does `strscpy` fill the entire buffer or just copy until a null? I need to know the exact behavior of `strscpy` in the Linux kernel context. I know what `strscpy` does in the standard library. But is it the same? I need to check the implementation details. If `pattern` isn't fully initialized *before* potentially being used, that *could* be a KMSAN candidate. This needs looking at! |
| 52/3 | 2026/09/23 11:37 | tool | grepper |
0mError:no matches Args: {
"Expression": "^ssize_t strscpy",
"PathPrefix": "lib/"
}Results: {
"error": "no matches"
} |
| 53/3 | 2026/09/23 11:37 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17352 output: 28 thoughts: 24 Thoughts: Here's my take on the thought process, summarized as you requested: **Investigating `strscpy`** Alright, I need to refresh my memory on `strscpy`. It's a critical function, so I want to make sure I'm crystal clear on its implementation and usage. My first instinct is to dive directly into the source code. Let's start with the standard locations, the likely repositories for the function. I'll check `lib/string.c` in the kernel source tree first; that's the most probable place for a function like this. However, if it's considered part of the kernel's core string manipulation tools, it could also be defined in a more central include file, so I'll also have a look at `include/linux/string.h` to see if there's an inline version or a declaration to direct me to the correct definition. That should give me the foundation I need. |
| 54/3 | 2026/09/23 11:37 | tool | grepper |
0mArgs:{
"Expression": "strscpy",
"PathPrefix": "lib/string.c"
}Results: {
"Output": "lib/string.c=89=EXPORT_SYMBOL(strcpy);\n--\nlib/string.c-97-\nlib/string.c:98:ssize_t sized_strscpy(char *dest, const char *src, size_t count)\nlib/string.c-99-{\n--\nlib/string.c-172-}\nlib/string.c:173:EXPORT_SYMBOL(sized_strscpy);\nlib/string.c-174-\n"
} |
| 55/3 | 2026/09/23 11:37 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 17734 output: 32 thoughts: 21 Thoughts: Okay, let's dive into this. Here's my take on those lines from `lib/string.c`: **Analyzing `lib/string.c` - Lines 98-175** Alright, I'm focusing in on lines 98 to 175 of `lib/string.c`. Based on the context of this project, I need to understand this section thoroughly. My initial thought is to quickly scan for function definitions and calls. Given the typical structure of a string library, this block is likely dealing with core string manipulation functions. I'd anticipate seeing things like memory allocation for new strings, perhaps some resizing logic, and, of course, the actual character manipulation. I'll be looking for any potential vulnerabilities, especially buffer overflows or memory leaks. I'm keeping an eye out for how they're handling null terminators and if they're considering edge cases like very large strings or empty strings. I'll need to assess the computational complexity of any loops or recursive calls here - particularly if performance is a critical factor for the application. My main goal is to identify how this section interacts with the broader string library and, ultimately, how the string functions are used in the application. I'm especially interested in how error handling is implemented. Are they using return values, exceptions, or assertions? Is this error handling robust, and does it align with the rest of the project's error management strategy? What are the implications if this code introduces undefined behavior? |
| 56/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "lib/string.c",
"FirstLine": 98,
"LineCount": 50
}Results: {
"Contents": " 98:\tssize_t sized_strscpy(char *dest, const char *src, size_t count)\n 99:\t{\n 100:\t\tconst struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;\n 101:\t\tsize_t max = count;\n 102:\t\tlong res = 0;\n 103:\t\n 104:\t\tif (count == 0 || WARN_ON_ONCE(count \u003e INT_MAX))\n 105:\t\t\treturn -E2BIG;\n 106:\t\n 107:\t#ifndef CONFIG_DCACHE_WORD_ACCESS\n 108:\t#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS\n 109:\t\t/*\n 110:\t\t * If src is unaligned, don't cross a page boundary,\n 111:\t\t * since we don't know if the next page is mapped.\n 112:\t\t */\n 113:\t\tif ((long)src \u0026 (sizeof(long) - 1))\n 114:\t\t\tmax = min(PAGE_SIZE - ((long)src \u0026 (PAGE_SIZE - 1)), max);\n 115:\t#else\n 116:\t\t/* If src or dest is unaligned, don't do word-at-a-time. */\n 117:\t\tif (((long) dest | (long) src) \u0026 (sizeof(long) - 1))\n 118:\t\t\tmax = 0;\n 119:\t#endif\n 120:\t#endif\n 121:\t\n 122:\t\t/*\n 123:\t\t * load_unaligned_zeropad() or read_word_at_a_time() below may read\n 124:\t\t * uninitialized bytes after the trailing zero and use them in\n 125:\t\t * comparisons. Disable this optimization under KMSAN to prevent\n 126:\t\t * false positive reports.\n 127:\t\t */\n 128:\t\tif (IS_ENABLED(CONFIG_KMSAN))\n 129:\t\t\tmax = 0;\n 130:\t\n 131:\t\twhile (max \u003e= sizeof(unsigned long)) {\n 132:\t\t\tunsigned long c, data;\n 133:\t\n 134:\t#ifdef CONFIG_DCACHE_WORD_ACCESS\n 135:\t\t\tc = load_unaligned_zeropad(src+res);\n 136:\t#else\n 137:\t\t\tc = read_word_at_a_time(src+res);\n 138:\t#endif\n 139:\t\t\tif (has_zero(c, \u0026data, \u0026constants)) {\n 140:\t\t\t\tdata = prep_zero_mask(c, data, \u0026constants);\n 141:\t\t\t\tdata = create_zero_mask(data);\n 142:\t\t\t\t*(unsigned long *)(dest+res) = c \u0026 zero_bytemask(data);\n 143:\t\t\t\treturn res + find_zero(data);\n 144:\t\t\t}\n 145:\t\t\tcount -= sizeof(unsigned long);\n 146:\t\t\tif (unlikely(!count)) {\n 147:\t\t\t\tc \u0026= ALLBUTLAST_BYTE_MASK;\n"
} |
| 57/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18923 output: 34 thoughts: 73 Thoughts: Okay, here's my assessment of the situation: **Understanding `strscpy` and Its Implications for Core Dump Parsing** Right, let's get this straight in my head. `strscpy` *doesn't* zero out the entire destination buffer, which is a key gotcha with these string copy functions. It simply null-terminates the string at the specified length. That's fine if the source string is shorter than the destination, but if the source is exactly the length of the destination, or larger, then you could end up with some uninitialized data after the null terminator. That's the first critical point. Now, my real concern is: how is `pattern` being handled in the `coredump_parse` function, and by extension, in `proc_dostring_coredump`? We know from this function that it is likely using `strscpy`, but we need to verify. Let's delve into the actual implementation of `coredump_parse` in `fs/coredump.c`. It's time to inspect that code directly and see if my hunch about potential buffer overflows or information leaks is correct. We've got to find out the buffer size, what it's copying, and how. We also need to understand how the resulting string is used. |
| 58/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "fs/coredump.c",
"FirstLine": 240,
"LineCount": 80
}Results: {
"Contents": " 240:\t */\n 241:\tstatic bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,\n 242:\t\t\t\t size_t **argv, int *argc)\n 243:\t{\n 244:\t\tconst struct cred *cred = current_cred();\n 245:\t\tchar pattern[CORENAME_MAX_SIZE];\n 246:\t\tconst char *pat_ptr = pattern;\n 247:\t\tbool was_space = false;\n 248:\t\tint pid_in_pattern = 0;\n 249:\t\tint err = 0;\n 250:\t\n 251:\t\t/* The sysctl handler may be publishing a new pattern. */\n 252:\t\tscoped_guard(spinlock, \u0026core_pattern_lock)\n 253:\t\t\tstrscpy(pattern, core_pattern);\n 254:\t\n 255:\t\tcprm-\u003emask = COREDUMP_KERNEL;\n 256:\t\tif (core_pipe_limit)\n 257:\t\t\tcprm-\u003emask |= COREDUMP_WAIT;\n 258:\t\tcn-\u003eused = 0;\n 259:\t\tcn-\u003ecorename = NULL;\n 260:\t\tcn-\u003ecore_pipe_limit = 0;\n 261:\t\tif (*pat_ptr == '|')\n 262:\t\t\tcn-\u003ecore_type = COREDUMP_PIPE;\n 263:\t\telse if (*pat_ptr == '@')\n 264:\t\t\tcn-\u003ecore_type = COREDUMP_SOCK;\n 265:\t\telse\n 266:\t\t\tcn-\u003ecore_type = COREDUMP_FILE;\n 267:\t\tif (expand_corename(cn, core_name_size))\n 268:\t\t\treturn false;\n 269:\t\tcn-\u003ecorename[0] = '\\0';\n 270:\t\n 271:\t\tswitch (cn-\u003ecore_type) {\n 272:\t\tcase COREDUMP_PIPE: {\n 273:\t\t\tint argvs = sizeof(core_pattern) / 2;\n 274:\t\t\t(*argv) = kmalloc_objs(**argv, argvs);\n 275:\t\t\tif (!(*argv))\n 276:\t\t\t\treturn false;\n 277:\t\t\t(*argv)[(*argc)++] = 0;\n 278:\t\t\t++pat_ptr;\n 279:\t\t\tif (!(*pat_ptr))\n 280:\t\t\t\treturn false;\n 281:\t\t\tbreak;\n 282:\t\t}\n 283:\t\tcase COREDUMP_SOCK: {\n 284:\t\t\t/* skip the @ */\n 285:\t\t\tpat_ptr++;\n 286:\t\t\tif (!(*pat_ptr))\n 287:\t\t\t\treturn false;\n 288:\t\t\tif (*pat_ptr == '@') {\n 289:\t\t\t\tpat_ptr++;\n 290:\t\t\t\tif (!(*pat_ptr))\n 291:\t\t\t\t\treturn false;\n 292:\t\n 293:\t\t\t\tcn-\u003ecore_type = COREDUMP_SOCK_REQ;\n 294:\t\t\t}\n 295:\t\n 296:\t\t\terr = cn_printf(cn, \"%s\", pat_ptr);\n 297:\t\t\tif (err)\n 298:\t\t\t\treturn false;\n 299:\t\n 300:\t\t\t/* Require absolute paths. */\n 301:\t\t\tif (cn-\u003ecorename[0] != '/')\n 302:\t\t\t\treturn false;\n 303:\t\n 304:\t\t\t/*\n 305:\t\t\t * Ensure we can uses spaces to indicate additional\n 306:\t\t\t * parameters in the future.\n 307:\t\t\t */\n 308:\t\t\tif (strchr(cn-\u003ecorename, ' ')) {\n 309:\t\t\t\tcoredump_report_failure(\"Coredump socket may not %s contain spaces\", cn-\u003ecorename);\n 310:\t\t\t\treturn false;\n 311:\t\t\t}\n 312:\t\n 313:\t\t\t/* Must not contain \"..\" in the path. */\n 314:\t\t\tif (name_contains_dotdot(cn-\u003ecorename)) {\n 315:\t\t\t\tcoredump_report_failure(\"Coredump socket may not %s contain '..' spaces\", cn-\u003ecorename);\n 316:\t\t\t\treturn false;\n 317:\t\t\t}\n 318:\t\n 319:\t\t\tif (strlen(cn-\u003ecorename) \u003e= UNIX_PATH_MAX) {\n"
} |
| 59/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20461 output: 34 thoughts: 15 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and rendered in the first person: **Digging Deeper into `coredump_parse`** Alright, so we've got a decent handle on the current context. We've got a specific issue in front of us, and a likely tool to help us debug it. But I'm not going to stop at the obvious first steps. My mind immediately jumps to a more comprehensive approach. The real meat of this situation probably involves more than just the initial obvious entry points. I need to get a really good grasp on what `coredump_parse` brings to the table. Let's not just assume it's going to do the heavy lifting immediately - that would be naive. I want to delve into the function's capabilities. I'm thinking about the depth of its parsing, the types of data it extracts, and the various ways it could be employed. Is it limited, or can I tweak some options to get the information I need? I'm asking myself: What other resources are in that `coredump_parse` function? Does it contain other helpful functions? Are there potential configuration options or flags that are buried that I could use? I want to know if there's anything else that I can leverage from this tool. This is a crucial step to make sure I'm taking full advantage of `coredump_parse`, and to make sure I don't miss any critical clues. The more I understand its inner workings, the better equipped I'll be to diagnose this issue quickly and accurately. This is where the real work begins. |
| 60/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "fs/coredump.c",
"FirstLine": 320,
"LineCount": 80
}Results: {
"Contents": " 320:\t\t\t\tcoredump_report_failure(\"Coredump socket path %s too long\", cn-\u003ecorename);\n 321:\t\t\t\treturn false;\n 322:\t\t\t}\n 323:\t\n 324:\t\t\t/*\n 325:\t\t\t * Currently no need to parse any other options.\n 326:\t\t\t * Relevant information can be retrieved from the peer\n 327:\t\t\t * pidfd retrievable via SO_PEERPIDFD by the receiver or\n 328:\t\t\t * via /proc/\u003cpid\u003e, using the SO_PEERPIDFD to guard\n 329:\t\t\t * against pid recycling when opening /proc/\u003cpid\u003e.\n 330:\t\t\t */\n 331:\t\t\treturn true;\n 332:\t\t}\n 333:\t\tcase COREDUMP_FILE:\n 334:\t\t\tbreak;\n 335:\t\tdefault:\n 336:\t\t\tWARN_ON_ONCE(true);\n 337:\t\t\treturn false;\n 338:\t\t}\n 339:\t\n 340:\t\t/* Repeat as long as we have more pattern to process and more output\n 341:\t\t space */\n 342:\t\twhile (*pat_ptr) {\n 343:\t\t\t/*\n 344:\t\t\t * Split on spaces before doing template expansion so that\n 345:\t\t\t * %e and %E don't get split if they have spaces in them\n 346:\t\t\t */\n 347:\t\t\tif (cn-\u003ecore_type == COREDUMP_PIPE) {\n 348:\t\t\t\tif (isspace(*pat_ptr)) {\n 349:\t\t\t\t\tif (cn-\u003eused != 0)\n 350:\t\t\t\t\t\twas_space = true;\n 351:\t\t\t\t\tpat_ptr++;\n 352:\t\t\t\t\tcontinue;\n 353:\t\t\t\t} else if (was_space) {\n 354:\t\t\t\t\twas_space = false;\n 355:\t\t\t\t\terr = cn_printf(cn, \"%c\", '\\0');\n 356:\t\t\t\t\tif (err)\n 357:\t\t\t\t\t\treturn false;\n 358:\t\t\t\t\t(*argv)[(*argc)++] = cn-\u003eused;\n 359:\t\t\t\t}\n 360:\t\t\t}\n 361:\t\t\tif (*pat_ptr != '%') {\n 362:\t\t\t\terr = cn_printf(cn, \"%c\", *pat_ptr++);\n 363:\t\t\t} else {\n 364:\t\t\t\tswitch (*++pat_ptr) {\n 365:\t\t\t\t/* single % at the end, drop that */\n 366:\t\t\t\tcase 0:\n 367:\t\t\t\t\tgoto out;\n 368:\t\t\t\t/* Double percent, output one percent */\n 369:\t\t\t\tcase '%':\n 370:\t\t\t\t\terr = cn_printf(cn, \"%c\", '%');\n 371:\t\t\t\t\tbreak;\n 372:\t\t\t\t/* pid */\n 373:\t\t\t\tcase 'p':\n 374:\t\t\t\t\tpid_in_pattern = 1;\n 375:\t\t\t\t\terr = cn_printf(cn, \"%d\",\n 376:\t\t\t\t\t\t task_tgid_vnr(current));\n 377:\t\t\t\t\tbreak;\n 378:\t\t\t\t/* global pid */\n 379:\t\t\t\tcase 'P':\n 380:\t\t\t\t\terr = cn_printf(cn, \"%d\",\n 381:\t\t\t\t\t\t task_tgid_nr(current));\n 382:\t\t\t\t\tbreak;\n 383:\t\t\t\tcase 'i':\n 384:\t\t\t\t\terr = cn_printf(cn, \"%d\",\n 385:\t\t\t\t\t\t task_pid_vnr(current));\n 386:\t\t\t\t\tbreak;\n 387:\t\t\t\tcase 'I':\n 388:\t\t\t\t\terr = cn_printf(cn, \"%d\",\n 389:\t\t\t\t\t\t task_pid_nr(current));\n 390:\t\t\t\t\tbreak;\n 391:\t\t\t\t/* uid */\n 392:\t\t\t\tcase 'u':\n 393:\t\t\t\t\terr = cn_printf(cn, \"%u\",\n 394:\t\t\t\t\t\t\tfrom_kuid(\u0026init_user_ns,\n 395:\t\t\t\t\t\t\t\t cred-\u003euid));\n 396:\t\t\t\t\tbreak;\n 397:\t\t\t\t/* gid */\n 398:\t\t\t\tcase 'g':\n 399:\t\t\t\t\terr = cn_printf(cn, \"%u\",\n"
} |
| 61/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21953 output: 32 thoughts: 691 Thoughts: **Analyzing the Core Dump Vulnerability** Okay, let's break this down. In `coredump_parse`, I see `pattern` declared on the stack, using `char pattern[CORENAME_MAX_SIZE];`. Good. The code uses `strscpy(pattern, core_pattern)` to copy the contents of `core_pattern` into `pattern`. `core_pattern` is a null-terminated string, so `strscpy` ensures `pattern` is also null-terminated. Then `pat_ptr` is set to point to `pattern`. All operations with `pat_ptr` stop when `*pat_ptr == '\0'`, so it can't read past the null terminator. In the `COREDUMP_SOCK` path, the `cn_printf(cn, "%s", pat_ptr);` call also respects the null terminator. So, no buffer overflow there. That's good to see. Now, let's turn our attention to `proc_dostring_coredump()`. I see another stack-allocated `pattern` buffer: `char pattern[CORENAME_MAX_SIZE];`. The code copies the current value of `core_pattern` into this local `pattern` using `strscpy` under a lock. It then calls `proc_dostring()` to handle reading or writing the sysctl. The interesting part is what happens when we're *reading* (i.e. `!write`). I see `strscpy(pattern, core_pattern)` is executed even when we're reading. Then `proc_dostring` is called. Critically, during the read operation (`!write`), `proc_dostring` will *read* from `tmp.data`, which is the stack buffer `pattern` and copy to the user space buffer `buffer`. That's where the vulnerability likely lies. I need to understand what `proc_dostring` does in the read path. Specifically, how much data does `proc_dostring` read or copy to user space? I need to dig into the implementation of `proc_dostring` itself to understand the potential for a leak. That's the key. |
| 62/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "int proc_dostring",
"PathPrefix": "kernel/sysctl.c"
}Results: {
"Output": "kernel/sysctl.c=155=static bool proc_first_pos_non_zero_ignore(loff_t *ppos,\n--\nkernel/sysctl.c-188- */\nkernel/sysctl.c:189:int proc_dostring(const struct ctl_table *table, int dir,\nkernel/sysctl.c-190-\t\t void *buffer, size_t *lenp, loff_t *ppos)\n--\nkernel/sysctl.c=1138=int proc_do_large_bitmap(const struct ctl_table *table, int dir,\n--\nkernel/sysctl.c-1269-\nkernel/sysctl.c:1270:int proc_dostring(const struct ctl_table *table, int dir,\nkernel/sysctl.c-1271-\t\t void *buffer, size_t *lenp, loff_t *ppos)\n"
} |
| 63/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23386 output: 34 thoughts: 19 Thoughts: Here's a first-person summary, tailored for an expert audience, as requested: **Diving into `kernel/sysctl.c` - Line 189 and Beyond** Alright, let's zero in on `kernel/sysctl.c`, specifically around line 189. I need to refresh my memory on how this particular sysctl node is handled, or perhaps I'm looking to identify some potential quirks or inefficiencies in the implementation. Knowing the kernel codebase like the back of my hand, a quick review of that area will help. |
| 64/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "kernel/sysctl.c",
"FirstLine": 180,
"LineCount": 60
}Results: {
"Contents": " 180:\t * Reads/writes a string from/to the user buffer. If the kernel\n 181:\t * buffer provided is not large enough to hold the string, the\n 182:\t * string is truncated. The copied string is %NULL-terminated.\n 183:\t * If the string is being read by the user process, it is copied\n 184:\t * and a newline '\\n' is added. It is truncated if the buffer is\n 185:\t * not large enough.\n 186:\t *\n 187:\t * Returns: %0 on success.\n 188:\t */\n 189:\tint proc_dostring(const struct ctl_table *table, int dir,\n 190:\t\t\t void *buffer, size_t *lenp, loff_t *ppos)\n 191:\t{\n 192:\t\tif (SYSCTL_USER_TO_KERN(dir))\n 193:\t\t\tproc_first_pos_non_zero_ignore(ppos, table);\n 194:\t\n 195:\t\treturn _proc_do_string(table-\u003edata, table-\u003emaxlen, dir, buffer, lenp,\n 196:\t\t\t\tppos);\n 197:\t}\n 198:\t\n 199:\tstatic void proc_skip_spaces(char **buf, size_t *size)\n 200:\t{\n 201:\t\twhile (*size) {\n 202:\t\t\tif (!isspace(**buf))\n 203:\t\t\t\tbreak;\n 204:\t\t\t(*size)--;\n 205:\t\t\t(*buf)++;\n 206:\t\t}\n 207:\t}\n 208:\t\n 209:\tstatic void proc_skip_char(char **buf, size_t *size, const char v)\n 210:\t{\n 211:\t\twhile (*size) {\n 212:\t\t\tif (**buf != v)\n 213:\t\t\t\tbreak;\n 214:\t\t\t(*size)--;\n 215:\t\t\t(*buf)++;\n 216:\t\t}\n 217:\t}\n 218:\t\n 219:\t/**\n 220:\t * strtoul_lenient - parse an ASCII formatted integer from a buffer and only\n 221:\t * fail on overflow\n 222:\t *\n 223:\t * @cp: kernel buffer containing the string to parse\n 224:\t * @endp: pointer to store the trailing characters\n 225:\t * @base: the base to use\n 226:\t * @res: where the parsed integer will be stored\n 227:\t *\n 228:\t * This function will fail the parse on overflow. If there wasn't an overflow\n 229:\t * the function will defer the decision what characters count as invalid to the\n 230:\t * caller.\n 231:\t *\n 232:\t * Returns:\n 233:\t * * %0 on success and @res will contain the parsed integer,\n 234:\t * @endp will hold any trailing characters.\n 235:\t * * %-ERANGE on overflow.\n 236:\t */\n 237:\tstatic int strtoul_lenient(const char *cp, char **endp, unsigned int base,\n 238:\t\t\t\t unsigned long *res)\n 239:\t{\n"
} |
| 65/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24436 output: 32 thoughts: 13 Thoughts: Okay, here's my interpretation of "Let's see `_proc_do_string`!", assuming I'm an expert in this field, presented as a first-person thought process: **Diving into `_proc_do_string`** Alright, that's what we're looking at now, `_proc_do_string`. Interesting. It's time to dig in and understand what that function is doing. I bet it handles string execution within the kernel or a crucial part of the runtime. I'll need to remember where I last saw a use case of this. Is it related to handling dynamic code generation, or maybe parsing commands or configuration strings? Could be a potential attack vector if not implemented securely. Hmm, let's see how it's used, what dependencies it has, and what the internal logic reveals. Time to put on my investigator hat. |
| 66/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "_proc_do_string",
"PathPrefix": "kernel/sysctl.c"
}Results: {
"Output": "kernel/sysctl.c=66=static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;\n--\nkernel/sysctl.c-75-\nkernel/sysctl.c:76:static int _proc_do_string(char *data, int maxlen, int dir,\nkernel/sysctl.c-77-\t\tchar *buffer, size_t *lenp, loff_t *ppos)\n--\nkernel/sysctl.c=189=int proc_dostring(const struct ctl_table *table, int dir,\n--\nkernel/sysctl.c-194-\nkernel/sysctl.c:195:\treturn _proc_do_string(table-\u003edata, table-\u003emaxlen, dir, buffer, lenp,\nkernel/sysctl.c-196-\t\t\tppos);\n"
} |
| 67/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24890 output: 33 thoughts: 21 Thoughts: Here's a first-person summary, tailored for an expert audience, based on your instructions: **Diving into `_proc_do_string` in `kernel/sysctl.c`** Alright, let's get down to it. Time to dig into `_proc_do_string` in `kernel/sysctl.c`. I need to refresh my understanding of how string-based sysctls are handled. My initial hypothesis is that this function will be the workhorse for retrieving and setting string values associated with various kernel parameters exposed through `/proc`. Specifically, I'm expecting this to be the core logic for the "string" type nodes within the sysctl hierarchy. I'm keen to see how the kernel handles buffer allocation, potential security considerations like buffer overflows when setting values, and any nuances in encoding or validation. I'm also anticipating that it likely leverages some common `sysctl` infrastructure, which I'll be looking to identify. I'll pay close attention to the error handling paths; kernel error handling can be notoriously tricky, and understanding these will be critical. Ultimately, I need a clear mental model of the control flow to ensure correctness and identify any lurking vulnerabilities. |
| 68/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "kernel/sysctl.c",
"FirstLine": 75,
"LineCount": 60
}Results: {
"Contents": " 75:\t\n 76:\tstatic int _proc_do_string(char *data, int maxlen, int dir,\n 77:\t\t\tchar *buffer, size_t *lenp, loff_t *ppos)\n 78:\t{\n 79:\t\tsize_t len;\n 80:\t\tchar c, *p;\n 81:\t\n 82:\t\tif (!data || !maxlen || !*lenp) {\n 83:\t\t\t*lenp = 0;\n 84:\t\t\treturn 0;\n 85:\t\t}\n 86:\t\n 87:\t\tif (SYSCTL_USER_TO_KERN(dir)) {\n 88:\t\t\tif (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {\n 89:\t\t\t\t/* Only continue writes not past the end of buffer. */\n 90:\t\t\t\tlen = strlen(data);\n 91:\t\t\t\tif (len \u003e maxlen - 1)\n 92:\t\t\t\t\tlen = maxlen - 1;\n 93:\t\n 94:\t\t\t\tif (*ppos \u003e len)\n 95:\t\t\t\t\treturn 0;\n 96:\t\t\t\tlen = *ppos;\n 97:\t\t\t} else {\n 98:\t\t\t\t/* Start writing from beginning of buffer. */\n 99:\t\t\t\tlen = 0;\n 100:\t\t\t}\n 101:\t\n 102:\t\t\t*ppos += *lenp;\n 103:\t\t\tp = buffer;\n 104:\t\t\twhile ((p - buffer) \u003c *lenp \u0026\u0026 len \u003c maxlen - 1) {\n 105:\t\t\t\tc = *(p++);\n 106:\t\t\t\tif (c == 0 || c == '\\n')\n 107:\t\t\t\t\tbreak;\n 108:\t\t\t\tdata[len++] = c;\n 109:\t\t\t}\n 110:\t\t\tdata[len] = 0;\n 111:\t\t} else {\n 112:\t\t\tlen = strlen(data);\n 113:\t\t\tif (len \u003e maxlen)\n 114:\t\t\t\tlen = maxlen;\n 115:\t\n 116:\t\t\tif (*ppos \u003e len) {\n 117:\t\t\t\t*lenp = 0;\n 118:\t\t\t\treturn 0;\n 119:\t\t\t}\n 120:\t\n 121:\t\t\tdata += *ppos;\n 122:\t\t\tlen -= *ppos;\n 123:\t\n 124:\t\t\tif (len \u003e *lenp)\n 125:\t\t\t\tlen = *lenp;\n 126:\t\t\tif (len)\n 127:\t\t\t\tmemcpy(buffer, data, len);\n 128:\t\t\tif (len \u003c *lenp) {\n 129:\t\t\t\tbuffer[len] = '\\n';\n 130:\t\t\t\tlen++;\n 131:\t\t\t}\n 132:\t\t\t*lenp = len;\n 133:\t\t\t*ppos += len;\n 134:\t\t}\n"
} |
| 69/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25963 output: 30 thoughts: 415 Thoughts: **Analyzing the Core Pattern Vulnerability** Okay, let's break this down. We're looking at `_proc_do_string` and how it handles the `core_pattern` sysctl. First, for a read operation ( `SYSCTL_KERN_TO_USER`), the code gets the length of `data`, which is actually the `pattern` buffer. Initially, `pattern` is populated with a copy of `core_pattern`. And `core_pattern` starts as "core". The key here is that `strscpy` ensures `pattern` is null-terminated after the copy. This means `strlen(data)` accurately reflects the string's length, counting up to that null terminator. Then, the subsequent `memcpy` correctly copies up to that length – no problem there. But, the write operation is where things get interesting. Similar to the read operation, it does the `strlen` check. If we are writing to the pattern via sysctl, we do a similar set of actions in `_proc_do_string`: We copy core_pattern, then get its length. If the write position is past that length, the function returns zero. Otherwise, characters from the user's input are copied into the pattern. This potentially overwrites whatever length value we had at the start, setting up a situation where the new `pattern` is then passed to `check_coredump_socket(pattern)`. Then, inside the `check_coredump_socket`, we have a critical section with a spinlock, where the code does a `strncmp` comparing the *user-provided* `pattern` against `core_pattern`. If it's different, it copies the new `pattern` into `core_pattern` via `strscpy`. Hold on! Look at that `strncmp` call! It uses `CORENAME_MAX_SIZE` as the comparison length. The key question now becomes, *what* is `CORENAME_MAX_SIZE`? This is the crucial piece of information to determine if we have a potential buffer overflow or other vulnerability. Let's go look that up. |
| 70/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "#define CORENAME_MAX_SIZE",
"PathPrefix": "include/"
}Results: {
"Output": "include/linux/binfmts.h=11=struct coredump_params;\ninclude/linux/binfmts.h-12-\ninclude/linux/binfmts.h:13:#define CORENAME_MAX_SIZE 128\ninclude/linux/binfmts.h-14-\n"
} |
| 71/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26941 output: 29 thoughts: 523 Thoughts: **Analyzing Potential Vulnerability in `proc_dostring_coredump`** Okay, hold on a second! I need to take a closer look at something. In this `proc_dostring_coredump()` function, I see this line: `char pattern[CORENAME_MAX_SIZE];`. Right, `pattern` is declared as a stack array. Wait, I think there is a problem. It's an uninitialized stack array of 128 bytes. The code copies to `pattern` from `core_pattern` using `strscpy(pattern, core_pattern)`. Now, let's say `core_pattern` is just the string "core", that's 5 bytes, including the null terminator. So, `strscpy` copies those 5 bytes. That means, `pattern[0]='c'`, `pattern[1]='o'`, `pattern[2]='r'`, `pattern[3]='e'`, `pattern[4]='\0'`. But then, `pattern[5]` through `pattern[127]` are *uninitialized stack bytes*! That could be problematic. Now, looking at the subsequent code, `strncmp(pattern, core_pattern, CORENAME_MAX_SIZE)` is used. What does `strncmp` do? Does it stop at the null terminator, or does it read the full `n` bytes? In my experience, it's very important to check. Let me verify the standard C behavior and the Linux kernel implementation of `strncmp`. I'll need to check the definition in `lib/string.c` for the Linux kernel's implementation. My memory is good but I need to make sure. I'm concerned that `strncmp` might read beyond the null terminator in `pattern`. If that's the case, then it could potentially leak the contents of stack memory to `changed`. And that's not good! It could lead to information disclosure. I need to be sure about this. |
| 72/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "int strncmp",
"PathPrefix": "lib/string.c"
}Results: {
"Output": "lib/string.c=274=EXPORT_SYMBOL(strcmp);\n--\nlib/string.c-283- */\nlib/string.c:284:int strncmp(const char *cs, const char *ct, size_t count)\nlib/string.c-285-{\n"
} |
| 73/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28001 output: 33 thoughts: 21 Thoughts: Okay, let's dive into this. Here's my take on those lines of code: **Analyzing `lib/string.c` from Lines 284-300** Alright, my focus is now on `lib/string.c`, specifically lines 284 through 300. Given the context of this project, I expect to see some pretty core string manipulation functions in this section. I'm immediately looking for any edge cases or potential vulnerabilities, perhaps related to buffer overflows or incorrect null termination. I want to quickly understand the memory management strategy employed here; are they using static buffers, dynamically allocating, or relying on something like a rope structure? Are they doing their own bounds checking, or relying on `strncpy` or `snprintf` in a way I need to scrutinize? Given my experience with these kinds of low-level string routines, I'm already anticipating some common pitfalls. I'll be particularly interested in any use of `memcpy` or similar operations, and whether they're properly handling overlapping memory regions. The choice of algorithms for the core string operations is something I always examine, to see if there's any room for optimization. It's often where the real performance bottlenecks arise and I'm looking for clues here as well. I'm bracing myself for some interesting code, and ready to get to work. |
| 74/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "lib/string.c",
"FirstLine": 284,
"LineCount": 20
}Results: {
"Contents": " 284:\tint strncmp(const char *cs, const char *ct, size_t count)\n 285:\t{\n 286:\t\tunsigned char c1, c2;\n 287:\t\n 288:\t\twhile (count) {\n 289:\t\t\tc1 = *cs++;\n 290:\t\t\tc2 = *ct++;\n 291:\t\t\tif (c1 != c2)\n 292:\t\t\t\treturn c1 \u003c c2 ? -1 : 1;\n 293:\t\t\tif (!c1)\n 294:\t\t\t\tbreak;\n 295:\t\t\tcount--;\n 296:\t\t}\n 297:\t\treturn 0;\n 298:\t}\n 299:\tEXPORT_SYMBOL(strncmp);\n 300:\t#endif\n 301:\t\n 302:\t#ifndef __HAVE_ARCH_STRCHR\n 303:\t/**\n"
} |
| 75/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28595 output: 28 thoughts: 315 Thoughts: **Analyzing String Comparison and Potential Vulnerability** Okay, so I'm diving into this code and immediately I see `if (!c1) break;`. Right, `strncmp` stops when `c1` is zero, or when it finds a mismatch. Hold on… if `strncmp(pattern, core_pattern, CORENAME_MAX_SIZE)` encounters a situation where `pattern` and `core_pattern` match up to a null terminator, when `c1` becomes `'\0'`, then since `c1` and `c2` are both null, the `if (!c1) break;` condition is met and `strncmp` returns zero! That's it! It never reads beyond that initial null character. Now, what's going on with `core_pattern` being written to? And more importantly, what's happening with `pattern` when it's written via `proc_dostring`? Okay, I can see the potential attack vector here. Imagine the user writes `"abc"` to it. The `_proc_do_string` function sets `pattern[0]='a'`, then `pattern[1]='b'`, and `pattern[2]='c'` and finally, `pattern[3]='\0'`. Then `check_coredump_socket(pattern)` is called. Time to look closely at that function. Let's see, `check_coredump_socket(pattern)`. First check is `if (pattern[0] != '@') return true;`. Okay, so if it starts with anything other than `@`, it returns `true`. If it *does* start with `@`, what happens next? Then we look at `pattern[1]` and `pattern[2]`, and a function called `name_contains_dotdot(pattern)`. Aha! Now we're getting somewhere. What does *that* function do? I need to understand what `name_contains_dotdot(pattern)` does to determine if there's a vulnerability here. Let's get searching. |
| 76/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "name_contains_dotdot",
"PathPrefix": "fs/"
}Results: {
"Output": "fs/coredump.c=241=static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,\n--\nfs/coredump.c-313-\t\t/* Must not contain \"..\" in the path. */\nfs/coredump.c:314:\t\tif (name_contains_dotdot(cn-\u003ecorename)) {\nfs/coredump.c-315-\t\t\tcoredump_report_failure(\"Coredump socket may not %s contain '..' spaces\", cn-\u003ecorename);\n--\nfs/coredump.c=1650=static inline bool check_coredump_socket(const char *pattern)\n--\nfs/coredump.c-1682-\t/* Must not contain \"..\" in the path. */\nfs/coredump.c:1683:\tif (name_contains_dotdot(pattern))\nfs/coredump.c-1684-\t\treturn false;\n"
} |
| 77/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29611 output: 20 thoughts: 14 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary: **Deconstructing `name_contains_dotdot`** Alright, let's break down this `name_contains_dotdot` concept. My immediate instinct is to dissect the function name itself. The keywords jump out: "name," "contains," and "dotdot." Clearly, we're looking at a function that likely checks if a given "name" string includes the sequence "dotdot". This implies some level of vulnerability or potential risk. In this context, "dotdot" most often alludes to path traversal or directory climbing attacks, especially when interacting with file systems or web servers. I need to understand the precise context in which this function is employed. Is it sanitizing user inputs, validating file paths, or guarding against arbitrary code execution? The implications change dramatically based on its application. I'd need to consider the threat model it's addressing. Is the concern purely security-related (e.g., preventing access to unauthorized directories), or is it more about data integrity (e.g., ensuring a file path stays within a defined scope)? My focus would then shift towards any possible edge cases or bypasses. What's the function's implementation? Does it account for different operating systems (Windows, Unix-like) and their unique path separators? Is it case-sensitive? Does it account for encoded forms of ".." or "./" ? I also want to assess its effectiveness against various attack vectors. Does it utilize a robust algorithm or a simple string search? Overall, I need to fully ascertain the security implications. |
| 78/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "name_contains_dotdot"
}Results: {
"Output": "drivers/base/firmware_loader/main.c=827=_request_firmware(const struct firmware **firmware_p, const char *name,\n--\ndrivers/base/firmware_loader/main.c-853-\t */\ndrivers/base/firmware_loader/main.c:854:\tif (name_contains_dotdot(name)) {\ndrivers/base/firmware_loader/main.c-855-\t\tdev_warn(device,\n--\nfs/coredump.c=241=static bool coredump_parse(struct core_name *cn, struct coredump_params *cprm,\n--\nfs/coredump.c-313-\t\t/* Must not contain \"..\" in the path. */\nfs/coredump.c:314:\t\tif (name_contains_dotdot(cn-\u003ecorename)) {\nfs/coredump.c-315-\t\t\tcoredump_report_failure(\"Coredump socket may not %s contain '..' spaces\", cn-\u003ecorename);\n--\nfs/coredump.c=1650=static inline bool check_coredump_socket(const char *pattern)\n--\nfs/coredump.c-1682-\t/* Must not contain \"..\" in the path. */\nfs/coredump.c:1683:\tif (name_contains_dotdot(pattern))\nfs/coredump.c-1684-\t\treturn false;\n--\ninclude/linux/fs.h=2933=static inline bool name_is_dot_dotdot(const char *name, size_t len)\n--\ninclude/linux/fs.h-2939-/**\ninclude/linux/fs.h:2940: * name_contains_dotdot - check if a file name contains \"..\" path components\ninclude/linux/fs.h-2941- * @name: File path string to check\n--\ninclude/linux/fs.h-2943- */\ninclude/linux/fs.h:2944:static inline bool name_contains_dotdot(const char *name)\ninclude/linux/fs.h-2945-{\n"
} |
| 79/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30516 output: 27 thoughts: 618 Thoughts: **Analyzing a Potential Kernel Vulnerability in `core_pattern` Handling** Okay, I'm digging into this `name_contains_dotdot` function and how it interacts with string manipulation. My immediate thought is, what if `proc_dostring` writes something into `pattern` and then `strscpy(core_pattern, pattern)` is called? `strscpy` only copies up to the null terminator, so there's a limit. But, I need to understand the data flow. My next concern is, if `core_pattern` is read via `sysctl` later, are we safe? Now, let me look at `proc_dostring_coredump()`. I see this block specifically for the read case (`!write`): It makes a local copy, `pattern`, within the `ctl_table`. It uses `strscpy` to copy `core_pattern` into it. Then it calls `proc_dostring`. Alright, I need to focus on what happens inside `proc_dostring` when it's handling a read operation. Here's what's happening in `_proc_do_string`: It calculates a length, considering `maxlen` and the current position (`*ppos`). It then copies data, potentially including an appended newline character, into the `buffer`. The key here is, is `buffer` a kernel or a user buffer? This is crucial. So, who is even calling `proc_dostring`? It's time to check where `proc_dostring_coredump` is called from. I see it's called from a sysctl handler! But is that buffer in `proc_dostring` a kernel buffer or a user buffer? Looking at `kernel/sysctl.c`, there's a check: `if (SYSCTL_USER_TO_KERN(dir))` determines if it's a write (1) or a read (0). When `dir` is 0 (a read operation), the `write` parameter in `proc_dostring` is false. I need to understand exactly how `sysctl` read operations work in modern kernels. Let's trace calls to `table->proc_handler` in `fs/proc/proc_sysctl.c` to understand the bigger picture. |
| 80/3 | 2026/09/23 11:38 | tool | grepper |
0mArgs:{
"Expression": "proc_handler",
"PathPrefix": "fs/proc/"
}Results: {
"Output": "fs/proc/proc_sysctl.c=553=static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter,\n--\nfs/proc/proc_sysctl.c-575-\terror = -EINVAL;\nfs/proc/proc_sysctl.c:576:\tif (!table-\u003eproc_handler)\nfs/proc/proc_sysctl.c-577-\t\tgoto out;\n--\nfs/proc/proc_sysctl.c-599-\t/* careful: calling conventions are nasty here */\nfs/proc/proc_sysctl.c:600:\terror = table-\u003eproc_handler(table, write, kbuf, \u0026count, \u0026iocb-\u003eki_pos);\nfs/proc/proc_sysctl.c-601-\tif (error)\n--\nfs/proc/proc_sysctl.c=646=static __poll_t proc_sys_poll(struct file *filp, poll_table *wait)\n--\nfs/proc/proc_sysctl.c-657-\nfs/proc/proc_sysctl.c:658:\tif (!table-\u003eproc_handler)\nfs/proc/proc_sysctl.c-659-\t\tgoto out;\n--\nfs/proc/proc_sysctl.c=1106=static int sysctl_check_table_array(const char *path, const struct ctl_table *table)\n--\nfs/proc/proc_sysctl.c-1110-\nfs/proc/proc_sysctl.c:1111:\tif ((table-\u003eproc_handler == proc_douintvec) ||\nfs/proc/proc_sysctl.c:1112:\t (table-\u003eproc_handler == proc_douintvec_minmax)) {\nfs/proc/proc_sysctl.c-1113-\t\tif (table-\u003emaxlen != sizeof(unsigned int))\n--\nfs/proc/proc_sysctl.c-1116-\nfs/proc/proc_sysctl.c:1117:\tif (table-\u003eproc_handler == proc_dou8vec_minmax) {\nfs/proc/proc_sysctl.c-1118-\t\tif (table-\u003emaxlen != sizeof(u8))\n--\nfs/proc/proc_sysctl.c-1134-\nfs/proc/proc_sysctl.c:1135:\tif (table-\u003eproc_handler == proc_dobool) {\nfs/proc/proc_sysctl.c-1136-\t\tif (table-\u003emaxlen != sizeof(bool))\n--\nfs/proc/proc_sysctl.c=1143=static int sysctl_check_table(const char *path, struct ctl_table_header *header)\n--\nfs/proc/proc_sysctl.c-1149-\t\t\terr |= sysctl_err(path, entry, \"procname is null\");\nfs/proc/proc_sysctl.c:1150:\t\tif ((entry-\u003eproc_handler == proc_dostring) ||\nfs/proc/proc_sysctl.c:1151:\t\t (entry-\u003eproc_handler == proc_dobool) ||\nfs/proc/proc_sysctl.c:1152:\t\t (entry-\u003eproc_handler == proc_dointvec) ||\nfs/proc/proc_sysctl.c:1153:\t\t (entry-\u003eproc_handler == proc_douintvec) ||\nfs/proc/proc_sysctl.c:1154:\t\t (entry-\u003eproc_handler == proc_douintvec_minmax) ||\nfs/proc/proc_sysctl.c:1155:\t\t (entry-\u003eproc_handler == proc_dointvec_minmax) ||\nfs/proc/proc_sysctl.c:1156:\t\t (entry-\u003eproc_handler == proc_dou8vec_minmax) ||\nfs/proc/proc_sysctl.c:1157:\t\t (entry-\u003eproc_handler == proc_dointvec_jiffies) ||\nfs/proc/proc_sysctl.c:1158:\t\t (entry-\u003eproc_handler == proc_dointvec_userhz_jiffies) ||\nfs/proc/proc_sysctl.c:1159:\t\t (entry-\u003eproc_handler == proc_dointvec_ms_jiffies) ||\nfs/proc/proc_sysctl.c:1160:\t\t (entry-\u003eproc_handler == proc_doulongvec_minmax) ||\nfs/proc/proc_sysctl.c:1161:\t\t (entry-\u003eproc_handler == proc_doulongvec_ms_jiffies_minmax)) {\nfs/proc/proc_sysctl.c-1162-\t\t\tif (!entry-\u003edata)\n--\nfs/proc/proc_sysctl.c-1168-\t\t}\nfs/proc/proc_sysctl.c:1169:\t\tif (!entry-\u003eproc_handler)\nfs/proc/proc_sysctl.c:1170:\t\t\terr |= sysctl_err(path, entry, \"No proc_handler\");\nfs/proc/proc_sysctl.c-1171-\n--\nfs/proc/proc_sysctl.c=1298=static struct ctl_dir *sysctl_mkdir_p(struct ctl_dir *dir, const char *path)\n--\nfs/proc/proc_sysctl.c-1342- * enter a sysctl file\nfs/proc/proc_sysctl.c:1343: * data - a pointer to data for use by proc_handler\nfs/proc/proc_sysctl.c-1344- * maxlen - the maximum size in bytes of the data\n--\nfs/proc/proc_sysctl.c-1346- * type - Defines the target type (described in struct definition)\nfs/proc/proc_sysctl.c:1347: * proc_handler - the text handler routine (described below)\nfs/proc/proc_sysctl.c-1348- *\n--\nfs/proc/proc_sysctl.c-1355- *\nfs/proc/proc_sysctl.c:1356: * There must be a proc_handler routine for any terminal nodes.\nfs/proc/proc_sysctl.c-1357- * Several default handlers are available to cover common cases -\n"
} |
| 81/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33233 output: 38 thoughts: 26 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm already quite familiar with kernel internals: **Diving into the Heart of the Matter: `proc_sys_call_handler`** Alright, my internal radar just pinged. "proc_sys_call_handler" in `fs/proc/proc_sysctl.c`... that name rings a bell. My mind's immediately jumping to the core of how system calls interact with the proc filesystem's sysctl interface. So, I'm thinking, this is probably the place where the magic happens – where user-space requests to read or modify kernel parameters through `/proc/sys` are actually routed and handled. I'm keen to understand the specific logic here, the crucial flow of control. What exactly is this function doing, and, specifically, how does it translate those user-space read and write operations into kernel-level actions? I anticipate that I'll find the intricate details of argument parsing, permission checks, and ultimately, the setting or getting of kernel variables or parameters. I'll need to refresh my memory about the relevant sysctl data structures as well. |
| 82/3 | 2026/09/23 11:38 | tool | read-file |
0mArgs:{
"File": "fs/proc/proc_sysctl.c",
"FirstLine": 550,
"LineCount": 60
}Results: {
"Contents": " 550:\t\treturn err;\n 551:\t}\n 552:\t\n 553:\tstatic ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter,\n 554:\t\t\tint write)\n 555:\t{\n 556:\t\tstruct inode *inode = file_inode(iocb-\u003eki_filp);\n 557:\t\tstruct ctl_table_header *head = grab_header(inode);\n 558:\t\tconst struct ctl_table *table = PROC_I(inode)-\u003esysctl_entry;\n 559:\t\tsize_t count = iov_iter_count(iter);\n 560:\t\tchar *kbuf;\n 561:\t\tssize_t error;\n 562:\t\n 563:\t\tif (IS_ERR(head))\n 564:\t\t\treturn PTR_ERR(head);\n 565:\t\n 566:\t\t/*\n 567:\t\t * At this point we know that the sysctl was not unregistered\n 568:\t\t * and won't be until we finish.\n 569:\t\t */\n 570:\t\terror = -EPERM;\n 571:\t\tif (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))\n 572:\t\t\tgoto out;\n 573:\t\n 574:\t\t/* if that can happen at all, it should be -EINVAL, not -EISDIR */\n 575:\t\terror = -EINVAL;\n 576:\t\tif (!table-\u003eproc_handler)\n 577:\t\t\tgoto out;\n 578:\t\n 579:\t\t/* don't even try if the size is too large */\n 580:\t\terror = -ENOMEM;\n 581:\t\tif (count \u003e= KMALLOC_MAX_SIZE)\n 582:\t\t\tgoto out;\n 583:\t\tkbuf = kvzalloc(count + 1, GFP_KERNEL);\n 584:\t\tif (!kbuf)\n 585:\t\t\tgoto out;\n 586:\t\n 587:\t\tif (write) {\n 588:\t\t\terror = -EFAULT;\n 589:\t\t\tif (!copy_from_iter_full(kbuf, count, iter))\n 590:\t\t\t\tgoto out_free_buf;\n 591:\t\t\tkbuf[count] = '\\0';\n 592:\t\t}\n 593:\t\n 594:\t\terror = BPF_CGROUP_RUN_PROG_SYSCTL(head, table, write, \u0026kbuf, \u0026count,\n 595:\t\t\t\t\t\t \u0026iocb-\u003eki_pos);\n 596:\t\tif (error)\n 597:\t\t\tgoto out_free_buf;\n 598:\t\n 599:\t\t/* careful: calling conventions are nasty here */\n 600:\t\terror = table-\u003eproc_handler(table, write, kbuf, \u0026count, \u0026iocb-\u003eki_pos);\n 601:\t\tif (error)\n 602:\t\t\tgoto out_free_buf;\n 603:\t\n 604:\t\tif (!write) {\n 605:\t\t\terror = -EFAULT;\n 606:\t\t\tif (copy_to_iter(kbuf, count, iter) \u003c count)\n 607:\t\t\t\tgoto out_free_buf;\n 608:\t\t}\n 609:\t\n"
} |
| 83/3 | 2026/09/23 11:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34430 output: 34 thoughts: 2250 Thoughts: **Analyzing the Core Dump Mechanism and File Descriptor Handling** Okay, so I've been diving into this patch and trying to understand its implications for core dumps and file descriptor management, specifically in the context of `sysctl` interactions. My main concern is around how the `core_pattern` is handled, especially when a write operation is involved, and ensuring that no vulnerabilities are introduced while changing the handling of file descriptors. Initially, I'm tracing how the `core_pattern` is used to build up an in-kernel buffer (`kbuf`) for a sysctl read operation. The `proc_handler` writes bytes into this buffer, and this is then fed to `copy_to_iter()`. I see the `core_pattern` is being used to initialize a pattern which is then passed to `_proc_do_string`. The size of the copied data to `kbuf` depends on the length of `core_pattern`. The potential vulnerability I spotted is that someone can write to `core_pattern`. I then went through the `proc_dostring_coredump` function and found that the current implementation works on a copy of `core_pattern` which is the local array `pattern`. This `pattern` is protected by `core_pattern_lock`. This prevents potential race conditions, which is good. The patch also checks if the new `pattern` satisfies `check_coredump_socket()` to make sure it is valid. Then finally it uses `strscpy()` to copy the modified, validated pattern to `core_pattern`. This prevents any buffer overflow problems in setting `core_pattern`. Now, I'm carefully analyzing the changes to `fs/coredump.c`, which introduces the `core_pattern_lock` and modifies several key functions. I see RCU lifetime protection for `task` and additions for `jobctl` checks. I also saw that `check_coredump_socket()` now takes a local `pattern` parameter instead of referencing a global variable. This is good because it makes the function more robust. The `proc_dostring_coredump` function uses a local `pattern` array protected by `core_pattern_lock`, confirming my suspicion about the lock. Next, I'm examining changes to `fs/exec.c`. It looks like `io_uring_task_cancel()` is being moved to run *before* `de_thread()`, to make sure that io_uring activity gets fully cancelled before the thread group cleanup. Finally, I'm looking closely at `fs/file.c` to see how file descriptors are being closed. I see a change to the closing order, iterating file descriptors from highest to lowest. This is an optimization. My main interest now is in `__range_close` and `close_cloexec_files`. I will dive deep into these functions. My suspicion is that this patch changes the iteration order of the file descriptors and that `find_last_bit` will have an important role in it. |
| 84/3 | 2026/09/23 11:39 | tool | grepper |
0mArgs:{
"Expression": "unsigned long find_last_bit",
"PathPrefix": "include/linux/find.h"
}Results: {
"Output": "include/linux/find.h=403=static __always_inline\ninclude/linux/find.h:404:unsigned long find_last_bit(const unsigned long *addr, unsigned long size)\ninclude/linux/find.h-405-{\n"
} |
| 85/3 | 2026/09/23 11:39 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37422 output: 35 thoughts: 20 Thoughts: Here's a summary of my thought process, keeping in mind my expert understanding: **Navigating the Linux Kernel: A Focused Investigation** Okay, time to dive in. Based on the context, I'm going to head directly into the kernel's `find.h` header. Specifically, I'm zeroing in on the area around line 404. My assumption is that the relevant logic is most likely to be located within that section, and I'll start there to get a granular understanding of the code. This targeted approach is more efficient than a full read-through, given the complexity of the kernel. I can quickly gain the context needed to understand the feature or potential issue at hand. |
| 86/3 | 2026/09/23 11:39 | tool | read-file |
0mArgs:{
"File": "include/linux/find.h",
"FirstLine": 400,
"LineCount": 25
}Results: {
"Contents": " 400:\t *\n 401:\t * Returns the bit number of the last set bit, or size.\n 402:\t */\n 403:\tstatic __always_inline\n 404:\tunsigned long find_last_bit(const unsigned long *addr, unsigned long size)\n 405:\t{\n 406:\t\tif (small_const_nbits(size)) {\n 407:\t\t\tunsigned long val = *addr \u0026 GENMASK(size - 1, 0);\n 408:\t\n 409:\t\t\treturn val ? __fls(val) : size;\n 410:\t\t}\n 411:\t\n 412:\t\treturn _find_last_bit(addr, size);\n 413:\t}\n 414:\t#endif\n 415:\t\n 416:\t/**\n 417:\t * find_next_and_bit_wrap - find the next set bit in both memory regions\n 418:\t * @addr1: The first address to base the search on\n 419:\t * @addr2: The second address to base the search on\n 420:\t * @size: The bitmap size in bits\n 421:\t * @offset: The bitnumber to start searching at\n 422:\t *\n 423:\t * Returns the bit number for the next set bit, or first set bit up to @offset\n 424:\t * If no bits are set, returns @size.\n"
} |
| 87/3 | 2026/09/23 11:39 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38010 output: 26 thoughts: 2962 Thoughts: **Kernel Changes Analysis: A Review of Concurrency, Signals, and File Descriptor Management** Okay, let's break this down. My initial scan focused on file descriptor (fd) management, particularly the `find_last_bit` function and how it's used to close files in reverse order within `__range_close` and `close_cloexec_files`. The reverse order approach, from high to low fds, makes sense for cleanup. The bit operations are standard. Now, I see important changes relating to signal handling, especially concerning tasks marked as "user workers" via `PF_USER_WORKER`. The `__fatal_signal_pending` function is now used, and coredumping behaviour has been updated. The new `coredump_signal_pending` function specifically addresses scenarios where a task is coredumping. A coredumping task now only stops for `SIGKILL`, the freezer, or `JOBCTL_TRAP_FREEZE`. This seems like a refinement of how we handle signals during coredump generation. The `io_wq_exit_start` introduces `smp_mb__after_atomic()` which is a memory barrier paired with the `task_work_add()` in `io_queue_worker_create()`, for thread creation and shutdown. The `do_exit` function in `kernel/exit.c` has had a code reordering, changing the order of disassociating the controlling terminal (`disassociate_ctty`) relative to file-related cleanup. Specifically, the terminal is hung up _before_ the last close which clears the session. The changes in `kernel/fork.c` around `copy_process` are important. The `PF_USER_WORKER` tasks are now restricted to blocking only `SIGKILL` and `SIGSTOP`. This is enforced through modifications to `p->blocked` during process creation. Now a user worker only takes signals nobody can block. This restriction appears in the `copy_process` function, and is now also enforced in `ptrace_request` via a `-EPERM` error code. The changes now include setting `p->files = NULL` to deal with the error path and have improved cleanup. Critically, a check in `create_io_thread` prevents the creation of threads from a process past the point of its fatal signal or its coredump, guarding against an attempt to create a thread if the process is marked as signaled or post-coredump. The real meat is in the signal blocking logic, particularly in `__set_task_blocked`. There's now a check that if a task is a user worker, then it can only block signals _except_ SIGKILL and SIGSTOP. The logic uses `siginitsetinv`, and `sigorsets` for this purpose. I must verify this code to ensure it's behaving as intended, and that there are no issues around race conditions and correctness. Specifically, the warning message `WARN_ON_ONCE(!sigequalsets(&floored, newset))` implies that a mismatch is unexpected, indicating a potential logic bug. We're effectively overriding the `newset` with a more restricted set if the task is a user worker. |
| 88/3 | 2026/09/23 11:39 | tool | grepper |
0mArgs:{
"Expression": "siginitsetinv",
"PathPrefix": "include/"
}Results: {
"Output": "include/linux/signal.h=235=static inline void siginitset(sigset_t *set, unsigned long mask)\n--\ninclude/linux/signal.h-247-\ninclude/linux/signal.h:248:static inline void siginitsetinv(sigset_t *set, unsigned long mask)\ninclude/linux/signal.h-249-{\n"
} |
| 89/3 | 2026/09/23 11:39 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41784 output: 35 thoughts: 20 Thoughts: Here's my attempt at summarizing the thought process, tailored for an expert audience: **Diving into Signal Handling** Okay, so I'm digging into signal handling again. I think I need to refresh my memory on where the signal structures are defined. My gut feeling is that the core data structures are probably in `include/linux/signal.h`. Let's take a look around line 248 of that file, that's usually where the meat of the `siginfo` and related structs are defined or referenced. Hopefully, that will get me back on track. I'll need to double-check my understanding of how those structures map to the kernel's internal representation and the user-space interactions. Let's see what's in there. |
| 90/3 | 2026/09/23 11:39 | tool | read-file |
0mArgs:{
"File": "include/linux/signal.h",
"FirstLine": 240,
"LineCount": 40
}Results: {
"Contents": " 240:\t\t\tmemset(\u0026set-\u003esig[1], 0, sizeof(long)*(_NSIG_WORDS-1));\n 241:\t\t\tbreak;\n 242:\t\tcase 2: set-\u003esig[1] = 0;\n 243:\t\t\tbreak;\n 244:\t\tcase 1: ;\n 245:\t\t}\n 246:\t}\n 247:\t\n 248:\tstatic inline void siginitsetinv(sigset_t *set, unsigned long mask)\n 249:\t{\n 250:\t\tset-\u003esig[0] = ~mask;\n 251:\t\tswitch (_NSIG_WORDS) {\n 252:\t\tdefault:\n 253:\t\t\tmemset(\u0026set-\u003esig[1], -1, sizeof(long)*(_NSIG_WORDS-1));\n 254:\t\t\tbreak;\n 255:\t\tcase 2: set-\u003esig[1] = -1;\n 256:\t\t\tbreak;\n 257:\t\tcase 1: ;\n 258:\t\t}\n 259:\t}\n 260:\t\n 261:\t#endif /* __HAVE_ARCH_SIG_SETOPS */\n 262:\t\n 263:\tstatic inline void init_sigpending(struct sigpending *sig)\n 264:\t{\n 265:\t\tsigemptyset(\u0026sig-\u003esignal);\n 266:\t\tINIT_LIST_HEAD(\u0026sig-\u003elist);\n 267:\t}\n 268:\t\n 269:\textern void flush_sigqueue(struct sigpending *queue);\n 270:\t\n 271:\t/* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */\n 272:\tstatic inline int valid_signal(unsigned long sig)\n 273:\t{\n 274:\t\treturn sig \u003c= _NSIG ? 1 : 0;\n 275:\t}\n 276:\t\n 277:\tstruct timespec;\n 278:\tstruct pt_regs;\n 279:\tenum pid_type;\n"
} |
| 91/3 | 2026/09/23 11:39 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42551 output: 439 thoughts: 1075 Thoughts: **KMSAN Assessment: NeedsKMSAN = false** Okay, let's break this down. First, `siginitsetinv` initializes the `set->sig` and `sigorsets` performs a bitwise OR operation. So, `floor` and `floored` are completely initialized. Now to consider the KMSAN criteria, I need to evaluate the changes against the instructions: I've checked each of the criteria. I've carefully examined the code changes, considering each of the defined criteria. My focus is whether this patch introduces the risk of uninitialized memory usage or potential info-leaks, or modifies kernel structures sent to userspace where padding or fields might not be zeroed. I've looked at the changes in `proc_dostring_coredump`, `kernel/signal.c`, `fs/file.c`, `kernel/exit.c`, `kernel/fork.c`, `kernel/ptrace.c`, `io_uring/io-wq.c`, and `fs/exec.c`, and `fs/coredump.c`. Specifically: * In `proc_dostring_coredump`, I've verified that the stack-allocated `pattern` buffer is safe since the write to `kbuf` is bounded by `strlen(data)`. * In `kernel/signal.c`, `floor` and `floored` are fully initialized stack variables. * The iteration order change in `fs/file.c` is not relevant to KMSAN. * The reordering in `kernel/exit.c` and `kernel/fork.c` is not relevant to KMSAN. * The signal mask prevention in `kernel/ptrace.c` is not relevant to KMSAN. * The memory barrier in `io_uring/io-wq.c` is not relevant to KMSAN. * The movement in `fs/exec.c` is not relevant to KMSAN. * The additions in `fs/coredump.c` are not relevant to KMSAN. In summary, none of these changes introduces, or exposes, uninitialized memory. The bugs addressed here concern concurrency, lifecycle/RCU issues, process freezing/signals during coredumps, file closing order, and user worker/io\_uring signal/exit handling. These are concurrency, locking, or lifecycle bugs that would be detected by LOCKDEP, KASAN, or generic stress testing. The issues do not fall under the purview of KMSAN. I'm confident in saying that all touched stack and heap structures are fully initialized before being read or copied. Therefore, this patch does not introduce any risk of uninitialized memory usage or info-leaks. KASAN and LOCKDEP are sufficient. Therefore, `NeedsKMSAN` should be set to `false`. I've documented my reasoning clearly: * KMSAN is for uninitialized memory use/leak; KASAN/LOCKDEP/RCU are for different classes of bugs. * The patch's core touchpoints (coredump pattern sync, thread wakeup under RCU, signal handling, file descriptor cleanup, execve io\_uring cancellation) are not related to uninitialized memory. * Stack arrays are initialized via string operations, and string operations are length-bounded. * No uninitialized data is exposed to userspace. * Concurrency issues are covered by existing tools. * KMSAN is not needed here. I'll proceed to call the `set-results` tool, as I'm satisfied with this assessment. |
| 92/3 | 2026/09/23 11:40 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series focuses on race conditions, process lifecycle, signal masks, and file descriptor closing order during coredump, exec, fork, and exit paths:\n1. fs/coredump.c: Introduces a spinlock (`core_pattern_lock`) protecting reads and writes to `core_pattern`. The local stack buffers `pattern` in `coredump_parse()` and `proc_dostring_coredump()` are populated using `strscpy()`, and subsequent string processing is strictly null-terminated or length-checked. The sysctl read/write handlers operate strictly on the string length (`strlen`), so uninitialized stack bytes are never copied to userspace.\n2. fs/coredump.c: Protects exiting threads with RCU during wakeup in `coredump_finish()` (guards against use-after-free, which is a KASAN domain).\n3. fs/file.c: Changes the iteration order when closing fds (using `__fls()` and `find_last_bit()` from highest to lowest fd) on existing bitmap structures without altering allocation or initialization.\n4. kernel/fork.c, kernel/exit.c, fs/exec.c, io_uring/io-wq.c: Reorders teardown steps, initializes `p-\u003efiles = NULL`, and cancels io_uring tasks earlier to prevent deadlocks and races with user workers.\n5. kernel/signal.c: `floor` and `floored` sigset_t variables in `__set_task_blocked()` are fully initialized via `siginitsetinv()` and `sigorsets()`.\n\nNone of the changes introduce uninitialized memory reads, info-leaks to userspace, or uninitialized padding exposure. The concerns addressed by this patch relate to synchronization, lifecycle/UAF, and deadlock prevention, which are covered by KASAN and LOCKDEP rather than KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series focuses on race conditions, process lifecycle, signal masks, and file descriptor closing order during coredump, exec, fork, and exit paths:\n1. fs/coredump.c: Introduces a spinlock (`core_pattern_lock`) protecting reads and writes to `core_pattern`. The local stack buffers `pattern` in `coredump_parse()` and `proc_dostring_coredump()` are populated using `strscpy()`, and subsequent string processing is strictly null-terminated or length-checked. The sysctl read/write handlers operate strictly on the string length (`strlen`), so uninitialized stack bytes are never copied to userspace.\n2. fs/coredump.c: Protects exiting threads with RCU during wakeup in `coredump_finish()` (guards against use-after-free, which is a KASAN domain).\n3. fs/file.c: Changes the iteration order when closing fds (using `__fls()` and `find_last_bit()` from highest to lowest fd) on existing bitmap structures without altering allocation or initialization.\n4. kernel/fork.c, kernel/exit.c, fs/exec.c, io_uring/io-wq.c: Reorders teardown steps, initializes `p-\u003efiles = NULL`, and cancels io_uring tasks earlier to prevent deadlocks and races with user workers.\n5. kernel/signal.c: `floor` and `floored` sigset_t variables in `__set_task_blocked()` are fully initialized via `siginitsetinv()` and `sigorsets()`.\n\nNone of the changes introduce uninitialized memory reads, info-leaks to userspace, or uninitialized padding exposure. The concerns addressed by this patch relate to synchronization, lifecycle/UAF, and deadlock prevention, which are covered by KASAN and LOCKDEP rather than KMSAN. Therefore, a dedicated KMSAN fuzzing session is not warranted.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|