From patchwork Sat May 27 02:33:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13257530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77832C77B73 for ; Sat, 27 May 2023 02:17:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA2256B0071; Fri, 26 May 2023 22:17:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E52D1900002; Fri, 26 May 2023 22:17:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D418D6B0074; Fri, 26 May 2023 22:17:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C51E76B0071 for ; Fri, 26 May 2023 22:17:37 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 96C7BA0EE3 for ; Sat, 27 May 2023 02:17:37 +0000 (UTC) X-FDA: 80834423754.20.A3DF3D0 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf02.hostedemail.com (Postfix) with ESMTP id 2D1FA8000F for ; Sat, 27 May 2023 02:17:34 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685153855; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=6VAWdDDLEZqtfYLMOaEBub90V0y1H/F+BoLqziZFuRE=; b=gVQ55cCb40divOFqAnXv0XEGYzYnrSkblW/4QB/ZkLn85imgMWdWeCmgUpPjAAUvKb2pTs 6jY2kokoJgAfzNRWSDBISs64YDOTljpmyxO90n8PZ4ByjFMmjvPe4ngi8RExm/mq1d9DNU hThN/GlMNdFiY3QerRP3WB5OMejmmQI= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf02.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685153855; a=rsa-sha256; cv=none; b=ZQruu76DGbTJhDBAhzIGVqcihBdt5gbDaI+0rXrqlTXWGE4itLU04dTy2wCe3f/9VtiQTN cfvGP9s/rPDvlx4uyB1Y7GZaK7WphZ4pmiaBwY3DlIrzTovnghtQmPjIvY/0APnwFAQdbp 4nVPpGtoTuTURbuuDP3a4UmV6NY1aIg= 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 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-Rspam-User: X-Stat-Signature: kmh1m3oey8x49hussjg4idp9ox9sxjwo X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2D1FA8000F X-HE-Tag: 1685153854-822955 X-HE-Meta: U2FsdGVkX18rzQ0u6LqTVJPVax8YZMiL4ycDA5LhqrR9IwPCa0mzqsY3PxPjdBUUvuU5znx7kFA0lF9kMKqEBpVqqEJ5WfHl+trY+MXKSDsfNQhrBhRwX1ZIZ4PI8WNB94aEf/WR1/l0Z+Ot4/pGexYXW7fHxFoCff5xRarFkPK0XrP7U9KAmbU+eUYUmsVzIR8zA77nrrwdfEsnwSVw4a7IBDQwN9opcVkoGl8kqfjveHYqWnX0KcOmSmDZ74bweiJJ7PVMS9LRCbbLkGaxy8hyPHAw06TRJebT9mAMWUxh6Un1PgOWg8SbM7un+4zv3rhSvjSccGA9szQA+zV4YRFydSlP0uDYuEX2pdCBILmW9BuaOIMhwEJaEQE1tMFUIUqCCvbcgL81nmKzwi0XF1uWXC/HcOOuCg0qFNvwPdxhr4zq7e/PrmVhYegKf5nNkrfeENiw7WKdZMpl3xq7+n3L8mkaZORSpIDMdZ2LEiWEfPokmOsTRmKGPYeWzoxtIj8HTVrqwcsKvBqGwd4YhLqXrCfrQEchpUhYEH8VbW22adcekr46e4ES6QgsN4GZZKUL5WL5QwVN9yLA3Onx1gw+tu7rwtyjKf6uYyUF/ftjhecf+4OhHFBEvJcpRv7ElCNLnqLD3vkwTLnaZZByEN6lYl8tXOhV2F7vspdRojS+wYt5m6Iz9KyE5NeGNkReANJGHYkQ/sbVR04mHk15e8oqgYc+F1rJAF9CseA7Mbh27tvq8v+rxItw0PGrYwRJA+hHKEcwXQJe1sOauGNnS/nHo7/C3ak8QTjzvoGouyCASmsvI9hLx/XzS6pd8asbW4Q1Xv2Eb+s+YpdRfwbnouoyUOwSX0itvzEgqW6aNJByRcQYTcpp2iPTfi4IaXZDc1uNo0vpQkiwJRz0hQ0QYuDIMobQ6dGq8soODIZ8TrnaHC2JmYuZaRFVIkJzaITUoMyBKtzfLxEIWWgLKcq JZq1zDar oqydgzne5LJNe97jr1oZHwhRM0rVZhIsE/Ti+rhvpf3oDppx8BGufwFJ/vgPL9/MScTLnirWN5W8JPE3E91kiwcWJ4Mn1uA8NaEz8RHvg4AM+0/tEjyoYTcvMRURDHeyNYhHoY4/lx0jms19FieCHFLwzZnukwDMPF6ku0E6nJM9HswDPjUzHlyXuXUmkzXtv+bjs9pQtBfZVcxxYG6yzoO+lmusetRybTV7rNP11uF9m7gExkh2R2Zk3blxA4yNJCbhLgUGGHAzZVeM/4ai4IZmOuGqnRd5k0RVx74TS8NkOTx55UVeTcP2FiE76WdyZTz59BqlZAPK+PLUuxZWUTTLJ99Ie1tPSsxRycYxzU9rQyvU= 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: 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 Reported-by: syzbot+841a46899768ec7bec67@syzkaller.appspotmail.com Reviewed-by: SeongJae Park --- 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;