Skip to contentSkip to conversation

circular locking with AX25 connection timeout

PATCH New Bernard Pidoux 5 participants 9 messages Dec 14, 2007 – Dec 18, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 circular locking with AX25 connection timeout

Hi,

This patch cancels a circular locking conflict that appeared with a timeout of an AX25 connection.

signed off by Jarek Poplawski

net/ax25/ax25_subr.c +2 -0
@@ -279,6 +279,7 @@
 	ax25_link_failed(ax25, reason);
 
 	if (ax25->sk != NULL) {
+		local_bh_disable();
 		bh_lock_sock(ax25->sk);
 		ax25->sk->sk_state     = TCP_CLOSE;
 		ax25->sk->sk_err       = reason;
@@ -288,5 +289,6 @@
 			sock_set_flag(ax25->sk, SOCK_DEAD);
 		}
 		bh_unlock_sock(ax25->sk);
+		local_bh_enable(); 
 	}
 }
#1 lore raw

PATCH 1/1 circular locking with AX25 connection timeout

Quoted 6 lines · Bernard Pidoux

Hi,

This patch cancels a circular locking conflict that appeared with a timeout of an AX25 connection.

signed off by Jarek Poplawski

One spurious space less here, and maybe a few more words to the changelog.

Regards,
Jarek P.
---------------->

Subject: [PATCH] [NET] 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 <[email protected]>
Tested_by: Bernard Pidoux <[email protected]>

---

net/ax25/ax25_subr.c +2 -0
diff -Nurp linux-2.6.24-rc2-/net/ax25/ax25_subr.c linux-2.6.24-rc2+/net/ax25/ax25_subr.c
@@ -279,6 +279,7 @@ void ax25_disconnect(ax25_cb *ax25, int 
 	ax25_link_failed(ax25, reason);
 
 	if (ax25->sk != NULL) {
+		local_bh_disable();
 		bh_lock_sock(ax25->sk);
 		ax25->sk->sk_state     = TCP_CLOSE;
 		ax25->sk->sk_err       = reason;
@@ -288,5 +289,6 @@ void ax25_disconnect(ax25_cb *ax25, int 
 			sock_set_flag(ax25->sk, SOCK_DEAD);
 		}
 		bh_unlock_sock(ax25->sk);
+		local_bh_enable();
 	}
 }
#2 lore raw

[BUG] lack of /proc/net/ax25 with 2.6.24-rc5

With 2.6.24-rc5 there is no /proc/net/ax25

Here is an extract from dmesg after boot :

=======================
sysctl table check failed: /net/ax25/ax0/ax25_default_mode .3.9.1.2 Unknown sysctl binary path
Pid: 2936, comm: kissattach Not tainted 2.6.24-rc5 #1

 [<c012ca6a>] set_fail+0x3b/0x43
 [<c012ce7a>] sysctl_check_table+0x408/0x456
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c02ac64a>] _spin_unlock+0x14/0x1c
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c011e681>] sysctl_set_parent+0x19/0x2a
 [<c011f55c>] register_sysctl_table+0x45/0x85
 [<d8be9d26>] ax25_register_sysctl+0x112/0x11c [ax25]
 [<d8be6c76>] ax25_device_event+0x2e/0x90 [ax25]
 [<c012c560>] notifier_call_chain+0x2a/0x47
 [<c012c59f>] raw_notifier_call_chain+0x17/0x1a
 [<c0259290>] dev_open+0x6f/0x75
 [<c0257ee7>] dev_change_flags+0x9c/0x148
 [<c0256ab3>] __dev_get_by_name+0x68/0x73
 [<c0292307>] devinet_ioctl+0x22e/0x53b
 [<c0259074>] dev_ioctl+0x472/0x5ba
 [<c024d4ba>] sock_ioctl+0x1aa/0x1cf
 [<c024d310>] sock_ioctl+0x0/0x1cf
 [<c016bc19>] do_ioctl+0x19/0x4c
 [<c016be40>] vfs_ioctl+0x1f4/0x20b
 [<c0103d01>] sysenter_past_esp+0x9a/0xa9
 [<c016be9c>] sys_ioctl+0x45/0x5d
 [<c0103cc6>] sysenter_past_esp+0x5f/0xa9
 =======================

