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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 EA8F1C433DB for ; Tue, 23 Feb 2021 11:30:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9C07B64E58 for ; Tue, 23 Feb 2021 11:30:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232273AbhBWL3l (ORCPT ); Tue, 23 Feb 2021 06:29:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230429AbhBWL3h (ORCPT ); Tue, 23 Feb 2021 06:29:37 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B92DC061574; Tue, 23 Feb 2021 03:28:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0jAXGKPxMIw4NpPHuTLsuiFVbiCmr9mViG5BBKJjnuw=; b=VfLZRreiIw1aK3M14fs1IjsWSW ziHle4k1KUsZNqtv23FlrOySa06y3drpyBuCxvN5+5RxPOOVhCIOgZPNs3jW6XOaCYGHLUF0bcax7 YTEOQ+la/CUpnckkcu7ToozwSJk0SgSCNn1w1pCiUduubJnqysWmZIaDgn2uuhi1fzbir9N5X8RMX 4xidvj/60SIwnBBEQqUjK6093P8x9XFZ6wfjIopPMIkNLPrnrcbTJ0AumeTalXiv9n1AI/Hjt9teI eN9QsQTOkuihnoW2vUwsn0zJT+Bamd/ec4l8zzhxsk68peVuQBu+tdqlLANQKRYGzIBF1d5aRWoK9 I+Olr4Iw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lEVs1-007tF7-T4; Tue, 23 Feb 2021 11:28:51 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8334930477A; Tue, 23 Feb 2021 12:28:49 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6A88B2013B7C2; Tue, 23 Feb 2021 12:28:49 +0100 (CET) Date: Tue, 23 Feb 2021 12:28:49 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: x86@kernel.org, LKML , stable@vger.kernel.org Subject: Re: [PATCH 2/3] x86/entry: Fix entry/exit mismatch on failed fast 32-bit syscalls Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 22, 2021 at 09:50:28PM -0800, Andy Lutomirski wrote: > On a 32-bit fast syscall that fails to read its arguments from user > memory, the kernel currently does syscall exit work but not > syscall exit work. This would confuse audit and ptrace. > > This is a minimal fix intended for ease of backporting. A more > complete cleanup is coming. > > Cc: stable@vger.kernel.org > Fixes: 0b085e68f407 ("x86/entry: Consolidate 32/64 bit syscall entry") > Signed-off-by: Andy Lutomirski > --- > arch/x86/entry/common.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c > index 0904f5676e4d..cf4dcf346ca8 100644 > --- a/arch/x86/entry/common.c > +++ b/arch/x86/entry/common.c > @@ -128,7 +128,8 @@ static noinstr bool __do_fast_syscall_32(struct pt_regs *regs) > regs->ax = -EFAULT; > > instrumentation_end(); > - syscall_exit_to_user_mode(regs); > + local_irq_disable(); > + exit_to_user_mode(); > return false; > } I'm confused, twice. Once by your Changelog, and second by the actual patch. Shouldn't every return to userspace pass through exit_to_user_mode_prepare() ? We shouldn't ignore NEED_RESCHED or NOTIFY_RESUME, both of which can be set I think, even if the SYSCALL didn't actually do anything.