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: 99755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp107034vqr; Fri, 26 May 2023 20:31:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4f+bByRTZfh8NH1m3hIj0mp6jnLFunMlFjZDiDXXTzO/Z+IYqzdOO0g3wnvYd/Uf5n/fH0 X-Received: by 2002:a05:6a00:1250:b0:64c:9b56:6215 with SMTP id u16-20020a056a00125000b0064c9b566215mr6137142pfi.25.1685158263332; Fri, 26 May 2023 20:31:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685158263; cv=none; d=google.com; s=arc-20160816; b=Pnl0w36ge5Ut16yd1XaCTPD6govbhVcDal4Dcn+0kOS58DmBQfbPI1A/vCIoMKKZNn 5lD3TKk7DmWNUv+A48Sf315jL+0/AiZgFygDk7W0p89feqNo3EN9ZAYGQQRii/BY7unZ 74ajFRZtJ9aMZCksh61S3mPnegK0XcmrVOWZYnS5ka/FWJr97BO1PfFv/rK1lxGx91Xl uASlSKPXsmKlE7PYSjuIFwGFqIYxtAoHajgIPyxQBNVIFCOBlWT3ZjuioEvFMfZ8Xp/2 ctqv1gEO7S2FX6lVeS922Cd5Vg/g73i95obNbTRUh4kSfnKQywoI0StGStYn50Ill+JE 6Fuw== 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=RrS+O/65GbPo9Tl2Wk3nUjuT5ML9Wnv1zcK2al4GoVA=; b=DJgD7cn0QYVy1JZ9izyf7qJv23eI1/hcvtli0e8G9jWJWaGBIpSt199P1kC/NZLisF e/+SIs+mFYzLZ9MZjBplSi0Ztt75hihusJiM+Tz0LRRK8qqM4h04dvmO+Xa5/XYjsOEl jrYuSVUcFMEwGXeKhzmtG17HeWCECWmfmo+NwSFvhO18lzTWXPM6IT3VdtahFhdXnbtG DNXlQRdxwo/GVfV2kzpkSPvg3LFjUiIAZ30ywKSgq+N1WiuR6/5WP0Vd5CNJl6bclvPD fLAVClxkBxBcrU9DgSFCHrcwNpcuojbEt+4dyEtyE5Fxfz0D92DLpzzEZvgVFXVQtAnV Eyrw== 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 i9-20020aa796e9000000b0064cecf7b983si5421531pfq.143.2023.05.26.20.30.31; Fri, 26 May 2023 20:31:03 -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 S230271AbjE0DEw (ORCPT + 99 others); Fri, 26 May 2023 23:04:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229691AbjE0DEu (ORCPT ); Fri, 26 May 2023 23:04:50 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2482ED9; Fri, 26 May 2023 20:04:47 -0700 (PDT) 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-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?1767016511108824067?= X-GMAIL-MSGID: =?utf-8?q?1767016511108824067?= 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;