Re: [PATCH v2 4/4] lib/vsprintf: Always check interrupt context restrictions

From: Peter Zijlstra

Date: Mon May 04 2026 - 09:02:59 EST


On Mon, May 04, 2026 at 12:47:20PM +0200, Thomas Weißschuh wrote:
> When kptr_restrict is set to '1' restricted pointers can not be used
> in IRQ context. As kptr_restrict can change at any time at runtime,
> this means that restricted pointers can not be used from IRQ context
> in general.
>
> Add some assertions to detect misuse early, independently of the
> runtime configuration of the test system.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
> ---
> lib/vsprintf.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 021db95087fe..185bd9e61144 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -871,6 +871,10 @@ char *restricted_pointer(char *buf, char *end, const void *ptr,
>
> guard(lock_map_acquire)(&vsprintf_restricted_pointer_map);
>
> + lockdep_assert(!in_hardirq());
> + lockdep_assert(!in_serving_softirq());
> + lockdep_assert(!in_nmi());
> +

did that want to be:

lockdep_assert(in_task());

?