summaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorMike Snitzer <snitzer@gmail.com>2008-04-02 22:04:47 +0200
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-03 00:28:19 +0200
commitffc41cf8dbb1b895a87daf47d0e5bf6dfbfcab4c (patch)
tree465f41f6c4e0e63c58a94c893d0b4ec5c5e7a10d /drivers/block
parentdoc: fix typo in SubmittingPatches (diff)
downloadlinux-ffc41cf8dbb1b895a87daf47d0e5bf6dfbfcab4c.tar.xz
linux-ffc41cf8dbb1b895a87daf47d0e5bf6dfbfcab4c.zip
nbd: prevent sock_xmit from attempting to use a NULL socket
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>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nbd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b53fdb0a282c..60cc54368b66 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -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));