Skip to contentSkip to conversation

NFS: null dereference in dev_remove()

PATCH In review Dan Carpenter 2 participants 2 messages Mar 13, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFS: null dereference in dev_remove()

In commit 5ffaf85541 "NFS: replace global bl_wq with per-net one" we made "msg" a pointer instead of a struct stored in stack memory. But we forgot to change the memset() here so we're still clearing stack memory instead clearing the struct like we intended. It will lead to a kernel crash.

fs/nfs/blocklayout/blocklayoutdm.c +1 -1
index 30fc22a..737d839 100644
@@ -54,7 +54,7 @@ static void dev_remove(struct net *net, dev_t dev)
 	dprintk("Entering %s\n", __func__);
 
 	bl_pipe_msg.bl_wq = &nn->bl_wq;
-	memset(&msg, 0, sizeof(*msg));
+	memset(msg, 0, sizeof(*msg));
 	msg->data = kzalloc(1 + sizeof(bl_umount_request), GFP_NOFS);
 	if (!msg->data)
 		goto out;
#1 lore raw

13.03.2012 21:18, Dan Carpenter пишет:

Quoted 13 lines

In commit 5ffaf85541 "NFS: replace global bl_wq with per-net one" we made "msg" a pointer instead of a struct stored in stack memory. But we forgot to change the memset() here so we're still clearing stack memory instead clearing the struct like we intended. It will lead to a kernel crash.

fs/nfs/blocklayout/blocklayoutdm.c +0 -0
index 30fc22a..737d839 100644

fs/nfs/blocklayout/blocklayoutdm.c static void dev_remove(struct net *net, dev_t dev) · line 60

Quoted 8 lines
fs/nfs/blocklayout/blocklayoutdm.c +1 -1
@@ -54,7 +54,7 @@ static void dev_remove(struct net *net, dev_t dev)
  	dprintk("Entering %s\n", __func__);
 
  	bl_pipe_msg.bl_wq =&nn->bl_wq;
-	memset(&msg, 0, sizeof(*msg));
+	memset(msg, 0, sizeof(*msg));
  	msg->data = kzalloc(1 + sizeof(bl_umount_request), GFP_NOFS);
  	if (!msg->data)
  		goto out;

Thanks, Dan!

Signature · 2 lines
Best regards,
Stanislav Kinsbursky