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]
Date:   Wed, 7 Jul 2021 14:26:02 +0200
From:   Petr Mladek <pmladek@...e.com>
To:     John Ogness <john.ogness@...utronix.de>
Cc:     Sergey Senozhatsky <senozhatsky@...omium.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, kernel test robot <lkp@...el.com>,
        stable@...r.kernel.org
Subject: Re: [PATCH v2] printk/console: Check consistent sequence number when
 handling race in console_unlock()

On Sat 2021-07-03 08:32:02, John Ogness wrote:
> On 2021-07-02, Petr Mladek <pmladek@...e.com> wrote:
> > The standard printk() tries to flush the message to the console
> > immediately. It tries to take the console lock. If the lock is
> > already taken then the current owner is responsible for flushing
> > even the new message.
> >
> > There is a small race window between checking whether a new message is
> > available and releasing the console lock. It is solved by re-checking
> > the state after releasing the console lock. If the check is positive
> > then console_unlock() tries to take the lock again and process the new
> > message as well.
> >
> > The commit 996e966640ddea7b535c ("printk: remove logbuf_lock") causes that
> > console_seq is not longer read atomically. As a result, the re-check might
> > be done with an inconsistent 64-bit index.
> >
> > Solve it by using the last sequence number that has been checked under
> > the console lock. In the worst case, it will take the lock again only
> > to realized that the new message has already been proceed. But it
> > was possible even before.
> >
> > The variable next_seq is marked as __maybe_unused to call down compiler
> > warning when CONFIG_PRINTK is not defined.
> 
> As Sergey already pointed out, this patch is not fixing a real
> problem. An inconsistent value (or an increased consistent value) would
> mean that another printer is actively printing, and thus a retry is not
> necessary anyway.

Ah, I misunderstood that part. You are right. CPU_X might see wrong
console_seq only when CPU_Y incremented console_seq. If CPU_X does not do
retry because of racy console_seq. Then CPU_Y would do retry when
yet another CPU added yet another new message in the meantime.

> But this patch will avoid a KASAN message about an unmarked
> (although safe) data race.

Yup.

OK, I am going to queue the patch for-5.15. There is no need to
rush it for-4.14.

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