Skip to contentSkip to conversation

contrib/elf2dmp: add kernel start address checking

PATCH Applied Viktor Prutyanov 3 participants 4 messages Feb 19, 2019 – Mar 9, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 contrib/elf2dmp: add kernel start address checking

Before this patch, if elf2dmp failed to find NT kernel PE magic in allowed virtual address range, then it assumes NULL as NT kernel address and cause segfault.

This patch fix the problem described above by checking NT kernel address before futher processing.

---
 contrib/elf2dmp/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
contrib/elf2dmp/main.c +6 -0
index 1a45eaf565..1bfeb89ba7 100644
@@ -524,6 +524,12 @@ int main(int argc, char *argv[])
         }
     }
 
+    if (!nt_start_addr) {
+        eprintf("Failed to find NT kernel image\n");
+        err = 1;
+        goto out_ps;
+    }
+
     printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase,
             (char *)nt_start_addr);
 
Signature · 1 line
2.17.2
#1 lore raw
Quoted 20 lines · Viktor Prutyanov

Before this patch, if elf2dmp failed to find NT kernel PE magic in allowed virtual address range, then it assumes NULL as NT kernel address and cause segfault.

This patch fix the problem described above by checking NT kernel address before futher processing.

---
 contrib/elf2dmp/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
contrib/elf2dmp/main.c +0 -0
index 1a45eaf565..1bfeb89ba7 100644
@@ -524,6 +524,12 @@ int main(int argc, char *argv[])
         }
     }

contrib/elf2dmp/main.c int main(int argc, char *argv[]) · line 535

Quoted 10 lines
contrib/elf2dmp/main.c +6 -0
 
+    if (!nt_start_addr) {
+        eprintf("Failed to find NT kernel image\n");
+        err = 1;
+        goto out_ps;
+    }
+
     printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase,
             (char *)nt_start_addr);
 

Queued, thanks.

Paolo

#2 lore raw
Quoted 22 lines · Paolo Bonzini
Quoted 20 lines · Viktor Prutyanov

Before this patch, if elf2dmp failed to find NT kernel PE magic in allowed virtual address range, then it assumes NULL as NT kernel address and cause segfault.

This patch fix the problem described above by checking NT kernel address before futher processing.

---
 contrib/elf2dmp/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
contrib/elf2dmp/main.c +0 -0
index 1a45eaf565..1bfeb89ba7 100644
@@ -524,6 +524,12 @@ int main(int argc, char *argv[])
         }
     }
 
Quoted 12 lines

contrib/elf2dmp/main.c int main(int argc, char *argv[]) · line 535

Quoted 10 lines
contrib/elf2dmp/main.c +6 -0
+    if (!nt_start_addr) {
+        eprintf("Failed to find NT kernel image\n");
+        err = 1;
+        goto out_ps;
+    }
+
     printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase,
             (char *)nt_start_addr);
 

Queued, thanks.

Hi Paolo -- I noticed this fix wasn't in master yet -- is it in a tree you're planning on sending a pullreq for soon?

thanks
-- PMM

#3 lore raw
Quoted 36 lines · Peter Maydell
Quoted 22 lines · Paolo Bonzini
Quoted 20 lines · Viktor Prutyanov

Before this patch, if elf2dmp failed to find NT kernel PE magic in allowed virtual address range, then it assumes NULL as NT kernel address and cause segfault.

This patch fix the problem described above by checking NT kernel address before futher processing.

---
 contrib/elf2dmp/main.c | 6 ++++++
 1 file changed, 6 insertions(+)
contrib/elf2dmp/main.c +0 -0
index 1a45eaf565..1bfeb89ba7 100644
@@ -524,6 +524,12 @@ int main(int argc, char *argv[])
         }
     }
 
Quoted 12 lines

contrib/elf2dmp/main.c int main(int argc, char *argv[]) · line 535

Quoted 10 lines
contrib/elf2dmp/main.c +6 -0
+    if (!nt_start_addr) {
+        eprintf("Failed to find NT kernel image\n");
+        err = 1;
+        goto out_ps;
+    }
+
     printf("KernBase = 0x%016"PRIx64", signature is \'%.2s\'\n", KernBase,
             (char *)nt_start_addr);
 

Queued, thanks.

Quoted 2 lines

Hi Paolo -- I noticed this fix wasn't in master yet -- is it in a tree you're planning on sending a pullreq for soon?

Yep, I just wanted to flush kconfig and qgraph before everybody starts sending pull requests for soft freeze.

Paolo