2013-07-18 23:03:52

by Kees Cook

[permalink] [raw]
Subject: [PATCH] panic: call panic handlers before kmsg_dump

Since the panic handlers may produce additional information (via printk)
for the kernel log, it should be reported as part of the panic output
saved by kmsg_dump(). Without this re-ordering, nothing that adds
information to a panic will show up in pstore's view when kmsg_dump
runs, and is therefore not visible to crash reporting tools that examine
pstore output.

Signed-off-by: Kees Cook <[email protected]>
---
kernel/panic.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/panic.c b/kernel/panic.c
index 8018646..b6c482c 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -123,10 +123,14 @@ void panic(const char *fmt, ...)
*/
smp_send_stop();

- kmsg_dump(KMSG_DUMP_PANIC);
-
+ /*
+ * Run any panic handlers, including those that might need to
+ * add information to the kmsg dump output.
+ */
atomic_notifier_call_chain(&panic_notifier_list, 0, buf);

+ kmsg_dump(KMSG_DUMP_PANIC);
+
bust_spinlocks(0);

if (!panic_blink)
--
1.7.9.5


--
Kees Cook
Chrome OS Security


2013-07-18 23:17:15

by Tony Luck

[permalink] [raw]
Subject: Re: [PATCH] panic: call panic handlers before kmsg_dump

On Thu, Jul 18, 2013 at 4:03 PM, Kees Cook <[email protected]> wrote:
> Since the panic handlers may produce additional information (via printk)
> for the kernel log, it should be reported as part of the panic output
> saved by kmsg_dump(). Without this re-ordering, nothing that adds
> information to a panic will show up in pstore's view when kmsg_dump
> runs, and is therefore not visible to crash reporting tools that examine
> pstore output.

Good point.

Acked-by: Tony Luck <[email protected]>

2013-09-10 22:41:27

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] panic: call panic handlers before kmsg_dump

On Thu, Jul 18, 2013 at 4:17 PM, Tony Luck <[email protected]> wrote:
> On Thu, Jul 18, 2013 at 4:03 PM, Kees Cook <[email protected]> wrote:
>> Since the panic handlers may produce additional information (via printk)
>> for the kernel log, it should be reported as part of the panic output
>> saved by kmsg_dump(). Without this re-ordering, nothing that adds
>> information to a panic will show up in pstore's view when kmsg_dump
>> runs, and is therefore not visible to crash reporting tools that examine
>> pstore output.
>
> Good point.
>
> Acked-by: Tony Luck <[email protected]>

Can someone pick this patch up? If akpm doesn't want it, it could live
in the pstore tree maybe?

-Kees

--
Kees Cook
Chrome OS Security

2013-09-10 22:44:59

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] panic: call panic handlers before kmsg_dump

On Tue, Sep 10, 2013 at 3:41 PM, Kees Cook <[email protected]> wrote:
> On Thu, Jul 18, 2013 at 4:17 PM, Tony Luck <[email protected]> wrote:
>> On Thu, Jul 18, 2013 at 4:03 PM, Kees Cook <[email protected]> wrote:
>>> Since the panic handlers may produce additional information (via printk)
>>> for the kernel log, it should be reported as part of the panic output
>>> saved by kmsg_dump(). Without this re-ordering, nothing that adds
>>> information to a panic will show up in pstore's view when kmsg_dump
>>> runs, and is therefore not visible to crash reporting tools that examine
>>> pstore output.
>>
>> Good point.
>>
>> Acked-by: Tony Luck <[email protected]>
>
> Can someone pick this patch up? If akpm doesn't want it, it could live
> in the pstore tree maybe?

Ah, sorry, it seems like it is already in -mm. Never mind!

-Kees

--
Kees Cook
Chrome OS Security