kvm: Fix stack access mode in KVM test ELF headers
PATCH 1/1 kvm: Fix stack access mode in KVM test ELF headers
When the linker converts guest payload binary into a linkable resource object file, it somehow defaults to requesting executable stack section for the final test binary. This trips some build-time security checks on newer systems. Add explicit linker option to make the stack non-executable.
---
Build tests in GitHub Actions:
https://github.com/mdoucha/ltp/actions/runs/2422115463
testcases/kernel/kvm/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/kvm/Makefile +2 -2
@@ -50,11 +50,11 @@ include $(top_srcdir)/include/mk/generic_leaf_target.mk ifdef VERBOSE $(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin - ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin + ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin else @$(CC) $(GUEST_CPPFLAGS) $(GUEST_CFLAGS) $(GUEST_LDFLAGS) -o $*-payload.elf $^ $(GUEST_LDLIBS) @objcopy -O binary -j .init.boot -j .text -j .data -j .init -j .preinit_array -j .init_array --gap-fill=0 $*-payload.elf $*-payload.bin - @ld -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin + @ld -z noexecstack -r -T $(abs_srcdir)/linker/payload.lds --oformat=$(BIN_FORMAT) -o $@ $*-payload.bin @echo KVM_CC $(target_rel_dir)$@ endif @rm $*-payload.elf $*-payload.bin
Signature · 5 lines
2.36.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Martin, Fabian,
Quoted 5 lines
When the linker converts guest payload binary into a linkable resource object file, it somehow defaults to requesting executable stack section for the final test binary. This trips some build-time security checks on newer systems. Add explicit linker option to make the stack non-executable.
LGTM, thanks!
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Pushed, thanks.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp