Skip to content

Commit f7e5cc0

Browse files
lw-karodavem330
authored andcommitted
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>
1 parent 252aa9d commit f7e5cc0

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

net/can/bcm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,9 @@ static int bcm_release(struct socket *sock)
14691469
bo->ifindex = 0;
14701470
}
14711471

1472+
sock_orphan(sk);
1473+
sock->sk = NULL;
1474+
14721475
release_sock(sk);
14731476
sock_put(sk);
14741477

net/can/raw.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ static int raw_release(struct socket *sock)
306306
ro->bound = 0;
307307
ro->count = 0;
308308

309+
sock_orphan(sk);
310+
sock->sk = NULL;
311+
309312
release_sock(sk);
310313
sock_put(sk);
311314

0 commit comments

Comments
 (0)