Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1091769imj; Thu, 14 Feb 2019 00:51:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IaWhlnQJW9xKAVr/c1nSj4AjLaqaLv3WPCWinOlXBesDjx1oK8lnglAWVRrmaXhRjl8BePx X-Received: by 2002:aa7:849a:: with SMTP id u26mr2820227pfn.157.1550134272037; Thu, 14 Feb 2019 00:51:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550134272; cv=none; d=google.com; s=arc-20160816; b=o3xbOwuRKBB7AI02p2WQIl2gWhQzvhoPaVg4abHGpyyv2nQAT5UcUUmdriOqY+mQaa b6aXOWYCErsOf4etOGoHjctWIyQh/2fLzVz7KqgBzYRacg6FC5bUbYjOPF5X56zPDgLh K7Dsqda9cJYiqcpOSp0WAOg2qgVkDFw8a7jxu907690lxWIDPNe+taPc3+Tuimn9+PeR AhBzYE1XtoSK501SONwMfjWERIg051cW62iUxt83/m13fv5GPqs2ldXsG5m7es/4Llx9 sgJEDiphDGvV6k4zn6rdsIhiVUPkCg3k9H0ojP2F2paKsvsq9LsJV34SJLolnQSteTj8 K2uQ== 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=cmHxjX3QWGEzbd3gID8OLJBVtbh3tUIgNET1gXVqzGU=; b=GePju0nDPYAKaB4WAaYzllNRp0NlJhU1pWNQFhvQhM3Op4yXBPaSG6QVr9UN88OXOg CDdoIdNjd+IkHNF03ZoeHsl/6wpKs4zZ060wuOASp8ycroX5QLy4h4xoQ0fJH9IeEI+H 7oSKk5P/RuypkEGac5XFzuvDYkvwFbH8b7g+gTKJqzKUFexei6IBc7cvY466YQabn69L owNJplny3VrHcBQcCCD5btPz5m6vKZLQuhwCJYgvYluwHLuLCf7EoqT+tETZKDzDHyhr AIVvejSGHYgMKo1RG669WQomQPC28flSr57TkhorcuFmbNsDvT3bCgINZ0h3uxiVXrcq Bd9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IvJ3USwh; 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 w11si1692028pgp.161.2019.02.14.00.50.56; Thu, 14 Feb 2019 00:51: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=IvJ3USwh; 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 S2394883AbfBMVdc (ORCPT + 99 others); Wed, 13 Feb 2019 16:33:32 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:34981 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436761AbfBMVcj (ORCPT ); Wed, 13 Feb 2019 16:32:39 -0500 Received: by mail-qt1-f194.google.com with SMTP id p48so4495936qtk.2 for ; Wed, 13 Feb 2019 13:32:38 -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=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=lOxCd9Ik8J4aM2xhGZJ8J3L0Oz1nLHfUBW9a0ueOWhrTmj07xz7u2oi8wpQnje2mAE RzDC6+o7A6WdQYrLkADKdX+sLSlXc3+cEFT8b6WNitn2wCFNczQTVppU1T/pbtfEhUsY Vu1ZhoLb0uPSs2glJ/3TXgoglnHdaHLkvfNSibl2qB0PGXTFKZYEzvpjN0SCMapwzn22 PYN/rMJM19u4zcYTyHxAmmWzzGm5s/EctkMZIGAn0f+EBaTps2lOTWoxJOW1ll4xn2Ii YBeeHPoOY3rz5PvvWFlYPujShqqHjeBM4KZWeih/SnxWX2yLqS/AEvJSpWlhG8dG/IVZ GVFw== X-Gm-Message-State: AHQUAuY4Jk1i/xl3qKfGib0V9r6RjR6876ErNdV40TOx1uY0eNBHzShu nblT2wzSC5lFFW2b5pjoJWeopw== X-Received: by 2002:a0c:941b:: with SMTP id h27mr260105qvh.8.1550093558210; Wed, 13 Feb 2019 13:32:38 -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 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> 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 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; } -- 2.17.1