* [PATCH] dm-verity: give each FEC buffer slab cache a unique name
@ 2026-11-20 18:51 Vasiliy Kovalev
2026-11-29 23:34 ` Eric Biggers
0 siblings, 1 reply; 2+ messages in thread
From: Vasiliy Kovalev @ 2026-11-20 18:51 UTC (permalink / raw)
To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
Benjamin Marzinski, dm-devel
Cc: linux-kernel, lvc-project, kovalev
verity_fec_ctr() creates a slab cache for the FEC buffers of every
verity target that uses FEC, always under the name
"dm_verity_fec_buffers". With CONFIG_DEBUG_VM=y, as soon as two such
targets exist at the same time, for example two FEC-enabled devices or
a table reload of one, the second kmem_cache_create() trips the
duplicate name check:
kmem_cache of name 'dm_verity_fec_buffers' already exists
WARNING: mm/slab_common.c:111 at kmem_cache_sanity_check mm/slab_common.c:111 [inline], CPU#2: syz.1.18/4545
WARNING: mm/slab_common.c:111 at __kmem_cache_create_args+0xab/0x450 mm/slab_common.c:352, CPU#2: syz.1.18/4545
Modules linked in:
CPU: 2 UID: 0 PID: 4545 Comm: syz.1.18 Not tainted 7.4.0-rc1-next-20261104-alt-syz-box-drivers_md_bcache #1 PREEMPT(lazy)
RIP: 0010:kmem_cache_sanity_check mm/slab_common.c:111 [inline]
RIP: 0010:__kmem_cache_create_args+0xae/0x450 mm/slab_common.c:352
Call Trace:
<TASK>
__kmem_cache_create include/linux/slab.h:402 [inline]
verity_fec_ctr+0x9eb/0x1070 drivers/md/dm-verity-fec.c:709
verity_ctr+0x1a6a/0x1ed0 drivers/md/dm-verity-target.c:1650
dm_table_add_target+0x7c2/0xf30 drivers/md/dm-table.c:749
populate_table drivers/md/dm-ioctl.c:1602 [inline]
table_load+0x38b/0x910 drivers/md/dm-ioctl.c:1645
ctl_ioctl+0x4d2/0xd70 drivers/md/dm-ioctl.c:2221
dm_ctl_ioctl+0x1e/0x30 drivers/md/dm-ioctl.c:2243
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:597 [inline]
__se_sys_ioctl fs/ioctl.c:583 [inline]
__x64_sys_ioctl+0x18a/0x210 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
do_syscall_64+0x112/0x630 arch/x86/entry/syscall_64.c:89
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x00007f213c87a829
</TASK>
The buffer size depends on the number of RS roots of each target, so a
single cache can't be created at module init. Append a unique sequence
number to the name, as dm-bufio does. The slab core copies the name, so
a stack buffer is enough.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Fixes: 4c39529663b9 ("slab: Warn on duplicate cache names when DEBUG_VM=y")
Cc: stable@vger.kernel.org
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
With panic_on_warn the warning panics the kernel.
drivers/md/dm-verity-fec.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
index c79f60df3a90..dfe44f25a5eb 100644
--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -594,6 +594,8 @@ int verity_fec_ctr(struct dm_verity *v)
struct dm_target *ti = v->ti;
u64 hash_blocks;
int ret;
+ char cache_name[64];
+ static atomic_t seqno = ATOMIC_INIT(0);
if (!verity_fec_is_enabled(v)) {
verity_fec_dtr(v);
@@ -706,7 +708,9 @@ int verity_fec_ctr(struct dm_verity *v)
return ret;
}
- f->cache = kmem_cache_create("dm_verity_fec_buffers",
+ snprintf(cache_name, sizeof(cache_name), "dm_verity_fec_buffers-%d",
+ atomic_inc_return(&seqno));
+ f->cache = kmem_cache_create(cache_name,
f->rs_k << DM_VERITY_FEC_BUF_RS_BITS,
0, 0, NULL);
if (!f->cache) {
--
2.50.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] dm-verity: give each FEC buffer slab cache a unique name
2026-11-20 18:51 [PATCH] dm-verity: give each FEC buffer slab cache a unique name Vasiliy Kovalev
@ 2026-11-29 23:34 ` Eric Biggers
0 siblings, 0 replies; 2+ messages in thread
From: Eric Biggers @ 2026-11-29 23:34 UTC (permalink / raw)
To: Vasiliy Kovalev
Cc: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
Benjamin Marzinski, dm-devel, linux-kernel, lvc-project
On Fri, Nov 20, 2026 at 09:51:23PM +0300, Vasiliy Kovalev wrote:
> verity_fec_ctr() creates a slab cache for the FEC buffers of every
> verity target that uses FEC, always under the name
> "dm_verity_fec_buffers". With CONFIG_DEBUG_VM=y, as soon as two such
> targets exist at the same time, for example two FEC-enabled devices or
> a table reload of one, the second kmem_cache_create() trips the
> duplicate name check:
>
> kmem_cache of name 'dm_verity_fec_buffers' already exists
> WARNING: mm/slab_common.c:111 at kmem_cache_sanity_check mm/slab_common.c:111 [inline], CPU#2: syz.1.18/4545
> WARNING: mm/slab_common.c:111 at __kmem_cache_create_args+0xab/0x450 mm/slab_common.c:352, CPU#2: syz.1.18/4545
> Modules linked in:
> CPU: 2 UID: 0 PID: 4545 Comm: syz.1.18 Not tainted 7.4.0-rc1-next-20261104-alt-syz-box-drivers_md_bcache #1 PREEMPT(lazy)
> RIP: 0010:kmem_cache_sanity_check mm/slab_common.c:111 [inline]
> RIP: 0010:__kmem_cache_create_args+0xae/0x450 mm/slab_common.c:352
> Call Trace:
> <TASK>
> __kmem_cache_create include/linux/slab.h:402 [inline]
> verity_fec_ctr+0x9eb/0x1070 drivers/md/dm-verity-fec.c:709
> verity_ctr+0x1a6a/0x1ed0 drivers/md/dm-verity-target.c:1650
> dm_table_add_target+0x7c2/0xf30 drivers/md/dm-table.c:749
> populate_table drivers/md/dm-ioctl.c:1602 [inline]
> table_load+0x38b/0x910 drivers/md/dm-ioctl.c:1645
> ctl_ioctl+0x4d2/0xd70 drivers/md/dm-ioctl.c:2221
> dm_ctl_ioctl+0x1e/0x30 drivers/md/dm-ioctl.c:2243
> vfs_ioctl fs/ioctl.c:51 [inline]
> __do_sys_ioctl fs/ioctl.c:597 [inline]
> __se_sys_ioctl fs/ioctl.c:583 [inline]
> __x64_sys_ioctl+0x18a/0x210 fs/ioctl.c:583
> do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
> do_syscall_64+0x112/0x630 arch/x86/entry/syscall_64.c:89
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x00007f213c87a829
> </TASK>
>
> The buffer size depends on the number of RS roots of each target, so a
> single cache can't be created at module init. Append a unique sequence
> number to the name, as dm-bufio does. The slab core copies the name, so
> a stack buffer is enough.
>
> Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
>
> Fixes: 4c39529663b9 ("slab: Warn on duplicate cache names when DEBUG_VM=y")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
> ---
> With panic_on_warn the warning panics the kernel.
>
> drivers/md/dm-verity-fec.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
- Eric
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-29 23:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-20 18:51 [PATCH] dm-verity: give each FEC buffer slab cache a unique name Vasiliy Kovalev
2026-11-29 23:34 ` Eric Biggers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®