From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by sourceware.org (Postfix) with ESMTPS id 35262385840F for ; Thu, 17 Mar 2022 16:06:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 35262385840F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f49.google.com with SMTP id t11so8027754wrm.5 for ; Thu, 17 Mar 2022 09:06:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=K6ALjF06IhKIm8+w7Zqcs/a8koVlbH0Apq6ys3V+cXo=; b=qKiCSScii6ElbQjEgji0rudSNNJwjShVDvx2n1j/wBLK+2OvX3421mLP4kl6SIa/7N J/jj0GHTHzmotpoutiavKFl+M3gq6iFBbPuvSTG8BHc7NsbTCcClGjdePNK+KEKL8TcF EWjf71RCPozgi9T3eF4DuEpKLuVmNSv2q9AfUQmhvKzyeSSD6gzz3Pz0WVpvWEvXxI5D /flK7wGhxxtK5CZQ6hRxBJXZD69R4I//dtnoX/MwR1Dap7cljaXbHH31ONoRdoSzaCk4 A5wQvcS9Yr55PbSlowRmUB0cCraGGxhBlsAsZRKY1pR9gX/+jRUb76/L9HMiduphHJZS R/FQ== X-Gm-Message-State: AOAM5327P6mjZ3cGfa0G/80Ozaymu8oCEJs/bPJCsHntQz6XEzzJ3O0u DJZHA0PvRhq55K3aP8bbIoaavOBWA1djbQ== X-Google-Smtp-Source: ABdhPJxt55Tkn/sOna+zPC+svAbzEIRKK1vX/Acq0Y/KlRu9H/qhGc90S3tUWxQeNurwHMaEr2fkeg== X-Received: by 2002:adf:dd0e:0:b0:1ed:d3c2:6f23 with SMTP id a14-20020adfdd0e000000b001edd3c26f23mr4911313wrm.277.1647533189072; Thu, 17 Mar 2022 09:06:29 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id n22-20020a05600c4f9600b0038c6ec42c38sm4228012wmq.6.2022.03.17.09.06.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 17 Mar 2022 09:06:27 -0700 (PDT) Message-ID: Date: Thu, 17 Mar 2022 16:06:26 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Subject: Re: [PATCH] Avoid harmful fall throughs in core_target::xfer_partial. Content-Language: en-US To: John Baldwin , gdb-patches@sourceware.org References: <20220316193604.89477-1-jhb@FreeBSD.org> From: Pedro Alves In-Reply-To: <20220316193604.89477-1-jhb@FreeBSD.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, 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:06:34 -0000 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. 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);