From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by sourceware.org (Postfix) with ESMTP id 5EDFE3858D34 for ; Thu, 2 Jul 2020 09:01:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5EDFE3858D34 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-43-FruEp4SrNkueIZkCBFEprw-1; Thu, 02 Jul 2020 05:01:02 -0400 X-MC-Unique: FruEp4SrNkueIZkCBFEprw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9449F185B39D for ; Thu, 2 Jul 2020 09:01:01 +0000 (UTC) Received: from calimero.vinschen.de (ovpn-112-158.ams2.redhat.com [10.36.112.158]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 676E010023A7 for ; Thu, 2 Jul 2020 09:01:01 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id 065C5A80705; Thu, 2 Jul 2020 11:01:00 +0200 (CEST) Date: Thu, 2 Jul 2020 11:00:59 +0200 From: Corinna Vinschen To: newlib@sourceware.org Subject: Re: [PATCH] pru: Fix memory corruption on syscall return Message-ID: <20200702090059.GR3499@calimero.vinschen.de> Reply-To: newlib@sourceware.org Mail-Followup-To: newlib@sourceware.org References: <20200603161422.18902-1-dimitar@dinux.eu> MIME-Version: 1.0 In-Reply-To: <20200603161422.18902-1-dimitar@dinux.eu> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-13.4 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_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Jul 2020 09:01:06 -0000 On Jun 3 19:14, Dimitar Dimitrov wrote: > In the initial code I missed one level of pointer indirection. Instead > of storing errno in impure_data, _impure_ptr was corrupted. > > Only simulator is impacted. Real targets have no OS and no syscalls. > > This resolves a bunch of stdio cases from the GCC testsuite: > FAIL->PASS: gcc.c-torture/execute/printf-2.c -O0 execution test > > Signed-off-by: Dimitar Dimitrov > --- > libgloss/pru/syscalls.S | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/libgloss/pru/syscalls.S b/libgloss/pru/syscalls.S > index 8ed7601a4..3ad0d9215 100644 > --- a/libgloss/pru/syscalls.S > +++ b/libgloss/pru/syscalls.S > @@ -42,6 +42,7 @@ __SC_ret: > /* Invert return code and store to errno (first int in _impure_ptr). */ > rsb r14, r14, 0 > ldi32 r1, _impure_ptr > + lbbo r1, r1, 0, 4 > sbbo r14, r1, 0, 4 > /* Return -1 (for both int32_t or int64_t). */ > fill r14, 8 > -- > 2.20.1 Pushed. Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat