[PATCH] [compiler-rt] Fix the prototype of ioctl interceptor

Kuba Brecka kuba.brecka at gmail.com
Thu Jan 22 11:40:54 PST 2015


> > > I agree with "unsigned long request", but is there any benefit in the _unconditional_ va_arg stuff? We don't reliably know if there is an argument to a given ioctl or not, and then we pass this (possible garbage) value to REAL(ioctl) in any case.

> 

> > 

> 

> > 

> 

> > I don't think we have a way to tell whether that argument is used or not.  The docs (e.g. http://man7.org/linux/man-pages/man2/ioctl.2.html) also suggest that it's always used:

> 

> 

> Exactly. Then why go through va_arg()?


Are you suggesting not to use the variadic prototype of the function, i.e.

  int ioctl(int fildes, unsigned long request, void *arg);

? Because that's exactly what I think is the cause of the memory corruptions that I saw.  Even when we *know* there's exactly one var-argument every time, the following function headers are not equal on all platforms:

  int ioctl(int fildes, unsigned long request, void *arg);
  int ioctl(int fildes, unsigned long request, ...);

> This costs 4 bytes multiplied by the number of known ioctls. We know that all values of req fit in "unsigned" - they are compile-time constants.


Right, I guess we can just fix the interceptor prototype, but store the `request` values as `unsigned`. I'll update the patch again.


http://reviews.llvm.org/D7038

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list