From d8d164db5ee217034dea7788263b532114bcd2fd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= <thomas@t-8ch.de>
Date: Thu, 2 Mar 2023 15:27:58 +0000
Subject: [PATCH] libblkid: nvidia_raid: verify superblock size
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
---
 libblkid/src/superblocks/nvidia_raid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libblkid/src/superblocks/nvidia_raid.c b/libblkid/src/superblocks/nvidia_raid.c
index 5db8ec260..35c663c8d 100644
--- a/libblkid/src/superblocks/nvidia_raid.c
+++ b/libblkid/src/superblocks/nvidia_raid.c
@@ -24,6 +24,8 @@ struct nv_metadata {
 } __attribute__((packed));
 
 #define NVIDIA_SIGNATURE		"NVIDIA"
+#define NVIDIA_SUPERBLOCK_SIZE		120
+
 
 static int probe_nvraid(blkid_probe pr,
 		const struct blkid_idmag *mag __attribute__((__unused__)))
@@ -46,6 +48,8 @@ static int probe_nvraid(blkid_probe pr,
 
 	if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0)
 		return 1;
+	if (le32_to_cpu(nv->size) * 4 != NVIDIA_SUPERBLOCK_SIZE)
+		return 1;
 	if (blkid_probe_sprintf_version(pr, "%u", le16_to_cpu(nv->version)) != 0)
 		return 1;
 	if (blkid_probe_set_magic(pr, off, sizeof(nv->vendor),
-- 
2.27.0

