All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Garnier <thgarnie@google.com>
To: "Luis R. Rodriguez" <mcgrof@kernel.org>
Cc: "Nicolas Pitre" <nicolas.pitre@linaro.org>,
	"Michal Hocko" <mhocko@suse.com>,
	"Radim Krčmář" <rkrcmar@redhat.com>,
	linux-doc@vger.kernel.org, "kvm list" <kvm@vger.kernel.org>,
	"Len Brown" <len.brown@intel.com>,
	"Peter Zijlstra" <peterz@infradead.org>,
	"Christopher Li" <sparse@chrisli.org>,
	"Jan H . Schönherr" <jschoenh@amazon.de>,
	"Alexei Starovoitov" <ast@kernel.org>,
	virtualization@lists.linux-foundation.org,
	"David Howells" <dhowells@redhat.com>,
	"Paul Gortmaker" <paul.gortmaker@windriver.com>,
	"Waiman Long" <longman@redhat.com>, "Pavel Machek" <pavel@ucw.cz>,
	"H . Peter Anvin" <hpa@zytor.com>,
	"Kernel Hardening" <kernel-hardening@lists.openwall.com>,
	"Christoph Lameter" <cl@linux.com>,
	"Alok Kataria" <akataria@vmware.com>,
	"the arch/x86 maintainers" <x86@kernel.org>,
	"Herbert Xu" <herbert@gondor.apana.org.au>,
	"Daniel Borkmann" <daniel@iogearbox.net>
Subject: Re: [PATCH v1 15/27] compiler: Option to default to hidden symbols
Date: Wed, 18 Oct 2017 16:15:10 -0700	[thread overview]
Message-ID: <CAJcbSZEJ-kjcRQD3uHm0QZuOvbHpg9FV=wn7v4-RweDG7J3uqg__28276.4366049834$1508368592$gmane$org@mail.gmail.com> (raw)
In-Reply-To: <20171012200201.GW11645@wotan.suse.de>

