From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de ([195.135.220.15]:50765 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752748AbdK2CGm (ORCPT ); Tue, 28 Nov 2017 21:06:42 -0500 From: NeilBrown To: gregkh@linuxfoundation.org, Anna.Schumaker@Netapp.com Date: Wed, 29 Nov 2017 13:06:35 +1100 Cc: stable@vger.kernel.org Subject: Re: FAILED: patch "[PATCH] NFS: revalidate "." etc correctly on "open"." failed to apply to 3.18-stable tree In-Reply-To: <1511796032118218@kroah.com> References: <1511796032118218@kroah.com> Message-ID: <874lpdyh1w.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: stable-owner@vger.kernel.org List-ID: --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Subject: [PATCH] NFS: revalidate "." etc correctly on "open". commit b688741cb06695312f18b730653d6611e1bad28d upstream. For correct close-to-open semantics, NFS must validate the change attribute of a directory (or file) on open. Since commit ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op"), open() of "." or a path ending ".." is not revalidated reliably (except when that direct is a mount point). Prior to that commit, "." was revalidated using nfs_lookup_revalidate() which checks the LOOKUP_OPEN flag and forces revalidation if the flag is set. Since that commit, nfs_weak_revalidate() is used for NFSv3 (which ignores the flags) and nothing is used for NFSv4. This is fixed by using nfs_lookup_verify_inode() in nfs_weak_revalidate(). This does the revalidation exactly when needed. Also, add a definition of .d_weak_revalidate for NFSv4. The incorrect behavior is easily demonstrated by running "echo *" in some non-mountpoint NFS directory while watching network traffic. Without this patch, "echo *" sometimes doesn't produce any traffic. With the patch it always does. Fixes: ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate = dentry op") cc: stable@vger.kernel.org (3.9+) Signed-off-by: NeilBrown Signed-off-by: Anna Schumaker =2D-- fs/nfs/dir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) This version applies to 3.18.y 4.4.y and 4.9.y Thanks, NeilBrown diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index d04ec3814779..65566d5fcf39 100644 =2D-- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -1292,7 +1292,7 @@ static int nfs_weak_revalidate(struct dentry *dentry,= unsigned int flags) return 0; } =20 =2D error =3D nfs_revalidate_inode(NFS_SERVER(inode), inode); + error =3D nfs_lookup_verify_inode(inode, flags); dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n", __func__, inode->i_ino, error ? "invalid" : "valid"); return !error; @@ -1443,6 +1443,7 @@ static int nfs4_lookup_revalidate(struct dentry *, un= signed int); =20 const struct dentry_operations nfs4_dentry_operations =3D { .d_revalidate =3D nfs4_lookup_revalidate, + .d_weak_revalidate =3D nfs_weak_revalidate, .d_delete =3D nfs_dentry_delete, .d_iput =3D nfs_dentry_iput, .d_automount =3D nfs_d_automount, =2D-=20 2.14.0.rc0.dirty --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAloeFisACgkQOeye3VZi gbkJyg/9EvOToIrR5OGYGAsxJYnZ7xlQA9g4eBkKbSWu2GjQo0whLEw8hRRipSFd yH2TV80dh/YYP4dCyF3CH7mB4mrremD1sdgl1HC9Ap0FOW/UohW3Hwy8nj03FM2O hqCMfGgA/KWTVFf9jn7HdunTWUzg1O1bPYgA5yn6GkzzDGL8xkgaW0P+jTnsCFS2 OAakXlrbEMgP69b26G48FM3T0dXnLgCp2HU8F4/kJ6gmNe0blV3Knm2vx/dtZ/PY /2D9v/DWzroxo9aOP7aGjKnCpWjxxNlw5YQkacKPnlszhN/Wepxmo4RvczjwsZjH mVhhQ9ZawHhwdnT93Y0IfYl6uTbzGd/BxYdDROWmyVph3fXkjKk7NG2amMpiyycp RyzUOo/cyscUjTwKmhsOkmXQGL/hZCITAAyp5mCUTSiOFHGBdnr8DP/SthEF4dri HHeZUBUhO6kigMce31Vzm6HAmdNGkgP1USLCJf2RLwLngOuvv08Gi0Hn1q0c7mS3 Lx9VAbRukqce2GPxlzOKAqhT1JvCrewhHPTLN8RStviwTcrd53IS1XqVufhvF9xd 3/MPYCjalFr4kYulLe2JDy+VD6z3ACVDq+9gCCJFrCqxwYbnnlAzbFUbHQdXx+kh viCAyY2eFzyTghCxOoulLxo3+bscOk5f8oOPtuOUQd/kz31EqWQ= =riEo -----END PGP SIGNATURE----- --=-=-=--