Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 286041 - Bad usage of ioctl() in sys-fs/udev-146 causes spurious errors on amd64
Summary: Bad usage of ioctl() in sys-fs/udev-146 causes spurious errors on amd64
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: udev maintainers
URL:
Whiteboard:
Keywords:
: 285050 285941 (view as bug list)
Depends on:
Blocks: 286074
  Show dependency tree
 
Reported: 2009-09-23 03:27 UTC by Andrew Church
Modified: 2009-10-02 11:41 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Fix for incorrect ioctl() parameter type (udevd-146-ioctl-type-fix.patch,292 bytes, patch)
2009-09-23 03:30 UTC, Andrew Church
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Church 2009-09-23 03:27:04 UTC
A bad parameter type to an ioctl() call causes udev-146 to generate "error getting buffer for inotify" messages in syslog.  The offending code is roughly:

    ssize_t nbytes, pos;
    // ...
    ioctl(fd, FIONREAD, &nbytes);

where ssize_t is 64 bits on amd64, but the kernel code for FIONREAD (at least through gentoo-sources-2.6.31) uses type int:

    p = (void __user *) arg;
    switch (cmd) {
    case FIONREAD:
        // ...
        ret = put_user(send_len, (int __user *) p);

so the upper 32 bits of "nbytes" are left uninitialized, and the subsequent malloc(nbytes) fails unless those 32 bits happen to be zero (or the system has a LOT of memory).

Patch will follow.
Comment 1 Andrew Church 2009-09-23 03:30:00 UTC
Created attachment 204988 [details, diff]
Fix for incorrect ioctl() parameter type

I'm assuming the use of int instead of [s]size_t in the kernel is intentional, since all the FIONREAD handlers seem to use int.
Comment 2 Rafał Mużyło 2009-09-23 20:32:35 UTC
*** Bug 285941 has been marked as a duplicate of this bug. ***
Comment 3 Rafał Mużyło 2009-09-23 20:34:41 UTC
*** Bug 285050 has been marked as a duplicate of this bug. ***
Comment 4 Matthias Schwarzott gentoo-dev 2009-10-02 11:41:26 UTC
Fixed in udev-145-r3 and udev-146-r1.