Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 0/2] PR gdb/server/34969
@ 2026-11-10  7:07 Kevin Buettner
  2026-11-10  7:07 ` [PATCH 1/2] gdbserver: reject malformed agent expressions in gdb_parse_agent_expr Kevin Buettner
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Kevin Buettner @ 2026-11-10  7:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

This series consists of two parts:  a fix and a test case for this
upstream bug:

https://sourceware.org/bugzilla/show_bug.cgi?id=34969

The test case was largely written by Claude Opus 5.5, but was based on
earlier work by GLM 5.3 Flash.

I have used the GCC AI Policy convention of using the "Assisted-by:"
tag in the commit log for the test case.  The GCC AI Policy may be
found here:

https://gcc.gnu.org/ai-policy.html

Based on my research into the matter, it seems that the convention
is to simply use:

  Assisted-by: LLM

It is my understanding that the GNU LIBC (GLIBC) project is on their
way to adopting the GCC policy.  More information here:

https://inbox.sourceware.org/libc-alpha/7b311b3e-8a35-4622-84e3-7dc57dbcac28@redhat.com/

In particular, observe Carlos's comment:

  "I think we should also approach binutils and gdb to harmonize the
   policy there."

Kevin

Kevin Buettner (2):
  gdbserver: reject malformed agent expressions in gdb_parse_agent_expr
  gdb/testsuite: test malformed agent expressions sent to gdbserver

 .../gdb.server/agent-expr-length.exp          | 188 ++++++++++++++++++
 gdbserver/ax.cc                               |  15 +-
 gdbserver/ax.h                                |   4 +-
 gdbserver/tracepoint.cc                       |  12 ++
 4 files changed, 215 insertions(+), 4 deletions(-)
 create mode 100644 gdb/testsuite/gdb.server/agent-expr-length.exp

-- 
2.56.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/2] gdbserver: reject malformed agent expressions in gdb_parse_agent_expr
  2026-11-10  7:07 [PATCH 0/2] PR gdb/server/34969 Kevin Buettner
@ 2026-11-10  7:07 ` Kevin Buettner
  2026-11-10  7:07 ` [PATCH 2/2] gdb/testsuite: test malformed agent expressions sent to gdbserver Kevin Buettner
  2026-11-10 12:58 ` [PATCH 0/2] PR gdb/server/34969 Eli Zaretskii
  2 siblings, 0 replies; 8+ messages in thread
From: Kevin Buettner @ 2026-11-10  7:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

gdb_parse_agent_expr, defined in gdbserver/ax.cc, is called from four
different sites within gdbserver, two from mem-break.cc and two from
tracepoint.cc.

Within tracepoint.cc, gdb_parse_agent_expr is called to handle the 'X'
portion of a QTDP packet.  The 'X' portion describes an agent
expression used by tracepoints for both conditions and actions.

Within mem-break.cc, it's called to handle breakpoint conditions or
commands as part of a 'z' or 'Z' packet.  These conditions or commands
are specified in a bytecode format identical to that used for agent
expressions for tracepoints.  Despite the fact that they use the same
format, this functionality is separate from the tracepoint facility.
(Though within gdbserver, some of it is implemented using the same code.)

The current implementation of gdb_parse_agent_expr has no checks about
validity of the length specified in the portion of a packet that
represents an agent expression.  This takes the form "X<len>,<hex>".
(This is not an 'X' packet but, rather, a portion of the 'QTDP' packet
for tracepoints or 'Z' packet for breakpoints.)  gdb_parse_agent_expr
allocates LEN bytes and asks hex2bin to convert that number of bytes,
but hex2bin stops at the end of the packet, leaving the end of the
buffer uninitialized.  For a tracepoint condition, that buffer is
later sent back to GDB in reply to qTfP/qTsP, which are used to
request tracepoint data.  Thus, using an overly large length can
provide access to uninitialized gdbserver heap memory.

The parse pointer is also advanced by 2 * LEN regardless of how much
data was present, so the callers continue parsing from a pointer that
can be far beyond the end of the packet; a large LEN crashes
gdbserver.  Similarly, a missing comma after LEN causes the parser to
step past the packet's terminating NUL.

