bounds checking ioctl data
Andreas Jaeger
aj@suse.de
Wed Jul 12 23:51:00 GMT 2000
>>>>> Greg McGary writes:
> I have the following defined in sysdeps/generic/bp-checks.h:
> ------------------------------------------------------------------------------
> # if defined (_IOC_SIZESHIFT) && defined (_IOC_SIZEBITS)
> /* Extract the size of the ioctl parameter argument and check its bounds. */
> # define CHECK_IOCTL(ARG, CMD) \
> CHECK_N ((ARG), (((CMD) >> _IOC_SIZESHIFT) & ((1 << _IOC_SIZEBITS) - 1)))
> # else
> # define CHECK_IOCTL(ARG, CMD) __ptrvalue (ARG)
> # endif
> ------------------------------------------------------------------------------
> The problem is that _IOC_SIZEBITS and _IOC_SIZESHIFT are not defined
> in glibc, but rather in the OS kernel sources. In order to make these
> work, should I clone these definitions in glibc? If so, where?
> Should it go in a file that's private to glibc, or should it be public
> so that conflicting definitions in the glibc part and the OS part will
> trigger diagnostics.
We already copy a number of definitions from kernel sources to glibc,
cloning is no problem in general. The problem I see is that it's
defined in <asm/ioctl.h> which might get included in a number of user
programs. We shouldn't add the defines in a user visible file so that
it leads to conflicts if <asm/ioctl.h> get's included. Adding a check
that the definitions are correct would be fine but is IMO not
required.
Btw. <bits/ioctls.h> already includes (on ix86-Linux) <asm/ioctls.h>
which includes <asm/ioctl.h> - therefore you should have the
definitions already by including <sys/ioctl.h>.
Andreas
--
Andreas Jaeger
SuSE Labs aj@suse.de
private aj@arthur.inka.de
More information about the Libc-hacker
mailing list