Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp641455pxb; Wed, 29 Sep 2021 06:50:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb8nSj+vKsT3m+LoTvvlsndDtzTHSuPWK8vATM50PydQOtsoPt8ePkL3UcEcSfstf4ns2d X-Received: by 2002:a17:90a:6782:: with SMTP id o2mr6573164pjj.165.1632923426433; Wed, 29 Sep 2021 06:50:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632923426; cv=none; d=google.com; s=arc-20160816; b=t99FUrv6Q31/0gdyc2xKNgjsO7baEHfdNBGHGbh87Ptc36eUkvwvuxs2PZueZPmtLh +5CgkwwdSQ+zhvwTZYRvap+6druF4Mz2r9gszJd0fgvk10seHL4Krch6wGkCxhDW7wlX JYBRuJpfoJv+4JoRK+Z6LxngLnDiJtVxpWhjMO8OhxqMyhokKVRTOp8iWgyl4NlmTbLM Fgwfe5mwxw5Hmrd47e+wPGGjSvG58AQB66E2VwzmatHVjAOEU5dYu84Z0vKP0mKX4n++ aoZO8nnYSfbhxUu5aeVmtZoCn+/vTFzBuceyFfIhIa/CG+Oo55AvQMBQKGVQ0IvVdwAc s/Pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=Ia5+kHkS4++Y6p+rvg0YAnIeOPC3mHtqjDWqRi3FYeg=; b=Gr3r8QHLCSw8zUt9z8lAOsnzp4v30PTAj6LKMWWV/75KIVUwnGr7O65BM54AILc5D6 SGkex5nMhiR24JrtcVsIz1tY/3J4hzcabBPBlCeDoAvBZZm6sDt0zg/EVhWjDm3+AMyy JV2hiqJ8yN8xQI3YtXX5dOLVQq7IbHpCT8abLvpGd6mSyMH7ffKRI1qqNcq+Hjixhc7w oCY9a4oK+c0qO2OYSDWa3WAOy9S1MBsHVAxFiwtPD4V93eZaVlIK10hDTHneml9ybQaf 6khfEZqf50jQ15QYDHnEFflcKFBrYr3R32Iu6uooUXGpcSJQJK2MYDf9O/56zfJElNq6 7stg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZwZUGZpo; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id na16si1943722pjb.49.2021.09.29.06.50.10; Wed, 29 Sep 2021 06:50:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=ZwZUGZpo; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344328AbhI2Nv3 (ORCPT + 99 others); Wed, 29 Sep 2021 09:51:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:36058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344315AbhI2Nv2 (ORCPT ); Wed, 29 Sep 2021 09:51:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 774EB61425 for ; Wed, 29 Sep 2021 13:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632923387; bh=gDpL6zIS7P+ehHd52+B4B0jAN5ATz/2k1bTUtMjnyOA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZwZUGZpoQaP/Bzhgs2PtMomNe6Q/XvJfLPfFwnWNOFu8Tb35gJ+ixAPn2zKqN8VOA HlXG18UhW0J5f4z8iwwQy3qWy31BKBp76glUsKQa4VTkrTM1dRSzqDe7U+7JVYdT1l xLvahNRV2IhuQ2eR7k7sKbvB30cvbKdDplQFjOrR0NLVh2PIhODNZONe5dklU9W/7I jEclEkQSUZhJ3m/UCoybe1w0Oy2+JuYK6wfEceMZsdpg4nom2MHu2I6Am8C00/LXWa uMmUB2MAzTJ3aeXpZf2BN3DohYxOiAjmxUnqOggRVS7IkzzbKBOWmy1i4cI9WAFSJe jyKzMaG0fJqpw== From: trondmy@kernel.org To: linux-nfs@vger.kernel.org Subject: [PATCH 5/5] NFS: Fix dentry verifier races Date: Wed, 29 Sep 2021 09:49:44 -0400 Message-Id: <20210929134944.632844-5-trondmy@kernel.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210929134944.632844-4-trondmy@kernel.org> References: <20210929134944.632844-1-trondmy@kernel.org> <20210929134944.632844-2-trondmy@kernel.org> <20210929134944.632844-3-trondmy@kernel.org> <20210929134944.632844-4-trondmy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org From: Trond Myklebust If the directory changed while we were revalidating the dentry, then don't update the dentry verifier. There is no value in setting the verifier to an older value, and we could end up overwriting a more up to date verifier from a parallel revalidation. Fixes: efeda80da38d ("NFSv4: Fix revalidation of dentries with delegations") Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 358033aea235..033e9b145627 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1276,13 +1276,12 @@ static bool nfs_verifier_is_delegated(struct dentry *dentry) static void nfs_set_verifier_locked(struct dentry *dentry, unsigned long verf) { struct inode *inode = d_inode(dentry); + struct inode *dir = d_inode(dentry->d_parent); - if (!nfs_verifier_is_delegated(dentry) && - !nfs_verify_change_attribute(d_inode(dentry->d_parent), verf)) - goto out; + if (!nfs_verify_change_attribute(dir, verf)) + return; if (inode && NFS_PROTO(inode)->have_delegation(inode, FMODE_READ)) nfs_set_verifier_delegated(&verf); -out: dentry->d_time = verf; } -- 2.31.1