Message ID | OF6F0DE70F.1C59BE55-ONC12581F3.0066F1BE-C12581F3.0068093A@avm.de |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
Series | net/tls: Fix inverted error codes to avoid endless loop | expand |
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 <r.hering@avm.de> 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.
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; }
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; }