summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2024-09-04 14:17:41 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-23 16:16:32 +0200
commitf61dfccc5a3e26fcd2308d880d6833d2c1199c00 (patch)
tree470fc5c2a8782d33ed09d3b1d3e471926665916c /net
parent071377a13834aba5507e85e72730f73736002bc7 (diff)
downloadlinux-f61dfccc5a3e26fcd2308d880d6833d2c1199c00.tar.gz
linux-f61dfccc5a3e26fcd2308d880d6833d2c1199c00.tar.bz2
linux-f61dfccc5a3e26fcd2308d880d6833d2c1199c00.zip
net: tls: wait for async completion on last message
[ Upstream commit 54001d0f2fdbc7852136a00f3e6fc395a9547ae5 ] When asynchronous encryption is used KTLS sends out the final data at proto->close time. This becomes problematic when the task calling close() receives a signal. In this case it can happen that tcp_sendmsg_locked() called at close time returns -ERESTARTSYS and the final data is not sent. The described situation happens when KTLS is used in conjunction with io_uring, as io_uring uses task_work_add() to add work to the current userspace task. A discussion of the problem along with a reproducer can be found in [1] and [2] Fix this by waiting for the asynchronous encryption to be completed on the final message. With this there is no data left to be sent at close time. [1] https://lore.kernel.org/all/20231010141932.GD3114228@pengutronix.de/ [2] https://lore.kernel.org/all/20240315100159.3898944-1-s.hauer@pengutronix.de/ Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://patch.msgid.link/20240904-ktls-wait-async-v1-1-a62892833110@pengutronix.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> Stable-dep-of: b014a4e066c5 ("tls: wait for async encrypt in case of error during latter iterations of sendmsg") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/tls/tls_sw.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 21276ac1f81d..1f22c7adf3e5 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1228,7 +1228,7 @@ trim_sgl:
if (!num_async) {
goto send_end;
- } else if (num_zc) {
+ } else if (num_zc || eor) {
int err;
/* Wait for pending encryptions to get completed */