Fix this by having gdb_parse_agent_expr return nullptr when the comma
is missing or when LEN exceeds the amount of hex data remaining in the
packet.  The Z packet condition and command paths (in mem-break.cc)
already handle a nullptr return.  Make the tracepoint action parser
discard an action whose expression could not be parsed, and make the
QTDP parser skip a malformed condition, so that any remaining fields,
including the trailing hyphen, are still processed.  As is already the
case for breakpoint conditions, this change causes the tracepoint
to be defined without the condition.

This fixes the bug associated with CVE-2026-121996.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34969
---
 gdbserver/ax.cc         | 15 ++++++++++++---
 gdbserver/ax.h          |  4 +++-
 gdbserver/tracepoint.cc | 12 ++++++++++++
 3 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/gdbserver/ax.cc b/gdbserver/ax.cc
index 4993bed2532..beec324f9b0 100644
--- a/gdbserver/ax.cc
+++ b/gdbserver/ax.cc
@@ -91,8 +91,7 @@ gdb_agent_op_name (int op)
 
 #ifndef IN_PROCESS_AGENT
 
-/* The packet form of an agent expression consists of an 'X', number
-   of bytes in expression, a comma, and then the bytes.  */
+/* See ax.h.  */
 
 struct agent_expr *
 gdb_parse_agent_expr (const char **actparm)
@@ -103,7 +102,17 @@ gdb_parse_agent_expr (const char **actparm)
 
   ++act;  /* skip the X */
   act = unpack_varlen_hex (act, &xlen);
-  ++act;  /* skip a comma */
+
+  /* The length must be followed by a comma, and must not exceed the
+     amount of hex data present in the packet.  Otherwise HEX2BIN would
+     leave the tail of the buffer uninitialized, and the parse pointer
+     would be advanced past the end of the packet.  */
+  if (*act != ',')
+    return nullptr;
+  ++act;  /* skip the comma */
+  if (xlen > strlen (act) / 2)
+    return nullptr;
+
   aexpr = XNEW (struct agent_expr);
   aexpr->length = xlen;
   aexpr->bytes = (unsigned char *) xmalloc (xlen);
diff --git a/gdbserver/ax.h b/gdbserver/ax.h
index 03882f4888a..7ad077f8195 100644
--- a/gdbserver/ax.h
+++ b/gdbserver/ax.h
@@ -48,7 +48,9 @@ struct agent_expr
 #ifndef IN_PROCESS_AGENT
 
 /* The packet form of an agent expression consists of an 'X', number
-   of bytes in expression, a comma, and then the bytes.  */
+   of bytes in expression, a comma, and then the bytes.  Parse one at
+   *ACTPARM, advancing *ACTPARM past it.  Return nullptr, leaving
+   *ACTPARM unchanged, if the expression is malformed.  */
 struct agent_expr *gdb_parse_agent_expr (const char **actparm);
 
 /* Release an agent expression.  */
diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc
index 6f657257ee8..d0f9228cad1 100644
--- a/gdbserver/tracepoint.cc
+++ b/gdbserver/tracepoint.cc
@@ -1877,6 +1877,11 @@ add_tracepoint_action (struct tracepoint *tpoint, const char *packet)
 
 	    trace_debug ("Want to evaluate expression");
 	    xaction->expr = gdb_parse_agent_expr (&act);
+	    if (xaction->expr == nullptr)
+	      {
+		free (xaction);
+		action = nullptr;
+	      }
 	    break;
 	  }
 	default:
@@ -2404,6 +2409,13 @@ cmd_qtdp (char *own_buf)
 	  else if (*packet == 'X')
 	    {
 	      tpoint->cond = gdb_parse_agent_expr (&packet);
+	      if (tpoint->cond == nullptr)
+		{
+		  /* Skip the malformed expression, so that any remaining
+		     fields, and the trailing hyphen, are still seen.  */
+		  trace_debug ("Malformed tracepoint condition, ignoring");
+		  packet += strcspn (packet, ":-");
+		}
 	    }
 	  else if (*packet == '-')
 	    break;
-- 
2.56.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/2] gdb/testsuite: test malformed agent expressions sent to gdbserver
  2026-11-10  7:07 [PATCH 0/2] PR gdb/server/34969 Kevin Buettner
  2026-11-10  7:07 ` [PATCH 1/2] gdbserver: reject malformed agent expressions in gdb_parse_agent_expr Kevin Buettner
@ 2026-11-10  7:07 ` Kevin Buettner
  2026-11-11 12:36   ` Andrew Burgess
  2026-11-10 12:58 ` [PATCH 0/2] PR gdb/server/34969 Eli Zaretskii
  2 siblings, 1 reply; 8+ messages in thread
From: Kevin Buettner @ 2026-11-10  7:07 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

Add gdb.server/agent-expr-length.exp, which uses "maintenance packet"
to send gdbserver agent expressions whose declared length exceeds the
hex data present in the packet, or which lack the comma after the
length.  They are sent as breakpoint conditions and commands (Z0) and
as tracepoint conditions and actions (QTDP).  The test checks that
gdbserver survives each one and, by reading the tracepoint definitions
back with qTfP/qTsP, that the malformed parts are dropped instead of
being stored with an uninitialized tail, while the well-formed
conditions and actions alongside them are kept.

Against a gdbserver without the previous commit's fix, the test shows
the heap disclosure (a tracepoint condition read back with 63 bytes of
heap contents beyond the single byte sent), and gdbserver crashes on
the expressions with a huge declared length.

This is a test for CVE-2026-121996.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34969

Assisted-by: LLM
---
 .../gdb.server/agent-expr-length.exp          | 188 ++++++++++++++++++
 1 file changed, 188 insertions(+)
 create mode 100644 gdb/testsuite/gdb.server/agent-expr-length.exp

diff --git a/gdb/testsuite/gdb.server/agent-expr-length.exp b/gdb/testsuite/gdb.server/agent-expr-length.exp
new file mode 100644
index 00000000000..f9c85fa5190
--- /dev/null
+++ b/gdb/testsuite/gdb.server/agent-expr-length.exp
@@ -0,0 +1,188 @@
+# Copyright 2026 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Test that gdbserver rejects agent expressions ("X<len>,<hex>") whose
+# declared length exceeds the hex data present in the packet, or which
+# lack the comma after the length (CVE-2026-121996).  Such expressions
+# used to leave the tail of the expression's buffer uninitialized,
+# which was then sent back to GDB as part of a tracepoint condition,
+# and to advance gdbserver's packet parser past the end of the packet,
+# crashing gdbserver.
+#
+# GDB never sends such an expression itself, so the packets are sent
+# with "maintenance packet".  Each case uses a fresh gdbserver, so
+# that a crash in one does not hide the results of the others.
+
+load_lib gdbserver-support.exp
+
+require allow_gdbserver_tests
+
+standard_testfile normal.c
+
+if {[build_executable "failed to prepare" $testfile $srcfile]} {
+    return
+}
+
+# Malformed expressions to try: one declaring 0x40 bytes but carrying
+# only one, one whose declared length would move the parse pointer far
+# beyond the end of the packet buffer, and one without the comma.
+set bad_exprs {"X40,ab" "X10000000,ab" "X40"}
+
+# Start GDB and a new gdbserver, and connect them.  Return true on
+# success.
+
+proc start_gdbserver {} {
+    clean_restart $::testfile
+
+    # Make sure we're disconnected, in case we're testing with an
+    # extended-remote board, therefore already connected.
+    gdb_test "disconnect" ".*"
+
+    if {[gdbserver_run ""] != 0} {
+	fail "connect to gdbserver"
+	return false
+    }
+    return true
+}
+
+# Send PACKET to gdbserver and return its reply, or the empty string
+# if no reply was seen.  TEST is the test name.
+
+proc send_packet { packet test } {
+    set reply ""
+    gdb_test_multiple "maintenance packet $packet" $test {
+	-re -wrap "received: \"(\[^\r\n\]*)\"" {
+	    set reply $expect_out(1,string)
+	    pass $gdb_test_name
+	}
+    }
+    return $reply
+}
+
+# Send PACKET to gdbserver, expecting an "OK" reply.
+
+proc send_packet_ok { packet test } {
+    gdb_test "maintenance packet $packet" "received: \"OK\"" $test
+}
+
+# Return true if gdbserver supports tracepoints.
+
+proc supports_tracepoints {} {
+    if {![start_gdbserver]} {
+	return false
+    }
+    return [expr {[send_packet "qTStatus" "query trace status"] != ""}]
+}
+
+# Insert a breakpoint at main whose condition or commands (according to
+# KIND) are the malformed expression EXPR.  The expression must be
+# rejected without disturbing gdbserver; the breakpoint itself is still
+# inserted.
+
+proc test_breakpoint { kind expr } {
+    if {![start_gdbserver]} {
+	return
+    }
+
+    set addr [format %x [get_hexadecimal_valueof "&main" 0]]
+    if {$kind == "condition"} {
+	set option $expr
+    } else {
+	set option "cmds:0,$expr"
+    }
+
+    send_packet_ok "Z0,$addr,1;$option" "insert breakpoint"
+    send_packet_ok "z0,$addr,1" "remove breakpoint"
+}
+
+# Send the tracepoint definition PACKETS to gdbserver, then read the
+# definitions back, and check that they match EXPECTED.  The
+# malformed parts must not appear, in particular not with the heap
+# contents an uninitialized buffer would contain.
+
+proc test_tracepoints { packets expected } {
+    if {![start_gdbserver]} {
+	return
+    }
+
+    send_packet_ok "QTinit" "clear tracepoints"
+    set i 0
+    foreach packet $packets {
+	incr i
+	send_packet_ok $packet "define tracepoint piece $i"
+    }
+
+    set pieces {}
+    set reply [send_packet "qTfP" "read first tracepoint piece"]
+    set i 0
+    while {$reply != "" && $reply != "l" && $i < 20} {
+	lappend pieces $reply
+	incr i
+	set reply [send_packet "qTsP" "read subsequent tracepoint piece $i"]
+    }
+
+    gdb_assert {$pieces eq $expected} "tracepoint definitions"
+}
+
+foreach_with_prefix kind {"condition" "commands"} {
+    foreach_with_prefix expr $bad_exprs {
+	test_breakpoint $kind $expr
+    }
+}
+
+if {![supports_tracepoints]} {
+    unsupported "gdbserver does not support tracepoints"
+    return
+}
+
+# Malformed tracepoint conditions are dropped.
+
+foreach_with_prefix expr $bad_exprs {
+    with_test_prefix "condition" {
+	test_tracepoints \
+	    [list \
+		 "QTDP:1:1000:E:1:1:X1,ab" \
+		 "QTDP:2:2000:E:1:1:$expr"] \
+	    [list \
+		 "T1:1000:E:1:1:X1,ab" \
+		 "T2:2000:E:1:1"]
+    }
+}
+
+# The parser must find its way past a malformed condition to any
+# following field, here a good condition.
+
+foreach_with_prefix expr $bad_exprs {
+    with_test_prefix "condition, then good condition" {
+	test_tracepoints \
+	    [list "QTDP:1:1000:E:1:1:$expr:X1,cd"] \
+	    [list "T1:1000:E:1:1:X1,cd"]
+    }
+}
+
+# Malformed tracepoint actions are dropped, leaving the good ones.
+
+foreach_with_prefix expr $bad_exprs {
+    with_test_prefix "action" {
+	test_tracepoints \
+	    [list \
+		 "QTDP:1:1000:E:1:1-" \
+		 "QTDP:-1:1000:X1,ab-" \
+		 "QTDP:-1:1000:$expr"] \
+	    [list \
+		 "T1:1000:E:1:1" \
+		 "A1:1000:X1,ab"]
+    }
+}
-- 
2.56.0


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] PR gdb/server/34969
  2026-11-10  7:07 [PATCH 0/2] PR gdb/server/34969 Kevin Buettner
  2026-11-10  7:07 ` [PATCH 1/2] gdbserver: reject malformed agent expressions in gdb_parse_agent_expr Kevin Buettner
  2026-11-10  7:07 ` [PATCH 2/2] gdb/testsuite: test malformed agent expressions sent to gdbserver Kevin Buettner
