Skip to content

Commit 1e3fa25

Browse files
oleg-nesterovakpm00
authored andcommitted
coredump: simplify zap_process()
After commit 0258b5f ("coredump: Limit coredumps to a single thread group") zap_process() doesn't need the "task_struct *start" arg, zap_threads() can pass "signal_struct *signal" instead. This simplifies the code and allows to use __for_each_thread() which is slightly more efficient. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Oleg Nesterov <[email protected]> Cc: Christian Brauner <[email protected]> Cc: Eric W. Biederman <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2a49c8b commit 1e3fa25

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

fs/coredump.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,16 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm,
361361
return ispipe;
362362
}
363363

364-
static int zap_process(struct task_struct *start, int exit_code)
364+
static int zap_process(struct signal_struct *signal, int exit_code)
365365
{
366366
struct task_struct *t;
367367
int nr = 0;
368368

369-
/* Allow SIGKILL, see prepare_signal() */
370-
start->signal->flags = SIGNAL_GROUP_EXIT;
371-
start->signal->group_exit_code = exit_code;
372-
start->signal->group_stop_count = 0;
369+
signal->flags = SIGNAL_GROUP_EXIT;
370+
signal->group_exit_code = exit_code;
371+
signal->group_stop_count = 0;
373372

374-
for_each_thread(start, t) {
373+
__for_each_thread(signal, t) {
375374
task_clear_jobctl_pending(t, JOBCTL_PENDING_MASK);
376375
if (t != current && !(t->flags & PF_POSTCOREDUMP)) {
377376
sigaddset(&t->pending.signal, SIGKILL);
@@ -391,8 +390,9 @@ static int zap_threads(struct task_struct *tsk,
391390

392391
spin_lock_irq(&tsk->sighand->siglock);
393392
if (!(signal->flags & SIGNAL_GROUP_EXIT) && !signal->group_exec_task) {
393+
/* Allow SIGKILL, see prepare_signal() */
394394
signal->core_state = core_state;
395-
nr = zap_process(tsk, exit_code);
395+
nr = zap_process(signal, exit_code);
396396
clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
397397
tsk->flags |= PF_DUMPCORE;
398398
atomic_set(&core_state->nr_threads, nr);

0 commit comments

Comments
 (0)