• Andrew Morton's avatar
    [PATCH] nbd: fix send/receive/shutdown/disconnect races · e915e99b
    Andrew Morton authored
    From: Paul Clements <Paul.Clements@SteelEye.com>
    
    Here's the updated patch to fix several race conditions in nbd. It
    requires reverting the already included (but incomplete)
    nbd-race-fix.patch that's in -mm5.
    
    This patch fixes the following race conditions:
    
    1) adds an increment of req->ref_count to eliminate races between
    do_nbd_request and nbd_end_request, which resulted in the freeing of
    in-use requests -- there were races between send/receive, send/shutdown
    (killall -9 nbd-client), and send/disconnect (nbd-client -d), which are
    now all fixed
    
    2) adds locking and properly orders the code in NBD_CLEAR_SOCK to
    eliminate races with other code
    
    3) adds an lo->sock check to nbd_clear_que to eliminate races between
    do_nbd_request and nbd_clear_que, which resulted in the dequeuing of
    active requests
    
    4) adds an lo->sock check to NBD_DO_IT to eliminate races with
    NBD_CLEAR_SOCK, which caused an Oops when "nbd-client -d" was called
    e915e99b
nbd.c 20.4 KB