Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2399465pxb; Tue, 23 Feb 2021 06:18:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJy622JZbbWOrVQzuSo1aPPAeorChWAZi+TQZdpT0e4GlRX0+T5GlP1PMK09gkUFUgu5DeY/ X-Received: by 2002:a50:d9cc:: with SMTP id x12mr28787440edj.68.1614089909507; Tue, 23 Feb 2021 06:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614089909; cv=none; d=google.com; s=arc-20160816; b=hGIUKWJ1eQUTyT1S61YBEnOdHPOaAGEOfyDu0fiAk9w4vavHitCSOn6Fb3TpJKkxZW mCaQ4xRO170s2Rfypq0PPdx1zJtuqVqlZSsOMnstA+r5HlBlImN9xvEKBt1S/a5KgfdJ epWtKyyBsmpZt+cx/dEhCQGN8BKNpWLd6SWYIg/cLdKLA1iZoyLDWQBPHvmvjG+BbRtC 2QiQzS60XcjSPOB7p8et/EqhZSN0vf1+CJjnwtt+LgrGSU1YKxOpDuSO65h7MLnup2xm yZaaLRrHmakLyYDHB82ueJjWye03qcGqu4uIA0TytpfAB9gjQawwqmbQGsy6IykNmat4 EXRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0jAXGKPxMIw4NpPHuTLsuiFVbiCmr9mViG5BBKJjnuw=; b=dkmFcl/ZolLuOB1HDQmBmDnO7IksYTaMo+NUz9I6baXCyObj9wOOk6JNNpvRRDE+P5 T7bPLl2/LK4DzQsnJHsBHt64oet8L9VJ5txt96QYLz1mNS2xf8kHI9zXPJQ2OJMkhVIF mFG+zHmF5eJURiQag47wwzJkj/tQj32RNWZ3Unvj1NiOLAjtDYZTDa4NnqjSUyu9x1mS LBMDwlv5tyzjF42trIWHEI+W2IMbkgEB4AUEpv4xSDzWjxatV1UP4tHsKg242P12lqB6 evagac/uTPCDXb12suY3S6kr4Y8eOzBvb0mYAFp1524ifEi+GssvbHEzJ00EYDr/j5lZ chAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VfLZRrei; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g21si7342259ejr.703.2021.02.23.06.18.04; Tue, 23 Feb 2021 06:18:29 -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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=VfLZRrei; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232172AbhBWL3i (ORCPT + 99 others); Tue, 23 Feb 2021 06:29:38 -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.