From: "Sungjong Seo" <sj1557.seo@samsung.com>
To: <Yuezhang.Mo@sony.com>, <linkinjeon@kernel.org>
Cc: <linux-fsdevel@vger.kernel.org>, <Andy.Wu@sony.com>,
<Wataru.Aoyama@sony.com>, <cpgs@samsung.com>,
<sj1557.seo@samsung.com>
Subject: RE: [PATCH v1] exfat: zero the reserved fields of file and stream extension dentries
Date: Wed, 24 Apr 2024 11:23:22 +0900 [thread overview]
Message-ID: <1891546521.01713933302009.JavaMail.epsvc@epcpadp3> (raw)
In-Reply-To: <PUZPR04MB63168EFB1C670A913C42E80981112@PUZPR04MB6316.apcprd04.prod.outlook.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 zeroes the reserved fields when 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 | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/exfat/dir.c b/fs/exfat/dir.c
> index 077944d3c2c0..cbdd9b59053d 100644
> --- a/fs/exfat/dir.c
> +++ b/fs/exfat/dir.c
> @@ -428,6 +428,10 @@ static void exfat_init_stream_entry(struct
> exfat_dentry *ep,
> ep->dentry.stream.start_clu = cpu_to_le32(start_clu);
> ep->dentry.stream.valid_size = cpu_to_le64(size);
> ep->dentry.stream.size = cpu_to_le64(size);
> +
> + ep->dentry.stream.reserved1 = 0;
> + ep->dentry.stream.reserved2 = 0;
> + ep->dentry.stream.reserved3 = 0;
The comment explains the problem well! And the patch you just sent
seems to solve the mentioned problem.
BTW, what about initializing the entire ep (fixed size of 32 bytes)
to 0 before setting the value of ep in each init function? This is the
simplest way to ensure that all other values are zero except for the
intentionally set value.
> }
>
> static void exfat_init_name_entry(struct exfat_dentry *ep,
> @@ -474,6 +478,9 @@ void exfat_init_dir_entry(struct exfat_entry_set_cache
> *es,
> &ep->dentry.file.access_date,
> NULL);
>
> + ep->dentry.file.reserved1 = 0;
> + memset(ep->dentry.file.reserved2, 0, sizeof(ep-
> >dentry.file.reserved2));
> +
> ep = exfat_get_dentry_cached(es, ES_IDX_STREAM);
> exfat_init_stream_entry(ep, start_clu, size);
> }
> --
> 2.34.1
next prev parent reply other threads:[~2024-04-24 4:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20240423022908epcas1p2e3f94bde4decfd8dca233031f0177f58@epcas1p2.samsung.com>
2024-04-23 2:28 ` [PATCH v1] exfat: zero the reserved fields of file and stream extension dentries Yuezhang.Mo
2024-04-24 2:23 ` Sungjong Seo [this message]
2024-04-24 7:44 ` Yuezhang.Mo
2024-04-24 11:40 ` Sungjong Seo
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=1891546521.01713933302009.JavaMail.epsvc@epcpadp3 \
--to=sj1557.seo@samsung.com \
--cc=Andy.Wu@sony.com \
--cc=Wataru.Aoyama@sony.com \
--cc=Yuezhang.Mo@sony.com \
--cc=cpgs@samsung.com \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@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 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).