Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2243745pxu; Sun, 13 Dec 2020 19:04:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJx733re6H3dLBznzcxiqOLdqSmj6IZILWEvVROlPJUDc5F3hrFGhZJYF3P4mQzOY8H/5cGD X-Received: by 2002:a05:6402:17a3:: with SMTP id j3mr22733206edy.333.1607915071240; Sun, 13 Dec 2020 19:04:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607915071; cv=none; d=google.com; s=arc-20160816; b=RFG4fmWHiWqBZZjVHFdvb2x7tElpibHAoYbbTAz9QNzTH5CMBmYPqGgtaVHig92Uck tzVuAIA7p5t/g6FUyAiyfLqANE3eKlu2OXHot4V4AF77KZuH6Uk34YN2IwBjX1bsHSOj ysh5sdvZDpDTn8grbj4zT6FJ0IavRK2EqIvCSH0OGXxdVPNlr4S9Qc3bS517y3l57rz8 ixnXMM9Eoy8qklfXzDX3yhHmkRenYvF9M/vyr62vEjnWBxt60oMcEssU8tg4nsbrI8tW TIDZF9ML2e7GFGjly+I1hGcBDHzZtpx2yDs/ssgBHQo533rsUz8Vf/sSklv2JH3RLDdM pghA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hf7MF4sbpPJgBVb0KzroGAfJlW9zsvmpP9egDqn9xPQ=; b=jeiRQY68LemROoqlB+VtnT5iuvd+gLWQfNRmB5TVUjqo8Sh6Hd3dZOo1dIOzHuXYPj GsJhZwp9p7ElvBxVDVepVSeYO3wodRpxmkj4/9+73VvzxH/kTlkVAS3hkECUMpPNLKQ4 62FUYb7kToQs9LgUC+5AWmbp0TvBHm1AQwPO4UKWuYxUIBFYrd8S0OyaS5ryuO+C5pTD wbxmAb4Xby/8QgGzoGtoviNQ4hT0F1BW8E7C8wI4OPlvgpwlVWNtRgAt2+3A9DYxIb9g lMWLEAnstGI5WKRxhyOKnMO36PTO2N5AxBcO20N2IFre7uQ0RhlYYsu0NXXh6NQcqBTQ KgYw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id no7si8752928ejb.586.2020.12.13.19.03.54; Sun, 13 Dec 2020 19:04:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439511AbgLLQLH (ORCPT + 99 others); Sat, 12 Dec 2020 11:11:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:57722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439379AbgLLQJg (ORCPT ); Sat, 12 Dec 2020 11:09:36 -0500 From: Sasha Levin Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mark Rutland , Catalin Marinas , James Morse , Will Deacon , Sasha Levin , linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.9 12/23] arm64: syscall: exit userspace before unmasking exceptions Date: Sat, 12 Dec 2020 11:07:53 -0500 Message-Id: <20201212160804.2334982-12-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201212160804.2334982-1-sashal@kernel.org> References: <20201212160804.2334982-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Rutland [ Upstream commit ca1314d73eed493c49bb1932c60a8605530db2e4 ] In el0_svc_common() we unmask exceptions before we call user_exit(), and so there's a window where an IRQ or debug exception can be taken while RCU is not watching. In do_debug_exception() we account for this in via debug_exception_{enter,exit}(), but in the el1_irq asm we do not and we call trace functions which rely on RCU before we have a guarantee that RCU is watching. Let's avoid this by having el0_svc_common() exit userspace before unmasking exceptions, matching what we do for all other EL0 entry paths. We can use user_exit_irqoff() to avoid the pointless save/restore of IRQ flags while we're sure exceptions are masked in DAIF. The workaround for Cortex-A76 erratum 1463225 may trigger a debug exception before this point, but the debug code invoked in this case is safe even when RCU is not watching. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: James Morse Cc: Will Deacon Link: https://lore.kernel.org/r/20201130115950.22492-2-mark.rutland@arm.com Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- arch/arm64/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 5f0c04863d2c1..8a4bf00e538c3 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -120,8 +120,8 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, */ cortex_a76_erratum_1463225_svc_handler(); + user_exit_irqoff(); local_daif_restore(DAIF_PROCCTX); - user_exit(); if (has_syscall_work(flags)) { /* -- 2.27.0