From 1ab5d84d66f144ef0a9d1ac9502a59a842466504 Mon Sep 17 00:00:00 2001
From: biubiuzy <294772273@qq.com>
Date: Wed, 17 Jan 2024 11:23:47 +0800
Subject: [PATCH] libblkid: (drbd) reduce false-positive

---
 libblkid/src/superblocks/drbd.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/libblkid/src/superblocks/drbd.c b/libblkid/src/superblocks/drbd.c
index 1723229..410e21d 100644
--- a/libblkid/src/superblocks/drbd.c
+++ b/libblkid/src/superblocks/drbd.c
@@ -18,6 +18,13 @@
 
 #include "superblocks.h"
 
+/*
+ * drbd/drbd_int.h
+ */
+#define BM_BLOCK_SHIFT	12			 /* 4k per bit */
+#define BM_BLOCK_SIZE	 (1<<BM_BLOCK_SHIFT)
+
+
 /*
  * drbd/linux/drbd.h
  */
@@ -153,6 +160,9 @@ static int probe_drbd_84(blkid_probe pr)
 			be32_to_cpu(md->magic) != DRBD_MD_MAGIC_84_UNCLEAN)
 		return 1;
 
+	if (be32_to_cpu(read_unaligned_member(md, bm_bytes_per_bit)) != BM_BLOCK_SIZE)
+		return 1;
+
 	/*
 	 * DRBD does not have "real" uuids; the following resembles DRBD's
 	 * notion of uuids (64 bit, see struct above)
@@ -197,6 +197,9 @@ static int probe_drbd_90(blkid_probe pr)
 	if (be32_to_cpu(md->magic) != DRBD_MD_MAGIC_09)
 		return 1;
 
+	if (be32_to_cpu(read_unaligned_member(md, bm_bytes_per_bit)) != BM_BLOCK_SIZE)
+		return 1;
+
 	/*
 	 * DRBD does not have "real" uuids; the following resembles DRBD's
 	 * notion of uuids (64 bit, see struct above)
-- 
2.33.0

