Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: horms@verge.net.au
Cc: kexec@lists.infradead.org, dyoung@redhat.com
Subject: Re: [PATCH v2] Fix the false positive error message when search /proc/kallsyms for kernel symbol
Date: Fri, 3 Mar 2017 09:02:18 +0800	[thread overview]
Message-ID: <20170303010218.GA24001@x1> (raw)
In-Reply-To: <1488447581-16465-1-git-send-email-bhe@redhat.com>

On 03/02/17 at 05:39pm, Baoquan He wrote:
> Function get_kernel_sym in kexec will search /proc/kallsyms for
> kernel symbol and print error message anyway if expected symbol
> is not found. While page_offset_base definition and exporting
> codes are only available when mm KASLR code is compiled in kernel.
> Otherwise search will fail and print out error message, obviously
> this is false positive warning.

This doesn't work, I must have been dizzy yesterday, NACK it. Will
repost with a new one.

> 
> So in this patch take out the error message from get_kernel_sym and
> put it where get_kernel_sym is called and expected symbol is not found.
> 
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
>  kexec/arch/i386/crashdump-x86.c | 41 +++++++++++++++++++++++------------------
>  1 file changed, 23 insertions(+), 18 deletions(-)
> 
> diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
> index 88aeee3..b9adc8c 100644
> --- a/kexec/arch/i386/crashdump-x86.c
> +++ b/kexec/arch/i386/crashdump-x86.c
> @@ -127,7 +127,6 @@ static unsigned long long get_kernel_sym(const char *symbol)
>  		}
>  	}
>  
> -	fprintf(stderr, "Cannot get kernel %s symbol address\n", symbol);
>  	return 0;
>  }
>  
> @@ -193,30 +192,36 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
>  		}
>  		if (lowest_vaddr != 0)
>  			elf_info->page_offset = lowest_vaddr;
> +	} else {
> +		fprintf(stderr, "Cannot get kernel page_offset_base symbol address\n");
>  	}
>  
>  	/* Traverse through the Elf headers and find the region where
>  	 * _stext symbol is located in. That's where kernel is mapped */
>  	stext_sym = get_kernel_sym("_stext");
> -	for(phdr = ehdr.e_phdr; stext_sym && phdr != end_phdr; phdr++) {
> -		if (phdr->p_type == PT_LOAD) {
> -			unsigned long long saddr = phdr->p_vaddr;
> -			unsigned long long eaddr = phdr->p_vaddr + phdr->p_memsz;
> -			unsigned long long size;
> -
> -			/* Look for kernel text mapping header. */
> -			if (saddr <= stext_sym && eaddr > stext_sym) {
> -				saddr = _ALIGN_DOWN(saddr, X86_64_KERN_VADDR_ALIGN);
> -				elf_info->kern_vaddr_start = saddr;
> -				size = eaddr - saddr;
> -				/* Align size to page size boundary. */
> -				size = _ALIGN(size, align);
> -				elf_info->kern_size = size;
> -				dbgprintf("kernel vaddr = 0x%llx size = 0x%llx\n",
> -					saddr, size);
> -				return 0;
> +	if (stext_sym) {
> +		for(phdr = ehdr.e_phdr; stext_sym && phdr != end_phdr; phdr++) {
> +			if (phdr->p_type == PT_LOAD) {
> +				unsigned long long saddr = phdr->p_vaddr;
> +				unsigned long long eaddr = phdr->p_vaddr + phdr->p_memsz;
> +				unsigned long long size;
> +
> +				/* Look for kernel text mapping header. */
> +				if (saddr <= stext_sym && eaddr > stext_sym) {
> +					saddr = _ALIGN_DOWN(saddr, X86_64_KERN_VADDR_ALIGN);
> +					elf_info->kern_vaddr_start = saddr;
> +					size = eaddr - saddr;
> +					/* Align size to page size boundary. */
> +					size = _ALIGN(size, align);
> +					elf_info->kern_size = size;
> +					dbgprintf("kernel vaddr = 0x%llx size = 0x%llx\n",
> +						saddr, size);
> +					return 0;
> +				}
>  			}
>  		}
> +	} else {
> +		fprintf(stderr, "Cannot get kernel _stext symbol address\n");
>  	}
>  
>  	/* If failed to retrieve kernel text mapping through
> -- 
> 2.5.5
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

      reply	other threads:[~2017-03-03  1:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-02  9:39 [PATCH v2] Fix the false positive error message when search /proc/kallsyms for kernel symbol Baoquan He
2017-03-03  1:02 ` Baoquan He [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170303010218.GA24001@x1 \
    --to=bhe@redhat.com \
    --cc=dyoung@redhat.com \
    --cc=horms@verge.net.au \
    --cc=kexec@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox