summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--meta/recipes-devtools/gdb/gdb.inc1
-rw-r--r--meta/recipes-devtools/gdb/gdb/0009-CVE-2023-39128.patch75
2 files changed, 76 insertions, 0 deletions
diff --git a/meta/recipes-devtools/gdb/gdb.inc b/meta/recipes-devtools/gdb/gdb.inc
index e986b1a1f9..2437a96ae7 100644
--- a/meta/recipes-devtools/gdb/gdb.inc
+++ b/meta/recipes-devtools/gdb/gdb.inc
@@ -14,6 +14,7 @@ SRC_URI = "${GNU_MIRROR}/gdb/gdb-${PV}.tar.xz \
14 file://0007-Fix-invalid-sigprocmask-call.patch \ 14 file://0007-Fix-invalid-sigprocmask-call.patch \
15 file://0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \ 15 file://0008-Define-alignof-using-_Alignof-when-using-C11-or-newe.patch \
16 file://add-missing-ldflags.patch \ 16 file://add-missing-ldflags.patch \
17 file://0009-CVE-2023-39128.patch \
17 " 18 "
18SRC_URI[sha256sum] = "fd5bebb7be1833abdb6e023c2f498a354498281df9d05523d8915babeb893f0a" 19SRC_URI[sha256sum] = "fd5bebb7be1833abdb6e023c2f498a354498281df9d05523d8915babeb893f0a"
19 20
diff --git a/meta/recipes-devtools/gdb/gdb/0009-CVE-2023-39128.patch b/meta/recipes-devtools/gdb/gdb/0009-CVE-2023-39128.patch
new file mode 100644
index 0000000000..88e39eaa59
--- /dev/null
+++ b/meta/recipes-devtools/gdb/gdb/0009-CVE-2023-39128.patch
@@ -0,0 +1,75 @@
1From 033bc52bb6190393c8eed80925fa78cc35b40c6d Mon Sep 17 00:00:00 2001
2From: Tom Tromey <tromey@adacore.com>
3Date: Wed, 16 Aug 2023 11:29:19 -0600
4Subject: [PATCH] Avoid buffer overflow in ada_decode
5
6A bug report pointed out a buffer overflow in ada_decode, which Keith
7helpfully analyzed. ada_decode had a logic error when the input was
8all digits. While this isn't valid -- and would probably only appear
9in fuzzer tests -- it still should be handled properly.
10
11This patch adds a missing bounds check. Tested with the self-tests in
12an asan build.
13
14Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30639
15Reviewed-by: Keith Seitz <keiths@redhat.com>
16
17Upstream-Status: Backport from [https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=033bc52bb6190393c8eed80925fa78cc35b40c6d]
18CVE: CVE-2023-39128
19Signed-off-by: Siddharth Doshi <sdoshi@mvista.com>
20---
21 gdb/ada-lang.c | 19 ++++++++++++++++++-
22 1 file changed, 18 insertions(+), 1 deletion(-)
23
24diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
25index 40f8591..06ac46b 100644
26--- a/gdb/ada-lang.c
27+++ b/gdb/ada-lang.c
28@@ -57,6 +57,7 @@
29 #include "cli/cli-utils.h"
30 #include "gdbsupport/function-view.h"
31 #include "gdbsupport/byte-vector.h"
32+#include "gdbsupport/selftest.h"
33 #include <algorithm>
34 #include "ada-exp.h"
35 #include "charset.h"
36@@ -1388,7 +1389,7 @@ ada_decode (const char *encoded, bool wrap, bool operators)
37 i -= 1;
38 if (i > 1 && encoded[i] == '_' && encoded[i - 1] == '_')
39 len0 = i - 1;
40- else if (encoded[i] == '$')
41+ else if (i >= 0 && encoded[i] == '$')
42 len0 = i;
43 }
44
45@@ -1585,6 +1586,18 @@ ada_decode (const char *encoded, bool wrap, bool operators)
46 return decoded;
47 }
48
49+#ifdef GDB_SELF_TEST
50+
51+static void
52+ada_decode_tests ()
53+{
54+ /* This isn't valid, but used to cause a crash. PR gdb/30639. The
55+ result does not really matter very much. */
56+ SELF_CHECK (ada_decode ("44") == "44");
57+}
58+
59+#endif
60+
61 /* Table for keeping permanent unique copies of decoded names. Once
62 allocated, names in this table are never released. While this is a
63 storage leak, it should not be significant unless there are massive
64@@ -14084,4 +14097,8 @@ DWARF attribute."),
65 gdb::observers::new_objfile.attach (ada_new_objfile_observer, "ada-lang");
66 gdb::observers::free_objfile.attach (ada_free_objfile_observer, "ada-lang");
67 gdb::observers::inferior_exit.attach (ada_inferior_exit, "ada-lang");
68+
69+#ifdef GDB_SELF_TEST
70+ selftests::register_test ("ada-decode", ada_decode_tests);
71+#endif
72 }
73--
742.25.1
75