Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1424264 > unrolled thread

PATCH 1/1] AX.25: Close socket connection on session completion

Started byBasil Gunn <basil@pacabunga.com>
First post2016-06-16 18:50 +0200
Last post2016-06-19 06:00 +0200
Articles 5 — 4 participants

Back to article view | Back to linux.kernel


Contents

  PATCH 1/1]  AX.25: Close socket connection on session completion Basil Gunn <basil@pacabunga.com> - 2016-06-16 18:50 +0200
    Re: PATCH 1/1] AX.25: Close socket connection on session completion David Miller <davem@davemloft.net> - 2016-06-17 20:40 +0200
      Re: PATCH 1/1] AX.25: Close socket connection on session completion David Ranch <linux-hams@trinnet.net> - 2016-06-19 03:10 +0200
      Re: PATCH 1/1] AX.25: Close socket connection on session completion Thomas Osterried <thomas@x-berg.in-berlin.de> - 2016-06-19 10:10 +0200
    Re: PATCH 1/1] AX.25: Close socket connection on session completion David Miller <davem@davemloft.net> - 2016-06-19 06:00 +0200

#1424264 — PATCH 1/1] AX.25: Close socket connection on session completion

FromBasil Gunn <basil@pacabunga.com>
Date2016-06-16 18:50 +0200
SubjectPATCH 1/1] AX.25: Close socket connection on session completion
Message-ID<rKIEp-2jH-13@gated-at.bofh.it>
A socket connection made in ax.25 is not closed when session is
completed.  The heartbeat timer is stopped prematurely and this is
where the socket gets closed. Allow heatbeat timer to run to close
socket. Symptom occurs in kernels >= 4.2.0

Originally sent 6/15/2016. Resend with distribution list matching
scripts/maintainer.pl output.

Signed-off-by: Basil Gunn <basil@pacabunga.com>
---
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c
index fbd0acf..2fdebab 100644
--- a/net/ax25/af_ax25.c
+++ b/net/ax25/af_ax25.c
@@ -976,7 +976,8 @@ static int ax25_release(struct socket *sock)
 			release_sock(sk);
 			ax25_disconnect(ax25, 0);
 			lock_sock(sk);
-			ax25_destroy_socket(ax25);
+			if (!sock_flag(ax25->sk, SOCK_DESTROY))
+				ax25_destroy_socket(ax25);
 			break;

 		case AX25_STATE_3:
