From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id uYW2ARum22rKqBAAWB0awg (envelope-from ) for ; Fri, 23 Oct 2026 14:23:23 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=avIgq9G2; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E6CB5378002; Fri, 23 Oct 2026 14:23:22 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no 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 CF2081E007 for ; Fri, 23 Oct 2026 14:23:21 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 93AE14BA2E3D for ; Fri, 23 Oct 2026 18:23:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 93AE14BA2E3D Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=avIgq9G2 Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 830784BA2E0D for ; Fri, 23 Oct 2026 18:22:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 830784BA2E0D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 830784BA2E0D Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792779775; cv=none; b=vCwFiDiumywgSHufNsQdeNOGUPBFYa7iHJVWGyt05KT6jAtGvXMVrINrgExEIVA9LE7z6ck2wzKZ77WK9zGqf31/9yYy8PrXwBiFsC/k17cti+W2+sMeQtBa8kkNIHl3ZByr1cvtCVsxhK7i2TfgiJdQL+aRwE0AXLT4RkKkWXI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792779775; c=relaxed/simple; bh=3tQ67oPeC7Puffdx+hkySLCVzwPshtUabfk6JmlJc94=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=BBnA96qQdUC0XwCouc6WJUwbnJX/TZi/Szn3Voi0PfrDKqGklKunmlR5HPlwDuRCjnib9g7ClV5FgAuBXcacTjykVoCbPOGZ9nPB7gfWPj7a9e2RCFW0hcEJDs7RXujHjgdCoLjhC8C9ICkw7o/gzfEuqsSK/y6kw2/20pqM5RY= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=avIgq9G2 reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 830784BA2E0D Received: from eig-obgw-5005b.ext.cloudfilter.net ([10.0.29.189]) by cmsmtp with ESMTPS id KHhzx0ev3c3XsKJuoxE4M4; Fri, 23 Oct 2026 18:22:54 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id KJunxBALr369DKJunxZMTk; Fri, 23 Oct 2026 18:22:53 +0000 X-Authority-Analysis: v=2.4 cv=EPgG00ZC c=1 sm=1 tr=0 ts=6adba5fe a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=660iZSQnnn4A:10 a=ItBw4LHWJt0A:10 a=pGLkceISAAAA:8 a=omT52crgquHtmPoFa7MA:9 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=w9JqkQI0J6qG7J/UlpsvrJ+iOxObjikAhoikyxfH4fc=; b=avIgq9G2a6mRufyVZbFoHwkZC0 cImokqjf3pInYwA9gjzJhhCQpEEsYGu7oiC6BFtvj3RDboLHoo482QS+O4vN+9UBepL8kctiCY9tG JulWDKUHSLugRDIOt8lddLZS5; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:55650 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xKJum-00000003QJr-2VlQ; Fri, 23 Oct 2026 12:22:52 -0600 From: Tom Tromey To: Jielun Wu Cc: gdb-patches@sourceware.org, Simon Marchi , Guinevere Larsen Subject: Re: [PATCH v2] gdb: Check bounds before reading DWARF expression operands In-Reply-To: <20260805040640.2095812-1-firmiana402@gmail.com> (Jielun Wu's message of "Wed, 5 Aug 2026 12:06:40 +0800") References: <20260805040640.2095812-1-firmiana402@gmail.com> X-Attribution: Tom Date: Fri, 23 Oct 2026 12:22:51 -0600 Message-ID: <87ld7oqnt0.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xKJum-00000003QJr-2VlQ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net (bapiya) [97.122.110.129]:55650 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLbWdh3UsrM18zQf/cyGMO4TtVPYIXoC3s0aV0JvJ/fEa0HlzW1epVl/s1WP8ZIwTWyfEl2DUWNN0dhu6ko1QoxFk1+dTb8pYQFXYUaYCfKMf2Z/Qlls vS4nLTkC9z5t5RP0Sme/2ovSXCe3hUD40bvkB6RGn2uWvjKrcZi+qatUtF7ELMgnLDmMPmo3Mh76g87AZbzk8SsRrxZyfoNNfzU= 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 >>>>> Jielun Wu writes: > Some DWARF expression opcodes read fixed-width operands or block payloads > before checking that the bytes are available in the current expression. > Malformed expressions can consequently consume opcode or unrelated bytes > and fail later with misleading results. Thanks for the patch. > +/* Return BUF advanced by BYTES bytes. Throw an error if fewer than BYTES > + bytes remain before BUF_END. */ > + > +static const gdb_byte * > +safe_skip_bytes (const gdb_byte *buf, const gdb_byte *buf_end, > + ULONGEST bytes) > +{ > + gdb_assert (buf <= buf_end); It's conventional in C for the end pointer to be one-past-the-end. And I think that's true in this code too: const gdb_byte *op_ptr = expr.data (); const gdb_byte *op_end = expr.data () + expr.size (); + op_ptr = safe_skip_bytes (op_ptr, op_end, len); So using "<" seems more correct than "<=" here? OTOH maybe it doesn't matter due to the subsequent check: > + if (bytes > (ULONGEST) (buf_end - buf)) > + error (_("DWARF expression error: ran off end of buffer reading bytes")); Curious what you think. Anyway that's my only nit on this patch. Tom