• Steven Rostedt's avatar
    ring-buffer: Fix race between integrity check and readers · 9366c1ba
    Steven Rostedt authored
    The function rb_check_pages() was added to make sure the ring buffer's
    pages were sane. This check is done when the ring buffer size is modified
    as well as when the iterator is released (closing the "trace" file),
    as that was considered a non fast path and a good place to do a sanity
    check.
    
    The problem is that the check does not have any locks around it.
    If one process were to read the trace file, and another were to read
    the raw binary file, the check could happen while the reader is reading
    the file.
    
    The issues with this is that the check requires to clear the HEAD page
    before doing the full check and it restores it afterward. But readers
    require the HEAD page to exist before it can read the buffer, otherwise
    it gives a nasty warning and disables the buffer.
    
    By adding the reader lock around the check, this keeps the race from
    happening.
    
    Cc: stable@vger.kernel.org # 3.6
    Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
    9366c1ba
ring_buffer.c 113 KB