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: 99751 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp98304vqr; Fri, 26 May 2023 20:04:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/UuCGaSRcpoxzJFo7AC2DjUmQLOkhvV17vrj1Tk4SQUfH/M++DVyuGA3FnJDgDI4vVvOl X-Received: by 2002:a05:6a20:8421:b0:10c:74e:92bf with SMTP id c33-20020a056a20842100b0010c074e92bfmr1931084pzd.10.1685156687542; Fri, 26 May 2023 20:04:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685156687; cv=none; d=google.com; s=arc-20160816; b=fbjd46DLAJEfyGz5jnlaaPfIPy9VACZYP40mZ+D+SLoTTcriD6ktRs6V50UzI1vecK egpy0b4oLNlaiH7aGWS/DOBGOR45I0aSVv5ht5kLd7oPhkutRG0nk7/hrHY8i5e08rt/ GQILJddeMzy7e7PTYgDI9XTwD4oMZwpsP9rRGpaUiZ3tuKwuS5prmqRUSV21AGRwTaOU bK56N26p4ZX1/wUvWfAgAbjOfuNjPqGVdppsSX7fUx+H+X8LcQfhE+bj9T6U8imzcTji Bi+QzElIPV75hRpou7+mBDgeoBTPgRNKkEjkOStFraGg33NGKXXNyot0yAC7Pmye5qpy sWuQ== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv7-20020a632e07000000b0053f25281d14si2255738pgb.546.2023.05.26.20.04.24; Fri, 26 May 2023 20:04:47 -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 S231313AbjE0CRf (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767013525155947644?= X-GMAIL-MSGID: =?utf-8?q?1767014858939510698?= 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;