All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vasiliy Kovalev <kovalev@altlinux.org>
To: Alasdair Kergon <agk@redhat.com>,
	Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	Benjamin Marzinski <bmarzins@redhat.com>,
	dm-devel@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org,
	kovalev@altlinux.org
Subject: [PATCH] dm-unstripe: terminate the status string for STATUSTYPE_INFO
Date: Fri, 20 Nov 2026 21:49:08 +0300	[thread overview]
Message-ID: <20261120184908.614271-1-kovalev@altlinux.org> (raw)

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


                 reply	other threads:[~2026-11-20 18:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120184908.614271-1-kovalev@altlinux.org \
    --to=kovalev@altlinux.org \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=dm-devel@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.