Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp190317imu; Wed, 21 Nov 2018 17:56:16 -0800 (PST) X-Google-Smtp-Source: AFSGD/WdOnXTLCx9Yi14etsO8RJqU1q5ewvvZi5EP2VPWYguuzn91qRWE4Xr/dYXgW0KLKPoOVmb X-Received: by 2002:a63:c42:: with SMTP id 2mr8231511pgm.372.1542851776530; Wed, 21 Nov 2018 17:56:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542851776; cv=none; d=google.com; s=arc-20160816; b=vmgCXThdpcuyoojOA5Aac8Bnq+Fg0LAZB49RtoeF1lsRCaZ1a+O0bJScyQEF0oYmGr i9cg949s02LC/CDKUG6D/sXxCsb7ww5pVuFVFYddeNR9K6tg721EGr1KSbRW6HLTnQn6 WGh/gO75q64cEGtDZfFP7VoO/L9NJI8pdy+vwYRe4Ff6jEHT+DAstD1kNjCaQ0XsP4SO 25wJ0gWn4D6KwOK6lzD30RhDCj5H3GCsmhjiJE8nUIS7ipWxSbFJGFXApRtQj5qjxeIk 3crpxnrMBERVJJNtA6v5nJdFB+Vx3jF+KmkaOSYH3nHSjObzM9l384ifFrc13C79m3/d Eb6g== 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=bc+HtSg5dn3QxUa5MgvPZevVZA64vqMrWGLogCLf5Fw=; b=n9ARvXlFmGVyLvFkaNbKWPj80QfoUCYwTNjxhzNHU6uYz4Mhl8TnjafcMrokrmIG/j wOnrOTWxkj1t5/LGNLvMlOcoiJhP7XzoSrh/Lnda1vzAUtKdqpyzfXbjTvLLt3Hp/NEZ YNEpMR5C6In05Yhlnt/7Kn3rAeRYJ9pJNPJmiKzVlfz2Xdl0HXEOMBLjfkkB8rWhu5kt MaKkIZwwmVIAY2oHa+U/ikm1sSogHuWw1rxfJz3mUUW3186baesRjubafDFgSPd3ZLSW DV+CpSnsM/WDTiuEldLwF1OYHuZXPnvMvN8fo5gvK82rENLCGORLskw+N/z7wcn6Wufs ekww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XwLqIzhp; 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 e89si9286082plb.401.2018.11.21.17.56.01; Wed, 21 Nov 2018 17:56:16 -0800 (PST) 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=XwLqIzhp; 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 S2389100AbeKVFrX (ORCPT + 99 others); Thu, 22 Nov 2018 00:47:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:42834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731945AbeKVFrW (ORCPT ); Thu, 22 Nov 2018 00:47:22 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 A1E5521527; Wed, 21 Nov 2018 19:11:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542827509; bh=dansAAk+dFB3MsLjU6iv8+lsiw9BVfXN2c7qMZafAoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XwLqIzhphzA3JW7SIoqADS2PHH6ZnkubmtcgdEayq24JKpt49eAKB55y2jfYjMiFE urZvkwEp0QM+aRi1GXCJDxyREUYBkZX86G+i/Q8vmZYwlwNBKSD8nfUvVEEP6FrKsO AAw1mH5sAPdDbZl7pnKSutlStk4JKmmsenuVMQx8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Russell King , "David A. Long" Subject: [PATCH 4.9 58/59] ARM: spectre-v1: use get_user() for __get_user() Date: Wed, 21 Nov 2018 20:07:13 +0100 Message-Id: <20181121183510.594709278@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181121183508.262873520@linuxfoundation.org> References: <20181121183508.262873520@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Russell King Commit b1cd0a14806321721aae45f5446ed83a3647c914 upstream. Fixing __get_user() for spectre variant 1 is not sane: we would have to add address space bounds checking in order to validate that the location should be accessed, and then zero the address if found to be invalid. Since __get_user() is supposed to avoid the bounds check, and this is exactly what get_user() does, there's no point having two different implementations that are doing the same thing. So, when the Spectre workarounds are required, make __get_user() an alias of get_user(). Acked-by: Mark Rutland Signed-off-by: Russell King Signed-off-by: David A. Long Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/uaccess.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -280,6 +280,16 @@ static inline void set_fs(mm_segment_t f #define user_addr_max() \ (segment_eq(get_fs(), KERNEL_DS) ? ~0UL : get_fs()) +#ifdef CONFIG_CPU_SPECTRE +/* + * When mitigating Spectre variant 1, it is not worth fixing the non- + * verifying accessors, because we need to add verification of the + * address space there. Force these to use the standard get_user() + * version instead. + */ +#define __get_user(x, ptr) get_user(x, ptr) +#else + /* * The "__xxx" versions of the user access functions do not verify the * address space - it must have been done previously with a separate @@ -296,12 +306,6 @@ static inline void set_fs(mm_segment_t f __gu_err; \ }) -#define __get_user_error(x, ptr, err) \ -({ \ - __get_user_err((x), (ptr), err); \ - (void) 0; \ -}) - #define __get_user_err(x, ptr, err) \ do { \ unsigned long __gu_addr = (unsigned long)(ptr); \ @@ -361,6 +365,7 @@ do { \ #define __get_user_asm_word(x, addr, err) \ __get_user_asm(x, addr, err, ldr) +#endif #define __put_user_switch(x, ptr, __err, __fn) \