Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3515599pxj; Tue, 15 Jun 2021 02:38:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAqYsNwYj20r0EuMSwVYTYhkPcde98OAmjRPnndZgQcOqF4RWRtj2lRrw9aZe5m7rWUfJR X-Received: by 2002:a05:6402:2317:: with SMTP id l23mr22289239eda.265.1623749887569; Tue, 15 Jun 2021 02:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623749887; cv=none; d=google.com; s=arc-20160816; b=k8/rJGllIoT19TNxskuW74DOGrVY29q60qiaz4Tiemh8J5UMEpiudJ3tvYhshlV5Yx dCUi10i0Ipm3LNA4OJHWTknbG/eKSbZdxjRS4TpMi1MgQMz63+H+2aSn5/8Sv7QGkrWd XbKebCfVOtfCLqmvM/qQoDXUyFAutSB1Gaa8YGW3qvseDcFP1u3ymyYmEKV7oJJqNhgn TWdcReurx4pl6L17WXUOi4MBHCQYfx3nD2SDM/T7pZjW2js3EpThC6BpMKLukd5gGT73 Sr4rjtsqBomZqx6JIRHuibvFANMQ1lM/Y1b044v9VL0AsWmLlWmUblJVxTT+NEKmmLw6 Na1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=v18LjlZay2QntUAvsYs9J89bVLgWC9mqZmtnVgdGahI=; b=XmbIO+WleWcEo7oZzjgNzYwLkLpxcaA/vmd30m7A1dCJOM42HwUVe/2xsEIKt0D+m7 mHZBi/J0X6tyXYQLF+8p4ApxNXNQyHZ0u+htmLgiLcy+M8mRXJYqybtLERYEa9Vq+3gI cCd+J6TfZV9LqgLO1OY7dDgpwvljEOk1Uw7SZdGVuEZ3XT+I+/7PYG9iOzFg/STxzxGO D9xIyXWhZ62rFTt8yuztDQigugppuz3jObLZWWBLxq4r+o6fqUeocn8r7DEENHyJQcEy UlIeNLe2/7sqhvWx9DHHak2QYVtXatjORGn7Vf/K+s1ANwYTy8qOmsU6A6/pCdC72uZv skfg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bo19si14069201edb.416.2021.06.15.02.37.45; Tue, 15 Jun 2021 02:38:07 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231500AbhFOJiG (ORCPT + 99 others); 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