[PATCH net 0/2] tls: don't hide a queued KeyUpdate from poll()

From: Felipe Pereira Stival via B4 Relay

Date: Wed Nov 18 2026 - 15:36:40 EST


A kTLS reader that waits for a read event before each recv() can stall
after the peer sends a TLS 1.3 KeyUpdate. I ran into this while testing
a kTLS patch for Erlang/OTP.

Erlang does one recv() per read event, with level-triggered epoll.
When application data is followed by a KeyUpdate, one recv() can
decrypt both records, return the data without an error, and leave the
KeyUpdate queued. Because a rekey is now pending, poll() no longer
reports the socket as readable. Without another read event, the reader
never calls recv() again, never sees the -EIO for the KeyUpdate, and
never provides the new key.

Patch 1 keeps the socket readable until the reader has consumed the
KeyUpdate. As before, poll() doesn't report records after the
KeyUpdate until userspace provides the new key. Patch 2 adds a
selftest, which fails without patch 1.

I worked on this with an AI coding assistant (Claude). It wrote the
first drafts of the code and the commit messages, and I reviewed and
reworked them. I directed the whole process, from tracing the missing
read event to tls_sk_poll() to checking how other kinds of readers
are affected and testing in QEMU/KVM.

Signed-off-by: Felipe Pereira Stival <v0idpwn@xxxxxxxxx>
---
Felipe Pereira Stival (2):
tls: don't hide a queued KeyUpdate from poll()
selftests: tls: add a poll test for a queued KeyUpdate

Documentation/networking/tls.rst | 7 ++++---
net/tls/tls_main.c | 6 +++---
tools/testing/selftests/net/tls.c | 40 +++++++++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 6 deletions(-)
---
base-commit: 2a324a58a084c5cfd7e5a2f55e0786bee170a4a5
change-id: 20261118-v0idpwn-tls-poll-parked-keyupdate-21792b8cfe6d

Best regards,
--
Felipe Pereira Stival <v0idpwn@xxxxxxxxx>