[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aLW1GEpKXVLo1Oue@visitorckw-System-Product-Name>
Date: Mon, 1 Sep 2025 23:00:40 +0800
From: Kuan-Wei Chiu <visitorckw@...il.com>
To: rafael@...nel.org, daniel.lezcano@...aro.org
Cc: rui.zhang@...el.com, lukasz.luba@....com, jacob.jun.pan@...ux.intel.com,
jserv@...s.ncku.edu.tw, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] tmon: Fix undefined behavior in left shift
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'
>
I forgot to mention in the commit message that the UBSAN report was
triggered when running sudo ./tmon -l. Let me know if you'd like me
to include that detail, and I can update and resend as v2.
Regards,
Kuan-Wei
Powered by blists - more mailing lists