From patchwork Thu Feb 14 02:10:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158282 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp793804jaa; Wed, 13 Feb 2019 18:10:37 -0800 (PST) X-Received: by 2002:a37:9dd0:: with SMTP id g199mr931032qke.344.1550110237480; Wed, 13 Feb 2019 18:10:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550110237; cv=none; d=google.com; s=arc-20160816; b=E9BnAIjd3Xx+iKjtydjmfylfw11nLBV9ci1d9wuJQZK1PpnFYLukSBjVDc3KbOO0rL PjTtkQFHS0bYH0NKuAVei66Fx12LJ2tzYKBpfPQrpMOoe8n7rct56qk77MdBSyUz1o3Y 5yrFVllcS+hTq+doUNlpKU0v7kVNhAwMuk01CCDuLS7s6LZAsoVsFSMaQi6JPIClZ1fu I6s1TiNIACskHQICa6tFllkPOStZ+VOPbxigWZlQV80hKYwYwlK5mpcx5A9pTA1/7Ri6 7IWbjP2ooAM0vWku6Q4PSrYnNWzvshAg2c38m6T9vWjVE50lS35bYmTXKNAlYwUP/l8S Lf3Q== 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=UDfhDnpKVnmaeI2MOrtdpi1WP35k25fyZ+OFvqzwhfiYjKvgZc1Hg0Sjekqiu2nMCl Pfe9AfiYJpbzWS7S34UY4pZ6xSrfxuFPXx1IlDm2RtBB9cK1pXIDcfxqLPAEB/Ipi6te G8q3ViTabDhxT/RTpuLQ/hMsFBb6NlSsIgguFyzunA7Oq+5AhPYKE28mIMWWO8EGOMCn JlZxJRDg1SW1DZGXdykem92irj09KpmUnOABQVUGR1qdQQFFxEXkLggw0odJUFP103bn ZFxPJYkF1EY5UmtAfmc56PXDdE1z45nKfXBCc6ASpfCerbJ3PGIiDPoxI8v+Z7ZsyWxB 09Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dwwaIIhG; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 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-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id p45sor1253420qtp.35.2019.02.13.18.10.37 for (Google Transport Security); Wed, 13 Feb 2019 18:10:37 -0800 (PST) Received-SPF: pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dwwaIIhG; spf=pass (google.com: domain of dave.long@linaro.org designates 209.85.220.41 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=dwwaIIhGhe/W4fv0WLGZipxrqaTJg/oyBGMzOQ5IfacD3zPcmv4vwj2uiHmFq9QWNy 5JPvOiad9GUL8bC6P7oGHiMR4AOxVlE+P6E39igFBrB3pv2Pczr92iGqyI4PjKPJUPpA x65m/MqQN62IhgWMpwGrc9yaparmdeII9TdnaREM2oxlvLC2b9otDSgIFbda/Ss1RQWi ebi9XIa3aNFeKyYxRH2zfPQxZUpgGd+Pz1OXmex5llrU44lvLBCSqofmN5iNmaEYIg6L iBtT7a28KDuwKj9c1a/8a6UXU1IWpGSth6KdlcLG72/qpZhy5u6q2WiPowFbqTfihKYe qMFQ== 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=d/K+cmmKf7+7ZnZn4kbA8rrsm2qZUGe4IiDtp9EGFwsl2LqsNw52QqZdaNqdKyh9zf MX7VwI1HISTcZHp7o9LGj5EfVCJpptY2vnThEu1U7E+5r9PGyqEMGURv49S3ERF4jpRD AWrEQbRFeW/IYOW3VRWr+B/clC0BbOFhkWxgoR/w9lr4Yq2mD2Yr8icZrquEJyxHEnQ3 PdkaUSCOp7uCfTIcx0krBlfg2LkMEgEdNQHwZHHDCviQvWnTZPc1s4kw2pRlKhdcz4g3 cn92jtoyVzXmi29ECr5JjifuWPyUAy78GInaOa2ZJcd3owmQKnAxGZOzv/lanDNN/Afr nJ+A== X-Gm-Message-State: AHQUAuZcrD7QUjOtp8u7JnV4Oh0r3QLlTT9EpzL1HZBe93xM/q8iP64E SltDxIJ0akIgtdpCgnaBtbGNBGog X-Google-Smtp-Source: AHgI3IbOJ0G/C9jKSa9gSfu5KY19PNsZDByWcebqN0yAJbWGCFZfEZvLsjhYnORACPzBc8i4S0rGeA== X-Received: by 2002:ac8:34ed:: with SMTP id x42mr1062788qtb.173.1550110237197; Wed, 13 Feb 2019 18:10:37 -0800 (PST) Return-Path: Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id d63sm1091575qka.22.2019.02.13.18.10.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:36 -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.14 V2 09/17] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Wed, 13 Feb 2019 21:10:14 -0500 Message-Id: <20190214021022.5313-10-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-1-dave.long@linaro.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(-) -- 2.17.1 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 9b4ed1728616..73dc7360cbdd 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; }