From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2C89C5B57D for ; Tue, 2 Jul 2019 08:04:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82C3721852 for ; Tue, 2 Jul 2019 08:04:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054672; bh=emvwUdVW0+nZbV6MltQoEQlRpt9QAeRJY2O4pV29Klw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=dnt3OG0uOI94RR3p2DiRSKUnzOU/SyY+tfCmVSKW9ba/Ts6EjMTmyISBvXRDn7vlO Xk0ecX61WMk67xLprtBk+Mih7xzSEvZVS49lisXS/V1uxaunhAI176xXs4HkyibEYj F9HVu78xTT2ETrjvzak+8r442PWBJBr4tE4rUdiM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727743AbfGBIEb (ORCPT ); Tue, 2 Jul 2019 04:04:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:49938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727726AbfGBIE2 (ORCPT ); Tue, 2 Jul 2019 04:04:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B7C6A20659; Tue, 2 Jul 2019 08:04:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054668; bh=emvwUdVW0+nZbV6MltQoEQlRpt9QAeRJY2O4pV29Klw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eQNgn5IeUXjFIM/aUxnKj4cU4jMlZtGVUB+NTxtdC9RS8NOj7z23+wmJBAOb8771R 1/IwbOHoz0EaNmF86cNFfwkrDLx2twgajJqa4Thr24NWdUYGciwTri29xuGoXp3znJ O2wYJBzcCcxNOuRLtqpBRVLHqOHlgHF6kO8SlWrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon Subject: [PATCH 5.1 50/55] arm64: futex: Avoid copying out uninitialised stack in failed cmpxchg() Date: Tue, 2 Jul 2019 10:01:58 +0200 Message-Id: <20190702080126.687857009@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.103022729@linuxfoundation.org> References: <20190702080124.103022729@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon commit 8e4e0ac02b449297b86498ac24db5786ddd9f647 upstream. Returning an error code from futex_atomic_cmpxchg_inatomic() indicates that the caller should not make any use of *uval, and should instead act upon on the value of the error code. Although this is implemented correctly in our futex code, we needlessly copy uninitialised stack to *uval in the error case, which can easily be avoided. Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/futex.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/arch/arm64/include/asm/futex.h +++ b/arch/arm64/include/asm/futex.h @@ -134,7 +134,9 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, : "memory"); uaccess_disable(); - *uval = val; + if (!ret) + *uval = val; + return ret; }