Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1538359 > unrolled thread

[PATCH 0/2] Determine kernel text mapping size at runtime for x86_64

Started byBaoquan He <bhe@redhat.com>
First post2016-12-08 09:00 +0100
Last post2016-12-10 02:40 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64 Baoquan He <bhe@redhat.com> - 2016-12-08 09:00 +0100
    Re: [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64 Kees Cook <keescook@chromium.org> - 2016-12-08 19:40 +0100
      Re: [PATCH 0/2] Determine kernel text mapping size at runtime for  x86_64 Dave Anderson <anderson@redhat.com> - 2016-12-08 20:10 +0100
        Re: [PATCH 0/2] Determine kernel text mapping size at runtime for  x86_64 Baoquan He <bhe@redhat.com> - 2016-12-10 02:40 +0100

#1538359 — [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64

FromBaoquan He <bhe@redhat.com>
Date2016-12-08 09:00 +0100
Subject[PATCH 0/2] Determine kernel text mapping size at runtime for x86_64
Message-ID<sM1Mt-3ja-11@gated-at.bofh.it>
Dave Anderson ever told in Crash utility he makes judgement whether it's
a kaslr kernel by size of KERNEL_IMAGE_SIZE. As long as it's 1G, it's
recognized as kaslr. Then the current upstream kernel has a wrong behaviour,
it sets KERNEL_IMAGE_SIZE as 1G as long as CONFIG_RANDOMIZE_BASE is enabled,
though people specify "nokaslr" into cmdline to disable kaslr explicitly.

So in this patchset, made changes to determine the size of kernel text mapping
area at runtime. If "nokaslr" specified, kernel mapping size is 512M though
CONFIG_RANDOMIZE_BASE is enabled.

Baoquan He (2):
  x86/64: Make kernel text mapping always take one whole page table in
    early boot code
  x86/KASLR/64: Determine kernel text mapping size at runtime

 arch/x86/boot/compressed/kaslr.c        | 15 ++++++++++-----
 arch/x86/include/asm/kaslr.h            |  1 +
 arch/x86/include/asm/page_64_types.h    | 20 ++++++++++++--------
 arch/x86/include/asm/pgtable_64_types.h |  2 +-
 arch/x86/kernel/head64.c                | 11 ++++++-----
 arch/x86/kernel/head_64.S               | 16 +++++++++-------
 arch/x86/mm/dump_pagetables.c           |  3 ++-
 arch/x86/mm/init_64.c                   |  2 +-
 arch/x86/mm/physaddr.c                  |  6 +++---
 9 files changed, 45 insertions(+), 31 deletions(-)

-- 
2.5.5

[toc] | [next] | [standalone]


#1538797

FromKees Cook <keescook@chromium.org>
Date2016-12-08 19:40 +0100
Message-ID<sMbLP-14G-29@gated-at.bofh.it>
In reply to#1538359
On Wed, Dec 7, 2016 at 11:56 PM, Baoquan He <bhe@redhat.com> wrote:
> Dave Anderson ever told in Crash utility he makes judgement whether it's
> a kaslr kernel by size of KERNEL_IMAGE_SIZE. As long as it's 1G, it's
> recognized as kaslr. Then the current upstream kernel has a wrong behaviour,
> it sets KERNEL_IMAGE_SIZE as 1G as long as CONFIG_RANDOMIZE_BASE is enabled,
> though people specify "nokaslr" into cmdline to disable kaslr explicitly.

I'm not sure that's the correct solution to the Crash utility -- the
kaslr-ness of a kernel should be already exposed in the dump with the
kaslr_enabled variable yes?

> So in this patchset, made changes to determine the size of kernel text mapping
> area at runtime. If "nokaslr" specified, kernel mapping size is 512M though
> CONFIG_RANDOMIZE_BASE is enabled.

This seems to make the non-KASLR case more consistent, so I'm fine
with the idea. Once the build-bots are happy with everything, consider
the series:

Acked-by: Kees Cook <keescook@chromium.org>

Thanks!

-Kees

>
> Baoquan He (2):
>   x86/64: Make kernel text mapping always take one whole page table in
>     early boot code
>   x86/KASLR/64: Determine kernel text mapping size at runtime
>
>  arch/x86/boot/compressed/kaslr.c        | 15 ++++++++++-----
>  arch/x86/include/asm/kaslr.h            |  1 +
>  arch/x86/include/asm/page_64_types.h    | 20 ++++++++++++--------
>  arch/x86/include/asm/pgtable_64_types.h |  2 +-
>  arch/x86/kernel/head64.c                | 11 ++++++-----
>  arch/x86/kernel/head_64.S               | 16 +++++++++-------
>  arch/x86/mm/dump_pagetables.c           |  3 ++-
>  arch/x86/mm/init_64.c                   |  2 +-
>  arch/x86/mm/physaddr.c                  |  6 +++---
>  9 files changed, 45 insertions(+), 31 deletions(-)
>
> --
> 2.5.5
>



-- 
Kees Cook
Nexus Security

[toc] | [prev] | [next] | [standalone]


#1538816 — Re: [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64

FromDave Anderson <anderson@redhat.com>
Date2016-12-08 20:10 +0100
SubjectRe: [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64
Message-ID<sMceR-1um-15@gated-at.bofh.it>
In reply to#1538797

----- Original Message -----
> On Wed, Dec 7, 2016 at 11:56 PM, Baoquan He <bhe@redhat.com> wrote:
> > Dave Anderson ever told in Crash utility he makes judgement whether it's
> > a kaslr kernel by size of KERNEL_IMAGE_SIZE. As long as it's 1G, it's
> > recognized as kaslr. Then the current upstream kernel has a wrong behaviour,
> > it sets KERNEL_IMAGE_SIZE as 1G as long as CONFIG_RANDOMIZE_BASE is enabled,
> > though people specify "nokaslr" into cmdline to disable kaslr explicitly.
> 
> I'm not sure that's the correct solution to the Crash utility -- the
> kaslr-ness of a kernel should be already exposed in the dump with the
> kaslr_enabled variable yes?

The crash utility doesn't use KERNEL_IMAGE_SIZE to determine whether
KASLR is in play, but rather to determine the base of the modules virtual
address space (i.e, the same way the kernel does).  And then it uses that
value in a couple other places.

Dave


> 
> > So in this patchset, made changes to determine the size of kernel text
> > mapping
> > area at runtime. If "nokaslr" specified, kernel mapping size is 512M though
> > CONFIG_RANDOMIZE_BASE is enabled.
> 
> This seems to make the non-KASLR case more consistent, so I'm fine
> with the idea. Once the build-bots are happy with everything, consider
> the series:
> 
> Acked-by: Kees Cook <keescook@chromium.org>
> 
> Thanks!
> 
> -Kees
> 
> >
> > Baoquan He (2):
> >   x86/64: Make kernel text mapping always take one whole page table in
> >     early boot code
> >   x86/KASLR/64: Determine kernel text mapping size at runtime
> >
> >  arch/x86/boot/compressed/kaslr.c        | 15 ++++++++++-----
> >  arch/x86/include/asm/kaslr.h            |  1 +
> >  arch/x86/include/asm/page_64_types.h    | 20 ++++++++++++--------
> >  arch/x86/include/asm/pgtable_64_types.h |  2 +-
> >  arch/x86/kernel/head64.c                | 11 ++++++-----
> >  arch/x86/kernel/head_64.S               | 16 +++++++++-------
> >  arch/x86/mm/dump_pagetables.c           |  3 ++-
> >  arch/x86/mm/init_64.c                   |  2 +-
> >  arch/x86/mm/physaddr.c                  |  6 +++---
> >  9 files changed, 45 insertions(+), 31 deletions(-)
> >
> > --
> > 2.5.5
> >
> 
> 
> 
> --
> Kees Cook
> Nexus Security
> 

[toc] | [prev] | [next] | [standalone]


#1539752 — Re: [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64

FromBaoquan He <bhe@redhat.com>
Date2016-12-10 02:40 +0100
SubjectRe: [PATCH 0/2] Determine kernel text mapping size at runtime for x86_64
Message-ID<sMENP-2b6-1@gated-at.bofh.it>
In reply to#1538816
On 12/08/16 at 02:00pm, Dave Anderson wrote:
> 
> 
> ----- Original Message -----
> > On Wed, Dec 7, 2016 at 11:56 PM, Baoquan He <bhe@redhat.com> wrote:
> > > Dave Anderson ever told in Crash utility he makes judgement whether it's
> > > a kaslr kernel by size of KERNEL_IMAGE_SIZE. As long as it's 1G, it's
> > > recognized as kaslr. Then the current upstream kernel has a wrong behaviour,
> > > it sets KERNEL_IMAGE_SIZE as 1G as long as CONFIG_RANDOMIZE_BASE is enabled,
> > > though people specify "nokaslr" into cmdline to disable kaslr explicitly.
> > 
> > I'm not sure that's the correct solution to the Crash utility -- the
> > kaslr-ness of a kernel should be already exposed in the dump with the
> > kaslr_enabled variable yes?
> 
> The crash utility doesn't use KERNEL_IMAGE_SIZE to determine whether
> KASLR is in play, but rather to determine the base of the modules virtual
> address space (i.e, the same way the kernel does).  And then it uses that
> value in a couple other places.

Then I got it wrong.

The current code makes it the same:

#define MODULES_VADDR    (__START_KERNEL_map + KERNEL_IMAGE_SIZE)

With change, Crash doesn't need to change.

Thanks
Baoquan

> 
> 
> > 
> > > So in this patchset, made changes to determine the size of kernel text
> > > mapping
> > > area at runtime. If "nokaslr" specified, kernel mapping size is 512M though
> > > CONFIG_RANDOMIZE_BASE is enabled.
> > 
> > This seems to make the non-KASLR case more consistent, so I'm fine
> > with the idea. Once the build-bots are happy with everything, consider
> > the series:
> > 
> > Acked-by: Kees Cook <keescook@chromium.org>
> > 
> > Thanks!
> > 
> > -Kees
> > 
> > >
> > > Baoquan He (2):
> > >   x86/64: Make kernel text mapping always take one whole page table in
> > >     early boot code
> > >   x86/KASLR/64: Determine kernel text mapping size at runtime
> > >
> > >  arch/x86/boot/compressed/kaslr.c        | 15 ++++++++++-----
> > >  arch/x86/include/asm/kaslr.h            |  1 +
> > >  arch/x86/include/asm/page_64_types.h    | 20 ++++++++++++--------
> > >  arch/x86/include/asm/pgtable_64_types.h |  2 +-
> > >  arch/x86/kernel/head64.c                | 11 ++++++-----
> > >  arch/x86/kernel/head_64.S               | 16 +++++++++-------
> > >  arch/x86/mm/dump_pagetables.c           |  3 ++-
> > >  arch/x86/mm/init_64.c                   |  2 +-
> > >  arch/x86/mm/physaddr.c                  |  6 +++---
> > >  9 files changed, 45 insertions(+), 31 deletions(-)
> > >
> > > --
> > > 2.5.5
> > >
> > 
> > 
> > 
> > --
> > Kees Cook
> > Nexus Security
> > 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web