All of lore.kernel.org
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Krystian Kaniewski <krystianmkaniewski@gmail.com>
Cc: linux-kernel@vger.kernel.org,  linux-fsdevel@vger.kernel.org,
	syzbot+b0aebd03565f5774f7f8@syzkaller.appspotmail.com
Subject: Re: [PATCH v5] fat: make rename recovery safe after metadata write errors
Date: Fri, 20 Nov 2026 21:36:16 +0900	[thread overview]
Message-ID: <87jym7fznj.fsf@mail.parknet.co.jp> (raw)
In-Reply-To: <91d8a899-e768-4a4f-8f56-50a7b6f8a293@gmail.com>

Krystian Kaniewski <krystianmkaniewski@gmail.com> writes:

> On 11/8/26 15:04, OGAWA Hirofumi wrote:
>>>
>>>  fs/fat/namei_msdos.c | 18 ++++++++++++----
>>>  fs/fat/namei_vfat.c  | 50 +++++++++++++++++++++++++++++++-------------
>>>  2 files changed, 49 insertions(+), 19 deletions(-)
>>>
>>> diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
>>> index d46d1a3851f25f..51d49a3ca93c14 100644
>>> --- a/fs/fat/namei_msdos.c
>>> +++ b/fs/fat/namei_msdos.c
>>> @@ -562,14 +562,20 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
>>>  	return err;
>>>  
>>>  error_dotdot:
>>> -	/* data cluster is shared, serious corruption */
>>> +	/*
>>> +	 * Complete the remaining rollback. Report corruption only if a
>>> +	 * recovery step cannot be completed.
>>> +	 */
>>>  	corrupt = 1;
>>>  
>>> -	if (update_dotdot) {
>>> +	/* A failed sync write clears BH_Uptodate, leave that buffer alone. */
>>> +	if (update_dotdot && buffer_uptodate(dotdot_bh)) {
>>>  		fat_set_start(dotdot_de, MSDOS_I(old_dir)->i_logstart);
>>>  		mmb_mark_buffer_dirty(dotdot_bh,
>>>  				      &MSDOS_I(old_inode)->i_metadata_bhs);
>>>  		corrupt |= sync_dirty_buffer(dotdot_bh);
>>> +	} else if (update_dotdot) {
>>> +		corrupt = err;
>>>  	}
>>>  error_inode:
>>>  	fat_detach(old_inode);
>>> @@ -577,11 +583,13 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
>>>  	MSDOS_I(old_inode)->i_attrs = old_attrs;
>>>  	if (new_inode) {
>>>  		fat_attach(new_inode, new_i_pos);
>>> -		if (corrupt) {
>>> +		if (corrupt && buffer_uptodate(sinfo.bh)) {
>> 
>> This check is ok with sinfo.bh?
>> 
>
> Yes. For an existing destination, msdos_lookup() reaches fat_scan()
> through msdos_find(), while do_msdos_rename() calls fat_scan() with
> the same normalized 8.3 name. Both identify the same directory entry,
> so sinfo.i_pos equals new_i_pos and sinfo.bh is the buffer containing
> that entry.
>
>> 
>> I guess this check is needed for msdos too? If so, maybe we want the
>> helper function in fat module.
>> 
>> Thanks.
>
> I agree that a common FAT helper would be the right shape if this check
> were still needed. I prepared that version, but before sending v6 I
> noticed that the buffer write-error contract changed in v7.4-rc1.
>
> Commit 9f08e58149dc ("buffer: stop touching BH_Uptodate on write
> completion") no longer clears BH_Uptodate after a failed write. The
> failure is recorded in BH_Write_EIO instead. The same series changed
> fat_sync_bhs() in 8417ab622ffc ("fat: check for a metadata write error
> with buffer_write_io_error()"). The 9f08e58149dc commit message calls
> out the mark_buffer_dirty() warning from this report as the reason for
> the series.
>
> I reran the original C and syz reproducers and targeted metadata write
> faults on current mainline without a FAT patch. The writes still failed,
> but the !buffer_uptodate warning did not occur.
>
> This also means that changing the v5 checks mechanically to
> buffer_write_io_error() would not be correct. The new buffer semantics
> deliberately preserve the in-memory data so that a failed write can be
> retried. In particular, suppressing the second dotdot rollback in
> vfat_rename_exchange() would now remove valid recovery.
>
> My current conclusion is that I should not send a FAT v6 for mainline.
> Would you agree that 9f08e58149dc should be reported to syzbot as the
> fix and that this FAT series should be dropped?
>
> Older kernels that do not contain these buffer changes may still hit
> the warning. Since the warning is now addressed in the buffer layer,
> backporting the relevant v7.4 buffer changes may be preferable to
> adding a separate FAT recovery change.

OK. If there is no WARN_ON() anymore, it sounds good.

Thanks.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>

  reply	other threads:[~2026-11-20 12:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-14 16:38 [syzbot] [exfat?] WARNING in vfat_update_dotdot_de syzbot
2026-09-29  9:00 ` [PATCH] fat: validate dotdot buffers in VFAT and MSDOS rename and rollback Krystian Kaniewski
2026-09-30  8:02   ` OGAWA Hirofumi
2026-09-30 12:17     ` Krystian Kaniewski
2026-10-02 13:43     ` [PATCH v2] fat: skip rename rollback on buffers with failed I/O Krystian Kaniewski
2026-10-11 18:36       ` OGAWA Hirofumi
2026-10-14  8:21         ` Krystian Kaniewski
2026-10-14  8:23         ` [PATCH v3] fat: make rename recovery safe after metadata write errors Krystian Kaniewski
2026-10-15 18:54           ` OGAWA Hirofumi
2026-10-16 13:30             ` Krystian Kaniewski
2026-10-16 13:50               ` OGAWA Hirofumi
2026-10-16 14:01                 ` Krystian Kaniewski
2026-10-16 15:23                   ` OGAWA Hirofumi
2026-10-19  8:21                     ` Krystian Kaniewski
2026-10-19  9:55                       ` OGAWA Hirofumi
2026-10-19 14:51                         ` [PATCH v4] " Krystian Kaniewski
2026-10-19 16:15                           ` OGAWA Hirofumi
2026-10-20  8:28                             ` Krystian Kaniewski
2026-11-02 14:30                               ` [PATCH v5] " Krystian Kaniewski
2026-11-08 14:04                                 ` OGAWA Hirofumi
2026-11-20 12:04                                   ` Krystian Kaniewski
2026-11-20 12:36                                     ` OGAWA Hirofumi [this message]
2026-11-20 12:48 ` [syzbot] [exfat?] WARNING in vfat_update_dotdot_de Krystian Kaniewski
2026-11-20 12:48   ` syzbot
2026-11-20 13:31 ` Krystian Kaniewski

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=87jym7fznj.fsf@mail.parknet.co.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=krystianmkaniewski@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+b0aebd03565f5774f7f8@syzkaller.appspotmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.