diff --git a/net/ax25/ax25_ds_timer.c b/net/ax25/ax25_ds_timer.c
index 951cd57..5237dff 100644
--- a/net/ax25/ax25_ds_timer.c
+++ b/net/ax25/ax25_ds_timer.c
@@ -102,6 +102,7 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
 	switch (ax25->state) {

 	case AX25_STATE_0:
+	case AX25_STATE_2:
 		/* Magic here: If we listen() and a new link dies before it
 		   is accepted() it isn't 'dead' so doesn't get removed. */
 		if (!sk || sock_flag(sk, SOCK_DESTROY) ||
@@ -111,6 +112,7 @@ void ax25_ds_heartbeat_expiry(ax25_cb *ax25)
 				sock_hold(sk);
 				ax25_destroy_socket(ax25);
 				bh_unlock_sock(sk);
+				/* Ungrab socket and destroy it */
 				sock_put(sk);
 			} else
 				ax25_destroy_socket(ax25);
@@ -213,7 +215,8 @@ void ax25_ds_t1_timeout(ax25_cb *ax25)
 	case AX25_STATE_2:
 		if (ax25->n2count == ax25->n2) {
 			ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
-			ax25_disconnect(ax25, ETIMEDOUT);
+			if (!sock_flag(ax25->sk, SOCK_DESTROY))
+				ax25_disconnect(ax25, ETIMEDOUT);
 			return;
 		} else {
 			ax25->n2count++;
diff --git a/net/ax25/ax25_std_timer.c b/net/ax25/ax25_std_timer.c
index 004467c9..2c0d6ef 100644
--- a/net/ax25/ax25_std_timer.c
+++ b/net/ax25/ax25_std_timer.c
@@ -38,6 +38,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)

 	switch (ax25->state) {
 	case AX25_STATE_0:
+	case AX25_STATE_2:
 		/* Magic here: If we listen() and a new link dies before it
 		   is accepted() it isn't 'dead' so doesn't get removed. */
 		if (!sk || sock_flag(sk, SOCK_DESTROY) ||
@@ -47,6 +48,7 @@ void ax25_std_heartbeat_expiry(ax25_cb *ax25)
 				sock_hold(sk);
 				ax25_destroy_socket(ax25);
 				bh_unlock_sock(sk);
+				/* Ungrab socket and destroy it */
 				sock_put(sk);
 			} else
 				ax25_destroy_socket(ax25);
@@ -144,7 +146,8 @@ void ax25_std_t1timer_expiry(ax25_cb *ax25)
 	case AX25_STATE_2:
 		if (ax25->n2count == ax25->n2) {
 			ax25_send_control(ax25, AX25_DISC, AX25_POLLON, AX25_COMMAND);
-			ax25_disconnect(ax25, ETIMEDOUT);
+			if (!sock_flag(ax25->sk, SOCK_DESTROY))
+				ax25_disconnect(ax25, ETIMEDOUT);
 			return;
 		} else {
 			ax25->n2count++;
diff --git a/net/ax25/ax25_subr.c b/net/ax25/ax25_subr.c
index 3b78e84..655a7d4 100644
--- a/net/ax25/ax25_subr.c
+++ b/net/ax25/ax25_subr.c
@@ -264,7 +264,8 @@ void ax25_disconnect(ax25_cb *ax25, int reason)
 {
 	ax25_clear_queues(ax25);

-	ax25_stop_heartbeat(ax25);
+	if (!sock_flag(ax25->sk, SOCK_DESTROY))
+		ax25_stop_heartbeat(ax25);
 	ax25_stop_t1timer(ax25);
 	ax25_stop_t2timer(ax25);
 	ax25_stop_t3timer(ax25);

[toc] | [next] | [standalone]


#1425381 — Re: PATCH 1/1] AX.25: Close socket connection on session completion

FromDavid Miller <davem@davemloft.net>
Date2016-06-17 20:40 +0200
SubjectRe: PATCH 1/1] AX.25: Close socket connection on session completion
Message-ID<rL6Qq-1D6-7@gated-at.bofh.it>
In reply to#1424264
From: Basil Gunn <basil@pacabunga.com>
Date: Thu, 16 Jun 2016 09:42:30 -0700

> A socket connection made in ax.25 is not closed when session is
> completed.  The heartbeat timer is stopped prematurely and this is
> where the socket gets closed. Allow heatbeat timer to run to close
> socket. Symptom occurs in kernels >= 4.2.0
> 
> Originally sent 6/15/2016. Resend with distribution list matching
> scripts/maintainer.pl output.
> 
> Signed-off-by: Basil Gunn <basil@pacabunga.com>

What changed in 4.2.x that broke this?

[toc] | [prev] | [next] | [standalone]


#1425895 — Re: PATCH 1/1] AX.25: Close socket connection on session completion

FromDavid Ranch <linux-hams@trinnet.net>
Date2016-06-19 03:10 +0200
SubjectRe: PATCH 1/1] AX.25: Close socket connection on session completion
Message-ID<rLzpn-3nt-15@gated-at.bofh.it>
In reply to#1425381
Hello David,

I don't have a specific commit # for you at the moment but there have been a few serious regressions since 4.1.x.  When new code gets commited, are there any systems to run regession tests on?  I'd be willing to build up a pair of VMs that can be run with scripts to verify say basic sanity for kissattach, ax.25, netrom, rose, etc.

Btw, once I get back, I hope to pursue some additional negative case fixes:  (pulling a usb-to-serial adapter when used with kiss-attach will panic the kernel, ifconfig rose0 down will take the kernel to 100%, and a data corruption issue for large transfers (2MB+).

Thanks for your help!

--David
KI6ZHD
--David

On June 17, 2016 12:33:19 PM CST, David Miller <davem@davemloft.net> wrote:
>From: Basil Gunn <basil@pacabunga.com>
>Date: Thu, 16 Jun 2016 09:42:30 -0700
>
>> A socket connection made in ax.25 is not closed when session is
>> completed.  The heartbeat timer is stopped prematurely and this is
>> where the socket gets closed. Allow heatbeat timer to run to close
>> socket. Symptom occurs in kernels >= 4.2.0
>> 
>> Originally sent 6/15/2016. Resend with distribution list matching
>> scripts/maintainer.pl output.
>> 
>> Signed-off-by: Basil Gunn <basil@pacabunga.com>
>
>What changed in 4.2.x that broke this?
>--
>To unsubscribe from this list: send the line "unsubscribe linux-hams"
>in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1425947 — Re: PATCH 1/1] AX.25: Close socket connection on session completion

FromThomas Osterried <thomas@x-berg.in-berlin.de>
Date2016-06-19 10:10 +0200
SubjectRe: PATCH 1/1] AX.25: Close socket connection on session completion
Message-ID<rLFXP-84c-7@gated-at.bofh.it>
In reply to#1425381
> > socket. Symptom occurs in kernels >= 4.2.0
[..] 
> What changed in 4.2.x that broke this?

3.x'er kernel had also this problem; but there it happens rarely.

vy 73,
	- Thomas  dl9sau

[toc] | [prev] | [next] | [standalone]


#1425922 — Re: PATCH 1/1] AX.25: Close socket connection on session completion

FromDavid Miller <davem@davemloft.net>
Date2016-06-19 06:00 +0200
SubjectRe: PATCH 1/1] AX.25: Close socket connection on session completion
Message-ID<rLC3T-54n-1@gated-at.bofh.it>
In reply to#1424264
From: Basil Gunn <basil@pacabunga.com>
Date: Thu, 16 Jun 2016 09:42:30 -0700

> A socket connection made in ax.25 is not closed when session is
> completed.  The heartbeat timer is stopped prematurely and this is
> where the socket gets closed. Allow heatbeat timer to run to close
> socket. Symptom occurs in kernels >= 4.2.0
> 
> Originally sent 6/15/2016. Resend with distribution list matching
> scripts/maintainer.pl output.
> 
> Signed-off-by: Basil Gunn <basil@pacabunga.com>

Applied.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web