Skip to contentSkip to conversation

ia64: bitvector_process could read out of bounds

PATCH Superseded Geyslan G. Bem 2 participants 2 messages Dec 2, 2015 – Dec 7, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ia64: bitvector_process could read out of bounds

The units[] array could be accessed out of its bounds due the lack of verification of the max vector value.

To make this function not prone to error "P" and "E" suffixes were added. Despite the new suffixes are unrelated to current ia64 vm magnitudes, they make the code ready for it and avoid misleadings.

Catched using static analysis (cppcheck).

---
 arch/ia64/kernel/palinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/palinfo.c +1 -1
index c39c3cd..160aba1 100644
@@ -126,7 +126,7 @@ static const char *mem_attrib[]={
 static void bitvector_process(struct seq_file *m, u64 vector)
 {
 	int i,j;
-	static const char *units[]={ "", "K", "M", "G", "T" };
+	static const char *units[] = { "", "K", "M", "G", "T", "P", "E" };
 
 	for (i=0, j=0; i < 64; i++ , j=i/10) {
 		if (vector & 0x1)
Signature · 1 line
2.6.2
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Geyslan G. Bem

The units[] array could be accessed out of its bounds due the lack of verification of the max vector value.

To make this function not prone to error "P" and "E" suffixes were added. Despite the new suffixes are unrelated to current ia64 vm magnitudes, they make the code ready for it and avoid misleadings.

I would mention that you also fix some white space issues, but other than that:

Quoted 25 lines

Catched using static analysis (cppcheck).

---
 arch/ia64/kernel/palinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/ia64/kernel/palinfo.c +1 -2
index c39c3cd..160aba1 100644
@@ -126,7 +126,7 @@ static const char *mem_attrib[]={
 static void bitvector_process(struct seq_file *m, u64 vector)
 {
        int i,j;
-       static const char *units[]={ "", "K", "M", "G", "T" };
+       static const char *units[] = { "", "K", "M", "G", "T", "P", "E" };
 
        for (i=0, j=0; i < 64; i++ , j=i/10) {
                if (vector & 0x1)
--

2.6.2

Signature · 1 line
Peter