net/can bugfix: use after free bug in can protocol drivers
authorLothar Waßmann <LW@KARO-electronics.de>
Tue, 14 Jul 2009 23:10:21 +0000 (23:10 +0000)
committerDavid S. Miller <davem@davemloft.net>
Wed, 15 Jul 2009 18:20:37 +0000 (11:20 -0700)
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>
net/can/bcm.c
net/can/raw.c

index 95d7f32643aef3a3e0b3830200ea592bb1b54849..1d17e41b892df31e5c9da968fc9647400d62fc0d 100644 (file)
@@ -1469,6 +1469,9 @@ static int bcm_release(struct socket *sock)
                bo->ifindex = 0;
        }
 
+       sock_orphan(sk);
+       sock->sk = NULL;
+
        release_sock(sk);
        sock_put(sk);
 
index 6aa154e806ae722c53e71603c0b22865526452a0..3482546e88848f7613ea0c7b47a9dc51f53c2562 100644 (file)
@@ -306,6 +306,9 @@ static int raw_release(struct socket *sock)
        ro->bound   = 0;
        ro->count   = 0;
 
+       sock_orphan(sk);
+       sock->sk = NULL;
+
        release_sock(sk);
        sock_put(sk);