Fix makedumpfile --mem-usage /proc/kcore
Patches have been taken from kexec-tools and makedumpfile to fix issue with `makedumpfile --mem-usage /proc/kcore`. Two of the patches is from kexec-tools and rest are from makedumpfile. All the patches have been acked upstream and applies without conflict. Kexec-tools patches: (kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch), which fixes koji build issue. kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch fixes the regresssion caused by kernel /proc/kcore fix to use -1 as default value of p_paddr for pt_loads. Without his patch kexec -p will fail with latest kernel. Other makedumpfile patches are backported to support --mem-usage while kernel kaslr being enabled. Details please see the patch log of the individual patches. All the patches are backport of upstream commits. Patches has been tested with kernel 4.11.0-0.rc1.git0.1.fc26.x86_64. # makedumpfile --mem-usage /proc/kcore -f The kernel version is not supported. The makedumpfile operation may be incomplete. TYPE PAGES EXCLUDABLE DESCRIPTION ---------------------------------------------------------------------- ZERO 1960 yes Pages filled with zero NON_PRI_CACHE 22850 yes Cache pages without private flag PRI_CACHE 1517 yes Cache pages with private flag USER 32522 yes User process pages FREE 1898981 yes Free pages KERN_DATA 78721 no Dumpable kernel data page size: 4096 Total pages on system: 2036551 Total size on system: 8341712896 Byte We won't need to pass -f once fedora kernel is rebased with v4.12. Signed-off-by: Pratyush Anand <panand@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
parent
bbe10baeb2
commit
86a81de3e5
@ -0,0 +1,43 @@
|
||||
From 5520739f1e6e31c7731d34d384bbaf4904282931 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <5520739f1e6e31c7731d34d384bbaf4904282931.1489470510.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Wed, 1 Mar 2017 11:19:42 +0530
|
||||
Subject: [PATCH] build_mem_phdrs(): check if p_paddr is invalid
|
||||
|
||||
Currently, all the p_paddr of PT_LOAD headers are assigned to 0, which
|
||||
is not correct and could be misleading, since 0 is a valid physical
|
||||
address.
|
||||
|
||||
Upstream kernel commit "464920104bf7 /proc/kcore: update physical
|
||||
address for kcore ram and text" fixed it and now invalid PT_LOAD is
|
||||
assigned as -1.
|
||||
|
||||
kexec/arch/i386/crashdump-x86.c:get_kernel_vaddr_and_size() uses kcore
|
||||
interface and so calls build_mem_phdrs() for kcore PT_LOAD headers.
|
||||
|
||||
This patch fixes build_mem_phdrs() to check if p_paddr is invalid.
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
Acked-by: Dave Young <dyoung@redhat.com>
|
||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||
---
|
||||
kexec/kexec-elf.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/kexec/kexec-elf.c b/kexec/kexec-elf.c
|
||||
index 1d6320a2f0e6..be60bbd48486 100644
|
||||
--- a/kexec/kexec-elf.c
|
||||
+++ b/kexec/kexec-elf.c
|
||||
@@ -432,7 +432,8 @@ static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
- if ((phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) {
|
||||
+ if (phdr->p_paddr != (unsigned long long)-1 &&
|
||||
+ (phdr->p_paddr + phdr->p_memsz) < phdr->p_paddr) {
|
||||
/* The memory address wraps */
|
||||
if (probe_debug) {
|
||||
fprintf(stderr, "ELF address wrap around\n");
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,47 @@
|
||||
From f4ab6897a716d3f3959f6cb8cab27744eaecb5a6 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <f4ab6897a716d3f3959f6cb8cab27744eaecb5a6.1489471500.git.panand@redhat.com>
|
||||
In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:16 +0900
|
||||
Subject: [PATCH 4/7] [PATCH v3 4/7] elf_info: kcore: check for invalid
|
||||
physical address
|
||||
|
||||
kcore passes correct phys_start for direct mapped region and an invalid
|
||||
value (-1) for all other regions after the kernel commit
|
||||
464920104bf7(/proc/kcore: update physical address for kcore ram and
|
||||
text). arch specific function is_phys_addr() accepts only virt_start.
|
||||
Therefore, check for valid phys_start in get_kcore_dump_loads().
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
---
|
||||
elf_info.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/elf_info.c b/makedumpfile-1.6.1/elf_info.c
|
||||
index 65ff333cf33a..c5743b3cab28 100644
|
||||
--- a/makedumpfile-1.6.1/elf_info.c
|
||||
+++ b/makedumpfile-1.6.1/elf_info.c
|
||||
@@ -881,7 +881,8 @@ int get_kcore_dump_loads(void)
|
||||
|
||||
for (i = 0; i < num_pt_loads; ++i) {
|
||||
struct pt_load_segment *p = &pt_loads[i];
|
||||
- if (!is_phys_addr(p->virt_start))
|
||||
+ if (p->phys_start == NOT_PADDR
|
||||
+ || !is_phys_addr(p->virt_start))
|
||||
continue;
|
||||
loads++;
|
||||
}
|
||||
@@ -901,7 +902,8 @@ int get_kcore_dump_loads(void)
|
||||
|
||||
for (i = 0, j = 0; i < num_pt_loads; ++i) {
|
||||
struct pt_load_segment *p = &pt_loads[i];
|
||||
- if (!is_phys_addr(p->virt_start))
|
||||
+ if (p->phys_start == NOT_PADDR
|
||||
+ || !is_phys_addr(p->virt_start))
|
||||
continue;
|
||||
if (j >= loads)
|
||||
return FALSE;
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,47 @@
|
||||
From 8e2834bac4f62da3894da297f083068431be6d80 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <8e2834bac4f62da3894da297f083068431be6d80.1489471500.git.panand@redhat.com>
|
||||
In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:11 +0900
|
||||
Subject: [PATCH 2/7] [PATCH v3 2/7] initial(): call cache_init() a bit early
|
||||
|
||||
Call cache_init() before get_kcore_dump_loads(), because latter uses
|
||||
cache_search().
|
||||
|
||||
Call path is like this :
|
||||
get_kcore_dump_loads() -> process_dump_load() -> vaddr_to_paddr() ->
|
||||
vtop4_x86_64() -> readmem() -> cache_search()
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
---
|
||||
makedumpfile.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c
|
||||
index 6942047199de..3b8e9810468d 100644
|
||||
--- a/makedumpfile-1.6.1/makedumpfile.c
|
||||
+++ b/makedumpfile-1.6.1/makedumpfile.c
|
||||
@@ -3878,6 +3878,9 @@ initial(void)
|
||||
if (!get_value_for_old_linux())
|
||||
return FALSE;
|
||||
|
||||
+ if (!is_xen_memory() && !cache_init())
|
||||
+ return FALSE;
|
||||
+
|
||||
if (info->flag_mem_usage && !get_kcore_dump_loads())
|
||||
return FALSE;
|
||||
|
||||
@@ -4000,9 +4003,6 @@ out:
|
||||
}
|
||||
}
|
||||
|
||||
- if (!is_xen_memory() && !cache_init())
|
||||
- return FALSE;
|
||||
-
|
||||
if (debug_info && !get_machdep_info())
|
||||
return FALSE;
|
||||
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,45 @@
|
||||
From 4c53423b995463067fbbd394e724b4d1d6ea3d62 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <4c53423b995463067fbbd394e724b4d1d6ea3d62.1489471500.git.panand@redhat.com>
|
||||
In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Baoquan He <bhe@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:19 +0900
|
||||
Subject: [PATCH 5/7] [PATCH v3 5/7] makedumpfile: Correct the calculation of
|
||||
kvaddr in set_kcore_vmcoreinfo
|
||||
|
||||
In set_kcore_vmcoreinfo, we calculate the virtual address of vmcoreinfo
|
||||
by OR operation as below:
|
||||
|
||||
kvaddr = (ulong)vmcoreinfo_addr | PAGE_OFFSET;
|
||||
|
||||
When mm sections kaslr is not enabled, this is correct since the
|
||||
starting address of direct mapping section is 0xffff880000000000 which
|
||||
is 1T aligned. Usually system with memory below 1T won't cause problem.
|
||||
|
||||
However with mm section kaslr enabled, the starting address of direct
|
||||
mapping is 1G aligned. The above code makes kvaddr unsure.
|
||||
|
||||
So change it to adding operation:
|
||||
kvaddr = (ulong)vmcoreinfo_addr + PAGE_OFFSET;
|
||||
|
||||
Signed-off-by: Baoquan He <bhe@redhat.com>
|
||||
---
|
||||
elf_info.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/elf_info.c b/makedumpfile-1.6.1/elf_info.c
|
||||
index c5743b3cab28..100272f83c48 100644
|
||||
--- a/makedumpfile-1.6.1/elf_info.c
|
||||
+++ b/makedumpfile-1.6.1/elf_info.c
|
||||
@@ -372,7 +372,7 @@ int set_kcore_vmcoreinfo(uint64_t vmcoreinfo_addr, uint64_t vmcoreinfo_len)
|
||||
off_t offset_desc;
|
||||
|
||||
offset = UNINITIALIZED;
|
||||
- kvaddr = (ulong)vmcoreinfo_addr | PAGE_OFFSET;
|
||||
+ kvaddr = (ulong)vmcoreinfo_addr + PAGE_OFFSET;
|
||||
|
||||
for (i = 0; i < num_pt_loads; ++i) {
|
||||
struct pt_load_segment *p = &pt_loads[i];
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,57 @@
|
||||
From f3ff8c6232de43fa2cc60f5ca0f233cf8eb8d2ad Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <f3ff8c6232de43fa2cc60f5ca0f233cf8eb8d2ad.1489471500.git.panand@redhat.com>
|
||||
In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Baoquan He <bhe@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:23 +0900
|
||||
Subject: [PATCH 6/7] [PATCH v3 6/7] makedumpfile: Discard process_dump_load
|
||||
|
||||
Kernel commit 464920104bf7 (/proc/kcore: update physical address for
|
||||
kcore ram and text) provides physical address of direct mapping kcore
|
||||
program segments. So no need to calculate it specifically now. And the
|
||||
old code is not correct since it calls vaddr_to_paddr() which has not
|
||||
been ready at that time.
|
||||
|
||||
Signed-off-by: Baoquan He <bhe@redhat.com>
|
||||
---
|
||||
elf_info.c | 17 -----------------
|
||||
1 file changed, 17 deletions(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/elf_info.c b/makedumpfile-1.6.1/elf_info.c
|
||||
index 100272f83c48..8e2437622141 100644
|
||||
--- a/makedumpfile-1.6.1/elf_info.c
|
||||
+++ b/makedumpfile-1.6.1/elf_info.c
|
||||
@@ -857,22 +857,6 @@ static int exclude_segment(struct pt_load_segment **pt_loads,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static int
|
||||
-process_dump_load(struct pt_load_segment *pls)
|
||||
-{
|
||||
- unsigned long long paddr;
|
||||
-
|
||||
- paddr = vaddr_to_paddr(pls->virt_start);
|
||||
- pls->phys_start = paddr;
|
||||
- pls->phys_end = paddr + (pls->virt_end - pls->virt_start);
|
||||
- DEBUG_MSG("process_dump_load\n");
|
||||
- DEBUG_MSG(" phys_start : %llx\n", pls->phys_start);
|
||||
- DEBUG_MSG(" phys_end : %llx\n", pls->phys_end);
|
||||
- DEBUG_MSG(" virt_start : %llx\n", pls->virt_start);
|
||||
- DEBUG_MSG(" virt_end : %llx\n", pls->virt_end);
|
||||
-
|
||||
- return TRUE;
|
||||
-}
|
||||
|
||||
int get_kcore_dump_loads(void)
|
||||
{
|
||||
@@ -917,7 +901,6 @@ int get_kcore_dump_loads(void)
|
||||
}
|
||||
|
||||
pls[j] = *p;
|
||||
- process_dump_load(&pls[j]);
|
||||
j++;
|
||||
}
|
||||
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,84 @@
|
||||
From 78cbb4035209add81563c00ba46d237f86b8c427 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <78cbb4035209add81563c00ba46d237f86b8c427.1489471500.git.panand@redhat.com>
|
||||
In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:25 +0900
|
||||
Subject: [PATCH 7/7] [PATCH v3 7/7] mem-usage: allow to work only with -f for
|
||||
kernel version < 4.11
|
||||
|
||||
PT_LOAD of kcore does not have valid p_paddr values for kernel version
|
||||
less that v4.11. Therefore, older kernel will no long work for mem-usage
|
||||
with current makedumpfile code. They can only work when they are patched
|
||||
with fix to "update physical address for kcore ram and text".
|
||||
|
||||
This patch fixes the makedumpfile so that it does not allow to work
|
||||
older kernel for --mem-usage until someone is sure that kernel is
|
||||
rightly patched and so uses -f in command line. It also updates man page
|
||||
and usage info accordingly.
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
---
|
||||
makedumpfile.8 | 9 ++++++++-
|
||||
makedumpfile.c | 6 ++++++
|
||||
print_info.c | 1 +
|
||||
3 files changed, 15 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/makedumpfile.8 b/makedumpfile-1.6.1/makedumpfile.8
|
||||
index 9069fb18cdb6..993236486e77 100644
|
||||
--- a/makedumpfile-1.6.1/makedumpfile.8
|
||||
+++ b/makedumpfile-1.6.1/makedumpfile.8
|
||||
@@ -235,13 +235,20 @@ the ELF format does not support compressed data.
|
||||
|
||||
.TP
|
||||
\fB\-f\fR
|
||||
-Force existing DUMPFILE to be overwritten.
|
||||
+Force existing DUMPFILE to be overwritten and mem-usage to work with older
|
||||
+kernel as well.
|
||||
.br
|
||||
.B Example:
|
||||
.br
|
||||
# makedumpfile \-f \-d 31 \-x vmlinux /proc/vmcore dumpfile
|
||||
.br
|
||||
This command overwrites \fIDUMPFILE\fR even if it already exists.
|
||||
+.br
|
||||
+# makedumpfile \-f \-\-mem\-usage /proc/kcore
|
||||
+.br
|
||||
+Kernel version lesser than v4.11 will not work with \-\-mem\-usage
|
||||
+functionality until it has been patched with upstream commit 464920104bf7.
|
||||
+Therefore if you have patched your older kernel then use \-f.
|
||||
|
||||
.TP
|
||||
\fB\-x\fR \fIVMLINUX\fR
|
||||
diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c
|
||||
index 3b8e9810468d..e3be1ab0a9ec 100644
|
||||
--- a/makedumpfile-1.6.1/makedumpfile.c
|
||||
+++ b/makedumpfile-1.6.1/makedumpfile.c
|
||||
@@ -11269,6 +11269,12 @@ main(int argc, char *argv[])
|
||||
MSG("Try `makedumpfile --help' for more information.\n");
|
||||
goto out;
|
||||
}
|
||||
+ if (info->kernel_version < KERNEL_VERSION(4, 11, 0) &&
|
||||
+ !info->flag_force) {
|
||||
+ MSG("mem-usage not supported for this kernel.\n");
|
||||
+ MSG("You can try with -f if your kernel's kcore has valid p_paddr\n");
|
||||
+ goto out;
|
||||
+ }
|
||||
|
||||
if (!show_mem_usage())
|
||||
goto out;
|
||||
diff --git a/makedumpfile-1.6.1/print_info.c b/makedumpfile-1.6.1/print_info.c
|
||||
index 392d863a4227..3c577d83cebb 100644
|
||||
--- a/makedumpfile-1.6.1/print_info.c
|
||||
+++ b/makedumpfile-1.6.1/print_info.c
|
||||
@@ -310,6 +310,7 @@ print_usage(void)
|
||||
MSG("\n");
|
||||
MSG(" [-f]:\n");
|
||||
MSG(" Overwrite DUMPFILE even if it already exists.\n");
|
||||
+ MSG(" Force mem-usage to work with older kernel as well.\n");
|
||||
MSG("\n");
|
||||
MSG(" [-h, --help]:\n");
|
||||
MSG(" Show help message and LZO/snappy support status (enabled/disabled).\n");
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,41 @@
|
||||
From 4b0bed3523a5f6c2c428d9dab3d27d4572207d52 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:08 +0900
|
||||
Subject: [PATCH 1/7] [PATCH v3 1/7] show_mem_usage(): calculate page offset
|
||||
after elf load
|
||||
|
||||
x86_64 calculated page offset from PT_LOAD headers. Therefore call
|
||||
get_page_offset() after get_elf_loads()
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
---
|
||||
makedumpfile.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/makedumpfile.c b/makedumpfile-1.6.1/makedumpfile.c
|
||||
index e69b6df9a9ee..6942047199de 100644
|
||||
--- a/makedumpfile-1.6.1/makedumpfile.c
|
||||
+++ b/makedumpfile-1.6.1/makedumpfile.c
|
||||
@@ -10944,15 +10944,15 @@ int show_mem_usage(void)
|
||||
|
||||
info->dump_level = MAX_DUMP_LEVEL;
|
||||
|
||||
- if (!get_page_offset())
|
||||
- return FALSE;
|
||||
-
|
||||
if (!open_files_for_creating_dumpfile())
|
||||
return FALSE;
|
||||
|
||||
if (!get_elf_loads(info->fd_memory, info->name_memory))
|
||||
return FALSE;
|
||||
|
||||
+ if (!get_page_offset())
|
||||
+ return FALSE;
|
||||
+
|
||||
if (!get_sys_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len))
|
||||
return FALSE;
|
||||
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,47 @@
|
||||
From f1363023b909df886eca5efcb64b78be9b8e6086 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <f1363023b909df886eca5efcb64b78be9b8e6086.1489471500.git.panand@redhat.com>
|
||||
In-Reply-To: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
References: <4b0bed3523a5f6c2c428d9dab3d27d4572207d52.1489471500.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Thu, 2 Mar 2017 17:37:13 +0900
|
||||
Subject: [PATCH 3/7] [PATCH v3 3/7] x86_64: check physical address in PT_LOAD
|
||||
for none direct mapped regions
|
||||
|
||||
A kcore PT_LOAD can have a section from vmalloc region. However,
|
||||
physical address in that header would be invalid (-1) after kernel
|
||||
commit 464920104bf7 (/proc/kcore: update physical address for kcore ram
|
||||
and text). Therefore, check for valid physical address while calculating
|
||||
page_offset or phys_offset.
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
---
|
||||
arch/x86_64.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/makedumpfile-1.6.1/arch/x86_64.c b/makedumpfile-1.6.1/arch/x86_64.c
|
||||
index 893cd516fc8b..e978a36f8878 100644
|
||||
--- a/makedumpfile-1.6.1/arch/x86_64.c
|
||||
+++ b/makedumpfile-1.6.1/arch/x86_64.c
|
||||
@@ -41,7 +41,8 @@ get_page_offset_x86_64(void)
|
||||
unsigned long long virt_start;
|
||||
|
||||
for (i = 0; get_pt_load(i, &phys_start, NULL, &virt_start, NULL); i++) {
|
||||
- if (virt_start < __START_KERNEL_map) {
|
||||
+ if (virt_start < __START_KERNEL_map
|
||||
+ && phys_start != NOT_PADDR) {
|
||||
info->page_offset = virt_start - phys_start;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -76,7 +77,8 @@ get_phys_base_x86_64(void)
|
||||
}
|
||||
|
||||
for (i = 0; get_pt_load(i, &phys_start, NULL, &virt_start, NULL); i++) {
|
||||
- if (virt_start >= __START_KERNEL_map) {
|
||||
+ if (virt_start >= __START_KERNEL_map
|
||||
+ && phys_start != NOT_PADDR) {
|
||||
|
||||
info->phys_base = phys_start -
|
||||
(virt_start & ~(__START_KERNEL_map));
|
||||
--
|
||||
2.9.3
|
||||
|
@ -0,0 +1,75 @@
|
||||
From fe667ab0567d5a5631809db2ce3476c83d312d21 Mon Sep 17 00:00:00 2001
|
||||
Message-Id: <fe667ab0567d5a5631809db2ce3476c83d312d21.1489504794.git.panand@redhat.com>
|
||||
From: Pratyush Anand <panand@redhat.com>
|
||||
Date: Tue, 14 Mar 2017 17:59:22 +0530
|
||||
Subject: [PATCH] x86/x86_64: Fix format warning with die()
|
||||
|
||||
Fedora koji uses gcc version 7.0.1-0.12.fc27, and it generates a build
|
||||
warning
|
||||
|
||||
kexec/arch/i386/kexec-elf-x86.c:299:3: error: format not a string
|
||||
literal and no format arguments [-Werror=format-security]
|
||||
die(error_msg);
|
||||
^~~
|
||||
cc1: some warnings being treated as errors
|
||||
|
||||
error_msg can have a format specifier as well in string. In such cases,
|
||||
if there is no other arguments for the format variable then code will
|
||||
try to access a non existing argument. Therefore, use 1st argument as
|
||||
format specifier for string print and pass error_msg as the string to be
|
||||
printed.
|
||||
|
||||
While doing that,also use const qualifier before "char *error_msg".
|
||||
|
||||
Signed-off-by: Pratyush Anand <panand@redhat.com>
|
||||
Signed-off-by: Simon Horman <horms@verge.net.au>
|
||||
---
|
||||
kexec/arch/i386/kexec-elf-x86.c | 4 ++--
|
||||
kexec/arch/x86_64/kexec-elf-x86_64.c | 4 ++--
|
||||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
|
||||
index de00dcb869d7..fedf031cdf4a 100644
|
||||
--- a/kexec/arch/i386/kexec-elf-x86.c
|
||||
+++ b/kexec/arch/i386/kexec-elf-x86.c
|
||||
@@ -91,7 +91,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
|
||||
char *command_line = NULL, *modified_cmdline = NULL;
|
||||
const char *append = NULL;
|
||||
char *tmp_cmdline = NULL;
|
||||
- char *error_msg = NULL;
|
||||
+ const char *error_msg = NULL;
|
||||
int result;
|
||||
int command_line_len;
|
||||
const char *ramdisk;
|
||||
@@ -296,6 +296,6 @@ out:
|
||||
free(command_line);
|
||||
free(modified_cmdline);
|
||||
if (error_msg)
|
||||
- die(error_msg);
|
||||
+ die("%s", error_msg);
|
||||
return result;
|
||||
}
|
||||
diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c
|
||||
index ae6569220bc8..ad2231193eb1 100644
|
||||
--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
|
||||
+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
|
||||
@@ -99,7 +99,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len,
|
||||
#define ARG_STYLE_NONE 2
|
||||
int opt;
|
||||
int result = 0;
|
||||
- char *error_msg = NULL;
|
||||
+ const char *error_msg = NULL;
|
||||
|
||||
/* See options.h and add any new options there too! */
|
||||
static const struct option options[] = {
|
||||
@@ -276,6 +276,6 @@ out:
|
||||
free(command_line);
|
||||
free(modified_cmdline);
|
||||
if (error_msg)
|
||||
- die(error_msg);
|
||||
+ die("%s", error_msg);
|
||||
return result;
|
||||
}
|
||||
--
|
||||
2.9.3
|
||||
|
@ -84,6 +84,16 @@ Obsoletes: diskdumputils netdump kexec-tools-eppic
|
||||
# Patches 601 onward are generic patches
|
||||
#
|
||||
Patch601: kexec-tools-2.0.3-disable-kexec-test.patch
|
||||
Patch602: kexec-tools-2.0.14-build_mem_phdrs-check-if-p_paddr-is-invalid.patch
|
||||
Patch603: kexec-tools-2.0.14-makedumpfile-show_mem_usage-calculate-page-offset-af.patch
|
||||
Patch604: kexec-tools-2.0.14-makedumpfile-initial-call-cache_init-a-bit-early.patch
|
||||
Patch605: kexec-tools-2.0.14-makedumpfile-x86_64-check-physical-address-in-PT_LOA.patch
|
||||
Patch606: kexec-tools-2.0.14-makedumpfile-elf_info-kcore-check-for-invalid-physic.patch
|
||||
Patch607: kexec-tools-2.0.14-makedumpfile-makedumpfile-Correct-the-calculation-of.patch
|
||||
Patch608: kexec-tools-2.0.14-makedumpfile-makedumpfile-Discard-process_dump_load.patch
|
||||
Patch609: kexec-tools-2.0.14-makedumpfile-mem-usage-allow-to-work-only-with-f-for.patch
|
||||
Patch610: kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch
|
||||
|
||||
|
||||
%description
|
||||
kexec-tools provides /sbin/kexec binary that facilitates a new
|
||||
@ -107,6 +117,15 @@ tar -z -x -v -f %{SOURCE19}
|
||||
tar -z -x -v -f %{SOURCE23}
|
||||
|
||||
%patch601 -p1
|
||||
%patch602 -p1
|
||||
%patch603 -p1
|
||||
%patch604 -p1
|
||||
%patch605 -p1
|
||||
%patch606 -p1
|
||||
%patch607 -p1
|
||||
%patch608 -p1
|
||||
%patch609 -p1
|
||||
%patch610 -p1
|
||||
|
||||
%ifarch ppc
|
||||
%define archdef ARCH=ppc
|
||||
|
Loading…
Reference in New Issue
Block a user