On Thu, Oct 12, 2017 at 1:02 PM, Luis R. Rodriguez <mcgrof@kernel.org> wrote:
> On Wed, Oct 11, 2017 at 01:30:15PM -0700, Thomas Garnier wrote:
>> Provide an option to default visibility to hidden except for key
>> symbols. This option is disabled by default and will be used by x86_64
>> PIE support to remove errors between compilation units.
>>
>> The default visibility is also enabled for external symbols that are
>> compared as they maybe equals (start/end of sections). In this case,
>> older versions of GCC will remove the comparison if the symbols are
>> hidden. This issue exists at least on gcc 4.9 and before.
>>
>> Signed-off-by: Thomas Garnier <thgarnie@google.com>
>
> <-- snip -->
>
>> diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
>> index 86e8f0b2537b..8f021783a929 100644
>> --- a/arch/x86/kernel/cpu/microcode/core.c
>> +++ b/arch/x86/kernel/cpu/microcode/core.c
>> @@ -144,8 +144,8 @@ static bool __init check_loader_disabled_bsp(void)
>>       return *res;
>>  }
>>
>> -extern struct builtin_fw __start_builtin_fw[];
>> -extern struct builtin_fw __end_builtin_fw[];
>> +extern struct builtin_fw __start_builtin_fw[] __default_visibility;
>> +extern struct builtin_fw __end_builtin_fw[] __default_visibility;
>>
>>  bool get_builtin_firmware(struct cpio_data *cd, const char *name)
>>  {
>
> <-- snip -->
>
>> diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h
>> index e5da44eddd2f..1aa5d6dac9e1 100644
>> --- a/include/asm-generic/sections.h
>> +++ b/include/asm-generic/sections.h
>> @@ -30,6 +30,9 @@
>>   *   __irqentry_text_start, __irqentry_text_end
>>   *   __softirqentry_text_start, __softirqentry_text_end
>>   */
>> +#ifdef CONFIG_DEFAULT_HIDDEN
>> +#pragma GCC visibility push(default)
>> +#endif
>>  extern char _text[], _stext[], _etext[];
>>  extern char _data[], _sdata[], _edata[];
>>  extern char __bss_start[], __bss_stop[];
>> @@ -46,6 +49,9 @@ extern char __softirqentry_text_start[], __softirqentry_text_end[];
>>
>>  /* Start and end of .ctors section - used for constructor calls. */
>>  extern char __ctors_start[], __ctors_end[];
>> +#ifdef CONFIG_DEFAULT_HIDDEN
>> +#pragma GCC visibility pop
>> +#endif
>>
>>  extern __visible const void __nosave_begin, __nosave_end;
>>
>> diff --git a/include/linux/compiler.h b/include/linux/compiler.h
>> index e95a2631e545..6997716f73bf 100644
>> --- a/include/linux/compiler.h
>> +++ b/include/linux/compiler.h
>> @@ -78,6 +78,14 @@ extern void __chk_io_ptr(const volatile void __iomem *);
>>  #include <linux/compiler-clang.h>
>>  #endif
>>
>> +/* Useful for Position Independent Code to reduce global references */
>> +#ifdef CONFIG_DEFAULT_HIDDEN
>> +#pragma GCC visibility push(hidden)
>> +#define __default_visibility  __attribute__((visibility ("default")))
>
> Does this still work with CONFIG_LD_DEAD_CODE_DATA_ELIMINATION ?

I cannot make it work with or without this change. How is it supposed
to be used?

For me with, it crashes with a bad consdev at:
http://elixir.free-electrons.com/linux/latest/source/drivers/tty/tty_io.c#L3194

>
>> +#else
>> +#define __default_visibility
>> +#endif
>> +
>>  /*
>>   * Generic compiler-dependent macros required for kernel
>>   * build go below this comment. Actual compiler/compiler version
>> diff --git a/init/Kconfig b/init/Kconfig
>> index ccb1d8daf241..b640201fcff7 100644
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -1649,6 +1649,13 @@ config PROFILING
>>  config TRACEPOINTS
>>       bool
>>
>> +#
>> +# Default to hidden visibility for all symbols.
>> +# Useful for Position Independent Code to reduce global references.
>> +#
>> +config DEFAULT_HIDDEN
>> +     bool
>
> Note it is default.
>
> Has 0-day ran through this git tree? It should be easy to get it added for
> testing. Also, even though most changes are x86 based there are some generic
> changes and I'd love a warm fuzzy this won't break odd / random builds.
> Although 0-day does cover a lot of test cases, it only has limited run time
> tests. There are some other test beds which also cover some more obscure
> architectures. Having a test pass on Guenter's test bed would be nice to
> see. For that please coordinate with Guenter if he's willing to run this
> a test for you.

Not yet, plan to give a v1.5 to Kees Cook to keep in one of his tree
for couple weeks. I expect it will identify interesting issues.

>
>   Luis



-- 
Thomas

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-10-18 23:15 UTC|newest]

Thread overview: 176+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 20:30 [PATCH v1 00/27] x86: PIE support and option to extend KASLR randomization Thomas Garnier
2017-10-11 20:30 ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 01/27] x86/crypto: Adapt assembly for PIE support Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-20  8:24   ` Ingo Molnar
2017-10-20  8:24     ` [kernel-hardening] " Ingo Molnar
2017-10-20  8:24     ` Ingo Molnar
2017-10-20  8:28     ` Ard Biesheuvel
2017-10-20  8:28       ` [kernel-hardening] " Ard Biesheuvel
2017-10-20 14:48       ` Thomas Garnier via Virtualization
2017-10-20 14:48       ` Thomas Garnier
2017-10-20 14:48         ` [kernel-hardening] " Thomas Garnier
2017-10-20 14:48         ` Thomas Garnier
2017-10-20 14:48       ` Thomas Garnier
2017-10-20  8:28     ` Ard Biesheuvel
2017-10-20  8:24   ` Ingo Molnar
2017-10-20  8:24   ` Ingo Molnar
2017-10-11 20:30 ` [PATCH v1 02/27] x86: Use symbol name on bug table " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 03/27] x86: Use symbol name in jump " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 04/27] x86: Add macro to get symbol address " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 05/27] x86: relocate_kernel - Adapt assembly " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 06/27] x86/entry/64: " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-20  8:26   ` Ingo Molnar
2017-10-20  8:26     ` [kernel-hardening] " Ingo Molnar
2017-10-20 14:47     ` Thomas Garnier via Virtualization
2017-10-20 14:47     ` Thomas Garnier
2017-10-20 14:47       ` [kernel-hardening] " Thomas Garnier
2017-10-20 14:47       ` Thomas Garnier
2017-10-20 15:20       ` Ingo Molnar
2017-10-20 15:20       ` Ingo Molnar
2017-10-20 15:20         ` [kernel-hardening] " Ingo Molnar
2017-10-20 16:27         ` Andy Lutomirski
2017-10-20 16:27         ` Andy Lutomirski
2017-10-20 16:27         ` Andy Lutomirski
2017-10-20 16:27           ` [kernel-hardening] " Andy Lutomirski
2017-10-20 16:27           ` Andy Lutomirski
2017-10-20 17:52         ` Andy Lutomirski
2017-10-20 17:52         ` Andy Lutomirski
2017-10-20 17:52           ` [kernel-hardening] " Andy Lutomirski
2017-10-20 17:52           ` Andy Lutomirski
2017-10-20 17:52         ` Andy Lutomirski
2017-10-20 14:47     ` Thomas Garnier
2017-10-20  8:26   ` Ingo Molnar
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 07/27] x86: pm-trace - " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 08/27] x86/CPU: " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 09/27] x86/acpi: " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 10/27] x86/boot/64: " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 11/27] x86/power/64: " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 12/27] x86/paravirt: " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 13/27] x86/boot/64: Use _text in a global " Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 14/27] x86/percpu: Adapt percpu " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 15/27] compiler: Option to default to hidden symbols Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-12 20:02   ` Luis R. Rodriguez
2017-10-12 20:02     ` [kernel-hardening] " Luis R. Rodriguez
2017-10-18 23:15     ` Thomas Garnier via Virtualization
2017-10-18 23:15     ` Thomas Garnier [this message]
2017-10-18 23:15     ` Thomas Garnier
2017-10-18 23:15       ` [kernel-hardening] " Thomas Garnier
2017-10-18 23:15       ` Thomas Garnier
2017-10-19 19:38       ` Luis R. Rodriguez
2017-10-19 19:38         ` [kernel-hardening] " Luis R. Rodriguez
2017-10-19 19:38       ` Luis R. Rodriguez
2017-10-12 20:02   ` Luis R. Rodriguez
2017-10-11 20:30 ` [PATCH v1 16/27] x86/relocs: Handle PIE relocations Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 17/27] xen: Adapt assembly for PIE support Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 18/27] kvm: " Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 19/27] x86: Support global stack cookie Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 20/27] x86/ftrace: Adapt function tracing for PIE support Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 21/27] x86/mm/dump_pagetables: Fix address markers index on x86_64 Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 22/27] x86/modules: Add option to start module section after kernel Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 23/27] x86/modules: Adapt module loading for PIE support Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 24/27] x86/mm: Make the x86 GOT read-only Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 25/27] x86/pie: Add option to build the kernel as PIE Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` [PATCH v1 26/27] x86/relocs: Add option to generate 64-bit relocations Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 20:30 ` Thomas Garnier via Virtualization
2017-10-11 20:30 ` [PATCH v1 27/27] x86/kaslr: Add option to extend KASLR range from 1GB to 3GB Thomas Garnier via Virtualization
2017-10-11 20:30 ` Thomas Garnier
2017-10-11 20:30   ` [kernel-hardening] " Thomas Garnier
2017-10-11 20:30   ` Thomas Garnier
2017-10-11 21:34 ` [PATCH v1 00/27] x86: PIE support and option to extend KASLR randomization Tom Lendacky
2017-10-11 21:34 ` Tom Lendacky
2017-10-11 21:34   ` [kernel-hardening] " Tom Lendacky
2017-10-11 21:34   ` Tom Lendacky
2017-10-12 15:34   ` Thomas Garnier via Virtualization
2017-10-12 15:34   ` Thomas Garnier
2017-10-12 15:34   ` Thomas Garnier
2017-10-12 15:34     ` [kernel-hardening] " Thomas Garnier
2017-10-12 15:34     ` Thomas Garnier
2017-10-12 15:51     ` Markus Trippelsdorf
2017-10-12 15:51     ` Markus Trippelsdorf
2017-10-12 15:51       ` [kernel-hardening] " Markus Trippelsdorf
2017-10-12 16:28     ` Tom Lendacky
2017-10-12 16:28     ` Tom Lendacky
2017-10-12 16:28       ` [kernel-hardening] " Tom Lendacky
2017-10-18 23:17       ` Thomas Garnier via Virtualization
2017-10-18 23:17       ` Thomas Garnier
2017-10-18 23:17       ` Thomas Garnier
2017-10-18 23:17         ` [kernel-hardening] " Thomas Garnier
2017-10-18 23:17         ` Thomas Garnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJcbSZEJ-kjcRQD3uHm0QZuOvbHpg9FV=wn7v4-RweDG7J3uqg__28276.4366049834$1508368592$gmane$org@mail.gmail.com' \
    --to=thgarnie@google.com \
    --cc=akataria@vmware.com \
    --cc=ast@kernel.org \
    --cc=cl@linux.com \
    --cc=daniel@iogearbox.net \
    --cc=dhowells@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jschoenh@amazon.de \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=kvm@vger.kernel.org \
    --cc=len.brown@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mcgrof@kernel.org \
    --cc=mhocko@suse.com \
    --cc=nicolas.pitre@linaro.org \
    --cc=paul.gortmaker@windriver.com \
    --cc=pavel@ucw.cz \
    --cc=peterz@infradead.org \
    --cc=rkrcmar@redhat.com \
    --cc=sparse@chrisli.org \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.