All of lore.kernel.org
 help / color / mirror / Atom feed
From: NeilBrown <neilb@suse.de>
To: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Josef Bacik <jbacik@fb.com>, Chris Mason <clm@fb.com>,
	Jan Kara <jack@suse.cz>, David Sterba <dsterba@suse.cz>,
	linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org,
	linux-nilfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/3] NILFS2: support NFSv2 export
Date: Mon, 11 May 2015 17:02:51 +1000	[thread overview]
Message-ID: <20150511170251.4fb69e52@notabene.brown> (raw)
In-Reply-To: <20150511.013143.706881749197692581.konishi.ryusuke@lab.ntt.co.jp>

[-- Attachment #1: Type: text/plain, Size: 2446 bytes --]

On Mon, 11 May 2015 01:31:43 +0900 (JST) Ryusuke Konishi
<konishi.ryusuke@lab.ntt.co.jp> wrote:

> On Fri, 08 May 2015 10:16:23 +1000, NeilBrown <neilb@suse.de> wrote:
> > The "fh_len" passed to ->fh_to_* is not guaranteed to be that same as
> > that returned by encode_fh - it may be larger.
> > 
> > With NFSv2, the filehandle is fixed length, so it may appear longer
> > than expected and be zero-padded.
> > 
> > So we must test that fh_len is at least some value, not exactly equal
> > to it.
> > 
> > Signed-off-by: NeilBrown <neilb@suse.de>
> > ---
> >  fs/nilfs2/namei.c |    6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> > index 22180836ec22..b65fb79d16fd 100644
> > --- a/fs/nilfs2/namei.c
> > +++ b/fs/nilfs2/namei.c
> > @@ -496,8 +496,8 @@ static struct dentry *nilfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
> >  {
> >  	struct nilfs_fid *fid = (struct nilfs_fid *)fh;
> >  
> > -	if ((fh_len != NILFS_FID_SIZE_NON_CONNECTABLE &&
> > -	     fh_len != NILFS_FID_SIZE_CONNECTABLE) ||
> 
> > +	if ((fh_len < NILFS_FID_SIZE_NON_CONNECTABLE &&
> > +	     fh_len < NILFS_FID_SIZE_CONNECTABLE) ||
> >  	    (fh_type != FILEID_NILFS_WITH_PARENT &&
> >  	     fh_type != FILEID_NILFS_WITHOUT_PARENT))
> >  		return NULL;
> 
> A bit weird.  "fh_len < NILFS_FID_SIZE_CONNECTABLE" implies "fh_len <
> NILFS_FID_SIZE_NON_CONNECTABLE".
> 
> How about the following fix ?
> 
> 	if ((fh_type != FILEID_NILFS_WITH_PARENT ||
> 	     fh_len < NILFS_FID_SIZE_CONNECTABLE) &&
> 	    (fh_type != FILEID_NILFS_WITHOUT_PARENT ||
> 	     fh_len < NILFS_FID_SIZE_NON_CONNECTABLE))
> 		return NULL;
> 

Yes, weird.  The code only uses the early parts of the filehandle, so we
only need to complain if the fh_len is less than FILEID_NILFS_WITHOUT_PARENT.

So I'd prefer:

@@ -496,8 +496,7 @@ static struct dentry *nilfs_fh_to_dentry(struct super_block *sb, struct fid *fh,
 {
        struct nilfs_fid *fid = (struct nilfs_fid *)fh;
 
-       if ((fh_len != NILFS_FID_SIZE_NON_CONNECTABLE &&
-            fh_len != NILFS_FID_SIZE_CONNECTABLE) ||
+       if (fh_len < NILFS_FID_SIZE_NON_CONNECTABLE ||
            (fh_type != FILEID_NILFS_WITH_PARENT &&
             fh_type != FILEID_NILFS_WITHOUT_PARENT))
                return NULL;


Would you be OK with that?  If so I'll resend.

Thanks,
NeilBrown

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 811 bytes --]

  reply	other threads:[~2015-05-11  7:03 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-08  0:16 [PATCH 0/3] make BTRFS, UDF, NILFS2 work with NFSv2 NeilBrown
2015-05-08  0:16 ` [PATCH 1/3] BTRFS: support NFSv2 export NeilBrown
2015-05-08  0:16   ` NeilBrown
2015-05-11  8:13   ` David Sterba
2015-09-24  1:59     ` Neil Brown
2015-10-05 14:32       ` Chris Mason
2015-10-05 14:32         ` Chris Mason
2015-05-08  0:16 ` [PATCH 3/3] UDF: " NeilBrown
2015-05-11  8:57   ` Jan Kara
2015-05-11  8:57     ` Jan Kara
2015-05-08  0:16 ` [PATCH 2/3] NILFS2: " NeilBrown
2015-05-10 16:31   ` Ryusuke Konishi
2015-05-10 16:31     ` Ryusuke Konishi
2015-05-11  7:02     ` NeilBrown [this message]
2015-05-11  9:54       ` Ryusuke Konishi
2015-05-11 11:13         ` [PATCH v2] " NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150511170251.4fb69e52@notabene.brown \
    --to=neilb@suse.de \
    --cc=clm@fb.com \
    --cc=dsterba@suse.cz \
    --cc=jack@suse.cz \
    --cc=jbacik@fb.com \
    --cc=konishi.ryusuke@lab.ntt.co.jp \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.