Skip to contentSkip to conversation

blkmapd: reject zero-length signature components while decoding block signatures

PATCH In review Scott Mayhew 2 participants 2 messages Sep 3 – Sep 16

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blkmapd: reject zero-length signature components while decoding block signatures

A zero-length signature can cause blkmapd to map to an unintended device.

---
 utils/blkmapd/device-process.c | 4 ++++
 1 file changed, 4 insertions(+)
utils/blkmapd/device-process.c +4 -0
index f53a6165..a47cc36e 100644
@@ -81,6 +81,10 @@ static int decode_blk_signature(uint32_t **pp, uint32_t * end,
 		BLK_READBUF(p, end, 12);
 		READ64(comp->bs_offset);
 		READ32(siglen);
+		if (siglen == 0) {
+			BL_LOG_ERR("0 length signature component\n");
+			goto out_err;
+		}
 		comp->bs_length = siglen;
 		BLK_READBUF(p, end, siglen);
 		/* Note we rely here on fact that sig is used immediately
Signature · 1 line
2.55.0
#1 lore raw
Quoted 4 lines · Scott Mayhew

A zero-length signature can cause blkmapd to map to an unintended device.

Committed... (tag: nfs-utils-2-9-3-rc4)

steved.> ---

Quoted 18 lines
  utils/blkmapd/device-process.c | 4 ++++
  1 file changed, 4 insertions(+)
utils/blkmapd/device-process.c +4 -0
index f53a6165..a47cc36e 100644
@@ -81,6 +81,10 @@ static int decode_blk_signature(uint32_t **pp, uint32_t * end,
  		BLK_READBUF(p, end, 12);
  		READ64(comp->bs_offset);
  		READ32(siglen);
+		if (siglen == 0) {
+			BL_LOG_ERR("0 length signature component\n");
+			goto out_err;
+		}
  		comp->bs_length = siglen;
  		BLK_READBUF(p, end, siglen);
  		/* Note we rely here on fact that sig is used immediately