From: Kuan-Wei Chiu <visitorckw@gmail.com>
To: rafael@kernel.org, daniel.lezcano@linaro.org
Cc: rui.zhang@intel.com, lukasz.luba@arm.com,
jacob.jun.pan@linux.intel.com, jserv@ccns.ncku.edu.tw,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tmon: Fix undefined behavior in left shift
Date: Wed, 29 Oct 2025 14:57:05 +0800 [thread overview]
Message-ID: <aQG6wTDy7Bnf4XDI@google.com> (raw)
In-Reply-To: <20250901144756.1179834-1-visitorckw@gmail.com>
On Mon, Sep 01, 2025 at 10:47:56PM +0800, Kuan-Wei Chiu wrote:
> Using 1 << j when j reaches 31 triggers undefined behavior because
> the constant 1 is of type int, and shifting it left by 31 exceeds
> the range of signed int. UBSAN reports:
>
> tmon.c:174:54: runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
>
> According to the C11 standard:
>
> "If E1 has a signed type and E1 x 2^E2 is not representable in the
> result type, the behavior is undefined."
>
> Fix this by using 1U << j, ensuring the shift is performed on an
> unsigned type where all 32 bits are representable.
>
> Fixes: 94f69966faf8 ("tools/thermal: Introduce tmon, a tool for thermal subsystem")
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
I know maintainers are busy people, so I usually try to avoid sending
ping messages. However, this patch was submitted about two months ago
and hasn't received any feedback yet. It looks like it might have
somehow got lost?
Regards,
Kuan-Wei
prev parent reply other threads:[~2025-10-29 6:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 14:47 [PATCH] tmon: Fix undefined behavior in left shift Kuan-Wei Chiu
2025-09-01 15:00 ` Kuan-Wei Chiu
2025-10-29 6:57 ` Kuan-Wei Chiu [this message]
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=aQG6wTDy7Bnf4XDI@google.com \
--to=visitorckw@gmail.com \
--cc=daniel.lezcano@linaro.org \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jserv@ccns.ncku.edu.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.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