Skip to content

Commit f192579

Browse files
YuezhangMonamjaejeon
authored andcommitted
exfat: zero the reserved fields of file and stream extension dentries
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 <[email protected]> Reviewed-by: Andy Wu <[email protected]> Reviewed-by: Aoyama Wataru <[email protected]> Reviewed-by: Sungjong Seo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent d7ed523 commit f192579

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/exfat/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ static void exfat_set_entry_type(struct exfat_dentry *ep, unsigned int type)
420420
static void exfat_init_stream_entry(struct exfat_dentry *ep,
421421
unsigned int start_clu, unsigned long long size)
422422
{
423+
memset(ep, 0, sizeof(*ep));
423424
exfat_set_entry_type(ep, TYPE_STREAM);
424425
if (size == 0)
425426
ep->dentry.stream.flags = ALLOC_FAT_CHAIN;
@@ -457,6 +458,7 @@ void exfat_init_dir_entry(struct exfat_entry_set_cache *es,
457458
struct exfat_dentry *ep;
458459

459460
ep = exfat_get_dentry_cached(es, ES_IDX_FILE);
461+
memset(ep, 0, sizeof(*ep));
460462
exfat_set_entry_type(ep, type);
461463
exfat_set_entry_time(sbi, ts,
462464
&ep->dentry.file.create_tz,

0 commit comments

Comments
 (0)