This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: bounds checking ioctl data


>>>>> 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]