khenidak/dysk

Proposal: Refuse chr_dev seek requests

ehotinger opened this issue · 2 comments

  1. Right now since llseek is not specified in ep_ops it will call default_llseek which will move the file pointer and nothing else. default_llseek protects this file pointer change using the BKL which is messy and in the case of dysk, unnecessary.

Since dysk doesn't use anything but ioctl, we can set llseek = no_llseek and change open to be = nonseekable_open instead of a default.

This advice is per 6038f373a3dcq in the kernel:

New drivers should normally not use noop_llseek but instead use and call nonseekable_open at open time. Existing drivers can be to do the same when the maintainer knows for certain that no user code relies on calling seek on the device file.

  1. I would also propose we change ENOTTY to EINVAL in ep_ioctl as well as all of the default return methods for open, write, and release.

NB: both of these changes are mostly fluff scenarios to make the driver similar to others in the kernel.

I agree - can i ask you to create a PR for this?

@khenidak of course, PR coming shortly 👍