lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87a51ic7up.fsf@jogness.linutronix.de>
Date: Thu, 23 Oct 2025 11:04:38 +0206
From: John Ogness <john.ogness@...utronix.de>
To: Petr Mladek <pmladek@...e.com>, Oleg Nesterov <oleg@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>, Sebastian Andrzej Siewior
 <bigeasy@...utronix.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] printk_legacy_map: use LD_WAIT_CONFIG instead of
 LD_WAIT_SLEEP

On 2025-10-23, Petr Mladek <pmladek@...e.com> wrote:
>> printk_legacy_map is used on !PREEMPT_RT to avoid false positives from
>> CONFIG_PROVE_RAW_LOCK_NESTING about raw_spinlock/spinlock nesting.
>> 
>> However, LD_WAIT_SLEEP is not exactly right; it fools lockdep as if it
>> is fine to acquire a sleeping lock.
>> 
>> Change DEFINE_WAIT_OVERRIDE_MAP(printk_legacy_map) to use LD_WAIT_CONFIG.
>> 
>> (We can also make printk_legacy_allow_spinlock_enter/exit() depend on
>>  !PREEMPT_RT && CONFIG_PROVE_RAW_LOCK_NESTING)
>
> I do not have strong opinion about adding (&& CONFIG_PROVE_RAW_LOCK_NESTING).
> This dependency is already handled in LD_WAIT_CONFIG definition.

I prefer avoiding CONFIG_PROVE_RAW_LOCK_NESTING since it is not necessary.

>> Signed-off-by: Oleg Nesterov <oleg@...hat.com>
>
> Anyway, the change makes sense to me. It seems that this better fits
> the purpose.
>
> Reviewed-by: Petr Mladek <pmladek@...e.com>
>
> See a note below.
>
>> ---
>>  kernel/printk/printk.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>> 
>> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
>> index 5aee9ffb16b9..f11b2f31999b 100644
>> --- a/kernel/printk/printk.c
>> +++ b/kernel/printk/printk.c
>> @@ -3007,7 +3007,7 @@ bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
>>   * false positive. For PREEMPT_RT the false positive condition does not
>>   * occur.
>
> From the comment, it was not obvious to me why the condition does not
> occur for PREEMPT_RT. I had to check the commit message from the
> commit daeed1595b4ddf314b ("printk: Avoid false positive lockdep
> report for legacy printing").
>
> <paste>
>     However, on PREEMPT_RT the printing path from atomic context is
>     always avoided and the console driver is always invoked from a
>     dedicated thread. Thus the lockdep splat on !PREEMPT_RT is a
>     false positive.
>  </paste>
>
> This is much more clear. It might make sense to improve the comment,
> for example:
>
> <proposal>
> /*
>  * Legacy console printing from printk() caller context does not respect
>  * raw_spinlock/spinlock nesting. However, on PREEMPT_RT the printing
>  * path from atomic context is always avoided and the console driver
>  * is always invoked from a dedicated thread. Thus the lockdep splat
>  * on !PREEMPT_RT is a false positive.
>  *
>  * This map is used to temporarily establish LD_WAIT_CONFIG context for the
>  * console write() callback when legacy printing to avoid false positive
>  * lockdep complaints, thus allowing lockdep to continue to function for
>  * real issues.
>  */
> </proposal>

I am OK with this proposal.

> But it can be done in a separate patch...
>
>>   *
>> - * This map is used to temporarily establish LD_WAIT_SLEEP context for the
>> + * This map is used to temporarily establish LD_WAIT_CONFIG context for the
>>   * console write() callback when legacy printing to avoid false positive
>>   * lockdep complaints, thus allowing lockdep to continue to function for
>>   * real issues.
>> @@ -3016,7 +3016,7 @@ bool printk_get_next_message(struct printk_message *pmsg, u64 seq,
>>  static inline void printk_legacy_allow_spinlock_enter(void) { }
>>  static inline void printk_legacy_allow_spinlock_exit(void) { }
>>  #else
>> -static DEFINE_WAIT_OVERRIDE_MAP(printk_legacy_map, LD_WAIT_SLEEP);
>> +static DEFINE_WAIT_OVERRIDE_MAP(printk_legacy_map, LD_WAIT_CONFIG);
>>  
>>  static inline void printk_legacy_allow_spinlock_enter(void)
>>  {
>
> Best Regards,
> Petr
>
> PS: I would take this patch via the printk tree. But I am going to wait
>     for feedback from others (John, Sebastian, ...).

AFAICT LD_WAIT_CONFIG would be an improvement by allowing detection of
non-spinlock-sleeping.

Reviewed-by: John Ogness <john.ogness@...utronix.de>

I would like to see an official ACK from Sebastian as well.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