From patchwork Tue Jul 2 08:02:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 168288 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3936794ilk; Tue, 2 Jul 2019 01:10:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyo4vQ8juYUr3SJQht1sty2nIlpPfLLs34XZmaVXXatBgAHujsMmpFCZjGGbEnRYP+iOlw6 X-Received: by 2002:a63:3f84:: with SMTP id m126mr28067888pga.213.1562055028206; Tue, 02 Jul 2019 01:10:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055028; cv=none; d=google.com; s=arc-20160816; b=uIhmAkeq3S2tZGY2kqLqOs0R4/BvbxDf4gfR9UIA1aPc922rqlyZiyOJ54cgmW82uY xaue0a9/JQLtBgULCec4VxFiGRXc8ach4rJaXNfS8btnnLUdN3HjVXBvuvc2m2Q8lxmP V3AcqAfMzZ6I+mvZblfUo5xgVFk/vGXfIoRhuWnR1lpeZTyXzwOhJC6dylYsbiFc2xvs dPnl3Qa7vKQT8hEMFiKiBIDskXXAaX6PPNmdXHkabHGm+JUsmvM2lT2t3JOIttQoHNA0 AmMpFdJAVfeDbexigXUFv4BFRt6KmqZSX4CoLztginbSrTbRCm34sEuHZ18c94chcQ5p slHg== 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=W2XrxLqHJ4/eqUwHG5Bc/Sv5VO+YZFyraeiVvYRSiw6rAnw9RTaZ/LdKAIRA3cwZIy Ai0ZUn7FN4eTgyv3fNLFBIM3iYsUwVpLQ/FZmjDZpP1Kn3Gj/Njhl1r+d96JTvY9iETr 1JMYd469KaAbyl8WJoGBXDHjP4vYjf54f72s+9c/vAHl+ZkVe5U4y+o72lDzWsVzDnLP jasM7GILfO4RPKjsHpNVTDl/QF7KXrbWinaiEGiPT6W+GNoU+cMGV6yLqSO0FK3RtDfb UFCAB2o5bTJSJrh8PZfe31R/T0NfkHcBVQRQF1tJv5T3ElaZDhvlOM05keNy3NED9USd m2/Q== 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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 w12si12383132pld.301.2019.07.02.01.10.27; Tue, 02 Jul 2019 01:10:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728383AbfGBIK1 (ORCPT + 14 others); Tue, 2 Jul 2019 04:10:27 -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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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; } From patchwork Tue Jul 2 08:02:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 168290 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3937760ilk; Tue, 2 Jul 2019 01:11:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOZreaUCvqUymsgkCM0ZnnFFqINGl9sfIv5jnDk8Y1GJYB3avNnf6rusth0ZKF7x/FBxQB X-Received: by 2002:a17:902:aa95:: with SMTP id d21mr32546297plr.185.1562055092933; Tue, 02 Jul 2019 01:11:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562055092; cv=none; d=google.com; s=arc-20160816; b=nIkX1292GbqlT+Dbla1EYESTG3SesTyd2OhyFmcvxo7/vYGn/FrwTW+JAPFUD43DZS QeZszIDv60pXYT6nrL6ktWPJRFpcyWbGGX2VtV++ZH/QDyodGaPqhmT5/V85joLem4Ra aNmMzZVAnB/2YMS2nI2M2YzeXZLrES/TJkAYvcq5WpP8RdCi5IVq0I0DigvuBIzLMEJC maY0x+5m8W1rPavk6tIN0OGAXKJ87bv8Q2J46zv0O3HWQY9NiJaapRxnGLjUUvPkKOJZ t1e8J4wwinMKICUpiw3Y3PZHm0Wvqjhac8qyzPx51JxttS/hdeNXkbcm0nyzdMFlHqrT Eu1A== 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=MgKBYedVmlJkYlgCCJHST89UjJ2AR1SUH+TA30bu/qQ=; b=gdFqtc20NJsg4IdvfxkZZp6+t2eldFE1seMzdC7dFOhDj0waY/LXT8XgOeJZswwnYK 6O3LIfPpB/vPL6XfYZvayRIHKnjWVPl8j0eF7XgWwMtmsUonbBeM3TIxsYpGpK6cs1B5 +Ovx1mQN6H9RDtCl5IqtGvbXluKNk6OjPwFX//NNeegfMkVUjagw8HeLqxo+Jm+dOh9V kIKcfvli2zUrUbCwb9fbbW+qO3tWBlploaTIPdwsh14zGXpdFCtbu9bIMqdjQ2FZEXJK iL6QulBqEJnhI7IHUgawgg6g8UkuFh1Ob7Hz8bWs5Owqohfl/PXv0v4kUmUzbpQ4Vv8H I7bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sq23KUQZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 e12si11959874plt.411.2019.07.02.01.11.32; Tue, 02 Jul 2019 01:11:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=sq23KUQZ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727846AbfGBIL1 (ORCPT + 14 others); Tue, 2 Jul 2019 04:11:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:58890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728654AbfGBIK1 (ORCPT ); Tue, 2 Jul 2019 04:10:27 -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 DB6792184B; Tue, 2 Jul 2019 08:10:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562055027; bh=FHZuVNPHrPEskjr4ytkC96O85qWn+vClIozAy1WdJBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sq23KUQZLGtbBD1etvUvfcTPmkzz6vNv4e7WpGmm0MXawGlkKDxvlIv9wUVthTERy tBwDrbpqYcFP8LfXGC92QuWEh7onEwIMR5jBOY3OsxfpokWOY/NiAgmUSuPCMx4KJ+ DhCG1499HeMEc+sCkXDbm6REzQZyus+nCZOk+de0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon Subject: [PATCH 4.14 42/43] futex: Update comments and docs about return values of arch futex code Date: Tue, 2 Jul 2019 10:02:22 +0200 Message-Id: <20190702080126.094515764@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 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Will Deacon commit 427503519739e779c0db8afe876c1b33f3ac60ae upstream. The architecture implementations of 'arch_futex_atomic_op_inuser()' and 'futex_atomic_cmpxchg_inatomic()' are permitted to return only -EFAULT, -EAGAIN or -ENOSYS in the case of failure. Update the comments in the asm-generic/ implementation and also a stray reference in the robust futex documentation. Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- Documentation/robust-futexes.txt | 3 +-- include/asm-generic/futex.h | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) --- a/Documentation/robust-futexes.txt +++ b/Documentation/robust-futexes.txt @@ -218,5 +218,4 @@ All other architectures should build jus the new syscalls yet. Architectures need to implement the new futex_atomic_cmpxchg_inatomic() -inline function before writing up the syscalls (that function returns --ENOSYS right now). +inline function before writing up the syscalls. --- a/include/asm-generic/futex.h +++ b/include/asm-generic/futex.h @@ -23,7 +23,9 @@ * * Return: * 0 - On success - * <0 - On error + * -EFAULT - User access resulted in a page fault + * -EAGAIN - Atomic operation was unable to complete due to contention + * -ENOSYS - Operation not supported */ static inline int arch_futex_atomic_op_inuser(int op, u32 oparg, int *oval, u32 __user *uaddr) @@ -85,7 +87,9 @@ out_pagefault_enable: * * Return: * 0 - On success - * <0 - On error + * -EFAULT - User access resulted in a page fault + * -EAGAIN - Atomic operation was unable to complete due to contention + * -ENOSYS - Function not implemented (only if !HAVE_FUTEX_CMPXCHG) */ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,