]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
bpf, ktls: Fix data corruption when using bpf_msg_pop_data() in ktls
authorJiayuan Chen <jiayuan.chen@linux.dev>
Mon, 9 Jun 2025 02:08:52 +0000 (10:08 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 15 Aug 2025 10:08:44 +0000 (12:08 +0200)
commit0e853c1464bcf61207f8b5c32d2ac5ee495e859d
treed0a6456fe47e4fbfb0cd60d2a61ee6b498f984b1
parentc69d06498ea2970c9f720da9cc5bf686bcdbf2b4
bpf, ktls: Fix data corruption when using bpf_msg_pop_data() in ktls

[ Upstream commit 178f6a5c8cb3b6be1602de0964cd440243f493c9 ]

When sending plaintext data, we initially calculated the corresponding
ciphertext length. However, if we later reduced the plaintext data length
via socket policy, we failed to recalculate the ciphertext length.

This results in transmitting buffers containing uninitialized data during
ciphertext transmission.

This causes uninitialized bytes to be appended after a complete
"Application Data" packet, leading to errors on the receiving end when
parsing TLS record.

Fixes: d3b18ad31f93 ("tls: add bpf support to sk_msg handling")
Reported-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/bpf/20250609020910.397930-2-jiayuan.chen@linux.dev
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/tls/tls_sw.c