[PATCH] net/tls: Fix inverted error codes to avoid endless loop

Subsystems: networking [general], networking [tls], the rest

STALE3236d

2 messages, 2 authors, 2017-12-13 · open the first message on its own page

[PATCH] net/tls: Fix inverted error codes to avoid endless loop

From: <hidden>
Date: 2017-12-11 19:22:19

sendfile() calls can hang endless with using Kernel TLS if a socket error 
occurs.
Socket error codes must be inverted by Kernel TLS before returning because
they are stored with positive sign. If returned non-inverted they are
interpreted as number of bytes sent, causing endless looping of the
splice mechanic behind sendfile().

Signed-off-by: Robert Hering <redacted>
---
diff --git a/include/net/tls.h b/include/net/tls.h
index 936cfc5..9185e53 100644
--- a/include/net/tls.h
+++ b/include/net/tls.h
@@ -170,7 +170,7 @@ static inline bool tls_is_pending_open_record(struct 
tls_context *tls_ctx)
 
 static inline void tls_err_abort(struct sock *sk)
 {
-       sk->sk_err = -EBADMSG;
+       sk->sk_err = EBADMSG;
        sk->sk_error_report(sk);
 }
 
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 73d1921..9773571 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -391,7 +391,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr 
*msg, size_t size)
 
        while (msg_data_left(msg)) {
                if (sk->sk_err) {
-                       ret = sk->sk_err;
+                       ret = -sk->sk_err;
                        goto send_end;
                }
 
@@ -544,7 +544,7 @@ int tls_sw_sendpage(struct sock *sk, struct page 
*page,
                size_t copy, required_size;
 
                if (sk->sk_err) {
-                       ret = sk->sk_err;
+                       ret = -sk->sk_err;
                        goto sendpage_end;
                }
 

Re: [PATCH] net/tls: Fix inverted error codes to avoid endless loop

From: David Miller <davem@davemloft.net>
Date: 2017-12-13 18:48:03

From: r.hering@avm.de
Date: Mon, 11 Dec 2017 19:56:21 +0100
sendfile() calls can hang endless with using Kernel TLS if a socket error 
occurs.
Socket error codes must be inverted by Kernel TLS before returning because
they are stored with positive sign. If returned non-inverted they are
interpreted as number of bytes sent, causing endless looping of the
splice mechanic behind sendfile().

Signed-off-by: Robert Hering <redacted>
Your patch is corrupted by your email client, it turned TAB characters
into spaces.

Please read Documentation/email-clients.txt to fix this.

Send a test patch to yourself, and make sure you can actually apply
the patch contained in that test email.

Do not repost the patch here until you can get such a test patch
to work properly.

Thank you.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help