From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4976FC43603 for ; Tue, 17 Dec 2019 18:03:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 12E1F20684 for ; Tue, 17 Dec 2019 18:03:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 12E1F20684 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B28648E0099; Tue, 17 Dec 2019 13:03:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AD9048E0079; Tue, 17 Dec 2019 13:03:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A16908E0099; Tue, 17 Dec 2019 13:03:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0217.hostedemail.com [216.40.44.217]) by kanga.kvack.org (Postfix) with ESMTP id 8478B8E0079 for ; Tue, 17 Dec 2019 13:03:23 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id E3AB7824999B for ; Tue, 17 Dec 2019 18:03:22 +0000 (UTC) X-FDA: 76275405444.08.51EEDD3 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin08.hostedemail.com (Postfix) with ESMTP id C347F1819E62F for ; Tue, 17 Dec 2019 18:01:57 +0000 (UTC) X-HE-Tag: suit98_685b799b20a10 X-Filterd-Recvd-Size: 4077 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Dec 2019 18:01:57 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1BF2E30E; Tue, 17 Dec 2019 10:01:56 -0800 (PST) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.197.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 70A7B3F67D; Tue, 17 Dec 2019 10:01:54 -0800 (PST) Date: Tue, 17 Dec 2019 18:01:52 +0000 From: Catalin Marinas To: Peter Collingbourne Cc: Evgenii Stepanov , Kostya Serebryany , Linux ARM , linux-arch@vger.kernel.org, Richard Earnshaw , Szabolcs Nagy , Marc Zyngier , Kevin Brodsky , linux-mm@kvack.org, Andrey Konovalov , Vincenzo Frascino , Will Deacon Subject: Re: [PATCH 13/22] arm64: mte: Handle synchronous and asynchronous tag check faults Message-ID: <20191217180152.GO5624@arrakis.emea.arm.com> References: <20191211184027.20130-1-catalin.marinas@arm.com> <20191211184027.20130-14-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Dec 13, 2019 at 05:43:15PM -0800, Peter Collingbourne wrote: > On Wed, Dec 11, 2019 at 10:44 AM Catalin Marinas > wrote: > > diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c > > index dd2cdc0d5be2..41fae64af82a 100644 > > --- a/arch/arm64/kernel/signal.c > > +++ b/arch/arm64/kernel/signal.c > > @@ -730,6 +730,9 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, > > regs->regs[29] = (unsigned long)&user->next_frame->fp; > > regs->pc = (unsigned long)ka->sa.sa_handler; > > > > + /* TCO (Tag Check Override) always cleared for signal handlers */ > > + regs->pstate &= ~PSR_TCO_BIT; > > + > > if (ka->sa.sa_flags & SA_RESTORER) > > sigtramp = ka->sa.sa_restorer; > > else > > @@ -921,6 +924,11 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, > > if (thread_flags & _TIF_UPROBE) > > uprobe_notify_resume(regs); > > > > + if (thread_flags & _TIF_MTE_ASYNC_FAULT) { > > + clear_thread_flag(TIF_MTE_ASYNC_FAULT); > > + force_signal_inject(SIGSEGV, SEGV_MTEAERR, 0); > > In the case where the kernel is entered due to a syscall, this will > inject a signal, but only after servicing the syscall. This means > that, for example, if the syscall is exit(), the async tag check > failure will be silently ignored. I can reproduce the problem with the > program below: [...] > This patch fixes the problem for me: > > diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c > index 9a9d98a443fc..d0c8918dee00 100644 > --- a/arch/arm64/kernel/syscall.c > +++ b/arch/arm64/kernel/syscall.c > @@ -94,6 +94,8 @@ static void el0_svc_common(struct pt_regs *regs, int > scno, int sc_nr, > const syscall_fn_t syscall_table[]) > { > unsigned long flags = current_thread_info()->flags; > + if (flags & _TIF_MTE_ASYNC_FAULT) > + return; It needs a bit of thinking. This one wouldn't work if you want to handle the signal and resume since it would skip the SVC instruction. We'd need at least to do a regs->pc -= 4 and probably move it further down in this function. -- Catalin