From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id V47gORF+BWsURDIAWB0awg (envelope-from ) for ; Tue, 24 Nov 2026 07:07:45 -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=GwubiLAr; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DC0D01E166; Tue, 24 Nov 2026 07:07:45 -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 [38.145.34.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 0B0891E09B for ; Tue, 24 Nov 2026 07:07:45 -0500 (EST) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2FC7940AFC8B for ; Tue, 24 Nov 2026 12:07:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2FC7940AFC8B 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=GwubiLAr 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 69B0040AFD41 for ; Tue, 24 Nov 2026 12:07:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69B0040AFD41 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 69B0040AFD41 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=1795522039; cv=none; b=fLjZ38a3L5o6o5SNFDjuOYAwifeADu7Tq1XCj7DPmRiyOoWv8wDk4P+/aMm6velmSMR31EjyHKcHcyTMpU/g7PcdjnNKIz3tyQ4IGJf+y+O/eiWIYisNhsuk/k7/iarnfFq7/hthQy9fSY/FNhVClmmn3PzTI4qEQYzlFm7bwmQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1795522039; c=relaxed/simple; bh=9r3PXQLTC/khG+LKC73laVa2NS81Pzg9bOqWiQ5cU88=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=G1ZpmlGXNc8ZJWanpEbRImkcrCS6j/fNDgg9QcEVFrQrdAQOSOU62FR80yJNtS+7C9TCWhcqL5iwrxIvW2neDIf0vcRKXlJmiwmxT2FgovuDNRs6s91HEad72BrdqN8l2wmgvFgil4JKd0EWKpvIPQmbxLkOlrwEVyI9OZ+OY1g= 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=GwubiLAr DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69B0040AFD41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795522039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IjDGiS+j6jxuT6uFIAhBU52Uz75Xe+OerN7WYYON8vY=; b=GwubiLArCXAMHOm2sLTB7aQpXDILE0MKr3aY5j429eg+BpLsjkO13+wUp76gi5KPuzmVmO dLx6PiH/lJmOmAWxz9tBOPpVZS3iJowX3yaZShWX3EbAEuF0MG5h7fZn6KQojQvn+F9QVw +7XyOgITKDcHq+/K1x0QTaapZMHRlGw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-711-vMuRo4i-NHyUglcHgPLcfg-1; Tue, 24 Nov 2026 12:07:16 +0000 X-MC-Unique: vMuRo4i-NHyUglcHgPLcfg-1 X-Mimecast-MFC-AGG-ID: vMuRo4i-NHyUglcHgPLcfg_1795522036 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-4a0284121c6so31563205e9.3 for ; Tue, 24 Nov 2026 04:07:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795522035; x=1796126835; h=content-type:mime-version:message-id:date:references:in-reply-to :subject:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IjDGiS+j6jxuT6uFIAhBU52Uz75Xe+OerN7WYYON8vY=; b=qNU4QoAph6i85+GjBPYlvW/1VAIwF8tFz+L0XcmbiNHJ0QwcNlc4T+G5+8M8cojtTB Z0aj+goOiwNo2I4MDKlXtCb+EoODxaZRtMNKwRD1SiNIuHguyFFsr9yOMlkrOjxzheMt 9yw+FdW/m47H7+hS663ZPZyNKU2I+cgJPl9I/bxJ/w6a/+DNz/On4Nkpu3KF4ZIOCvoM WiCZlLWxCzeKhFmOdOLFxyXTzodw+6DMjbgv/WdEn5E7InFiHr7ZIvBy08Qo6s23E7FE MjdpjA80z/PEfXfB+ykxH77CbEeyqJFVv9E8K2T0oholsqGWIjonXIc6CXFSvI9TgFqA cqiw== X-Forwarded-Encrypted: i=1; AL+hErFH2pP7YWK+GO/UWMu1p1kAofiAWgx5CxDcWmpfytmtOSmFeGwTRGvkudLOw9WwWMwg13uc7eWB7Fu1cA==@sourceware.org X-Gm-Message-State: APuU4Z9B2cHRasUE8ufRkgCS63JAG/OGIwe+bdUTGYYsdzqH9UYEJlI1 vzrREYadbrgOc2CVN3kUwC7JrbLpvFRvM7D/wSNqjCS6d53LhS4YvGmqS2QKo2ApZn732ftJij5 4dmARQkMIjVydIXfVTcmUZrIw/D91tPnOyr6tgNlXqleNQMC+dmn031Vv9CZeXfEo+rHvplg= X-Gm-Gg: AZFdTZfMuCTVFtIY6ti3VMGAnLq3BeDP7JOQC516gjC/hXym19xkg5ej1wa+PtnuOWO 3UNdmIkJue/cdni8OYG/Km+90uHeUhXIscSKzzJUz7Ic6a+QCw6OR+QkpMHl3l9vdIv7PuP7EQI 8cKp9FiILVjiNNa63PA+Wnh/rcamxKGT5ZEgZn911jSGfin+/o+NWa6AkrLHfrWCC4GWNtnbfK5 e52atEoQRgKScqu4GIIwOhrRbvmE2GTfyYlHmpI/BBlpfSO3Bvolm6aOPFMNh55jfGZ55CghNxe PCb5YhogwpBh4wJ1ICrtyFmFHMrHiNU6lDwP+T4NVM4+HBO50aRp5vTD24kQKJ3uVpXdMNDWQWx 8suGg9ZETPzJnZ2N1+UkAD9XRu1xRvUcCvUlPyyfxcYsUFw== X-Received: by 2002:a05:600c:820d:b0:4bb:6cef:d14b with SMTP id 5b1f17b1804b1-4bb887c34f1mr306381545e9.2.1795522035554; Tue, 24 Nov 2026 04:07:15 -0800 (PST) X-Received: by 2002:a05:600c:820d:b0:4bb:6cef:d14b with SMTP id 5b1f17b1804b1-4bb887c34f1mr306380945e9.2.1795522035033; Tue, 24 Nov 2026 04:07:15 -0800 (PST) Received: from localhost ([83.216.138.189]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb8960068fsm161279285e9.4.2026.11.24.04.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2026 04:07:14 -0800 (PST) From: Andrew Burgess To: Keith Seitz , gdb-patches@sourceware.org Subject: Re: [PATCH 1/5] [gdb/remote] Fix stack overflow in parse_tsv_definition In-Reply-To: <0075bc3fc2908558e86385531ee62479683149a7.1794430701.git.keiths@redhat.com> References: <0075bc3fc2908558e86385531ee62479683149a7.1794430701.git.keiths@redhat.com> Date: Tue, 24 Nov 2026 12:07:12 +0000 Message-ID: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: eISOBvKy2ck5ULYoBiNwrNe0Zbnwl-J2yqMf-iKSQYA_1795522036 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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 Keith Seitz writes: > gdb/34967 demonstrates how a malicious remote stub may cause > a stack overflow with a malformed tsv definition. > > parse_tsv_definition skips field separators without checking whether > the skipped character is really the field separator. Worse, a short > definition such as "1:0:0000" (which is missing a colon) would point > a buffer past the terminating NUL into leftover bytes of a reused RSP packet > buffer. hex2bin then copied more bytes than allocated by alloca. > > Fix this by introducing shared helpers that require a field separator > and report a malformed definition. Only parse_tsv_definition is > converted here; follow-up patches will use the same helpers for the > remaining trace definition parsers. > > Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34967 Thanks for fixing this. I have one small suggestion, see inline below. > > +/* Free UTSVP, including each node's name. */ > + > +static void > +cleanup_uploaded_tsvs (uploaded_tsv **utsvp) > +{ > + for (uploaded_tsv *utsv = *utsvp; utsv != nullptr; utsv = utsv->next) > + xfree (const_cast (utsv->name)); > + free_uploaded_tsvs (utsvp); > +} I think it would be better to move the free of uploaded_tsv::name into free_uploaded_tsvs, which would close a memory leak. I took a look through the GDB code and I think name is only ever assigned in one place by strdup, and the name is owned entirely by the uploaded_tsv, so I cannot see why freeing the name would cause any problems. This could be done in this commit as it's a small enough fix. Thanks, Andrew