linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block
@ 2018-11-27  8:50 Martin Schiller
  2018-11-27  8:50 ` [PATCH 2/3] net/x25: fix null_x25_address handling Martin Schiller
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Martin Schiller @ 2018-11-27  8:50 UTC (permalink / raw)
  To: andrew.hendry, davem
  Cc: stephen, joe, anto.cardace, linux-x25, netdev, linux-kernel,
	Martin Schiller

The length of the called and calling address was not calculated
correctly (BCD encoding).

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 net/x25/af_x25.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index d49aa79b7997..5226a7f43050 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -100,7 +100,7 @@ int x25_parse_address_block(struct sk_buff *skb,
 	}
 
 	len = *skb->data;
-	needed = 1 + (len >> 4) + (len & 0x0f);
+	needed = 1 + ((len >> 4) + (len & 0x0f) + 1) / 2;
 
 	if (!pskb_may_pull(skb, needed)) {
 		/* packet is too short to hold the addresses it claims
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] net/x25: fix null_x25_address handling
  2018-11-27  8:50 [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block Martin Schiller
@ 2018-11-27  8:50 ` Martin Schiller
  2018-11-29 22:26   ` David Miller
  2018-11-27  8:50 ` [PATCH 3/3] net/x25: handle call collisions Martin Schiller
  2018-11-29 22:26 ` [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Martin Schiller @ 2018-11-27  8:50 UTC (permalink / raw)
  To: andrew.hendry, davem
  Cc: stephen, joe, anto.cardace, linux-x25, netdev, linux-kernel,
	Martin Schiller

 o x25_find_listener(): the compare for the null_x25_address was wrong.
   We have to check the x25_addr of the listener socket instead of the
   x25_addr of the incomming call.

 o x25_bind(): it was not possible to bind a socket to null_x25_address

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 net/x25/af_x25.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 5226a7f43050..5121729b8b63 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -288,7 +288,7 @@ static struct sock *x25_find_listener(struct x25_address *addr,
 	sk_for_each(s, &x25_list)
 		if ((!strcmp(addr->x25_addr,
 			x25_sk(s)->source_addr.x25_addr) ||
-				!strcmp(addr->x25_addr,
+				!strcmp(x25_sk(s)->source_addr.x25_addr,
 					null_x25_address.x25_addr)) &&
 					s->sk_state == TCP_LISTEN) {
 			/*
@@ -688,11 +688,15 @@ static int x25_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		goto out;
 	}
 
-	len = strlen(addr->sx25_addr.x25_addr);
-	for (i = 0; i < len; i++) {
-		if (!isdigit(addr->sx25_addr.x25_addr[i])) {
-			rc = -EINVAL;
-			goto out;
+	/* check for the null_x25_address */
+	if (strcmp(addr->sx25_addr.x25_addr, null_x25_address.x25_addr)) {
+
+		len = strlen(addr->sx25_addr.x25_addr);
+		for (i = 0; i < len; i++) {
+			if (!isdigit(addr->sx25_addr.x25_addr[i])) {
+				rc = -EINVAL;
+				goto out;
+			}
 		}
 	}
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] net/x25: handle call collisions
  2018-11-27  8:50 [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block Martin Schiller
  2018-11-27  8:50 ` [PATCH 2/3] net/x25: fix null_x25_address handling Martin Schiller
@ 2018-11-27  8:50 ` Martin Schiller
  2018-11-29 22:26   ` David Miller
  2018-11-29 22:26 ` [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block David Miller
  2 siblings, 1 reply; 6+ messages in thread
From: Martin Schiller @ 2018-11-27  8:50 UTC (permalink / raw)
  To: andrew.hendry, davem
  Cc: stephen, joe, anto.cardace, linux-x25, netdev, linux-kernel,
	Martin Schiller

If a session in X25_STATE_1 (Awaiting Call Accept) receives a call
request, the session will be closed (x25_disconnect), cause=0x01
(Number Busy) and diag=0x48 (Call Collision) will be set and a clear
request will be send.

Signed-off-by: Martin Schiller <ms@dev.tdt.de>
---
 net/x25/x25_in.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
index 3c12cae32001..afb26221d8a8 100644
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -142,6 +142,15 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
 			sk->sk_state_change(sk);
 		break;
 	}
+	case X25_CALL_REQUEST:
+		/* call collision */
+		x25->causediag.cause      = 0x01;
+		x25->causediag.diagnostic = 0x48;
+
+		x25_write_internal(sk, X25_CLEAR_REQUEST);
+		x25_disconnect(sk, EISCONN, 0x01, 0x48);
+		break;
+
 	case X25_CLEAR_REQUEST:
 		if (!pskb_may_pull(skb, X25_STD_MIN_LEN + 2))
 			goto out_clear;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block
  2018-11-27  8:50 [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block Martin Schiller
  2018-11-27  8:50 ` [PATCH 2/3] net/x25: fix null_x25_address handling Martin Schiller
  2018-11-27  8:50 ` [PATCH 3/3] net/x25: handle call collisions Martin Schiller
@ 2018-11-29 22:26 ` David Miller
  2 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-11-29 22:26 UTC (permalink / raw)
  To: ms
  Cc: andrew.hendry, stephen, joe, anto.cardace, linux-x25, netdev,
	linux-kernel

From: Martin Schiller <ms@dev.tdt.de>
Date: Tue, 27 Nov 2018 09:50:27 +0100

> The length of the called and calling address was not calculated
> correctly (BCD encoding).
> 
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/3] net/x25: fix null_x25_address handling
  2018-11-27  8:50 ` [PATCH 2/3] net/x25: fix null_x25_address handling Martin Schiller
@ 2018-11-29 22:26   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-11-29 22:26 UTC (permalink / raw)
  To: ms
  Cc: andrew.hendry, stephen, joe, anto.cardace, linux-x25, netdev,
	linux-kernel

From: Martin Schiller <ms@dev.tdt.de>
Date: Tue, 27 Nov 2018 09:50:28 +0100

>  o x25_find_listener(): the compare for the null_x25_address was wrong.
>    We have to check the x25_addr of the listener socket instead of the
>    x25_addr of the incomming call.
> 
>  o x25_bind(): it was not possible to bind a socket to null_x25_address
> 
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 3/3] net/x25: handle call collisions
  2018-11-27  8:50 ` [PATCH 3/3] net/x25: handle call collisions Martin Schiller
@ 2018-11-29 22:26   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-11-29 22:26 UTC (permalink / raw)
  To: ms
  Cc: andrew.hendry, stephen, joe, anto.cardace, linux-x25, netdev,
	linux-kernel

From: Martin Schiller <ms@dev.tdt.de>
Date: Tue, 27 Nov 2018 09:50:29 +0100

> If a session in X25_STATE_1 (Awaiting Call Accept) receives a call
> request, the session will be closed (x25_disconnect), cause=0x01
> (Number Busy) and diag=0x48 (Call Collision) will be set and a clear
> request will be send.
> 
> Signed-off-by: Martin Schiller <ms@dev.tdt.de>

Applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-11-29 22:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-27  8:50 [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block Martin Schiller
2018-11-27  8:50 ` [PATCH 2/3] net/x25: fix null_x25_address handling Martin Schiller
2018-11-29 22:26   ` David Miller
2018-11-27  8:50 ` [PATCH 3/3] net/x25: handle call collisions Martin Schiller
2018-11-29 22:26   ` David Miller
2018-11-29 22:26 ` [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).