浏览代码

net/can bugfix: use after free bug in can protocol drivers

Fix a use after free bug in can protocol drivers

The release functions of the can protocol drivers lack a call to
sock_orphan() which leads to referencing freed memory under certain
circumstances.

This patch fixes a bug reported here:
https://lists.berlios.de/pipermail/socketcan-users/2009-July/000985.html

Signed-off-by: Lothar Wassmann <LW@KARO-electronics.de>
Acked-by: Oliver Hartkopp <oliver@hartkopp.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Lothar Waßmann 16 年之前
父节点
当前提交
f7e5cc0c40
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 3 0
      net/can/bcm.c
  2. 3 0
      net/can/raw.c

+ 3 - 0
net/can/bcm.c

@@ -1469,6 +1469,9 @@ static int bcm_release(struct socket *sock)
 		bo->ifindex = 0;
 		bo->ifindex = 0;
 	}
 	}
 
 
+	sock_orphan(sk);
+	sock->sk = NULL;
+
 	release_sock(sk);
 	release_sock(sk);
 	sock_put(sk);
 	sock_put(sk);
 
 

+ 3 - 0
net/can/raw.c

@@ -306,6 +306,9 @@ static int raw_release(struct socket *sock)
 	ro->bound   = 0;
 	ro->bound   = 0;
 	ro->count   = 0;
 	ro->count   = 0;
 
 
+	sock_orphan(sk);
+	sock->sk = NULL;
+
 	release_sock(sk);
 	release_sock(sk);
 	sock_put(sk);
 	sock_put(sk);