Skip to contentSkip to conversation

net/x25: fix called/calling length calculation in x25_parse_address_block

PATCH Applied Martin Schiller 2 participants 6 messages Nov 27, 2018 – Nov 29, 2018

Subsystems (3)
lore
Share & tools
lore

Martin Schiller

author maintainer
#0 lore raw

PATCH 1/3 net/x25: fix called/calling length calculation in x25_parse_address_block

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

---
 net/x25/af_x25.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/x25/af_x25.c +1 -1
index d49aa79b7997..5226a7f43050 100644
@@ -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
Signature · 1 line
2.11.0
author maintainer
#1 lore raw

PATCH 2/3 net/x25: fix null_x25_address handling

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

---
 net/x25/af_x25.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
net/x25/af_x25.c +10 -6
index 5226a7f43050..5121729b8b63 100644
@@ -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;
+			}
 		}
 	}
 
Signature · 1 line
2.11.0
maintainer Applied
#2 lore raw

Re: [PATCH 2/3] net/x25: fix null_x25_address handling

From: Martin Schiller <[email protected]>
Date: Tue, 27 Nov 2018 09:50:28 +0100

Quoted 7 lines

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

Applied.

author maintainer
#3 lore raw

PATCH 3/3 net/x25: handle call collisions

In reply to 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.

---
 net/x25/x25_in.c | 9 +++++++++
 1 file changed, 9 insertions(+)
net/x25/x25_in.c +9 -0
index 3c12cae32001..afb26221d8a8 100644
@@ -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;
Signature · 1 line
2.11.0
maintainer Applied
#4 lore raw

Re: [PATCH 3/3] net/x25: handle call collisions

From: Martin Schiller <[email protected]>
Date: Tue, 27 Nov 2018 09:50:29 +0100

Quoted 6 lines

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.

Applied.