From patchwork Wed Oct 31 13:57:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 149817 Delivered-To: patches@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp6826831ljp; Wed, 31 Oct 2018 06:57:46 -0700 (PDT) X-Received: by 2002:a1f:2145:: with SMTP id h66mr1342945vkh.65.1540994266085; Wed, 31 Oct 2018 06:57:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540994266; cv=none; d=google.com; s=arc-20160816; b=VoDjETaXGimt0XLIEGkcDjL2QP54hoLvEFB5gSbqvcBl5qNEQzguu8DbqXNVuXTNdP 6zdM0PGMhQjGVm2hLEmFLUQKvDi03b/np1fTKNRFeuvpOoRvg+R7Vx9inrqYBVsAyYN6 Hp9Muzkb4KECTZR3h0c+Uwgs3kcYc0JPaqTvCOMiH31rpA9P1htEZz5EGUh1RiBw4Kz3 MKjshBYJ/bTUXpxA4VEoEHJ6n1PP8u3dVvHXvPYuyDgNi3aFd7iB4I9GrP7RwY4/j769 nMlI42yDllOLV2yMjoU2bFWrhCdMOZotVNfL+W2uBPRt4sKaaT3MG1AzV/dd0ctCbloB YeBg== 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=NgpDbEEIVQNDaGmylLr91S8vRe2oycD1Ffr64haQrrw=; b=p1HmE0bgNAW1792IxrrgVb9B0Ue+JUb4tc69mi0g+w63rs2l5Xtvdu1392VdivWMaf fbGrwlSa/aDWTMTxRUNJwbIUM4NZ0GolPfhTpfcghsdBmsL30YIK4LtIMtIEAAChuej1 AuNLbJxFSkYVDcx+AHbPKZGFNTGZkjuxXFKot0++YuFHV1NH/x2gPn6ObyDVnElY4KqY +4+4KvieFwaFF6c6f5fPuWyDlBMmRbNTovXxm/rSHU2t9vbTqKcpz0Ywrt7864H4LLsE fIWQs2HE2CdjTWint4ua3lfY0nbJJduwiVbkZlazYUA1esBDrnPKiIQmwG/fT7Kpv/3n ocxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HMwf8VUo; 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 125sor546815vkt.51.2018.10.31.06.57.45 for (Google Transport Security); Wed, 31 Oct 2018 06:57:46 -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=HMwf8VUo; 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=NgpDbEEIVQNDaGmylLr91S8vRe2oycD1Ffr64haQrrw=; b=HMwf8VUoInrIuqKY6Xg49UuVRw7eburoboY7RB+wBq4pyzSuaTjoqgy2pAI2DwvhNN 6obM45WTKlN+RKSZNHkqQrxYVAJLfqNpzf0112JuxbtPBjhI1dq+6b8s7Q4LJ9gwXUfA zKz+jexuqb00GgB1mZ6P/viu+PB+jHtCyY9mg= 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=NgpDbEEIVQNDaGmylLr91S8vRe2oycD1Ffr64haQrrw=; b=T4d3Iwq3MQIXhq6WmkDaQnLqaiZXSbjEEmMvxOAN6GZbt0aPCZTfyw0ysOinWpg4Wq 3tSFrTyneprXstsgUUfyYk0z05RaJgOccNaI5zDyRhGYWgCY9pXBcfNV1ApgqS3PVEi/ M4jmj6Um+OmZVC31UbUAUAaL0NOqO9o9EQGdVOGveGYwQUL5+ssqBPBA3qKbOrLvzk9D vuuT2Mrb0hyM3tqToO+pRFQ8jhGybfqbtZVmK+YpGk1EPs9X1LBkJ5wzb6x2aTocS9LB zM3po1lHUzgmANGpbhgCYbhK8wcwvwsZ3PbW3ZKZyw4UZLltG0Zsi+ph2EdXjwX2Z/i2 UbtA== X-Gm-Message-State: AGRZ1gLi0xF7TvmFsDGQNNH5lbQVidk0If7b8PCkCt2J0nv6pZlmMIp/ 21sryCp/XuiHecw+IhYmflrif1nM X-Google-Smtp-Source: AJdET5eF0AP+wOOnpuMsDOTqPoyBHoGQfmc5/gdNzHXwr/tRcUPAooLd60Ia5XVe11vWZupegpJsPw== X-Received: by 2002:a1f:97d1:: with SMTP id z200mr1330638vkd.15.1540994265488; Wed, 31 Oct 2018 06:57:45 -0700 (PDT) Return-Path: Received: from dave-Dell-System-XPS-L502X.hsd1.nh.comcast.net ([2603:3005:3403:7100:2c71:8680:34e1:a6aa]) by smtp.googlemail.com with ESMTPSA id s85-v6sm2275624vse.29.2018.10.31.06.57.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 31 Oct 2018 06:57:44 -0700 (PDT) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.9 23/24] ARM: spectre-v1: use get_user() for __get_user() Date: Wed, 31 Oct 2018 09:57:12 -0400 Message-Id: <20181031135713.2873-24-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031135713.2873-1-dave.long@linaro.org> References: <20181031135713.2873-1-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.17.1 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 4a61f36c7397..7b17460127fd 100644 --- 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 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 @@ -296,12 +306,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); \ @@ -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) \