From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QF4VGj7Cw1/0CgAAWB0awg (envelope-from ) for ; Sun, 29 Nov 2020 10:46:06 -0500 Received: by simark.ca (Postfix, from userid 112) id 64DDF1F0AC; Sun, 29 Nov 2020 10:46:06 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.3 required=5.0 tests=MAILING_LIST_MULTI,RDNS_NONE autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5530B1EFBB for ; Sun, 29 Nov 2020 10:46:05 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 17167386F83E; Sun, 29 Nov 2020 15:46:04 +0000 (GMT) Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 2D68F385EC58 for ; Sun, 29 Nov 2020 15:46:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2D68F385EC58 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=brobecke@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 5CA6956170; Sun, 29 Nov 2020 10:46:00 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id b3z2LwoxZQLo; Sun, 29 Nov 2020 10:46:00 -0500 (EST) Received: from tron.gnat.com (tron.gnat.com [205.232.38.10]) by rock.gnat.com (Postfix) with ESMTP id 4CAF45616D; Sun, 29 Nov 2020 10:46:00 -0500 (EST) Received: by tron.gnat.com (Postfix, from userid 4233) id 2A333AD; Sun, 29 Nov 2020 10:46:00 -0500 (EST) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: RFA: wrap mpz_export into gdb_mpz::safe_export... Date: Sun, 29 Nov 2020 10:45:55 -0500 Message-Id: <1606664757-144138-1-git-send-email-brobecker@adacore.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <20201123042711.GA967337@adacore.com> References: <20201123042711.GA967337@adacore.com> X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Simon Marchi Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Hello, As discussed earlier this week when we discovered that we need to be careful before calling mpz_export, the purpose of this patch series is to introduce a new gdb_mpz method called safe_export that GDB can use to make sure we don't have any buffer overrun. As it happens, you'll see from patch #2 that I found a number of areas we could improve. For the record, I didn't do the following, but I was thinking it would be nice to poison mpz_export if we could. We can do that as a followup patch, if we'd like, although I will likely need a bit of help doing so, because I am not sure how to poison it for the entire GDB except the one place where it's OK to use it. In the end, it sounds to me like Tom wants to wrap GDB's usage of gmp into the gdb_mp[xxx] classes, and so, once we have that, it seems unlikely that someone would unwittingly use mpz_export directly. Patch #1 is just something I noticed. Truth be told, I am kind of second guessing myself on that one... Luckily, it's easy to just drop it if it turns out I was wrong. * [RFA 1/2] Fix TARGET_CHAR_BIT/HOST_CHAR_BIT confusion in gmp-utils.c * [RFA 2/2] gmp-utils: protect gdb_mpz exports against out-of-range The patches above were tested on x86_64-linux, with both the official testsuite, as well as AdaCore's testsuite (just in case). OK to push to master? Thank you! -- Joel