Re: [PATCH] tls: defer close to kernel task

From: Sascha Hauer
Date: Fri Apr 12 2024 - 03:26:16 EST


On Wed, Apr 10, 2024 at 06:11:28AM -0700, Jakub Kicinski wrote:
> On Wed, 10 Apr 2024 08:33:07 +0200 Sascha Hauer wrote:
> > proto->close is normally called from a userspace task which can be
> > interrupted by signals. When asynchronous encryption is used then KTLS
> > sends out the final data at close time. When a signal comes in during
> > close then it can happen tcp_sendmsg_locked() is interrupted by that
> > signal while waiting for memory in sk_stream_wait_memory() which then
> > returns with -ERSTARTSYS. It is not possible to recover from this situation
> > and the final transmit data is lost.
> >
> > With this patch we defer the close operation to a kernel task which
> > doesn't get signals.
> >
> > 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.
> >
> > The problem is discussed in [1] and [2] and the solution implemented in
> > this patch is suggested by Pavel Begunkov here [3]
>
> Appears to crash reliably.
> Please run the tls selftests with KASAN enabled.

Oops, will run the tests and fix the fallout before resending.

Sascha

--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |