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
Notes:
sideshowbarker
2024-07-17 05:12:36 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/e3de568a45 Pull-request: https://github.com/SerenityOS/serenity/pull/15760 Reviewed-by: https://github.com/ADKaster ✅
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)
|
||||
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) {
|
||||
if (checker.ioctl_number == request)
|
||||
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)
|
||||
|
@ -269,7 +270,8 @@ ErrorOr<void> DisplayConnector::ioctl(OpenFileDescription&, unsigned request, Us
|
|||
// Note: We only allow to set responsibility on a DisplayConnector,
|
||||
// get the current ModeSetting or the hardware framebuffer properties without the
|
||||
// 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();
|
||||
if (!process || process.ptr() != &Process::current()) {
|
||||
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 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 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_fake_writes_framebuffer_region;
|
||||
|
|
Loading…
Add table
Reference in a new issue