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] [day] [month] [year] [list]
Message-ID: <87lear2i8w.fsf@jogness.linutronix.de>
Date:   Tue, 21 Nov 2023 17:23:35 +0106
From:   John Ogness <john.ogness@...utronix.de>
To:     Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:     Petr Mladek <pmladek@...e.com>,
        Sergey Senozhatsky <senozhatsky@...omium.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org, Mukesh Ojha <quic_mojha@...cinc.com>
Subject: Re: [PATCH printk v2 1/9] printk: ringbuffer: Do not skip
 non-finalized records with prb_next_seq()

On 2023-11-20, Sebastian Andrzej Siewior <bigeasy@...utronix.de> wrote:
> based on my research this should be the most recent post of this patch.
> If so then
>
> On 2023-11-06 22:13:22 [+0106], John Ogness wrote:
>> --- a/kernel/printk/printk_ringbuffer.c
>> +++ b/kernel/printk/printk_ringbuffer.c
>> +	/*
>> +	 * The provided sequence is only the lower 32 bits of the ringbuffer
>> +	 * sequence. It needs to be expanded to 64bit. Get the first sequence
>> +	 * number from the ringbuffer and fold it.
>> +	 */
>> +	seq = rb_first_seq - ((u32)rb_first_seq - ulseq);
>
> This needs to become
> 	seq = rb_first_seq - ((s32)((u32)rb_first_seq - ulseq));
>
> in order to continue booting on 32bit.

Indeed. The code assumes the passed in value (@ulseq) always represents
a 64-bit number that is less than or equal to the basis value
(@rb_first_seq). For kernel/printk/nbcon.c:__nbcon_seq_to_seq() that
assumption is correct. For this function, it is not.

Your change will round up or down to the nearest 32 bits of the basis
value.

For example, with @rb_first_seq = 0x200000000 and @ulseq = 0x1:

before your change (where @ulseq cannot represent something higher than
@rb_first_seq):

    @ulseq translates to 0x100000001

after your change:

    @ulseq translates to 0x200000001

Since __ulseq_to_u64seq() must deal with arbitrary values, I think the
32-bit rounding is appropriate.

Despite not strictly being necessary (because of the valid assumption),
I think we should also update __nbcon_seq_to_seq() to avoid any bizarre
cases due to different translations of the 32-bit value.

In fact, there is no reason to have 2 macros for this. I will create a
single macro using the 32-bit rounding.

Thanks for researching this!

John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