mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 18:10:56 +09:00
Kernel: Lock the inode before writing in SharedInodeVMObject::sync
We ensure that when we call SharedInodeVMObject::sync we lock the inode lock before calling Inode virtual write_bytes method directly to avoid assertion on the unlocked inode lock, as it was regressed recently. This is not a complete fix as the need to lock from each path before calling the write_bytes method should be avoided because it can lead to hard-to-find bugs, and this commit only fixes the problem temporarily.
This commit is contained in:
parent
0b9d83fe0d
commit
de980de0e4
Notes:
sideshowbarker
2024-07-19 17:04:23 +09:00
Author: https://github.com/mikeakers
Commit: de980de0e4
Pull-request: https://github.com/SerenityOS/serenity/pull/14836
Reviewed-by: https://github.com/supercomputer7 ✅
2 changed files with 3 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include <Kernel/Forward.h>
|
#include <Kernel/Forward.h>
|
||||||
#include <Kernel/Library/ListedRefCounted.h>
|
#include <Kernel/Library/ListedRefCounted.h>
|
||||||
#include <Kernel/Locking/Mutex.h>
|
#include <Kernel/Locking/Mutex.h>
|
||||||
|
#include <Kernel/Memory/SharedInodeVMObject.h>
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
@ -32,6 +33,7 @@ class Inode : public ListedRefCounted<Inode, LockType::Spinlock>
|
||||||
friend class VirtualFileSystem;
|
friend class VirtualFileSystem;
|
||||||
friend class FileSystem;
|
friend class FileSystem;
|
||||||
friend class InodeFile;
|
friend class InodeFile;
|
||||||
|
friend class Kernel::Memory::SharedInodeVMObject; // FIXME: Remove when write_bytes becomes non-virtual
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~Inode();
|
virtual ~Inode();
|
||||||
|
|
|
@ -53,6 +53,7 @@ ErrorOr<void> SharedInodeVMObject::sync(off_t offset_in_pages, size_t pages)
|
||||||
u8 page_buffer[PAGE_SIZE];
|
u8 page_buffer[PAGE_SIZE];
|
||||||
MM.copy_physical_page(*physical_page, page_buffer);
|
MM.copy_physical_page(*physical_page, page_buffer);
|
||||||
|
|
||||||
|
MutexLocker locker(m_inode->m_inode_lock);
|
||||||
TRY(m_inode->write_bytes(page_index * PAGE_SIZE, PAGE_SIZE, UserOrKernelBuffer::for_kernel_buffer(page_buffer), nullptr));
|
TRY(m_inode->write_bytes(page_index * PAGE_SIZE, PAGE_SIZE, UserOrKernelBuffer::for_kernel_buffer(page_buffer), nullptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue