mm/execmem: check execmem_restore_rox() failure in execmem_cache_free()
Subsystems (3)
PATCH 1/1 mm/execmem: check execmem_restore_rox() failure in execmem_cache_free()
From: Shao Mingyin <[email protected]>
mm/execmem: check execmem_restore_rox() failure in execmem_cache_free()
__execmem_cache_free() checks execmem_force_rw(), but ignores the matching execmem_restore_rox() result before adding the block to the free ROX cache. A failed restore can leave permissions only partially updated, so a later cache allocation can return memory that is not ROX. The cache allocation path does not reapply permissions.
Check the restore result and return the error. The existing callers keep failed frees pending and retry them through delayed work. This prevents a block whose ROX restoration failed from entering the free cache, and matches the error handling in execmem_vmalloc_rox().
---
Build-tested mm/execmem.o with W=1 and CONFIG_ARCH_HAS_EXECMEM_ROX=y on x86_64. The pending-free error path was reviewed statically. No natural CPA restore failure or BPF execution fault was reproduced.
mm/execmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/execmem.c +3 -1
@@ -351,7 +351,9 @@ static int __execmem_cache_free(struct ma_state *mas, void *ptr, gfp_t gfp_mask)return err;execmem_fill_trapping_insns (ptr, size); -execmem_restore_rox (ptr, size); + err =execmem_restore_rox (ptr, size); +if (err) +return err; err =execmem_cache_add_locked (ptr, size, gfp_mask);if (err)
base-commit: 84abb955b1015477aa11a96e2f3ac1b938b77f48
Signature · 1 line
2.43.0
Quoted 10 lines · On Sun, Nov 15, 2026 at 12:47:04AM +0800, [email protected] wrote:
From: Shao Mingyin <[email protected]>
mm/execmem: check
execmem_restore_rox()failure inexecmem_cache_free()
__execmem_cache_free()checksexecmem_force_rw(), but ignores the matchingexecmem_restore_rox()result before adding the block to the free ROX cache. A failed restore can leave permissions only partially updated, so a later cache allocation can return memory that is not ROX. The cache allocation path does not reapply permissions.
Quoted 8 lines
Check the restore result and return the error. The existing callers keep failed frees pending and retry them through delayed work. This prevents a block whose ROX restoration failed from entering the free cache, and matches the error handling in
execmem_vmalloc_rox().Fixes 187fd8521dd8 ("execmem: rework execmem_cache_free()")Cc [email protected] # 6.17Signed-off-by Shao Mingyin <[email protected]>
NAK.
this is generated by some AI slopper's script, spamming the kernel. The patches I looked at were wrong/broken, so no to anything from this person.
They've sent 300 mails in under four weeks spanniing: ata, scsi, target, ufs, nvme/nvmet, ubifs, ublk, zloop, dm, md, mmc, virtio-blk, mfd, gpio, pwm, spi, PCI, ASoC, ACPI, net, vfs mount, block partitions, and now mm.
and 17 series across 7 subsystems over the past 23 hours.
We need a way to ban emails from people like this...
--
Cheers, Lorenzo
Mike Rapoport
maintainerQuoted 15 lines · On Sun, Nov 15, 2026 at 12:47:04AM +0800, [email protected] wrote:
From: Shao Mingyin <[email protected]>
mm/execmem: check
execmem_restore_rox()failure inexecmem_cache_free()
__execmem_cache_free()checksexecmem_force_rw(), but ignores the matchingexecmem_restore_rox()result before adding the block to the free ROX cache. A failed restore can leave permissions only partially updated, so a later cache allocation can return memory that is not ROX. The cache allocation path does not reapply permissions.Check the restore result and return the error. The existing callers keep failed frees pending and retry them through delayed work. This prevents a block whose ROX restoration failed from entering the free cache, and matches the error handling in
execmem_vmalloc_rox().
Quoted 7 lines
Fixes 187fd8521dd8 ("execmem: rework execmem_cache_free()")Cc [email protected] # 6.17Signed-off-by Shao Mingyin <[email protected]>---
Build-testedmm/execmem.owith W=1 andCONFIG_ARCH_HAS_EXECMEM_ROX=yonx86_64. The pending-free error path was reviewed statically. No natural CPA restore failure or BPF execution fault was reproduced.
Yes, because it cannot happen.
Quoted 22 lines
mm/execmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)mm/execmem.c +3
-1@@ -351,7 +351,9 @@ static int __execmem_cache_free(struct ma_state *mas, void *ptr, gfp_t gfp_mask)return err;execmem_fill_trapping_insns (ptr, size); -execmem_restore_rox (ptr, size); + err =execmem_restore_rox (ptr, size); +if (err) +return err; err =execmem_cache_add_locked (ptr, size, gfp_mask);if (err)base-commit:
84abb955b1015477aa11a96e2f3ac1b938b77f48Signature · 1 line
2.43.0
Signature · 2 lines
Sincerely yours, Mike.