diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-09-21 15:44:52 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-09-22 13:47:27 +0200 |
| commit | 8421a62085ec2d0be97b17ef66536344f472703e (patch) | |
| tree | fe915ccf267d347239e2ab783de0955346e4603d /tools/lib/python/kdoc | |
| parent | 852d7eaa44a575a4395ca4d3465d3c91ae1b7865 (diff) | |
| download | linux-next-8421a62085ec2d0be97b17ef66536344f472703e.tar.gz linux-next-8421a62085ec2d0be97b17ef66536344f472703e.zip | |
coredump: parse a snapshot of core_pattern
This is a long-standing problem that I discussed a while back with Jann.
I didn't care enough about it to really fix it and it's from the
before-fore-times.
coredump_parse() reads core_pattern directly while it can concurrently
be modified. So it reads the first byte, figures out what mode is
wanted, then allocates the number buffer and then consumes the rest of
the core_pattern string.
Say the sysctl handler updates the core_pattern array byte by byte
(idiotic but supported). So that can lead to all kinds of insane mixups.
Say you could transform the old "|/usr/bin/helper" and the new
"/tmp/core.%p" into a usermodehelper started as "tmp/core.<pid>".
So copy what proc_do_uts_string() does and let the handler run
proc_dostring() on a copy, validate the copy and make it visible beneath
a spinlock. Then coredump_parse() can take a snapshot under the same
spinlock and parse a stable copy.
From now on, rejected patterns are never visible and we can drop the
whole rollback logic. It has the same minor defect that utsname has,
namely that two writers can race on a non-zero offset. Irrelevant imho.
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Link: https://patch.msgid.link/20260921-work-coredump-fixes-v3-3-8e4adb1619e6@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc')
0 files changed, 0 insertions, 0 deletions
