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/6865] New: fallback posix_fallocate() implementation is racy


The fallback implementation of posix_fallocate() in
sysdeps/posix/posix_fallocate*.c does a loop over the file, reading a byte,
checking that it is zero, and writing it back. If another application is writing
to the file at the same time, this can result in random data corruption.

One possible solution would be to mmap in the file, then trigger page faults
using atomic operations such as gcc's __sync_bool_compare_and_swap; note that
this can sometimes put too much pressure on the kernel - I've triggered OOM
kills on older linux kernels (2.6.18 xen kernels) this way - and the stat()
block count may remain out of date until a sync() call or until the dirty pages
pass through the filesystem driver.

-- 
           Summary: fallback posix_fallocate() implementation is racy
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bdonlan at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com


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

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