Skip to contentSkip to conversation

master - allocation: Avoid exceeding array bounds in allocation tag code

PATCH Alasdair Kergon 1 participant 1 message Jan 10, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bacc94233368cf136b55e2574e969e7f53b31c6c
Commit:        bacc94233368cf136b55e2574e969e7f53b31c6c
Parent:        e2438b5b9ff526cae8fa29ca7023b43995f00647
Author:        Alasdair G Kergon <[email protected]>
AuthorDate:    Wed Jan 10 02:03:32 2018 +0000
Committer:     Alasdair G Kergon <[email protected]>
CommitterDate: Wed Jan 10 15:48:03 2018 +0000

allocation: Avoid exceeding array bounds in allocation tag code

If _limit_to_one_area_per_tag() changes nothing it writes beyond the array.

---
 WHATS_NEW               |    1 +
 lib/metadata/lv_manip.c |    3 ++-
 2 files changed, 3 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
index 345c472..897576c 100644
@@ -1,5 +1,6 @@
 Version 2.02.178 - 
 =====================================
+  Avoid exceeding array bounds in allocation tag processing.
   Refactor metadata reading code to use callback functions.
   Move memory allocation for the key dev_reads into the device layer.
 
lib/metadata/lv_manip.c +2 -1
index 70dc2d9..ac30dad 100644
@@ -2737,7 +2737,8 @@ static int _limit_to_one_area_per_tag(struct alloc_handle *ah, struct alloc_stat
 		s++;
 	}
 
-	alloc_state->areas[u].pva = NULL;
+	if (u < alloc_state->areas_size)
+		alloc_state->areas[u].pva = NULL;
 
 	return 1;
 }