@ 2026-11-10 12:58 ` Eli Zaretskii
  2026-11-10 15:15   ` Simon Marchi
  2026-11-11  6:13   ` Kevin Buettner
  2 siblings, 2 replies; 8+ messages in thread
From: Eli Zaretskii @ 2026-11-10 12:58 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

> From: Kevin Buettner <kevinb@redhat.com>
> Cc: Kevin Buettner <kevinb@redhat.com>
> Date: Tue, 10 Nov 2026 00:07:52 -0700
> 
> This series consists of two parts:  a fix and a test case for this
> upstream bug:
> 
> https://sourceware.org/bugzilla/show_bug.cgi?id=34969
> 
> The test case was largely written by Claude Opus 5.5, but was based on
> earlier work by GLM 5.3 Flash.
> 
> I have used the GCC AI Policy convention of using the "Assisted-by:"
> tag in the commit log for the test case.  The GCC AI Policy may be
> found here:
> 
> https://gcc.gnu.org/ai-policy.html
> 
> Based on my research into the matter, it seems that the convention
> is to simply use:
> 
>   Assisted-by: LLM
> 
> It is my understanding that the GNU LIBC (GLIBC) project is on their
> way to adopting the GCC policy.  More information here:
> 
> https://inbox.sourceware.org/libc-alpha/7b311b3e-8a35-4622-84e3-7dc57dbcac28@redhat.com/
> 
> In particular, observe Carlos's comment:
> 
>   "I think we should also approach binutils and gdb to harmonize the
>    policy there."

By contrast, the whole GNU Project was asked by RMS not to accept
LLM-generated code until the lawyers asked to provide recommendations
in this regard complete their work:

  https://lists.gnu.org/mailman/private/gnu-prog/2026/000237.html

Did we decide to go the GCC way and basically disregard RMS's request?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] PR gdb/server/34969
  2026-11-10 12:58 ` [PATCH 0/2] PR gdb/server/34969 Eli Zaretskii
@ 2026-11-10 15:15   ` Simon Marchi
  2026-11-11  6:13   ` Kevin Buettner
  1 sibling, 0 replies; 8+ messages in thread
From: Simon Marchi @ 2026-11-10 15:15 UTC (permalink / raw)
  To: Eli Zaretskii, Kevin Buettner; +Cc: gdb-patches

On 11/10/26 7:58 AM, Eli Zaretskii wrote:
>> From: Kevin Buettner <kevinb@redhat.com>
>> Cc: Kevin Buettner <kevinb@redhat.com>
>> Date: Tue, 10 Nov 2026 00:07:52 -0700
>>
>> This series consists of two parts:  a fix and a test case for this
>> upstream bug:
>>
>> https://sourceware.org/bugzilla/show_bug.cgi?id=34969
>>
>> The test case was largely written by Claude Opus 5.5, but was based on
>> earlier work by GLM 5.3 Flash.
>>
>> I have used the GCC AI Policy convention of using the "Assisted-by:"
>> tag in the commit log for the test case.  The GCC AI Policy may be
>> found here:
>>
>> https://gcc.gnu.org/ai-policy.html
>>
>> Based on my research into the matter, it seems that the convention
>> is to simply use:
>>
>>   Assisted-by: LLM
>>
>> It is my understanding that the GNU LIBC (GLIBC) project is on their
>> way to adopting the GCC policy.  More information here:
>>
>> https://inbox.sourceware.org/libc-alpha/7b311b3e-8a35-4622-84e3-7dc57dbcac28@redhat.com/
>>
>> In particular, observe Carlos's comment:
>>
>>   "I think we should also approach binutils and gdb to harmonize the
>>    policy there."
> 
> By contrast, the whole GNU Project was asked by RMS not to accept
> LLM-generated code until the lawyers asked to provide recommendations
> in this regard complete their work:
> 
>   https://lists.gnu.org/mailman/private/gnu-prog/2026/000237.html
> 
> Did we decide to go the GCC way and basically disregard RMS's request?

I think it would make sense for us to align with gcc and glibc on that.

Allowing some legally significant LLM output in the tests seems less
risky to me than allowing some legally significant LLM output in the
actual programs, because worst case we can just delete the tests and the
programs we ship won't be affected.  And from my experience, I can tell
that LLMs are extremely good to generate thorough test cases, which is a
task that is quite difficult, boring and time-consuming for humans, and
that can really benefit the project.  So it seems low risk high reward
to me.

Simon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] PR gdb/server/34969
  2026-11-10 12:58 ` [PATCH 0/2] PR gdb/server/34969 Eli Zaretskii
  2026-11-10 15:15   ` Simon Marchi
@ 2026-11-11  6:13   ` Kevin Buettner
  2026-11-11 12:37     ` Eli Zaretskii
  1 sibling, 1 reply; 8+ messages in thread
