* [PATCH] nbd: fix potential NULL pointer fault in nbd_genl_disconnect
@ 2020-01-20 11:23 Sun Ke
0 siblings, 0 replies; only message in thread
From: Sun Ke @ 2020-01-20 11:23 UTC (permalink / raw)
To: sunke32, josef, axboe, mchristi; +Cc: linux-block, nbd, linux-kernel
Open /dev/nbdX first, the config_refs will be 1 and
the pointers in nbd_device are still null. Disconnect
/dev/nbdX, then reference a null recv_workq. The
protection by config_refs in nbd_genl_disconnect is useless.
To fix it, just add a check for a non null task_recv in
nbd_genl_disconnect.
Signed-off-by: Sun Ke <sunke32@huawei.com>
---
drivers/block/nbd.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index b4607dd96185..5e1530bcb81a 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -2008,6 +2008,8 @@ static int nbd_genl_disconnect(struct sk_buff *skb, struct genl_info *info)
index);
return -EINVAL;
}
+ if (!nbd->task_recv)
+ return -EINVAL;
if (!refcount_inc_not_zero(&nbd->refs)) {
mutex_unlock(&nbd_index_mutex);
printk(KERN_ERR "nbd: device at index %d is going down\n",
--
2.17.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-01-20 11:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 11:23 [PATCH] nbd: fix potential NULL pointer fault in nbd_genl_disconnect Sun Ke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®