* [PATCH v1] exfat: fix unexpected EOF while reading dir @ 2022-12-26 7:23 ` Yuezhang.Mo 2022-12-29 2:25 ` Sungjong Seo 2022-12-30 1:33 ` Namjae Jeon 0 siblings, 2 replies; 3+ messages in thread From: Yuezhang.Mo @ 2022-12-26 7:23 UTC (permalink / raw) To: linkinjeon@kernel.org, sj1557.seo@samsung.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andy.Wu@sony.com, Wataru.Aoyama@sony.com, Wang Yugui If the position is not aligned with the dentry size, the return value of readdir() will be NULL and errno is 0, which means the end of the directory stream is reached. If the position is aligned with dentry size, but there is no file or directory at the position, exfat_readdir() will continue to get dentry from the next dentry. So the dentry gotten by readdir() may not be at the position. After this commit, if the position is not aligned with the dentry size, round the position up to the dentry size and continue to get the dentry. Fixes: ca06197382bd ("exfat: add directory operations") Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Andy Wu <Andy.Wu@sony.com> Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com> Reported-by: Wang Yugui <wangyugui@e16-tech.com> --- fs/exfat/dir.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c index 1dfa67f307f1..1122bee3b634 100644 --- a/fs/exfat/dir.c +++ b/fs/exfat/dir.c @@ -234,10 +234,7 @@ static int exfat_iterate(struct file *file, struct dir_context *ctx) fake_offset = 1; } - if (cpos & (DENTRY_SIZE - 1)) { - err = -ENOENT; - goto unlock; - } + cpos = round_up(cpos, DENTRY_SIZE); /* name buffer should be allocated before use */ err = exfat_alloc_namebuf(nb); -- 2.25.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v1] exfat: fix unexpected EOF while reading dir 2022-12-26 7:23 ` [PATCH v1] exfat: fix unexpected EOF while reading dir Yuezhang.Mo @ 2022-12-29 2:25 ` Sungjong Seo 2022-12-30 1:33 ` Namjae Jeon 1 sibling, 0 replies; 3+ messages in thread From: Sungjong Seo @ 2022-12-29 2:25 UTC (permalink / raw) To: linkinjeon; +Cc: linux-fsdevel, linux-kernel, 'Wang Yugui' > If the position is not aligned with the dentry size, the return > value of readdir() will be NULL and errno is 0, which means the > end of the directory stream is reached. > > If the position is aligned with dentry size, but there is no file > or directory at the position, exfat_readdir() will continue to > get dentry from the next dentry. So the dentry gotten by readdir() > may not be at the position. > > After this commit, if the position is not aligned with the dentry > size, round the position up to the dentry size and continue to get > the dentry. > > Fixes: ca06197382bd ("exfat: add directory operations") > > Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> > Reviewed-by: Andy Wu <Andy.Wu@sony.com> > Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com> > Reported-by: Wang Yugui <wangyugui@e16-tech.com> Looks good. Thanks. Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> > --- > fs/exfat/dir.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c > index 1dfa67f307f1..1122bee3b634 100644 > --- a/fs/exfat/dir.c > +++ b/fs/exfat/dir.c > @@ -234,10 +234,7 @@ static int exfat_iterate(struct file *file, struct > dir_context *ctx) > fake_offset = 1; > } > > - if (cpos & (DENTRY_SIZE - 1)) { > - err = -ENOENT; > - goto unlock; > - } > + cpos = round_up(cpos, DENTRY_SIZE); > > /* name buffer should be allocated before use */ > err = exfat_alloc_namebuf(nb); > -- > 2.25.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] exfat: fix unexpected EOF while reading dir 2022-12-26 7:23 ` [PATCH v1] exfat: fix unexpected EOF while reading dir Yuezhang.Mo 2022-12-29 2:25 ` Sungjong Seo @ 2022-12-30 1:33 ` Namjae Jeon 1 sibling, 0 replies; 3+ messages in thread From: Namjae Jeon @ 2022-12-30 1:33 UTC (permalink / raw) To: Yuezhang.Mo@sony.com Cc: sj1557.seo@samsung.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andy.Wu@sony.com, Wataru.Aoyama@sony.com, Wang Yugui 2022-12-26 16:23 GMT+09:00, Yuezhang.Mo@sony.com <Yuezhang.Mo@sony.com>: > If the position is not aligned with the dentry size, the return > value of readdir() will be NULL and errno is 0, which means the > end of the directory stream is reached. > > If the position is aligned with dentry size, but there is no file > or directory at the position, exfat_readdir() will continue to > get dentry from the next dentry. So the dentry gotten by readdir() > may not be at the position. > > After this commit, if the position is not aligned with the dentry > size, round the position up to the dentry size and continue to get > the dentry. > > Fixes: ca06197382bd ("exfat: add directory operations") > > Signed-off-by: Yuezhang Mo <Yuezhang.Mo@sony.com> > Reviewed-by: Andy Wu <Andy.Wu@sony.com> > Reviewed-by: Aoyama Wataru <wataru.aoyama@sony.com> > Reported-by: Wang Yugui <wangyugui@e16-tech.com> Applied, Thanks for your patch! ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-30 1:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20221226072359epcas1p4fa9052333561109f76db171f4c57324a@epcas1p4.samsung.com>
2022-12-26 7:23 ` [PATCH v1] exfat: fix unexpected EOF while reading dir Yuezhang.Mo
2022-12-29 2:25 ` Sungjong Seo
2022-12-30 1:33 ` Namjae Jeon
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox