NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/58442: kmem_alloc, kmem_free, &c., might not panic under spin locks



>Number:         58442
>Category:       kern
>Synopsis:       kmem_alloc, kmem_free, &c., might not panic under spin locks
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 18 15:30:00 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10, 9, ...
>Organization:
The NetBSD Foundalloc in interrupt context
>Environment:
>Description:
It is forbidden to call kmem_alloc, kmem_free, and other such functions in interrupt context.

Since logic in interrupt context may take spin locks, calling kmem_alloc/free under a spin lock is effectively calling them in interrupt context, so it is also forbidden.

kmem_alloc and kmem_free have

	KASSERT(!cpu_intr_p());
	KASSERT(!cpu_softintr_p());

but they don't assert anything about raised IPL or holding spin locks.
>How-To-Repeat:
draft code that calls kmem_alloc/free under a spin lock, e.g. an IPL_VM mutex
>Fix:
1. invent a way to assert IPL is not raised
2. maybe use LOCKDEBUG_BARRIER(NULL, /*slplocksforbidden*/false) in kmem_alloc/free



Home | Main Index | Thread Index | Old Index