bounds checking ioctl data

Greg McGary greg@mcgary.org
Wed Jul 12 18:16:00 GMT 2000


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.

Please advise.


More information about the Libc-hacker mailing list