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=unavailable 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 71338C48BE5 for ; Tue, 15 Jun 2021 09:36:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CA8B61440 for ; Tue, 15 Jun 2021 09:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbhFOJiG (ORCPT ); Tue, 15 Jun 2021 05:38:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:56326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231262AbhFOJiD (ORCPT ); Tue, 15 Jun 2021 05:38:03 -0400 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) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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