diff mbox series

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

Message ID OFB355F51D.12739AB9-ONC12581F6.0067C72B-C12581F6.0067EF4E@avm.de
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series net/tls: Fix inverted error codes to avoid endless loop | expand

Commit Message

r.hering@avm.de Dec. 14, 2017, 6:55 p.m. UTC
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 <r.hering@avm.de>
---
 
@@ -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;
                }

Comments

David Miller Dec. 15, 2017, 6:49 p.m. UTC | #1
From: r.hering@avm.de
Date: Thu, 14 Dec 2017 19:55:14 +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 <r.hering@avm.de>

Your patch is corrupted again, exactly the same like last time.

I asked you politely to send a test patch to yourself, and make sure you
could apply the patch cleanly.

Because TABs have been corrupted into spaces, exactly like last time,
I cannot see how you could have possibly succesfully done such a test
before posting here again.

Please fix this properly, get your email client sending patches without
modifying the text, and only then resubmit this patch.

Thank you.
diff mbox series

Patch

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;
                }