Proposal: Refuse chr_dev seek requests
ehotinger opened this issue · 2 comments
ehotinger commented
- Right now since
llseek
is not specified inep_ops
it will calldefault_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 ofdysk
, 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.
- I would also propose we change
ENOTTY
toEINVAL
inep_ioctl
as well as all of the default return methods foropen
,write
, andrelease
.
NB: both of these changes are mostly fluff scenarios to make the driver similar to others in the kernel.
khenidak commented
I agree - can i ask you to create a PR for this?