From patchwork Thu Aug 12 16:58:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 44654 Return-Path: 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 3FF9F39540CD for ; Thu, 12 Aug 2021 16:59:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3FF9F39540CD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1628787579; bh=PktZZSI7DjJjxNYRHstZfJZWQoi3vrfJSHZIqofHWhE=; h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=D1j6xJv23MWYAoz44n6UA2wRrWWbZeo6rAn3VeAdHZjDl3JLePH62ZwTCg6DxQt4o AHX20GFny0Wy6SylxSHcswDRQNOTXvUUsE+R6MPRloHRq3Bh6yxnNLYZsQ3bCwiIWi VQKTJ0DrsKOyMxnJ5SK3s6ESb0HjyuCIo4uQ851M= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mengyan1223.wang (mengyan1223.wang [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id BEBF8383D023 for ; Thu, 12 Aug 2021 16:58:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BEBF8383D023 Received: from [IPv6:240e:35a:103f:100:dc73:854d:832e:3] (unknown [IPv6:240e:35a:103f:100:dc73:854d:832e:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id DE828659BD for ; Thu, 12 Aug 2021 12:58:47 -0400 (EDT) Message-ID: <07cf2ef7f47070979089f880d91a0369c4efa978.camel@mengyan1223.wang> Subject: [PATCH] mips: align stack in clone [BZ #28223] To: libc-alpha@sourceware.org Date: Fri, 13 Aug 2021 00:58:31 +0800 User-Agent: Evolution 3.40.3 MIME-Version: 1.0 X-Spam-Status: No, score=-3039.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, SPF_HELO_PASS, SPF_PASS, TXREP 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Xi Ruoyao via Libc-alpha From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The MIPS O32 ABI requires 4 byte aligned stack, and the MIPS N64 and N32 ABI require 8 byte aligned stack. Previously if the caller passed an unaligned stack to clone the the child misbehaved. Fixes bug 28223. --- sysdeps/unix/sysv/linux/mips/clone.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysdeps/unix/sysv/linux/mips/clone.S b/sysdeps/unix/sysv/linux/mips/clone.S index 71d9dba8bd..9e5826aeba 100644 --- a/sysdeps/unix/sysv/linux/mips/clone.S +++ b/sysdeps/unix/sysv/linux/mips/clone.S @@ -55,6 +55,13 @@ NESTED(__clone,4*SZREG,sp) .set at #endif + /* Align stack to 4/8 bytes per the ABI */ +#if _MIPS_SIM == _ABIO32 + li t0,-4 +#else + li t0,-8 +#endif + and a1,a1,t0 /* Sanity check arguments. */ li v0,EINVAL