All of lore.kernel.org
 help / color / mirror / Atom feed
From: Al Viro <viro@zeniv.linux.org.uk>
To: Edward Adam Davis <eadavis@qq.com>
Cc: hirofumi@mail.parknet.co.jp, linkinjeon@kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	sj1557.seo@samsung.com,
	syzbot+d3c29ed63db6ddf8406e@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] fat: Prevent the race of read/write the FAT16 and FAT32 entry
Date: Tue, 29 Jul 2025 06:04:13 +0100	[thread overview]
Message-ID: <20250729050413.GF222315@ZenIV> (raw)
In-Reply-To: <20250729045323.GE222315@ZenIV>

On Tue, Jul 29, 2025 at 05:53:23AM +0100, Al Viro wrote:

> FAT12 problem is that FAT entries being accessed there are 12-bit, packed in
> pairs into an array of 3-byte values.

PS: they most definitely can cross the cacheline boundaries - cacheline size
is not going to be a multiple of 3 on anything realistic.  Hell, they can
cross *block* boundaries (which is why for FAT12 that code is using two
separate pointers - most of the time they point to adjacent bytes, but
if one byte is in one block and the next one is in another...; that's
what that if in fat12_ent_set_ptr() is doing)...

We could map the entire array contiguously (and it might simplify some of
the logics there), but it's not going to avoid the problem with a single
entry occupying a byte in one cacheline and half of a byte in another.

So nothing like cmpxchg would suffice - we need a spinlock for FAT12 case.

  reply	other threads:[~2025-07-29  5:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-28  8:17 [syzbot] [exfat?] KCSAN: data-race in fat32_ent_get / fat32_ent_put syzbot
2025-07-28 11:37 ` [PATCH] fat: Prevent the race of read/write the FAT16 and FAT32 entry Edward Adam Davis
2025-07-28 15:10   ` OGAWA Hirofumi
2025-07-29  3:57     ` Edward Adam Davis
2025-07-28 16:04   ` Al Viro
2025-07-28 16:35     ` Al Viro
2025-07-29  4:17       ` Edward Adam Davis
2025-07-29  4:53         ` Al Viro
2025-07-29  5:04           ` Al Viro [this message]
2025-07-29  5:32             ` Edward Adam Davis
2025-07-29  6:17               ` [PATCH V2] fat: Prevent the race of read/write the " Edward Adam Davis
2025-07-29  9:03                 ` OGAWA Hirofumi
2025-07-29  9:35                 ` Al Viro
2025-07-29 10:06                   ` Al Viro
2025-08-18 13:58                     ` Edward Adam Davis

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=20250729050413.GF222315@ZenIV \
    --to=viro@zeniv.linux.org.uk \
    --cc=eadavis@qq.com \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linkinjeon@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj1557.seo@samsung.com \
    --cc=syzbot+d3c29ed63db6ddf8406e@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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.