Skip to contentSkip to conversation

kcsan: select CONFIG_CONSTRUCTORS

PATCH Applied Arnd Bergmann 4 participants 6 messages Feb 15, 2023 – Feb 16, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kcsan: select CONFIG_CONSTRUCTORS

From: Arnd Bergmann <[email protected]>

Building a kcsan enabled kernel for x86_64 with gcc-11 results in a lot of build warnings or errors without CONFIG_CONSTRUCTORS:

x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/copy_mc.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/cpu.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/csum-partial_64.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/csum-wrappers_64.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/insn-eval.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/insn.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/misc.o'

The same thing has been reported for mips64. I can't reproduce it for any other compiler version, so I don't know if constructors are always required here or if this is a gcc-11 specific implementation detail.

I see no harm in always enabling constructors here, and this reliably fixes the build warnings for me.

See-also: 3e6631485fae ("vmlinux.lds.h: Keep .ctors.* with .ctors")

---
 lib/Kconfig.kcsan | 1 +
 1 file changed, 1 insertion(+)
lib/Kconfig.kcsan +1 -0
index 4dedd61e5192..609ddfc73de5 100644
@@ -14,6 +14,7 @@ menuconfig KCSAN
 	bool "KCSAN: dynamic data race detector"
 	depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER
 	depends on DEBUG_KERNEL && !KASAN
+	select CONSTRUCTORS
 	select STACKTRACE
 	help
 	  The Kernel Concurrency Sanitizer (KCSAN) is a dynamic
Signature · 1 line
2.39.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

Building a kcsan enabled kernel for x86_64 with gcc-11 results in a lot of build warnings or errors without CONFIG_CONSTRUCTORS:

x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/copy_mc.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/cpu.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/csum-partial_64.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/csum-wrappers_64.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/insn-eval.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/insn.o'
x86_64-linux-ld: error: unplaced orphan section .ctors.65436' from arch/x86/lib/misc.o'

The same thing has been reported for mips64. I can't reproduce it for any other compiler version, so I don't know if constructors are always required here or if this is a gcc-11 specific implementation detail.

Quoted 7 lines

I see no harm in always enabling constructors here, and this reliably fixes the build warnings for me.

See-also: 3e6631485fae ("vmlinux.lds.h: Keep .ctors.* with .ctors")

Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well.

Do you have a tree to take this through, or should it go through -rcu as usual for KCSAN patches?

Thanks,
-- Marco

Quoted 19 lines
---
 lib/Kconfig.kcsan | 1 +
 1 file changed, 1 insertion(+)
lib/Kconfig.kcsan +1 -1
index 4dedd61e5192..609ddfc73de5 100644
@@ -14,6 +14,7 @@ menuconfig KCSAN
        bool "KCSAN: dynamic data race detector"
        depends on HAVE_ARCH_KCSAN && HAVE_KCSAN_COMPILER
        depends on DEBUG_KERNEL && !KASAN
+       select CONSTRUCTORS
        select STACKTRACE
        help
          The Kernel Concurrency Sanitizer (KCSAN) is a dynamic
--

2.39.1

#2 lore raw
Quoted 6 lines · Marco Elver

On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <[email protected]> wrote:

Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well.

Do you have a tree to take this through, or should it go through -rcu as usual for KCSAN patches?

I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate.

Thanks,

Arnd

#3 lore raw
Quoted 9 lines · Arnd Bergmann
Quoted 6 lines · Marco Elver

On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <[email protected]> wrote:

Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well.

Do you have a tree to take this through, or should it go through -rcu as usual for KCSAN patches?

I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate.

Queued and pushed, thank you both!

Is this ready for the upcoming merge window, or would you rather that I hold off until the v6.4 merge window? (I am tempted to treat this as a bug fix, thus sending it earlier rather than later, but figured I should ask.)

Thanx, Paul

maintainer
#4 lore raw
Quoted 10 lines · Paul E. McKenney
Quoted 8 lines · Arnd Bergmann
Quoted 6 lines · Marco Elver

On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <[email protected]> wrote:

Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well.

Do you have a tree to take this through, or should it go through -rcu as usual for KCSAN patches?

Quoted 8 lines
Quoted 1 line

I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate.

Queued and pushed, thank you both!

Is this ready for the upcoming merge window, or would you rather that I hold off until the v6.4 merge window? (I am tempted to treat this as a bug fix, thus sending it earlier rather than later, but figured I should ask.)

I'd consider it a bug fix. If it survives the usual -next exposure, no harm in sending it as a fix.

Thanks,
-- Marco

#5 lore raw
Quoted 15 lines · Marco Elver
Quoted 14 lines · Paul E. McKenney
Quoted 9 lines · Arnd Bergmann
Quoted 6 lines · Marco Elver

On Wed, 15 Feb 2023 at 10:15, Arnd Bergmann <[email protected]> wrote:

Looks like KASAN does select CONSTRUCTORS already, so KCSAN should as well.

Do you have a tree to take this through, or should it go through -rcu as usual for KCSAN patches?

I don't have a tree for taking these build fixes, so it would be good if you could forward it as appropriate.

Queued and pushed, thank you both!

Quoted 7 lines
Quoted 4 lines

Is this ready for the upcoming merge window, or would you rather that I hold off until the v6.4 merge window? (I am tempted to treat this as a bug fix, thus sending it earlier rather than later, but figured I should ask.)

I'd consider it a bug fix. If it survives the usual -next exposure, no harm in sending it as a fix.

It passed overnight tests, so I have sent it along to -next. If there are no issues, I will push it by the end of this coming week (which is the first weke of the merge window).

Thanx, Paul