Re: [PATCH v3 5/5] lib/vsprintf: Always check interrupt context restrictions
From: Petr Mladek
Date: Wed May 27 2026 - 11:53:00 EST
On Wed 2026-05-20 10:40:04, 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.
>
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -871,6 +871,8 @@ char *restricted_pointer(char *buf, char *end, const void *ptr,
>
> guard(lock_map_acquire)(&vsprintf_restricted_pointer_map);
>
> + lockdep_assert(in_task());
It might make sense to do this assert before checking the fake
spinlock. The task context is more restrictive than then
the spin lock context so we might want to check it first.
It might prevent confusing reports about inconsitent IRQ
usage. This function should not be called in IRQ context
at all.
Otherwise, it looks good to me.
Best Regards,
Petr
> +
> switch (kptr_restrict) {
> case 0:
> /* Handle as %p, hash and do _not_ leak addresses. */