Skip to content

Commit 8abdb1b

Browse files
Dave JonesBrad Figg
Dave Jones
authored and
Brad Figg
committed
x25: Fix broken locking in ioctl error paths.
BugLink: http://bugs.launchpad.net/bugs/1214984 [ Upstream commit 4ccb93c ] Two of the x25 ioctl cases have error paths that break out of the function without unlocking the socket, leading to this warning: ================================================ [ BUG: lock held when returning to user space! ] 3.10.0-rc7+ torvalds#36 Not tainted ------------------------------------------------ trinity-child2/31407 is leaving the kernel with locks still held! 1 lock held by trinity-child2/31407: #0: (sk_lock-AF_X25){+.+.+.}, at: [<ffffffffa024b6da>] x25_ioctl+0x8a/0x740 [x25] Signed-off-by: Dave Jones <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Ben Hutchings <[email protected]> Signed-off-by: Brad Figg <[email protected]>
1 parent 067d0fa commit 8abdb1b

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

Diff for: net/x25/af_x25.c

+8-7
Original file line numberDiff line numberDiff line change
@@ -1586,26 +1586,27 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
15861586
case SIOCX25CALLACCPTAPPRV: {
15871587
rc = -EINVAL;
15881588
lock_sock(sk);
1589-
if (sk->sk_state != TCP_CLOSE)
1590-
break;
1591-
clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1589+
if (sk->sk_state == TCP_CLOSE) {
1590+
clear_bit(X25_ACCPT_APPRV_FLAG, &x25->flags);
1591+
rc = 0;
1592+
}
15921593
release_sock(sk);
1593-
rc = 0;
15941594
break;
15951595
}
15961596

15971597
case SIOCX25SENDCALLACCPT: {
15981598
rc = -EINVAL;
15991599
lock_sock(sk);
16001600
if (sk->sk_state != TCP_ESTABLISHED)
1601-
break;
1601+
goto out_sendcallaccpt_release;
16021602
/* must call accptapprv above */
16031603
if (test_bit(X25_ACCPT_APPRV_FLAG, &x25->flags))
1604-
break;
1604+
goto out_sendcallaccpt_release;
16051605
x25_write_internal(sk, X25_CALL_ACCEPTED);
16061606
x25->state = X25_STATE_3;
1607-
release_sock(sk);
16081607
rc = 0;
1608+
out_sendcallaccpt_release:
1609+
release_sock(sk);
16091610
break;
16101611
}
16111612

0 commit comments

Comments
 (0)