f2fs: check name_len of dir entry to prevent from deadloop
Subsystems (2)
PATCH 1/2 f2fs: check name_len of dir entry to prevent from deadloop
We assume that modification of some special application could result in zeroed name_len, or it is consciously made by somebody. We will deadloop in find_in_block when name_len of dir entry is zero.
This patch is added for preventing deadloop in above scenario.
--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/f2fs/dir.c +10 -0
@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, } } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } + bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); }
Signature · 1 line
1.7.9.5
Jaegeuk Kim
maintainerHi Chao,
Quoted 3 lines · Chao Yu
We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop infind_in_blockwhenname_lenof dir entry is zero.
Could you explain this a little bit more?
I'm not sure how it can happen.
I think the zeroed name_len would cause some problems in f2fs_add_link.
Thanks,
Quoted 31 lines
This patch is added for preventing deadloop in above scenario.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)fs/f2fs/dir.c +10
-0@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, } } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } + bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); }Signature · 1 line
1.7.9.5
Signature · 1 line
Jaegeuk Kim
Hi Jaegeuk,
Quoted 10 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Saturday, July 05, 2014 2:43 PM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopHi Chao,
Quoted 7 lines
Quoted 3 lines · Chao Yu
We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop infind_in_blockwhenname_lenof dir entry is zero.Could you explain this a little bit more?
I'm not sure how it can happen.
IMO,
On one hand, programs like mkfs/fsck/img2simg and f2fs could directly operate the raw device, so bugs of these software may be triggered to generate the corrupt data such as zeroed name_len.
On the other hand, it' could be treated as a potential security problem, because user could crafted such a malicious image include zeroed name_len for hacking purpose. Once such special image is being mounted, deadloop could be triggered, finally will result in effecting on linux system's running.
Thanks,
Yu
Quoted 30 lines
I think the zeroed
name_lenwould cause some problems inf2fs_add_link.Thanks,
Quoted 26 lines
This patch is added for preventing deadloop in above scenario.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)fs/f2fs/dir.c +10
-0@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, } } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } +
Quoted 8 lines
Quoted 5 lines
fs/f2fs/dir.c +0
-1bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); } --1.7.9.5
--
Jaegeuk Kim
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
Jaegeuk Kim
maintainerQuoted 17 lines · Chao Yu
Hi Jaegeuk,
Quoted 15 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Saturday, July 05, 2014 2:43 PM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopHi Chao,
Quoted 3 lines · Chao Yu
We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop infind_in_blockwhenname_lenof dir entry is zero.
Quoted 7 lines
Quoted 2 lines
Could you explain this a little bit more?
I'm not sure how it can happen.IMO,
On one hand, programs like mkfs/fsck/img2simg and f2fs could directly operate the raw device, so bugs of these software may be triggered to generate the corrupt data such as zeroedname_len.
Well...
If such the programs try to corrupt the f2fs image crucially, the bug should be fixed inside the programs, not from the workaround through f2fs.
As I mentioned, even though f2fs avoids such the dead loop whatever at that moment, it will be operating with inconsistent file system status, resulting in system crash in the near furture finally.
Why should we avoid this specific case only? It seems that it is a kinda intentional user-made case. Is it really normal?
Quoted 2 lines
On the other hand, it' could be treated as a potential security problem, because user could crafted such a malicious image include zeroed
name_lenfor hacking purpose.
If user can try to do something like that, why do they write zeroed name_len only? To crash the system, they can do everything.
Thanks,
Quoted 44 lines
Once such special image is being mounted, deadloop could be triggered, finally will result in effecting on linux system's running.
Thanks,
YuQuoted 38 lines
I think the zeroed
name_lenwould cause some problems inf2fs_add_link.Thanks,
Quoted 30 lines
This patch is added for preventing deadloop in above scenario.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)fs/f2fs/dir.c +10
-1@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, } } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } + bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); } --Quoted 1 line
1.7.9.5
--
Jaegeuk Kim
Signature · 8 lines
Jaegeuk Kim ------------------------------------------------------------------------------ Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards http://p.sf.net/sfu/Bonitasoft
Hi,
Quoted 29 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, July 08, 2014 1:56 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopQuoted 20 lines · Chao Yu
Hi Jaegeuk,
Quoted 17 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Saturday, July 05, 2014 2:43 PM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopHi Chao,
Quoted 3 lines · Chao Yu
We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop infind_in_blockwhenname_lenof dir entry is zero.Could you explain this a little bit more?
I'm not sure how it can happen.
Quoted 8 lines
Quoted 4 lines
IMO,
On one hand, programs like mkfs/fsck/img2simg and f2fs could directly operate the raw device, so bugs of these software may be triggered to generate the corrupt data such as zeroedname_len.Well...
If such the programs try to corrupt the f2fs image crucially, the bug should be fixed inside the programs, not from the workaround through f2fs.
IMO, software should have ability of self fault-tolerant, but not depend on correctness of other related software. And I will hope there are no more other software which could directly operate the raw device, to provide us such corrupted data as input.
How about swifting to BUG_ON here?
Quoted 4 lines
As I mentioned, even though f2fs avoids such the dead loop whatever at that moment, it will be operating with inconsistent file system status, resulting in system crash in the near furture finally.
Agreed, we should avoid this. Previous solution with "break" is not suitable here. Thanks for you reminder.
Quoted 2 lines
Why should we avoid this specific case only?
Hmm... I just found this case could cause some issue when I review Gu's last patch. As I check, several error cases of find_data_page in find_in_level could also cause inconsistent status of fs as you said.
Quoted 2 lines
It seems that it is a kinda intentional user-made case. Is it really normal?
It's really rare.
Quoted 6 lines
Quoted 3 lines
On the other hand, it' could be treated as a potential security problem, because user could crafted such a malicious image include zeroed
name_lenfor hacking purpose.If user can try to do something like that, why do they write zeroed
name_lenonly? To crash the system, they can do everything.
If they have the whole right to access the system, certainly they do not have to do such thing. I just assume that they only have the right to upload the crafted image, then use social engineering in next "do mount" step. Or it's no need to worry about this?
Thanks,
Yu
Quoted 48 lines
Thanks,
Quoted 44 lines
Once such special image is being mounted, deadloop could be triggered, finally will result in effecting on linux system's running.
Thanks,
YuQuoted 38 lines
I think the zeroed
name_lenwould cause some problems inf2fs_add_link.Thanks,
Quoted 30 lines
This patch is added for preventing deadloop in above scenario.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)fs/f2fs/dir.c +10
-1@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, } } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } + bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); } --Quoted 1 line
1.7.9.5
--
Jaegeuk Kim
Quoted 2 lines
--
Jaegeuk Kim
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
Jaegeuk Kim
maintainerHi Chao,
Quoted 40 lines · Chao Yu
Hi,
Quoted 29 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, July 08, 2014 1:56 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopQuoted 20 lines · Chao Yu
Hi Jaegeuk,
Quoted 17 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Saturday, July 05, 2014 2:43 PM
To: Chao Yu
Cc: Changman Lee; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopHi Chao,
Quoted 3 lines · Chao Yu
We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop infind_in_blockwhenname_lenof dir entry is zero.Could you explain this a little bit more?
I'm not sure how it can happen.Quoted 8 lines
Quoted 4 lines
IMO,
On one hand, programs like mkfs/fsck/img2simg and f2fs could directly operate the raw device, so bugs of these software may be triggered to generate the corrupt data such as zeroedname_len.Well...
If such the programs try to corrupt the f2fs image crucially, the bug should be fixed inside the programs, not from the workaround through f2fs.
Quoted 5 lines
IMO, software should have ability of self fault-tolerant, but not depend on correctness of other related software. And I will hope there are no more other software which could directly operate the raw device, to provide us such corrupted data as input.
How about swifting to
BUG_ONhere?
Well, IMO, it would be good to add f2fs_bug_on() here with a specific comment.
In the current phase of f2fs, it is more important to investigate the file system bugs, rather than workarounds for any corrupted images. And, definitely it needs to stop the kernel if any corrupted image was mounted, so that we can figure out where the bugs are occurred.
Thanks,
Quoted 85 lines
Quoted 5 lines
As I mentioned, even though f2fs avoids such the dead loop whatever at that moment, it will be operating with inconsistent file system status, resulting in system crash in the near furture finally.
Agreed, we should avoid this. Previous solution with "break" is not suitable here. Thanks for you reminder.
Quoted 2 lines
Why should we avoid this specific case only?
Hmm... I just found this case could cause some issue when I review Gu's last patch. As I check, several error cases of
find_data_pageinfind_in_levelcould also cause inconsistent status of fs as you said.Quoted 2 lines
It seems that it is a kinda intentional user-made case. Is it really normal?
It's really rare.
Quoted 6 lines
Quoted 3 lines
On the other hand, it' could be treated as a potential security problem, because user could crafted such a malicious image include zeroed
name_lenfor hacking purpose.If user can try to do something like that, why do they write zeroed
name_lenonly? To crash the system, they can do everything.If they have the whole right to access the system, certainly they do not have to do such thing. I just assume that they only have the right to upload the crafted image, then use social engineering in next "do mount" step. Or it's no need to worry about this?
Thanks,
YuQuoted 50 lines
Thanks,
Quoted 44 lines
Once such special image is being mounted, deadloop could be triggered, finally will result in effecting on linux system's running.
Thanks,
YuQuoted 38 lines
I think the zeroed
name_lenwould cause some problems inf2fs_add_link.Thanks,
Quoted 30 lines
This patch is added for preventing deadloop in above scenario.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)fs/f2fs/dir.c +10
-1@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page, } } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } + bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); } --Quoted 1 line
1.7.9.5
--
Jaegeuk Kim--
Jaegeuk Kim
Signature · 1 line
Jaegeuk Kim
Hi Jaegeuk,
Quoted 53 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Wednesday, July 09, 2014 9:48 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopHi Chao,
Quoted 18 lines · Chao Yu
Hi,
Quoted 16 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Tuesday, July 08, 2014 1:56 PM
To: Chao Yu
Cc: 'Changman Lee'; [email protected]; [email protected]; [email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent from deadloopQuoted 7 lines · Chao Yu
Hi Jaegeuk,
Quoted 5 lines
-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Saturday, July 05, 2014 2:43 PM
To: Chao Yu
Cc: Changman Lee; [email protected];Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
[email protected]
Subject: Re: [f2fs-dev][PATCH 1/2] f2fs: checkname_lenof dir entry to prevent fromdeadloop
Quoted 20 lines
Quoted 19 lines
Quoted 8 lines
Quoted 8 lines
Hi Chao,
Quoted 3 lines · Chao Yu
We assume that modification of some special application could result in zeroed
name_len, or it is consciously made by somebody. We will deadloop infind_in_blockwhenname_lenof dir entry is zero.Quoted 7 lines
Quoted 2 lines
Could you explain this a little bit more?
I'm not sure how it can happen.IMO,
On one hand, programs like mkfs/fsck/img2simg and f2fs could directly operate the raw device, so bugs of these software may be triggered to generate the corrupt data such as zeroedname_len.Well...
If such the programs try to corrupt the f2fs image crucially, the bug should be fixed inside the programs, not from the workaround through f2fs.
Quoted 7 lines
Quoted 5 lines
IMO, software should have ability of self fault-tolerant, but not depend on correctness of other related software. And I will hope there are no more other software which could directly operate the raw device, to provide us such corrupted data as input.
How about swifting to
BUG_ONhere?Well, IMO, it would be good to add
f2fs_bug_on()here with a specific comment.
Ok, I will modify this patch and resend it.
Quoted 5 lines
In the current phase of f2fs, it is more important to investigate the file system bugs, rather than workarounds for any corrupted images. And, definitely it needs to stop the kernel if any corrupted image was mounted, so that we can figure out where the bugs are occurred.
All right, I got it.
Thanks for the review and explanation in patience. :)
Regards,
Yu
Quoted 87 lines
Thanks,
Quoted 56 lines
Quoted 5 lines
As I mentioned, even though f2fs avoids such the dead loop whatever at that moment, it will be operating with inconsistent file system status, resulting in system crash in the near furture finally.
Agreed, we should avoid this. Previous solution with "break" is not suitable here. Thanks for you reminder.
Quoted 2 lines
Why should we avoid this specific case only?
Hmm... I just found this case could cause some issue when I review Gu's last patch. As I check, several error cases of
find_data_pageinfind_in_levelcould also cause inconsistent status of fs as you said.Quoted 2 lines
It seems that it is a kinda intentional user-made case. Is it really normal?
It's really rare.
Quoted 6 lines
Quoted 3 lines
On the other hand, it' could be treated as a potential security problem, because user could crafted such a malicious image include zeroed
name_lenfor hacking purpose.If user can try to do something like that, why do they write zeroed
name_lenonly? To crash the system, they can do everything.If they have the whole right to access the system, certainly they do not have to do such thing. I just assume that they only have the right to upload the crafted image, then use social engineering in next "do mount" step. Or it's no need to worry about this?
Thanks,
YuQuoted 21 lines
Thanks,
Quoted 18 lines
Once such special image is being mounted, deadloop could be triggered, finally will result in effecting on linux system's running.
Thanks,
YuQuoted 12 lines
I think the zeroed
name_lenwould cause some problems inf2fs_add_link.Thanks,
Quoted 8 lines
This patch is added for preventing deadloop in above scenario.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/dir.c | 10 ++++++++++ 1 file changed, 10 insertions(+)Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/f2fs/dir.c static struct f2fs_dir_entry *find_in_block(struct page
Quoted 5 lines
fs/f2fs/dir.c +0
-0@@ -121,6 +121,16 @@ static struct f2fs_dir_entry *find_in_block(struct page
*dentry_page,Quoted 22 lines
Quoted 22 lines
Quoted 21 lines
Quoted 21 lines
Quoted 17 lines
fs/f2fs/dir.c +10
-1} } +/* check name_len to prevent from deadloop here */ +if (unlikely (de->name_len ==0 )) { +struct inode *inode = dentry_page->mapping->host; + +f2fs_msg (inode->i_sb,KERN_ERR , +"zero-length dir entry, ino = %lu, name = %s" , + (unsigned long )inode->i_ino, name->name); +break ; + } + bit_start = bit_pos +GET_DENTRY_SLOTS (le16_to_cpu (de->name_len)); } --Quoted 1 line
1.7.9.5
--
Jaegeuk Kim
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
--
Jaegeuk Kim--
Jaegeuk Kim
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse Turn processes into business applications with Bonita BPM Community Edition Quickly connect people, data, and systems into organized workflows Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft