RE: [PATCH] kernfs: fix dentry unexpected skip
> -Original Message- > From: linux-kernel-ow...@vger.kernel.org > [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Hatayama, Daisuke > Sent: Saturday, May 19, 2018 12:43 AM > To: 'gre...@linuxfoundation.org'> Cc: Okajima, Toshiyuki/岡嶋 寿行 ; > linux-kernel@vger.kernel.org; 'ebied...@aristanetworks.com' > > Subject: [PATCH] kernfs: fix dentry unexpected skip > > kernfs_dir_next_pos() overlooks the situation that the dentry > corresponding to a given pos object has already been inactive. Hence, > when kernfs_dir_pos() returns the dentry with a hash value larger than > the original one, kernfs_dir_next_pos() returns the dentry next to the > one returned by kernfs_dir_pos(). As a result, the dentry returned by > kernfs_dir_pos() is skipped. > > To fix this issue, try to find a next node only when the returned > object has a hash value equal to or smaller than the original one. > > Signed-off-by: HATAYAMA Daisuke > Suggested-by: Toshiyuki Okajima > Cc: Eric W. Biederman > --- > fs/kernfs/dir.c |2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c > index 89d1dc1..8a2f49c 100644 > --- a/fs/kernfs/dir.c > +++ b/fs/kernfs/dir.c > @@ -1622,7 +1622,7 @@ static int kernfs_dir_fop_release(struct inode *inode, > struct file *filp) > struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos) > { > pos = kernfs_dir_pos(ns, parent, ino, pos); > - if (pos) { > + if (pos && pos->hash <= ino) { I found this condition still misses the case that the returend pos with the same hash value but with different name is skipped. I'll post v2 patch. > do { > struct rb_node *node = rb_next(>rb); > if (!node) > -- > 1.7.1 > > >
RE: [PATCH] kernfs: fix dentry unexpected skip
> -Original Message- > From: linux-kernel-ow...@vger.kernel.org > [mailto:linux-kernel-ow...@vger.kernel.org] On Behalf Of Hatayama, Daisuke > Sent: Saturday, May 19, 2018 12:43 AM > To: 'gre...@linuxfoundation.org' > Cc: Okajima, Toshiyuki/岡嶋 寿行 ; > linux-kernel@vger.kernel.org; 'ebied...@aristanetworks.com' > > Subject: [PATCH] kernfs: fix dentry unexpected skip > > kernfs_dir_next_pos() overlooks the situation that the dentry > corresponding to a given pos object has already been inactive. Hence, > when kernfs_dir_pos() returns the dentry with a hash value larger than > the original one, kernfs_dir_next_pos() returns the dentry next to the > one returned by kernfs_dir_pos(). As a result, the dentry returned by > kernfs_dir_pos() is skipped. > > To fix this issue, try to find a next node only when the returned > object has a hash value equal to or smaller than the original one. > > Signed-off-by: HATAYAMA Daisuke > Suggested-by: Toshiyuki Okajima > Cc: Eric W. Biederman > --- > fs/kernfs/dir.c |2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c > index 89d1dc1..8a2f49c 100644 > --- a/fs/kernfs/dir.c > +++ b/fs/kernfs/dir.c > @@ -1622,7 +1622,7 @@ static int kernfs_dir_fop_release(struct inode *inode, > struct file *filp) > struct kernfs_node *parent, ino_t ino, struct kernfs_node *pos) > { > pos = kernfs_dir_pos(ns, parent, ino, pos); > - if (pos) { > + if (pos && pos->hash <= ino) { I found this condition still misses the case that the returend pos with the same hash value but with different name is skipped. I'll post v2 patch. > do { > struct rb_node *node = rb_next(>rb); > if (!node) > -- > 1.7.1 > > >