[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210910153315.GG4323@worktop.programming.kicks-ass.net>
Date: Fri, 10 Sep 2021 17:33:15 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Ravi Singh <ravi.singh1@...sung.com>
Cc: hannes@...xchg.org, mingo@...hat.com, linux-kernel@...r.kernel.org,
a.sahrawat@...sung.com, v.narang@...sung.com,
vishal.goel@...sung.com
Subject: Re: [PATCH] psi: fix integer overflow on unsigned int multiply on 32
bit systems
On Mon, Sep 06, 2021 at 05:55:24PM +0530, Ravi Singh wrote:
> psi accepts window sizes upto WINDOW_MAX_US(10000000). In the case
> where window_us is larger than 4294967, the result of an
> multiplication overflows an unsigned int/long(4 bytes on 32 bit
> system).
>
> For example, this can happen when the window_us is 5000000 so 5000000
> * 1000 (NSEC_PER_USEC) will result in 5000000000 which is greater than
> UINT_MAX(4294967295). Due to this overflow, 705032704 is stored in
> t->win.size instead of 5000000000. Now psi will be monitoring the
> window size of 705 msecs instead of 5 secs as expected by user.
>
> Fix this by type casting the first term of the mutiply to a u64.
>
> Issue doesnot occur on 64 bit systems because NSEC_PER_USEC is of type
> long which is 8 bytes on 64 bit systems.
>
> Signed-off-by: Ravi Singh <ravi.singh1@...sung.com>
> Signed-off-by: Vishal Goel <vishal.goel@...sung.com>
That's not a valid SoB chain.
Powered by blists - more mailing lists