From patchwork Mon Oct 15 15:32:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 148873 Delivered-To: patches@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3934145lji; Mon, 15 Oct 2018 08:32:46 -0700 (PDT) X-Received: by 2002:aed:22e1:: with SMTP id q30-v6mr17087241qtc.145.1539617565923; Mon, 15 Oct 2018 08:32:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617565; cv=none; d=google.com; s=arc-20160816; b=QR0LWb2rO3Xc82gvZ4mybZTFblrxReHv/9CMBGvtwa/GsnHNaHB4+M708mSojUf2n5 TPHfj4apTxH1vtHFKW4hx6a7K/+geHT5LHP2vXNzboKdIhIAMkzvjUal069Axnkd70t/ w8V8/GUSneV510fspfT38e6UCz9ApDQ/GNOx5hCO2ZojRb6ZYdY6fb6/maz56RMWt7jz MCrwY9Zx5V7Gx1oOkP/VNDVoyI+6zMRyFFAWujGl3ixqhVG3ucQxbucR3G+kgqa92ntx vWGvV46YQoGPP+Z1nnJQZr5fhlYHGMwxFVaABqVBO0dYtggS32MRFgri8pKyIIPq4/hy Sa8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VHHUxUa/5XuUHKRpfF7BKbpSDxY0tH8ku5ZXmftxiNk=; b=Ecu2zxQcWes1pQPQP5X5mEfDLSfSZ9jYlT6Ko8PPCzBS0+fIgKasyFNSYrfFPZ25zC /3MuB7PaZ85EI/ldtSwPEa3lkfWKUKyrkwWnAK3mosHNv8D/TUKeQXS8yZL/pdCnPGaP USJfHMhEjn8ZeTQnEQK7AC1n+BtxQR0yKB9BeetAu61nIYALd/vSIW20JaEmOZX7c++9 Wh5AbWeHh4K8Ka4SfVaZDJg/yuJB+ZxhouhRnY3RIy5GnFgMIZo6xyt1NiriQ9TRaCVE AHRzNC5QjFX/2VzCD8RHBXIjdbnlI9CT4AXptlR66qGQKhT9XaJlGXQFFI7k2LmXkRcV AHew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMShWdG+; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id p15-v6sor6329834qkh.70.2018.10.15.08.32.45 for (Google Transport Security); Mon, 15 Oct 2018 08:32:45 -0700 (PDT) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PMShWdG+; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=dave.long@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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; bh=VHHUxUa/5XuUHKRpfF7BKbpSDxY0tH8ku5ZXmftxiNk=; b=PMShWdG+7ZBhMmM8eGXLEhmcmoKs1aigCQn8nwzopjaCyyGQ1k3T8wYY3TZilRt5P7 GeErZdQRqLT5fSHDt05WrEJ32Mw2Ns+y2z+INzc++Kaq3LSHTmh52kIXR7xHz3tLsdTV 1fjGXaZvzEmMmuOLg8XN/IgHmbq7RPFlWcwLw= 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; bh=VHHUxUa/5XuUHKRpfF7BKbpSDxY0tH8ku5ZXmftxiNk=; b=dabyxBNGF+o8BcmxwlvF+ojM/KPNpktRLFGNwXRpXdLkxhoofIaQ9PWAlEqkAbqQ4k o8BSswPv4OO+umcLbrdzTPbAKblxnB1rXxE2Te9njOX0CJxHjrdBO8Lcerq7h/sbyrZU qP1+83Bgf6XkrN2CG6TCRO65ORy0FGNW4r54NmuQXaodQJlLqrxUHucpFoYDsig6GUCV z/bCHIs9OHR/FRY0UuIvvK+pb/IAsd6EiFZ+0a2bSuS8+o0qAInmzJuFvSBsND/YqwRM 2a9o1A+Ai10Cxqtvt9sR5hiRd14UxTtZL4oVotA485kd2uRztMlvkmrdtQ9EVTpygrKL lELw== X-Gm-Message-State: ABuFfoj2rsiV6f4d++S2VL/1HELZxGHT2Td+CNxYfb4JeRv/xwPkAKaQ x4FFaXg6Cd+z78Ru3YoZ23D1GBs2 X-Google-Smtp-Source: ACcGV61u84ohS99v2zLo6t6QL2UqAhjml96XRRgqNOUMa/iMPv6ElnbfbzRSpV6Nxn/e+F/iMMXGrw== X-Received: by 2002:a37:c085:: with SMTP id v5-v6mr16077537qkv.317.1539617565515; Mon, 15 Oct 2018 08:32:45 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([72.71.243.63]) by smtp.googlemail.com with ESMTPSA id g82-v6sm10087768qkh.24.2018.10.15.08.32.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Oct 2018 08:32:45 -0700 (PDT) From: David Long To: , Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 23/24] ARM: spectre-v1: use get_user() for __get_user() Date: Mon, 15 Oct 2018 11:32:17 -0400 Message-Id: <1539617538-22328-24-git-send-email-dave.long@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1539617538-22328-1-git-send-email-dave.long@linaro.org> References: <1539617538-22328-1-git-send-email-dave.long@linaro.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 --- arch/arm/include/asm/uaccess.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) -- 2.5.0 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 29fa6f3..4140be4 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -250,6 +250,16 @@ static inline void set_fs(mm_segment_t fs) #define user_addr_max() \ (uaccess_kernel() ? ~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 @@ -266,12 +276,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); \ @@ -331,6 +335,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) \