linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Ravi Singh <ravi.singh1@samsung.com>
Cc: hannes@cmpxchg.org, mingo@redhat.com,
	linux-kernel@vger.kernel.org, a.sahrawat@samsung.com,
	v.narang@samsung.com, vishal.goel@samsung.com
Subject: Re: [PATCH] psi: fix integer overflow on unsigned int multiply on 32 bit systems
Date: Fri, 10 Sep 2021 17:33:15 +0200	[thread overview]
Message-ID: <20210910153315.GG4323@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <1630931124-27197-1-git-send-email-ravi.singh1@samsung.com>

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@samsung.com>
> Signed-off-by: Vishal Goel <vishal.goel@samsung.com>

That's not a valid SoB chain.

  parent reply	other threads:[~2021-09-10 15:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210906122653epcas5p19c46576f0be4d4a101f851a751addde8@epcas5p1.samsung.com>
2021-09-06 12:25 ` [PATCH] psi: fix integer overflow on unsigned int multiply on 32 bit systems Ravi Singh
2021-09-08 11:32   ` Johannes Weiner
2021-09-10 15:33   ` Peter Zijlstra [this message]
     [not found] <CGME20210913085226epcas5p2b516f0f591926c927faa9c60d211bf44@epcas5p2.samsung.com>
2021-09-13  8:51 ` Ravi Singh
2021-11-04 16:55   ` Johannes Weiner
2021-11-04 23:11     ` Suren Baghdasaryan

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=20210910153315.GG4323@worktop.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=a.sahrawat@samsung.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=ravi.singh1@samsung.com \
    --cc=v.narang@samsung.com \
    --cc=vishal.goel@samsung.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;
as well as URLs for NNTP newsgroup(s).