lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250813170224.6128-1-sj@kernel.org>
Date: Wed, 13 Aug 2025 10:02:24 -0700
From: SeongJae Park <sj@...nel.org>
To: Quanmin Yan <yanquanmin1@...wei.com>
Cc: SeongJae Park <sj@...nel.org>,
	akpm@...ux-foundation.org,
	damon@...ts.linux.dev,
	linux-kernel@...r.kernel.org,
	linux-mm@...ck.org,
	wangkefeng.wang@...wei.com,
	zuoze1@...wei.com
Subject: Re: [RFC PATCH -next 13/16] mm/damon/sysfs: ensure valid addr_unit setting in damon_sysfs_apply_inputs()

On Wed, 13 Aug 2025 13:07:03 +0800 Quanmin Yan <yanquanmin1@...wei.com> wrote:

> By calling damon_sysfs_turn_damon_on(), the execution of damon_commit_ctx()
> can be bypassed. Therefore, it is necessary to prevent ctx->addr_unit from
> being set to 0 in damon_sysfs_apply_inputs() and update min_region to avoid
> potential issues.

Nice catch!

> 
> Signed-off-by: Quanmin Yan <yanquanmin1@...wei.com>
> ---
>  mm/damon/sysfs.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index bea782b0a711..122824776c1d 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -1422,7 +1422,8 @@ static int damon_sysfs_apply_inputs(struct damon_ctx *ctx,
>  	err = damon_select_ops(ctx, sys_ctx->ops_id);
>  	if (err)
>  		return err;
> -	ctx->addr_unit = sys_ctx->addr_unit;
> +	ctx->addr_unit = sys_ctx->addr_unit ? : 1;

So this is fixing a bug of the seventh patch ("mm/damon/sysfs: implement
addr_unit file under context dir") of this series, right?  It is better to not
add a broken patch, and then fixing it in the same series.  Let's squash the
fix of the problem into the patch.  Don't forget adding your Signed-off-by on
the patch.

Also, since sys_ctx->addr_unit is initialized as 1, the value being zero is
user's wrong input.  Let's return -EINVAL instead of making it silently
success.

> +	ctx->min_region = max(DAMON_MIN_REGION / ctx->addr_unit, 1);

Seems this is a fix of an issue in the 12th patch ("mm/damon: add
damon_ctx->min_region and damon_target->min_region") of this series?  Let's fix
it on the patch.

>  	err = damon_sysfs_set_attrs(ctx, sys_ctx->attrs);
>  	if (err)
>  		return err;
> -- 
> 2.34.1


Thanks,
SJ

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