From: Liew Rui Yan <aethernet65535@gmail.com>
To: aethernet65535@gmail.com
Cc: damon@lists.linux.dev, linux-mm@kvack.org, sj@kernel.org
Subject: Re: (sashiko review) [PATCH] mm/damon: validate addr_unit to be power of 2
Date: Fri, 27 Mar 2026 16:11:31 +0800 [thread overview]
Message-ID: <20260327081131.80608-1-aethernet65535@gmail.com> (raw)
In-Reply-To: <20260327062627.66426-1-aethernet65535@gmail.com>
Forwarding Sashiko review for doing discussions via mails.
# review url: https://sashiko.dev/#/patchset/20260327062627.66426-1-aethernet65535@gmail.com
# start of sashiko.dev inline review
commit ceb9522e072d53117ff67157d6f0be7d35919759
Author: Liew Rui Yan <aethernet65535@gmail.com>
mm/damon: validate addr_unit to be power of 2
This commit adds a validation check in damon_commit_ctx() to ensure
addr_unit is a power of 2. This prevents kdamond from exiting
unexpectedly during parameter application when given invalid inputs.
Link: https://lore.kernel.org/20260325025317.86571-1-sj@kernel.org
> diff --git a/mm/damon/core.c b/mm/damon/core.c
> index db6c67e52d2b..6bad85a47a79 100644
> --- a/mm/damon/core.c
> +++ b/mm/damon/core.c
[ ... ]
> @@ -1330,6 +1330,8 @@ int damon_commit_ctx(struct damon_ctx *dst, struct damon_ctx *src)
> dst->maybe_corrupted = true;
> if (!is_power_of_2(src->min_region_sz))
> return -EINVAL;
> + if (!src->addr_unit || !is_power_of_2(src->addr_unit))
This isn't a bug, but is the !src->addr_unit check needed here?
Looking at is_power_of_2(), it already evaluates to false for an input
of zero, so the compound condition could perhaps be simplified to just
!is_power_of_2(src->addr_unit).
> + return -EINVAL;
>
> err = damon_commit_schemes(dst, src);
> if (err)
# end of sashiko.dev inline review
# review url: https://sashiko.dev/#/patchset/20260327062627.66426-1-aethernet65535@gmail.com
#
# hkml [1] generated a draft of this mail. It can be regenerated
# using below command:
#
# hkml patch sashiko_dev --for_forwarding \
# 20260327062627.66426-1-aethernet65535@gmail.com
#
# [1] https://github.com/sjp38/hackermail
next prev parent reply other threads:[~2026-03-27 8:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-27 6:26 [PATCH] mm/damon: validate addr_unit to be power of 2 Liew Rui Yan
2026-03-27 6:45 ` Liew Rui Yan
2026-03-27 12:10 ` Liew Rui Yan
2026-03-27 8:11 ` Liew Rui Yan [this message]
2026-03-27 8:27 ` (sashiko review) " Liew Rui Yan
2026-03-27 14:14 ` SeongJae Park
2026-03-27 14:56 ` Liew Rui Yan
2026-03-28 0:14 ` SeongJae Park
2026-03-28 2:26 ` Liew Rui Yan
2026-03-28 13:29 ` SeongJae Park
2026-03-28 14:13 ` SeongJae Park
2026-03-28 17:44 ` Liew Rui Yan
2026-03-28 18:06 ` SeongJae Park
2026-03-28 18:43 ` Liew Rui Yan
2026-03-29 3:20 ` SeongJae Park
2026-03-29 7:51 ` Liew Rui Yan
2026-03-29 15:15 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260327081131.80608-1-aethernet65535@gmail.com \
--to=aethernet65535@gmail.com \
--cc=damon@lists.linux.dev \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox