Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp307421rwd; Fri, 26 May 2023 20:30:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Fr57uCPFhEwSngei9EAQRxZxZfsDPr+3PN4gKOrw/4gO23mSIm+iPRWSRVRJ5Ga4pNA+7 X-Received: by 2002:a05:6a00:1250:b0:64c:9b56:6215 with SMTP id u16-20020a056a00125000b0064c9b566215mr6136420pfi.25.1685158244939; Fri, 26 May 2023 20:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685158244; cv=none; d=google.com; s=arc-20160816; b=bsaLtddRKfWQFV8U/9ZQb5DQPqAHbypZw2APeU8SXkHtb7wG1tUgaRVqbo3quoqIms 5veIOmhtWEUH4HjEy9RZFcizDD/qL+39CUR1OLwQ/kajjnFm0Glq34PL5JJ7tsQj2jU1 jzPJAUQnAv8MMOGOTO67QHjXm5o+y0+hyKpGZ6PfzG9UX7rFKsofcZMpoKRZDzUm5A1L YDpjzQ+esLXNeBBGhsbjVLtitNNOMWhf1sYgfIcD0rgRUE8zMKvpwVKQhT1aGoS4sHBY no2lXpf27IAYM7TEv2qrdA6PnCEd12imsj6g9qyqBAirRegi+s+OT8xx7DftsNw0Y9ul WXsQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v10-20020a63f20a000000b005340840c0c7si5212097pgh.476.2023.05.26.20.30.30; Fri, 26 May 2023 20:30:44 -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 S231428AbjE0DEw (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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 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; -- 2.35.3