mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:07:34 +00:00
Kernel/Graphics: Handle correctly unknown ioctls on a DisplayConnector
In such case, we should not assert but instead just return EINVAL.
This commit is contained in:
parent
e2ebc8826f
commit
e3de568a45
2 changed files with 11 additions and 6 deletions
|
@ -250,16 +250,17 @@ static StringView ioctl_to_stringview(unsigned request)
|
||||||
if (checker.ioctl_number == request)
|
if (checker.ioctl_number == request)
|
||||||
return checker.name;
|
return checker.name;
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
return "unknown"sv;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DisplayConnector::ioctl_requires_ownership(unsigned request) const
|
ErrorOr<bool> DisplayConnector::ioctl_requires_ownership(unsigned request) const
|
||||||
{
|
{
|
||||||
for (auto& checker : s_checkers) {
|
for (auto& checker : s_checkers) {
|
||||||
if (checker.ioctl_number == request)
|
if (checker.ioctl_number == request)
|
||||||
return checker.requires_ownership;
|
return checker.requires_ownership;
|
||||||
}
|
}
|
||||||
VERIFY_NOT_REACHED();
|
// Note: In case of unknown ioctl, return EINVAL.
|
||||||
|
return Error::from_errno(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<void> DisplayConnector::ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg)
|
ErrorOr<void> DisplayConnector::ioctl(OpenFileDescription&, unsigned request, Userspace<void*> arg)
|
||||||
|
@ -269,7 +270,8 @@ ErrorOr<void> DisplayConnector::ioctl(OpenFileDescription&, unsigned request, Us
|
||||||
// Note: We only allow to set responsibility on a DisplayConnector,
|
// Note: We only allow to set responsibility on a DisplayConnector,
|
||||||
// get the current ModeSetting or the hardware framebuffer properties without the
|
// get the current ModeSetting or the hardware framebuffer properties without the
|
||||||
// need of having an established responsibility on a DisplayConnector.
|
// need of having an established responsibility on a DisplayConnector.
|
||||||
if (ioctl_requires_ownership(request)) {
|
auto needs_ownership = TRY(ioctl_requires_ownership(request));
|
||||||
|
if (needs_ownership) {
|
||||||
auto process = m_responsible_process.strong_ref();
|
auto process = m_responsible_process.strong_ref();
|
||||||
if (!process || process.ptr() != &Process::current()) {
|
if (!process || process.ptr() != &Process::current()) {
|
||||||
dbgln("DisplayConnector::ioctl: {} requires ownership over the device", ioctl_to_stringview(request));
|
dbgln("DisplayConnector::ioctl: {} requires ownership over the device", ioctl_to_stringview(request));
|
||||||
|
@ -459,7 +461,10 @@ ErrorOr<void> DisplayConnector::ioctl(OpenFileDescription&, unsigned request, Us
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EINVAL;
|
// Note: We already verify that the IOCTL is supported and not unknown in
|
||||||
|
// the call to the ioctl_requires_ownership method, so if we reached this
|
||||||
|
// section of the code, this is bug.
|
||||||
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ private:
|
||||||
virtual void will_be_destroyed() override;
|
virtual void will_be_destroyed() override;
|
||||||
virtual void after_inserting() override;
|
virtual void after_inserting() override;
|
||||||
|
|
||||||
bool ioctl_requires_ownership(unsigned request) const;
|
ErrorOr<bool> ioctl_requires_ownership(unsigned request) const;
|
||||||
|
|
||||||
OwnPtr<Memory::Region> m_framebuffer_region;
|
OwnPtr<Memory::Region> m_framebuffer_region;
|
||||||
OwnPtr<Memory::Region> m_fake_writes_framebuffer_region;
|
OwnPtr<Memory::Region> m_fake_writes_framebuffer_region;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue