All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] vmlinux.lds: account for destructor sections
@ 2016-06-24 15:39 Dmitry Vyukov
  2016-06-24 16:57 ` Andrey Ryabinin
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Vyukov @ 2016-06-24 15:39 UTC (permalink / raw)
  To: tglx, mingo, hpa, x86, arnd, linux-arch, ryabinin.a.a
  Cc: kasan-dev, glider, Dmitry Vyukov

If CONFIG_KASAN is enabled and gcc is configured with
--disable-initfini-array and/or gold linker is used,
gcc emits .ctors/.dtors and .text.startup/.text.exit
sections instead of .init_array/.fini_array.
.dtors section is not explicitly accounted in the linker
script and messes vvar/percpu layout. Want:

ffffffff822bfd80 D _edata
ffffffff822c0000 D __vvar_beginning_hack
ffffffff822c0000 A __vvar_page
ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
ffffffff822c1000 A __init_begin
ffffffff822c1000 D init_per_cpu__irq_stack_union
ffffffff822c1000 A __per_cpu_load
ffffffff822d3000 D init_per_cpu__gdt_page

Got:

ffffffff8279a600 D _edata
ffffffff8279b000 A __vvar_page
ffffffff8279c000 A __init_begin
ffffffff8279c000 D init_per_cpu__irq_stack_union
ffffffff8279c000 A __per_cpu_load
ffffffff8279e000 D __vvar_beginning_hack
ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
ffffffff827ae000 D init_per_cpu__gdt_page

This happens because __vvar_page and .vvar get different
addresses in arch/x86/kernel/vmlinux.lds.S:

	. = ALIGN(PAGE_SIZE);
	__vvar_page = .;

	.vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
		/* work around gold bug 13023 */
		__vvar_beginning_hack = .;

Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
Merge .text.startup into init text.

Signed-off-by: Dmitry Vyukov <dvyukov@google.com>

---

Changes since v1:
 - discard .dtors
 - don't define .mem sections

Changes since v2:
 - use 'vmlinux.lds' subsystem prefix instead of 'kasan'
---
 include/asm-generic/vmlinux.lds.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 6a67ab9..081d0f2 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -542,15 +542,19 @@
 
 #define INIT_TEXT							\
 	*(.init.text)							\
+	*(.text.startup)						\
 	MEM_DISCARD(init.text)
 
 #define EXIT_DATA							\
 	*(.exit.data)							\
+	*(.fini_array)							\
+	*(.dtors)							\
 	MEM_DISCARD(exit.data)						\
 	MEM_DISCARD(exit.rodata)
 
 #define EXIT_TEXT							\
 	*(.exit.text)							\
+	*(.text.exit)							\
 	MEM_DISCARD(exit.text)
 
 #define EXIT_CALL							\
-- 
2.8.0.rc3.226.g39d4020

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

* Re: [PATCH v3] vmlinux.lds: account for destructor sections
  2016-06-24 15:39 [PATCH v3] vmlinux.lds: account for destructor sections Dmitry Vyukov
@ 2016-06-24 16:57 ` Andrey Ryabinin
  2016-06-29 17:28   ` Dmitry Vyukov
  0 siblings, 1 reply; 6+ messages in thread
From: Andrey Ryabinin @ 2016-06-24 16:57 UTC (permalink / raw)
  To: Dmitry Vyukov
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Arnd Bergmann,
	linux-arch, kasan-dev, Alexander Potapenko

2016-06-24 18:39 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
> If CONFIG_KASAN is enabled and gcc is configured with
> --disable-initfini-array and/or gold linker is used,
> gcc emits .ctors/.dtors and .text.startup/.text.exit
> sections instead of .init_array/.fini_array.
> .dtors section is not explicitly accounted in the linker
> script and messes vvar/percpu layout. Want:
>
> ffffffff822bfd80 D _edata
> ffffffff822c0000 D __vvar_beginning_hack
> ffffffff822c0000 A __vvar_page
> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
> ffffffff822c1000 A __init_begin
> ffffffff822c1000 D init_per_cpu__irq_stack_union
> ffffffff822c1000 A __per_cpu_load
> ffffffff822d3000 D init_per_cpu__gdt_page
>
> Got:
>
> ffffffff8279a600 D _edata
> ffffffff8279b000 A __vvar_page
> ffffffff8279c000 A __init_begin
> ffffffff8279c000 D init_per_cpu__irq_stack_union
> ffffffff8279c000 A __per_cpu_load
> ffffffff8279e000 D __vvar_beginning_hack
> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
> ffffffff827ae000 D init_per_cpu__gdt_page
>
> This happens because __vvar_page and .vvar get different
> addresses in arch/x86/kernel/vmlinux.lds.S:
>
>         . = ALIGN(PAGE_SIZE);
>         __vvar_page = .;
>
>         .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
>                 /* work around gold bug 13023 */
>                 __vvar_beginning_hack = .;
>
> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
> Merge .text.startup into init text.
>
> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>

Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

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

* Re: [PATCH v3] vmlinux.lds: account for destructor sections
  2016-06-24 16:57 ` Andrey Ryabinin
@ 2016-06-29 17:28   ` Dmitry Vyukov
  2016-06-30 10:16     ` Dmitry Vyukov
  2016-07-01 14:58     ` Andrey Ryabinin
  0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Vyukov @ 2016-06-29 17:28 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Arnd Bergmann,
	linux-arch, kasan-dev, Alexander Potapenko

On Fri, Jun 24, 2016 at 6:57 PM, Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
> 2016-06-24 18:39 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
>> If CONFIG_KASAN is enabled and gcc is configured with
>> --disable-initfini-array and/or gold linker is used,
>> gcc emits .ctors/.dtors and .text.startup/.text.exit
>> sections instead of .init_array/.fini_array.
>> .dtors section is not explicitly accounted in the linker
>> script and messes vvar/percpu layout. Want:
>>
>> ffffffff822bfd80 D _edata
>> ffffffff822c0000 D __vvar_beginning_hack
>> ffffffff822c0000 A __vvar_page
>> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
>> ffffffff822c1000 A __init_begin
>> ffffffff822c1000 D init_per_cpu__irq_stack_union
>> ffffffff822c1000 A __per_cpu_load
>> ffffffff822d3000 D init_per_cpu__gdt_page
>>
>> Got:
>>
>> ffffffff8279a600 D _edata
>> ffffffff8279b000 A __vvar_page
>> ffffffff8279c000 A __init_begin
>> ffffffff8279c000 D init_per_cpu__irq_stack_union
>> ffffffff8279c000 A __per_cpu_load
>> ffffffff8279e000 D __vvar_beginning_hack
>> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
>> ffffffff827ae000 D init_per_cpu__gdt_page
>>
>> This happens because __vvar_page and .vvar get different
>> addresses in arch/x86/kernel/vmlinux.lds.S:
>>
>>         . = ALIGN(PAGE_SIZE);
>>         __vvar_page = .;
>>
>>         .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
>>                 /* work around gold bug 13023 */
>>                 __vvar_beginning_hack = .;
>>
>> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
>> Merge .text.startup into init text.
>>
>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>
> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>


Who can take it to some tree?

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

* Re: [PATCH v3] vmlinux.lds: account for destructor sections
  2016-06-29 17:28   ` Dmitry Vyukov
@ 2016-06-30 10:16     ` Dmitry Vyukov
  2016-07-01 14:58     ` Andrey Ryabinin
  1 sibling, 0 replies; 6+ messages in thread
From: Dmitry Vyukov @ 2016-06-30 10:16 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Arnd Bergmann,
	linux-arch, kasan-dev, Alexander Potapenko

On Wed, Jun 29, 2016 at 7:28 PM, Dmitry Vyukov <dvyukov@google.com> wrote:
> On Fri, Jun 24, 2016 at 6:57 PM, Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
>> 2016-06-24 18:39 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
>>> If CONFIG_KASAN is enabled and gcc is configured with
>>> --disable-initfini-array and/or gold linker is used,
>>> gcc emits .ctors/.dtors and .text.startup/.text.exit
>>> sections instead of .init_array/.fini_array.
>>> .dtors section is not explicitly accounted in the linker
>>> script and messes vvar/percpu layout. Want:
>>>
>>> ffffffff822bfd80 D _edata
>>> ffffffff822c0000 D __vvar_beginning_hack
>>> ffffffff822c0000 A __vvar_page
>>> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
>>> ffffffff822c1000 A __init_begin
>>> ffffffff822c1000 D init_per_cpu__irq_stack_union
>>> ffffffff822c1000 A __per_cpu_load
>>> ffffffff822d3000 D init_per_cpu__gdt_page
>>>
>>> Got:
>>>
>>> ffffffff8279a600 D _edata
>>> ffffffff8279b000 A __vvar_page
>>> ffffffff8279c000 A __init_begin
>>> ffffffff8279c000 D init_per_cpu__irq_stack_union
>>> ffffffff8279c000 A __per_cpu_load
>>> ffffffff8279e000 D __vvar_beginning_hack
>>> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
>>> ffffffff827ae000 D init_per_cpu__gdt_page
>>>
>>> This happens because __vvar_page and .vvar get different
>>> addresses in arch/x86/kernel/vmlinux.lds.S:
>>>
>>>         . = ALIGN(PAGE_SIZE);
>>>         __vvar_page = .;
>>>
>>>         .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
>>>                 /* work around gold bug 13023 */
>>>                 __vvar_beginning_hack = .;
>>>
>>> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
>>> Merge .text.startup into init text.
>>>
>>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>>
>> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>
>
> Who can take it to some tree?


Arnd, you are listed as maintainer of this file. How can I get this
into mainline?

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

* Re: [PATCH v3] vmlinux.lds: account for destructor sections
  2016-06-29 17:28   ` Dmitry Vyukov
  2016-06-30 10:16     ` Dmitry Vyukov
@ 2016-07-01 14:58     ` Andrey Ryabinin
  2016-07-01 15:19       ` Dmitry Vyukov
  1 sibling, 1 reply; 6+ messages in thread
From: Andrey Ryabinin @ 2016-07-01 14:58 UTC (permalink / raw)
  To: Dmitry Vyukov, Andrew Morton
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Arnd Bergmann,
	linux-arch, kasan-dev, Alexander Potapenko, LKML

2016-06-29 20:28 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
> On Fri, Jun 24, 2016 at 6:57 PM, Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
>> 2016-06-24 18:39 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
>>> If CONFIG_KASAN is enabled and gcc is configured with
>>> --disable-initfini-array and/or gold linker is used,
>>> gcc emits .ctors/.dtors and .text.startup/.text.exit
>>> sections instead of .init_array/.fini_array.
>>> .dtors section is not explicitly accounted in the linker
>>> script and messes vvar/percpu layout. Want:
>>>
>>> ffffffff822bfd80 D _edata
>>> ffffffff822c0000 D __vvar_beginning_hack
>>> ffffffff822c0000 A __vvar_page
>>> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
>>> ffffffff822c1000 A __init_begin
>>> ffffffff822c1000 D init_per_cpu__irq_stack_union
>>> ffffffff822c1000 A __per_cpu_load
>>> ffffffff822d3000 D init_per_cpu__gdt_page
>>>
>>> Got:
>>>
>>> ffffffff8279a600 D _edata
>>> ffffffff8279b000 A __vvar_page
>>> ffffffff8279c000 A __init_begin
>>> ffffffff8279c000 D init_per_cpu__irq_stack_union
>>> ffffffff8279c000 A __per_cpu_load
>>> ffffffff8279e000 D __vvar_beginning_hack
>>> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
>>> ffffffff827ae000 D init_per_cpu__gdt_page
>>>
>>> This happens because __vvar_page and .vvar get different
>>> addresses in arch/x86/kernel/vmlinux.lds.S:
>>>
>>>         . = ALIGN(PAGE_SIZE);
>>>         __vvar_page = .;
>>>
>>>         .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
>>>                 /* work around gold bug 13023 */
>>>                 __vvar_beginning_hack = .;
>>>
>>> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
>>> Merge .text.startup into init text.
>>>
>>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>>
>> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>
>
> Who can take it to some tree?

