[comp.unix.questions] redundant range checking of minor

mangler@cit-vax.Caltech.Edu (System Mangler) (05/26/87)

Most drivers check that minor(dev) is within range in every call
to the read and write routines.  Why isn't it sufficient to do
this once in the open routine?	Is it just unwarranted paranoia?

Don Speck   speck@vlsi.caltech.edu  {seismo,rutgers,ames}!cit-vax!speck

mouse@mcgill-vision.UUCP (06/07/87)

In article <2814@cit-vax.Caltech.Edu>, mangler@cit-vax.Caltech.Edu (System Mangler) writes:
> Most drivers check that minor(dev) is within range in every call to
> the read and write routines.  Why isn't it sufficient to do this once
> in the open routine?	Is it just unwarranted paranoia?

I would say yes, it is just paranoia.  I would not say it is really
unwarranted.  (I am assuming the device does really have an open
routine which does check the unit number - a few simple devices just
have nulldev() for an open routine.)  The check is cheap, and the
potential for harm is great (scribbling on basically random parts of
kernel memory...).

					der Mouse

				(mouse@mcgill-vision.uucp)