Skip to content

Commit

Permalink
nbd: prevent sock_xmit from attempting to use a NULL socket
Browse files Browse the repository at this point in the history
NBD does not protect the nbd_device's socket from becoming NULL during
receives.

This closes a race with the NBD_CLEAR_SOCK ioctl (nbd-client -d) setting
the nbd_device's socket to NULL right before NBD calls sock_xmit.

Signed-off-by: Mike Snitzer <snitzer@gmail.com>
Cc: Paul Clements <paul.clements@steeleye.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Mike Snitzer authored and Linus Torvalds committed Apr 2, 2008
1 parent f2b2ea6 commit ffc41cf
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
struct kvec iov;
sigset_t blocked, oldset;

if (unlikely(!sock)) {
printk(KERN_ERR "%s: Attempted %s on closed socket in sock_xmit\n",
lo->disk->disk_name, (send ? "send" : "recv"));
return -EINVAL;
}

/* Allow interception of SIGKILL only
* Don't allow other signals to interrupt the transmission */
siginitsetinv(&blocked, sigmask(SIGKILL));
Expand Down

0 comments on commit ffc41cf

Please sign in to comment.