Re: [syzbot] [fs?] KCSAN: data-race in task_dump_owner / task_dump_owner (2)
From: Christian Brauner
Date: Wed Dec 02 2026 - 06:27:32 EST
On Tue, Nov 24, 2026 at 08:37:41PM -0800, Andrew Morton wrote:
> A simple patch which takes ->i_lock in a few places fixed all that up,
> but the performance costs were pretty horrid.
Eeew, no. i_lock isn't about the permission fields of an inode and it
really shouldn't start being about it. It protects inode state, hash,
lru and so on. If filesystems start using it to serialize i_uid, i_gid
and i_mode nobody will know anymore what it actually protects and
everything will suffer in performance including the dcache.
> So updates are now made inside a write section of a new per-inode
> seqcount, still under i_lock, and they read the task's credentials
> inside that section. The comparison is a read section of the same
> seqcount. It waits for an update which is in flight, and it is only
> trusted if no update started while it ran. Every later update reads
> the task after the comparison did and cannot store anything older.
Comparing first and reading the credentials inside the write section
looks ok. But give struct proc_inode its own lock for that, e.g., a
seqlock_t owner_lock. I'd also fold the two patches into one as the
first one only exists to be rewritten by the second.
Note that this will conflict with the procfs work in vfs-7.5.procfs.
fs/proc/fd.c changed quite a bit there and "proc: refresh the owner of
fd/ before checking access" adds another tid_fd_update_inode() caller
from the permission path. Please rebase onto vfs-7.5.procfs and send it
to fsdevel and I'll pick it up.