mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
Kernel/FS: Fix check-then-act concurrency bug in FileSystem/Inode
When the FileSystem does a sync, it gathers up all the inodes with dirty metadata into a vector. The inode mutex is not held while checking the inode dirty bit, which can lead to a kernel panic due to concurrent inode modifications. Fixes: #21796
This commit is contained in:
committed by
Andreas Kling
parent
2372584b18
commit
e346331424
@@ -494,6 +494,9 @@ InodeMetadata Ext2FSInode::metadata() const
|
||||
ErrorOr<void> Ext2FSInode::flush_metadata()
|
||||
{
|
||||
MutexLocker locker(m_inode_lock);
|
||||
if (!is_metadata_dirty())
|
||||
return {};
|
||||
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]::flush_metadata(): Flushing inode", identifier());
|
||||
TRY(fs().write_ext2_inode(index(), m_raw_inode));
|
||||
if (is_directory()) {
|
||||
|
||||
Reference in New Issue
Block a user