[PATCH] dm-ioctl: fix a possible overflow in list_version_get_info

Mikulas Patocka <[email protected]> Thu, 9 Jul 2026 21:31:47 +0200 (CEST)
Newsgroups dev.linux.lists.dm-devel
Message-ID <[email protected]>
sizeof(tt->version) is 12 bytes, but the code writes 16 bytes into the
output buffer - info->vers->version[0], info->vers->version[1],
info->vers->version[2] and info->vers->next. This can cause buffer
overflow.

Fix this buffer overflow by replacing "sizeof(tt->version)" with
"sizeof(struct dm_target_versions)".

Signed-off-by: Mikulas Patocka <[email protected]>
Assisted-by: Claude:claude-opus-4.6
Cc: [email protected]

---
 drivers/md/dm-ioctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/drivers/md/dm-ioctl.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-ioctl.c	2026-06-23 13:02:40.000000000 +0200
+++ linux-2.6/drivers/md/dm-ioctl.c	2026-06-23 14:17:22.000000000 +0200
@@ -698,7 +698,7 @@ static void list_version_get_info(struct
 	struct vers_iter *info = param;
 
 	/* Check space - it might have changed since the first iteration */
-	if ((char *)info->vers + sizeof(tt->version) + strlen(tt->name) + 1 > info->end) {
+	if ((char *)info->vers + sizeof(struct dm_target_versions) + strlen(tt->name) + 1 > info->end) {
 		info->flags = DM_BUFFER_FULL_FLAG;
 		return;
 	}