2018-11-27 08:53:07

by Martin Schiller

[permalink] [raw]
Subject: [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).

Signed-off-by: Martin Schiller <[email protected]>
---
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



2018-11-27 08:52:00

by Martin Schiller

[permalink] [raw]
Subject: [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

Signed-off-by: Martin Schiller <[email protected]>
---
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


2018-11-27 11:18:12

by Martin Schiller

[permalink] [raw]
Subject: [PATCH 3/3] net/x25: handle call collisions

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 <[email protected]>
---
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


2018-11-29 22:26:59

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 1/3] net/x25: fix called/calling length calculation in x25_parse_address_block

From: Martin Schiller <[email protected]>
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 <[email protected]>

Applied.

2018-11-29 22:27:10

by David Miller

[permalink] [raw]
Subject: 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

> 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 <[email protected]>

Applied.

2018-11-29 22:28:43

by David Miller

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

From: Martin Schiller <[email protected]>
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 <[email protected]>

Applied.