Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3053680ybi; Tue, 2 Jul 2019 01:13:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjhosw+WEbxuDDTr3MABIb1fg1CPq9+OZfpZ47aEk/nlcZdgjdHViFMpiPsUYi4B5CxAYx X-Received: by 2002:a63:231c:: with SMTP id j28mr28818792pgj.430.1562055193738; Tue, 02 Jul 2019 01:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055193; cv=none; d=google.com; s=arc-20160816; b=nM6csdWvrRxHTntHXLgOTYjo4NO0Rl0au12w3V4EtAvzSojKkxajzLRMPP6+Y01XZZ 8kvngzVHuYiV3h1Gr5qCKHNVN+b0tjeg8SX+tVjH9YKepINv1hQeg9f7fvNZYUNZYnlY BqXqVJUrEvbq8Mk+UC4K9LVLY8XfKG6qjHZHHAIjMBwgxfP6hRo8GeR4Ld//lInTbSDS ddvRRz6JUiIodoCTVr9w5v1SBJ17Gd5ib9jCqXsPBHtQ9NFm2TuinBOceYJY3K/fXzvP BHpdlnPRA8P38eCh6gRg2+6rlQrLZIkdnQU6SKMwVWcl07DPPbf6rk2b/l0JevZ0lUHp 611A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=smwADwmnPQHrDMAIex54M14jdc9d+yYb03vjNtzVKkE=; b=FQpZGQQlynSwf08uiKu69wehQAI030i+so8D2rDXdq3ChKnGQTnUPa1Ih9f7v2JwFJ pznVggkKDBd7GQAdfUJRkiFBPGjQh2lbHLW+vn3oDJHU3XAVNwr9OfI1RFHrq0xpj69y 0dCZyiE7/dps1nub6SEssHYe9qltFpDfZcVy1539zXT+NMbq+AH4Bkz9oVUQ7zYpjNfc /IpwqGG7j314tehKjWOGn6igIxLiEdc/ZRfrC1k3Ncy1kLvqApMtoPTrH/quM0YLlQe5 1aLhNP5qMqa1GCzm++xqr51bF/2dGybcJW0RjD5benGPzpUD2ACxuAiULhJHKyAbniPZ Ku2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fcgsHnlB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s33si10403994pgk.112.2019.07.02.01.12.59; Tue, 02 Jul 2019 01:13:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fcgsHnlB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728665AbfGBIK2 (ORCPT + 99 others); Tue, 2 Jul 2019 04:10:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:58744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728391AbfGBIKW (ORCPT ); Tue, 2 Jul 2019 04:10:22 -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 B63F32189F; Tue, 2 Jul 2019 08:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562055021; bh=emvwUdVW0+nZbV6MltQoEQlRpt9QAeRJY2O4pV29Klw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fcgsHnlBvXuitvt+t7n/zi+wsp2Qw0tKEX9vQYpOwqdrueQvaEcs8wevE+DIJSouX aGYEyvlBCkCWNO2mKU1Na7DhKgpjNeG/Y7WpTR6DCKtKodmCpuyADoqOgb4t2Uest9 EqmO9qEKErEC/5xf9U0egTCpKw9ScO8iuxUi6EZI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon Subject: [PATCH 4.14 40/43] arm64: futex: Avoid copying out uninitialised stack in failed cmpxchg() Date: Tue, 2 Jul 2019 10:02:20 +0200 Message-Id: <20190702080125.983132605@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080123.904399496@linuxfoundation.org> References: <20190702080123.904399496@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; }