-fstack-protector-strong은 작동하지만 gcc로 커널을 컴파일할 때 컴파일러가 손상됩니다.

-fstack-protector-strong은 작동하지만 gcc로 커널을 컴파일할 때 컴파일러가 손상됩니다.

이 특정 오류를 찾아봤지만 찾지 못했습니다. 대신 "컴파일러에서 지원되지 않음"과 같은 유사한 오류를 발견했습니다.

커널 버전 4.8.8을 컴파일하려고 하는데, 차이점이 있으면 grsecuirty로 패치했습니다.

이것은 출력 명령의 전체 오류입니다 fakeroot make-kpkg --initrd kernel_image.

Cannot use CONFIG_CC_STACKPROTECTOR_STRONG: -fstack-protector-strong available but compiler is broken
Makefile:1059: recipe for target 'prepare-compiler-check' failed
make[2]: *** [prepare-compiler-check] Error 1
make[2]: Leaving directory '/home/shurik/GrSec/linux-4.8.8'
debian/ruleset/targets/common.mk:194: recipe for target 'debian/stamp/conf/kernel-conf' failed
make[1]: *** [debian/stamp/conf/kernel-conf] Error 2
make[1]: Leaving directory '/home/shurik/GrSec/linux-4.8.8'
/usr/share/kernel-package/ruleset/minimal.mk:93: recipe for target 'debian/stamp/conf/minimal_debian' failed
make: *** [debian/stamp/conf/minimal_debian] Error 2
Failed to create a ./debian directory:  at /usr/bin/make-kpkg line 970.

현재 저는 Debian Sid x86_64를 실행하고 있고 컴파일러는 gcc 6.2.0입니다.

이 플래그를 사용하여 간단한 C 프로그램을 컴파일해 보았 -fstack-protector-strong더니 제대로 작동했습니다.

답변1

이것은 Grsecurity 문제가 아니라 Linux 및 Debian 문제입니다. 실수주목받았다.

다음 패치와 유사한 것을 적용하십시오.

--- a/Makefile
+++ b/Makefile
@@ -622,6 +622,8 @@ include arch/$(SRCARCH)/Makefile
 KBUILD_CFLAGS  += $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_CFLAGS  += $(call cc-disable-warning,maybe-uninitialized,)
 KBUILD_CFLAGS  += $(call cc-disable-warning,frame-address,)
+KBUILD_CFLAGS  += $(call cc-option,-fno-PIE)
+KBUILD_AFLAGS  += $(call cc-option,-fno-PIE)

 ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 KBUILD_CFLAGS  += $(call cc-option,-ffunction-sections,)

--- a/scripts/gcc-x86_64-has-stack-protector.sh
+++ b/scripts/gcc-x86_64-has-stack-protector.sh
@@ -1,6 +1,6 @@
 #!/bin/sh

-echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
 if [ "$?" -eq "0" ] ; then
    echo y
 else

--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -16,6 +16,7 @@ KCOV_INSTRUMENT := n

 KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes -fno-zero-initialized-in-bss -fno-builtin -ffreestanding -c -MD -Os -mcmodel=large
 KBUILD_CFLAGS += -m$(BITS)
+KBUILD_CFLAGS += $(call cc-option,-fno-PIE)

 $(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE
        $(call if_changed,ld)

실제로 Makefile은 패치되지 않았고 4.8.10일부 수동 수정이 필요했지만 그 후에는 작동했습니다.

아니면...잠깐만요. 곧 메인라인이 고쳐질 것 같아요.

관련 정보