• Rabin Vincent's avatar
    splice: handle zero nr_pages in splice_to_pipe() · 0651623b
    Rabin Vincent authored
    [ Upstream commit d6785d91 ]
    
    Running the following command:
    
     busybox cat /sys/kernel/debug/tracing/trace_pipe > /dev/null
    
    with any tracing enabled pretty very quickly leads to various NULL
    pointer dereferences and VM BUG_ON()s, such as these:
    
     BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
     IP: [<ffffffff8119df6c>] generic_pipe_buf_release+0xc/0x40
     Call Trace:
      [<ffffffff811c48a3>] splice_direct_to_actor+0x143/0x1e0
      [<ffffffff811c42e0>] ? generic_pipe_buf_nosteal+0x10/0x10
      [<ffffffff811c49cf>] do_splice_direct+0x8f/0xb0
      [<ffffffff81196869>] do_sendfile+0x199/0x380
      [<ffffffff81197600>] SyS_sendfile64+0x90/0xa0
      [<ffffffff8192cbee>] entry_SYSCALL_64_fastpath+0x12/0x6d
    
     page dumped because: VM_BUG_ON_PAGE(atomic_read(&page->_count) == 0)
     kernel BUG at include/linux/mm.h:367!
     invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
     RIP: [<ffffffff8119df9c>] generic_pipe_buf_release+0x3c/...
    0651623b
splice.c 46.2 KB