akpm tends to be the maintainer of last resort.
But you probably need to resend the patch, because LKML was not in CC list.
Also, please add stable tag: Cc: <stable@vger.kernel.org> # v4.0+

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

* Re: [PATCH v3] vmlinux.lds: account for destructor sections
  2016-07-01 14:58     ` Andrey Ryabinin
@ 2016-07-01 15:19       ` Dmitry Vyukov
  0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Vyukov @ 2016-07-01 15:19 UTC (permalink / raw)
  To: Andrey Ryabinin
  Cc: Andrew Morton, Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86,
	Arnd Bergmann, linux-arch, kasan-dev, Alexander Potapenko, LKML

On Fri, Jul 1, 2016 at 4:58 PM, Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
> 2016-06-29 20:28 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
>> On Fri, Jun 24, 2016 at 6:57 PM, Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
>>> 2016-06-24 18:39 GMT+03:00 Dmitry Vyukov <dvyukov@google.com>:
>>>> If CONFIG_KASAN is enabled and gcc is configured with
>>>> --disable-initfini-array and/or gold linker is used,
>>>> gcc emits .ctors/.dtors and .text.startup/.text.exit
>>>> sections instead of .init_array/.fini_array.
>>>> .dtors section is not explicitly accounted in the linker
>>>> script and messes vvar/percpu layout. Want:
>>>>
>>>> ffffffff822bfd80 D _edata
>>>> ffffffff822c0000 D __vvar_beginning_hack
>>>> ffffffff822c0000 A __vvar_page
>>>> ffffffff822c0080 0000000000000098 D vsyscall_gtod_data
>>>> ffffffff822c1000 A __init_begin
>>>> ffffffff822c1000 D init_per_cpu__irq_stack_union
>>>> ffffffff822c1000 A __per_cpu_load
>>>> ffffffff822d3000 D init_per_cpu__gdt_page
>>>>
>>>> Got:
>>>>
>>>> ffffffff8279a600 D _edata
>>>> ffffffff8279b000 A __vvar_page
>>>> ffffffff8279c000 A __init_begin
>>>> ffffffff8279c000 D init_per_cpu__irq_stack_union
>>>> ffffffff8279c000 A __per_cpu_load
>>>> ffffffff8279e000 D __vvar_beginning_hack
>>>> ffffffff8279e080 0000000000000098 D vsyscall_gtod_data
>>>> ffffffff827ae000 D init_per_cpu__gdt_page
>>>>
>>>> This happens because __vvar_page and .vvar get different
>>>> addresses in arch/x86/kernel/vmlinux.lds.S:
>>>>
>>>>         . = ALIGN(PAGE_SIZE);
>>>>         __vvar_page = .;
>>>>
>>>>         .vvar : AT(ADDR(.vvar) - LOAD_OFFSET) {
>>>>                 /* work around gold bug 13023 */
>>>>                 __vvar_beginning_hack = .;
>>>>
>>>> Discard .dtors/.fini_array/.text.exit, since we don't call dtors.
>>>> Merge .text.startup into init text.
>>>>
>>>> Signed-off-by: Dmitry Vyukov <dvyukov@google.com>
>>>
>>> Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
>>
>>
>> Who can take it to some tree?
>
> akpm tends to be the maintainer of last resort.
> But you probably need to resend the patch, because LKML was not in CC list.
> Also, please add stable tag: Cc: <stable@vger.kernel.org> # v4.0+

Remailed. Thanks.

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

end of thread, other threads:[~2016-07-01 15:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-24 15:39 [PATCH v3] vmlinux.lds: account for destructor sections Dmitry Vyukov
2016-06-24 16:57 ` Andrey Ryabinin
2016-06-29 17:28   ` Dmitry Vyukov
2016-06-30 10:16     ` Dmitry Vyukov
2016-07-01 14:58     ` Andrey Ryabinin
2016-07-01 15:19       ` Dmitry Vyukov

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.