From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: zhoumin <teczm@foxmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vfat: fix uninitialized i_pos error
Date: Wed, 20 Aug 2025 01:57:54 +0900 [thread overview]
Message-ID: <87jz2zz1t9.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <tencent_93CE617328A1683191A7418BCCE87AFE500A@qq.com>
zhoumin <teczm@foxmail.com> writes:
>>> The i_pos field remains uninitialized when fat_fs_error_ratelimit() reports
>>> error, e.g.,
>>>
>>> [ 1642.703550] FAT-fs (loop0): error, fat_get_cluster: invalid
>>> cluster chain (i_pos 0)
>>>
>>> Since i_pos is assigned in fat_attach after fat_fill_inode, the error
>>> message lacks useful debug info.
>>>
>>> Path:
>>> vfat_lookup
>>> fat_build_inode
>>> fat_fill_inode
>>> fat_calc_dir_size
>>> fat_get_cluster /* report error */
>>> fat_attach /* i_pos assigned here */
>
>> No. It is initialized as 0, and it must be unavailable outside
>> between fat_attach and fat_detach.
>
> I see that it was initialized to 0. What I meant is that when
> fat_fs_error_ratelimit uses i_pos for debugging output, it doesn't get the
> correct value.
Not big issue. IOW, 0 is still a valid state.
>> IOW, this is introducing the race.
> I'm not quite clear about the race condition you mentioned here. Could you
> give an example to explain it?
>
> Actually, the modification I initially considered was as follows. I'm not
> sure if this approach carries any risks. If it's acceptable, I'm ready to
> submit a new version.
When you try to change logic, you should read and understand the current
logic before.
For example, fat_iget() and __fat_write_inode() have to grab only valid
and live inode. And the orphaned inode must not be written back to disk,
because same entry can be reused already.
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
next prev parent reply other threads:[~2025-08-19 16:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 15:00 zhoumin
2025-08-19 15:36 ` OGAWA Hirofumi
2025-08-19 16:17 ` zhoumin
2025-08-19 16:57 ` OGAWA Hirofumi [this message]
2025-08-19 17:28 ` zhoumin
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=87jz2zz1t9.fsf@mail.parknet.co.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=teczm@foxmail.com \
/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
all inboxes | Powered by JetHome®