summaryrefslogtreecommitdiffstats
path: root/net/x25
diff options
context:
space:
mode:
authorMartin Schiller <ms@dev.tdt.de>2020-01-09 07:31:14 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-29 16:45:33 +0100
commitd8a11e0f4e26f033a217a24617c11bcd24b8f65a (patch)
treebd17b521fb19453c36fa015317bb8f9d2899a3c9 /net/x25
parentce75dd3abbc8f1be531ac5de559d59df9098020c (diff)
downloadlinux-stable-d8a11e0f4e26f033a217a24617c11bcd24b8f65a.tar.gz
linux-stable-d8a11e0f4e26f033a217a24617c11bcd24b8f65a.tar.bz2
linux-stable-d8a11e0f4e26f033a217a24617c11bcd24b8f65a.zip
net/x25: fix nonblocking connect
commit e21dba7a4df4d93da237da65a096084b4f2e87b4 upstream. This patch fixes 2 issues in x25_connect(): 1. It makes absolutely no sense to reset the neighbour and the connection state after a (successful) nonblocking call of x25_connect. This prevents any connection from being established, since the response (call accept) cannot be processed. 2. Any further calls to x25_connect() while a call is pending should simply return, instead of creating new Call Request (on different logical channels). This patch should also fix the "KASAN: null-ptr-deref Write in x25_connect" and "BUG: unable to handle kernel NULL pointer dereference in x25_connect" bugs reported by syzbot. Signed-off-by: Martin Schiller <ms@dev.tdt.de> Reported-by: syzbot+429c200ffc8772bfe070@syzkaller.appspotmail.com Reported-by: syzbot+eec0c87f31a7c3b66f7b@syzkaller.appspotmail.com Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/x25')
-rw-r--r--net/x25/af_x25.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 6aee9f5e8e71..256f3e97d1f3 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -760,6 +760,10 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
if (sk->sk_state == TCP_ESTABLISHED)
goto out;
+ rc = -EALREADY; /* Do nothing if call is already in progress */
+ if (sk->sk_state == TCP_SYN_SENT)
+ goto out;
+
sk->sk_state = TCP_CLOSE;
sock->state = SS_UNCONNECTED;
@@ -806,7 +810,7 @@ static int x25_connect(struct socket *sock, struct sockaddr *uaddr,
/* Now the loop */
rc = -EINPROGRESS;
if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK))
- goto out_put_neigh;
+ goto out;
rc = x25_wait_for_connection_establishment(sk);
if (rc)