Re: [syzbot] [damon?] divide error in damon_set_attrs

From: Kefeng Wang
Date: Fri May 26 2023 - 08:59:22 EST

On 2023/5/26 19:51, syzbot wrote:

syzbot found the following issue on:

HEAD commit: 44c026a73be8 Linux 6.4-rc3
git tree: upstream
console output:
kernel config:
dashboard link:
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2
userspace arch: i386

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image:
kernel image:

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+841a46899768ec7bec67@xxxxxxxxxxxxxxxxxxxxxxxxx

divide error: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 13527 Comm: syz-executor.1 Not tainted 6.4.0-rc3-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
RIP: 0010:damon_nr_accesses_to_accesses_bp mm/damon/core.c:491 [inline]
RIP: 0010:damon_nr_accesses_for_new_attrs mm/damon/core.c:497 [inline]
RIP: 0010:damon_update_monitoring_result mm/damon/core.c:506 [inline]
RIP: 0010:damon_update_monitoring_results mm/damon/core.c:534 [inline]
RIP: 0010:damon_set_attrs+0x224/0x460 mm/damon/core.c:555

make aggr_interval great than or equal sample_interval?

diff --git a/mm/damon/core.c b/mm/damon/core.c
index d9ef62047bf5..6fe1960f3d6b 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -525,8 +525,8 @@ static void damon_update_monitoring_results(struct damon_ctx *ctx,

/* if any interval is zero, simply forgive conversion */
if (!old_attrs->sample_interval || !old_attrs->aggr_interval ||
- !new_attrs->sample_interval ||
- !new_attrs->aggr_interval)
+ !new_attrs->sample_interval || !new_attrs->aggr_interval ||
+ new_attrs->aggr_interval < new_attrs->sample_interval)