From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32D931DFF5 for ; Fri, 9 Aug 2024 12:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723206885; cv=none; b=s2GwrppCo1GUw/lh0+N6Se9WS4O+j5+SYMwYPmrwkCiPli1+feZaKofS0Cu8p3bPLNb7r8V/0uF1GOHt9tzNj9pXkrmMSYVgTalvoRFqX3Wn62C2wP8RGxvX6xLqkUvesA0pzXuiTCfQfjoVAJv5k6D8uR7JVZoy2Qln4dZFswE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723206885; c=relaxed/simple; bh=rUYCqkE9wgipaqoEp9/tM8dZU2PomIa2q+KTfmbqPoE=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=fMaAva6LEMhkzkjo02NhPCO9hkBLCfZif99olOYM5n/j/M2IfMeZl+zoQKBHe+XfVOq96ndMUROrK9XEYNsxqUF0pJiP9o17PIFAeQb30HRR36ap8+73SoHLqEEcmZaUj+LmJ5zigwvo3wlkS7pTfTFQqrw4BXZMQAKhimpQJQg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OT+5m9Ca; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OT+5m9Ca" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A872C32782; Fri, 9 Aug 2024 12:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1723206884; bh=rUYCqkE9wgipaqoEp9/tM8dZU2PomIa2q+KTfmbqPoE=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=OT+5m9Cao6XWSNUYNKpe/mSINXUkwkITpzrAQFQ19b+ioClfNqvpaW/SaYwoFKu7O LAeeXW3fGMhY/clhvVdn0PUpIG9d/oVadLfCY1k0ELIrL+e72pXj/Gp2OfuEJqnLtu TXATk/F+brq9/AK4aG2KN/Z/sSNq7UXwPJ2E48xVKjEcWh40zrWF9YecKhPB2WVaQS 5Dfruypd3B9/iCsJDfrN3yN1SXzZBUv24jAXPlaUrZr9TcmX1581DuTEoliIyjQnhy 9ZSTqo+5SsFzQlBRr12UEX3rPk+h+8LBYGrCEP+0t1lThUCN7fV8+F9oClKJqXlChl 63HiP2eNwq2gQ== Message-ID: <6da76065c364e3585f89b13e57f9727ffd59ef3f.camel@kernel.org> Subject: Re: [PATCH 3/3] nfsd: move error choice for incorrect object types to version-specific code. From: Jeff Layton To: NeilBrown Cc: Chuck Lever , linux-nfs@vger.kernel.org, Olga Kornievskaia , Dai Ngo , Tom Talpey Date: Fri, 09 Aug 2024 08:34:43 -0400 In-Reply-To: <172315440855.6062.9482773808089698009@noble.neil.brown.name> References: <>, <2f37c577c26c69f23345153576b2e1270115d63d.camel@kernel.org> <172315440855.6062.9482773808089698009@noble.neil.brown.name> Autocrypt: addr=jlayton@kernel.org; prefer-encrypt=mutual; keydata=mQINBE6V0TwBEADXhJg7s8wFDwBMEvn0qyhAnzFLTOCHooMZyx7XO7dAiIhDSi7G1NPxw n8jdFUQMCR/GlpozMFlSFiZXiObE7sef9rTtM68ukUyZM4pJ9l0KjQNgDJ6Fr342Htkjxu/kFV1Wv egyjnSsFt7EGoDjdKqr1TS9syJYFjagYtvWk/UfHlW09X+jOh4vYtfX7iYSx/NfqV3W1D7EDi0PqV T2h6v8i8YqsATFPwO4nuiTmL6I40ZofxVd+9w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CliEco5DwhpaaSnzWnbAPXhQDWb/lUgs/JNk8dtwmvWnqCwRqElMLVisAbJmC0 BhZ/Ab4sph3EaiZfdXKhiQqSGdK4La3OTJOJYZphPdGgnkvDV9Pl1QZ0ijXQrVIy3zd6VCNaKYq7B AKidn5g/2Q8oio9Tf4XfdZ9dtwcB+bwDJFgvvDYaZ5bI3ln4V3EyW5i2NfXazz/GA/I/ZtbsigCFc 8ftCBKZWZmIExheXRvbiA8amxheXRvbkBrZXJuZWwub3JnPokCOAQTAQIAIgUCWe8u6AIbAwYLCQg HAwIGFQgCCQoLBBYCAwECHgECF4AACgkQAA5oQRlWghUuCg/+Lb/xGxZD2Q1oJVAE37uW308UpVSD 2tAMJUvFTdDbfe3zKlPDTuVsyNsALBGclPLagJ5ZTP+Vp2irAN9uwBuacBOTtmOdz4ZN2tdvNgozz uxp4CHBDVzAslUi2idy+xpsp47DWPxYFIRP3M8QG/aNW052LaPc0cedYxp8+9eiVUNpxF4SiU4i9J DfX/sn9XcfoVZIxMpCRE750zvJvcCUz9HojsrMQ1NFc7MFT1z3MOW2/RlzPcog7xvR5ENPH19ojRD CHqumUHRry+RF0lH00clzX/W8OrQJZtoBPXv9ahka/Vp7kEulcBJr1cH5Wz/WprhsIM7U9pse1f1g Yy9YbXtWctUz8uvDR7shsQxAhX3qO7DilMtuGo1v97I/Kx4gXQ52syh/w6EBny71CZrOgD6kJwPVV AaM1LRC28muq91WCFhs/nzHozpbzcheyGtMUI2Ao4K6mnY+3zIuXPygZMFr9KXE6fF7HzKxKuZMJO aEZCiDOq0anx6FmOzs5E6Jqdpo/mtI8beK+BE7Va6ni7YrQlnT0i3vaTVMTiCThbqsB20VrbMjlhp f8lfK1XVNbRq/R7GZ9zHESlsa35ha60yd/j3pu5hT2xyy8krV8vGhHvnJ1XRMJBAB/UYb6FyC7S+m QZIQXVeAA+smfTT0tDrisj1U5x6ZB9b3nBg65kc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.52.3 (3.52.3-1.fc40app2) Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2024-08-09 at 08:00 +1000, NeilBrown wrote: > On Thu, 08 Aug 2024, Jeff Layton wrote: > > On Thu, 2024-08-08 at 21:40 +1000, NeilBrown wrote: > > > On Thu, 08 Aug 2024, Jeff Layton wrote: > > > > On Mon, 2024-07-29 at 11:47 +1000, NeilBrown wrote: > > > > > If an NFS operation expect a particular sort of object (file, dir= , link, > > > > > etc) but gets a file handle for a different sort of object, it mu= st > > > > > return an error. The actual error varies among version in no-tri= vial > > > > > ways. > > > > >=20 > > > > > For v2 and v3 there are ISDIR and NOTDIR errors, and for any else= , only > > > > > INVAL is suitable. > > > > >=20 > > > > > For v4.0 there is also NFS4ERR_SYMLINK which should be used if a = SYMLINK > > > > > was found when not expected. This take precedence over NOTDIR. > > > > >=20 > > > > > For v4.1+ there is also NFS4ERR_WRONG_TYPE which should be used i= n > > > > > preference to EINVAL when none of the specific error codes apply. > > > > >=20 > > > > > When nfsd_mode_check() finds a symlink where it expect a director= y it > > > > > needs to return an error code that can be converted to NOTDIR for= v2 or > > > > > v3 but will be SYMLINK for v4. It must be different from the err= or > > > > > code returns when it finds a symlink but expects a regular file -= that > > > > > must be converted to EINVAL or SYMLINK. > > > > >=20 > > > > > So we introduce an internal error code nfserr_symlink_not_dir whi= ch each > > > > > version converts as appropriate. > > > > >=20 > > > > > We also allow nfserr_wrong_type to be returned by > > > > > nfsd_check_obj_is_reg() in nfsv4 code) and nfsd_mode_check(). Th= is a > > > > > behavioural change as nfsd_check_obj_is_reg() would previously re= turn > > > > > nfserr_symiink for non-directory objects that aren't regular file= s. Now > > > > > it will return nfserr_wrong_type for objects that aren't regular, > > > > > directory, symlink (so char-special, block-special, sockets), whi= ch is > > > > > mapped to nfserr_inval for NFSv4.0. This should not be a problem= as the > > > > > behaviour is supported by RFCs. > > > > >=20 > > > > > As a result of these changes, nfsd_mode_check() doesn't need an r= qstp > > > > > arg any more. > > > > >=20 > > > > > Signed-off-by: NeilBrown > > > > > --- > > > > > fs/nfsd/nfs3proc.c | 8 ++++++++ > > > > > fs/nfsd/nfs4proc.c | 24 ++++++++++++++++-------- > > > > > fs/nfsd/nfsd.h | 5 +++++ > > > > > fs/nfsd/nfsfh.c | 16 +++++++--------- > > > > > fs/nfsd/nfsproc.c | 7 +++++++ > > > > > 5 files changed, 43 insertions(+), 17 deletions(-) > > > > >=20 > > > > > diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c > > > > > index 31bd9bcf8687..ac7ee24415a3 100644 > > > > > --- a/fs/nfsd/nfs3proc.c > > > > > +++ b/fs/nfsd/nfs3proc.c > > > > > @@ -38,6 +38,14 @@ static __be32 map_status(__be32 status) > > > > > case nfserr_file_open: > > > > > status =3D nfserr_acces; > > > > > break; > > > > > + > > > > > + case nfserr_symlink_not_dir: > > > > > + status =3D nfserr_notdir; > > > > > + break; > > > > > + case nfserr_symlink: > > > > > + case nfserr_wrong_type: > > > > > + status =3D nfserr_inval; > > > > > + break; > > > > > } > > > > > return status; > > > > > } > > > > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > > > > > index 46bd20fe5c0f..cc715438e77a 100644 > > > > > --- a/fs/nfsd/nfs4proc.c > > > > > +++ b/fs/nfsd/nfs4proc.c > > > > > @@ -166,14 +166,9 @@ static __be32 nfsd_check_obj_isreg(struct sv= c_fh *fh) > > > > > return nfs_ok; > > > > > if (S_ISDIR(mode)) > > > > > return nfserr_isdir; > > > > > - /* > > > > > - * Using err_symlink as our catch-all case may look odd; but > > > > > - * there's no other obvious error for this case in 4.0, and we > > > > > - * happen to know that it will cause the linux v4 client to do > > > > > - * the right thing on attempts to open something other than a > > > > > - * regular file. > > > > > - */ > > > > > - return nfserr_symlink; > > > > > + if (S_ISLNK(mode)) > > > > > + return nfserr_symlink; > > > > > + return nfserr_wrong_type; > > > > > } > > > > > =20 > > > > > static void nfsd4_set_open_owner_reply_cache(struct nfsd4_compou= nd_state *cstate, struct nfsd4_open *open, struct svc_fh *resfh) > > > > > @@ -184,6 +179,17 @@ static void nfsd4_set_open_owner_reply_cache= (struct nfsd4_compound_state *cstate > > > > > &resfh->fh_handle); > > > > > } > > > > > =20 > > > > > +static __be32 map_status(__be32 status, int minor) > > > > > +{ > > > > > + if (status =3D=3D nfserr_wrong_type && > > > > > + minor =3D=3D 0) > > > > > + /* RFC5661 - 15.1.2.9 */ > > > > > + status =3D nfserr_inval; > > > > > + > > > > > + if (status =3D=3D nfserr_symlink_not_dir) > > > > > + status =3D nfserr_symlink; > > > > > + return status; > > > > > +} > > > > > static inline bool nfsd4_create_is_exclusive(int createmode) > > > > > { > > > > > return createmode =3D=3D NFS4_CREATE_EXCLUSIVE || > > > > > @@ -2798,6 +2804,8 @@ nfsd4_proc_compound(struct svc_rqst *rqstp) > > > > > nfsd4_encode_replay(resp->xdr, op); > > > > > status =3D op->status =3D op->replay->rp_status; > > > > > } else { > > > > > + op->status =3D map_status(op->status, > > > > > + cstate->minorversion); > > > > > nfsd4_encode_operation(resp, op); > > > > > status =3D op->status; > > > > > } > > > > > diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h > > > > > index 593c34fd325a..3c8c8da063b0 100644 > > > > > --- a/fs/nfsd/nfsd.h > > > > > +++ b/fs/nfsd/nfsd.h > > > > > @@ -349,6 +349,11 @@ enum { > > > > > NFSERR_REPLAY_CACHE, > > > > > #define nfserr_replay_cache cpu_to_be32(NFSERR_REPLAY_CACHE) > > > > > =20 > > > > > +/* symlink found where dir expected - handled differently to > > > > > + * other symlink found errors by NFSv3. > > > > > + */ > > > > > + NFSERR_SYMLINK_NOT_DIR, > > > > > +#define nfserr_symlink_not_dir cpu_to_be32(NFSERR_SYMLINK_NOT_DI= R) > > > > > }; > > > > > =20 > > > > > /* Check for dir entries '.' and '..' */ > > > > > diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c > > > > > index 0130103833e5..8cd70f93827c 100644 > > > > > --- a/fs/nfsd/nfsfh.c > > > > > +++ b/fs/nfsd/nfsfh.c > > > > > @@ -62,8 +62,7 @@ static int nfsd_acceptable(void *expv, struct d= entry *dentry) > > > > > * the write call). > > > > > */ > > > > > static inline __be32 > > > > > -nfsd_mode_check(struct svc_rqst *rqstp, struct dentry *dentry, > > > > > - umode_t requested) > > > > > +nfsd_mode_check(struct dentry *dentry, umode_t requested) > > > > > { > > > > > umode_t mode =3D d_inode(dentry)->i_mode & S_IFMT; > > > > > =20 > > > > > @@ -76,17 +75,16 @@ nfsd_mode_check(struct svc_rqst *rqstp, struc= t dentry *dentry, > > > > > } > > > > > return nfs_ok; > > > > > } > > > > > - /* > > > > > - * v4 has an error more specific than err_notdir which we shoul= d > > > > > - * return in preference to err_notdir: > > > > > - */ > > > > > - if (rqstp->rq_vers =3D=3D 4 && mode =3D=3D S_IFLNK) > > > > > + if (mode =3D=3D S_IFLNK) { > > > > > + if (requested =3D=3D S_IFDIR) > > > > > + return nfserr_symlink_not_dir; > > > > > return nfserr_symlink; > > > > > + } > > > > > if (requested =3D=3D S_IFDIR) > > > > > return nfserr_notdir; > > > > > if (mode =3D=3D S_IFDIR) > > > > > return nfserr_isdir; > > > > > - return nfserr_inval; > > > > > + return nfserr_wrong_type; > > > > > } > > > > > =20 > > > > > static bool nfsd_originating_port_ok(struct svc_rqst *rqstp, int= flags) > > > > > @@ -362,7 +360,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_= fh *fhp, umode_t type, int access) > > > > > if (error) > > > > > goto out; > > > > > =20 > > > > > - error =3D nfsd_mode_check(rqstp, dentry, type); > > > > > + error =3D nfsd_mode_check(dentry, type); > > > > > if (error) > > > > > goto out; > > > > > =20 > > > > > diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c > > > > > index cb7099c6dc78..3d65ab558091 100644 > > > > > --- a/fs/nfsd/nfsproc.c > > > > > +++ b/fs/nfsd/nfsproc.c > > > > > @@ -25,6 +25,13 @@ static __be32 map_status(__be32 status) > > > > > case nfserr_file_open: > > > > > status =3D nfserr_acces; > > > > > break; > > > > > + case nfserr_symlink_not_dir: > > > > > + status =3D nfserr_notdir; > > > > > + break; > > > > > + case nfserr_symlink: > > > > > + case nfserr_wrong_type: > > > > > + status =3D nfserr_inval; > > > > > + break; > > > > > } > > > > > return status; > > > > > } > > > >=20 > > > > Hi Neil, > > > >=20 > > > > I'm seeing a set of failures in pynfs with this patch (json results > > > > attached). I haven't looked in detail yet, but we should probably d= rop > > > > this one for now. > > >=20 > > > Most of the complaints are because pynfs is expecting the incorrect > > > error code that nfsd currently returns, rather than the correct one t= hat > > > my patch makes it return. > > >=20 > > > There is one where the internal error code of 10101 leaks out. That = is > > > NFSERR_SYMLNK_NOT_DIR. > > > That certainly requires investigation. > > >=20 > >=20 > > I'm not sure these error code changes are correct, now that I look. For > > instance: > >=20 > > { > > "classname": "st_readlink", > > "code": "RDLK2r", > > "failure": { > > "err": "Traceback (most recent call last):\n File \"/d= ata/pynfs/nfs4.0/lib/testmod.py\", line 234, in run\n self.runtest(self,= environment)\n File \"/data/pynfs/nfs4.0/servertests/st_readlink.py\", li= ne 29, in testFile\n check(res, NFS4ERR_INVAL, \"READLINK on non-symlink= objects\")\n File \"/data/pynfs/nfs4.0/servertests/environment.py\", line= 270, in check\n raise testmod.FailureException(msg)\ntestmod.FailureExc= eption: READLINK on non-symlink objects should return NFS4ERR_INVAL, instea= d got NFS4ERR_WRONG_TYPE\n", > > "message": "READLINK on non-symlink objects should retu= rn NFS4ERR_INVAL, instead got NFS4ERR_WRONG_TYPE" > > }, > > "name": "testFile", > > "time": "0.003440380096435547" > > }, > >=20 > >=20 > > Looking at RFC7530, the READLINK section (16.25.5) says: > >=20 > > The READLINK operation is only allowed on objects of type NF4LNK. > > The server should return the error NFS4ERR_INVAL if the object is no= t > > of type NF4LNK. >=20 > RFC7530 is for NFSv4.0 It doesn't have NFS4ERR_WRONG_TYPE. So if this > is a 4.0 test then that is indeed a bug. If the "nfs4.0" in the File > path the only hit that this was 4.0 rather than 4.1? > (RFC8881 declares this should be NFS4ERR_WRONG_TYPE for 4.1) >=20 This was a v4.0 pynfs run, so yes it appears this was leaking out somewhere. > >=20 > > Several OPEN cases have errors similar to this one: > >=20 > > { > > "classname": "st_open", > > "code": "OPEN7s", > > "failure": { > > "err": "Traceback (most recent call last):\n File \"/d= ata/pynfs/nfs4.0/lib/testmod.py\", line 234, in run\n self.runtest(self,= environment)\n File \"/data/pynfs/nfs4.0/servertests/st_open.py\", line 1= 83, in testSocket\n check(res, NFS4ERR_SYMLINK, \"Trying to OPEN socket\= ")\n File \"/data/pynfs/nfs4.0/servertests/environment.py\", line 270, in = check\n raise testmod.FailureException(msg)\ntestmod.FailureException: T= rying to OPEN socket should return NFS4ERR_SYMLINK, instead got NFS4ERR_INV= AL\n", > > "message": "Trying to OPEN socket should return NFS4ERR= _SYMLINK, instead got NFS4ERR_INVAL" > > }, > > "name": "testSocket", > > "time": "0.006421566009521484" > > }, > >=20 > > RFC7530, 16.16.6: > >=20 > > If the component provided to OPEN resolves to something other than a > > regular file (or a named attribute), an error will be returned to th= e > > client. If it is a directory, NFS4ERR_ISDIR is returned; otherwise, > > NFS4ERR_SYMLINK is returned. Note that NFS4ERR_SYMLINK is returned > > for both symlinks and for special files of other types; NFS4ERR_INVA= L > > would be inappropriate, since the arguments provided by the client > > were correct, and the client cannot necessarily know at the time it > > sent the OPEN that the component would resolve to a non-regular file= . >=20 > Ahhh - thanks. The comments in the code seemed to suggest that the RFC > wasn't specific. I guess I misread them. >=20 > Thanks for the more careful analysis. I'll aim to have an update on > Monday. >=20 Sounds great! > >=20 > > --=20 > > Jeff Layton > >=20 > >=20 >=20 --=20 Jeff Layton