From: Deepesh Varatharajan Date: Thu, 6 Mar 2025 10:48:06 +0000 (-0800) Subject: binutils: Fix CVE-2025-0840 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e12ee4b1713aa25465aa3f866d345d84e9eb948a;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git binutils: Fix CVE-2025-0840 PR32560 stack-buffer-overflow at objdump disassemble_bytes Backport a patch from upstream to fix CVE-2025-0840 Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=baac6c221e9d69335bf41366a1c7d87d8ab2f893] Signed-off-by: Deepesh Varatharajan Signed-off-by: Steve Sakoman --- diff --git a/meta/recipes-devtools/binutils/binutils-2.38.inc b/meta/recipes-devtools/binutils/binutils-2.38.inc index e577a10cb8..26d0b570f3 100644 --- a/meta/recipes-devtools/binutils/binutils-2.38.inc +++ b/meta/recipes-devtools/binutils/binutils-2.38.inc @@ -72,5 +72,6 @@ SRC_URI = "\ file://0035-CVE-2023-39129.patch \ file://0036-CVE-2023-39130.patch \ file://0037-CVE-2024-53589.patch \ + file://0038-CVE-2025-0840.patch \ " S = "${WORKDIR}/git" diff --git a/meta/recipes-devtools/binutils/binutils/0038-CVE-2025-0840.patch b/meta/recipes-devtools/binutils/binutils/0038-CVE-2025-0840.patch new file mode 100644 index 0000000000..b04e750690 --- /dev/null +++ b/meta/recipes-devtools/binutils/binutils/0038-CVE-2025-0840.patch @@ -0,0 +1,53 @@ +Author: Alan Modra +Date: Wed, 15 Jan 2025 19:13:43 +1030 + +PR32560 stack-buffer-overflow at objdump disassemble_bytes + +There's always someone pushing the boundaries. + + PR 32560 + * objdump.c (MAX_INSN_WIDTH): Define. + (insn_width): Make it an unsigned long. + (disassemble_bytes): Use MAX_INSN_WIDTH to size buffer. + (main ): Restrict size of insn_width. + +Upstream-Status: Backport [https://sourceware.org/git/?p=binutils-gdb.git;a=commitdiff;h=baac6c221e9d69335bf41366a1c7d87d8ab2f893] +CVE: CVE-2025-0840 + +Signed-off-by: Deepesh Varatharajan + +diff --git a/binutils/objdump.c b/binutils/objdump.c +index 59f454b0..bd6180be 100644 +--- a/binutils/objdump.c ++++ b/binutils/objdump.c +@@ -110,7 +110,8 @@ static bool disassemble_all; /* -D */ + static int disassemble_zeroes; /* --disassemble-zeroes */ + static bool formats_info; /* -i */ + static int wide_output; /* -w */ +-static int insn_width; /* --insn-width */ ++#define MAX_INSN_WIDTH 49 ++static unsigned long insn_width; /* --insn-width */ + static bfd_vma start_address = (bfd_vma) -1; /* --start-address */ + static bfd_vma stop_address = (bfd_vma) -1; /* --stop-address */ + static int dump_debugging; /* --debugging */ +@@ -2897,7 +2898,7 @@ disassemble_bytes (struct disassemble_info *inf, + } + else + { +- char buf[50]; ++ char buf[MAX_INSN_WIDTH + 1]; + unsigned int bpc = 0; + unsigned int pb = 0; + +@@ -5457,8 +5458,9 @@ main (int argc, char **argv) + break; + case OPTION_INSN_WIDTH: + insn_width = strtoul (optarg, NULL, 0); +- if (insn_width <= 0) +- fatal (_("error: instruction width must be positive")); ++ if (insn_width - 1 >= MAX_INSN_WIDTH) ++ fatal (_("error: instruction width must be in the range 1 to " ++ XSTRING (MAX_INSN_WIDTH))); + break; + case OPTION_INLINES: + unwind_inlines = true;