Skip to contentSkip to conversation

vmlinux.lds.h: catch more UBSAN symbols into .data

PATCH Applied Alexander Lobakin 4 participants 5 messages Feb 16, 2021

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

PATCH 1/1 vmlinux.lds.h: catch more UBSAN symbols into .data

LKP triggered lots of LD orphan warnings [0]:

mipsel-linux-ld: warning: orphan section .data.$Lubsan_data299' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data299'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_data183' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data183'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type3' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type3'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type2' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type2'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type0' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type0'

[...]

Seems like "unnamed data" isn't the only type of symbols that UBSAN instrumentation can emit.
Catch these into .data with the wildcard as well.

[0] https://lore.kernel.org/linux-mm/[email protected]

Fixes f41b233de0ae ("vmlinux.lds.h: catch UBSAN's "unnamed data" into data")
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +1 -1
index cc659e77fcb0..83537e5ee78f 100644
@@ -95,7 +95,7 @@
  */
 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$Lubsan_*
 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
Signature · 1 line
2.30.1
#1 lore raw
Quoted 2 lines · Alexander Lobakin

LKP triggered lots of LD orphan warnings [0]:

Thanks for the patch, just some questions.

With which linker? Was there a particular config from the bot's report that triggered this?

Quoted 32 lines

mipsel-linux-ld: warning: orphan section .data.$Lubsan_data299' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data299'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_data183' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data183'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type3' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type3'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type2' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type2'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type0' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type0'

[...]

Seems like "unnamed data" isn't the only type of symbols that UBSAN instrumentation can emit.
Catch these into .data with the wildcard as well.

[0] https://lore.kernel.org/linux-mm/[email protected]

Fixes f41b233de0ae ("vmlinux.lds.h: catch UBSAN's "unnamed data" into data")
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +0 -0
index cc659e77fcb0..83537e5ee78f 100644

include/asm-generic/vmlinux.lds.h line 98

Quoted 5 lines
include/asm-generic/vmlinux.lds.h +1 -1
@@ -95,7 +95,7 @@
  */
 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$Lubsan_*

Are these sections only created when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is selected? (Same with .data.$__unnamed_*)

Quoted 7 lines
include/asm-generic/vmlinux.lds.h +0 -1
 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
--

2.30.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
#2 lore raw
Quoted 8 lines · Nick Desaulniers' via Clang Built Linux
Quoted 2 lines · Alexander Lobakin

LKP triggered lots of LD orphan warnings [0]:

Thanks for the patch, just some questions.

With which linker? Was there a particular config from the bot's report that triggered this?

Looks like GNU ld 2.34 (see below).

Quoted 27 lines
Quoted 27 lines

mipsel-linux-ld: warning: orphan section .data.$Lubsan_data299' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data299'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_data183' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data183'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type3' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type3'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type2' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type2'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type0' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type0'

[...]

Seems like "unnamed data" isn't the only type of symbols that UBSAN instrumentation can emit.
Catch these into .data with the wildcard as well.

[0] https://lore.kernel.org/linux-mm/[email protected]

Fixes f41b233de0ae ("vmlinux.lds.h: catch UBSAN's "unnamed data" into data")
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

include/asm-generic/vmlinux.lds.h line 98

Quoted 10 lines
include/asm-generic/vmlinux.lds.h +1 -1
index cc659e77fcb0..83537e5ee78f 100644
@@ -95,7 +95,7 @@
  */
 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$Lubsan_*

Are these sections only created when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is selected? (Same with .data.$__unnamed_*)

Most likely, as that config is set in the problematic config. My guess is that these are GCC's equivalent of Clang's .data.$__unnamed_...

$ crl https://lore.kernel.org/linux-mm/[email protected]/2-a.bin | gzip -d | rg "CONFIG_LD_DEAD_CODE|CONFIG_LD_VERSION"
CONFIG_LD_VERSION=234000000
CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y
Quoted 13 lines
Quoted 7 lines
include/asm-generic/vmlinux.lds.h +0 -1
 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
--

2.30.1

Signature · 2 lines
Thanks,
~Nick Desaulniers
#3 lore raw
In reply to Nick Desaulniers

From: Nick Desaulniers <[email protected]>
Date: Tue, 16 Feb 2021 09:56:32 -0800

Quoted 8 lines · Alexander Lobakin
Quoted 2 lines

LKP triggered lots of LD orphan warnings [0]:

Thanks for the patch, just some questions.

With which linker? Was there a particular config from the bot's report that triggered this?

All the info can be found by going through the link from the commit message. Compiler was GCC 9.3, so I suppose BFD was used as a linker. I mentioned CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y in the attached dotconfig, the warnings and the fix are relevant only for this case.

Quoted 42 lines
Quoted 32 lines

mipsel-linux-ld: warning: orphan section .data.$Lubsan_data299' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data299'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_data183' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data183'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type3' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type3'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type2' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type2'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type0' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type0'

[...]

Seems like "unnamed data" isn't the only type of symbols that UBSAN instrumentation can emit.
Catch these into .data with the wildcard as well.

[0] https://lore.kernel.org/linux-mm/[email protected]

Fixes f41b233de0ae ("vmlinux.lds.h: catch UBSAN's "unnamed data" into data")
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/vmlinux.lds.h +0 -0
index cc659e77fcb0..83537e5ee78f 100644

include/asm-generic/vmlinux.lds.h line 98

Quoted 5 lines
include/asm-generic/vmlinux.lds.h +1 -1
@@ -95,7 +95,7 @@
  */
 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral* .data.$__unnamed_* .data.$Lubsan_*

Are these sections only created when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is selected? (Same with .data.$__unnamed_*)

Quoted 12 lines
Quoted 7 lines
include/asm-generic/vmlinux.lds.h +0 -1
 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
 #define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
 #define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
--

2.30.1

Signature · 2 lines
Thanks,
~Nick Desaulniers

Al

maintainer Applied
#4 lore raw
In reply to Alexander Lobakin
Quoted 19 lines · Alexander Lobakin

LKP triggered lots of LD orphan warnings [0]:

mipsel-linux-ld: warning: orphan section .data.$Lubsan_data299' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data299'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_data183' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_data183'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type3' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type3'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type2' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type2'
mipsel-linux-ld: warning: orphan section .data.$Lubsan_type0' from init/do_mounts_rd.o' being placed in section `.data.$Lubsan_type0'

[...]

Seems like "unnamed data" isn't the only type of symbols that UBSAN instrumentation can emit.
Catch these into .data with the wildcard as well.

Quoted 8 lines

[0] https://lore.kernel.org/linux-mm/[email protected]

Fixes f41b233de0ae ("vmlinux.lds.h: catch UBSAN's "unnamed data" into data")
---
 include/asm-generic/vmlinux.lds.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

applied to mips-next.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]