netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tls: Stricter error checking in zerocopy sendmsg path
@ 2018-07-12 15:03 Dave Watson
  2018-07-16 20:32 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Watson @ 2018-07-12 15:03 UTC (permalink / raw)
  To: Boris Pismenny, davem@davemloft.net, netdev@vger.kernel.org,
	aviadye@mellanox.com, Daniel Borkmann, doronrk, Vakul Garg

In the zerocopy sendmsg() path, there are error checks to revert
the zerocopy if we get any error code.  syzkaller has discovered
that tls_push_record can return -ECONNRESET, which is fatal, and
happens after the point at which it is safe to revert the iter,
as we've already passed the memory to do_tcp_sendpages.

Previously this code could return -ENOMEM and we would want to
revert the iter, but AFAIK this no longer returns ENOMEM after
a447da7d004 ("tls: fix waitall behavior in tls_sw_recvmsg"),
so we fail for all error codes.

Reported-by: syzbot+c226690f7b3126c5ee04@syzkaller.appspotmail.com
Reported-by: syzbot+709f2810a6a05f11d4d3@syzkaller.appspotmail.com
Signed-off-by: Dave Watson <davejwatson@fb.com>
Fixes: 3c4d7559159b ("tls: kernel TLS support")
---
 net/tls/tls_sw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 7818011fd250..4618f1c31137 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -440,7 +440,7 @@ int tls_sw_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
 			ret = tls_push_record(sk, msg->msg_flags, record_type);
 			if (!ret)
 				continue;
-			if (ret == -EAGAIN)
+			if (ret < 0)
 				goto send_end;
 
 			copied -= try_to_copy;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] tls: Stricter error checking in zerocopy sendmsg path
  2018-07-12 15:03 [PATCH net] tls: Stricter error checking in zerocopy sendmsg path Dave Watson
@ 2018-07-16 20:32 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-16 20:32 UTC (permalink / raw)
  To: davejwatson; +Cc: borisp, netdev, aviadye, daniel, doronrk, vakul.garg

From: Dave Watson <davejwatson@fb.com>
Date: Thu, 12 Jul 2018 08:03:43 -0700

> In the zerocopy sendmsg() path, there are error checks to revert
> the zerocopy if we get any error code.  syzkaller has discovered
> that tls_push_record can return -ECONNRESET, which is fatal, and
> happens after the point at which it is safe to revert the iter,
> as we've already passed the memory to do_tcp_sendpages.
> 
> Previously this code could return -ENOMEM and we would want to
> revert the iter, but AFAIK this no longer returns ENOMEM after
> a447da7d004 ("tls: fix waitall behavior in tls_sw_recvmsg"),
> so we fail for all error codes.
> 
> Reported-by: syzbot+c226690f7b3126c5ee04@syzkaller.appspotmail.com
> Reported-by: syzbot+709f2810a6a05f11d4d3@syzkaller.appspotmail.com
> Signed-off-by: Dave Watson <davejwatson@fb.com>
> Fixes: 3c4d7559159b ("tls: kernel TLS support")

Applied and queued up for -stable, thanks Dave.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-16 21:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-12 15:03 [PATCH net] tls: Stricter error checking in zerocopy sendmsg path Dave Watson
2018-07-16 20:32 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).