* [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming @ 2022-03-25 9:42 ` Yuezhang.Mo 2022-03-28 1:43 ` Namjae Jeon 2022-04-01 10:32 ` Sungjong Seo 0 siblings, 2 replies; 4+ messages in thread From: Yuezhang.Mo @ 2022-03-25 9:42 UTC (permalink / raw) To: sj1557.seo@samsung.com, Namjae Jeon Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andy.Wu@sony.com, Wataru.Aoyama@sony.com, Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jp [-- Attachment #1: Type: text/plain, Size: 1318 bytes --] During renaming, the parent directory information maybe updated. But the file/directory still references to the old parent directory information. This bug will cause 2 problems. (1) The renamed file can not be written. [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : 7afd50e4 iblock : 0, err : -5) [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only ash: write error: Input/output error (2) Some dentries of the renamed file/directory are not set to deleted after removing the file/directory. fixes: 5f2aa075070c ("exfat: add inode 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> Reviewed-by: Daniel Palmer <daniel.palmer@sony.com> --- fs/exfat/namei.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index a02a04a993bf..e7adb6bfd9d5 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1080,6 +1080,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, exfat_remove_entries(inode, p_dir, oldentry, 0, num_old_entries); + ei->dir = *p_dir; ei->entry = newentry; } else { if (exfat_get_entry_type(epold) == TYPE_FILE) { -- 2.25.1 [-- Attachment #2: 0001-exfat-fix-referencing-wrong-parent-directory-informa.patch --] [-- Type: application/octet-stream, Size: 1280 bytes --] During renaming, the parent directory information maybe updated. But the file/directory still references to the old parent directory information. This bug will cause 2 problems. (1) The renamed file can not be written. [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : 7afd50e4 iblock : 0, err : -5) [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only ash: write error: Input/output error (2) Some dentries of the renamed file/directory are not set to deleted after removing the file/directory. fixes: 5f2aa075070c ("exfat: add inode 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> Reviewed-by: Daniel Palmer <daniel.palmer@sony.com> --- fs/exfat/namei.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index a02a04a993bf..e7adb6bfd9d5 100644 --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -1080,6 +1080,7 @@ static int exfat_rename_file(struct inode *inode, struct exfat_chain *p_dir, exfat_remove_entries(inode, p_dir, oldentry, 0, num_old_entries); + ei->dir = *p_dir; ei->entry = newentry; } else { if (exfat_get_entry_type(epold) == TYPE_FILE) { -- 2.25.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming 2022-03-25 9:42 ` [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming Yuezhang.Mo @ 2022-03-28 1:43 ` Namjae Jeon 2022-03-28 6:18 ` Yuezhang.Mo 2022-04-01 10:32 ` Sungjong Seo 1 sibling, 1 reply; 4+ messages in thread From: Namjae Jeon @ 2022-03-28 1:43 UTC (permalink / raw) To: Yuezhang.Mo@sony.com Cc: sj1557.seo@samsung.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andy.Wu@sony.com, Wataru.Aoyama@sony.com, Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jp 2022-03-25 18:42 GMT+09:00, Yuezhang.Mo@sony.com <Yuezhang.Mo@sony.com>: Hi Yuezhang, > During renaming, the parent directory information maybe > updated. But the file/directory still references to the > old parent directory information. > > This bug will cause 2 problems. > > (1) The renamed file can not be written. > > [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : 7afd50e4 > iblock : 0, err : -5) > [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only > ash: write error: Input/output error Could you please elaborate how to reproduce it ? Thanks. > > (2) Some dentries of the renamed file/directory are not set > to deleted after removing the file/directory. > > fixes: 5f2aa075070c ("exfat: add inode 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> > Reviewed-by: Daniel Palmer <daniel.palmer@sony.com> > --- > fs/exfat/namei.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c > index a02a04a993bf..e7adb6bfd9d5 100644 > --- a/fs/exfat/namei.c > +++ b/fs/exfat/namei.c > @@ -1080,6 +1080,7 @@ static int exfat_rename_file(struct inode *inode, > struct exfat_chain *p_dir, > > exfat_remove_entries(inode, p_dir, oldentry, 0, > num_old_entries); > + ei->dir = *p_dir; > ei->entry = newentry; > } else { > if (exfat_get_entry_type(epold) == TYPE_FILE) { > -- > 2.25.1 > ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming 2022-03-28 1:43 ` Namjae Jeon @ 2022-03-28 6:18 ` Yuezhang.Mo 0 siblings, 0 replies; 4+ messages in thread From: Yuezhang.Mo @ 2022-03-28 6:18 UTC (permalink / raw) To: Namjae Jeon Cc: sj1557.seo@samsung.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andy.Wu@sony.com, Wataru.Aoyama@sony.com, Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jp Hi Namjae Jeon, The issue can be reproduced by Step 1: create and rename the file as: dir=${mount_point}/dir rm -fr ${mount_point}/* mkdir ${dir} dirsize=$(du -b ${dir} | awk '{print $1}') for ((i = 1; i <= dirsize / (32 * 3); i++)); do touch ${dir}/file-$i done mkdir ${mount_point}/dir2 mv ${dir}/file-1 ${dir}/long-file-name-1234567890-1234567890 > > (1) The renamed file can not be written. > > > > [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : > > 7afd50e4 iblock : 0, err : -5) > > [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only > > ash: write error: Input/output error > Could you please elaborate how to reproduce it ? Step 2: Write data to the renamed file, such as: echo xxx > ${dir}/file-1 ${dir}/long-file-name-1234567890-1234567890 > > (2) Some dentries of the renamed file/directory are not set > > to deleted after removing the file/directory. After applying the debug patch, ```diff --- a/fs/exfat/namei.c +++ b/fs/exfat/namei.c @@ -824,6 +824,11 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry) num_entries++; brelse(bh); + if (num_entries != ep->dentry.file.num_ext + 1) { + pr_err("file has %d entries\n", ep->dentry.file.num_ext + 1); + pr_err("But only set %d entries to deleted\n", num_entries); + } + exfat_set_volume_dirty(sb); /* update the directory entry */ if (exfat_remove_entries(dir, &cdir, entry, 0, num_entries)) { ``` We can find that 4 entries are not set to delete. [ 388.140802] file has 5 entries [ 388.144200] But only set 1 entries to deleted ^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming 2022-03-25 9:42 ` [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming Yuezhang.Mo 2022-03-28 1:43 ` Namjae Jeon @ 2022-04-01 10:32 ` Sungjong Seo 1 sibling, 0 replies; 4+ messages in thread From: Sungjong Seo @ 2022-04-01 10:32 UTC (permalink / raw) To: 'Namjae Jeon'; +Cc: linux-kernel, linux-fsdevel, sj1557.seo > During renaming, the parent directory information maybe updated. But the > file/directory still references to the old parent directory information. > > This bug will cause 2 problems. > > (1) The renamed file can not be written. > > [10768.175172] exFAT-fs (sda1): error, failed to bmap (inode : 7afd50e4 > iblock : 0, err : -5) > [10768.184285] exFAT-fs (sda1): Filesystem has been set read-only > ash: write error: Input/output error > > (2) Some dentries of the renamed file/directory are not set > to deleted after removing the file/directory. > > fixes: 5f2aa075070c ("exfat: add inode 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> > Reviewed-by: Daniel Palmer <daniel.palmer@sony.com> Looks good! Thanks for your patch! Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com> > --- > fs/exfat/namei.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c index > a02a04a993bf..e7adb6bfd9d5 100644 > --- a/fs/exfat/namei.c > +++ b/fs/exfat/namei.c > @@ -1080,6 +1080,7 @@ static int exfat_rename_file(struct inode *inode, > struct exfat_chain *p_dir, > > exfat_remove_entries(inode, p_dir, oldentry, 0, > num_old_entries); > + ei->dir = *p_dir; > ei->entry = newentry; > } else { > if (exfat_get_entry_type(epold) == TYPE_FILE) { > -- > 2.25.1 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-04-01 10:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CGME20220325094229epcas1p194e9008627d718a444253c1c7e58b2b8@epcas1p1.samsung.com>
2022-03-25 9:42 ` [PATCH 1/2] exfat: fix referencing wrong parent directory information after renaming Yuezhang.Mo
2022-03-28 1:43 ` Namjae Jeon
2022-03-28 6:18 ` Yuezhang.Mo
2022-04-01 10:32 ` Sungjong Seo
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).