From patchwork Thu Nov 17 13:47:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 13046908 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 27C09C4332F for ; Thu, 17 Nov 2022 13:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240034AbiKQNxi (ORCPT ); Thu, 17 Nov 2022 08:53:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240215AbiKQNxY (ORCPT ); Thu, 17 Nov 2022 08:53:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2E4251C39 for ; Thu, 17 Nov 2022 05:53:21 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 9F694B81FB8 for ; Thu, 17 Nov 2022 13:53:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23CA7C433C1 for ; Thu, 17 Nov 2022 13:53:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668693199; bh=nskT2tP8NUFzeSciyMIfLU61mc2ruDj9SW1lHSw0PX0=; h=From:To:Subject:Date:From; b=OEwcX+iWutBdruhAFz20ysu22f5DK2j8ReNaoStT4bgqi46jFPD9+LiT+nPtbPhW/ gNe1KzSEC+DgDOrOF+UWO0DALA/tecVvdil5w9B6gQILhxO4UdcsDMUiiGMIN2N8JA UN2ABWJTkKFDpaYOHMAXJ5YOYfQQ7WixfE0EDwKg5nuOx69hKFOol8TLZhd7JQoe1D /OW5SJWXdJrvNAwHP9lVnF6kmJMT2tzrg0Xs6PGjAXwC6jqUrCYinyKyiHw6KmO3yh 4snmE0FAuS+wFNjEesv3wRujABDTmLVEI/M6Yf+wS5Y1GM8ppsuL+9iNqoqeVVFL/9 h+dPbV6f5wvnQ== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Fix a race in nfs_call_unlink() Date: Thu, 17 Nov 2022 08:47:13 -0500 Message-Id: <20221117134713.9069-2-trondmy@kernel.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust We should check that the filehandles match before transferring the sillyrename data to the newly looked-up dentry in case the name was reused on the server. Signed-off-by: Trond Myklebust --- fs/nfs/unlink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 9697cd5d2561..150a953a8be9 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -139,6 +139,7 @@ static int nfs_call_unlink(struct dentry *dentry, struct inode *inode, struct nf */ spin_lock(&alias->d_lock); if (d_really_is_positive(alias) && + !nfs_compare_fh(NFS_FH(inode), NFS_FH(d_inode(alias))) && !(alias->d_flags & DCACHE_NFSFS_RENAMED)) { devname_garbage = alias->d_fsdata; alias->d_fsdata = data;