From patchwork Wed Feb 13 21:32:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Long X-Patchwork-Id: 158261 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp560946jaa; Wed, 13 Feb 2019 13:32:38 -0800 (PST) X-Received: by 2002:ac8:3774:: with SMTP id p49mr231330qtb.388.1550093558542; Wed, 13 Feb 2019 13:32:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550093558; cv=none; d=google.com; s=arc-20160816; b=eXyQ5RmA/u/QMcdxEwgJMx//Lepc3tYeg5QzAd9n9Z3qJr8KzMTRQqGA0iSN2sbGjn nt6dfqHL8GklpaT3MFOqKLzUbpseoDxDA3vnJvVTWt71gFoaxZylbZ17EX2F+Oj+p4j7 zzemr0iv/8qxatGBb+HI2yuv/wmTyTQtbZqTbi/9ACEfLNwCrr87gyYcIrjRnsvHhOFh kzcXh6iZp0SrrAlzusXeAhk7TfZKxo9JzZ8uMOBXP1eqfVOAOffoR9qwh0Q51/bnAwUN y0ryOf7BQ3gDl0/1QdfkUqA7pynQsGGlSeFDB7sAghoNaOI/NTIKPNgGQkJJ/Bir9MZb 6UZg== 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=cth19GVBpysbRLNUUIom9yXekruzMIZuTB7NW75yAUvgqF7GsttPF8AB6YEGL1vtRt tUBS+PRromt+PtBt8sIuC2F1TgkCZ9Q8Hi8+rbe/mLkl2fQpQQAfFbFdkpP9AP5v3bxc RKaeCzb5ow5qZhwASPhQUROmPXfcc9LC0hL1rkswIGZ4hp1hMjWJaAJQVTeTZk2a5KRA 2qfNYWk86cuJ287mdTsV/ZC1qP7fTwtf7hvxGNyp7YvKFfJYYQxarCYhz6T3k+Oct1hU AM8EgIc7wUTwFbWuCcgGb58jLwpjvrfINy6PSbQvtCAXQho2M1jkaBbClqWDwtT1/kid 8k5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IvJ3USwh; 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 r17sor569245qve.9.2019.02.13.13.32.38 for (Google Transport Security); Wed, 13 Feb 2019 13:32:38 -0800 (PST) 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=IvJ3USwh; 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=IvJ3USwho3JZnRpyvMASZ3XvtoUm7qzuHhmNDwX8q6yHGzn9uAMmmIBUHhGLFwgQUU seEUJTS1jYdirWnlwMaWfZ1STNzjOeoWD2lr5w+Iq9kcmhXGiAv5AI0sS8kMGxK6fBhg NRTtPwWJmnhk5bK8Pi+x3iXRRprvqNhlAgtk+kET2zt0xiNUFcTzmJPYTvA61T9WuwvZ JqGXRJMA+6qUJZCFLsTTyrteplKjo0NxVun0F3UTJDo9mHz0Dg3jqHGr5EnXhxkJFMw9 XSHcgxBW+FlSHpqGy4SNfysvdA/eznrYPWnr0jqnKmArPcU77qNUYn0Dbrp4k670vAAI pRgg== 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=ogNRsSIZi2H7SORRY2UD2SvDhl4Qj7Bm50uJHiLSYYTBqVf4QlrcSMldQxY+AAihOs RGAYp1fgyCSLX1xss0vkk1lZ9KKu5DinxZJjktKh1WsbfiOkLxyDaylGcIEiOyLE+Z7F AVgHDY3RNA6cGHPo+Qf8Z/Dt1ypfK7wDBd77srah1Op3f4PHinaYZa/SDGZgDMNkrHra DIZAxBZ8Y+CVxL99D0EYYB810BTikN4SXNnAWYq2D3MCsWnrYJS8ef+w1BACigftcaez 9n6Kvdx1bwWvBzXgbuVLzBMQ/hDLs5L0y7OWo/0AyilGH79pk2eQhPpLd17qq6TNEqvQ LF0w== X-Gm-Message-State: AHQUAua7WSiJ1uDz75zzFB88+MOo+2sT6pMClSiO6hszEcWG1am4matW /hkmSwEmxB2u2RYy+5VG+24Gqf5q X-Google-Smtp-Source: AHgI3IYW8+K14QArKauUWkZ9ZtqpL7O14AvEk/eB69PdquX061fTxlr8ZKWVxytrXleRGtxapCzz/Q== X-Received: by 2002:a0c:941b:: with SMTP id h27mr260105qvh.8.1550093558210; Wed, 13 Feb 2019 13:32:38 -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 8sm382675qtr.7.2019.02.13.13.32.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:37 -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.19 09/17] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Wed, 13 Feb 2019 16:32:15 -0500 Message-Id: <20190213213223.916-10-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-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; }