From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C238C48BE8 for ; Tue, 15 Jun 2021 09:36:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 470FA61440 for ; Tue, 15 Jun 2021 09:36:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 470FA61440 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D5DDB6B0036; Tue, 15 Jun 2021 05:36:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D0D466B006E; Tue, 15 Jun 2021 05:36:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFC526B0071; Tue, 15 Jun 2021 05:36:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0216.hostedemail.com [216.40.44.216]) by kanga.kvack.org (Postfix) with ESMTP id 8D4316B0036 for ; Tue, 15 Jun 2021 05:36:01 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 29D7A181AEF09 for ; Tue, 15 Jun 2021 09:36:01 +0000 (UTC) X-FDA: 78255451722.01.63E74E5 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf09.hostedemail.com (Postfix) with ESMTP id 81D906000140 for ; Tue, 15 Jun 2021 09:35:55 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 07A2B613F1; Tue, 15 Jun 2021 09:35:58 +0000 (UTC) Date: Tue, 15 Jun 2021 10:35:56 +0100 From: Catalin Marinas To: Yanfei Xu Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/kmemleak: fix the possible wrong memory scanning period Message-ID: <20210615093555.GA26027@arm.com> References: <20210613174022.23044-1-yanfei.xu@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210613174022.23044-1-yanfei.xu@windriver.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 81D906000140 Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none); spf=pass (imf09.hostedemail.com: domain of cmarinas@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=cmarinas@kernel.org X-Stat-Signature: f3yrwcm3atibwzqdokdricueeuehnoce X-HE-Tag: 1623749755-468560 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Jun 14, 2021 at 01:40:22AM +0800, Yanfei Xu wrote: > This commit contains 3 modifies: > > 1.Convert the type of jiffies_scan_wait to "unsigned long". > > 2.Use READ/WRITE_ONCE() for accessing "jiffies_scan_wait". > > 3.Fix the possible wrong memory scanning period. If you set a large > memory scanning period like blow, then the "secs" variable will be > non-zero, however the value of "jiffies_scan_wait" will be zero. > > echo "scan=0x10000000" > /sys/kernel/debug/kmemleak > > It is because the type of the msecs_to_jiffies()'s parameter is > "unsigned int", and the "secs * 1000" is larger than its max value. > This in turn leads a unexpected jiffies_scan_wait, maybe zero. We > corret it by replacing kstrtoul() with kstrtouint(), and check the > msecs to prevent it larger than UINT_MAX. > > Signed-off-by: Yanfei Xu Acked-by: Catalin Marinas