Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp298658rwd; Fri, 26 May 2023 20:16:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wp2nFMRgRRL1r97m5EdOMmi7AU55NP1EadAJSA3GOeDNHXcup3rRGbj6UdiBd0hiCtjD4 X-Received: by 2002:a17:902:d485:b0:1ab:160c:526d with SMTP id c5-20020a170902d48500b001ab160c526dmr4566198plg.22.1685157406834; Fri, 26 May 2023 20:16:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685157406; cv=none; d=google.com; s=arc-20160816; b=GwxSkKfZFqUYTmD7uy3dxtGP3gxiNK6u2Kpjodpuu/uWoJ5WOa9Qz4OX0wOih2vFKe 6dGqk3rupGbti7gBO7qGBzy11BIAI78yNyDBQQ1K6xBx3hHuwwkVDffRb1fe4hbtS2Xw 3V2t6kQruTtPissj8rAbZcOCW3IoSHkS79Ja14BRIdIJzMyKeyKpCAuAB8ZASnHyyltX E1/U0h3LSRSzku12ATHCDb4+oJJWeqFHWgUS41m69TdCofa2KvF7/HTPj0Lf7b6YbP+q SyDnunJbR0JMk6fKY27jFSsupAdgar0DXVeiTsvnRb1EDdpdoZyzaWmecflXnieqtE7y sLwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=6VAWdDDLEZqtfYLMOaEBub90V0y1H/F+BoLqziZFuRE=; b=jXQH29julD0fYnuQPoDYiteprlfr+jkyRJQojsGI79sKkUJvd6CPH5WAXNqIDtaCvd QjY37IjH7tNIxJffBAYpjj+pNoCAKa+yceLcbGPEOJFvVO1WNepVxUVxt9pA8MgbeX26 0xC4bgKmvBp5fyKCaW8bGHio+MG4wL84H4PdyZ/3+aSBDUDH0fcSwhn1X4xI/A6TFrNa cGPesnRxEJP7EPEi+ny4G/7LWBp7+gGfezfYTa9dX30z7F6VvETIirqaogvqHX8rbxWX axBz3erQ7Tx/F+Z4Z75C2ZslJe2h/UVrEj6l4lVI3ktZDwM8RDdGwq1FIqAnP+N1CzZ4 p5kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u9-20020a17090341c900b001ae8c22791asi1718971ple.477.2023.05.26.20.16.32; Fri, 26 May 2023 20:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbjE0CRf (ORCPT + 99 others); Fri, 26 May 2023 22:17:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbjE0CRe (ORCPT ); Fri, 26 May 2023 22:17:34 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFFE112A for ; Fri, 26 May 2023 19:17:32 -0700 (PDT) Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4QSlgZ4f5Rz18KDL; Sat, 27 May 2023 10:12:58 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sat, 27 May 2023 10:17:31 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton , , CC: , Kefeng Wang , Subject: [PATCH] mm/damon/core: fix divide error in damon_nr_accesses_to_accesses_bp() Date: Sat, 27 May 2023 10:33:30 +0800 Message-ID: <20230527023330.23535-1-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If 'aggr_interval' is smaller than 'sample_interval', max_nr_accesses becomes zero which leads to divide error in damon_nr_accesses_to_accesses_bp(), let's validate the values of them in damon_set_attrs() to fix it, which similar to others attrs check. Reported-by: syzbot+841a46899768ec7bec67@syzkaller.appspotmail.com Fixes: 2f5bef5a590b ("mm/damon/core: update monitoring results for new monitoring attributes") Signed-off-by: Kefeng Wang --- mm/damon/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/damon/core.c b/mm/damon/core.c index d9ef62047bf5..91cff7f2997e 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -551,6 +551,8 @@ int damon_set_attrs(struct damon_ctx *ctx, struct damon_attrs *attrs) return -EINVAL; if (attrs->min_nr_regions > attrs->max_nr_regions) return -EINVAL; + if (attrs->sample_interval > attrs->aggr_interval) + return -EINVAL; damon_update_monitoring_results(ctx, attrs); ctx->attrs = *attrs; -- 2.35.3