Commit 30be8f8d authored by r.hering@avm.de's avatar r.hering@avm.de Committed by David S. Miller

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

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: default avatarRobert Hering <r.hering@avm.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 95ef498d
...@@ -170,7 +170,7 @@ static inline bool tls_is_pending_open_record(struct tls_context *tls_ctx) ...@@ -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) static inline void tls_err_abort(struct sock *sk)
{ {
sk->sk_err = -EBADMSG; sk->sk_err = EBADMSG;
sk->sk_error_report(sk); sk->sk_error_report(sk);
} }
......
...@@ -391,7 +391,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) ...@@ -391,7 +391,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
while (msg_data_left(msg)) { while (msg_data_left(msg)) {
if (sk->sk_err) { if (sk->sk_err) {
ret = sk->sk_err; ret = -sk->sk_err;
goto send_end; goto send_end;
} }
...@@ -544,7 +544,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page, ...@@ -544,7 +544,7 @@ int tls_sw_sendpage(struct sock *sk, struct page *page,
size_t copy, required_size; size_t copy, required_size;
if (sk->sk_err) { if (sk->sk_err) {
ret = sk->sk_err; ret = -sk->sk_err;
goto sendpage_end; goto sendpage_end;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment