Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 24 May 2016 10:16:09 -0700
From: Kees Cook <keescook@...omium.org>
To: Emese Revfy <re.emese@...il.com>
Cc: "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, PaX Team <pageexec@...email.hu>, 
	Brad Spengler <spender@...ecurity.net>, Michal Marek <mmarek@...e.com>, 
	LKML <linux-kernel@...r.kernel.org>, 
	Masahiro Yamada <yamada.masahiro@...ionext.com>, linux-kbuild <linux-kbuild@...r.kernel.org>, 
	"Theodore Ts'o" <tytso@....edu>, Andrew Morton <akpm@...ux-foundation.org>, Linux-MM <linux-mm@...ck.org>, 
	Jens Axboe <axboe@...nel.dk>, Al Viro <viro@...iv.linux.org.uk>, 
	Paul McKenney <paulmck@...ux.vnet.ibm.com>, Ingo Molnar <mingo@...hat.com>, 
	Thomas Gleixner <tglx@...utronix.de>, bart.vanassche@...disk.com, 
	"David S. Miller" <davem@...emloft.net>
Subject: Re: [PATCH v1 2/3] Mark functions with the latent_entropy attribute

On Mon, May 23, 2016 at 3:16 PM, Emese Revfy <re.emese@...il.com> wrote:
> These functions have been selected because they are init functions or
> are called at random times or they have variable loops.
>
> Based on work created by the PaX Team.
>
> Signed-off-by: Emese Revfy <re.emese@...il.com>
> [...]
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -188,6 +188,11 @@
>  #endif /* GCC_VERSION >= 40300 */
>
>  #if GCC_VERSION >= 40500
> +
> +#ifdef LATENT_ENTROPY_PLUGIN
> +#define __latent_entropy __attribute__((latent_entropy))
> +#endif

This deserves a full comment above it to describe its purpose and use
for when people go trying to figure out what it is and where to use
it. The commit message is a bit terse, so I'd try to expand both to
describe what function characteristics a developer should look for to
mark something with __latent_entropy.

> +
>  /*
>   * Mark a position in code as unreachable.  This can be used to
>   * suppress control flow warnings after asm blocks that transfer
> [...]
> diff --git a/include/linux/init.h b/include/linux/init.h
> index aedb254..68df2c3 100644
> --- a/include/linux/init.h
> +++ b/include/linux/init.h
> @@ -37,9 +37,15 @@
>   * section.
>   */
>
> +#ifdef CONFIG_MEMORY_HOTPLUG
> +#define add_meminit_latent_entropy
> +#else
> +#define add_meminit_latent_entropy __latent_entropy
> +#endif
> +
>  /* These are for everybody (although not all archs will actually
>     discard it in modules) */
> -#define __init         __section(.init.text) __cold notrace
> +#define __init         __section(.init.text) __cold notrace __latent_entropy
>  #define __initdata     __section(.init.data)
>  #define __initconst    __constsection(.init.rodata)
>  #define __exitdata     __section(.exit.data)
> @@ -92,7 +98,7 @@
>  #define __exit          __section(.exit.text) __exitused __cold notrace
>
>  /* Used for MEMORY_HOTPLUG */
> -#define __meminit        __section(.meminit.text) __cold notrace
> +#define __meminit        __section(.meminit.text) __cold notrace add_meminit_latent_entropy
>  #define __meminitdata    __section(.meminit.data)
>  #define __meminitconst   __constsection(.meminit.rodata)
>  #define __memexit        __section(.memexit.text) __exitused __cold notrace

I was confused by these defines. :) Maybe "add_meminit_latent_entropy"
should be named "__memory_hotplug_only_latent_entropy" or something
like that?

-Kees

-- 
Kees Cook
Chrome OS & Brillo Security

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.