Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device: unimplemented ioctls may return error code other than ENOTTY if passed invalid input #5

Open
Gnurou opened this issue May 10, 2024 · 0 comments

Comments

@Gnurou
Copy link
Collaborator

Gnurou commented May 10, 2024

Currently virtio_media_dispatch_ioctl tries to validate the passed input and returns EINVAL it is doesn't pass. The problem is that if the ioctl handler does not override the ioctl, it is supposed to return ENOTTY - which won't happen here, making the driver believe that the ioctl is in fact supported.

I cannot find an ideal solution to this, but the less worse is probably to define a bool constant for each ioctl in the VirtioMediaIoctlHandler trait that defaults to false, and which implementers need to flip to true if they are overriding the ioctl. That way the dispatch method can check if the constant is true, return ENOTTY if it isn't, and then proceed with the validation and handler calling otherwise.

If we go that route the default ioctl implementation should probably panic, as it won't be called unless the implementer overriddes the constant of the ioctl without reimplementing the handler as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant