All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dm-unstripe: terminate the status string for STATUSTYPE_INFO
@ 2026-11-20 18:49 Vasiliy Kovalev
  0 siblings, 0 replies; only message in thread
From: Vasiliy Kovalev @ 2026-11-20 18:49 UTC (permalink / raw)
  To: Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski, dm-devel
  Cc: linux-kernel, lvc-project, kovalev

unstripe_status() writes nothing to the result buffer for
STATUSTYPE_INFO. retrieve_status() then runs strlen() on that buffer,
which still holds whatever the caller passed in the ioctl payload. If
the payload contains no NUL byte, strlen() runs past the end of the
kernel copy of the ioctl buffer:

BUG: KASAN: slab-out-of-bounds in strlen+0x8f/0xa0 lib/string.c:402
Read of size 1 at addr ffff888109690566 by task syz.1.18/1420

CPU: 0 UID: 0 PID: 1420 Comm: syz.1.18 Not tainted 7.4.0-rc1-next-20261104-alt-syz-box-drivers_md_bcache #1 PREEMPT(lazy)
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:94 [inline]
 dump_stack_lvl+0xc2/0x120 lib/dump_stack.c:120
 print_address_description mm/kasan/report.c:378 [inline]
 print_report+0xce/0x640 mm/kasan/report.c:482
 kasan_report+0xdc/0x110 mm/kasan/report.c:595
 strlen+0x8f/0xa0 lib/string.c:402
 __fortify_strlen include/linux/fortify-string.h:218 [inline]
 retrieve_status+0x483/0x8c0 drivers/md/dm-ioctl.c:1442
 dev_wait+0x1ba/0x210 drivers/md/dm-ioctl.c:1496
 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:0x00007f6a853ea829
 </TASK>

retrieve_status() then also reports a data_size past the end of the
payload, and ctl_ioctl() copies the bytes behind it back to userspace.
The same happens with DM_TABLE_STATUS.

Other targets emit at least an empty string here; do the same as for
STATUSTYPE_IMA.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Fixes: 18a5bf270532 ("dm: add unstriped target")
Cc: stable@vger.kernel.org
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
 drivers/md/dm-unstripe.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/md/dm-unstripe.c b/drivers/md/dm-unstripe.c
index 770a9958def0..708640a8f6d4 100644
--- a/drivers/md/dm-unstripe.c
+++ b/drivers/md/dm-unstripe.c
@@ -150,6 +150,7 @@ static void unstripe_status(struct dm_target *ti, status_type_t type,
 
 	switch (type) {
 	case STATUSTYPE_INFO:
+		*result = '\0';
 		break;
 
 	case STATUSTYPE_TABLE:
-- 
2.50.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-20 18:49 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 18:49 [PATCH] dm-unstripe: terminate the status string for STATUSTYPE_INFO Vasiliy Kovalev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.