Skip to content

Commit

Permalink
Fix deadlock in synthfs read implementation.
Browse files Browse the repository at this point in the history
Not cool disabling interrupts and then calling out to arbitrary code.
  • Loading branch information
awesomekling committed Nov 8, 2018
1 parent 3b2dcd5 commit abdf24c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions VirtualFileSystem/SyntheticFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,19 +194,22 @@ bool SyntheticFileSystem::writeInode(InodeIdentifier, const ByteBuffer&)

Unix::ssize_t SyntheticFileSystem::readInodeBytes(InodeIdentifier inode, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor* handle) const
{
InterruptDisabler disabler;

ASSERT(inode.fileSystemID() == id());
#ifdef SYNTHFS_DEBUG
kprintf("synthfs: readInode %u\n", inode.index());
#endif
ASSERT(offset >= 0);
ASSERT(buffer);

auto it = m_inodes.find(inode.index());
if (it == m_inodes.end())
return false;
const File& file = *(*it).value;
const File* found_file;
{
InterruptDisabler disabler;
auto it = m_inodes.find(inode.index());
if (it == m_inodes.end())
return false;
found_file = (*it).value.ptr();
}
const File& file = *found_file;
ByteBuffer generatedData;
if (file.generator) {
if (!handle) {
Expand Down

0 comments on commit abdf24c

Please sign in to comment.