• Kirill Tkhai's avatar
    fuse: Fix use-after-free in fuse_dev_do_read() · bc78abbd
    Kirill Tkhai authored
    We may pick freed req in this way:
    
    [cpu0]                                  [cpu1]
    fuse_dev_do_read()                      fuse_dev_do_write()
       list_move_tail(&req->list, ...);     ...
       spin_unlock(&fpq->lock);             ...
       ...                                  request_end(fc, req);
       ...                                    fuse_put_request(fc, req);
       if (test_bit(FR_INTERRUPTED, ...))
             queue_interrupt(fiq, req);
    
    Fix that by keeping req alive until we finish all manipulations.
    
    Reported-by: syzbot+4e975615ca01f2277bdd@syzkaller.appspotmail.com
    Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
    Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
    Fixes: 46c34a34 ("fuse: no fc->lock for pqueue parts")
    Cc: <stable@vger.kernel.org> # v4.2
    bc78abbd
dev.c 51.9 KB