* [PATCH] Only search page_offset_base when KASLR mm code is compiled in
@ 2017-02-24 10:38 Baoquan He
2017-02-28 6:06 ` Dave Young
0 siblings, 1 reply; 3+ messages in thread
From: Baoquan He @ 2017-02-24 10:38 UTC (permalink / raw)
To: horms; +Cc: kexec, Baoquan He, piliu
Otherwise it will print false positve message as below. So add
a check when do the search.
"Cannot get kernel page_offset_base symbol address"
Signed-off-by: Baoquan He <bhe@redhat.com>
---
kexec/arch/i386/crashdump-x86.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 88aeee3..b2c1be5 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -150,8 +150,6 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
off_t size;
uint32_t elf_flags = 0;
uint64_t stext_sym;
- const unsigned long long pud_mask = ~((1 << 30) - 1);
- unsigned long long vaddr, lowest_vaddr = 0;
if (elf_info->machine != EM_X86_64)
return 0;
@@ -181,8 +179,11 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
end_phdr = &ehdr.e_phdr[ehdr.e_phnum];
+#ifdef CONFIG_RANDOMIZE_MEMORY
/* Search for the real PAGE_OFFSET when KASLR memory randomization
* is enabled */
+ const unsigned long long pud_mask = ~((1 << 30) - 1);
+ unsigned long long vaddr, lowest_vaddr = 0;
if (get_kernel_sym("page_offset_base") != 0) {
for(phdr = ehdr.e_phdr; phdr != end_phdr; phdr++) {
if (phdr->p_type == PT_LOAD) {
@@ -194,6 +195,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
if (lowest_vaddr != 0)
elf_info->page_offset = lowest_vaddr;
}
+#endif
/* Traverse through the Elf headers and find the region where
* _stext symbol is located in. That's where kernel is mapped */
--
2.5.5
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Only search page_offset_base when KASLR mm code is compiled in
2017-02-24 10:38 [PATCH] Only search page_offset_base when KASLR mm code is compiled in Baoquan He
@ 2017-02-28 6:06 ` Dave Young
2017-03-02 9:36 ` Baoquan He
0 siblings, 1 reply; 3+ messages in thread
From: Dave Young @ 2017-02-28 6:06 UTC (permalink / raw)
To: Baoquan He; +Cc: horms, kexec, piliu
On 02/24/17 at 06:38pm, Baoquan He wrote:
> Otherwise it will print false positve message as below. So add
> a check when do the search.
>
> "Cannot get kernel page_offset_base symbol address"
>
> Signed-off-by: Baoquan He <bhe@redhat.com>
> ---
> kexec/arch/i386/crashdump-x86.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
> index 88aeee3..b2c1be5 100644
> --- a/kexec/arch/i386/crashdump-x86.c
> +++ b/kexec/arch/i386/crashdump-x86.c
> @@ -150,8 +150,6 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
> off_t size;
> uint32_t elf_flags = 0;
> uint64_t stext_sym;
> - const unsigned long long pud_mask = ~((1 << 30) - 1);
> - unsigned long long vaddr, lowest_vaddr = 0;
>
> if (elf_info->machine != EM_X86_64)
> return 0;
> @@ -181,8 +179,11 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
>
> end_phdr = &ehdr.e_phdr[ehdr.e_phnum];
>
> +#ifdef CONFIG_RANDOMIZE_MEMORY
It does not work in userspace code.
Maybe mute the error message or move it to kexec --debug is more
reasonable..
> /* Search for the real PAGE_OFFSET when KASLR memory randomization
> * is enabled */
> + const unsigned long long pud_mask = ~((1 << 30) - 1);
> + unsigned long long vaddr, lowest_vaddr = 0;
> if (get_kernel_sym("page_offset_base") != 0) {
> for(phdr = ehdr.e_phdr; phdr != end_phdr; phdr++) {
> if (phdr->p_type == PT_LOAD) {
> @@ -194,6 +195,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
> if (lowest_vaddr != 0)
> elf_info->page_offset = lowest_vaddr;
> }
> +#endif
>
> /* Traverse through the Elf headers and find the region where
> * _stext symbol is located in. That's where kernel is mapped */
> --
> 2.5.5
>
>
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
Thanks
Dave
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Only search page_offset_base when KASLR mm code is compiled in
2017-02-28 6:06 ` Dave Young
@ 2017-03-02 9:36 ` Baoquan He
0 siblings, 0 replies; 3+ messages in thread
From: Baoquan He @ 2017-03-02 9:36 UTC (permalink / raw)
To: Dave Young; +Cc: horms, kexec, piliu
On 02/28/17 at 02:06pm, Dave Young wrote:
> On 02/24/17 at 06:38pm, Baoquan He wrote:
> > Otherwise it will print false positve message as below. So add
> > a check when do the search.
> >
> > "Cannot get kernel page_offset_base symbol address"
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > ---
> > kexec/arch/i386/crashdump-x86.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
> > index 88aeee3..b2c1be5 100644
> > --- a/kexec/arch/i386/crashdump-x86.c
> > +++ b/kexec/arch/i386/crashdump-x86.c
> > @@ -150,8 +150,6 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
> > off_t size;
> > uint32_t elf_flags = 0;
> > uint64_t stext_sym;
> > - const unsigned long long pud_mask = ~((1 << 30) - 1);
> > - unsigned long long vaddr, lowest_vaddr = 0;
> >
> > if (elf_info->machine != EM_X86_64)
> > return 0;
> > @@ -181,8 +179,11 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
> >
> > end_phdr = &ehdr.e_phdr[ehdr.e_phnum];
> >
> > +#ifdef CONFIG_RANDOMIZE_MEMORY
>
> It does not work in userspace code.
Could be it only works when make header and install. Otherwise it can't
be seen by user space. I built a rhel kernel package and test passed.
Anyway, since it doesn't work in all cases, I have made another way to
fix it, just take out the error message and put it where get_kernel_sym
is called.
>
> Maybe mute the error message or move it to kexec --debug is more
> reasonable..
>
> > /* Search for the real PAGE_OFFSET when KASLR memory randomization
> > * is enabled */
> > + const unsigned long long pud_mask = ~((1 << 30) - 1);
> > + unsigned long long vaddr, lowest_vaddr = 0;
> > if (get_kernel_sym("page_offset_base") != 0) {
> > for(phdr = ehdr.e_phdr; phdr != end_phdr; phdr++) {
> > if (phdr->p_type == PT_LOAD) {
> > @@ -194,6 +195,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info),
> > if (lowest_vaddr != 0)
> > elf_info->page_offset = lowest_vaddr;
> > }
> > +#endif
> >
> > /* Traverse through the Elf headers and find the region where
> > * _stext symbol is located in. That's where kernel is mapped */
> > --
> > 2.5.5
> >
> >
> > _______________________________________________
> > kexec mailing list
> > kexec@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/kexec
>
> Thanks
> Dave
>
> _______________________________________________
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-02 9:37 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-24 10:38 [PATCH] Only search page_offset_base when KASLR mm code is compiled in Baoquan He
2017-02-28 6:06 ` Dave Young
2017-03-02 9:36 ` Baoquan He
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox