From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id sBjXMDGNPmqFVBkAWB0awg (envelope-from ) for ; Fri, 26 Jun 2026 10:31:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1782484273; bh=3raYcT5wFuhcbZms1463L45pESIh/+nDoL43tap8p3E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=A82Nk2ij7U7qufWT4nQAO+SR8lJ/1sQAGeQ0vMH9/P3g6e/bzpD+YS1Nle4Z436tQ 9m9B016RNZzk1qBL7uzIsGiyNivu49xQ0ZNaD+5+cLp8ScXLgxVE6beeRn+tEeVGYR 1H4hER5FqVOEZj3wpxiNVUxViFfolPv8XHS8yTyI= Received: by simark.ca (Postfix, from userid 112) id B6FD01E098; Fri, 26 Jun 2026 10:31:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=hBRQALxE; dkim-atps=neutral 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 4097C1E024 for ; Fri, 26 Jun 2026 10:31:13 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BE8D4BA2E23 for ; Fri, 26 Jun 2026 14:31:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5BE8D4BA2E23 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=hBRQALxE Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 334F04BA2E09 for ; Fri, 26 Jun 2026 14:30:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 334F04BA2E09 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 334F04BA2E09 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782484248; cv=none; b=rePE2I0KIGA3Xniv0w23vUAi0ZWJwWROJhnN4s9dKr4Du8pdIt9tSxxIF5DT9yPP8tLWhjeQKOWTq/a7ZXDiP7ytei+mzWIiYX/YPqnSe9SAR2KESEETeXLYlcy1+y4UzeHszmBIs5HQ+cGAVe6gTBozYXWzugGFlvnYX6ggaOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1782484248; c=relaxed/simple; bh=3raYcT5wFuhcbZms1463L45pESIh/+nDoL43tap8p3E=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=RqstPHDo0pCzMdpSC068IKv1duY0NL9UXydAyeEn0AsIh4NlkIVv31bJX3n3MfXmVU2Er/8gWuaO/Jnf/xpVRin+0pHfpNaCLmYYTL0tFFXoXOhbF88WnqDGWRorCr45yS3uAgMvx4WxoPQO2ISLSPmVcNGH5ZbBiQ8PJ1D30uE= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=hBRQALxE DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 334F04BA2E09 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1782484247; bh=3raYcT5wFuhcbZms1463L45pESIh/+nDoL43tap8p3E=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=hBRQALxEbob2mVBbf9C6N9Vqq4eSPTVgr9ZlX0fMLuiZQDhSPZNIPT7OqF03UegCm iHgwFR/uzBciIWj6U+VKL5DQfMXgiInrAdRi0fmccJIMIl6iGe2Sp2VlPPamLD5nEg cjzdWFE9uDN0PhuOcFx5LRiR7qCxIImLBmZsYKCU= Received: by simark.ca (Postfix) id D69B61E024; Fri, 26 Jun 2026 10:30:46 -0400 (EDT) Message-ID: <7efeed5a-415c-4b39-ad3f-b2f893974c04@simark.ca> Date: Fri, 26 Jun 2026 10:30:46 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH][PR gdb/34239][PR gdb/34299] gdb: Check bounds before reading DWARF expression operands To: Firmiana , Guinevere Larsen Cc: gdb-patches@sourceware.org References: <20260618180158.2893540-1-firmiana402@gmail.com> Content-Language: en-US From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 2026-06-26 04:31, Firmiana wrote: > > Hi, > > Thanks for the review and for testing the patch. > > Before preparing v2, I would like to respond to a few points. > > About the safe_read_* helper implementation: yes, your understanding is > right. The helper saves the original pointer, advances through > safe_skip_bytes to validate that the requested byte range is available, > and only then calls extract_*_integer on the saved pointer. I agree that > this was not obvious enough, so I will make the helper comments and/or > implementation clearer in v2. > > On the question of reading into `uoffset` and then assigning to the real > destination: that was mainly done to mirror the nearby > safe_read_uleb128/safe_read_sleb128 helper style, which uses fixed output > types and output pointer parameters. Based on your comment and the other > review, I plan to change the new fixed-width helpers to use references, > probably templated, so many call sites can read directly into `result`, > `this->m_len`, or the relevant field. The GDB code used to be C, and is now organically evolving into C++. When you find some opportunities to use some C++ constructs to make the code better, feel free to do so. > For DW_OP_deref_size / DW_OP_deref_type: the v1 code is intended to be > equivalent to: > > addr_size = *op_ptr; > op_ptr++; > > but with a bounds check first. safe_read_unsigned_integer keeps the > original pointer for extract_unsigned_integer and uses safe_skip_bytes to > validate and compute the next pointer. Since this was confusing, I will > rewrite the branch more explicitly in v2. > > I will also switch the testcase loop to foreach_with_prefix. Good idea. Simon