From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H . Peter Anvin" <hpa@zytor.com>
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86/lib: Fix overflow of variable m when val >= 1410065408
Date: Thu, 2 Nov 2023 17:25:29 +0000 [thread overview]
Message-ID: <b8183f5e-7c4f-48c1-8130-54b77e55349d@gmail.com> (raw)
In-Reply-To: <203cf76c-3855-408c-9a7c-8ff3f74a88bd@intel.com>
On 02/11/2023 16:38, Dave Hansen wrote:
> On 11/1/23 08:32, Colin Ian King wrote:
> ...
>> int num_digits(int val)
>> {
>> - int m = 10;
>> + long m = 10;
>> int d = 1;
>>
>> if (val < 0) {
>
> Isn't this still broken on 32-bit where sizeof(long) == sizeof(int)?
> Seems like we need 'm' to be able to hold values that are ~10x larger
> than 'val' if we need this to work for the entire int range.
Good point, long long is required for 32 bit,
sizes:
arch int long long long
i386 4 4 8
x86_64 4 8 8
I'll send a V2.
>
> Also, performance doesn't matter here at *all* with the current use in
> a couple of printk()'s. Just making 'm' 'long long' or u64 probably be
> just fine.
prev parent reply other threads:[~2023-11-02 17:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-01 15:32 Colin Ian King
2023-11-01 23:50 ` Randy Dunlap
2023-11-02 16:38 ` Dave Hansen
2023-11-02 17:25 ` Colin King (gmail) [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=b8183f5e-7c4f-48c1-8130-54b77e55349d@gmail.com \
--to=colin.i.king@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®