diff options
author | Chris Packham <judge.packham@gmail.com> | 2023-09-13 17:10:20 +1200 |
---|---|---|
committer | Chris Packham <judge.packham@gmail.com> | 2023-09-17 15:41:50 +1200 |
commit | c175b21ce470a07875a5db86f21439f02f93df0e (patch) | |
tree | fb9e2da6156e247142f9c67fe21edd5a5978f66a /packages/gcc/13.2.0/0015-aarch64-Avoid-a-use-of-callee_offset.patch | |
parent | 977ed69427889a09f8e77ff9b60a6d50a18d8417 (diff) | |
download | crosstool-ng-c175b21ce470a07875a5db86f21439f02f93df0e.tar.gz crosstool-ng-c175b21ce470a07875a5db86f21439f02f93df0e.tar.bz2 crosstool-ng-c175b21ce470a07875a5db86f21439f02f93df0e.zip |
gcc: Bring in upstream fixes for CVE-2023-4039
Bring in the fixes for GCC 7 through 13.
https://rtx.meta.security/mitigation/2023/09/12/CVE-2023-4039.html
https://developer.arm.com/Arm%20Security%20Center/GCC%20Stack%20Protector%20Vulnerability%20AArch64
Signed-off-by: Chris Packham <judge.packham@gmail.com>
Diffstat (limited to 'packages/gcc/13.2.0/0015-aarch64-Avoid-a-use-of-callee_offset.patch')
-rw-r--r-- | packages/gcc/13.2.0/0015-aarch64-Avoid-a-use-of-callee_offset.patch | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/packages/gcc/13.2.0/0015-aarch64-Avoid-a-use-of-callee_offset.patch b/packages/gcc/13.2.0/0015-aarch64-Avoid-a-use-of-callee_offset.patch new file mode 100644 index 00000000..8a30f5a6 --- /dev/null +++ b/packages/gcc/13.2.0/0015-aarch64-Avoid-a-use-of-callee_offset.patch @@ -0,0 +1,73 @@ +From 89a9fa287706c5011f61926eaf65e7b996b963a3 Mon Sep 17 00:00:00 2001 +From: Richard Sandiford <richard.sandiford@arm.com> +Date: Tue, 12 Sep 2023 16:07:12 +0100 +Subject: [PATCH 15/32] aarch64: Avoid a use of callee_offset + +When we emit the frame chain, i.e. when we reach Here in this statement +of aarch64_expand_prologue: + + if (emit_frame_chain) + { + // Here + ... + } + +the stack is in one of two states: + +- We've allocated up to the frame chain, but no more. + +- We've allocated the whole frame, and the frame chain is within easy + reach of the new SP. + +The offset of the frame chain from the current SP is available +in aarch64_frame as callee_offset. It is also available as the +chain_offset local variable, where the latter is calculated from other +data. (However, chain_offset is not always equal to callee_offset when +!emit_frame_chain, so chain_offset isn't redundant.) + +In c600df9a4060da3c6121ff4d0b93f179eafd69d1 I switched to using +chain_offset for the initialisation of the hard frame pointer: + + aarch64_add_offset (Pmode, hard_frame_pointer_rtx, +- stack_pointer_rtx, callee_offset, ++ stack_pointer_rtx, chain_offset, + tmp1_rtx, tmp0_rtx, frame_pointer_needed); + +But the later REG_CFA_ADJUST_CFA handling still used callee_offset. + +I think the difference is harmless, but it's more logical for the +CFA note to be in sync, and it's more convenient for later patches +if it uses chain_offset. + +gcc/ + * config/aarch64/aarch64.cc (aarch64_expand_prologue): Use + chain_offset rather than callee_offset. +--- + gcc/config/aarch64/aarch64.cc | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc +index 5d473d161d97..4f233c95140e 100644 +--- a/gcc/config/aarch64/aarch64.cc ++++ b/gcc/config/aarch64/aarch64.cc +@@ -9985,7 +9985,6 @@ aarch64_expand_prologue (void) + poly_int64 initial_adjust = frame.initial_adjust; + HOST_WIDE_INT callee_adjust = frame.callee_adjust; + poly_int64 final_adjust = frame.final_adjust; +- poly_int64 callee_offset = frame.callee_offset; + poly_int64 sve_callee_adjust = frame.sve_callee_adjust; + poly_int64 below_hard_fp_saved_regs_size + = frame.below_hard_fp_saved_regs_size; +@@ -10098,8 +10097,7 @@ aarch64_expand_prologue (void) + implicit. */ + if (!find_reg_note (insn, REG_CFA_ADJUST_CFA, NULL_RTX)) + { +- rtx src = plus_constant (Pmode, stack_pointer_rtx, +- callee_offset); ++ rtx src = plus_constant (Pmode, stack_pointer_rtx, chain_offset); + add_reg_note (insn, REG_CFA_ADJUST_CFA, + gen_rtx_SET (hard_frame_pointer_rtx, src)); + } +-- +2.42.0 + |