From patchwork Mon Dec 28 12:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352629 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9745379jai; Mon, 28 Dec 2020 05:27:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxEvCKk9vrEgAYCceP/PKhDuwSP21s4ight/pxdHU4NBxZX7XGb4bOB1gliOGw2z+0JFepE X-Received: by 2002:a17:906:59a:: with SMTP id 26mr40977291ejn.309.1609162023915; Mon, 28 Dec 2020 05:27:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609162023; cv=none; d=google.com; s=arc-20160816; b=SZGOa2FjLT4r4UfaFE8GXZF01mAKOj6wLQM33fMNfYvmiBFFV6yqkkfVJwX3K0NmOk uMQ4HsVfplazde63lyudXlgV2jPNzXQzqAu2FVYl9BCSlXhGGUizmyoimMFyjPKjK58e lfj8MDo6S8a/ZseEwh8q3BwHhN4LCezV4Wudej0xfHSGMBean4Ni0SY+rRPnGKzu8gy5 bgbc3aiDZoQMoWKnHlA4lRPS1e0aShDF4a7xMWrevwyTX0gmD6Xw3WtwY0n5mqawW+2D Fu+P30OzEil5l+Y4s6aGEvPnNC4y27+f1ZUIJLGFqb/hDGXUw7RYdyAXjZojuK6EhEBP X9mQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VU/yWJp+pYQKrmzk1yQJeLap0WdmBTRYTU2SGv+/N6w=; b=c1E5LzHxpAIMne67o2cZkYuLxcNFlNx8jl14rGtTKBE3UafOJHwRYQEtvRAQbEQNQH oDYOCdn5CVjmj5BSsOeTY8Dfe3w723O24SIa7HxE9BmxTTfzIv9RWHsy8tLG4gizL/Zi OlXTda8Isq3CC5zSDVjTt3lBZfUnDgXr95h4JFIvyAWC7Y4kesnk6DDPfcjUtvhGb9DV q9QubxaTUnbflYG8e1OnnT2tgveZtWps8vxllNz2xZ0apzDjeWCDlQ6nNkcp/0n+IlRx MQzjid/sIpY3mun5Y2eZn3NSKWVABUV46se+8JHbjXdr8WQxF5kSfNvPYayzEx0XB3XN FJiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VTG7SbIM; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ho39si19307546ejc.745.2020.12.28.05.27.03; Mon, 28 Dec 2020 05:27:03 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VTG7SbIM; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388463AbgL1NXW (ORCPT + 14 others); Mon, 28 Dec 2020 08:23:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:51818 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731785AbgL1NXW (ORCPT ); Mon, 28 Dec 2020 08:23:22 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9BD78208BA; Mon, 28 Dec 2020 13:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161761; bh=vetFylCNhqBy9Hb0U/hW9ek/D9/LNGKncD0/iCRr3t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VTG7SbIMlUUW6hSCCVyKdmctHVYhNXAlmpzJkwuMIpf2llHkGqEU8wL5mZvx4ZN7E gQv4lfpq18o1ufxrzK8wkRmWDLs/ZKCkMl4bcGynRUaTqtCq5FQKBNdJ0BHNkCiW+n 6gr5gWn79iHBOslLY48TL69K79rsR+GwvlFAhR7s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Catalin Marinas , James Morse , Will Deacon , Sasha Levin Subject: [PATCH 4.19 072/346] arm64: syscall: exit userspace before unmasking exceptions Date: Mon, 28 Dec 2020 13:46:31 +0100 Message-Id: <20201228124923.277198210@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124919.745526410@linuxfoundation.org> References: <20201228124919.745526410@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@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(-) -- 2.27.0 diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c index 1457a0ba83dbc..f2d2dbbbfca20 100644 --- a/arch/arm64/kernel/syscall.c +++ b/arch/arm64/kernel/syscall.c @@ -102,8 +102,8 @@ static void el0_svc_common(struct pt_regs *regs, int scno, int sc_nr, regs->syscallno = scno; cortex_a76_erratum_1463225_svc_handler(); + user_exit_irqoff(); local_daif_restore(DAIF_PROCCTX); - user_exit(); if (has_syscall_work(flags)) { /* set default errno for user-issued syscall(-1) */