)]}'
{
  "commit": "83330e3e9f113a240afb0b970aaa7402ecc50e63",
  "tree": "15763756aa3a394751d76f2cd5a0dcac37d940a0",
  "parents": [
    "a47dbab97f0692856e9d4cde6dd6724f4139aeaf"
  ],
  "author": {
    "name": "Kevin Buettner",
    "email": "kevinb@redhat.com",
    "time": "Mon Nov 09 13:27:53 2026 -0700"
  },
  "committer": {
    "name": "Kevin Buettner",
    "email": "kevinb@redhat.com",
    "time": "Tue Nov 24 11:01:27 2026 -0700"
  },
  "message": "gdbserver: reject malformed agent expressions in gdb_parse_agent_expr\n\ngdb_parse_agent_expr, defined in gdbserver/ax.cc, is called from four\ndifferent sites within gdbserver, two from mem-break.cc and two from\ntracepoint.cc.\n\nWithin tracepoint.cc, gdb_parse_agent_expr is called to handle the \u0027X\u0027\nportion of a QTDP packet.  The \u0027X\u0027 portion describes agent expressions\nused by tracepoints for both conditions and actions.\n\nWithin mem-break.cc, it\u0027s called to handle breakpoint conditions or\ncommands as part of a \u0027Z\u0027 packet.  These conditions or commands are\nspecified in a bytecode format identical to that used for agent\nexpressions for tracepoints.\n\nThe current implementation of gdb_parse_agent_expr contains no checks\nabout validity of the length specified in the portion of a packet that\nrepresents an agent expression.  This takes the form \"X\u003clen\u003e,\u003chex\u003e\".\n(This is not an \u0027X\u0027 packet but, rather, a portion of the \u0027QTDP\u0027 packet\nfor tracepoints or \u0027Z0\u0027 packet for breakpoints.)  gdb_parse_agent_expr\nallocates LEN bytes and asks hex2bin to convert that number of bytes,\nbut hex2bin stops at the end of the packet, leaving the end of the\nbuffer uninitialized.  For a tracepoint condition, that buffer is\nlater sent back to GDB in reply to qTfP/qTsP, which are used to\nrequest tracepoint data.  Thus, using an overly large length can\nprovide access to uninitialized gdbserver heap memory, a potential\nsecurity concern.\n\nThe parse pointer is also advanced by 2 * LEN bytes regardless of how\nmuch data was present, so callers continue parsing from a pointer that\ncan be far beyond the end of the packet; a large LEN crashes gdbserver.\n\nFix this by having gdb_parse_agent_expr return nullptr (representing\nan error condition) when the specified length exceeds the amount of\nhex data actually present.  This code also wasn\u0027t checking for the\nmandated comma character in the packet syntax.  I added a check and\nerror return for that too.\n\nThe remainder of this patch to gdbserver consists of propagating the\nerror back to various points in the code where write_enn may be\ncalled.  This causes the error to be sent as the reply to GDB.\n\nFor Z0 packet support, I removed two warning messages.  One concerned\na malformed condition and the other was about a malformed action\n(command).  A malformed condition was discarded, making the breakpoint\nunconditional; similarly, a malformed action was simply dropped.  The\nwarning message (which might not even be seen by the user) stated\nthese facts.  gdbserver now returns an error response for these cases.\n\nThe test case uses GDB\u0027s little-used \"maintenance packet\" command to\nsend bad packets to gdbserver.  This has been done not only for the\ntracepoint related packets, but for the Z0 (set breakpoint) packet as\nwell.  Z0 used to silently drop malformed packets and set a breakpoint\nwithout the (presumably intended, but malformed) condition or action.\nIt no longer does this.  Malformed conditions and actions within a\nZ0 packet now cause an error to be returned.\n\nWhile working on this patch, I spotted numerous other problems in\nnearby code (e.g. memory leaks and lack of packet syntax checking).\nI left these alone.  gdbserver desperately needs attention to fix\nmyriad problems.\n\nThis fixes the bug associated with CVE-2026-121996.\n\nRegression tested on x86_64 Fedora 44.  The new test case was tested\non RISC-V Fedora 42, for which neither Z0 packets nor tracepoint\npackets are implemented.\n\nBug: https://sourceware.org/bugzilla/show_bug.cgi?id\u003d34969\n\nApproved-By: Andrew Burgess \u003caburgess@redhat.com\u003e\n",
  "tree_diff": [
    {
      "type": "add",
      "old_id": "0000000000000000000000000000000000000000",
      "old_mode": 0,
      "old_path": "/dev/null",
      "new_id": "d9e1db7865c1cd26d540cd518a2e3d1404948bc4",
      "new_mode": 33188,
      "new_path": "gdb/testsuite/gdb.server/agent-expr-length.exp"
    },
    {
      "type": "modify",
      "old_id": "4993bed2532c999bf81724b2289773fe5f97011e",
      "old_mode": 33188,
      "old_path": "gdbserver/ax.cc",
      "new_id": "f73a407f70aac9b21432e4d5aa8d76fa70dd596e",
      "new_mode": 33188,
      "new_path": "gdbserver/ax.cc"
    },
    {
      "type": "modify",
      "old_id": "03882f4888a5a68783354ffab8c93beb92e40cb5",
      "old_mode": 33188,
      "old_path": "gdbserver/ax.h",
      "new_id": "7ad077f81951f997675f1794c4d00968aa80b5ca",
      "new_mode": 33188,
      "new_path": "gdbserver/ax.h"
    },
    {
      "type": "modify",
      "old_id": "4e944ff1df2e5b8d213f650b3d8ea37f64387dab",
      "old_mode": 33188,
      "old_path": "gdbserver/mem-break.cc",
      "new_id": "071f8330c5047d942219db1a1ba40065ce38194d",
      "new_mode": 33188,
      "new_path": "gdbserver/mem-break.cc"
    },
    {
      "type": "modify",
      "old_id": "df5754257cdec7244d6a0beb42b8521f1372086f",
      "old_mode": 33188,
      "old_path": "gdbserver/server.cc",
      "new_id": "9bb15d1ece2c647b08c2255477b618d60beddf16",
      "new_mode": 33188,
      "new_path": "gdbserver/server.cc"
    },
    {
      "type": "modify",
      "old_id": "6f657257ee83558874f105cb27fe1debac6fa2bf",
      "old_mode": 33188,
      "old_path": "gdbserver/tracepoint.cc",
      "new_id": "e7b09b8bfee426d8dda8515bbac1cf193a6f043a",
      "new_mode": 33188,
      "new_path": "gdbserver/tracepoint.cc"
    }
  ]
}
