public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Kuan-Wei Chiu <visitorckw@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Ching-Chun Huang <jserv@ccns.ncku.edu.tw>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX
Date: Tue, 1 Oct 2024 13:27:03 +0200	[thread overview]
Message-ID: <Zvvch303oFPCZnJ-@pathway.suse.cz> (raw)
In-Reply-To: <20240928113608.1438087-1-visitorckw@gmail.com>

On Sat 2024-09-28 19:36:08, Kuan-Wei Chiu wrote:
> Shifting 1 << 31 on a 32-bit int causes signed integer overflow, which
> leads to undefined behavior. To prevent this, cast 1 to u32 before
> performing the shift, ensuring well-defined behavior.
> 
> This change explicitly avoids any potential overflow by ensuring that
> the shift occurs on an unsigned 32-bit integer.
> 
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>

Looks good to me.

Acked-by: Petr Mladek <pmladek@suse.com>

Best Regards,
Petr

  reply	other threads:[~2024-10-01 11:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-28 11:36 [PATCH] printk: Fix signed integer overflow when defining LOG_BUF_LEN_MAX Kuan-Wei Chiu
2024-10-01 11:27 ` Petr Mladek [this message]
2024-11-07 12:42   ` Kuan-Wei Chiu
2024-12-12 11:33 ` Petr Mladek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zvvch303oFPCZnJ-@pathway.suse.cz \
    --to=pmladek@suse.com \
    --cc=john.ogness@linutronix.de \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.org \
    --cc=visitorckw@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox