All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] net/tls: fix poll() wake up
@ 2019-07-04 21:50 Jakub Kicinski
  2019-07-04 21:50 ` [PATCH net 1/2] net/tls: fix poll ignoring partially copied records Jakub Kicinski
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-07-04 21:50 UTC (permalink / raw)
  To: davem; +Cc: netdev, oss-drivers, alexei.starovoitov, Jakub Kicinski

Hi!

This small fix + selftest series is very similar to the previous
commit 04b25a5411f9 ("net/tls: fix no wakeup on partial reads").
This time instead of recvmsg we're fixing poll wake up.

Jakub Kicinski (2):
  net/tls: fix poll ignoring partially copied records
  selftests/tls: add test for poll() with data in TLS ULP

 net/tls/tls_sw.c                  |  3 ++-
 tools/testing/selftests/net/tls.c | 26 ++++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)

-- 
2.21.0


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

* [PATCH net 1/2] net/tls: fix poll ignoring partially copied records
  2019-07-04 21:50 [PATCH net 0/2] net/tls: fix poll() wake up Jakub Kicinski
@ 2019-07-04 21:50 ` Jakub Kicinski
  2019-07-04 21:50 ` [PATCH net 2/2] selftests/tls: add test for poll() with data in TLS ULP Jakub Kicinski
  2019-07-07 21:13 ` [PATCH net 0/2] net/tls: fix poll() wake up David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-07-04 21:50 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, alexei.starovoitov, Jakub Kicinski,
	David Beckett, Dirk van der Merwe

David reports that RPC applications which use epoll() occasionally
get stuck, and that TLS ULP causes the kernel to not wake applications,
even though read() will return data.

This is indeed true. The ctx->rx_list which holds partially copied
records is not consulted when deciding whether socket is readable.

Note that SO_RCVLOWAT with epoll() is and has always been broken for
kernel TLS. We'd need to parse all records from the TCP layer, instead
of just the first one.

Fixes: 692d7b5d1f91 ("tls: Fix recvmsg() to be able to peek across multiple records")
Reported-by: David Beckett <david.beckett@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 net/tls/tls_sw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 455a782c7658..e2385183526e 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1958,7 +1958,8 @@ bool tls_sw_stream_read(const struct sock *sk)
 		ingress_empty = list_empty(&psock->ingress_msg);
 	rcu_read_unlock();
 
-	return !ingress_empty || ctx->recv_pkt;
+	return !ingress_empty || ctx->recv_pkt ||
+		!skb_queue_empty(&ctx->rx_list);
 }
 
 static int tls_read_size(struct strparser *strp, struct sk_buff *skb)
-- 
2.21.0


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

* [PATCH net 2/2] selftests/tls: add test for poll() with data in TLS ULP
  2019-07-04 21:50 [PATCH net 0/2] net/tls: fix poll() wake up Jakub Kicinski
  2019-07-04 21:50 ` [PATCH net 1/2] net/tls: fix poll ignoring partially copied records Jakub Kicinski
@ 2019-07-04 21:50 ` Jakub Kicinski
  2019-07-07 21:13 ` [PATCH net 0/2] net/tls: fix poll() wake up David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2019-07-04 21:50 UTC (permalink / raw)
  To: davem
  Cc: netdev, oss-drivers, alexei.starovoitov, Jakub Kicinski,
	Dirk van der Merwe

Add a test which checks if leftover record data in TLS
layer correctly wakes up poll().

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 tools/testing/selftests/net/tls.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/tools/testing/selftests/net/tls.c b/tools/testing/selftests/net/tls.c
index 278c86134556..090fff9dbc48 100644
--- a/tools/testing/selftests/net/tls.c
+++ b/tools/testing/selftests/net/tls.c
@@ -644,6 +644,32 @@ TEST_F(tls, poll_wait)
 	EXPECT_EQ(recv(self->cfd, recv_mem, send_len, MSG_WAITALL), send_len);
 }
 
+TEST_F(tls, poll_wait_split)
+{
+	struct pollfd fd = { 0, 0, 0 };
+	char send_mem[20] = {};
+	char recv_mem[15];
+
+	fd.fd = self->cfd;
+	fd.events = POLLIN;
+	/* Send 20 bytes */
+	EXPECT_EQ(send(self->fd, send_mem, sizeof(send_mem), 0),
+		  sizeof(send_mem));
+	/* Poll with inf. timeout */
+	EXPECT_EQ(poll(&fd, 1, -1), 1);
+	EXPECT_EQ(fd.revents & POLLIN, 1);
+	EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), MSG_WAITALL),
+		  sizeof(recv_mem));
+
+	/* Now the remaining 5 bytes of record data are in TLS ULP */
+	fd.fd = self->cfd;
+	fd.events = POLLIN;
+	EXPECT_EQ(poll(&fd, 1, -1), 1);
+	EXPECT_EQ(fd.revents & POLLIN, 1);
+	EXPECT_EQ(recv(self->cfd, recv_mem, sizeof(recv_mem), 0),
+		  sizeof(send_mem) - sizeof(recv_mem));
+}
+
 TEST_F(tls, blocking)
 {
 	size_t data = 100000;
-- 
2.21.0


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

* Re: [PATCH net 0/2] net/tls: fix poll() wake up
  2019-07-04 21:50 [PATCH net 0/2] net/tls: fix poll() wake up Jakub Kicinski
  2019-07-04 21:50 ` [PATCH net 1/2] net/tls: fix poll ignoring partially copied records Jakub Kicinski
  2019-07-04 21:50 ` [PATCH net 2/2] selftests/tls: add test for poll() with data in TLS ULP Jakub Kicinski
@ 2019-07-07 21:13 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-07-07 21:13 UTC (permalink / raw)
  To: jakub.kicinski; +Cc: netdev, oss-drivers, alexei.starovoitov

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Thu,  4 Jul 2019 14:50:35 -0700

> This small fix + selftest series is very similar to the previous
> commit 04b25a5411f9 ("net/tls: fix no wakeup on partial reads").
> This time instead of recvmsg we're fixing poll wake up.

Series applied and patch #1 queued up for -stable.

Thanks!

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

end of thread, other threads:[~2019-07-07 21:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 21:50 [PATCH net 0/2] net/tls: fix poll() wake up Jakub Kicinski
2019-07-04 21:50 ` [PATCH net 1/2] net/tls: fix poll ignoring partially copied records Jakub Kicinski
2019-07-04 21:50 ` [PATCH net 2/2] selftests/tls: add test for poll() with data in TLS ULP Jakub Kicinski
2019-07-07 21:13 ` [PATCH net 0/2] net/tls: fix poll() wake up David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.