Skip to content

Commit

Permalink
Phonet: fix potential use-after-free in pep_sock_close()
Browse files Browse the repository at this point in the history
sk_common_release() might destroy our last reference to the socket.
So an extra temporary reference is needed during cleanup.

Signed-off-by: Rémi Denis-Courmont <remi.denis-courmont@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rémi Denis-Courmont authored and davem330 committed May 25, 2010
1 parent 7466a38 commit e513480
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/phonet/pep.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ static void pep_sock_close(struct sock *sk, long timeout)
struct pep_sock *pn = pep_sk(sk);
int ifindex = 0;

sock_hold(sk); /* keep a reference after sk_common_release() */
sk_common_release(sk);

lock_sock(sk);
Expand All @@ -644,6 +645,7 @@ static void pep_sock_close(struct sock *sk, long timeout)

if (ifindex)
gprs_detach(sk);
sock_put(sk);
}

static int pep_wait_connreq(struct sock *sk, int noblock)
Expand Down

0 comments on commit e513480

Please sign in to comment.