Message ID | 0bd7df35b8c709a72d6f2a0900e60fa12727779e.1666192979.git.aburgess@redhat.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BCF14384D18F for <patchwork@sourceware.org>; Wed, 19 Oct 2022 15:25:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BCF14384D18F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1666193144; bh=NCgz7xQ5GlxL4lUCRpx14/zvTMRl0SyBfGfibEmCWDs=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=qd7WrSirlf7nMOz6qRkdMF3774NG9ZP6VRka5Ff7XZnIHo3GdjecbaQaR8t/BTA3h Di4Xn6VTaRfihOMgdtDDevw9Ybi3I/54lhWujcRiFxN9j4E2scFeJhuQ1O29M7qJ7y x+1TQy5igFvPXiZy/1dikuSrbvfbpDdbDtnnoG6o= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id B96BC3853560 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 15:25:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B96BC3853560 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-172-VnUPAFmPP0q8ukexT2didQ-1; Wed, 19 Oct 2022 11:25:01 -0400 X-MC-Unique: VnUPAFmPP0q8ukexT2didQ-1 Received: by mail-qv1-f70.google.com with SMTP id 71-20020a0c804d000000b004b2fb260447so10922093qva.10 for <gdb-patches@sourceware.org>; Wed, 19 Oct 2022 08:25:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NCgz7xQ5GlxL4lUCRpx14/zvTMRl0SyBfGfibEmCWDs=; b=TPkI5biuvbIRxCgsV3AEURs5Ymn6RoFuVoagBwu7iLpztnwzlJTOyHPF4XSZsRX67T oHbmJ0WcqROhoyV41pkZjgmX+PmvSkuAQ4JTfhGt6ooBHCUKySm21g1UOQ+Oxs77f1PJ UgSNTv21I/1hDzRRd+plpLg9b1m6IIDXcXaGmyw3VY2Ll68yvP3lpCARVAwWpfct/6Gr 4u++O/K/TeI7sIWqCRsqI5mg0z71jjofH17Fmw/BdsELYr2VP6rBAaphWx9rDoTQerE4 bFpOKuhBzfBiZocGxIIyb/l/fRxoGqHv0MQUvvaVmFr6viu6y6MYb2uS7qaqHwaQYpfB eFLw== X-Gm-Message-State: ACrzQf0iBAm9Q8CqFRzKmGZLuao06RmFmDXprXJs6HzTfRJlPH9pVPmC IP/wvpJhwvFt6Ew4f6zHXHayUwJ2/BYnX/BwGt1Jslc8wFb2t44Frlvly1VTgnK03M+m2NdAAtQ hVKUJ5Q2IBilU2UjdkuKj0osHhQzSXjwiopQtgXp50X/LS7XEl5CW7CGu6adtW0l6SpIyFMV3fg == X-Received: by 2002:a05:620a:4054:b0:6ec:5735:2e20 with SMTP id i20-20020a05620a405400b006ec57352e20mr5855043qko.321.1666193100906; Wed, 19 Oct 2022 08:25:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4o8VxbdpjmO0NbXs/tiuYsn9JLI2JqSqfOJlVnIS+gsHKHqRv9dMMyRkc1WnoR9LLRJgGB6g== X-Received: by 2002:a05:620a:4054:b0:6ec:5735:2e20 with SMTP id i20-20020a05620a405400b006ec57352e20mr5855025qko.321.1666193100589; Wed, 19 Oct 2022 08:25:00 -0700 (PDT) Received: from localhost ([31.111.84.238]) by smtp.gmail.com with ESMTPSA id cb23-20020a05622a1f9700b0039cc22a2c49sm4201072qtb.47.2022.10.19.08.25.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 08:25:00 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [PATCH 03/10] sim/ppc: initialize a memory buffer in all cases Date: Wed, 19 Oct 2022 16:24:42 +0100 Message-Id: <0bd7df35b8c709a72d6f2a0900e60fa12727779e.1666192979.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <cover.1666192979.git.aburgess@redhat.com> References: <cover.1666192979.git.aburgess@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Andrew Burgess via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Andrew Burgess <aburgess@redhat.com> Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
Building the sim/ tree with clang
|
|
Commit Message
Andrew Burgess
Oct. 19, 2022, 3:24 p.m. UTC
In the ppc simulator's do_fstat function, which provides the fstat call for the simulator, if the fstat is going to fail then we current write an uninitialized buffer into the inferior. In theory, I think this is fine, we also write the error status into the simulated target, so, given that the fstat has failed, the target shouldn't be relying on the buffer contents. However, writing an uninitialized buffer means we might leak simulator private data into the simulated target, which is probably a bad thing. Plus it probably makes life easier if something consistent, like all zeros, is written rather than random junk, that might look like a successful call. So, in this commit, I clear the stat buffer to zero before writing it into the simulated target, if the fstat call is not run (due to a bad file descriptor). Another option would be to just not write the buffer into the inferior (rather than zeroing it, and writing all zeros). This would solve the problem of copying simulator data into the target, but I think the all zeros will make debugging things in the simulator easier. --- sim/ppc/emul_netbsd.c | 2 ++ 1 file changed, 2 insertions(+)
Comments
On 19 Oct 2022 16:24, Andrew Burgess via Gdb-patches wrote: > --- a/sim/ppc/emul_netbsd.c > +++ b/sim/ppc/emul_netbsd.c > @@ -888,6 +888,8 @@ do_fstat(os_emul_data *emul, > status = fdbad (fd); > if (status == 0) > status = fstat(fd, &buf); > + else > + memset (&buf, 0, sizeof (buf)); i don't think this is perf critical, so simpler to do: struct statfs buf = {}; -mike
Mike Frysinger <vapier@gentoo.org> writes: > On 19 Oct 2022 16:24, Andrew Burgess via Gdb-patches wrote: >> --- a/sim/ppc/emul_netbsd.c >> +++ b/sim/ppc/emul_netbsd.c >> @@ -888,6 +888,8 @@ do_fstat(os_emul_data *emul, >> status = fdbad (fd); >> if (status == 0) >> status = fstat(fd, &buf); >> + else >> + memset (&buf, 0, sizeof (buf)); > > i don't think this is perf critical, so simpler to do: > struct statfs buf = {}; Pushed with the fix you suggest. Thanks, Andrew
diff --git a/sim/ppc/emul_netbsd.c b/sim/ppc/emul_netbsd.c index 322b584a3f1..f5fa8499bde 100644 --- a/sim/ppc/emul_netbsd.c +++ b/sim/ppc/emul_netbsd.c @@ -888,6 +888,8 @@ do_fstat(os_emul_data *emul, status = fdbad (fd); if (status == 0) status = fstat(fd, &buf); + else + memset (&buf, 0, sizeof (buf)); emul_write_status(processor, status, errno); write_stat(stat_buf_addr, buf, processor, cia); }