sysctl table check failed: /net/ax25/ax0/backoff_type .3.9.1.3 Unknown sysctl binary path (...) truncated
=======================
sysctl table check failed: /net/ax25/ax0/connect_mode .3.9.1.4 Unknown sysctl binary path (...)
=======================
sysctl table check failed: /net/ax25/ax0/standard_window_size .3.9.1.5 Unknown sysctl binary path
=======================
(...)

and so on ...

Bernard Pidoux
[email protected]

#3 lore raw

Re: [BUG] lack of /proc/net/ax25 with 2.6.24-rc5

Quoted 1 line · Bernard Pidoux

With 2.6.24-rc5 there is no /proc/net/ax25

FYI, I've created a Bugzilla entry for this issue at:
http://bugzilla.kernel.org/show_bug.cgi?id=9589

Please add your address to the CC list in there.

Thanks,
Rafael

Quoted 57 lines

Here is an extract from dmesg after boot :

=======================
sysctl table check failed: /net/ax25/ax0/ax25_default_mode .3.9.1.2 Unknown sysctl binary path
Pid: 2936, comm: kissattach Not tainted 2.6.24-rc5 #1

  [<c012ca6a>] set_fail+0x3b/0x43
  [<c012ce7a>] sysctl_check_table+0x408/0x456
  [<c012ce8e>] sysctl_check_table+0x41c/0x456
  [<c012ce8e>] sysctl_check_table+0x41c/0x456
  [<c02ac64a>] _spin_unlock+0x14/0x1c
  [<c012ce8e>] sysctl_check_table+0x41c/0x456
  [<c011e681>] sysctl_set_parent+0x19/0x2a
  [<c011f55c>] register_sysctl_table+0x45/0x85
  [<d8be9d26>] ax25_register_sysctl+0x112/0x11c [ax25]
  [<d8be6c76>] ax25_device_event+0x2e/0x90 [ax25]
  [<c012c560>] notifier_call_chain+0x2a/0x47
  [<c012c59f>] raw_notifier_call_chain+0x17/0x1a
  [<c0259290>] dev_open+0x6f/0x75
  [<c0257ee7>] dev_change_flags+0x9c/0x148
  [<c0256ab3>] __dev_get_by_name+0x68/0x73
  [<c0292307>] devinet_ioctl+0x22e/0x53b
  [<c0259074>] dev_ioctl+0x472/0x5ba
  [<c024d4ba>] sock_ioctl+0x1aa/0x1cf
  [<c024d310>] sock_ioctl+0x0/0x1cf
  [<c016bc19>] do_ioctl+0x19/0x4c
  [<c016be40>] vfs_ioctl+0x1f4/0x20b
  [<c0103d01>] sysenter_past_esp+0x9a/0xa9
  [<c016be9c>] sys_ioctl+0x45/0x5d
  [<c0103cc6>] sysenter_past_esp+0x5f/0xa9
  =======================

sysctl table check failed: /net/ax25/ax0/backoff_type .3.9.1.3 Unknown sysctl binary path
(...) truncated
=======================
sysctl table check failed: /net/ax25/ax0/connect_mode .3.9.1.4 Unknown sysctl binary path
(...)
=======================
sysctl table check failed: /net/ax25/ax0/standard_window_size .3.9.1.5 Unknown sysctl binary path
=======================
(...)

and so on ...

Bernard Pidoux
[email protected]
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#4 lore raw

PATCH 1/1 sysctl: Fix ax25 checks

In reply to Bernard Pidoux
Quoted 1 line · Bernard Pidoux

With 2.6.24-rc5 there is no /proc/net/ax25

/proc/sys/net/ax25?

Quoted 1 line

Here is an extract from dmesg after boot :

Groan. I thought I had found the last of the bugs with my sysctl sanity checks. I guess you actually have to use ax25 for this bug to show up.

Thank you for catching this.

Quoted 42 lines

=======================
sysctl table check failed: /net/ax25/ax0/ax25_default_mode .3.9.1.2 Unknown sysctl binary path
Pid: 2936, comm: kissattach Not tainted 2.6.24-rc5 #1

 [<c012ca6a>] set_fail+0x3b/0x43
 [<c012ce7a>] sysctl_check_table+0x408/0x456
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c02ac64a>] _spin_unlock+0x14/0x1c
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c011e681>] sysctl_set_parent+0x19/0x2a
 [<c011f55c>] register_sysctl_table+0x45/0x85
 [<d8be9d26>] ax25_register_sysctl+0x112/0x11c [ax25]
 [<d8be6c76>] ax25_device_event+0x2e/0x90 [ax25]
 [<c012c560>] notifier_call_chain+0x2a/0x47
 [<c012c59f>] raw_notifier_call_chain+0x17/0x1a
 [<c0259290>] dev_open+0x6f/0x75
 [<c0257ee7>] dev_change_flags+0x9c/0x148
 [<c0256ab3>] __dev_get_by_name+0x68/0x73
 [<c0292307>] devinet_ioctl+0x22e/0x53b
 [<c0259074>] dev_ioctl+0x472/0x5ba
 [<c024d4ba>] sock_ioctl+0x1aa/0x1cf
 [<c024d310>] sock_ioctl+0x0/0x1cf
 [<c016bc19>] do_ioctl+0x19/0x4c
 [<c016be40>] vfs_ioctl+0x1f4/0x20b
 [<c0103d01>] sysenter_past_esp+0x9a/0xa9
 [<c016be9c>] sys_ioctl+0x45/0x5d
 [<c0103cc6>] sysenter_past_esp+0x5f/0xa9
 =======================

sysctl table check failed: /net/ax25/ax0/backoff_type .3.9.1.3 Unknown sysctl binary path
(...) truncated
=======================
sysctl table check failed: /net/ax25/ax0/connect_mode .3.9.1.4 Unknown sysctl binary path
(...)
=======================
sysctl table check failed: /net/ax25/ax0/standard_window_size .3.9.1.5 Unknown sysctl binary path
=======================
(...)

Quoted 2 lines

and so on ...

---
 kernel/sysctl_check.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/sysctl_check.c +6 -1
index bed939f..a68425a 100644
@@ -428,7 +428,7 @@ static struct trans_ctl_table trans_net_netrom_table[] = {
 	{}
 };
 
-static struct trans_ctl_table trans_net_ax25_table[] = {
+static struct trans_ctl_table trans_net_ax25_param_table[] = {
 	{ NET_AX25_IP_DEFAULT_MODE,	"ip_default_mode" },
 	{ NET_AX25_DEFAULT_MODE,	"ax25_default_mode" },
 	{ NET_AX25_BACKOFF_TYPE,	"backoff_type" },
@@ -446,6 +446,11 @@ static struct trans_ctl_table trans_net_ax25_table[] = {
 	{}
 };
 
+static struct trans_ctl_table trans_net_ax25_table[] = {
+	{ 0, NULL, trans_net_ax25_param_table },
+	{}
+};
+
 static struct trans_ctl_table trans_net_bridge_table[] = {
 	{ NET_BRIDGE_NF_CALL_ARPTABLES,		"bridge-nf-call-arptables" },
 	{ NET_BRIDGE_NF_CALL_IPTABLES,		"bridge-nf-call-iptables" },
Signature · 1 line
1.5.3.rc6.17.g1911
#5 lore raw

Re: [PATCH] sysctl: Fix ax25 checks

Eric,

I applied your patch and now I have all /proc/sys/net/ax25 created and initialized as before.

Thanks.

Bernard Pidoux

Quoted 89 lines · Eric W. Biederman
Quoted 1 line · Bernard Pidoux

With 2.6.24-rc5 there is no /proc/net/ax25

/proc/sys/net/ax25?

Quoted 1 line

Here is an extract from dmesg after boot :

Groan. I thought I had found the last of the bugs with my sysctl sanity checks. I guess you actually have to use ax25 for this bug to show up.

Thank you for catching this.

Quoted 42 lines

=======================
sysctl table check failed: /net/ax25/ax0/ax25_default_mode .3.9.1.2 Unknown sysctl binary path
Pid: 2936, comm: kissattach Not tainted 2.6.24-rc5 #1

 [<c012ca6a>] set_fail+0x3b/0x43
 [<c012ce7a>] sysctl_check_table+0x408/0x456
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c02ac64a>] _spin_unlock+0x14/0x1c
 [<c012ce8e>] sysctl_check_table+0x41c/0x456
 [<c011e681>] sysctl_set_parent+0x19/0x2a
 [<c011f55c>] register_sysctl_table+0x45/0x85
 [<d8be9d26>] ax25_register_sysctl+0x112/0x11c [ax25]
 [<d8be6c76>] ax25_device_event+0x2e/0x90 [ax25]
 [<c012c560>] notifier_call_chain+0x2a/0x47
 [<c012c59f>] raw_notifier_call_chain+0x17/0x1a
 [<c0259290>] dev_open+0x6f/0x75
 [<c0257ee7>] dev_change_flags+0x9c/0x148
 [<c0256ab3>] __dev_get_by_name+0x68/0x73
 [<c0292307>] devinet_ioctl+0x22e/0x53b
 [<c0259074>] dev_ioctl+0x472/0x5ba
 [<c024d4ba>] sock_ioctl+0x1aa/0x1cf
 [<c024d310>] sock_ioctl+0x0/0x1cf
 [<c016bc19>] do_ioctl+0x19/0x4c
 [<c016be40>] vfs_ioctl+0x1f4/0x20b
 [<c0103d01>] sysenter_past_esp+0x9a/0xa9
 [<c016be9c>] sys_ioctl+0x45/0x5d
 [<c0103cc6>] sysenter_past_esp+0x5f/0xa9
 =======================

sysctl table check failed: /net/ax25/ax0/backoff_type .3.9.1.3 Unknown sysctl binary path
(...) truncated
=======================
sysctl table check failed: /net/ax25/ax0/connect_mode .3.9.1.4 Unknown sysctl binary path
(...)
=======================
sysctl table check failed: /net/ax25/ax0/standard_window_size .3.9.1.5 Unknown sysctl binary path
=======================
(...)

Quoted 2 lines

and so on ...

---
 kernel/sysctl_check.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
kernel/sysctl_check.c +6 -1
index bed939f..a68425a 100644
@@ -428,7 +428,7 @@ static struct trans_ctl_table trans_net_netrom_table[] = {
 	{}
 };
 
-static struct trans_ctl_table trans_net_ax25_table[] = {
+static struct trans_ctl_table trans_net_ax25_param_table[] = {
 	{ NET_AX25_IP_DEFAULT_MODE,	"ip_default_mode" },
 	{ NET_AX25_DEFAULT_MODE,	"ax25_default_mode" },
 	{ NET_AX25_BACKOFF_TYPE,	"backoff_type" },
@@ -446,6 +446,11 @@ static struct trans_ctl_table trans_net_ax25_table[] = {
 	{}
 };
 
+static struct trans_ctl_table trans_net_ax25_table[] = {
+	{ 0, NULL, trans_net_ax25_param_table },
+	{}
+};
+
 static struct trans_ctl_table trans_net_bridge_table[] = {
 	{ NET_BRIDGE_NF_CALL_ARPTABLES,		"bridge-nf-call-arptables" },
 	{ NET_BRIDGE_NF_CALL_IPTABLES,		"bridge-nf-call-iptables" },
#6 lore raw

Re: [PATCH] sysctl: Fix ax25 checks

Quoted 4 lines · Bernard Pidoux

Eric,

I applied your patch and now I have all /proc/sys/net/ax25 created and initialized as before.

Thanks for reporting this.

Eric

maintainer
#8 lore raw
In reply to Jarek Poplawski

From: Jarek Poplawski <[email protected]>
Date: Sat, 15 Dec 2007 11:18:10 +0100

Quoted 9 lines · Bernard Pidoux
Quoted 6 lines

Hi,

This patch cancels a circular locking conflict that appeared with a timeout of an AX25 connection.

signed off by Jarek Poplawski

One spurious space less here, and maybe a few more words to the changelog.

Patch applied, thanks Jarek.