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: <YDPWPI4aZat+D1DE@alley>
Date:   Mon, 22 Feb 2021 17:05:16 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
        Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH printk-rework 08/14] printk: add syslog_lock

On Fri 2021-02-19 15:45:21, John Ogness wrote:
> On 2021-02-19, Petr Mladek <pmladek@...e.com> wrote:
> >> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> >> index 20c21a25143d..401df370832b 100644
> >> --- a/kernel/printk/printk.c
> >> +++ b/kernel/printk/printk.c
> >> +/* Return a consistent copy of @syslog_seq. */
> >> +static u64 read_syslog_seq_irq(void)
> >> +{
> >> +	u64 seq;
> >> +
> >> +	raw_spin_lock_irq(&syslog_lock);
> >> +	seq = syslog_seq;
> >> +	raw_spin_unlock_irq(&syslog_lock);
> >
> > Is there any particular reason to disable interrupts here?
> >
> > It would make sense only when the lock could be taken in IRQ
> > context. Then we would need to always disable interrupts when
> > the lock is taken. And if it is taken in IRQ context, we would
> > need to safe flags.
> 
> All other instances of locking @syslog_lock are done with interrupts
> disabled. And we have:
> 
> register_console()
>   logbuf_lock_irqsave()
>     raw_spin_lock(&syslog_lock)

I see. We should revisit this after removing logbuf_lock and
printk_safe context.

> Looking back through history, I found that locking of the "console lock"
> in register_console() was changed from spin_lock_irq() to
> spin_lock_irqsave() for 2.3.15pre1 [0]. The only reason I can find why
> that was done is because sparc64 was regstering its console in a PROM
> callback (the comments there: "Pretty sick eh?").

Note that console_lock was a spinlock in 2.3.15.pre1. I see it defined
in kernel/printk.c as:

spinlock_t console_lock = SPIN_LOCK_UNLOCKED;

But it is a sleeping semaphore these days. As a result,
register_console(), as it is now, must not be called in an interrupt context.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