Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2427016imj; Mon, 18 Feb 2019 05:55:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IYiej7RTTjyUJXF7QQL2308aG6ZVtVmqaE9joJegMJjVEa/MBOAhXLze2m19br3Y4ZoMJK4 X-Received: by 2002:a63:575d:: with SMTP id h29mr4326753pgm.442.1550498137338; Mon, 18 Feb 2019 05:55:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498137; cv=none; d=google.com; s=arc-20160816; b=Wu6VxlvuvyvdLU4uhH/Tz2tHLMqYjN9VnQvnpwma3+Qr0Wq/TgfvpmxaXITxgc7DRd V9x8mUB1YE+0w+I9ZTrzo6SA4i8hIC5j/rhjTKQD6pPUfGrQhuR7erAX1e9uR0iEkdDE qBBAf4N2932IqY+tYFGeCJUqEy8laK0/3vOXuw8tp5pG5yoENYbq9Wvqms1a5/2ERdyC VJoEbvfjqn4asHXI4MWRSCwFc7UDSmkFz8Q33sXJzogo3tDTSlUbflGIxPD/OGnxtQ+P bj+dCUDPb3nGOToOHcW6J0iXLuPCS0jtUZ1ymzEz8cmBGIqiQlAxK2S9g3Rb9sjvQk1Y K3+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=76QV078aDt6c4ptYhwRdR8eXmSLWcwQzuS/zuKZaMDs=; b=fUOVq2sAfeIRVRQ4+/FP2ts2qmd+tTtneb45LBVZII1vWg2h/uky9l7becrm122Bbw VpJvRF7XdtY64aM5+afLkUovJuFl5Dyv8jwlqRtS+l8dU855Cw+PL/NiN6/i2AKwVNmJ 7vmrcNl2S+hEXDWL7goDvdZz7Jzon2ZKZp5tt6/IWkRCy3qqrGVVcXNajX3RO1gnwE00 1itxjurXv5W21xhqni3lKkYE2q9RkkfN8tuXsGRVKjShyW5/zvFMgZe0jjdk5c4UvBrL BYsBBeTMxauBQ0Nf7j8o81o67x6qBBExuCXka57GkEY/JjFI17DFgOdMjKD+uQC7eXEQ c7qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HXED6Iks; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r8si10545750plo.203.2019.02.18.05.55.21; Mon, 18 Feb 2019 05:55:37 -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=@kernel.org header.s=default header.b=HXED6Iks; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733226AbfBRNye (ORCPT + 99 others); Mon, 18 Feb 2019 08:54:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:34362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733191AbfBRNy2 (ORCPT ); Mon, 18 Feb 2019 08:54:28 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C8C62217D9; Mon, 18 Feb 2019 13:54:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498067; bh=o+h7qqofNB76a9t7REEqLT1viC+nboCMqYImP8GTobs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HXED6Iks6rRLoGYc1RTp7pTQhXNgqeDVMNkZoGMgl5RV3ovjlMriA5zUTk1QGxyur P8O7aji2iw1nJmHzS5UAJpI+p+kDPjzP8v6CeO/ica+o9WFMJiuYgwqpD5N8anE/Jh unzGmcW5H4AeQYyab9zUwQBMi/F5em79lwPFPz1A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Thierry , Russell King , "David A. Long" , Sasha Levin Subject: [PATCH 4.14 13/62] ARM: 8797/1: spectre-v1.1: harden __copy_to_user Date: Mon, 18 Feb 2019 14:43:19 +0100 Message-Id: <20190218133506.964600367@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Reviewed-by: Julien Thierry Signed-off-by: Sasha Levin --- 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.19.1