From 91e37ad48110633185d9c4d97627fa5c9d0e7f78 Mon Sep 17 00:00:00 2001 From: Phoenix591 <11486+Phoenix591@users.noreply.github.com> Date: Fri, 21 Jan 2022 15:08:50 -0600 Subject: [PATCH] Disable executable stack by adding note to assembly files Signed-off-by: Phoenix591 <11486+Phoenix591@users.noreply.github.com> --- arch/aarch64/getcontext.S | 3 +++ arch/aarch64/setcontext.S | 3 +++ arch/aarch64/swapcontext.S | 3 +++ arch/arm/getcontext.S | 3 +++ arch/arm/setcontext.S | 3 +++ arch/arm/swapcontext.S | 3 +++ arch/m68k/getcontext.S | 3 +++ arch/m68k/setcontext.S | 3 +++ arch/m68k/swapcontext.S | 3 +++ arch/mips/getcontext.S | 3 +++ arch/mips/makecontext.S | 3 +++ arch/mips/setcontext.S | 3 +++ arch/mips/startcontext.S | 3 +++ arch/mips/swapcontext.S | 3 +++ arch/mips64/getcontext.S | 3 +++ arch/mips64/makecontext.S | 3 +++ arch/mips64/setcontext.S | 3 +++ arch/mips64/startcontext.S | 3 +++ arch/mips64/swapcontext.S | 3 +++ arch/ppc/getcontext.S | 3 +++ arch/ppc/setcontext.S | 3 +++ arch/ppc/startcontext.S | 3 +++ arch/ppc/swapcontext.S | 3 +++ arch/ppc64/getcontext.S | 3 +++ arch/ppc64/setcontext.S | 3 +++ arch/ppc64/startcontext.S | 3 +++ arch/ppc64/swapcontext.S | 3 +++ arch/riscv32/getcontext.S | 3 +++ arch/riscv32/setcontext.S | 3 +++ arch/riscv32/swapcontext.S | 3 +++ arch/riscv64/getcontext.S | 3 +++ arch/riscv64/setcontext.S | 3 +++ arch/riscv64/swapcontext.S | 3 +++ arch/s390x/getcontext.S | 3 +++ arch/s390x/setcontext.S | 3 +++ arch/s390x/startcontext.S | 3 +++ arch/s390x/swapcontext.S | 3 +++ arch/sh/getcontext.S | 3 +++ arch/sh/setcontext.S | 3 +++ arch/sh/swapcontext.S | 3 +++ arch/x86/getcontext.S | 3 +++ arch/x86/setcontext.S | 3 +++ arch/x86/swapcontext.S | 3 +++ arch/x86_64/getcontext.S | 3 +++ arch/x86_64/setcontext.S | 3 +++ arch/x86_64/swapcontext.S | 3 +++ 46 files changed, 138 insertions(+) diff --git a/arch/aarch64/getcontext.S b/arch/aarch64/getcontext.S index 1098706..7b5432a 100644 --- a/arch/aarch64/getcontext.S +++ b/arch/aarch64/getcontext.S @@ -55,3 +55,6 @@ PROC_NAME(libucontext_getcontext): mov x0, #0 ret END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/aarch64/setcontext.S b/arch/aarch64/setcontext.S index 3d455a5..9e40003 100644 --- a/arch/aarch64/setcontext.S +++ b/arch/aarch64/setcontext.S @@ -47,3 +47,6 @@ PROC_NAME(libucontext_setcontext): /* jump to new PC */ br x16 END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/aarch64/swapcontext.S b/arch/aarch64/swapcontext.S index fddfa41..6502ed2 100644 --- a/arch/aarch64/swapcontext.S +++ b/arch/aarch64/swapcontext.S @@ -61,3 +61,6 @@ PROC_NAME(libucontext_swapcontext): mov x30, x28 ret END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/arm/getcontext.S b/arch/arm/getcontext.S index 57a56c6..756c0b5 100644 --- a/arch/arm/getcontext.S +++ b/arch/arm/getcontext.S @@ -26,3 +26,6 @@ FUNC(libucontext_getcontext) mov r0, #0 mov pc, lr END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/arm/setcontext.S b/arch/arm/setcontext.S index 7ab956e..6268146 100644 --- a/arch/arm/setcontext.S +++ b/arch/arm/setcontext.S @@ -25,3 +25,6 @@ FUNC(libucontext_setcontext) /* load link register and jump to new context */ ldmia r14, {r14, pc} END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/arm/swapcontext.S b/arch/arm/swapcontext.S index 29c6889..2262142 100644 --- a/arch/arm/swapcontext.S +++ b/arch/arm/swapcontext.S @@ -29,3 +29,6 @@ FUNC(libucontext_swapcontext) add r14, r14, #56 ldmia r14, {r14, pc} END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/m68k/getcontext.S b/arch/m68k/getcontext.S index 40f2c14..5c2d368 100644 --- a/arch/m68k/getcontext.S +++ b/arch/m68k/getcontext.S @@ -28,3 +28,6 @@ FUNC(libucontext_getcontext) clr.l %d0 /* return 0 */ rts END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/m68k/setcontext.S b/arch/m68k/setcontext.S index 994c37e..77c2bc4 100644 --- a/arch/m68k/setcontext.S +++ b/arch/m68k/setcontext.S @@ -29,3 +29,6 @@ FUNC(libucontext_setcontext) jmp (%a1) /* jump to *$a1 */ END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/m68k/swapcontext.S b/arch/m68k/swapcontext.S index e74eca5..8a69c1a 100644 --- a/arch/m68k/swapcontext.S +++ b/arch/m68k/swapcontext.S @@ -38,3 +38,6 @@ FUNC(libucontext_swapcontext) jmp (%a1) /* jump to *$a1 */ END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips/getcontext.S b/arch/mips/getcontext.S index 1655612..337d1ee 100644 --- a/arch/mips/getcontext.S +++ b/arch/mips/getcontext.S @@ -45,3 +45,6 @@ FUNC(libucontext_getcontext) jr $ra END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips/makecontext.S b/arch/mips/makecontext.S index bb841ae..e003da8 100644 --- a/arch/mips/makecontext.S +++ b/arch/mips/makecontext.S @@ -99,3 +99,6 @@ no_more_arguments: jr $ra END(libucontext_makecontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips/setcontext.S b/arch/mips/setcontext.S index 6017048..bfd52bd 100644 --- a/arch/mips/setcontext.S +++ b/arch/mips/setcontext.S @@ -49,3 +49,6 @@ FUNC(libucontext_setcontext) POP_FRAME(libucontext_setcontext) END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips/startcontext.S b/arch/mips/startcontext.S index 2ac79ec..320a095 100644 --- a/arch/mips/startcontext.S +++ b/arch/mips/startcontext.S @@ -33,3 +33,6 @@ no_linked_context: jalr $t9 nop END(libucontext_trampoline) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips/swapcontext.S b/arch/mips/swapcontext.S index 5e56470..1da6d9b 100644 --- a/arch/mips/swapcontext.S +++ b/arch/mips/swapcontext.S @@ -80,3 +80,6 @@ fail: move $v0, $zero jalr $t9 END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips64/getcontext.S b/arch/mips64/getcontext.S index 9912573..bfe4a8e 100644 --- a/arch/mips64/getcontext.S +++ b/arch/mips64/getcontext.S @@ -45,3 +45,6 @@ FUNC(libucontext_getcontext) jr $ra END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips64/makecontext.S b/arch/mips64/makecontext.S index 98b4b51..cd5d903 100644 --- a/arch/mips64/makecontext.S +++ b/arch/mips64/makecontext.S @@ -105,3 +105,6 @@ no_more_arguments: jr $ra END(libucontext_makecontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips64/setcontext.S b/arch/mips64/setcontext.S index 17b9969..3cfbd1f 100644 --- a/arch/mips64/setcontext.S +++ b/arch/mips64/setcontext.S @@ -53,3 +53,6 @@ FUNC(libucontext_setcontext) POP_FRAME(libucontext_setcontext) END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips64/startcontext.S b/arch/mips64/startcontext.S index a960279..450e324 100644 --- a/arch/mips64/startcontext.S +++ b/arch/mips64/startcontext.S @@ -33,3 +33,6 @@ no_linked_context: jalr $t9 nop END(libucontext_trampoline) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/mips64/swapcontext.S b/arch/mips64/swapcontext.S index 2284661..99344c2 100644 --- a/arch/mips64/swapcontext.S +++ b/arch/mips64/swapcontext.S @@ -85,3 +85,6 @@ fail: move $v0, $zero jalr $t9 END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc/getcontext.S b/arch/ppc/getcontext.S index 4920fd3..4137e39 100644 --- a/arch/ppc/getcontext.S +++ b/arch/ppc/getcontext.S @@ -20,3 +20,6 @@ FUNC(libucontext_getcontext) li 4, 0 b __libucontext_swapcontext@local END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc/setcontext.S b/arch/ppc/setcontext.S index d634e66..2e9d2fe 100644 --- a/arch/ppc/setcontext.S +++ b/arch/ppc/setcontext.S @@ -21,3 +21,6 @@ FUNC(libucontext_setcontext) li 3, 0 b __libucontext_swapcontext@local END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc/startcontext.S b/arch/ppc/startcontext.S index 7833808..72393a3 100644 --- a/arch/ppc/startcontext.S +++ b/arch/ppc/startcontext.S @@ -26,3 +26,6 @@ FUNC(libucontext_trampoline) no_linked_context: b exit@GOT END(libucontext_trampoline) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc/swapcontext.S b/arch/ppc/swapcontext.S index 3d1efe0..8e0f09f 100644 --- a/arch/ppc/swapcontext.S +++ b/arch/ppc/swapcontext.S @@ -27,3 +27,6 @@ FUNC(__libucontext_swapcontext) .hidden __retfromsyscall b __retfromsyscall@local END(__libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc64/getcontext.S b/arch/ppc64/getcontext.S index 1a67424..45a4c2d 100644 --- a/arch/ppc64/getcontext.S +++ b/arch/ppc64/getcontext.S @@ -25,3 +25,6 @@ FUNC(libucontext_getcontext) li 4, 0 b __libucontext_swapcontext END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc64/setcontext.S b/arch/ppc64/setcontext.S index 0cd9186..c062cd2 100644 --- a/arch/ppc64/setcontext.S +++ b/arch/ppc64/setcontext.S @@ -26,3 +26,6 @@ FUNC(libucontext_setcontext) li 3, 0 b __libucontext_swapcontext END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc64/startcontext.S b/arch/ppc64/startcontext.S index 367f99d..2d027fa 100644 --- a/arch/ppc64/startcontext.S +++ b/arch/ppc64/startcontext.S @@ -31,3 +31,6 @@ no_linked_context: b exit@GOT nop END(libucontext_trampoline) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/ppc64/swapcontext.S b/arch/ppc64/swapcontext.S index facd491..2335f5a 100644 --- a/arch/ppc64/swapcontext.S +++ b/arch/ppc64/swapcontext.S @@ -32,3 +32,6 @@ FUNC(__libucontext_swapcontext) .hidden __retfromsyscall b __retfromsyscall END(__libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/riscv32/getcontext.S b/arch/riscv32/getcontext.S index 888b6ab..06d07ab 100644 --- a/arch/riscv32/getcontext.S +++ b/arch/riscv32/getcontext.S @@ -43,3 +43,6 @@ FUNC(libucontext_getcontext) /* done saving, return */ ret END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/riscv32/setcontext.S b/arch/riscv32/setcontext.S index 0672785..df943e8 100644 --- a/arch/riscv32/setcontext.S +++ b/arch/riscv32/setcontext.S @@ -54,3 +54,6 @@ FUNC(libucontext_setcontext) /* done restoring, jump to new pc in S1 */ jr t1 END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/riscv32/swapcontext.S b/arch/riscv32/swapcontext.S index a4c7138..04dd302 100644 --- a/arch/riscv32/swapcontext.S +++ b/arch/riscv32/swapcontext.S @@ -79,3 +79,6 @@ FUNC(libucontext_swapcontext) /* done swapping, jump to new PC in S1 */ jr t1 END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/riscv64/getcontext.S b/arch/riscv64/getcontext.S index 99a9c9a..a080f4a 100644 --- a/arch/riscv64/getcontext.S +++ b/arch/riscv64/getcontext.S @@ -43,3 +43,6 @@ FUNC(libucontext_getcontext) /* done saving, return */ ret END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/riscv64/setcontext.S b/arch/riscv64/setcontext.S index 36704c9..5e9ba83 100644 --- a/arch/riscv64/setcontext.S +++ b/arch/riscv64/setcontext.S @@ -54,3 +54,6 @@ FUNC(libucontext_setcontext) /* done restoring, jump to new pc in S1 */ jr t1 END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/riscv64/swapcontext.S b/arch/riscv64/swapcontext.S index a2b013e..e529b5d 100644 --- a/arch/riscv64/swapcontext.S +++ b/arch/riscv64/swapcontext.S @@ -79,3 +79,6 @@ FUNC(libucontext_swapcontext) /* done swapping, jump to new PC in S1 */ jr t1 END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/s390x/getcontext.S b/arch/s390x/getcontext.S index fd19d9b..55a0b86 100644 --- a/arch/s390x/getcontext.S +++ b/arch/s390x/getcontext.S @@ -24,3 +24,6 @@ FUNC(libucontext_getcontext) br %r14 /* return to where we came from */ END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/s390x/setcontext.S b/arch/s390x/setcontext.S index 03fd4a1..f5426ab 100644 --- a/arch/s390x/setcontext.S +++ b/arch/s390x/setcontext.S @@ -23,3 +23,6 @@ FUNC(libucontext_setcontext) br %r14 /* return to new link register address */ END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/s390x/startcontext.S b/arch/s390x/startcontext.S index 1656943..f797229 100644 --- a/arch/s390x/startcontext.S +++ b/arch/s390x/startcontext.S @@ -28,3 +28,6 @@ no_linked_context: j .+2 /* crash if exit returns */ END(libucontext_trampoline) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/s390x/swapcontext.S b/arch/s390x/swapcontext.S index 21a9b5a..61ba87c 100644 --- a/arch/s390x/swapcontext.S +++ b/arch/s390x/swapcontext.S @@ -28,3 +28,6 @@ FUNC(libucontext_swapcontext) br %r14 /* return to new link register address */ END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/sh/getcontext.S b/arch/sh/getcontext.S index 0978af6..aa88fe9 100644 --- a/arch/sh/getcontext.S +++ b/arch/sh/getcontext.S @@ -54,3 +54,6 @@ FUNC(libucontext_getcontext) mov #0, r0 /* set return value as zero */ rts END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/sh/setcontext.S b/arch/sh/setcontext.S index cee065c..6141c72 100644 --- a/arch/sh/setcontext.S +++ b/arch/sh/setcontext.S @@ -58,3 +58,6 @@ FUNC(libucontext_setcontext) mov.l @r15+, r0 /* pop original r0 from stack */ END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/sh/swapcontext.S b/arch/sh/swapcontext.S index 2890613..2b50f94 100644 --- a/arch/sh/swapcontext.S +++ b/arch/sh/swapcontext.S @@ -93,3 +93,6 @@ FUNC(libucontext_swapcontext) mov.l @r15+, r0 /* pop original r0 from stack */ END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/x86/getcontext.S b/arch/x86/getcontext.S index 4b95197..439d5c7 100644 --- a/arch/x86/getcontext.S +++ b/arch/x86/getcontext.S @@ -48,3 +48,6 @@ FUNC(libucontext_getcontext) xorl %eax, %eax ret END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/x86/setcontext.S b/arch/x86/setcontext.S index 75d2108..4418ea7 100644 --- a/arch/x86/setcontext.S +++ b/arch/x86/setcontext.S @@ -43,3 +43,6 @@ FUNC(libucontext_setcontext) ret END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/x86/swapcontext.S b/arch/x86/swapcontext.S index 3594fc0..bb06df2 100644 --- a/arch/x86/swapcontext.S +++ b/arch/x86/swapcontext.S @@ -71,3 +71,6 @@ FUNC(libucontext_swapcontext) ret END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/x86_64/getcontext.S b/arch/x86_64/getcontext.S index 168fa47..1b26849 100644 --- a/arch/x86_64/getcontext.S +++ b/arch/x86_64/getcontext.S @@ -47,3 +47,6 @@ FUNC(libucontext_getcontext) xorl %eax, %eax ret END(libucontext_getcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/x86_64/setcontext.S b/arch/x86_64/setcontext.S index 4dc2702..b1aaf6e 100644 --- a/arch/x86_64/setcontext.S +++ b/arch/x86_64/setcontext.S @@ -44,3 +44,6 @@ FUNC(libucontext_setcontext) xorl %eax, %eax ret END(libucontext_setcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif diff --git a/arch/x86_64/swapcontext.S b/arch/x86_64/swapcontext.S index 43dafb5..bcd15db 100644 --- a/arch/x86_64/swapcontext.S +++ b/arch/x86_64/swapcontext.S @@ -73,3 +73,6 @@ FUNC(libucontext_swapcontext) xorl %eax, %eax ret END(libucontext_swapcontext) +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack,"",%progbits +#endif -- 2.34.1