From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Anupam Aggarwal <anupam.al@samsung.com>
Cc: AMIT SAHRAWAT <a.sahrawat@samsung.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs: fat: add check for dir size in fat_calc_dir_size
Date: Sat, 04 Jul 2020 04:11:26 +0900 [thread overview]
Message-ID: <87zh8gct29.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <20200703142939epcms5p1440ec65f7e8a3e4741ade2496135d747@epcms5p1> (Anupam Aggarwal's message of "Fri, 03 Jul 2020 19:59:39 +0530")
Anupam Aggarwal <anupam.al@samsung.com> writes:
>>So what was the root cause of slowness on big directory?
>
> Problem happened on FAT32 formatted 32GB USB 3.0 pendrive, which has
> 20GB of data, cluster size is 16KB It has one corrupted directory
> whose size calculated by fat_calc_dir_size() is 1146896384 bytes
> i.e. 1.06 GB.
>
> When directory traversal of corrupted directory starts, directory
> entries looks to be corrupted and lookup fails for these directory
> entries. Some directory entries name are having format abc/xyz,
> following are the few observed directory entry names:
[...]
> During search for single name in fat_search_long() function, whole
> corrupted directory of size 1.06GB is traversed, which takes around
> 230 to 240 secs, which finally ends up with returning ENOENT.
>
> Now multiple lookups in corrupted directory makes “ls -lR”
> never-ending e.g. in overnite test of running “ls –lR” on USB having
> corrupted directory, around 200 such lookups in corrupted directory
> took 14hrs and still ”ls –lR” is running.
Sounds like totally corrupted FAT image, and the directory may have the
non-simple loop (e.g. there is hardlink of directory).
If so, I'm not sure if we can detect without heavyweight check. Well,
although user should run fsck before mount. However, if fs can detect
and stop early, it would be better.
BTW, if you run fsck, the corrupted directories and issue are gone at
least?
Anyway, fsck would be main way. And on other hand, if we want to add
mitigation for corruption, we would have to see much more details of
this corruption. Can you put somewhere to access the corrupted image
(need the only metadata) to reproduce?
> Total number of directory entries in corrupted directory of size
> 1146896384 bytes = 1146896384/32 = 35840512, so lookup for 35840512
> looks very exhaustive, therefore we have put size check of directory
> in fat_calc_dir_size() and prevented the directory traversal by
> returning -EIO.
>
> While browsing corrupted directory(\CorruptedDIR) on Windows 10 PC,
> 2623 directory entries were listed and timestamps were wrong
What happens if you recursively traversed directories on Windows? This
issue happens on Windows too?
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2020-07-03 19:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20200629110320epcas5p34ccccc7c293f077b34b350935c328215@epcas5p3.samsung.com>
2020-06-29 11:02 ` [PATCH] fs: fat: add check for dir size in fat_calc_dir_size Anupam Aggarwal
2020-06-30 11:08 ` OGAWA Hirofumi
2020-06-30 12:33 ` AMIT SAHRAWAT
2020-06-30 16:26 ` (2) " OGAWA Hirofumi
2020-06-30 17:07 ` AMIT SAHRAWAT
2020-07-03 14:29 ` Anupam Aggarwal
2020-07-03 19:11 ` OGAWA Hirofumi [this message]
2020-07-06 11:53 ` Anupam Aggarwal
2020-07-06 14:22 ` OGAWA Hirofumi
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=87zh8gct29.fsf@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=a.sahrawat@samsung.com \
--cc=anupam.al@samsung.com \
--cc=linux-kernel@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