Commit 2cb75c87 authored by Sascha Hauer's avatar Sascha Hauer Committed by Greg Kroah-Hartman
Browse files

net: tls: wait for async completion on last message

[ Upstream commit 54001d0f ]

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: default avatarSascha Hauer <s.hauer@pengutronix.de>
Link: https://patch.msgid.link/20240904-ktls-wait-async-v1-1-a62892833110@pengutronix.de


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Stable-dep-of: b014a4e0 ("tls: wait for async encrypt in case of error during latter iterations of sendmsg")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 4de9057a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment