summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@gmail.com>2019-11-13 15:54:22 +0300
committerAndreas Kling <awesomekling@gmail.com>2019-11-13 16:37:04 +0100
commitcfdbb712fbf4dbb8587d986eab77d77093da5fbf (patch)
tree01a59eb6cfdd4f9f8b676ed17d3e652bf7d267bd
parentfabdc8cdcb6c8bf1519b0f9e7b6e353d9000fc07 (diff)
downloadserenity-cfdbb712fbf4dbb8587d986eab77d77093da5fbf.zip
Kernel: Fix failing in can_read()/can_write()
Now that the SystemMonitor queries which open files can be read and written to, having can_read()/can_write() unconditionally call ASSERT_NOT_REACHED() leads to system crashes when inspecting the WindowServer. Instead, just return true from can_read()/can_write() (indicating that the read()/write() syscalls should not block) and return -EINVAL when trying to actually read from or write to these devices.
-rw-r--r--Kernel/Devices/BXVGADevice.cpp20
-rw-r--r--Kernel/Devices/BXVGADevice.h8
-rw-r--r--Kernel/Devices/MBVGADevice.cpp20
-rw-r--r--Kernel/Devices/MBVGADevice.h8
4 files changed, 8 insertions, 48 deletions
diff --git a/Kernel/Devices/BXVGADevice.cpp b/Kernel/Devices/BXVGADevice.cpp
index 5c277075d1..9ee46c7c9b 100644
--- a/Kernel/Devices/BXVGADevice.cpp
+++ b/Kernel/Devices/BXVGADevice.cpp
@@ -149,23 +149,3 @@ int BXVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}
-
-bool BXVGADevice::can_read(const FileDescription&) const
-{
- ASSERT_NOT_REACHED();
-}
-
-bool BXVGADevice::can_write(const FileDescription&) const
-{
- ASSERT_NOT_REACHED();
-}
-
-ssize_t BXVGADevice::read(FileDescription&, u8*, ssize_t)
-{
- ASSERT_NOT_REACHED();
-}
-
-ssize_t BXVGADevice::write(FileDescription&, const u8*, ssize_t)
-{
- ASSERT_NOT_REACHED();
-}
diff --git a/Kernel/Devices/BXVGADevice.h b/Kernel/Devices/BXVGADevice.h
index 465203a9a8..1fdf454a7e 100644
--- a/Kernel/Devices/BXVGADevice.h
+++ b/Kernel/Devices/BXVGADevice.h
@@ -17,10 +17,10 @@ public:
private:
virtual const char* class_name() const override { return "BXVGA"; }
- virtual bool can_read(const FileDescription&) const override;
- virtual bool can_write(const FileDescription&) const override;
- virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
+ virtual bool can_read(const FileDescription&) const override { return true; }
+ virtual bool can_write(const FileDescription&) const override { return true; }
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return -EINVAL; }
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return -EINVAL; }
void set_register(u16 index, u16 value);
u32 find_framebuffer_address();
diff --git a/Kernel/Devices/MBVGADevice.cpp b/Kernel/Devices/MBVGADevice.cpp
index 2b4554e7e5..887a06f355 100644
--- a/Kernel/Devices/MBVGADevice.cpp
+++ b/Kernel/Devices/MBVGADevice.cpp
@@ -81,23 +81,3 @@ int MBVGADevice::ioctl(FileDescription&, unsigned request, unsigned arg)
return -EINVAL;
};
}
-
-bool MBVGADevice::can_read(const FileDescription&) const
-{
- ASSERT_NOT_REACHED();
-}
-
-bool MBVGADevice::can_write(const FileDescription&) const
-{
- ASSERT_NOT_REACHED();
-}
-
-ssize_t MBVGADevice::read(FileDescription&, u8*, ssize_t)
-{
- ASSERT_NOT_REACHED();
-}
-
-ssize_t MBVGADevice::write(FileDescription&, const u8*, ssize_t)
-{
- ASSERT_NOT_REACHED();
-}
diff --git a/Kernel/Devices/MBVGADevice.h b/Kernel/Devices/MBVGADevice.h
index a7980a1fcb..c02002540a 100644
--- a/Kernel/Devices/MBVGADevice.h
+++ b/Kernel/Devices/MBVGADevice.h
@@ -17,10 +17,10 @@ public:
private:
virtual const char* class_name() const override { return "MBVGA"; }
- virtual bool can_read(const FileDescription&) const override;
- virtual bool can_write(const FileDescription&) const override;
- virtual ssize_t read(FileDescription&, u8*, ssize_t) override;
- virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
+ virtual bool can_read(const FileDescription&) const override { return true; }
+ virtual bool can_write(const FileDescription&) const override { return true; }
+ virtual ssize_t read(FileDescription&, u8*, ssize_t) override { return -EINVAL; }
+ virtual ssize_t write(FileDescription&, const u8*, ssize_t) override { return -EINVAL; }
size_t framebuffer_size_in_bytes() const { return m_framebuffer_pitch * m_framebuffer_height; }