From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.freebsd.org (mx2.freebsd.org [96.47.72.81]) by sourceware.org (Postfix) with ESMTPS id 74FCB385801E for ; Thu, 17 Mar 2022 16:23:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 74FCB385801E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [96.47.72.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits)) (Client CN "mx1.freebsd.org", Issuer "R3" (verified OK)) by mx2.freebsd.org (Postfix) with ESMTPS id 4869085FFB; Thu, 17 Mar 2022 16:23:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KKC9y0HB1z3tLn; Thu, 17 Mar 2022 16:23:18 +0000 (UTC) (envelope-from jhb@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647534198; 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=Q2ijST/1tYQFCZwWzXssflS9qGjFL7bV7TZDhfHSXj0=; b=VFKtmaErWPC4twoXiMV+jsyMNdtjNgGwYPORF/eUZGzCpfn4ioc124crN1gSy6opKikpmH BN74zNCziy6HfVHPFIvb3DAyX2n+FD9ZPuJOTjoPhjTjhV9ccpsiS+14PTy2qRa1g0Unxc zJpbunbHPnsQUXIogmcyCaGiCtrkXp+vAUGyGPjp9EwAQx8AFN7EECUjiiN5DzRrd4kYHZ NN9oZCvNTihFm+12AiRkIdTtMbpUdjNcMHSscsrGg26A7j/G0I4UPq2clrvNAzAht10FCi 8D0Egp13oRRgCVY2BXJNNPSKJLDXvEpjakKqRjd6xp4u9H31khzIVo+Z8d6Z6Q== Received: from [10.0.1.4] (ralph.baldwin.cx [66.234.199.215]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: jhb) by smtp.freebsd.org (Postfix) with ESMTPSA id 97CB99BB4; Thu, 17 Mar 2022 16:23:17 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Message-ID: <6c760756-3cc9-f024-f40a-f8b4a13e4418@FreeBSD.org> Date: Thu, 17 Mar 2022 09:23:16 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.6.0 Subject: Re: [PATCH] Avoid harmful fall throughs in core_target::xfer_partial. Content-Language: en-US To: Pedro Alves , gdb-patches@sourceware.org References: <20220316193604.89477-1-jhb@FreeBSD.org> From: John Baldwin In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647534198; 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=Q2ijST/1tYQFCZwWzXssflS9qGjFL7bV7TZDhfHSXj0=; b=t0TBYPK3S6u53VFVjIo/s9aXEI0/YhbKTQnAV8lJQqLHw6B9iqr6iDdlY3H0GstBIGOnQs GvgC+W3FQ07sn1VpOKOacKnhsYzBF7e7mbBuKZ88gvv8nptLl8VnKpLYgQTwmW9DAjNVYw a3wBYS22p+btY31jFq3J1IrJYUi1Hn2xxS3oRXFR1jvo838YEInK/wi2dCRj+mG+uBDKpn X4GoevzPVOR1DgOqIyPPOArYSJwec0h/EZvwgNbFi50Gt1xueaW+zE0Pi0i6VPQlVfy+L3 G/MjA1vh0GJAFp2MlG/iFaFDI1oqYnTDv0TMhpApBM46gAR0eokj+UjOOqIgjw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647534198; a=rsa-sha256; cv=none; b=KpBr472Rw+qSlUj89oSxCKee4gCL++TwgywpuvFqLb8hcvnDMMSOej9aq6tr/0LswQkz4s /P/D/CYztqVJoQ1qyxu/0ZCrgUiqr0bpFBG5NWZSeoEDMGfmbOecObEeik5nwULZk9gvsm 7NTsF/6f9BAavjO+Lyd0WfwTG1Wj3MXRAd4SPOm+DCDsnmoGfPQTmoTdNkBb9aORuj53l1 cICJaVlaziN5O1eajHNYE0kbP+sDLys5UfHljKD4LH6/4h5KstMkCSZoCDwEiMv/xWGi6I Zdblia2AuXETLI7TSQYAqA2LHbcV96bKxwD0wOY4OxNK1wjttd19BlKhZRZaFw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Thu, 17 Mar 2022 16:23:19 -0000 On 3/17/22 9:06 AM, Pedro Alves wrote: > On 2022-03-16 19:36, John Baldwin wrote: >> The cases for TARGET_OBJECT_LIBRARIES and TARGET_OBJECT_LIBRARIES_AIX >> can try to fetch different data objects (such as >> TARGET_OBJECT_SIGNAL_INFO) if gdbarch methods for the requested data >> aren't present. Replace case fallthroughs with an explicit goto to >> the default case. > > This is OK. I mean, I think it would be reasonable to instead return > TARGET_XFER_E_IO -- it's what the other cases do (notice even TARGET_OBJECT_SIGNAL_INFO > doesn't fallback to the beneath target if there's no gdbarch method installed), and the targets > beneath (file and dummy) won't be returning any library anyhow. OTOH, maybe some day we will > teach GDB to read the list of libraries the program is linked with and load those before > the program starts, and it's conceivable that we would do that at the file_stratum layer. I'm happy to do whichever. I was trying to preserve the intent from when TARGET_OBJECT_LIBRARIES was first added. If there are no beneath targets that handle these objects, then I think it probably is cleaner to just fail with TARGET_XFER_E_IO for now and let explicit fall through logic be added in the future when it is needed. > Pedro Alves > >> --- >> gdb/corelow.c | 5 +++-- >> 1 file changed, 3 insertions(+), 2 deletions(-) >> >> diff --git a/gdb/corelow.c b/gdb/corelow.c >> index 1579e6bc2b8..f7f2bd3f318 100644 >> --- a/gdb/corelow.c >> +++ b/gdb/corelow.c >> @@ -943,7 +943,7 @@ core_target::xfer_partial (enum target_object object, const char *annex, >> return TARGET_XFER_OK; >> } >> } >> - /* FALL THROUGH */ >> + goto fallthrough; >> >> case TARGET_OBJECT_LIBRARIES_AIX: >> if (m_core_gdbarch != nullptr >> @@ -964,7 +964,7 @@ core_target::xfer_partial (enum target_object object, const char *annex, >> return TARGET_XFER_OK; >> } >> } >> - /* FALL THROUGH */ >> + goto fallthrough; >> >> case TARGET_OBJECT_SIGNAL_INFO: >> if (readbuf) >> @@ -988,6 +988,7 @@ core_target::xfer_partial (enum target_object object, const char *annex, >> return TARGET_XFER_E_IO; >> >> default: >> + fallthrough: >> return this->beneath ()->xfer_partial (object, annex, readbuf, >> writebuf, offset, len, >> xfered_len); > -- John Baldwin