Re: BUG: KASAN: null-ptr-deref in _raw_spin_lock_irq next-20240410

From: David Gow
Date: Thu Apr 11 2024 - 23:26:50 EST


On Thu, 11 Apr 2024 at 23:05, Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
>
> On Thu, Apr 11, 2024 at 06:00:25PM +0300, Dan Carpenter wrote:
> > On Thu, Apr 11, 2024 at 08:20:55PM +0530, Naresh Kamboju wrote:
> > >
> > > I use to notice kernel panic while running kunit tests
> > > now I have noticed this
> > >
> > > Unable to handle kernel paging request at virtual address
> > > KASAN: null-ptr-deref in range
> > > pc : kunit_test_null_dereference (lib/kunit/kunit-test.c:119)
> > > lr : kunit_generic_run_threadfn_adapter (lib/kunit/try-catch.c:31)
> > >
> > > The kunit tests run to completion and the system is stable.
> > > Kernel did not panic.
> > >
> >
> > [ Snip ]
> >
> > > <0>[ 76.808597] Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP
> > > <4>[ 76.809876] Modules linked in:
> > > <4>[ 76.812055] CPU: 1 PID: 567 Comm: kunit_try_catch Tainted: G
> > > B N 6.9.0-rc3-next-20240410 #1
> > > <4>[ 76.812987] Hardware name: linux,dummy-virt (DT)
> > > <4>[ 76.814123] pstate: 12400009 (nzcV daif +PAN -UAO +TCO -DIT
> > > -SSBS BTYPE=--)
> > > <4>[ 76.814947] pc : kunit_test_null_dereference (lib/kunit/kunit-test.c:119)
> > ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > This is a new intentional NULL dereferencer that was added yesterday.
> >
> > Maybe these should have a big printk, "Intentional NULL dereference
> > coming up!\n".
> >
>
> Can the backtrace be suppressed, similar to the warnings suppression I am
> working on ?
>

I'd like to do that going forward. Of course, this isn't a warning, so
it doesn't work as-is (and it'd be harder to pass things like the
function name through), but it seems like a worthwhile feature to have
going forward.
We did have some similar stuff for trapping KASAN errors as a part of
the KASAN tests a while ago: that's also something to look at.

I have been playing with the warning suppression with the fortify
test, and that seems to be working well.

Cheers,
-- David

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature