Commit 215f7b08f2a142ec19f4bd3d6de263e68b877955

Authored by Jarek Poplawski
Committed by David S. Miller
1 parent 488faa2ae3

[AX25]: Locking dependencies fix in ax25_disconnect().

Bernard Pidoux reported these lockdep warnings:

[ INFO: possible irq lock inversion dependency detected ]
2.6.23.1 #1
---------------------------------------------------------
fpac/4933 just changed the state of lock:
 (slock-AF_AX25){--..}, at: [<d8be3312>] ax25_disconnect+0x46/0xaf
 [ax25]
 but this lock was taken by another, soft-irq-safe lock in the past:
  (ax25_list_lock){-+..}

  and interrupts could create inverse lock ordering between them.
  [...]

[ INFO: inconsistent lock state ]
2.6.23.1 #1
---------------------------------
inconsistent {in-softirq-W} -> {softirq-on-W} usage.
ax25_call/4005 [HC0[0]:SC0[0]:HE1:SE1] takes:
 (slock-AF_AX25){-+..}, at: [<d8b79312>] ax25_disconnect+0x46/0xaf [ax25]
 [...]

This means slock-AF_AX25 could be taken both from softirq and process
context with softirqs enabled, so it's endangered itself, but also makes
ax25_list_lock vulnerable. It was not 100% verified if the real lockup
can happen, but this fix isn't very costly and looks safe anyway.
(It was tested by Bernard with 2.6.23.9 and 2.6.24-rc5 kernels.)


Reported_by: Bernard Pidoux <pidoux@ccr.jussieu.fr>
Tested_by: Bernard Pidoux <pidoux@ccr.jussieu.fr>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 2 additions and 0 deletions Side-by-side Diff

net/ax25/ax25_subr.c
... ... @@ -279,6 +279,7 @@
279 279 ax25_link_failed(ax25, reason);
280 280  
281 281 if (ax25->sk != NULL) {
  282 + local_bh_disable();
282 283 bh_lock_sock(ax25->sk);
283 284 ax25->sk->sk_state = TCP_CLOSE;
284 285 ax25->sk->sk_err = reason;
... ... @@ -288,6 +289,7 @@
288 289 sock_set_flag(ax25->sk, SOCK_DEAD);
289 290 }
290 291 bh_unlock_sock(ax25->sk);
  292 + local_bh_enable();
291 293 }
292 294 }