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: <6d054831-054f-446a-a82f-239913a9deaa@huawei.com>
Date: Wed, 20 Aug 2025 16:45:54 +0800
From: Quanmin Yan <yanquanmin1@...wei.com>
To: SeongJae Park <sj@...nel.org>
CC: <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()

Hi SJ,

在 2025/8/14 1:02, SeongJae Park 写道:
> 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.

Thank you for the kind reminder! The relevant changes have been integrated into
patch #7 of the v2 series[1]. It's worth noting that we've already prevented users
from inputting 0 at the source, therefore "ctx->addr_unit = sys_ctx->addr_unit;"
has been retained in the v2 version.

[1] https://lore.kernel.org/all/20250820080623.3799131-8-yanquanmin1@huawei.com/

>> +	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.

This set of changes has been integrated into patch #11 of the v2 series[2].

[2] https://lore.kernel.org/all/20250820080623.3799131-12-yanquanmin1@huawei.com/

Thanks,
Quanmin Yan


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