* [PATCH v2] exfat: zero the reserved fields of file and stream extension dentries
@ 2024-04-25 4:55 ` Yuezhang.Mo
2024-04-25 6:15 ` Sungjong Seo
0 siblings, 1 reply; 3+ messages in thread
From: Yuezhang.Mo @ 2024-04-25 4:55 UTC (permalink / raw)
To: linkinjeon@kernel.org, sj1557.seo@samsung.com
Cc: linux-fsdevel@vger.kernel.org, Andy.Wu@sony.com,
Wataru.Aoyama@sony.com
From exFAT specification, the reserved fields should initialize
to zero and should not use for any purpose.
If create a new dentry set in the UNUSED dentries, all fields
had been zeroed when allocating cluster to parent directory.
But if create a new dentry set in the DELETED dentries, the
reserved fields in file and stream extension dentries may be
non-zero. Because only the valid bit of the type field of the
dentry is cleared in exfat_remove_entries(), if the type of
dentry is different from the original(For example, a dentry that
was originally a file name dentry, then set to deleted dentry,
and then set as a file dentry), the reserved fields is non-zero.
So this commit initializes the dentry to 0 before createing file
dentry and stream extension dentry.
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>
---
fs/exfat/dir.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
index 077944d3c2c0..84572e11cc05 100644
--- a/fs/exfat/dir.c
+++ b/fs/exfat/dir.c
@@ -420,6 +420,7 @@ static void exfat_set_entry_type(struct exfat_dentry *ep, unsigned int type)
static void exfat_init_stream_entry(struct exfat_dentry *ep,
unsigned int start_clu, unsigned long long size)
{
+ memset(ep, 0, sizeof(*ep));
exfat_set_entry_type(ep, TYPE_STREAM);
if (size == 0)
ep->dentry.stream.flags = ALLOC_FAT_CHAIN;
@@ -457,6 +458,7 @@ void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
struct exfat_dentry *ep;
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
+ memset(ep, 0, sizeof(*ep));
exfat_set_entry_type(ep, type);
exfat_set_entry_time(sbi, ts,
&ep->dentry.file.create_tz,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [PATCH v2] exfat: zero the reserved fields of file and stream extension dentries
2024-04-25 4:55 ` [PATCH v2] exfat: zero the reserved fields of file and stream extension dentries Yuezhang.Mo
@ 2024-04-25 6:15 ` Sungjong Seo
2024-04-25 13:05 ` Namjae Jeon
0 siblings, 1 reply; 3+ messages in thread
From: Sungjong Seo @ 2024-04-25 6:15 UTC (permalink / raw)
To: Yuezhang.Mo, linkinjeon
Cc: linux-fsdevel, Andy.Wu, Wataru.Aoyama, cpgs, sj1557.seo
> From exFAT specification, the reserved fields should initialize
> to zero and should not use for any purpose.
>
> If create a new dentry set in the UNUSED dentries, all fields
> had been zeroed when allocating cluster to parent directory.
>
> But if create a new dentry set in the DELETED dentries, the
> reserved fields in file and stream extension dentries may be
> non-zero. Because only the valid bit of the type field of the
> dentry is cleared in exfat_remove_entries(), if the type of
> dentry is different from the original(For example, a dentry that
> was originally a file name dentry, then set to deleted dentry,
> and then set as a file dentry), the reserved fields is non-zero.
>
> So this commit initializes the dentry to 0 before createing file
> dentry and stream extension dentry.
>
> 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>
Looks good. Thanks for your patch.
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
> ---
> fs/exfat/dir.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
> index 077944d3c2c0..84572e11cc05 100644
> --- a/fs/exfat/dir.c
> +++ b/fs/exfat/dir.c
> @@ -420,6 +420,7 @@ static void exfat_set_entry_type(struct exfat_dentry
> *ep, unsigned int type)
> static void exfat_init_stream_entry(struct exfat_dentry *ep,
> unsigned int start_clu, unsigned long long size)
> {
> + memset(ep, 0, sizeof(*ep));
> exfat_set_entry_type(ep, TYPE_STREAM);
> if (size == 0)
> ep->dentry.stream.flags = ALLOC_FAT_CHAIN;
> @@ -457,6 +458,7 @@ void exfat_init_dir_entry(struct exfat_entry_set_cache
> *es,
> struct exfat_dentry *ep;
>
> ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
> + memset(ep, 0, sizeof(*ep));
> exfat_set_entry_type(ep, type);
> exfat_set_entry_time(sbi, ts,
> &ep->dentry.file.create_tz,
> --
> 2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] exfat: zero the reserved fields of file and stream extension dentries
2024-04-25 6:15 ` Sungjong Seo
@ 2024-04-25 13:05 ` Namjae Jeon
0 siblings, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2024-04-25 13:05 UTC (permalink / raw)
To: Sungjong Seo, Yuezhang.Mo; +Cc: linux-fsdevel, Andy.Wu, Wataru.Aoyama, cpgs
2024년 4월 25일 (목) 오후 3:23, Sungjong Seo <sj1557.seo@samsung.com>님이 작성:
>
> > From exFAT specification, the reserved fields should initialize
> > to zero and should not use for any purpose.
> >
> > If create a new dentry set in the UNUSED dentries, all fields
> > had been zeroed when allocating cluster to parent directory.
> >
> > But if create a new dentry set in the DELETED dentries, the
> > reserved fields in file and stream extension dentries may be
> > non-zero. Because only the valid bit of the type field of the
> > dentry is cleared in exfat_remove_entries(), if the type of
> > dentry is different from the original(For example, a dentry that
> > was originally a file name dentry, then set to deleted dentry,
> > and then set as a file dentry), the reserved fields is non-zero.
> >
> > So this commit initializes the dentry to 0 before createing file
> > dentry and stream extension dentry.
> >
> > 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>
>
> Looks good. Thanks for your patch.
> Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Applied it to #dev.
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-25 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20240425045525epcas1p1052d7d89d9ced86a34dbe5f6a7dcad39@epcas1p1.samsung.com>
2024-04-25 4:55 ` [PATCH v2] exfat: zero the reserved fields of file and stream extension dentries Yuezhang.Mo
2024-04-25 6:15 ` Sungjong Seo
2024-04-25 13:05 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).