From: Kevin Buettner @ 2026-11-11  6:13 UTC (permalink / raw)
  To: gdb-patches; +Cc: Eli Zaretskii



On 11/10/26 5:58 AM, Eli Zaretskii wrote:
>> From: Kevin Buettner <kevinb@redhat.com>
>> Cc: Kevin Buettner <kevinb@redhat.com>
>> Date: Tue, 10 Nov 2026 00:07:52 -0700
>>
>> This series consists of two parts:  a fix and a test case for this
>> upstream bug:
>>
>> https://sourceware.org/bugzilla/show_bug.cgi?id=34969
>>
>> The test case was largely written by Claude Opus 5.5, but was based on
>> earlier work by GLM 5.3 Flash.
>>
>> I have used the GCC AI Policy convention of using the "Assisted-by:"
>> tag in the commit log for the test case.  The GCC AI Policy may be
>> found here:
>>
>> https://gcc.gnu.org/ai-policy.html
>>
>> Based on my research into the matter, it seems that the convention
>> is to simply use:
>>
>>   Assisted-by: LLM
>>
>> It is my understanding that the GNU LIBC (GLIBC) project is on their
>> way to adopting the GCC policy.  More information here:
>>
>> https://inbox.sourceware.org/libc-alpha/7b311b3e-8a35-4622-84e3-7dc57dbcac28@redhat.com/
>>
>> In particular, observe Carlos's comment:
>>
>>   "I think we should also approach binutils and gdb to harmonize the
>>    policy there."
> 
> By contrast, the whole GNU Project was asked by RMS not to accept
> LLM-generated code until the lawyers asked to provide recommendations
> in this regard complete their work:
> 
>   https://lists.gnu.org/mailman/private/gnu-prog/2026/000237.html
> 
> Did we decide to go the GCC way and basically disregard RMS's request?

Not all of us are on that list.  I'm not able to read it...

Does RMS say how long we should wait for the lawyers to provide a
recommendation?  When was that email sent?

Regardless, I'm quite happy to go the GCC way.  In fact, I'd be willing
to go further and accept LLM assisted code into the main part of GDB
too. But it seems to me that getting AI help for writing test cases is a
good first step.

Kevin


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/2] gdb/testsuite: test malformed agent expressions sent to gdbserver
  2026-11-10  7:07 ` [PATCH 2/2] gdb/testsuite: test malformed agent expressions sent to gdbserver Kevin Buettner
@ 2026-11-11 12:36   ` Andrew Burgess
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Burgess @ 2026-11-11 12:36 UTC (permalink / raw)
  To: Kevin Buettner, gdb-patches; +Cc: Kevin Buettner

Kevin Buettner <kevinb@redhat.com> writes:

> Add gdb.server/agent-expr-length.exp, which uses "maintenance packet"
> to send gdbserver agent expressions whose declared length exceeds the
> hex data present in the packet, or which lack the comma after the
> length.  They are sent as breakpoint conditions and commands (Z0) and
> as tracepoint conditions and actions (QTDP).  The test checks that
> gdbserver survives each one and, by reading the tracepoint definitions
> back with qTfP/qTsP, that the malformed parts are dropped instead of
> being stored with an uninitialized tail, while the well-formed
> conditions and actions alongside them are kept.
>
> Against a gdbserver without the previous commit's fix, the test shows

Hi Kevin,

Please don't split tests from fixes like this.  When looking back at
commits using e.g. `git blame` it's super annoying to find a commit with
not associated tests.  I then have to go and dig around in the git
history to see if a test was added later.  It's a small thing, but
keeping the tests with the change just makes peoples (my) life that
little bit easier.

> the heap disclosure (a tracepoint condition read back with 63 bytes of
> heap contents beyond the single byte sent), and gdbserver crashes on
> the expressions with a huge declared length.
>
> This is a test for CVE-2026-121996.
>
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34969
>
> Assisted-by: LLM

Maybe this is why you split it off?

I'm all in on LLM use, and I'd be in favour of it for helping create
both GDB patches and test patches.  But I just don't see how the current
copyright assignment can be compatible with LLM generated code.

I do see a path to getting LLM code into GDB, which goes:

  1. Convince GDB project to accept code under DCO rather than copyright
     assignment,

  2. If we no longer need to assign copyright, then using LLM generated
     code is a project choice.  Convince GDB project to accept LLM
     generated code.

  3. There's no step 3!

But if we want to start accepting LLM code now then I think someone need
to propose a patch which actually makes it clear where we do or do not
accept LLM code.  We (the GDB project) also need to document how we see
this interacting with copyright assignment.  I mean, we (GDB project)
might say we hare happy to risk assigning copyright to FSF for LLM
generated testsuite code, but are FSF happy to receive it?

If not then the policy has actually become "testsuite is no longer
copyright assigned to FSF".  This all needs to be checked (with FSF) and
a proper policy written down.

I don't think this should be decided in some thread hanging off some
random testsuite patch.

I'm really not anti-llm, I make use of these tools for patch review, and
planning work in GDB, and I'd like to be able to use it more
extensively.  I think by dragging their heels for so long the FSF have
messed up on this topic, and honestly, I think the right path for GDB is
to move away from FSF copyright assignment.

Hopefully we can find a way to get this fix and a suitable test merged
without having to resolve the whole llm question.

Thanks,
Andrew


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/2] PR gdb/server/34969
  2026-11-11  6:13   ` Kevin Buettner
@ 2026-11-11 12:37     ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2026-11-11 12:37 UTC (permalink / raw)
  To: Kevin Buettner; +Cc: gdb-patches

> Date: Tue, 10 Nov 2026 23:13:49 -0700
> Cc: Eli Zaretskii <eliz@gnu.org>
> From: Kevin Buettner <kevinb@redhat.com>
> 
> >>   "I think we should also approach binutils and gdb to harmonize the
> >>    policy there."
> > 
> > By contrast, the whole GNU Project was asked by RMS not to accept
> > LLM-generated code until the lawyers asked to provide recommendations
> > in this regard complete their work:
> > 
> >   https://lists.gnu.org/mailman/private/gnu-prog/2026/000237.html
> > 
> > Did we decide to go the GCC way and basically disregard RMS's request?
> 
> Not all of us are on that list.  I'm not able to read it...

I show the full text below.

> Does RMS say how long we should wait for the lawyers to provide a
> recommendation?

No.

> When was that email sent?

On May 21 this year.

> Regardless, I'm quite happy to go the GCC way.  In fact, I'd be willing
> to go further and accept LLM assisted code into the main part of GDB
> too. But it seems to me that getting AI help for writing test cases is a
> good first step.

Test cases are also code, AFAIU.

  Please do not install code generated by LLMs into GNU packages
  Richard Stallman rms at gnu.org
  Thu May 21 19:00:55 EDT 2026

  The FSF is looking at the copyright issues raised by code generated by
  LLMs, to determine under what conditions we can consider it
  sufficiently safe to install LLM output, and what precautions to take
  and what records to keep when doing so.

  There are multiple issues to consider.  One is that having LLM output
  in the source code of a program may complicate copyright registration
  or make the program's copyright invalid, because the LLM's output may
  be unable to carry a copyright.

  Until the FSF states a conclusion, please don't install or accept any
  LLM-generated code into your GNU packages.

  If you have already installed some LLM-generated code, there is no
  need to rush to delete it.  Perhaps we will eventually conclude that
  that particular code is safe.  But do save full records about how that
  code was generated, including the prompts used to generate it, and
  take care not to make any further changes that would ingrain
  dependence on it, or in any way be an obstacle to deleting it, if that
  is later called for.

  On a different but related issue, there are people who claim, as if
  certain, that passing copylefted code through an LLM can produce
  equivalent code that isn't covered by that code's copyleft.  We think
  the output is unlikely to excape from the copyright covering the
  LLM's input.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-11 12:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-10  7:07 [PATCH 0/2] PR gdb/server/34969 Kevin Buettner
2026-11-10  7:07 ` [PATCH 1/2] gdbserver: reject malformed agent expressions in gdb_parse_agent_expr Kevin Buettner
2026-11-10  7:07 ` [PATCH 2/2] gdb/testsuite: test malformed agent expressions sent to gdbserver Kevin Buettner
2026-11-11 12:36   ` Andrew Burgess
2026-11-10 12:58 ` [PATCH 0/2] PR gdb/server/34969 Eli Zaretskii
2026-11-10 15:15   ` Simon Marchi
2026-11-11  6:13   ` Kevin Buettner
2026-11-11 12:37     ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox