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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36577C77B7F for ; Sat, 6 May 2023 17:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229736AbjEFRl1 (ORCPT ); Sat, 6 May 2023 13:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjEFRlZ (ORCPT ); Sat, 6 May 2023 13:41:25 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7584156B2 for ; Sat, 6 May 2023 10:41:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 47FFF60BA6 for ; Sat, 6 May 2023 17:41:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58CAFC433EF; Sat, 6 May 2023 17:41:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1683394883; bh=uCjhesLcsunAx7s5aod9XiUZ78Nv1oXq2yenr1NvgEE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=wsLd1C5HlxgIIVmt4ASrhpcTtCrMHOWkZ7A5kZGgmXequPskUYr5NMOdrSKTiQiXs j0Tt+d8KgWhYrFW5L7vt4X6YlrppLBG00FWLvx+DG3AZr6N8Em6rAgx7edTgnKz9Mp x79j6kLny7YolS9/hayAtU9joGsetEU+1u4BwI8E= Date: Sat, 6 May 2023 10:41:22 -0700 From: Andrew Morton To: Linus Torvalds Cc: "Matthew Wilcox (Oracle)" , Josef Bacik , Johannes Weiner , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Dan Carpenter , syzbot+48011b86c8ea329af1b9@syzkaller.appspotmail.com, Christoph Hellwig Subject: Re: [PATCH] filemap: Handle error return from __filemap_get_folio() Message-Id: <20230506104122.e9ab27f59fd3d8294cb1356d@linux-foundation.org> In-Reply-To: References: <20230506160415.2992089-1-willy@infradead.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sat, 6 May 2023 10:34:31 -0700 Linus Torvalds wrote: > On Sat, May 6, 2023 at 10:10 AM Linus Torvalds > wrote: > > > > .. in the meantime, I did end up applying your patch. > > Final (?) note on this: I not only applied your patch, but went > looking for any other missed cases. > > And found one in fs/nfs/dir.c, which like ext4 had grown a new use of > __filemap_get_folio(). > > But unlike ext4 it hadn't been caught in linux-next (or I had just > missed it) and so I hadn't caught it in my merge either. > > I hope that's the last one. > > I grepped for all these __filemap_get_folio() cases when I did the MM > merge that brought in that change (and did the ext4 merge fixup), but > then the nfs pull happened later and I didn't think to check for new > cases... > > A current grep seems to say that it's all good. But we had all missed > the second check in filemap_fault(), so... > We have a related afs fix which I plan to send over later today: From: Christoph Hellwig Subject: afs: fix the afs_dir_get_folio return value Date: Wed, 3 May 2023 17:45:26 +0200 Keep returning NULL on failure instead of letting an ERR_PTR escape to callers that don't expect it. Link: https://lkml.kernel.org/r/20230503154526.1223095-2-hch@lst.de Fixes: 66dabbb65d67 ("mm: return an ERR_PTR from __filemap_get_folio") Signed-off-by: Christoph Hellwig Reported-by: Jan Kara Reviewed-by: Jan Kara Reviewed-by: David Howells Tested-by: David Howells Cc: Marc Dionne Cc: Matthew Wilcox Signed-off-by: Andrew Morton --- fs/afs/dir_edit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/fs/afs/dir_edit.c~afs-fix-the-afs_dir_get_folio-return-value +++ a/fs/afs/dir_edit.c @@ -115,11 +115,12 @@ static struct folio *afs_dir_get_folio(s folio = __filemap_get_folio(mapping, index, FGP_LOCK | FGP_ACCESSED | FGP_CREAT, mapping->gfp_mask); - if (IS_ERR(folio)) + if (IS_ERR(folio)) { clear_bit(AFS_VNODE_DIR_VALID, &vnode->flags); - else if (folio && !folio_test_private(folio)) + return NULL; + } + if (!folio_test_private(folio)) folio_attach_private(folio, (void *)1); - return folio; } _