Skip to content

Commit

Permalink
net/appletalk: fix atalk_release use after free
Browse files Browse the repository at this point in the history
The BKL removal in appletalk introduced a use-after-free problem,
where atalk_destroy_socket frees a sock, but we still release
the socket lock on it.

An easy fix is to take an extra reference on the sock and sock_put
it when returning from atalk_release.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
arndb authored and davem330 committed Mar 22, 2011
1 parent 674f211 commit b20e7bb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/appletalk/ddp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1051,13 +1051,16 @@ static int atalk_release(struct socket *sock)
{
struct sock *sk = sock->sk;

sock_hold(sk);
lock_sock(sk);
if (sk) {
sock_orphan(sk);
sock->sk = NULL;
atalk_destroy_socket(sk);
}
release_sock(sk);
sock_put(sk);

return 0;
}

Expand Down

0 comments on commit b20e7bb

Please sign in to comment.