Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pidfs: fix PIDFD_INFO_COREDUMP handling

When PIDFD_INFO_COREDUMP is requested we raise it unconditionally in the
returned mask even if no coredump actually did take place. This was
done because we assumed that the later check whether ->coredump_mask as
non-zero detects that it is zero and then retrieves the dumpability
settings from the task's mm. This has issues though becuase there are
tasks that might not have any mm. Also it's just not very cleanly
implemented. Fix this.

Link: https://patch.msgid.link/20251028-work-coredump-signal-v1-2-ca449b7b7aa0@kernel.org
Reviewed-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

+4 -2
+4 -2
fs/pidfs.c
··· 335 335 } 336 336 337 337 if (mask & PIDFD_INFO_COREDUMP) { 338 - kinfo.mask |= PIDFD_INFO_COREDUMP; 339 338 kinfo.coredump_mask = READ_ONCE(attr->__pei.coredump_mask); 339 + if (kinfo.coredump_mask) 340 + kinfo.mask |= PIDFD_INFO_COREDUMP; 340 341 } 341 342 342 343 task = get_pid_task(pid, PIDTYPE_PID); ··· 356 355 if (!c) 357 356 return -ESRCH; 358 357 359 - if ((kinfo.mask & PIDFD_INFO_COREDUMP) && !(kinfo.coredump_mask)) { 358 + if ((mask & PIDFD_INFO_COREDUMP) && !kinfo.coredump_mask) { 360 359 guard(task_lock)(task); 361 360 if (task->mm) { 362 361 unsigned long flags = __mm_flags_get_dumpable(task->mm); 363 362 364 363 kinfo.coredump_mask = pidfs_coredump_mask(flags); 364 + kinfo.mask |= PIDFD_INFO_COREDUMP; 365 365 } 366 366 } 367 367