Messages in this thread Patch in this message | | | Date | Sat, 14 Mar 2020 21:35:00 +0000 | From | Sudip Mukherjee <> | Subject | Re: [PATCH 0/1] coredump: Fix null pointer dereference when kernel.core_pattern is "|" |
| |
Hi Paul,
On Sat, Mar 14, 2020 at 08:28:10AM +0800, Paul Wise wrote: > On Tue, 2020-03-10 at 11:34 +1300, Matthew Ruffell wrote: > > > Can I please get some feedback on this patch? Would be good to clear > > up the null pointer dereference.
I could reproduce the problem very easily, though the core_pattern is not supposed to be used that way. Only "|" is invalid core_pattern. But in anycase I think the kernel should have a check for this invalid usecase.
> > I had a thought about it, instead of using strlen, what about checking > that the first item in the array is NUL or not? In the normal case this > should be faster than strlen.
Why are you checking the corename in do_coredump() after it has done almost everything? It can be very easily checked in format_corename(). Something like the following:
diff --git a/fs/coredump.c b/fs/coredump.c index b1ea7dfbd149..d25bad2ed061 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -211,6 +211,8 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm, return -ENOMEM; (*argv)[(*argc)++] = 0; ++pat_ptr; + if (!(*pat_ptr)) + return -ENOMEM; } /* Repeat as long as we have more pattern to process and more output
-- Regards Sudip
| |