From patchwork Thu Aug 1 08:16:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 170333 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp5086282ile; Thu, 1 Aug 2019 01:20:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz8Boi/cW6oaP+10P11ULrdOukc26l0Z2jqqyZbKsBOCPm0pyLKiU9itsy2cPlmZDzTb8/t X-Received: by 2002:a63:381d:: with SMTP id f29mr120513935pga.101.1564647645590; Thu, 01 Aug 2019 01:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564647645; cv=none; d=google.com; s=arc-20160816; b=EODS98OCnS9d8y4aIoB88K25zC8+VSj86PKuMY3MZ2PMrlyDHcj3s1x08zCk/B0R5d 0FHSdgbhLJ3OUJrAxr8Rntt0aHqKZ+XR+UJMuNVdoTb7w1FjMnWpeoP8DdVQw4UO75IV ERM38W+1KoNztd10ZXh/zHaIhdPlO0u7Kb4gHxJnlwI1j+ygyOjd8PoymIco6jq9CkLV p8aV7+iwJa/RLMYgyhKUvXoNDbxnfxkqCVqoTY8uZ5fE0cuEREV2kzOwMxCD5WbX/tIF YPRo3JbsVgnO6DIAcsO6S5n4fesNtaOsko6NT9kkirKqaij1c8ZJmxgZ1DeTXY0y0eau oaDw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=38pdn6yMPIMVV02QHWSD6x84Nqpn4d6LkQlpQyJb38o=; b=pPu2sMDekswnhIJj6ziD84u6jGW5VPIauAzt1yG9l0K1K41tVaZdQBqHCu0mXVxs4F f8EPJ4vc7Q5iPd7eMf6mTPl6j/xVq4rgQG82YMRZVT4pZYpjRU3+Bv1MIjGdWEHNRYBu VfPd6rt5ITPuqy5DoWeymVoLxap9ZJLjdBbfURcbJZCZaK9ESN0DZhHpPvuZVC0E1Z52 dMdlYeJ0g/Fy76PSDPP79ZzMv0S6PhiQIBfhccMPC2bCpx0zG2wCZInXoCsGKFdeLPHm 238RRt+Mxu3/jfFEioic33GWQ72pfoEqPG+T/JWpQ//sPBM3jMSaTZmypMxX8e5qskl+ I0tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hpj8rFpq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v63si6543334pgd.111.2019.08.01.01.20.45; Thu, 01 Aug 2019 01:20:45 -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=@linaro.org header.s=google header.b=hpj8rFpq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729760AbfHAIUo (ORCPT + 14 others); Thu, 1 Aug 2019 04:20:44 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35221 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729672AbfHAIUo (ORCPT ); Thu, 1 Aug 2019 04:20:44 -0400 Received: by mail-pl1-f194.google.com with SMTP id w24so31862393plp.2 for ; Thu, 01 Aug 2019 01:20:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=38pdn6yMPIMVV02QHWSD6x84Nqpn4d6LkQlpQyJb38o=; b=hpj8rFpqrv5qQhzotiE9gMdgzeeBBY56JsYcX7mov2k4sLQED6mYGWck9/YlmIsNte CvgNOeTzEU/dOYJodtSCB/QqdhAWuKaWfHbSDifhT7uswu3+TXhLyYcJMnYSklDo2R65 naU69OUI9lfGVslVSxJiiwfCNGn62aCu3lwlJIh7Tf55NYlFiUfpB+YQzce5TrXsjSLr q74/ypxEdtW3UDTY+0ssOk3V4RqaK1kmHYGv+j9E0+masU4wpX5nCLSroLSz1wwvgmZt PJaWq6BASd5p7zAoOmB4CddaIgIFG2/7658BQH6TXT/Y8J+l1bk9aXHhozn7zAhQmTsX swMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=38pdn6yMPIMVV02QHWSD6x84Nqpn4d6LkQlpQyJb38o=; b=X341xygyN0299gbw6v3YP8P+SiGKL9s2lMPAv9W/QhU2oZ3yTX90h9vzIz82u0Q7xa AXPKLaa1fh+UtweUpPqNt4lJtBBIzQLLhvA0Bf9YZ1ojDyKUcST5Jciq0oQmNrw4AH6O 3rS5CecaQzEdBbOf0NJq2Aj7QmE2Thq5+L+jAS3u1c/O6twwzBzVzHV5yTGcvYwxz/mw A/D0Ts2RnE3KVkxhndcchXmh+8WDDG8RC6oyVgkyeaie6OQn/2mcg0SUUPsN6hADLbrX ZaQrCm8gzD6KIaDIYq5cUK/fYlx305kB9H4jtsu52o/GRXje3l5SvEzbe6f41tCuqhyk Au8w== X-Gm-Message-State: APjAAAXG48P+7opvEVtJpz3RYVVaVkYCOTdK66zA6iqwRqapyoEZJ9QQ W46T5gzWGGSbVS3SIz8PQYt9DZzwYdY= X-Received: by 2002:a17:902:2a69:: with SMTP id i96mr123097817plb.108.1564647643267; Thu, 01 Aug 2019 01:20:43 -0700 (PDT) Received: from localhost ([122.172.28.117]) by smtp.gmail.com with ESMTPSA id t7sm67895102pfh.101.2019.08.01.01.20.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2019 01:20:42 -0700 (PDT) From: Viresh Kumar To: stable@vger.kernel.org Cc: Viresh Kumar , Julien Thierry , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Mark Rutland , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com, guohanjun@huawei.com Subject: [PATCH ARM32 v4.4 V2 26/47] ARM: spectre-v1: use get_user() for __get_user() Date: Thu, 1 Aug 2019 13:46:10 +0530 Message-Id: <092598d625ced1af31bac019a567319e189cb1ea.1564646727.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 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: Viresh Kumar --- arch/arm/include/asm/uaccess.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) -- 2.21.0.rc0.269.g1a574e7a288b diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 968b50063431..ecd159b45f12 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -314,6 +314,15 @@ static inline void set_fs(mm_segment_t fs) #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 @@ -330,12 +339,6 @@ static inline void set_fs(mm_segment_t fs) __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); \ @@ -395,6 +398,7 @@ do { \ #define __get_user_asm_word(x, addr, err) \ __get_user_asm(x, addr, err, ldr) +#endif #define __put_user(x, ptr) \ ({ \