Fix the false positive error message when search /proc/kallsyms for kernel symbol
Subsystems (2)
PATCH v2 1/1 Fix the false positive error message when search /proc/kallsyms for kernel symbol
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.
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.
--- kexec/arch/i386/crashdump-x86.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-)
kexec/arch/i386/crashdump-x86.c +23 -18
@@ -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
Signature · 7 lines
2.5.5 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 6 lines · Baoquan He
Function
get_kernel_symin kexec will search/proc/kallsymsfor kernel symbol and print error message anyway if expected symbol is not found. Whilepage_offset_basedefinition 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.
Quoted 83 lines
So in this patch take out the error message from
get_kernel_symand put it whereget_kernel_symis called and expected symbol is not found.Signed-off-by Baoquan He <[email protected]>--- kexec/arch/i386/crashdump-x86.c | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-)kexec/arch/i386/crashdump-x86.c +23
-18@@ -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 Signature · 7 lines
2.5.5 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec