From 60cf280ebfe8b6468bfd1dd592a117e719c56ccf Mon Sep 17 00:00:00 2001 From: Kazuhito Hagio Date: Fri, 3 Jan 2020 11:27:41 -0500 Subject: [PATCH 2/3] [PATCH] Pass 0 to get_kaslr_offset() in find_kaslr_offsets() Currently SYMBOL(_stext) is passed to get_kaslr_offset() in find_kaslr_offsets(), but it is always zero, because it has not been set yet at the time. On the other hand, the vaddr argument of get_kaslr_offset() is only used to decide whether to return a KASLR offset or not, but the return value is not used in find_kaslr_offsets(). Therefore, passing SYMBOL(_stext) is meaningless and confusing, so let's pass it 0 explicitly to avoid confusion. Reported-by: Lianbo Jiang Signed-off-by: Kazuhito Hagio --- arch/x86_64.c | 2 +- makedumpfile.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/makedumpfile-1.6.6/arch/x86_64.c b/makedumpfile-1.6.6/arch/x86_64.c index 7a2c05c36809..b5e295452964 100644 --- a/makedumpfile-1.6.6/arch/x86_64.c +++ b/makedumpfile-1.6.6/arch/x86_64.c @@ -69,7 +69,7 @@ get_kaslr_offset_x86_64(unsigned long vaddr) strtoul(buf+strlen(STR_KERNELOFFSET),&endp,16); } } - if (!info->kaslr_offset) + if (!info->kaslr_offset || !vaddr) return 0; if (NUMBER(KERNEL_IMAGE_SIZE) != NOT_FOUND_NUMBER) diff --git a/makedumpfile-1.6.6/makedumpfile.c b/makedumpfile-1.6.6/makedumpfile.c index 332b804cd756..e290fbdb4f9f 100644 --- a/makedumpfile-1.6.6/makedumpfile.c +++ b/makedumpfile-1.6.6/makedumpfile.c @@ -3975,7 +3975,7 @@ get_kaslr_offset_general(unsigned long vaddr) } } } - if (!info->kaslr_offset) + if (!info->kaslr_offset || !vaddr) return 0; if (_text == NOT_FOUND_SYMBOL) { @@ -4032,8 +4032,10 @@ find_kaslr_offsets() * function might need to read from vmcoreinfo, therefore we have * called this function between open_vmcoreinfo() and * close_vmcoreinfo() + * And the argument is not needed, because we don't use the return + * value here. So pass it 0 explicitly. */ - get_kaslr_offset(SYMBOL(_stext)); + get_kaslr_offset(0); close_vmcoreinfo(); -- 2.17.1