linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] security: CONFIG_HARDENED_USERCOPY does not need to select BUG
@ 2018-06-29 20:04 Kamal Mostafa
  2018-06-29 20:27 ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Kamal Mostafa @ 2018-06-29 20:04 UTC (permalink / raw)
  To: linux-kernel, Kees Cook
  Cc: Kamal Mostafa, James Morris, Serge E. Hallyn,
	open list:SECURITY SUBSYSTEM

Allows for CONFIG_HARDENED_USERCOPY without CONFIG_BUG.

Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 security/Kconfig | 1 -
 1 file changed, 1 deletion(-)

diff --git a/security/Kconfig b/security/Kconfig
index c430206..7667774 100644
--- a/security/Kconfig
+++ b/security/Kconfig
@@ -153,7 +153,6 @@ config HAVE_HARDENED_USERCOPY_ALLOCATOR
 config HARDENED_USERCOPY
 	bool "Harden memory copies between kernel and userspace"
 	depends on HAVE_HARDENED_USERCOPY_ALLOCATOR
-	select BUG
 	imply STRICT_DEVMEM
 	help
 	  This option checks for obviously wrong memory regions when
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] security: CONFIG_HARDENED_USERCOPY does not need to select BUG
  2018-06-29 20:04 [PATCH] security: CONFIG_HARDENED_USERCOPY does not need to select BUG Kamal Mostafa
@ 2018-06-29 20:27 ` Kees Cook
  2018-07-02 20:14   ` Kamal Mostafa
  0 siblings, 1 reply; 4+ messages in thread
From: Kees Cook @ 2018-06-29 20:27 UTC (permalink / raw)
  To: Kamal Mostafa
  Cc: LKML, James Morris, Serge E. Hallyn, open list:SECURITY SUBSYSTEM

On Fri, Jun 29, 2018 at 1:04 PM, Kamal Mostafa <kamal@canonical.com> wrote:
> Allows for CONFIG_HARDENED_USERCOPY without CONFIG_BUG.
>
> Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> ---
>  security/Kconfig | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/security/Kconfig b/security/Kconfig
> index c430206..7667774 100644
> --- a/security/Kconfig
> +++ b/security/Kconfig
> @@ -153,7 +153,6 @@ config HAVE_HARDENED_USERCOPY_ALLOCATOR
>  config HARDENED_USERCOPY
>         bool "Harden memory copies between kernel and userspace"
>         depends on HAVE_HARDENED_USERCOPY_ALLOCATOR
> -       select BUG
>         imply STRICT_DEVMEM
>         help
>           This option checks for obviously wrong memory regions when

Do the lkdtm tests for usercopy correctly halt the kernel thread if
CONFIG_BUG is removed?

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] security: CONFIG_HARDENED_USERCOPY does not need to select BUG
  2018-06-29 20:27 ` Kees Cook
@ 2018-07-02 20:14   ` Kamal Mostafa
  2018-07-02 20:46     ` Kees Cook
  0 siblings, 1 reply; 4+ messages in thread
From: Kamal Mostafa @ 2018-07-02 20:14 UTC (permalink / raw)
  To: Kees Cook
  Cc: LKML, James Morris, Serge E. Hallyn, open list:SECURITY SUBSYSTEM

On Fri, Jun 29, 2018 at 01:27:08PM -0700, Kees Cook wrote:
> On Fri, Jun 29, 2018 at 1:04 PM, Kamal Mostafa <kamal@canonical.com> wrote:
> > Allows for CONFIG_HARDENED_USERCOPY without CONFIG_BUG.
> >
> > Signed-off-by: Kamal Mostafa <kamal@canonical.com>
> > ---
> >  security/Kconfig | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/security/Kconfig b/security/Kconfig
> > index c430206..7667774 100644
> > --- a/security/Kconfig
> > +++ b/security/Kconfig
> > @@ -153,7 +153,6 @@ config HAVE_HARDENED_USERCOPY_ALLOCATOR
> >  config HARDENED_USERCOPY
> >         bool "Harden memory copies between kernel and userspace"
> >         depends on HAVE_HARDENED_USERCOPY_ALLOCATOR
> > -       select BUG
> >         imply STRICT_DEVMEM
> >         help
> >           This option checks for obviously wrong memory regions when
> 
> Do the lkdtm tests for usercopy correctly halt the kernel thread if
> CONFIG_BUG is removed?
> 

Yes, they do...

With this config (specifically disabling 'FALLBACK'):

    CONFIG_HARDENED_USERCOPY=y
    # CONFIG_HARDENED_USERCOPY_FALLBACK is not set
    # CONFIG_BUG is not set

I ran the usercopy tests as follows:

    modprobe lkdtm
    cd /sys/kernel/debug/provoke-crash
    cat DIRECT | grep USERCOPY | while read x ; do echo $x | tee DIRECT || echo $?; done

Resulting in this command line output:

    USERCOPY_HEAP_SIZE_TO
    139
    USERCOPY_HEAP_SIZE_FROM
    139
    USERCOPY_HEAP_WHITELIST_TO
    139
    USERCOPY_HEAP_WHITELIST_FROM
    139
    USERCOPY_STACK_FRAME_TO
    139
    USERCOPY_STACK_FRAME_FROM
    139
    USERCOPY_STACK_BEYOND
    139
    USERCOPY_KERNEL
    139

Each test case yields kernel log output like:

    lkdtm: Performing direct entry USERCOPY_HEAP_SIZE_TO
    lkdtm: attempting good copy_to_user of correct size
    lkdtm: attempting bad copy_to_user of too large size
    usercopy: Kernel memory exposure attempt detected from SLUB object 'kmalloc-1024' (offset 16, size 1024)!
    invalid opcode: 0000 [#17] SMP PTI
    ... {panic dump} ...

Each 'tee' gets terminated with SIGSEGV and no instances appear of the
lkdtm/usercopy.c warning "copy_{to/from}_user failed, but lacked Oops".

If I leave CONFIG_HARDENED_USERCOPY_FALLBACK=y then the pair of
WHITELIST tests don't trigger a panic or SIGSEGV, as expected.

 -Kamal

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] security: CONFIG_HARDENED_USERCOPY does not need to select BUG
  2018-07-02 20:14   ` Kamal Mostafa
@ 2018-07-02 20:46     ` Kees Cook
  0 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2018-07-02 20:46 UTC (permalink / raw)
  To: Kamal Mostafa
  Cc: LKML, James Morris, Serge E. Hallyn, open list:SECURITY SUBSYSTEM

Hi Kamal,

On Mon, Jul 2, 2018 at 1:14 PM, Kamal Mostafa <kamal@canonical.com> wrote:
> On Fri, Jun 29, 2018 at 01:27:08PM -0700, Kees Cook wrote:
>> Do the lkdtm tests for usercopy correctly halt the kernel thread if
>> CONFIG_BUG is removed?
>
> Yes, they do...

Perfect, thanks for double-checking! I'll apply this to my tree.

-Kees

-- 
Kees Cook
Pixel Security

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-02 20:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-29 20:04 [PATCH] security: CONFIG_HARDENED_USERCOPY does not need to select BUG Kamal Mostafa
2018-06-29 20:27 ` Kees Cook
2018-07-02 20:14   ` Kamal Mostafa
2018-07-02 20:46     ` Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).