cvs commit: src/sys/dev/atkbdc atkbd.c src/sys/dev/digi digi.c src/sys/dev/kbdmux kbdmux.c src/sys/dev/syscons scvidctl.c syscons.c src/sys/dev/uart uart_kbd_sun.c src/sys/dev/usb ukbd.c src/sys/dev/vkbd vkbd.c src/sys/fs/procfs procfs_ioctl.c ...

Ruslan Ermilov ru at freebsd.org
Thu Sep 28 09:21:45 PDT 2006


On Thu, Sep 28, 2006 at 10:56:27AM -0400, John Baldwin wrote:
> On Wednesday 27 September 2006 18:12, Ruslan Ermilov wrote:
> > There are some _IO() ioctls that pass a pointer to variable sized data,
> > and their ioctl handlers to uiocopy'ing rather than ioctl().  See
> > sys/cam/scsi/scsi_ses.c, SESIOC_* ioctls for one such example.
> 
> I think these are just broken and should be fixed. :)  SESIOC_ENCSTAT should 
> be IOW(..., ses_encstat) for example.  The two troublesome ones GETNOBJ and 
> GETOBJMAP are broken by design.  Somehow they need to tell userland how much 
> they copied out, and they also need to let userland specify the buffer length 
> to avoid buffer overflows.  Thus, they need to be using a IOWR with a 
> structure containing a pointer and length (modify the length on return if 
> needed) to avoid problems anyway.  I'd be all for just fixing the few that 
> abuse _IO to treat the arg as anything other than an int and assume _IO means 
> an int arg for 7.x and future.   The solution for 6.x might be uglier, but 
> for the future we should fix the abusers and avoid adding the _IOWINT hack.
> 
> > > If an ioctl doesn't use the arg, then you don't lose anything.. 
> > > do we have any ioctl's that use the arg directly but not as an int?
> > > 
> > Unfortunately yes.
> 
> Are there any others outside of SES?  How many?  If it's a small list, then 
> let's fix them.  The SES ones are broken as an API anyway as mentioned above, 
> and if other ioctl's are copying out a variable amount of data w/o allowing 
> for buffer lengths or telling userland how much it copied, they are also 
> fundamentally broken as well.
> 
Some only read from userland, so they aren't broken.  I'll compile and send
you the list of such ioctls (don't have it saved)...  Ah, here's one from
memory that isn't broken: SPKRTUNE from sys/dev/speaker/.

> > stack (such as i386) this causes return address to be accessed
> > instead of the argument value.  Ioctls that are "void" should
> > either pass "0" or "NULL".
> 
> It will be stack (or register) garbage yes, but unread stack (or register) 
> garbage. :)
> 
Yes, you're right.


Cheers,
-- 
Ruslan Ermilov
ru at FreeBSD.org
FreeBSD committer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/cvs-all/attachments/20060928/cd0ea266/attachment.pgp


More information about the cvs-all mailing list