]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
tls: device: push pending open record on splice EOF
authorRishikesh Jethwani <rjethwani@purestorage.com>
Thu, 9 Jul 2026 22:44:36 +0000 (16:44 -0600)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Jul 2026 21:50:50 +0000 (14:50 -0700)
On kTLS device-offload sockets, sendfile() with count > EOF can reach
->splice_eof() with a fully assembled but still-open TLS record left
pending. tls_device_splice_eof() only flushes partially sent records,
so an abrupt close() can drop the final record and the peer receives
a short file.

Fix tls_device_splice_eof() to also push pending open records.
This matches the software path, where splice EOF already flushes
pending open records.

Fixes: d4c1e80b0d1b ("tls/device: Use splice_eof() to flush")
Link: https://lore.kernel.org/netdev/CAMPsyauZ+jzG9AysO0FWv6ZY0kvCUpjX_U7o=oOjCuOQ87BCgg@mail.gmail.com/
Reported-by: Nils Juenemann <nils.juenemann@gmail.com>
Signed-off-by: Rishikesh Jethwani <rjethwani@purestorage.com>
Tested-by: Nils Juenemann <nils.juenemann@gmail.com>
Link: https://patch.msgid.link/20260709224436.1608993-2-rjethwani@purestorage.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/tls/tls_device.c

index 741aef09bfd356a852aae4182e187443a43a2625..37bb06a8e8f5b5b3067f5fe25aa743b54483ec17 100644 (file)
@@ -595,13 +595,15 @@ void tls_device_splice_eof(struct socket *sock)
        struct tls_context *tls_ctx = tls_get_ctx(sk);
        struct iov_iter iter = {};
 
-       if (!tls_is_partially_sent_record(tls_ctx))
+       if (!tls_is_partially_sent_record(tls_ctx) &&
+           !tls_is_pending_open_record(tls_ctx))
                return;
 
        mutex_lock(&tls_ctx->tx_lock);
        lock_sock(sk);
 
-       if (tls_is_partially_sent_record(tls_ctx)) {
+       if (tls_is_partially_sent_record(tls_ctx) ||
+           tls_is_pending_open_record(tls_ctx)) {
                iov_iter_bvec(&iter, ITER_SOURCE, NULL, 0, 0);
                tls_push_data(sk, &iter, 0, 0, TLS_RECORD_TYPE_DATA);
        }