nuttx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-nuttx] patacongo commented on issue #769: misc/Kconfig: enable LIBC_IOCTL_VARIADIC by default
Date Sun, 12 Apr 2020 15:17:36 GMT
patacongo commented on issue #769: misc/Kconfig: enable LIBC_IOCTL_VARIADIC by default
URL: https://github.com/apache/incubator-nuttx/pull/769#issuecomment-612631905
 
 
   > NOTE: That this is only a thin layer. It still only accepts one 'unsigned int' argument.
But the ioctl layer just gets that using va_arg. See libs/libc/misc/lib_ioctl.c:
   > 
   > ```
   > 108   va_start(ap, req);
   > 109   arg = va_arg(ap, unsigned long);
   > 110   va_end(ap);
   > 111
   > 112   /* Then let fs_ioctl() to the real work */
   > 113
   > 114   return fs_ioctl(fd, req, arg);
   > ```
   
   That problem with that is that it is unsafe.  Per comments in libs/libc/misc/lib_ioctl.c:
   
        91   /* Get the unsigned long argument.
        92    *
        93    * REVISIT:  This could be the cause of the crash down the road if the
        94    * actual size of the argument is anything other than sizeof(unsigned long).
        95    * Most small integers will be promoted to 'int'.  ARM should pass the
        96    * following test with all three types having sizeof(type) == 4 bytes.
        97    * 'float' should also be tested.  But 'long long' and 'double' are out of
        98    * the question!  Don't try to pass them.
        99    *
       100    * And what will happen if no third argument is passed?  In most cases,
       101    * this should just result in a garbage value for arg.  But you may
       102    * discover cases where something worse happens!
       103    */
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message