From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1aiBB5flBWtOYzMAWB0awg (envelope-from ) for ; Tue, 24 Nov 2026 14:29:27 -0500 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dg5SIbFF; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id F3E721E023; Tue, 24 Nov 2026 14:29:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 32AE01E023 for ; Tue, 24 Nov 2026 14:29:26 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A158F439A7C0 for ; Tue, 24 Nov 2026 19:29:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A158F439A7C0 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dg5SIbFF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 94E8646C8345 for ; Tue, 24 Nov 2026 19:28:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 94E8646C8345 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 94E8646C8345 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795548533; cv=none; b=lAJIQuGjFqlpwXl7k1wRkYE4BYfwGxJ4dMSOWZmj5AMUAXCzsuVM6E08i3OVa3+zUkliONTCwJwKvfSRC5/KUOUlLPWCStWkgy6F0K8mXyI9lhJym+2p+YpY/jOnMRpS3Yw+fO8+T+EuXzgRdAxTFuPFzebwFyqJV93BDMscgIM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795548533; c=relaxed/simple; bh=7k/ByVejF/yGSGINIJRwQeZV8P1R9CFH63rNDp8Hq9M=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=tBsd/CBuvEVmMLEq9ZjQOVI9YMVDOa8lamBtc9c9LI1iDHkxqJREouUpw6BEpPehNRJ1sueCsE4conSKi5zFD4h94NLe+/KoFN4a+CWNB9HfN/Q3Wm9V+R5vkT8kM/kFQQfSQhLGsLPSHdCWsS1c/TwvDZBXicVrBax5OQJZQwY= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=dg5SIbFF DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 94E8646C8345 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795548533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0rkLKFbfWLGqBvuMTP+Zzz8GMFKf+Zknxj5PqDMbDqI=; b=dg5SIbFFiJULemHb15W90nWX0bDkJ5ytcy+nUhICXhqJ/wDYS5O1pp9PVWWMYTxKQQORtX xZtD9y/TE3J4bqX9t4mDtnaKSDOeryY1t7I3GQVV6X2lLNjIBqVboRGO1meftF0WsnOEl6 6vezX/NmCk3NpSxnG7OI0M8tf+jRDbQ= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-547-dNlIVUORPe-xAEwImRi51A-1; Tue, 24 Nov 2026 19:28:50 +0000 X-MC-Unique: dNlIVUORPe-xAEwImRi51A-1 X-Mimecast-MFC-AGG-ID: dNlIVUORPe-xAEwImRi51A_1795548530 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-55d846fd50aso2812431cf.0 for ; Tue, 24 Nov 2026 11:28:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795548530; x=1796153330; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0rkLKFbfWLGqBvuMTP+Zzz8GMFKf+Zknxj5PqDMbDqI=; b=ud1ERDqsSL991GImH3CA1v2TsQYN0j8UmOqhW5pcKfu+Jcz4sHCK15wAfAaV24iXbT uzXqrQXPuWW8+lZYIeOamsN9Y2wPlVy0OmyzyokVcN52k6HoU7b9R3EBf4qGDhHkW4Db GH1gInHEOUpj+OWn8+zInlV6WvrC60Av58BvVHFDZ0DGfyequgcuFsTn4HDOB7wJ+f1B 7NScP3e+SQ8p68Goa0rgD6511xF/zwusuB3tcVtXt3OpAQztdj3NNaVJWPgiIg2Soy/4 0NnOJq15grrITy1qZEpdugVYst1oXs63fZluxDed2J9WwuiTohZOCw50T3p3anBURcds rmTQ== X-Forwarded-Encrypted: i=1; AL+hErG8CJJx9Y6hw4Um3FMVrVBhwKGrQGvqGsZ9s3EV1umRY0Fgl26tNFMJ3080tjpTMYzuI5BLRYfxCF9rtQ==@sourceware.org X-Gm-Message-State: APuU4Z81CEqD5n+miLEWz8Tuy3M77ys5Sy0u+9QnHFoXUTeot+8VjEyA D4+22RpgBtBSIMsr2tljr+hANHU/iP4XEEAB1lHU/rSA2kv7XqljszF6w1j/91WSbU25WmYPgzO WqA+/1ew6uIefnJGP95d4Apb+g7AQOCqr4ZOajkGqJ9wSSckfTKNuDLpz33sDfzfQi9SiGxU= X-Gm-Gg: AZFdTZeT0qCwbMowJ7DpOOhll2ZR82zfRbQ+EzrxwUPz7j44hN1GQoP57yO5wjimRdb wkXXkp9sJP+yZOXkgcW4PXf3x5vJEAH430lrw/u8kgCW3fo4+FJJm4aUPnhEBexRFz+AMXxJ49b I5+Q2RS7EplIMcuAktAoqUyo1XDb7yyYAAGxudCka5JlIckDWNOSEXe9CFZWPzvNPCbHh98HZIk 49I7XZHOFjH24udTfmHdK7eqW4gFm14gdqMOO8k9+bWSSpF9VqIoM4XvTeOY+c20P+h2SSQgTCg 6MnTk7PP+YRIiuxl6bSwq8YRxQWBzaD6k6PY2fqbqy21hZCnCcLrb+TLy+yG4x+ww/CTy7iGJO/ FMF5CO3nPVxxGSwZEVFPV88/vci391BUWOAg2V+VeFtgShbUWhFceCh8= X-Received: by 2002:a05:620a:3905:b0:947:6585:aedd with SMTP id af79cd13be357-949ba827bcamr2637599785a.6.1795548529843; Tue, 24 Nov 2026 11:28:49 -0800 (PST) X-Received: by 2002:a05:620a:3905:b0:947:6585:aedd with SMTP id af79cd13be357-949ba827bcamr2637597385a.6.1795548529400; Tue, 24 Nov 2026 11:28:49 -0800 (PST) Received: from [150.1.200.157] ([172.56.105.46]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb3cb882sm1124849985a.27.2026.11.24.11.28.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 24 Nov 2026 11:28:48 -0800 (PST) Message-ID: Date: Tue, 24 Nov 2026 11:28:47 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 2/5] [gdb/remote] Fix stack overflow in parse_tracepoint_definition To: Andrew Burgess , gdb-patches@sourceware.org References: From: Keith Seitz In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: W9ypUkKeYNZ7uJtohcGrrZf8e1RAXEKQFPqNEMZ_-ws_1795548530 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Hi, Thank you for the review. I'd like to give you my opinion on your follow-up question below. On 11/24/26 6:45 AM, Andrew Burgess wrote: >> @@ -3501,24 +3507,20 @@ parse_tracepoint_definition (const char *line, struct uploaded_tp **utpp) >> /* Parse a chunk of source form definition. */ >> utp = get_uploaded_tp (num, addr, utpp); >> srctype = p; >> - p = strchr (p, ':'); >> - p++; /* skip a colon */ >> + p = require (strchr (p, ':')); >> p = unpack_varlen_hex (p, &start); >> - p++; /* skip a colon */ >> + p = require (p); >> p = unpack_varlen_hex (p, &xlen); >> - p++; /* skip a colon */ >> - >> - buf = (char *) alloca (strlen (line)); >> + p = require (p); >> >> - end = hex2bin (p, (gdb_byte *) buf, strlen (p) / 2); >> - buf[end] = '\0'; >> + std::string decoded = hex2str (p); > > Maybe I'm looking in the wrong place, but I couldn't find the > specification for this 'Z' case anywhere, so I'm guessing a little bit > about what the fields mean. I believe that the meaning of the fields of 'Z' follow 'QTDPsrc': Z::::: From the manual (QTDPsrc): start — offset of this packet’s bytes within the overall source string slen (xlen in the parser) — total length of the source string bytes — hex encoding of a chunk (possibly not the whole string) > Still, we parse XLEN from the packet, then process the remaining bytes > as a string. XLEN isn't used anywhere else. I'm assuming that XLEN is > supposed to be the number of bytes in the string? That's how I interpret it. > The old code didn't check that these things matched, but maybe, as > you're improving the code anyway, we could/should add something like: > > if (decoded.size () != xlen) > bad_trace_definition ("tracepoint", line); > > What do you think? Honestly, I think I'd rather not touch this because the issue isn't quite so simple. XLEN is the Z/QTDPsrc 'slen', the total length of the source string in bytes. 'start' is the offset of this packet's bytes within that string, for strings that need more than one packet. I think the main issue here is that the code is attempting to partially implement that multi-packet protocol possibility. It parses start and slen, but then ignores both and hex2str's "whatever remains as if it were the whole string" feature. GDB's encoder always sends start=0 with the full string today, so in practice decoded.size() == xlen is correct, but a strict equality check would reject a valid chunked reply if that ever did occur. This is definitely another cleanup that could be done, but I'd prefer to not cloud the CVE-related malformed-packet issues that this series focuses on. Is that acceptable? Keith