This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/5208] New: readahead() system call implementation has incorrect order of higher and lower bytes of 'offset'


GLIBC version: I've seen this on all glibc releases since 2.2 to current release
(2.7)

This code snippet is taken from sysdeps/unix/sysv/linux/readahead.c:

ssize_t
__readahead (int fd, loff_t offset, size_t count)
{
  return INLINE_SYSCALL (readahead, 4, fd, (off_t) (offset >> 32),
                         (off_t) (offset & 0xffffffff), count);

The offset is being passed in bigger endian format and won't work on little
endian machines. It should instead be passed as:
  __LONG_LONG_PAIR((off_t)(offset >> 32), (off_t)(offset & 0xffffffff))

The reason why this probably never got discovered is that it's difficult for the
user to detect failure of a readahead() syscall due to it's weird return status
semantics (it returns 0 on success, and 0 is also returned when reading beyond
eof), and that no data is read into userland for the user to verify. I verified
this bug using a linux block tracing utility.

Thanks

-- 
           Summary: readahead() system call implementation has incorrect
                    order of higher and lower bytes of 'offset'
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: abhishekrai at google dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: *
  GCC host triplet: *
GCC target triplet: linux


http://sourceware.org/bugzilla/show_bug.cgi?id=5208

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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