Skip to content

Commit

Permalink
net/can bugfix: use after free bug in can protocol drivers
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Oliver Hartkopp <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
lw-karo authored and davem330 committed Jul 15, 2009
1 parent 252aa9d commit f7e5cc0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/can/bcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions net/can/raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit f7e5cc0

Please sign in to comment.