On 8/3/22 11:38 AM, Nick Desaulniers wrote: > On Wed, Aug 3, 2022 at 9:53 AM Jens Axboe <axboe@xxxxxxxxx> wrote: >> >> On 8/3/22 10:51 AM, Nick Desaulniers wrote: >>> On Wed, Aug 3, 2022 at 9:26 AM Linus Torvalds >>> <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: >>>> >>>> On Wed, Aug 3, 2022 at 8:16 AM Jens Axboe <axboe@xxxxxxxxx> wrote: >>>>> >>>>> On the topic of warnings, on my new build box I get a lot of these: >>>>> >>>>> ld: warning: arch/x86/lib/putuser.o: missing .note.GNU-stack section implies executable stack >>>>> ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker >>>>> >>>>> which ends up polluting the output quite a bit. >>>>> >>>>> axboe@r7525 ~> ld --version >>>>> GNU ld (GNU Binutils for Debian) 2.38.90.20220713 >>>> >>>> Ok, I have binutils 2.37, so it may be new to 2.38. >>>> >>>> Some googling around seems to imply that we'd need to so something like this >>>> >>>> .section .note.GNU-stack,"",%progbits >>>> >>>> in all our *.S files. >>>> >>>> We do have some signs of that in our tooling, because apparently it >>>> has hit user-space, but I wonder what has triggered the need on the >>>> kernel side for you. >>>> >>>> I'd hate to add that pointless line to every asm file, but maybe we >>>> could so something like this >>>> >>>> #ifdef __ASSEMBLY_ >>>> #ifdef OUTPUT_PROGBITS >>>> .section .note.GNU-stack,"",%progbits >>>> #undef OUTPUT_PROGBITS >>>> #endif >>>> #endif >>>> >>>> and then change our 'AS' command line to do '-DOUTPUT_PROGBITS' in our >>>> makefiles. >>>> >>>> *Most* asm files should include <linux/linkage.h> just for all the >>>> macros that declare variables externally, so that might catch the bulk >>>> of it. >>>> >>>> Somebody who knows the rules better than I would be a good idea. >>> >>> $ as --help | grep exec >>> --execstack require executable stack for this object >>> --noexecstack don't require executable stack for this object >>> --statistics print various measured statistics from execution >>> >>> Does adding `--noexecstack` to KBUILD_ASFLAGS for these architectures >>> help, rather than modifying every assembler source? >> >> I can try whatever here, but a quick grep doesn't find anything for >> KBUILD_ASFLAGS or anything close to it. What am I missing? > > Sorry, I'm running between many meetings today...so suggestions aren't > tested and may not be fully coherent... > > KBUILD_AFLAGS += -Wa,--noexecstack > > There's also as-option Make macro in case older binutils doesn't > support that flag outright. > > tools/perf/Makefile.config also uses noexecstack as a linker flag. > That might be an option, too. It is the linker producing the > warnings, not the assembler, but the assembler flag is probably the > way to go to fix the warnings since it sounds like these are assembler > sources exclusively causing the issue. I ran with the below and it silences the linker warning mentioned. I do also see the below with my build (which aren't new with the option added obviously, but not visible since I don't get the other noise): axboe@r7525 ~/gi/linux-block (test)> time make -j256 -s 1.886s ld: warning: .tmp_vmlinux.kallsyms1 has a LOAD segment with RWX permissions ld: warning: .tmp_vmlinux.kallsyms2 has a LOAD segment with RWX permissions ld: warning: vmlinux has a LOAD segment with RWX permissions ld: warning: arch/x86/boot/compressed/efi_thunk_64.o: missing .note.GNU-stack section implies executable stack ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker ld: warning: arch/x86/boot/compressed/vmlinux has a LOAD segment with RWX permissions ld: warning: arch/x86/boot/pmjump.o: missing .note.GNU-stack section implies executable stack ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker ld: warning: arch/x86/boot/setup.elf has a LOAD segment with RWX permissions diff --git a/arch/x86/Makefile b/arch/x86/Makefile index 7854685c5f25..51824528a026 100644 --- a/arch/x86/Makefile +++ b/arch/x86/Makefile @@ -123,6 +123,7 @@ else CHECKFLAGS += -D__x86_64__ KBUILD_AFLAGS += -m64 + KBUILD_AFLAGS += -Wa,--noexecstack KBUILD_CFLAGS += -m64 # Align jump targets to 1 byte, not the default 16 bytes: -- Jens Axboe