Skip to content

Commit

Permalink
SCTP: lock_sock_nested in sctp_sock_migrate
Browse files Browse the repository at this point in the history
sctp_sock_migrate() grabs the socket lock on a newly allocated socket while
holding the socket lock on an old socket.  lockdep worries that this might
be a recursive lock attempt.

 task/3026 is trying to acquire lock:
  (sk_lock-AF_INET){--..}, at: [<ffffffff88105b8c>] sctp_sock_migrate+0x2e3/0x327 [sctp]
 but task is already holding lock:
  (sk_lock-AF_INET){--..}, at: [<ffffffff8810891f>] sctp_accept+0xdf/0x1e3 [sctp]

This patch tells lockdep that this locking is safe by using
lock_sock_nested().

Signed-off-by: Zach Brown <zach.brown@oracle.com>
Signed-off-by: Vlad Yasevich <vladislav.yasevich@hp.com>
  • Loading branch information
Zach Brown authored and Vlad Yasevich committed Jun 26, 2007
1 parent 186e234 commit 5131a18
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion net/sctp/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -6123,8 +6123,11 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
* queued to the backlog. This prevents a potential race between
* backlog processing on the old socket and new-packet processing
* on the new socket.
*
* The caller has just allocated newsk so we can guarantee that other
* paths won't try to lock it and then oldsk.
*/
sctp_lock_sock(newsk);
lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
sctp_assoc_migrate(assoc, newsk);

/* If the association on the newsk is already closed before accept()
Expand Down

0 comments on commit 5131a18

Please sign in to comment.