Re: [PATCH] lib/test_crash: test module to trigger kernel crashes
From: Calvin Owens
Date: Wed May 27 2026 - 16:44:33 EST
On Wednesday 05/27 at 11:40 -0700, Andrew Morton wrote:
> On Wed, 27 May 2026 09:56:44 -0700 Calvin Owens <calvin@xxxxxxxxxx> wrote:
>
> > This test calls panic() from various execution contexts in the kernel,
> > so the user can see if a crash trace is successfully emitted.
> >
> > This is useful for testing console drivers, and can help rule out issues
> > with the console itself when silent reboots or hangs are observed on a
> > particular system.
>
> Well you aren't the first to write a patch which crashes the kernel ;)
Thanks for taking a look Andrew.
In answering some of your questions, I ran across drivers/misc/lkdtm/
which already does all of this and more... oops :/
So we can drop this, unless Petr sees some value to this new one and
wants to chime in.
Thanks,
Calvin
> > ---
> > I shared this upthread in [1] where it turned out to be useful for
> > netconsole. Petr suggested it might be useful for others, so I've
> > applied his feedback and cleaned everything up a bit more too.
> >
> > It's a superset of what 'echo c > /proc/sysrq-trigger' does, but
> > extending that interface doesn't seem practical.
>
> Please fully expand on this?
>
> > The write() implementation requries the entire string be written in a
> > single syscall: this is pretty common for these debugfs interfaces, so
> > it didn't seem worth the complexity to handle partial writes. But I'm
> > happy to do so if somebody cares :)
>
> Some of the above is useful background and deserves to be above the ---
> separator.
>
> I'm not really liking the "crash" name. We already have one of those -
> a kexec crashdumping thing. Maybe "force_panic" or someting.
>
>
> > lib/Kconfig.debug | 18 +++++
> > lib/Makefile | 1 +
> > lib/test_crash.c | 176 ++++++++++++++++++++++++++++++++++++++++++++++
>
> Some Documentation would be nice.
>
> > --- a/lib/Kconfig.debug
> > +++ b/lib/Kconfig.debug
> > @@ -1385,6 +1385,24 @@ config TEST_LOCKUP
> >
> > If unsure, say N.
> >
> > +config TEST_CRASH
> > + tristate "Test module to trigger crashes"
>
> Some debugfs dependency needed?
>
> > + help
> > + Expose a file in debugfs which triggers a panic() call in
> > + various kernel execution contexts.
> > +
> > + $ cat /sys/kernel/debug/test_crash
> > + irq
> > + [...]
> > + $ echo "irq" > /sys/kernel/debug/test_crash
> > + Kernel panic - not syncing: User triggered crash in context irq
> > +
> > + This is useful for testing console drivers, and can help rule
> > + out issues with the console itself when silent reboots or
> > + hangs are observed on a particular system.
> > +
> > + If unsure, say N.
> > +
> > endmenu # "Debug lockups and hangs"
> >
> > menu "Scheduler Debugging"
> >
> > ...
> >