Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1562026pxb; Fri, 10 Sep 2021 08:35:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ2+uZomuD7J+BQ/Z0ftltDyAJWd6nB5uHuMfY8XRMmWiVOXq8A8NV2aOqmFU/k2U7by6L X-Received: by 2002:a05:6e02:1846:: with SMTP id b6mr6541171ilv.264.1631288120975; Fri, 10 Sep 2021 08:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631288120; cv=none; d=google.com; s=arc-20160816; b=qioeenS93TYUaJsZz0JCy6bGLBiIurXOJ/D0izsiBHvnfxtsaHVONo1sxnFglL1iTG IUblezNyIg9ZSMhzKg+nQPanHzk/xwvWX5PRWyHimQ/8/4q2wpssN2lQDQYYp1+2oCXn lxwLpb6dTkOcVGeiCRZO9VO0KIf36EwWPZujkJ731sKL62CTjXuzfzfmOXBMDqUXvdV3 rsEOwMhK4Mzaw4QoldmPmopG9f2eTVwt7XIXCjx2YL7qXlltz9ihSboYVBbm8Ljmgvmh TrHhsJJ07lp25OgUQ5zTksPO8JgdvOKGZXm3Zn2ZWgw0lE1hqf3SRndBPPT1H6X8xzMc kIYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oaN7qY6S4Isxzy4JLgqhBnxwl4cPBYd1rT3odrvAhkE=; b=sT4Bth0uV6Y6O4dv5yKCZ0R38VSMgujZbtPOX1cR8o00AlD7CQf/3zhlM7BJDIa/KH K0JKWPzd49IHmsNAeOBAZ57iT7ZQNSAildzdlyRd2pfLHzHeXgnAv+LDg24m1LuSPePN PmGf33KezNUSXVv48zQEAa39dXwh8fDN/wv3jSNZPpuBI7buseX0q9007riwB77N0ScJ 68+Y7OI3AarqvndqsaXojYmSjpBw3hG991E2gNsAyyvT+Aes1NkcGyc2yW2XTMuRX9UQ hrQfriqyDAHgvyWtpXroAEOw7wNKnf5abXIwwK7K191A+aZTXjvt5Sm+EFm0ED1X0aHR IjTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EYYEyWNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si5303755jak.129.2021.09.10.08.35.08; Fri, 10 Sep 2021 08:35:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EYYEyWNg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234449AbhIJPfd (ORCPT + 99 others); Fri, 10 Sep 2021 11:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232438AbhIJPfc (ORCPT ); Fri, 10 Sep 2021 11:35:32 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC638C061574 for ; Fri, 10 Sep 2021 08:34:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=oaN7qY6S4Isxzy4JLgqhBnxwl4cPBYd1rT3odrvAhkE=; b=EYYEyWNgiYgbFcjd+HEoEf0qsI E/NiSQdKohkj9lefBwKagRRodVIVjbSMhH/Nd6zTtsjGQZOkMHWdXIcF9ck8V8jjRO+Yyt7jATzA4 ygVPaWwXVkeJVAI6gnxHJlG47N4f2BE0H1H4RKMi198dkX99cj13uX4fsSQR75HonFXRXkIlDQZWZ xyAurHH5zFa9SsRrojeSBHz7uYQmuxjGaq6eRvvLrDZR1fL+9MG0NIDetC2wEtm5rw2y8Sqs9Z29a 6swk9LV78PuI9uDVmMgdavDAkkl7I2plJ1TKhMtyplS0gD0Bpfl/Hcg3KuNpNhboVYMs5ClmmZCIG dSfwqlXg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOiWi-00B7IE-HX; Fri, 10 Sep 2021 15:33:27 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id B735198627A; Fri, 10 Sep 2021 17:33:15 +0200 (CEST) Date: Fri, 10 Sep 2021 17:33:15 +0200 From: Peter Zijlstra To: Ravi Singh 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 Message-ID: <20210910153315.GG4323@worktop.programming.kicks-ass.net> References: <1630931124-27197-1-git-send-email-ravi.singh1@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1630931124-27197-1-git-send-email-ravi.singh1@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > Signed-off-by: Vishal Goel That's not a valid SoB chain.