Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2183240pxb; Thu, 11 Feb 2021 06:30:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJxcNpYdLfONzaP7riDXeLyFhvRABvA7z0uYWtutfwA9sUn7laN9awoYO0ikrrq8bcd7ouN9 X-Received: by 2002:a17:906:dfce:: with SMTP id jt14mr8831095ejc.345.1613053841110; Thu, 11 Feb 2021 06:30:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613053841; cv=none; d=google.com; s=arc-20160816; b=X8DQaaF2uF4yBj163pqfJPI2tY6q6rIZg1QubY1kEFTYk/MaP5+pCKAR03LV4QuY8Q gCreDQQ56ONOj+lRHfamijdyrPn8Pzg1Tj2FA8Xt9bbiUNb0f/xB4SZmcrmLTIx60Nby dyvB9jp4wh9ccuCSpiVRnPGEwhIM+tAaOUH77rxFzPNYP5NQun17LzRYk0cuqkqidsd+ RdR9u07GtIY1wILeyp892s8ZE8QEsoUbWsCdPi71JVJ9Lv+9Fe2pv66djX2eDZ44mhWy 6G1RFUcGroBGjWn+J21NA8VWhKkwayuTsgyKHVl9KK433O65pAcoHhqFd68idiV58Tbm jbuw== 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=sj97A1FDFENPqakt33g1HE1eopZz9zZrknGdche1pZw=; b=JkQpir1wALhvdjkLQo0ZUFAvQZMsxcN467foW6ifRdTLY5vUHqVl2Ojx1cfCB+sIbz 4C/lzJULGfZcCQ478+b9XxZgKRR3NAyQ/fl/WCbkvrry2EdONe3eGfpU8gjfQFPEXks8 fbMPVq1b2+J2qCtzXkDEx40P0ePwxj1jk+8XUzIzsiJeYuK6YzPiG1XLHgN2Ec9bkMFh hSDjNa6NIYSm1UsaGTTi38rd1QfvgM3WI+znabJduixKReNXE66gDn3n99C9zQebKejZ yW1r75lBWDg8MsJjTTC427sNHcBkTGak6VvzQMvx2RxCaHLL8ZNspYDUz2urlVNDn7ps eavA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=UI6wmsC6; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 d16si3951750edy.432.2021.02.11.06.30.14; Thu, 11 Feb 2021 06:30:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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=UI6wmsC6; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229531AbhBKO32 (ORCPT + 99 others); Thu, 11 Feb 2021 09:29:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230465AbhBKO1S (ORCPT ); Thu, 11 Feb 2021 09:27:18 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5F9C061786; Thu, 11 Feb 2021 06:26:36 -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=sj97A1FDFENPqakt33g1HE1eopZz9zZrknGdche1pZw=; b=UI6wmsC6f1Q37cjg5BZyBtHJK1 NgBK1KBg3ulPKm84h15eY0H938wnq0Ps9/n1u9LO7MNAuB8dO2cSNpEsRRGDMnSFSVqPjkNQNPkxQ 0s3dUvDykwFUiS1JgCJvm9e83li1rD3un+G12IdJuH2TPjsskW09hILEgrzLpZez7Nyo+r+e2IkD5 xlwul7xkjZAaGtyb8wdEeFwtQaxMKvgVHg3kXLgpz+OWYfTLS4C0Z1po7Fu92QncBpomMIfF2bUjB vVua5Xbw/7u3/EQ/EuCk1PZMqColbfywnDrrRYdO1PmfjzL9XrUbQJX3nWlH7RtmE70CjbeveXerQ XvSyGqLA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lACvO-00ALJC-39; Thu, 11 Feb 2021 14:26:31 +0000 Date: Thu, 11 Feb 2021 14:26:30 +0000 From: Matthew Wilcox To: Michal Hocko Cc: Jan Kara , Dmitry Vyukov , syzbot , Jan Kara , linux-ext4@vger.kernel.org, LKML , syzkaller-bugs , Theodore Ts'o , Linux-MM Subject: Re: possible deadlock in start_this_handle (2) Message-ID: <20210211142630.GK308988@casper.infradead.org> References: <000000000000563a0205bafb7970@google.com> <20210211104947.GL19070@quack2.suse.cz> <20210211121020.GO19070@quack2.suse.cz> <20210211125717.GH308988@casper.infradead.org> <20210211132533.GI308988@casper.infradead.org> 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-ext4@vger.kernel.org On Thu, Feb 11, 2021 at 03:20:41PM +0100, Michal Hocko wrote: > On Thu 11-02-21 13:25:33, Matthew Wilcox wrote: > > On Thu, Feb 11, 2021 at 02:07:03PM +0100, Michal Hocko wrote: > > > On Thu 11-02-21 12:57:17, Matthew Wilcox wrote: > > > > > current->flags should be always manipulated from the user context. But > > > > > who knows maybe there is a bug and some interrupt handler is calling it. > > > > > This should be easy to catch no? > > > > > > > > Why would it matter if it were? > > > > > > I was thinking about a clobbered state because updates to ->flags are > > > not atomic because this shouldn't ever be updated concurrently. So maybe > > > a racing interrupt could corrupt the flags state? > > > > I don't think that's possible. Same-CPU races between interrupt and > > process context are simpler because the CPU always observes its own writes > > in order and the interrupt handler completes "between" two instructions. > > I have to confess I haven't really thought the scenario through. My idea > was to simply add a simple check for an irq context into ->flags setting > routine because this should never be done in the first place. Not only > for scope gfp flags but any other PF_ flags IIRC. That's not automatically clear to me. There are plenty of places where an interrupt borrows the context of the task that it happens to have interrupted. Specifically, interrupts should be using GFP_ATOMIC anyway, so this doesn't really make a lot of sense, but I don't think it's necessarily wrong for an interrupt to call a function that says "Definitely don't make GFP_FS allocations between these two points".