kexec-tools/kexec-tools-2.0.14-x86-x86_64-Fix-format-warning-with-die.patch
Pratyush Anand 86a81de3e5 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>
2017-03-17 10:14:17 +08:00

76 lines
2.5 KiB
Diff

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