Re: [PATCH] lib/vsprintf: Validate sleepable context during restrictred pointer formatting
From: Andy Shevchenko
Date: Tue Mar 17 2026 - 10:19:09 EST
On Tue, Mar 17, 2026 at 12:41:23PM +0100, Thomas Weißschuh wrote:
> Depending on the system configuration, the restricted pointer formatting
> might call into the security subsystem which might sleep.
> As %pK is intended to be only used from read handlers of virtual files,
> which always run in task context, this should never happen in practice.
> However, developers have used %pK before from atomic context without
> realizing this restriction. While all existing user of %pK through
> printk() have been removed, new ones might be reintroduced accidentally
> in the future.
>
> Add a might_sleep(), so that misuse of %pK from atomic context is
> detected right away.
...
> + /* Only usable from task context, The call to has_capability_noaudit() might sleep. */
> + might_sleep();
Yeah, but for kptr_restrict != 1 it's not true. Perhaps might_sleep_if() ?
--
With Best Regards,
Andy Shevchenko