Skip to contentSkip to conversation

Toolchain fixes for Scarthgap

PATCH In review Mark Hatle 4 participants 8 messages May 24, 2024 – May 28, 2024

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

cover Toolchain fixes for Scarthgap

Two different toolchain fixes for Scarthgap.

The binutils change was found in a AMD/Xilinx specific build script that attempts to disassemble some code as part of a firmware setup. This cortex-a53 baremetal firmware triggered a fault fixed by the issue.

The newer versions of binutils have already accepted this change, but I'm not exactly sure which version(s) have it other then then the current development tree.

The GCC change only affects cortex-M. This is simply a port of the GCC accepted change into Yocto Project for baremetal usage. Unfortunately I don't have any sort of test cases to show it works or doesn't. It does not break any of my existing test cases related to Linux for cortex-r baremetal.

Again this change has already been accepted to newer versions of GCC.

Mark Hatle (2):
binutils: Fix aarch64 disassembly abort
gcc: Fix for CVE-2024-0151

 .../binutils/binutils-2.42.inc                |   1 +
 ...sserts-from-operand-qualifier-decode.patch | 382 ++++++++++++++++++
 meta/recipes-devtools/gcc/gcc-13.2.inc        |   1 +
 .../gcc/gcc/CVE-2024-0151.patch               | 315 +++++++++++++++
 4 files changed, 699 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch
 create mode 100644 meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 1/2 binutils: Fix aarch64 disassembly abort

Code backported from binutils development tree.

aarch64: Remove asserts from operand qualifier decoders [PR31595]

Given that the disassembler should never abort when decoding (potentially random) data, assertion statements in the `get_*reg_qualifier_from_value' function family prove problematic.

...

---
 .../binutils/binutils-2.42.inc                |   1 +
 ...sserts-from-operand-qualifier-decode.patch | 382 ++++++++++++++++++
 2 files changed, 383 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch
meta/recipes-devtools/binutils/binutils-2.42.inc +1 -0
index 3b6f47d4ce..d2f49560f3 100644
@@ -36,5 +36,6 @@ SRC_URI = "\
      file://0013-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \
      file://0014-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \
      file://0015-gprofng-change-use-of-bignum-to-bigint.patch \
+     file://0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch \
 "
 S  = "${WORKDIR}/git"
meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch new file +382 -0

382 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

Re: [OE-core] [scarthgap 1/2] binutils: Fix aarch64 disassembly abort

This patch will need to be submitted and accepted for master before I can take it for scarthgap.

Thanks,

Steve

Quoted 429 lines · Mark Hatle via lists.openembedded.org

Code backported from binutils development tree.

aarch64: Remove asserts from operand qualifier decoders [PR31595]

Given that the disassembler should never abort when decoding (potentially random) data, assertion statements in the `get_*reg_qualifier_from_value' function family prove problematic.

...

---
 .../binutils/binutils-2.42.inc                |   1 +
 ...sserts-from-operand-qualifier-decode.patch | 382 ++++++++++++++++++
 2 files changed, 383 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch
meta/recipes-devtools/binutils/binutils-2.42.inc +1 -0
index 3b6f47d4ce..d2f49560f3 100644
@@ -36,5 +36,6 @@ SRC_URI = "\
      file://0013-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \
      file://0014-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \
      file://0015-gprofng-change-use-of-bignum-to-bigint.patch \
+     file://0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch \
 "
 S  = "${WORKDIR}/git"
meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch new file +382 -1
new file mode 100644
index 0000000000..7b52425a38
@@ -0,0 +1,382 @@
+From 5b1c70bfe0d8f84dc28237d6150b7b9d57c791a8 Mon Sep 17 00:00:00 2001
+From: Victor Do Nascimento <[email protected]>
+Date: Tue, 16 Apr 2024 11:49:15 +0100
+Subject: [PATCH] aarch64: Remove asserts from operand qualifier decoders
+ [PR31595]
+
+Given that the disassembler should never abort when decoding
+(potentially random) data, assertion statements in the
+`get_*reg_qualifier_from_value' function family prove problematic.
+
+Consider the random 32-bit word W, encoded in a data segment and
+encountered on execution of `objdump -D <obj_name>'.
+
+If:
+
+  (W & ~opcode_mask) == valid instruction
+
+Then before `print_insn_aarch64_word' has a chance to report the
+instruction as potentially undefined, an attempt will be made to have
+the qualifiers for the instruction's register operands (if any)
+decoded.  If the relevant bits do not map onto a valid qualifier for
+the matched instruction-like word, an abort will be triggered and the
+execution of objdump aborted.
+
+As this scenario is perfectly feasible and, in light of the fact that
+objdump must successfully decode all sections of a given object file,
+it is not appropriate to assert in this family of functions.
+
+Therefore, we add a new pseudo-qualifier `AARCH64_OPND_QLF_ERR' for
+handling invalid qualifier-associated values and re-purpose the
+assertion conditions in qualifier-retrieving functions to be the
+predicate guarding the returning of the calculated qualifier type.
+If the predicate fails, we return this new qualifier and allow the
+caller to handle the error as appropriate.
+
+As these functions are called either from within
+`aarch64_extract_operand' or `do_special_decoding', both of which are
+expected to return non-zero values, it suffices that callers return
+zero upon encountering `AARCH64_OPND_QLF_ERR'.
+
+Ar present the error presented in the hypothetical scenario has been
+encountered in `get_sreg_qualifier_from_value', but the change is made
+to the whole family to keep the interface consistent.
+
+Bug: https://sourceware.org/PR31595
+
+Upstream-Status: Backport [commit 2601b201e95ea0edab89342ee7137c74e88a8a79]
+
+Signed-off-by: Mark Hatle <[email protected]>
+---
+ .../testsuite/binutils-all/aarch64/illegal.d  |  1 +
+ .../testsuite/binutils-all/aarch64/illegal.s  |  3 +
+ include/opcode/aarch64.h                      |  3 +
+ opcodes/aarch64-dis.c                         | 98 +++++++++++++++----
+ 4 files changed, 87 insertions(+), 18 deletions(-)
+
+diff --git a/binutils/testsuite/binutils-all/aarch64/illegal.d b/binutils/testsuite/binutils-all/aarch64/illegal.d
+index 4b90a1d9f39..b69318aec85 100644
+--- a/binutils/testsuite/binutils-all/aarch64/illegal.d
++++ b/binutils/testsuite/binutils-all/aarch64/illegal.d
+@@ -8,5 +8,6 @@ Disassembly of section \.text:
+
+ 0+000 <.*>:
+ [     ]+0:[   ]+68ea18cc[     ]+.inst[        ]+0x68ea18cc ; undefined
++[     ]+4:[   ]+9dc39839[     ]+.inst[        ]+0x9dc39839 ; undefined
+ #pass
+
+diff --git a/binutils/testsuite/binutils-all/aarch64/illegal.s b/binutils/testsuite/binutils-all/aarch64/illegal.s
+index 216cbe6f265..43668c6db55 100644
+--- a/binutils/testsuite/binutils-all/aarch64/illegal.s
++++ b/binutils/testsuite/binutils-all/aarch64/illegal.s
+@@ -4,4 +4,7 @@
+       # ldpsw   x12, x6, [x6],#-8 ; illegal because one of the dest regs is also the address reg
+       .inst 0x68ea18cc
+
++      # illegal, resembles the opcode `ldapur' with invalid qualifier bits
++      .inst 0x9dc39839
++
+       # FIXME: Add more illegal instructions here.
+diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h
+index 2fca9528c20..e8fe93ef127 100644
+--- a/include/opcode/aarch64.h
++++ b/include/opcode/aarch64.h
+@@ -894,6 +894,9 @@ enum aarch64_opnd_qualifier
+   /* Special qualifier helping retrieve qualifier information during the
+      decoding time (currently not in use).  */
+   AARCH64_OPND_QLF_RETRIEVE,
++
++  /* Special qualifier used for indicating error in qualifier retrieval.  */
++  AARCH64_OPND_QLF_ERR,
+ };
+
+ /* Instruction class.  */
+diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c
+index 96f42ae862a..b70e6da9eb7 100644
+--- a/opcodes/aarch64-dis.c
++++ b/opcodes/aarch64-dis.c
+@@ -219,9 +219,10 @@ static inline enum aarch64_opnd_qualifier
+ get_greg_qualifier_from_value (aarch64_insn value)
+ {
+   enum aarch64_opnd_qualifier qualifier = AARCH64_OPND_QLF_W + value;
+-  assert (value <= 0x1
+-        && aarch64_get_qualifier_standard_value (qualifier) == value);
+-  return qualifier;
++  if (value <= 0x1
++      && aarch64_get_qualifier_standard_value (qualifier) == value)
++    return qualifier;
++  return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Given VALUE, return qualifier for a vector register.  This does not support
+@@ -237,9 +238,10 @@ get_vreg_qualifier_from_value (aarch64_insn value)
+   if (qualifier >= AARCH64_OPND_QLF_V_2H)
+     qualifier += 1;
+
+-  assert (value <= 0x8
+-        && aarch64_get_qualifier_standard_value (qualifier) == value);
+-  return qualifier;
++  if (value <= 0x8
++      && aarch64_get_qualifier_standard_value (qualifier) == value)
++    return qualifier;
++  return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Given VALUE, return qualifier for an FP or AdvSIMD scalar register.  */
+@@ -248,9 +250,10 @@ get_sreg_qualifier_from_value (aarch64_insn value)
+ {
+   enum aarch64_opnd_qualifier qualifier = AARCH64_OPND_QLF_S_B + value;
+
+-  assert (value <= 0x4
+-        && aarch64_get_qualifier_standard_value (qualifier) == value);
+-  return qualifier;
++  if (value <= 0x4
++      && aarch64_get_qualifier_standard_value (qualifier) == value)
++    return qualifier;
++  return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Given the instruction in *INST which is probably half way through the
+@@ -263,13 +266,17 @@ get_expected_qualifier (const aarch64_inst *inst, int i)
+ {
+   aarch64_opnd_qualifier_seq_t qualifiers;
+   /* Should not be called if the qualifier is known.  */
+-  assert (inst->operands[i].qualifier == AARCH64_OPND_QLF_NIL);
+-  int invalid_count;
+-  if (aarch64_find_best_match (inst, inst->opcode->qualifiers_list,
+-                             i, qualifiers, &invalid_count))
+-    return qualifiers[i];
++  if (inst->operands[i].qualifier == AARCH64_OPND_QLF_NIL)
++    {
++      int invalid_count;
++      if (aarch64_find_best_match (inst, inst->opcode->qualifiers_list,
++                                 i, qualifiers, &invalid_count))
++      return qualifiers[i];
++      else
++      return AARCH64_OPND_QLF_NIL;
++    }
+   else
+-    return AARCH64_OPND_QLF_NIL;
++    return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Operand extractors.  */
+@@ -355,6 +362,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+         aarch64_insn value = extract_field (FLD_imm4_11, code, 0);
+         /* Depend on AARCH64_OPND_Ed to determine the qualifier.  */
+         info->qualifier = get_expected_qualifier (inst, info->idx);
++        if (info->qualifier == AARCH64_OPND_QLF_ERR)
++          return 0;
+         shift = get_logsz (aarch64_get_qualifier_esize (info->qualifier));
+         info->reglane.index = value >> shift;
+       }
+@@ -374,6 +383,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+         if (pos > 3)
+           return false;
+         info->qualifier = get_sreg_qualifier_from_value (pos);
++        if (info->qualifier == AARCH64_OPND_QLF_ERR)
++          return 0;
+         info->reglane.index = (unsigned) (value >> 1);
+       }
+     }
+@@ -381,6 +392,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+     {
+       /* Need information in other operand(s) to help decoding.  */
+       info->qualifier = get_expected_qualifier (inst, info->idx);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       switch (info->qualifier)
+       {
+       case AARCH64_OPND_QLF_S_4B:
+@@ -405,6 +418,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+
+       /* Need information in other operand(s) to help decoding.  */
+       info->qualifier = get_expected_qualifier (inst, info->idx);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       switch (info->qualifier)
+       {
+       case AARCH64_OPND_QLF_S_H:
+@@ -644,9 +659,15 @@ aarch64_ext_advsimd_imm_shift (const aarch64_operand *self ATTRIBUTE_UNUSED,
+        1xxx   1       2D  */
+       info->qualifier =
+       get_vreg_qualifier_from_value ((pos << 1) | (int) Q);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return false;
+     }
+   else
+-    info->qualifier = get_sreg_qualifier_from_value (pos);
++    {
++      info->qualifier = get_sreg_qualifier_from_value (pos);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
++    }
+
+   if (info->type == AARCH64_OPND_IMM_VLSR)
+     /* immh   <shift>
+@@ -773,6 +794,8 @@ aarch64_ext_advsimd_imm_modified (const aarch64_operand *self ATTRIBUTE_UNUSED,
+
+   /* cmode */
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+   switch (info->qualifier)
+     {
+     case AARCH64_OPND_QLF_NIL:
+@@ -1014,6 +1037,8 @@ aarch64_ext_ft (const aarch64_operand *self ATTRIBUTE_UNUSED,
+       if (value > 0x4)
+       return false;
+       info->qualifier = get_sreg_qualifier_from_value (value);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+
+   return true;
+@@ -1086,6 +1111,8 @@ aarch64_ext_rcpc3_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+                              aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+ {
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+@@ -1105,6 +1132,8 @@ aarch64_ext_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+ {
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+@@ -1154,6 +1183,8 @@ aarch64_ext_addr_regoff (const aarch64_operand *self ATTRIBUTE_UNUSED,
+       /* Need information in other operand(s) to help achieve the decoding
+        from 'S' field.  */
+       info->qualifier = get_expected_qualifier (inst, info->idx);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       /* Get the size of the data element that is accessed, which may be
+        different from that of the source register size, e.g. in strb/ldrb.  */
+       size = aarch64_get_qualifier_esize (info->qualifier);
+@@ -1172,6 +1203,8 @@ aarch64_ext_addr_simm (const aarch64_operand *self, aarch64_opnd_info *info,
+ {
+   aarch64_insn imm;
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+
+   /* Rn */
+   info->addr.base_regno = extract_field (FLD_Rn, code, 0);
+@@ -1210,6 +1243,8 @@ aarch64_ext_addr_uimm12 (const aarch64_operand *self, aarch64_opnd_info *info,
+ {
+   int shift;
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+   shift = get_logsz (aarch64_get_qualifier_esize (info->qualifier));
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+@@ -1228,6 +1263,8 @@ aarch64_ext_addr_simm10 (const aarch64_operand *self, aarch64_opnd_info *info,
+   aarch64_insn imm;
+
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+   /* simm10 */
+@@ -2467,6 +2504,8 @@ decode_sizeq (aarch64_inst *inst)
+   if (mask == 0x7)
+     {
+       inst->operands[idx].qualifier = get_vreg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       return 1;
+     }
+
+@@ -2649,6 +2688,8 @@ do_special_decoding (aarch64_inst *inst)
+       idx = select_operand_for_sf_field_coding (inst->opcode);
+       value = extract_field (FLD_sf, inst->value, 0);
+       inst->operands[idx].qualifier = get_greg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       if ((inst->opcode->flags & F_N)
+         && extract_field (FLD_N, inst->value, 0) != value)
+       return 0;
+@@ -2659,6 +2700,8 @@ do_special_decoding (aarch64_inst *inst)
+       idx = select_operand_for_sf_field_coding (inst->opcode);
+       value = extract_field (FLD_lse_sz, inst->value, 0);
+       inst->operands[idx].qualifier = get_greg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+   /* rcpc3 'size' field.  */
+   if (inst->opcode->flags & F_RCPC3_SIZE)
+@@ -2670,12 +2713,18 @@ do_special_decoding (aarch64_inst *inst)
+       {
+         if (aarch64_operands[inst->operands[i].type].op_class
+             == AARCH64_OPND_CLASS_INT_REG)
+-          inst->operands[i].qualifier = get_greg_qualifier_from_value (value & 1);
++          {
++            inst->operands[i].qualifier = get_greg_qualifier_from_value (value & 1);
++            if (inst->operands[i].qualifier == AARCH64_OPND_QLF_ERR)
++              return 0;
++          }
+         else if (aarch64_operands[inst->operands[i].type].op_class
+             == AARCH64_OPND_CLASS_FP_REG)
+           {
+             value += (extract_field (FLD_opc1, inst->value, 0) << 2);
+             inst->operands[i].qualifier = get_sreg_qualifier_from_value (value);
++            if (inst->operands[i].qualifier == AARCH64_OPND_QLF_ERR)
++              return 0;
+           }
+       }
+     }
+@@ -2709,7 +2758,11 @@ do_special_decoding (aarch64_inst *inst)
+       /* For most related instruciton, the 'size' field is fully available for
+        operand encoding.  */
+       if (mask == 0x3)
+-      inst->operands[idx].qualifier = get_sreg_qualifier_from_value (value);
++      {
++        inst->operands[idx].qualifier = get_sreg_qualifier_from_value (value);
++        if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++          return 0;
++      }
+       else
+       {
+         get_operand_possible_qualifiers (idx, inst->opcode->qualifiers_list,
+@@ -2744,6 +2797,9 @@ do_special_decoding (aarch64_inst *inst)
+       Q = (unsigned) extract_field (FLD_Q, inst->value, inst->opcode->mask);
+       inst->operands[0].qualifier =
+       get_vreg_qualifier_from_value ((num << 1) | Q);
++      if (inst->operands[0].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
++
+     }
+
+   if ((inst->opcode->flags & F_OPD_SIZE) && inst->opcode->iclass == sve2_urqvs)
+@@ -2753,7 +2809,11 @@ do_special_decoding (aarch64_inst *inst)
+                                      inst->opcode->mask);
+       inst->operands[0].qualifier
+       = get_vreg_qualifier_from_value (1 + (size << 1));
++      if (inst->operands[0].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       inst->operands[2].qualifier = get_sreg_qualifier_from_value (size);
++      if (inst->operands[2].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+
+   if (inst->opcode->flags & F_GPRSIZE_IN_Q)
+@@ -2772,6 +2832,8 @@ do_special_decoding (aarch64_inst *inst)
+       assert (idx == 0 || idx == 1);
+       value = extract_field (FLD_Q, inst->value, 0);
+       inst->operands[idx].qualifier = get_greg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+
+   if (inst->opcode->flags & F_LDS_SIZE)
+--
+2.34.1
+
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199862): https://lists.openembedded.org/g/openembedded-core/message/199862
Mute This Topic: https://lists.openembedded.org/mt/106288403/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

Re: [OE-core] [scarthgap 1/2] binutils: Fix aarch64 disassembly abort

Quoted 2 lines · Steve Sakoman

This patch will need to be submitted and accepted for master before I can take it for scarthgap.

I didn't submit because I thought there was a new binutils version in master-next. I guess I'm wrong.

The patch should apply the same in master.

--Mark

Quoted 439 lines

Thanks,

Steve

Quoted 433 lines · Mark Hatle via lists.openembedded.org

Code backported from binutils development tree.

aarch64: Remove asserts from operand qualifier decoders [PR31595]

Given that the disassembler should never abort when decoding (potentially random) data, assertion statements in the `get_*reg_qualifier_from_value' function family prove problematic.

   ...
---
  .../binutils/binutils-2.42.inc                |   1 +
  ...sserts-from-operand-qualifier-decode.patch | 382 ++++++++++++++++++
  2 files changed, 383 insertions(+)

create mode 100644 meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch

meta/recipes-devtools/binutils/binutils-2.42.inc +1 -0
index 3b6f47d4ce..d2f49560f3 100644
@@ -36,5 +36,6 @@ SRC_URI = "\
       file://0013-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \
       file://0014-Remove-duplicate-pe-dll.o-entry-deom-targ_extra_ofil.patch \
       file://0015-gprofng-change-use-of-bignum-to-bigint.patch \
+     file://0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch \
  "
  S  = "${WORKDIR}/git"
meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch new file +382 -1
new file mode 100644
index 0000000000..7b52425a38
@@ -0,0 +1,382 @@
+From 5b1c70bfe0d8f84dc28237d6150b7b9d57c791a8 Mon Sep 17 00:00:00 2001
+From: Victor Do Nascimento <[email protected]>
+Date: Tue, 16 Apr 2024 11:49:15 +0100
+Subject: [PATCH] aarch64: Remove asserts from operand qualifier decoders
+ [PR31595]
+
+Given that the disassembler should never abort when decoding
+(potentially random) data, assertion statements in the
+`get_*reg_qualifier_from_value' function family prove problematic.
+
+Consider the random 32-bit word W, encoded in a data segment and
+encountered on execution of `objdump -D <obj_name>'.
+
+If:
+
+  (W & ~opcode_mask) == valid instruction
+
+Then before `print_insn_aarch64_word' has a chance to report the
+instruction as potentially undefined, an attempt will be made to have
+the qualifiers for the instruction's register operands (if any)
+decoded.  If the relevant bits do not map onto a valid qualifier for
+the matched instruction-like word, an abort will be triggered and the
+execution of objdump aborted.
+
+As this scenario is perfectly feasible and, in light of the fact that
+objdump must successfully decode all sections of a given object file,
+it is not appropriate to assert in this family of functions.
+
+Therefore, we add a new pseudo-qualifier `AARCH64_OPND_QLF_ERR' for
+handling invalid qualifier-associated values and re-purpose the
+assertion conditions in qualifier-retrieving functions to be the
+predicate guarding the returning of the calculated qualifier type.
+If the predicate fails, we return this new qualifier and allow the
+caller to handle the error as appropriate.
+
+As these functions are called either from within
+`aarch64_extract_operand' or `do_special_decoding', both of which are
+expected to return non-zero values, it suffices that callers return
+zero upon encountering `AARCH64_OPND_QLF_ERR'.
+
+Ar present the error presented in the hypothetical scenario has been
+encountered in `get_sreg_qualifier_from_value', but the change is made
+to the whole family to keep the interface consistent.
+
+Bug: https://sourceware.org/PR31595
+
+Upstream-Status: Backport [commit 2601b201e95ea0edab89342ee7137c74e88a8a79]
+
+Signed-off-by: Mark Hatle <[email protected]>
+---
+ .../testsuite/binutils-all/aarch64/illegal.d  |  1 +
+ .../testsuite/binutils-all/aarch64/illegal.s  |  3 +
+ include/opcode/aarch64.h                      |  3 +
+ opcodes/aarch64-dis.c                         | 98 +++++++++++++++----
+ 4 files changed, 87 insertions(+), 18 deletions(-)
+
+diff --git a/binutils/testsuite/binutils-all/aarch64/illegal.d b/binutils/testsuite/binutils-all/aarch64/illegal.d
+index 4b90a1d9f39..b69318aec85 100644
+--- a/binutils/testsuite/binutils-all/aarch64/illegal.d
++++ b/binutils/testsuite/binutils-all/aarch64/illegal.d
+@@ -8,5 +8,6 @@ Disassembly of section \.text:
+
+ 0+000 <.*>:
+ [     ]+0:[   ]+68ea18cc[     ]+.inst[        ]+0x68ea18cc ; undefined
++[     ]+4:[   ]+9dc39839[     ]+.inst[        ]+0x9dc39839 ; undefined
+ #pass
+
+diff --git a/binutils/testsuite/binutils-all/aarch64/illegal.s b/binutils/testsuite/binutils-all/aarch64/illegal.s
+index 216cbe6f265..43668c6db55 100644
+--- a/binutils/testsuite/binutils-all/aarch64/illegal.s
++++ b/binutils/testsuite/binutils-all/aarch64/illegal.s
+@@ -4,4 +4,7 @@
+       # ldpsw   x12, x6, [x6],#-8 ; illegal because one of the dest regs is also the address reg
+       .inst 0x68ea18cc
+
++      # illegal, resembles the opcode `ldapur' with invalid qualifier bits
++      .inst 0x9dc39839
++
+       # FIXME: Add more illegal instructions here.
+diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h
+index 2fca9528c20..e8fe93ef127 100644
+--- a/include/opcode/aarch64.h
++++ b/include/opcode/aarch64.h
+@@ -894,6 +894,9 @@ enum aarch64_opnd_qualifier
+   /* Special qualifier helping retrieve qualifier information during the
+      decoding time (currently not in use).  */
+   AARCH64_OPND_QLF_RETRIEVE,
++
++  /* Special qualifier used for indicating error in qualifier retrieval.  */
++  AARCH64_OPND_QLF_ERR,
+ };
+
+ /* Instruction class.  */
+diff --git a/opcodes/aarch64-dis.c b/opcodes/aarch64-dis.c
+index 96f42ae862a..b70e6da9eb7 100644
+--- a/opcodes/aarch64-dis.c
++++ b/opcodes/aarch64-dis.c
+@@ -219,9 +219,10 @@ static inline enum aarch64_opnd_qualifier
+ get_greg_qualifier_from_value (aarch64_insn value)
+ {
+   enum aarch64_opnd_qualifier qualifier = AARCH64_OPND_QLF_W + value;
+-  assert (value <= 0x1
+-        && aarch64_get_qualifier_standard_value (qualifier) == value);
+-  return qualifier;
++  if (value <= 0x1
++      && aarch64_get_qualifier_standard_value (qualifier) == value)
++    return qualifier;
++  return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Given VALUE, return qualifier for a vector register.  This does not support
+@@ -237,9 +238,10 @@ get_vreg_qualifier_from_value (aarch64_insn value)
+   if (qualifier >= AARCH64_OPND_QLF_V_2H)
+     qualifier += 1;
+
+-  assert (value <= 0x8
+-        && aarch64_get_qualifier_standard_value (qualifier) == value);
+-  return qualifier;
++  if (value <= 0x8
++      && aarch64_get_qualifier_standard_value (qualifier) == value)
++    return qualifier;
++  return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Given VALUE, return qualifier for an FP or AdvSIMD scalar register.  */
+@@ -248,9 +250,10 @@ get_sreg_qualifier_from_value (aarch64_insn value)
+ {
+   enum aarch64_opnd_qualifier qualifier = AARCH64_OPND_QLF_S_B + value;
+
+-  assert (value <= 0x4
+-        && aarch64_get_qualifier_standard_value (qualifier) == value);
+-  return qualifier;
++  if (value <= 0x4
++      && aarch64_get_qualifier_standard_value (qualifier) == value)
++    return qualifier;
++  return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Given the instruction in *INST which is probably half way through the
+@@ -263,13 +266,17 @@ get_expected_qualifier (const aarch64_inst *inst, int i)
+ {
+   aarch64_opnd_qualifier_seq_t qualifiers;
+   /* Should not be called if the qualifier is known.  */
+-  assert (inst->operands[i].qualifier == AARCH64_OPND_QLF_NIL);
+-  int invalid_count;
+-  if (aarch64_find_best_match (inst, inst->opcode->qualifiers_list,
+-                             i, qualifiers, &invalid_count))
+-    return qualifiers[i];
++  if (inst->operands[i].qualifier == AARCH64_OPND_QLF_NIL)
++    {
++      int invalid_count;
++      if (aarch64_find_best_match (inst, inst->opcode->qualifiers_list,
++                                 i, qualifiers, &invalid_count))
++      return qualifiers[i];
++      else
++      return AARCH64_OPND_QLF_NIL;
++    }
+   else
+-    return AARCH64_OPND_QLF_NIL;
++    return AARCH64_OPND_QLF_ERR;
+ }
+
+ /* Operand extractors.  */
+@@ -355,6 +362,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+         aarch64_insn value = extract_field (FLD_imm4_11, code, 0);
+         /* Depend on AARCH64_OPND_Ed to determine the qualifier.  */
+         info->qualifier = get_expected_qualifier (inst, info->idx);
++        if (info->qualifier == AARCH64_OPND_QLF_ERR)
++          return 0;
+         shift = get_logsz (aarch64_get_qualifier_esize (info->qualifier));
+         info->reglane.index = value >> shift;
+       }
+@@ -374,6 +383,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+         if (pos > 3)
+           return false;
+         info->qualifier = get_sreg_qualifier_from_value (pos);
++        if (info->qualifier == AARCH64_OPND_QLF_ERR)
++          return 0;
+         info->reglane.index = (unsigned) (value >> 1);
+       }
+     }
+@@ -381,6 +392,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+     {
+       /* Need information in other operand(s) to help decoding.  */
+       info->qualifier = get_expected_qualifier (inst, info->idx);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       switch (info->qualifier)
+       {
+       case AARCH64_OPND_QLF_S_4B:
+@@ -405,6 +418,8 @@ aarch64_ext_reglane (const aarch64_operand *self, aarch64_opnd_info *info,
+
+       /* Need information in other operand(s) to help decoding.  */
+       info->qualifier = get_expected_qualifier (inst, info->idx);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       switch (info->qualifier)
+       {
+       case AARCH64_OPND_QLF_S_H:
+@@ -644,9 +659,15 @@ aarch64_ext_advsimd_imm_shift (const aarch64_operand *self ATTRIBUTE_UNUSED,
+        1xxx   1       2D  */
+       info->qualifier =
+       get_vreg_qualifier_from_value ((pos << 1) | (int) Q);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return false;
+     }
+   else
+-    info->qualifier = get_sreg_qualifier_from_value (pos);
++    {
++      info->qualifier = get_sreg_qualifier_from_value (pos);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
++    }
+
+   if (info->type == AARCH64_OPND_IMM_VLSR)
+     /* immh   <shift>
+@@ -773,6 +794,8 @@ aarch64_ext_advsimd_imm_modified (const aarch64_operand *self ATTRIBUTE_UNUSED,
+
+   /* cmode */
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+   switch (info->qualifier)
+     {
+     case AARCH64_OPND_QLF_NIL:
+@@ -1014,6 +1037,8 @@ aarch64_ext_ft (const aarch64_operand *self ATTRIBUTE_UNUSED,
+       if (value > 0x4)
+       return false;
+       info->qualifier = get_sreg_qualifier_from_value (value);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+
+   return true;
+@@ -1086,6 +1111,8 @@ aarch64_ext_rcpc3_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+                              aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+ {
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+@@ -1105,6 +1132,8 @@ aarch64_ext_addr_offset (const aarch64_operand *self ATTRIBUTE_UNUSED,
+                        aarch64_operand_error *errors ATTRIBUTE_UNUSED)
+ {
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+@@ -1154,6 +1183,8 @@ aarch64_ext_addr_regoff (const aarch64_operand *self ATTRIBUTE_UNUSED,
+       /* Need information in other operand(s) to help achieve the decoding
+        from 'S' field.  */
+       info->qualifier = get_expected_qualifier (inst, info->idx);
++      if (info->qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       /* Get the size of the data element that is accessed, which may be
+        different from that of the source register size, e.g. in strb/ldrb.  */
+       size = aarch64_get_qualifier_esize (info->qualifier);
+@@ -1172,6 +1203,8 @@ aarch64_ext_addr_simm (const aarch64_operand *self, aarch64_opnd_info *info,
+ {
+   aarch64_insn imm;
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+
+   /* Rn */
+   info->addr.base_regno = extract_field (FLD_Rn, code, 0);
+@@ -1210,6 +1243,8 @@ aarch64_ext_addr_uimm12 (const aarch64_operand *self, aarch64_opnd_info *info,
+ {
+   int shift;
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+   shift = get_logsz (aarch64_get_qualifier_esize (info->qualifier));
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+@@ -1228,6 +1263,8 @@ aarch64_ext_addr_simm10 (const aarch64_operand *self, aarch64_opnd_info *info,
+   aarch64_insn imm;
+
+   info->qualifier = get_expected_qualifier (inst, info->idx);
++  if (info->qualifier == AARCH64_OPND_QLF_ERR)
++    return 0;
+   /* Rn */
+   info->addr.base_regno = extract_field (self->fields[0], code, 0);
+   /* simm10 */
+@@ -2467,6 +2504,8 @@ decode_sizeq (aarch64_inst *inst)
+   if (mask == 0x7)
+     {
+       inst->operands[idx].qualifier = get_vreg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       return 1;
+     }
+
+@@ -2649,6 +2688,8 @@ do_special_decoding (aarch64_inst *inst)
+       idx = select_operand_for_sf_field_coding (inst->opcode);
+       value = extract_field (FLD_sf, inst->value, 0);
+       inst->operands[idx].qualifier = get_greg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       if ((inst->opcode->flags & F_N)
+         && extract_field (FLD_N, inst->value, 0) != value)
+       return 0;
+@@ -2659,6 +2700,8 @@ do_special_decoding (aarch64_inst *inst)
+       idx = select_operand_for_sf_field_coding (inst->opcode);
+       value = extract_field (FLD_lse_sz, inst->value, 0);
+       inst->operands[idx].qualifier = get_greg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+   /* rcpc3 'size' field.  */
+   if (inst->opcode->flags & F_RCPC3_SIZE)
+@@ -2670,12 +2713,18 @@ do_special_decoding (aarch64_inst *inst)
+       {
+         if (aarch64_operands[inst->operands[i].type].op_class
+             == AARCH64_OPND_CLASS_INT_REG)
+-          inst->operands[i].qualifier = get_greg_qualifier_from_value (value & 1);
++          {
++            inst->operands[i].qualifier = get_greg_qualifier_from_value (value & 1);
++            if (inst->operands[i].qualifier == AARCH64_OPND_QLF_ERR)
++              return 0;
++          }
+         else if (aarch64_operands[inst->operands[i].type].op_class
+             == AARCH64_OPND_CLASS_FP_REG)
+           {
+             value += (extract_field (FLD_opc1, inst->value, 0) << 2);
+             inst->operands[i].qualifier = get_sreg_qualifier_from_value (value);
++            if (inst->operands[i].qualifier == AARCH64_OPND_QLF_ERR)
++              return 0;
+           }
+       }
+     }
+@@ -2709,7 +2758,11 @@ do_special_decoding (aarch64_inst *inst)
+       /* For most related instruciton, the 'size' field is fully available for
+        operand encoding.  */
+       if (mask == 0x3)
+-      inst->operands[idx].qualifier = get_sreg_qualifier_from_value (value);
++      {
++        inst->operands[idx].qualifier = get_sreg_qualifier_from_value (value);
++        if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++          return 0;
++      }
+       else
+       {
+         get_operand_possible_qualifiers (idx, inst->opcode->qualifiers_list,
+@@ -2744,6 +2797,9 @@ do_special_decoding (aarch64_inst *inst)
+       Q = (unsigned) extract_field (FLD_Q, inst->value, inst->opcode->mask);
+       inst->operands[0].qualifier =
+       get_vreg_qualifier_from_value ((num << 1) | Q);
++      if (inst->operands[0].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
++
+     }
+
+   if ((inst->opcode->flags & F_OPD_SIZE) && inst->opcode->iclass == sve2_urqvs)
+@@ -2753,7 +2809,11 @@ do_special_decoding (aarch64_inst *inst)
+                                      inst->opcode->mask);
+       inst->operands[0].qualifier
+       = get_vreg_qualifier_from_value (1 + (size << 1));
++      if (inst->operands[0].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+       inst->operands[2].qualifier = get_sreg_qualifier_from_value (size);
++      if (inst->operands[2].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+
+   if (inst->opcode->flags & F_GPRSIZE_IN_Q)
+@@ -2772,6 +2832,8 @@ do_special_decoding (aarch64_inst *inst)
+       assert (idx == 0 || idx == 1);
+       value = extract_field (FLD_Q, inst->value, 0);
+       inst->operands[idx].qualifier = get_greg_qualifier_from_value (value);
++      if (inst->operands[idx].qualifier == AARCH64_OPND_QLF_ERR)
++      return 0;
+     }
+
+   if (inst->opcode->flags & F_LDS_SIZE)
+--
+2.34.1
+
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199901): https://lists.openembedded.org/g/openembedded-core/message/199901
Mute This Topic: https://lists.openembedded.org/mt/106288403/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

author
#4 lore raw

PATCH 2/2 gcc: Fix for CVE-2024-0151

In reply to Mark Hatle

Fix for insufficient argument checking in Secure state Entry functions in software using Cortex-M Security Extensions (CMSE), that has been compiled using toolchains that implement 'Arm v8-M Security Extensions Requirements on Development Tools' prior to version 1.4, allows an attacker to pass values to Secure state that are out of range for types smaller than 32-bits. Out of range values might lead to incorrect operations in secure state.

---
 meta/recipes-devtools/gcc/gcc-13.2.inc        |   1 +
 .../gcc/gcc/CVE-2024-0151.patch               | 315 ++++++++++++++++++
 2 files changed, 316 insertions(+)
 create mode 100644 meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch
meta/recipes-devtools/gcc/gcc-13.2.inc +1 -0
index 603377a49a..abf177822b 100644
@@ -68,6 +68,7 @@ SRC_URI = "${BASEURI} \
            file://CVE-2023-4039.patch \
            file://0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch \
            file://0027-Fix-gcc-vect-module-testcases.patch \
+           file://CVE-2024-0151.patch \
 "
 SRC_URI[sha256sum] = "e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da"
 
meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch new file +315 -0

315 lines not on this page · raw message

Signature · 1 line
2.34.1
#5 lore raw

Re: [OE-core] [scarthgap 2/2] gcc: Fix for CVE-2024-0151

I just realized that somehow I entered the wrong CVE in the body of the patch itself.

This IS CVE-2024-0151, but somehow I entered CVE-2023-4039 is the patch body.

Steve can you fix this as part of the merge, or do you want me to send a V2 or a follow on to fix this?

--Mark

Quoted 359 lines · Mark Hatle via lists.openembedded.org

Fix for insufficient argument checking in Secure state Entry functions in software using Cortex-M Security Extensions (CMSE), that has been compiled using toolchains that implement 'Arm v8-M Security Extensions Requirements on Development Tools' prior to version 1.4, allows an attacker to pass values to Secure state that are out of range for types smaller than 32-bits. Out of range values might lead to incorrect operations in secure state.

---
  meta/recipes-devtools/gcc/gcc-13.2.inc        |   1 +
  .../gcc/gcc/CVE-2024-0151.patch               | 315 ++++++++++++++++++
  2 files changed, 316 insertions(+)

create mode 100644 meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch

meta/recipes-devtools/gcc/gcc-13.2.inc +1 -0
index 603377a49a..abf177822b 100644
@@ -68,6 +68,7 @@ SRC_URI = "${BASEURI} \
             file://CVE-2023-4039.patch \
             file://0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch \
             file://0027-Fix-gcc-vect-module-testcases.patch \
+           file://CVE-2024-0151.patch \
  "
  SRC_URI[sha256sum] = "e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da"
 
meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch new file +315 -1
new file mode 100644
index 0000000000..01d55b5cdb
@@ -0,0 +1,315 @@
+arm: Zero/Sign extends for CMSE security
+
+This patch makes the following changes:
+
+1) When calling a secure function from non-secure code then any arguments
+   smaller than 32-bits that are passed in registers are zero- or sign-extended.
+2) After a non-secure function returns into secure code then any return value
+   smaller than 32-bits that is passed in a register is  zero- or sign-extended.
+
+This patch addresses the following CVE-2024-0151.
+
+gcc/ChangeLog:
+        PR target/114837
+        * config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
+          Add zero/sign extend.
+        (arm_expand_prologue): Add zero/sign extend.
+
+gcc/testsuite/ChangeLog:
+
+        * gcc.target/arm/cmse/extend-param.c: New test.
+        * gcc.target/arm/cmse/extend-return.c: New test.
+
+CVE: CVE-2023-4039
+Upstream-Status: Backport [https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649973.html]
+Signed-off-by: Mark Hatle <[email protected]>
+
+diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
+index 0217abc218d60956ce727e6d008d46b9176dddc5..ea0c963a4d67ecd70e1571624e84dfe46d757df9 100644
+--- a/gcc/config/arm/arm.cc
++++ b/gcc/config/arm/arm.cc
+@@ -19210,6 +19210,30 @@ cmse_nonsecure_call_inline_register_clear (void)
+ 	  end_sequence ();
+ 	  emit_insn_before (seq, insn);
+
++	  /* The AAPCS requires the callee to widen integral types narrower
++	     than 32 bits to the full width of the register; but when handling
++	     calls to non-secure space, we cannot trust the callee to have
++	     correctly done so.  So forcibly re-widen the result here.  */
++	  tree ret_type = TREE_TYPE (fntype);
++	  if ((TREE_CODE (ret_type) == INTEGER_TYPE
++	      || TREE_CODE (ret_type) == ENUMERAL_TYPE
++	      || TREE_CODE (ret_type) == BOOLEAN_TYPE)
++	      && known_lt (GET_MODE_SIZE (TYPE_MODE (ret_type)), 4))
++	    {
++	      machine_mode ret_mode = TYPE_MODE (ret_type);
++	      rtx extend;
++	      if (TYPE_UNSIGNED (ret_type))
++		extend = gen_rtx_ZERO_EXTEND (SImode,
++					      gen_rtx_REG (ret_mode, R0_REGNUM));
++	      else
++		extend = gen_rtx_SIGN_EXTEND (SImode,
++					      gen_rtx_REG (ret_mode, R0_REGNUM));
++	      emit_insn_after (gen_rtx_SET (gen_rtx_REG (SImode, R0_REGNUM),
++					     extend), insn);
++
++	    }
++
++
+ 	  if (TARGET_HAVE_FPCXT_CMSE)
+ 	    {
+ 	      rtx_insn *last, *pop_insn, *after = insn;
+@@ -23652,6 +23676,51 @@ arm_expand_prologue (void)
+
+   ip_rtx = gen_rtx_REG (SImode, IP_REGNUM);
+
++  /* The AAPCS requires the callee to widen integral types narrower
++     than 32 bits to the full width of the register; but when handling
++     calls to non-secure space, we cannot trust the callee to have
++     correctly done so.  So forcibly re-widen the result here.  */
++  if (IS_CMSE_ENTRY (func_type))
++    {
++      function_args_iterator args_iter;
++      CUMULATIVE_ARGS args_so_far_v;
++      cumulative_args_t args_so_far;
++      bool first_param = true;
++      tree arg_type;
++      tree fndecl = current_function_decl;
++      tree fntype = TREE_TYPE (fndecl);
++      arm_init_cumulative_args (&args_so_far_v, fntype, NULL_RTX, fndecl);
++      args_so_far = pack_cumulative_args (&args_so_far_v);
++      FOREACH_FUNCTION_ARGS (fntype, arg_type, args_iter)
++	{
++	  rtx arg_rtx;
++
++	  if (VOID_TYPE_P (arg_type))
++	    break;
++
++	  function_arg_info arg (arg_type, /*named=*/true);
++	  if (!first_param)
++	    /* We should advance after processing the argument and pass
++	       the argument we're advancing past.  */
++	    arm_function_arg_advance (args_so_far, arg);
++	  first_param = false;
++	  arg_rtx = arm_function_arg (args_so_far, arg);
++	  gcc_assert (REG_P (arg_rtx));
++	  if ((TREE_CODE (arg_type) == INTEGER_TYPE
++	      || TREE_CODE (arg_type) == ENUMERAL_TYPE
++	      || TREE_CODE (arg_type) == BOOLEAN_TYPE)
++	      && known_lt (GET_MODE_SIZE (GET_MODE (arg_rtx)), 4))
++	    {
++	      if (TYPE_UNSIGNED (arg_type))
++		emit_set_insn (gen_rtx_REG (SImode, REGNO (arg_rtx)),
++			       gen_rtx_ZERO_EXTEND (SImode, arg_rtx));
++	      else
++		emit_set_insn (gen_rtx_REG (SImode, REGNO (arg_rtx)),
++			       gen_rtx_SIGN_EXTEND (SImode, arg_rtx));
++	    }
++	}
++    }
++
+   if (IS_STACKALIGN (func_type))
+     {
+       rtx r0, r1;
+diff --git a/gcc/testsuite/gcc.target/arm/cmse/extend-param.c b/gcc/testsuite/gcc.target/arm/cmse/extend-param.c
+new file mode 100644
+index 0000000000000000000000000000000000000000..01fac7862385f871f3ecc246ede95eea180be025
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/arm/cmse/extend-param.c
+@@ -0,0 +1,96 @@
++/* { dg-do compile } */
++/* { dg-options "-mcmse" } */
++/* { dg-final { check-function-bodies "**" "" "" } } */
++
++#include <arm_cmse.h>
++#include <stdbool.h>
++
++#define ARRAY_SIZE (256)
++char array[ARRAY_SIZE];
++
++enum offset
++{
++    zero = 0,
++    one = 1,
++    two = 2
++};
++
++/*
++**__acle_se_unsignSecureFunc:
++**	...
++**	uxtb	r0, r0
++**	...
++*/
++__attribute__((cmse_nonsecure_entry)) char unsignSecureFunc (unsigned char index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_signSecureFunc:
++**	...
++**	sxtb	r0, r0
++**	...
++*/
++__attribute__((cmse_nonsecure_entry)) char signSecureFunc (signed char index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_shortUnsignSecureFunc:
++**	...
++**	uxth	r0, r0
++**	...
++*/
++__attribute__((cmse_nonsecure_entry)) char shortUnsignSecureFunc (unsigned short index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_shortSignSecureFunc:
++**	...
++**	sxth	r0, r0
++**	...
++*/
++__attribute__((cmse_nonsecure_entry)) char shortSignSecureFunc (signed short index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_enumSecureFunc:
++**	...
++**	uxtb	r0, r0
++**	...
++*/
++__attribute__((cmse_nonsecure_entry)) char enumSecureFunc (enum offset index) {
++
++  // Compiler may optimize away bounds check as value is an unsigned char.
++
++  // According to AAPCS caller will zero extend to ensure value is < 256.
++
++  if (index >= ARRAY_SIZE)
++    return 0;
++  return array[index];
++
++}
++
++/*
++**__acle_se_boolSecureFunc:
++**	...
++**	uxtb	r0, r0
++**	...
++*/
++__attribute__((cmse_nonsecure_entry)) char boolSecureFunc (bool index) {
++
++  if (index >= ARRAY_SIZE)
++    return 0;
++  return array[index];
++
++}
+\ No newline at end of file
+diff --git a/gcc/testsuite/gcc.target/arm/cmse/extend-return.c b/gcc/testsuite/gcc.target/arm/cmse/extend-return.c
+new file mode 100644
+index 0000000000000000000000000000000000000000..cf731ed33df7e6dc101320c1970016f01b14c59a
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/arm/cmse/extend-return.c
+@@ -0,0 +1,92 @@
++/* { dg-do compile } */
++/* { dg-options "-mcmse" } */
++/* { dg-final { check-function-bodies "**" "" "" } } */
++
++#include <arm_cmse.h>
++#include <stdbool.h>
++
++enum offset
++{
++    zero = 0,
++    one = 1,
++    two = 2
++};
++
++typedef unsigned char __attribute__ ((cmse_nonsecure_call)) ns_unsign_foo_t (void);
++typedef signed char __attribute__ ((cmse_nonsecure_call)) ns_sign_foo_t (void);
++typedef unsigned short __attribute__ ((cmse_nonsecure_call)) ns_short_unsign_foo_t (void);
++typedef signed short __attribute__ ((cmse_nonsecure_call)) ns_short_sign_foo_t (void);
++typedef enum offset __attribute__ ((cmse_nonsecure_call)) ns_enum_foo_t (void);
++typedef bool __attribute__ ((cmse_nonsecure_call)) ns_bool_foo_t (void);
++
++/*
++**unsignNonsecure0:
++**	...
++**	bl	__gnu_cmse_nonsecure_call
++**	uxtb	r0, r0
++**	...
++*/
++unsigned char unsignNonsecure0 (ns_unsign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**signNonsecure0:
++**	...
++**	bl	__gnu_cmse_nonsecure_call
++**	sxtb	r0, r0
++**	...
++*/
++signed char signNonsecure0 (ns_sign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**shortUnsignNonsecure0:
++**	...
++**	bl	__gnu_cmse_nonsecure_call
++**	uxth	r0, r0
++**	...
++*/
++unsigned short shortUnsignNonsecure0 (ns_short_unsign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**shortSignNonsecure0:
++**	...
++**	bl	__gnu_cmse_nonsecure_call
++**	sxth	r0, r0
++**	...
++*/
++signed short shortSignNonsecure0 (ns_short_sign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**enumNonsecure0:
++**	...
++**	bl	__gnu_cmse_nonsecure_call
++**	uxtb	r0, r0
++**	...
++*/
++unsigned char __attribute__((noipa)) enumNonsecure0 (ns_enum_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**boolNonsecure0:
++**	...
++**	bl	__gnu_cmse_nonsecure_call
++**	uxtb	r0, r0
++**	...
++*/
++unsigned char boolNonsecure0 (ns_bool_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
+\ No newline at end of file
 
 
 
-=-=-=-=-=-=-=-=-=-=-=-

Links: You receive all messages sent to this group.
View/Reply Online (#199861): https://lists.openembedded.org/g/openembedded-core/message/199861
Mute This Topic: https://lists.openembedded.org/mt/106288402/3616948
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#6 lore raw

Re: [OE-core] [scarthgap 2/2] gcc: Fix for CVE-2024-0151

Quoted 8 lines · Mark Hatle via lists.openembedded.org

I just realized that somehow I entered the wrong CVE in the body of the patch itself.

This IS CVE-2024-0151, but somehow I entered CVE-2023-4039 is the patch body.

Steve can you fix this as part of the merge, or do you want me to send a V2 or a follow on to fix this?

I'll fix it!

Steve

Quoted 365 lines

--Mark

Quoted 343 lines · Mark Hatle via lists.openembedded.org

Fix for insufficient argument checking in Secure state Entry functions in software using Cortex-M Security Extensions (CMSE), that has been compiled using toolchains that implement 'Arm v8-M Security Extensions Requirements on Development Tools' prior to version 1.4, allows an attacker to pass values to Secure state that are out of range for types smaller than 32-bits. Out of range values might lead to incorrect operations in secure state.

---
  meta/recipes-devtools/gcc/gcc-13.2.inc        |   1 +
  .../gcc/gcc/CVE-2024-0151.patch               | 315 ++++++++++++++++++
  2 files changed, 316 insertions(+)

create mode 100644 meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch

meta/recipes-devtools/gcc/gcc-13.2.inc +1 -0
index 603377a49a..abf177822b 100644
@@ -68,6 +68,7 @@ SRC_URI = "${BASEURI} \
             file://CVE-2023-4039.patch \
             file://0026-aarch64-Fix-loose-ldpstp-check-PR111411.patch \
             file://0027-Fix-gcc-vect-module-testcases.patch \
+           file://CVE-2024-0151.patch \
  "
  SRC_URI[sha256sum] = "e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da"
 
meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch new file +305 -0
new file mode 100644
index 0000000000..01d55b5cdb
@@ -0,0 +1,315 @@
+arm: Zero/Sign extends for CMSE security
+
+This patch makes the following changes:
+
+1) When calling a secure function from non-secure code then any arguments
+   smaller than 32-bits that are passed in registers are zero- or sign-extended.
+2) After a non-secure function returns into secure code then any return value
+   smaller than 32-bits that is passed in a register is  zero- or sign-extended.
+
+This patch addresses the following CVE-2024-0151.
+
+gcc/ChangeLog:
+        PR target/114837
+        * config/arm/arm.cc (cmse_nonsecure_call_inline_register_clear):
+          Add zero/sign extend.
+        (arm_expand_prologue): Add zero/sign extend.
+
+gcc/testsuite/ChangeLog:
+
+        * gcc.target/arm/cmse/extend-param.c: New test.
+        * gcc.target/arm/cmse/extend-return.c: New test.
+
+CVE: CVE-2023-4039
+Upstream-Status: Backport [https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649973.html]
+Signed-off-by: Mark Hatle <[email protected]>
+
+diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
+index 0217abc218d60956ce727e6d008d46b9176dddc5..ea0c963a4d67ecd70e1571624e84dfe46d757df9 100644
+--- a/gcc/config/arm/arm.cc
++++ b/gcc/config/arm/arm.cc
+@@ -19210,6 +19210,30 @@ cmse_nonsecure_call_inline_register_clear (void)
+       end_sequence ();
+       emit_insn_before (seq, insn);
+
++      /* The AAPCS requires the callee to widen integral types narrower
++         than 32 bits to the full width of the register; but when handling
++         calls to non-secure space, we cannot trust the callee to have
++         correctly done so.  So forcibly re-widen the result here.  */
++      tree ret_type = TREE_TYPE (fntype);
++      if ((TREE_CODE (ret_type) == INTEGER_TYPE
++          || TREE_CODE (ret_type) == ENUMERAL_TYPE
++          || TREE_CODE (ret_type) == BOOLEAN_TYPE)
++          && known_lt (GET_MODE_SIZE (TYPE_MODE (ret_type)), 4))
++        {
++          machine_mode ret_mode = TYPE_MODE (ret_type);
++          rtx extend;
++          if (TYPE_UNSIGNED (ret_type))
++            extend = gen_rtx_ZERO_EXTEND (SImode,
++                                          gen_rtx_REG (ret_mode, R0_REGNUM));
++          else
++            extend = gen_rtx_SIGN_EXTEND (SImode,
++                                          gen_rtx_REG (ret_mode, R0_REGNUM));
++          emit_insn_after (gen_rtx_SET (gen_rtx_REG (SImode, R0_REGNUM),
++                                         extend), insn);
++
++        }
++
++
+       if (TARGET_HAVE_FPCXT_CMSE)
+         {
+           rtx_insn *last, *pop_insn, *after = insn;
+@@ -23652,6 +23676,51 @@ arm_expand_prologue (void)
+
+   ip_rtx = gen_rtx_REG (SImode, IP_REGNUM);
+
++  /* The AAPCS requires the callee to widen integral types narrower
++     than 32 bits to the full width of the register; but when handling
++     calls to non-secure space, we cannot trust the callee to have
++     correctly done so.  So forcibly re-widen the result here.  */
++  if (IS_CMSE_ENTRY (func_type))
++    {
++      function_args_iterator args_iter;
++      CUMULATIVE_ARGS args_so_far_v;
++      cumulative_args_t args_so_far;
++      bool first_param = true;
++      tree arg_type;
++      tree fndecl = current_function_decl;
++      tree fntype = TREE_TYPE (fndecl);
++      arm_init_cumulative_args (&args_so_far_v, fntype, NULL_RTX, fndecl);
++      args_so_far = pack_cumulative_args (&args_so_far_v);
++      FOREACH_FUNCTION_ARGS (fntype, arg_type, args_iter)
++    {
++      rtx arg_rtx;
++
++      if (VOID_TYPE_P (arg_type))
++        break;
++
++      function_arg_info arg (arg_type, /*named=*/true);
++      if (!first_param)
++        /* We should advance after processing the argument and pass
++           the argument we're advancing past.  */
++        arm_function_arg_advance (args_so_far, arg);
++      first_param = false;
++      arg_rtx = arm_function_arg (args_so_far, arg);
++      gcc_assert (REG_P (arg_rtx));
++      if ((TREE_CODE (arg_type) == INTEGER_TYPE
++          || TREE_CODE (arg_type) == ENUMERAL_TYPE
++          || TREE_CODE (arg_type) == BOOLEAN_TYPE)
++          && known_lt (GET_MODE_SIZE (GET_MODE (arg_rtx)), 4))
++        {
++          if (TYPE_UNSIGNED (arg_type))
++            emit_set_insn (gen_rtx_REG (SImode, REGNO (arg_rtx)),
++                           gen_rtx_ZERO_EXTEND (SImode, arg_rtx));
++          else
++            emit_set_insn (gen_rtx_REG (SImode, REGNO (arg_rtx)),
++                           gen_rtx_SIGN_EXTEND (SImode, arg_rtx));
++        }
++    }
++    }
++
+   if (IS_STACKALIGN (func_type))
+     {
+       rtx r0, r1;
+diff --git a/gcc/testsuite/gcc.target/arm/cmse/extend-param.c b/gcc/testsuite/gcc.target/arm/cmse/extend-param.c
+new file mode 100644
+index 0000000000000000000000000000000000000000..01fac7862385f871f3ecc246ede95eea180be025
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/arm/cmse/extend-param.c
+@@ -0,0 +1,96 @@
++/* { dg-do compile } */
++/* { dg-options "-mcmse" } */
++/* { dg-final { check-function-bodies "**" "" "" } } */
++
++#include <arm_cmse.h>
++#include <stdbool.h>
++
++#define ARRAY_SIZE (256)
++char array[ARRAY_SIZE];
++
++enum offset
++{
++    zero = 0,
++    one = 1,
++    two = 2
++};
++
++/*
++**__acle_se_unsignSecureFunc:
++**  ...
++**  uxtb    r0, r0
++**  ...
++*/
++__attribute__((cmse_nonsecure_entry)) char unsignSecureFunc (unsigned char index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_signSecureFunc:
++**  ...
++**  sxtb    r0, r0
++**  ...
++*/
++__attribute__((cmse_nonsecure_entry)) char signSecureFunc (signed char index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_shortUnsignSecureFunc:
++**  ...
++**  uxth    r0, r0
++**  ...
++*/
++__attribute__((cmse_nonsecure_entry)) char shortUnsignSecureFunc (unsigned short index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_shortSignSecureFunc:
++**  ...
++**  sxth    r0, r0
++**  ...
++*/
++__attribute__((cmse_nonsecure_entry)) char shortSignSecureFunc (signed short index) {
++    if (index >= ARRAY_SIZE)
++      return 0;
++    return array[index];
++}
++
++/*
++**__acle_se_enumSecureFunc:
++**  ...
++**  uxtb    r0, r0
++**  ...
++*/
++__attribute__((cmse_nonsecure_entry)) char enumSecureFunc (enum offset index) {
++
++  // Compiler may optimize away bounds check as value is an unsigned char.
++
++  // According to AAPCS caller will zero extend to ensure value is < 256.
++
++  if (index >= ARRAY_SIZE)
++    return 0;
++  return array[index];
++
++}
++
++/*
++**__acle_se_boolSecureFunc:
++**  ...
++**  uxtb    r0, r0
++**  ...
++*/
++__attribute__((cmse_nonsecure_entry)) char boolSecureFunc (bool index) {
++
++  if (index >= ARRAY_SIZE)
++    return 0;
++  return array[index];
++
++}
+\ No newline at end of file
+diff --git a/gcc/testsuite/gcc.target/arm/cmse/extend-return.c b/gcc/testsuite/gcc.target/arm/cmse/extend-return.c
+new file mode 100644
+index 0000000000000000000000000000000000000000..cf731ed33df7e6dc101320c1970016f01b14c59a
+--- /dev/null
++++ b/gcc/testsuite/gcc.target/arm/cmse/extend-return.c
+@@ -0,0 +1,92 @@
++/* { dg-do compile } */
++/* { dg-options "-mcmse" } */
++/* { dg-final { check-function-bodies "**" "" "" } } */
++
++#include <arm_cmse.h>
++#include <stdbool.h>
++
++enum offset
++{
++    zero = 0,
++    one = 1,
++    two = 2
++};
++
++typedef unsigned char __attribute__ ((cmse_nonsecure_call)) ns_unsign_foo_t (void);
++typedef signed char __attribute__ ((cmse_nonsecure_call)) ns_sign_foo_t (void);
++typedef unsigned short __attribute__ ((cmse_nonsecure_call)) ns_short_unsign_foo_t (void);
++typedef signed short __attribute__ ((cmse_nonsecure_call)) ns_short_sign_foo_t (void);
++typedef enum offset __attribute__ ((cmse_nonsecure_call)) ns_enum_foo_t (void);
++typedef bool __attribute__ ((cmse_nonsecure_call)) ns_bool_foo_t (void);
++
++/*
++**unsignNonsecure0:
++**  ...
++**  bl      __gnu_cmse_nonsecure_call
++**  uxtb    r0, r0
++**  ...
++*/
++unsigned char unsignNonsecure0 (ns_unsign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**signNonsecure0:
++**  ...
++**  bl      __gnu_cmse_nonsecure_call
++**  sxtb    r0, r0
++**  ...
++*/
++signed char signNonsecure0 (ns_sign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**shortUnsignNonsecure0:
++**  ...
++**  bl      __gnu_cmse_nonsecure_call
++**  uxth    r0, r0
++**  ...
++*/
++unsigned short shortUnsignNonsecure0 (ns_short_unsign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**shortSignNonsecure0:
++**  ...
++**  bl      __gnu_cmse_nonsecure_call
++**  sxth    r0, r0
++**  ...
++*/
++signed short shortSignNonsecure0 (ns_short_sign_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**enumNonsecure0:
++**  ...
++**  bl      __gnu_cmse_nonsecure_call
++**  uxtb    r0, r0
++**  ...
++*/
++unsigned char __attribute__((noipa)) enumNonsecure0 (ns_enum_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
++
++/*
++**boolNonsecure0:

meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch line 315

Quoted 10 lines
meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch new file +10 -0
++**  ...
++**  bl      __gnu_cmse_nonsecure_call
++**  uxtb    r0, r0
++**  ...
++*/
++unsigned char boolNonsecure0 (ns_bool_foo_t * ns_foo_p)
++{
++  return ns_foo_p ();
++}
+\ No newline at end of file

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199940): https://lists.openembedded.org/g/openembedded-core/message/199940
Mute This Topic: https://lists.openembedded.org/mt/106288402/3620601
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#7 lore raw
In reply to Mark Hatle

These look fine to me

Quoted 44 lines · Mark Hatle via lists.openembedded.org

Two different toolchain fixes for Scarthgap.

The binutils change was found in a AMD/Xilinx specific build script that attempts to disassemble some code as part of a firmware setup. This cortex-a53 baremetal firmware triggered a fault fixed by the issue.

The newer versions of binutils have already accepted this change, but I'm not exactly sure which version(s) have it other then then the current development tree.

The GCC change only affects cortex-M. This is simply a port of the GCC accepted change into Yocto Project for baremetal usage. Unfortunately I don't have any sort of test cases to show it works or doesn't. It does not break any of my existing test cases related to Linux for cortex-r baremetal.

Again this change has already been accepted to newer versions of GCC.

Mark Hatle (2):
binutils: Fix aarch64 disassembly abort
gcc: Fix for CVE-2024-0151

 .../binutils/binutils-2.42.inc                |   1 +
 ...sserts-from-operand-qualifier-decode.patch | 382 ++++++++++++++++++
 meta/recipes-devtools/gcc/gcc-13.2.inc        |   1 +
 .../gcc/gcc/CVE-2024-0151.patch               | 315 +++++++++++++++
 4 files changed, 699 insertions(+)
 create mode 100644 meta/recipes-devtools/binutils/binutils/0016-aarch64-Remove-asserts-from-operand-qualifier-decode.patch
 create mode 100644 meta/recipes-devtools/gcc/gcc/CVE-2024-0151.patch

--
2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#199860): https://lists.openembedded.org/g/openembedded-core/message/199860
Mute This Topic: https://lists.openembedded.org/mt/106288401/1997914
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-