* NULL pointer dereference in coredump code
@ 2020-03-30 8:31 Thibaut Sautereau
2020-05-19 7:16 ` Thibaut Sautereau
0 siblings, 1 reply; 2+ messages in thread
From: Thibaut Sautereau @ 2020-03-30 8:31 UTC (permalink / raw)
To: Alexander Viro, linux-fsdevel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 944 bytes --]
I hit a kernel NULL pointer dereference caused by the following call chain:
do_coredump()
file_start_write(cprm.file) # cprm.file is NULL
file_inode(file) # NULL ptr deref
The `ispipe` path is followed in do_coredump(), and:
# cat /proc/sys/kernel/core_pattern
|/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h
It seems that cprm.file can be NULL after the call to the usermode
helper, especially when setting CONFIG_STATIC_USERMODEHELPER=y and
CONFIG_STATIC_USERMODEHELPER_PATH="", which is the case for me.
One may say it's a strange combination of configuration options but I
think it should not crash the kernel anyway. As I don't know much about
coredumps in general and this code, I don't know what's the best way to
fix this issue in a clean and comprehensive way.
I attached the patch I used to temporarily work around this issue, if
that can clarify anything.
Thanks,
--
Thibaut Sautereau
CLIP OS developer
[-- Attachment #2: 0001-coredump-FIXUP.patch --]
[-- Type: text/plain, Size: 678 bytes --]
From 613dfc60429c1fc5fc19e1c8662648620dc103af Mon Sep 17 00:00:00 2001
From: Thibaut Sautereau <thibaut.sautereau@ssi.gouv.fr>
Date: Fri, 27 Mar 2020 16:34:59 +0100
Subject: [PATCH] coredump: FIXUP
---
fs/coredump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/coredump.c b/fs/coredump.c
index b1ea7dfbd149..d0177b81345f 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -686,7 +686,7 @@ void do_coredump(const kernel_siginfo_t *siginfo)
UMH_WAIT_EXEC);
kfree(helper_argv);
- if (retval) {
+ if (retval || !cprm.file) {
printk(KERN_INFO "Core dump to |%s pipe failed\n",
cn.corename);
goto close_fail;
--
2.26.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: NULL pointer dereference in coredump code
2020-03-30 8:31 NULL pointer dereference in coredump code Thibaut Sautereau
@ 2020-05-19 7:16 ` Thibaut Sautereau
0 siblings, 0 replies; 2+ messages in thread
From: Thibaut Sautereau @ 2020-05-19 7:16 UTC (permalink / raw)
To: Alexander Viro, linux-fsdevel, linux-kernel
On Mon, Mar 30, 2020 at 10:31:59AM +0200, Thibaut Sautereau wrote:
> I hit a kernel NULL pointer dereference caused by the following call chain:
>
> do_coredump()
> file_start_write(cprm.file) # cprm.file is NULL
> file_inode(file) # NULL ptr deref
>
> The `ispipe` path is followed in do_coredump(), and:
> # cat /proc/sys/kernel/core_pattern
> |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h
>
> It seems that cprm.file can be NULL after the call to the usermode
> helper, especially when setting CONFIG_STATIC_USERMODEHELPER=y and
> CONFIG_STATIC_USERMODEHELPER_PATH="", which is the case for me.
>
> One may say it's a strange combination of configuration options but I
> think it should not crash the kernel anyway. As I don't know much about
> coredumps in general and this code, I don't know what's the best way to
> fix this issue in a clean and comprehensive way.
>
> I attached the patch I used to temporarily work around this issue, if
> that can clarify anything.
>
> Thanks,
For the record, this had previously been reported [1] and was eventually
fixed by 3740d93e3790 ("coredump: fix crash when umh is disabled").
[1] https://bugzilla.kernel.org/show_bug.cgi?id=199795
--
Thibaut Sautereau
CLIP OS developer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-19 7:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 8:31 NULL pointer dereference in coredump code Thibaut Sautereau
2020-05-19 7:16 ` Thibaut Sautereau
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).