From patchwork Tue Jul 2 08:02:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 168286 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3935068ilk; Tue, 2 Jul 2019 01:08:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNry2Abgny6YMFp0MdYfDLebkz3joEKT4l3li5AXq4eOdyII2meEZV0xkjGrKxQ+F4Hbhx X-Received: by 2002:a63:6ec1:: with SMTP id j184mr29483377pgc.225.1562054919036; Tue, 02 Jul 2019 01:08:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562054919; cv=none; d=google.com; s=arc-20160816; b=xtU/5Q3eqGmmvQINcz8sCVjBCmHcnTOgGAWSTP7uao08oB5s9lalM8DTs3T+9MXxjS WHpcoK3cwQKMg6393enHAyQ1cfuL9Qu87iTZkemCU1IQsXUPBuUDdlTy+EUDJyxl4DUD FUOCxnE8qMHBns8IsA+A85XXLTNTABpkr02SnyKcef2sCqqLKo+COq0No9X3dEXiq0iQ 4eVcRiY42Rq6REGErBPabRCbuJbKvkZKsjprXFesjJOeXNU+DLHFu23/fKuWOl56WqNr IYNUdeYjyzAJIa3ZI6+MbwMYPyexOipI4LbTxogy0qatH6Ig+/mUPu6GaMRPy4iC9C/f 146g== 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=IwbgG2Z2Gzm1AHuxLa09Kg7r4jQtbzgY5WwxIWss7Q6rMIK83GIKvsGPMX8e57NuNU Sxy76M1NcoNO8bTTtMkfH9Az3cUSAcOj/tsCcCSosKoItZhhCiVn93V+C7eu0WfCpE9J Zv8kW1bM9rHs+/uSVkxtGKXbKlYBpSt+7AYOxQbtApR7qvqqV+a7mw0k89AeXG35Zhji V3J31yOOOVHD4/Trmz7Pw/46pmtt6rbxskv3styI9hezzkDQavTkEm3bO6jTAbRriFXo xOKXqjjRYSJB8ulNt4Wege6wOUpPFbW+wrRCDrXCsb4v2QnmqegSt4OVHjvQwfXfaTky /Ocw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JUWmo5WZ; 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 r204si13316980pgr.243.2019.07.02.01.08.38; Tue, 02 Jul 2019 01:08:39 -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=JUWmo5WZ; 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 S1728105AbfGBIIh (ORCPT + 30 others); Tue, 2 Jul 2019 04:08:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:56164 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728456AbfGBIIe (ORCPT ); Tue, 2 Jul 2019 04:08:34 -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 7E3132184C; Tue, 2 Jul 2019 08:08:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054914; bh=emvwUdVW0+nZbV6MltQoEQlRpt9QAeRJY2O4pV29Klw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JUWmo5WZlxN5laMKAJhO7df4PxKMDv6AJHxFjbelBhJ/1QU+UOJOdDCDXBMYjCIAR em3JwSJ8VXKCbQDqT7tbi1Pi5xktKu0Veg6GfeaJqDR/lGICjeRfuT/x7KFJG00w18 CVNRCIWpB+B3cfYnVr7iW1h6ZTB1PoE4x4jECNXk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon Subject: [PATCH 4.19 68/72] arm64: futex: Avoid copying out uninitialised stack in failed cmpxchg() Date: Tue, 2 Jul 2019 10:02:09 +0200 Message-Id: <20190702080128.167642047@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 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; } From patchwork Tue Jul 2 08:02:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 168287 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3935177ilk; Tue, 2 Jul 2019 01:08:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwAKp8P1wyzEVbkscLoyihb/5pd93mvZ7IKeMVVyrV/i+azTytgyRsehJ2PUm48El7vqdd X-Received: by 2002:a17:90a:22aa:: with SMTP id s39mr4085022pjc.39.1562054926325; Tue, 02 Jul 2019 01:08:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562054926; cv=none; d=google.com; s=arc-20160816; b=peu84+cYIS3jjbnkVRrU9JaBi6SzLaszouiqZaHPc/SzRug5naD1AgqbqFuqZ8SoVm Qwyg7ToxVh/3kMgqP21TRTCtJvvI2Ra5FYipLC1gx4aPUjplvWD5S1lyzhQ5aGkj2esB FW+0C/tHvhVGLPERy6wm2d3mryoF5vO6U1i2Fi3U0b5x2BauXNK5oTk/97CFYToTsltM VfQNFfHDOVnVbfCXbw9H+Yedq60CPceLYtwE8+vuFI8kLFIs5UeB94qGEKiSl7yqEjIN oDShVV1iP2tEr7qfL3be0i4W5CTVOjvTdXCmssyf4+uhJ4il4e5OJFH4q2cQ6Y/2lNM6 qeoA== 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=CdzXQJ8PEODUb1iqox2bPlD4rnSKi33/blIbPWkxC4KvZZJTy9+EaPeuHRYk7YBurr TF/iSJOcgAGG8tohSgopWzno+6WULReVyWFkECz+IsPqK61gz7ktTBwm2+D0OdZnLlkG YqdB31O0m5OoOCYt37cajYkXaKFr1oY2KL9nuGyNui1E2lOwh+Oi4FC1ArdPHXj90BL0 VEsYtvFaVLSLekVKbXgbsgRG3cRuHQIUcElOPtccETIq1YD6rVeA92D9fQR5n2rU4r7C E44/Zu5+W2hvWzVN+me1jpH9l5OK/8dtSuejNj7N4fFEFBJCHzxa7zc/tWfLfsgwukwQ p5rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q3+yXiiP; 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 q187si11994333pga.220.2019.07.02.01.08.45; Tue, 02 Jul 2019 01:08:46 -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=q3+yXiiP; 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 S1728504AbfGBIIo (ORCPT + 30 others); Tue, 2 Jul 2019 04:08:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:56292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728490AbfGBIIj (ORCPT ); Tue, 2 Jul 2019 04:08:39 -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 D042521855; Tue, 2 Jul 2019 08:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562054919; bh=FHZuVNPHrPEskjr4ytkC96O85qWn+vClIozAy1WdJBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3+yXiiPd88E2WpfMYtBYq0+faZNMO9rSzJaX8bKE8inTeiwsSsuyQGB0WrLBlMlk UIG7jRfA8j7LH39dQ1oAGGNrhgrjkqIK5NaTr2n0zAdedn9yFAXY/2IU+gtGzrfKKH d7Z2TJMmkTFHfMFkFtFfnjcrjyaAK/dpyq2uV8w4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon Subject: [PATCH 4.19 70/72] futex: Update comments and docs about return values of arch futex code Date: Tue, 2 Jul 2019 10:02:11 +0200 Message-Id: <20190702080128.275446262@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190702080124.564652899@linuxfoundation.org> References: <20190702080124.564652899@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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,