FAILED: patch "[PATCH] mm/damon/sysfs: read addr_unit only once in" failed to apply to 6.18-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.18-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.18.y
git checkout FETCH_HEAD
git cherry-pick -x ab4d9358e32316fa39b5f1f5360292135978c3d9
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090850-untried-sanctity-a00c@gregkh' --subject-prefix 'PATCH 6.18.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From ab4d9358e32316fa39b5f1f5360292135978c3d9 Mon Sep 17 00:00:00 2001
From: SJ Park <[email protected]>
Date: Tue, 14 Jul 2026 20:10:00 -0700
Subject: [PATCH] mm/damon/sysfs: read addr_unit only once in
damon_sysfs_apply_inputs()
damon_sysfs_apply_inputs() reads addr_unit twice. It could race with addr_unit_store(). As a result, the min_region_sz could wrongly be set up. Read it once.
The user impact is trivial. Sane users ain't update the parameter in parallel. Even if it happens, the DAMON core layer handles the wrong min_region_sz (!is_power_of_2()). Even if somehow the race ended up making a min_region_sz that is different from the user's intention but still valid, only monitoring itself runs differently than expected. No critical consequences like kernel panic or memory corruption happen.
The issue was discovered [1] by Sashiko.
mm/damon/sysfs.c +2 -2
@@ -2099,11 +2099,11 @@ 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 =READ_ONCE (sys_ctx->addr_unit);/* addr_unit is respected by only DAMON_OPS_PADDR */ if (sys_ctx->ops_id ==DAMON_OPS_PADDR ) ctx->min_region_sz =max ( -DAMON_MIN_REGION_SZ / sys_ctx->addr_unit,1 ); +DAMON_MIN_REGION_SZ / ctx->addr_unit,1 ); ctx->pause = sys_ctx->pause; err =damon_sysfs_set_attrs (ctx, sys_ctx->attrs);if (err)
SJ Park
maintainerPATCH 1/1 mm/damon/sysfs: read addr_unit only once in damon_sysfs_apply_inputs()
damon_sysfs_apply_inputs() reads addr_unit twice. It could race with addr_unit_store(). As a result, the min_region_sz could wrongly be set up. Read it once.
The user impact is trivial. Sane users ain't update the parameter in parallel. Even if it happens, the DAMON core layer handles the wrong min_region_sz (!is_power_of_2()). Even if somehow the race ended up making a min_region_sz that is different from the user's intention but still valid, only monitoring itself runs differently than expected. No critical consequences like kernel panic or memory corruption happen.
The issue was discovered [1] by Sashiko.
--- mm/damon/sysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/damon/sysfs.c +2 -2
@@ -1437,11 +1437,11 @@ 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 =READ_ONCE (sys_ctx->addr_unit);/* addr_unit is respected by only DAMON_OPS_PADDR */ if (sys_ctx->ops_id ==DAMON_OPS_PADDR ) ctx->min_sz_region =max ( -DAMON_MIN_REGION / sys_ctx->addr_unit,1 ); +DAMON_MIN_REGION / ctx->addr_unit,1 ); err =damon_sysfs_set_attrs (ctx, sys_ctx->attrs);if (err)return err;
Signature · 1 line
2.47.3
[email protected]
AI reviewRe: [PATCH 6.18.y] mm/damon/sysfs: read addr_unit only once in damon_sysfs_apply_inputs()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 13 lines
damon_sysfs_apply_inputs()readsaddr_unittwice. It could race withaddr_unit_store(). As a result, themin_region_szcould wrongly be set up. Read it once.The user impact is trivial. Sane users ain't update the parameter in parallel. Even if it happens, the DAMON core layer handles the wrong
min_region_sz(!is_power_of_2()). Even if somehow the race ended up making amin_region_szthat is different from the user's intention but still valid, only monitoring itself runs differently than expected. No critical consequences like kernel panic or memory corruption happen.The issue was discovered [1] by Sashiko.
Quoted 8 lines
Fixes 540a2aebc657 ("mm/damon/sysfs: implement addr_unit file under context dir")Signed-off-by SJ Park <[email protected]>Cc <[email protected]> # 6.18.xSigned-off-by Andrew Morton <[email protected]>(cherry picked from commit ab4d9358e32316fa39b5f1f5360292135978c3d9)Signed-off-by SJ Park <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1