From patchwork Sat May 27 03:21:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13257532 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 EA074C77B73 for ; Sat, 27 May 2023 03:04:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40B26900002; Fri, 26 May 2023 23:04:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B9F26B0072; Fri, 26 May 2023 23:04:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A89E900002; Fri, 26 May 2023 23:04:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1CFCD6B0071 for ; Fri, 26 May 2023 23:04:57 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D0217C0F9F for ; Sat, 27 May 2023 03:04:56 +0000 (UTC) X-FDA: 80834542992.07.0A996E5 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf29.hostedemail.com (Postfix) with ESMTP id 8D6B4120010 for ; Sat, 27 May 2023 03:04:53 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685156695; 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=RrS+O/65GbPo9Tl2Wk3nUjuT5ML9Wnv1zcK2al4GoVA=; b=AHNXeUtUbk0h0Ft/dBobih5ZtoNXEe+dhiIDp7HbbIqpGeLIexLDej4kYaQNQsPzudlQmV lGe5z55IVobQJVlP/gYj8sUmUsSKS/3iYfsWJIRY7JQ4MHh3fywbNgvm5DX6f+FwThe63T H4lzWk2LRucIdGD4vHj6K6lTi0lya8w= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=none; spf=pass (imf29.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685156695; a=rsa-sha256; cv=none; b=zNFylzRX7VQHavj1Hl2Z5FXg9KrdL/Fz7losFY+djg1H4/+vJfG+Q1htFlT2vOemS6l6DG fXUNprUlUSXI2J4DSnAjPI9Uk9SesskjnfWE8PvtsJuMlEaYwr8MpADPcvuo6Zcanma9lC zAZ5i9dPM72xu3xaSUb2px0CSpQvXBA= Received: from dggpemm500001.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4QSmlw1WkrzLnb3; Sat, 27 May 2023 11:01:48 +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 11:04:45 +0800 From: Kefeng Wang To: SeongJae Park , Andrew Morton , , CC: , Kefeng Wang , , Subject: [PATCH v2] mm/damon/core: fix divide error in damon_nr_accesses_to_accesses_bp() Date: Sat, 27 May 2023 11:21:01 +0800 Message-ID: <20230527032101.167788-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: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 8D6B4120010 X-Rspam-User: X-Stat-Signature: yu9g5pwty8hjzr3oudxpsfpo4qw9cxtm X-Rspamd-Server: rspam01 X-HE-Tag: 1685156693-539698 X-HE-Meta: U2FsdGVkX18Uvp4gpehfnJ8YIxVS6QVkMnrtnnETe2X5+bekaXgxxJCy6QgpvMgO7+BkPhjr/rYPJINj34ByiWjXNJT65qtIEJEOap48LclLeg/R6IzOnZrgzvQyit6wIu9dLtdu8O/6i5ZAJ0ZNrVbyITk/FeV2F0kJdbj+nEEuSrjmbNn1wPutvwjSyo6SNCwZqiU+z0JBJHHeoWCtiGrCtHDXqUOKYfhsdHOUYGqe+9uP4efT8+KQDc+UMsEDjhR8oYIkaSYXYBsa4zZRTsZ1xhtW2gvApd1sUQUDsDmLv+WKvvOnaw498zOrPyLNe/zJrDi+axYZn3U9R3gvQWJCPO/8/D3xi6rvMOf+ACqOA/5wwfSvqj/Qtzj/RlXOqD2u/TM8YV7p3rbggL29ADG11GYog3Le9Rl1ClXGVijAEs+O6fheITcdvV4+FvGD8ITKQjqAwo2WWJYMyzCk7LbHGvkDrvCs6qQVdSgS2zz+UvnfqtxL7K+Ih+PSkaqeEdoFMoRTidRqnOTKJdVaW0ShfTVYA2Omd9OulLaTVApMf61a9Ked7IxvsaPzjoUHJeIorWLdl4Nz1H5QheEpp68Te/TeoI3EfZoIipRsWkqP/9CU6EEgwcEs2x23x9e48r0zQAfzZaKlqS3lOZyHrih13WKjSCznXv3k/HOmGJ8OuIULE3d3hihS4FigeickhkgNsIkvvUujKRHyRjWXNGYDZDpnoFpPFqE6xU6smy5uWMoqUOJ0lo2l6QRsPTSp+hqnE8XYzM1Ssu+PMIYcsIiIlTN/Skmy92rfYhadSaepoL+T7TLvzTu4jwLyTs9WHOz8H3Wlj6Dp+a+rE/3TfOwsQLIpE1xPSaW0b0+uMNASoEnP3caJFrPvFDlndXy3NF08YuMtlxYUhRTUuWoVtLnBUCrLbuOOUPv1Mvekbwe5wB5DWy5MADS83VOQXw7lotf4LdLuDriD8/MKoJC 4kRarKLm J+t7MMEwnbcbyx65/zXXK94cnTPyOJNHSVR+XefJgUF/Hrv7lRxqYdr3CxkTbaj4uKLsSuIe0Pt02UpPJT6gzHVAOl7tCD2XbxRGJZElaUyJwP1rm3FfXWjYIjLxSqbn2hweYevQJGhGX04X7zY0iQKVQJBg4I8LML0mBEteuw3XOrpiUyFPiWb98XNRaDufiCByZLITrxD1dJ9shlcjzMJF+bYg3FZdwxCdFkQOU9szJ/OmGySecfW95ODSDC8nvrYnuUS6TAbiAl4cc3hxWu6PurKIfEq4t5Zrec3ItkJatJ0S8B+gcDotC+EF7n8cY1QZFhQKqbwArkAnIqezSTMyFf/rVfOX9SCyLmW0gisLtLt/DbdYqzRMAgWYOshbhrEqllgRhHNuuDn5OE3GODTxb87d5J8yqkqn2Eejp1kBK/J1zfnVWr2UvUq7ZfOhsVM/pyyW9GDn9NCAoL+SL2BBFrGYzpQ2eYsNwr7Wglze/59Q= 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 in damon_nr_accesses_to_accesses_bp() becomes zero which leads to divide error, 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 Closes: https://syzkaller.appspot.com/bug?extid=841a46899768ec7bec67 Link: https://lore.kernel.org/damon/00000000000055fc4e05fc975bc2@google.com/ Fixes: 2f5bef5a590b ("mm/damon/core: update monitoring results for new monitoring attributes") Cc: # 6.3.x- Reviewed-by: SeongJae Park Signed-off-by: Kefeng Wang --- v2: close checkpatch warning, add RB/cc stable, per SJ 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;