Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp96293imj; Thu, 14 Feb 2019 16:08:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IaeF7HLKOopUVBcgaG7zoNhGb8ZXOms20x7annqPw9IrRlvbTWygY2GdX3+gvEbu10uWFru X-Received: by 2002:a17:902:f24:: with SMTP id 33mr7088216ply.65.1550189292826; Thu, 14 Feb 2019 16:08:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550189292; cv=none; d=google.com; s=arc-20160816; b=xVBPdwwoFAQfTaEXhSw2bU9D+4zICmAyv8wUPxnY2YL2w3qYstm7GFShH/pGVXh+Fn Q/DdPWPhUKgu/TcCmgK5kIoLI6f1dhyUh6ajLIsgRaxDz6qrfzwVxg86eUBV/f/91ijq tHmgN+QAYJ38En3p1ziCbRipY3Ron4wV8HNF6xHXnCMjLVh6SNzEldDr0YJErdn2FQaH bK2CVrlv7WyHPaFJhHL4qD9Esy4TuCBAUrkbjS0nYYZtoIWJdJ8WybJy3hRTCf0ymScj R9tZpPyViuRp3tuGFxIdulMAU5BfO5c4HyBr0BDFgQuLXvrv6S88hcSkj0pGuRsEHOYI MKnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=jAX1WYClvTF68HOuBDHcjdNU9Y05TUeERF66yDaIHEY=; b=bV77w1NajErJQ42v29YbNPeFqsLxxPFwvRc1Oj+szxbNX8tFG6APTssI4WWB0+t1Rp 1Ktnw9piAbuzP7dATObz4DrwL+3i8IWHJUJcLS5LC9pHJpifOMVryMhjkObqPArwNuo5 pWYEmNcHD1KcnvqIoSZbBOO08i8J0oaZwaYY7BWzPzHLlTPeGFqHkHRUfoWP+QvETUbW eL4vNRMftiZCuOvm63jEawkx5eq/78S2R98VKq1+brSYFhIuE2CX6ybu6hRE5jwf219B ZT7aAKPGSK95myaO9mXR5cr7kqBEW/uiRobWgACNcI1XFQjfmwgD5RHFkEEej4AzDbtC y4gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L9Zyo6Tb; 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; 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 j1si3521748pgp.449.2019.02.14.16.07.57; Thu, 14 Feb 2019 16:08:12 -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=@linaro.org header.s=google header.b=L9Zyo6Tb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407332AbfBNOus (ORCPT + 99 others); Thu, 14 Feb 2019 09:50:48 -0500 Received: from mail-qt1-f176.google.com ([209.85.160.176]:42625 "EHLO mail-qt1-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439321AbfBNOtp (ORCPT ); Thu, 14 Feb 2019 09:49:45 -0500 Received: by mail-qt1-f176.google.com with SMTP id b8so7058340qtr.9 for ; Thu, 14 Feb 2019 06:49:44 -0800 (PST) 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=jAX1WYClvTF68HOuBDHcjdNU9Y05TUeERF66yDaIHEY=; b=L9Zyo6Tbln45JAT9duHaa+RG+kna2YWVG18IgdQaCAkBuqKBSBxHfhQYFLpRMM8q1K vUa5hlIrngpOLZW+qnMs4VuoUfnCEsQ8QxTdLgJikfw0oKlPGC2wF7N9/vONBVBkHRI8 PLv/3iQp2q0UUqgl74XpHUyWSiX7XrTCpx2A1g+oIOlkL5BsVShfZejJdh3E113twJaL OhOYZRHHWMvpr9PmmDc21N/5M4qbpSzIoNN7B+SPJDKXtYQdPKa0La9A/QihDG27PZRU /YtPIr/EcA97zw3ydKdalfgLpb3aR+9hGt9vP+ZVRlPS8dz0moSsZaR4qJHjdEPTh7zZ w3CA== 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=jAX1WYClvTF68HOuBDHcjdNU9Y05TUeERF66yDaIHEY=; b=C9t4tiXqZojgk69IcqwnqcfofkKD0SyZ1PmTH9fguMdyWSZvtqeacsHLzHJrqF45yl 72Sn0014qoNQ2LejwX8+GJOeVpw+CGl8KJvzHwCc0bBsm9tUrz+RhmGuTsyuTG19pA9/ HiZmmPOD14cDy4ariNmgcnRYgxcq51sSGwuAe2iI8iCYdMKfwtp5g25PIEYukM6KYZH8 yq7RoENTILjdxNc9B+NUEmUDU6D+Vw1GmpVl9MuT/TAcNScJHHl06Y+x9MpBD8PMhWog GVmRGC8y93YhEgYJj9ug/641xy6PV9U1C28MiQcLqW8RqpGZIAxWzmRz7vBUK7q5SbX6 b9TQ== X-Gm-Message-State: AHQUAuY/ULAX6CKYa9xv3ftvnzaYD7n+mES3VRXhsVejDz7Hd8Jp5USD S9X7i86dsfTN/5L8VEQM9VsY4SROwGA= X-Received: by 2002:a0c:d124:: with SMTP id a33mr3194125qvh.19.1550155783894; Thu, 14 Feb 2019 06:49:43 -0800 (PST) Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id k66sm1498919qkc.25.2019.02.14.06.49.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:43 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.9 08/16] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Thu, 14 Feb 2019 09:49:22 -0500 Message-Id: <20190214144930.27539-9-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214144930.27539-1-dave.long@linaro.org> References: <20190214144930.27539-1-dave.long@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julien Thierry Commit a1d09e074250fad24f1b993f327b18cc6812eb7a upstream. Sanitize user pointer given to __copy_to_user, both for standard version and memcopy version of the user accessor. Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long --- arch/arm/lib/copy_to_user.S | 6 +++++- arch/arm/lib/uaccess_with_memcpy.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S index caf5019d8161..970abe521197 100644 --- a/arch/arm/lib/copy_to_user.S +++ b/arch/arm/lib/copy_to_user.S @@ -94,6 +94,11 @@ ENTRY(__copy_to_user_std) WEAK(arm_copy_to_user) +#ifdef CONFIG_CPU_SPECTRE + get_thread_info r3 + ldr r3, [r3, #TI_ADDR_LIMIT] + uaccess_mask_range_ptr r0, r2, r3, ip +#endif #include "copy_template.S" @@ -108,4 +113,3 @@ ENDPROC(__copy_to_user_std) rsb r0, r0, r2 copy_abort_end .popsection - diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c index 6bd1089b07e0..f598d792bace 100644 --- a/arch/arm/lib/uaccess_with_memcpy.c +++ b/arch/arm/lib/uaccess_with_memcpy.c @@ -152,7 +152,8 @@ arm_copy_to_user(void __user *to, const void *from, unsigned long n) n = __copy_to_user_std(to, from, n); uaccess_restore(ua_flags); } else { - n = __copy_to_user_memcpy(to, from, n); + n = __copy_to_user_memcpy(uaccess_mask_range_ptr(to, n), + from, n); } return n; } -- 2.17.1