Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1592827rdb; Mon, 2 Oct 2023 14:45:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF5lMEKE8n3lH/7x3/8MTSt5onSLlH0ClXuRTq9rfcie2GZP1kscgC7BsnvMmNQ/HFU3Qrp X-Received: by 2002:a81:54d7:0:b0:595:2094:f87 with SMTP id i206-20020a8154d7000000b0059520940f87mr11646093ywb.47.1696283111001; Mon, 02 Oct 2023 14:45:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696283110; cv=none; d=google.com; s=arc-20160816; b=z0zF/7FjRdob+Ni+4ZD4jVvin1xqsZr14vBZ37DA0cqK8ifD9RNXhwwOFtY920DW3q 2cPfPfIdiyfuUMwozoUmy47+Izo/Prf+42NuqpPitSiLTJoUuMq0u1jRxfJlNGfHD7xm Fh6dQvNvf4wImp3R5SnFAQYqMaDzxkKeblOqOpDQCuUS3KqgbDCPA1qi7DtXz9kIiD6W 6Sgy6FkAXyeMCgbjo+zuWOoLeeU8Tih7wtWXAjjwLs0aOwbP/UpGVmwBvLiBEWoCiPsk 6Q6gklUWph8odu/cUwQcfwo83kxaBtQoLFkyUge3kUUE5WUBcSGqTUkeqPevPnuCq9eK ZSdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=wrZQ3H7iYtHM5XHpxzu9V90wEPR401WhmQTPhk5oPTg=; fh=POmI5HOZf4EB3F6TFxP5Ul3XS6ur8+A7rRkPsbuzjBY=; b=vd+YY/Fs9Fn4zDFXO9QUeO8EZ7bbxz1AHtB6u7dae/fcEWn9tvjyaEqFhO4zJNpWh1 XTK+espn7084Kr2tLvD6t85eYTnlwvLZNIXsbYdukzEu7l6S98lAf5JIT86w2eB/HZUZ QPFiZImu6TJE/oE3y7Wh/uPPcbvLXWYI/2Ev0TWehA0u2lHyYKPGRNMS5NhVSjNTZn/M vTVVUDzWoPiSzijyD/Svz3lWqYpRwa7II+rSGdg0QfOHfuptHXqXCxEWIUbRDZNaQMIz GimrWc6gCmmqGtnpH+UExNym+PL5x9MaOncg6doAAU5bmiO/ZNtq3/iM/TAZ3pm4iT8q 3R9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nall0DUE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id pi4-20020a17090b1e4400b00262e99964bdsi9548802pjb.99.2023.10.02.14.45.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 14:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nall0DUE; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id D7BFD812D22A; Mon, 2 Oct 2023 13:29:57 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235575AbjJBU3w (ORCPT + 99 others); Mon, 2 Oct 2023 16:29:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236118AbjJBU3v (ORCPT ); Mon, 2 Oct 2023 16:29:51 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E5C5D9 for ; Mon, 2 Oct 2023 13:29:48 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 932C1C433C7; Mon, 2 Oct 2023 20:29:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696278588; bh=naQ/y/qKI3wU5gJ4xQwYSxikkTJguhkfVKwnb7t4n8k=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=Nall0DUE+vd5bbSHWTyauQISJ+V13dLpliXI3ZOffJst3CNu2qiBhZP4bW01O6Ve+ dUioItRWkv5qI7M8Z0n+2iqpkgmGMoLGRXCbpPd38oW+3m0yxubvSmM1vV7bZGR9Gf 4K3YyNUSh/R+fkheRIDq9Dgptc/bkF2Y8w6wv13jddL0KM1c3anD0xTIIVfbe81q78 3uprlU5CZ3AxGMEYqmyCq2g1o4q0KqLAbNDUqNS1ifUo50v1re/C1ssWdDvDVJC4Xb c4N2Z/oWH2sXKCYSSeEe2PBox0RJik9sC7uzr5tQ2/m80dmD8XF1PZctlxhRmE9Nsg dMHl9/JFiL7wA== Message-ID: Subject: Re: [PATCH 1/1] NFS: Fix potential oops in nfs_inode_remove_request() From: Jeff Layton To: Scott Mayhew , trond.myklebust@hammerspace.com, anna@kernel.org Cc: linux-nfs@vger.kernel.org Date: Mon, 02 Oct 2023 16:29:46 -0400 In-Reply-To: <20230725150807.8770-2-smayhew@redhat.com> References: <20230725150807.8770-1-smayhew@redhat.com> <20230725150807.8770-2-smayhew@redhat.com> Content-Type: text/plain; charset="ISO-8859-15" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.48.4 (3.48.4-1.fc38) MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 02 Oct 2023 13:29:58 -0700 (PDT) On Tue, 2023-07-25 at 11:08 -0400, Scott Mayhew wrote: > Once a folio's private data has been cleared, it's possible for another > process to clear the folio->mapping (e.g. via invalidate_complete_folio2 > or evict_mapping_folio), so it wouldn't be safe to call > nfs_page_to_inode() after that. >=20 > Fixes: 0c493b5cf16e ("NFS: Convert buffered writes to use folios") > Signed-off-by: Scott Mayhew > --- > fs/nfs/write.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/fs/nfs/write.c b/fs/nfs/write.c > index f4cca8f00c0c..489c3f9dae23 100644 > --- a/fs/nfs/write.c > +++ b/fs/nfs/write.c > @@ -785,6 +785,8 @@ static void nfs_inode_add_request(struct nfs_page *re= q) > */ > static void nfs_inode_remove_request(struct nfs_page *req) > { > + struct nfs_inode *nfsi =3D NFS_I(nfs_page_to_inode(req)); > + > if (nfs_page_group_sync_on_bit(req, PG_REMOVE)) { > struct folio *folio =3D nfs_page_to_folio(req->wb_head); > struct address_space *mapping =3D folio_file_mapping(folio); > @@ -800,7 +802,7 @@ static void nfs_inode_remove_request(struct nfs_page = *req) > =20 > if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) { > nfs_release_request(req); > - atomic_long_dec(&NFS_I(nfs_page_to_inode(req))->nrequests); > + atomic_long_dec(&nfsi->nrequests); > } > } > =20 Reviewed-by: Jeff Layton