From patchwork Mon Dec 28 12:44:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 352733 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp9846455jai; Mon, 28 Dec 2020 07:53:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEJl2Ie8W/jIcAXZTKcUs79a93zMjKJJ8gz/6IsAOkiraX8rQXWfuKQGo5sbqXrGgoFqKD X-Received: by 2002:a17:906:34c3:: with SMTP id h3mr41903153ejb.132.1609170833622; Mon, 28 Dec 2020 07:53:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609170833; cv=none; d=google.com; s=arc-20160816; b=tWmdDkgISHsyjEB3cWIa/tL6WK5mvZ5cv7/hiHGyxnOkQjW2f+hk3i1DTx7rkbHlB2 W0TcbOhCIaWsp2CSd5vD1HU8UyJiipk5PgCFYzRLFt97w0JDGt9FVgz2unQQdNwltTeO CubSm//PNjC5DBlLqXYwrJ8r74N5gs+RIJTcoz4S6HgHh0pLpQr7LWAPjo++ulo+vDBE 5DzQZMlCluW0B8Vxdz2yRk2A7mwKncHhdqYiBsPYTQ2UkAxL/mfqxeGOm+FIZRx9Lg8k 8By5Pyz+Io1LhWWA7whU/A/NoG55Oka51M3F9fEYmVOBDVBE+yFPs7Tng/cyk3//13TI LLdA== 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=es1wdw508NvYyII0LZALu3+4w7mDkmeRQc66rYOpx+bmG6AnhGRuirWF9WegpVObYJ q9pKEoGmW9RqXIcShGugP5hmBLkC494FXunBWsGOiOZV/Lw3o8RM/Y9EHLjRsRCpu22p 6hYnKeFj9Ux9AdvDYmnyTxhcmqucTA8Kz3JFe7fXHM4Iqk+vQ2QDv7Aqfjfklh5AsZN9 wp122ooZ65aRaG26InNMh9R3N3lQFPj4H7gdUFHcL5V9ECGuJKbPRvqI3/VJA9+6+4wz 1tt7MdIjU+BCQjLFRytbHAMecL0z5TRylnq41Opl9kubqWjFhl0PrB3btl+iwMeFb4t8 vRSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FI9RA6dv; 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 7si19461835edw.324.2020.12.28.07.53.53; Mon, 28 Dec 2020 07:53:53 -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=FI9RA6dv; 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 S2404020AbgL1Nlk (ORCPT + 14 others); Mon, 28 Dec 2020 08:41:40 -0500 Received: from mail.kernel.org ([198.145.29.99]:40444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403846AbgL1Nkc (ORCPT ); Mon, 28 Dec 2020 08:40:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F25B4205CB; Mon, 28 Dec 2020 13:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609162816; bh=vetFylCNhqBy9Hb0U/hW9ek/D9/LNGKncD0/iCRr3t0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FI9RA6dv9jiMKEJTraPS8v8JPmT2mPkvQJDPFBR5RU8BgWbmC72nSPEdMFjXTtcZz U+p0YW5v49J1HrtIO422aB4FTBEydJcMEli1ZZCAzHR6rdJqGN5PQmh1c2eU+4iMXj neUP6PikoP9B0lffjQ5AalVgs3hRdin68aNykRwA= 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 5.4 041/453] arm64: syscall: exit userspace before unmasking exceptions Date: Mon, 28 Dec 2020 13:44:37 +0100 Message-Id: <20201228124939.237711750@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124937.240114599@linuxfoundation.org> References: <20201228124937.240114599@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) */