Repository navigation
ktls: Accept anonymous EXT_SFBUF mbufs on receive (fixes #673) - #674
Merged
Merged
Conversation
Otherwise ktls_record_has_shared_mbuf() rejects mbufs created by _mb_unmapped_to_ext(), which arises when transmitting packets through an interface that doesn't support unmapped mbufs, and the loopback interface in particular. KTLS receive on a loopback connection then fails with EBADMSG for records of about a page or more, even though the sender's encrypted pages are anonymous. Adapted from FreeBSD's fix for the same regression in its version of the CVE-2026-45257 fix; our check lives in ktls_record_has_shared_mbuf() (257e33b) rather than ktls_mbuf_crypto_state(). File-backed sendfile pages are still rejected. Fixes: #673 Fixes: 257e33b ("ktls: reject shared mbufs on receive decrypt") Obtained from: FreeBSD 0af1065b3a57 AI-Assisted-by: Claude Opus 5.5 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Lucas Holt <luke@foolishgames.com>
Reviewer's GuideData structuresDefine the mbuf flag used to mark SFBUF pages originating from anonymous pages.
ImplementationPropagate the anonymous-page marker when converting unmapped mbufs, then allow marked SFBUF mbufs through the KTLS shared-mbuf check while continuing to reject unmarked ones.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #673.
Our CVE-2026-45257 fix (257e33b) makes KTLS receive reject any record that contains an
EXT_SFBUFmbuf. The loopback interface doesn't handle unmapped mbufs, so_mb_unmapped_to_ext()turns the sender's encrypted, anonymousM_EXTPGpages intoEXT_SFBUFmbufs. Valid records of about a page or more were therefore rejected with EBADMSG on any loopback connection with KTLS on both ends.This ports FreeBSD 0af1065b3a57 ("ktls: Propagate EPG_FLAG_ANON to mapped mbufs"), FreeBSD's fix for the same regression in its version of the CVE fix (FreeBSD PR 296498):
sys/sys/mbuf.h: newEXT_FLAG_SFBUF_ANON._mb_unmapped_to_ext(): setsEXT_FLAG_SFBUF_ANONwhen the source pages haveEPG_FLAG_ANON.ktls_record_has_shared_mbuf(): acceptsEXT_SFBUFmbufs that carry the flag. FreeBSD's check is inktls_mbuf_crypto_state(); ours is here.File-backed sendfile pages, the CVE case, are still rejected. They are either non-anonymous
M_EXTPG, orEXT_SFBUFwithout the flag.This is independent of #672 and merges cleanly either way.
Testing
amd64 GENERIC with INVARIANTS and WITNESS, from master plus this commit, in a bhyve guest with
ktls_ocf.koloaded:ktls_test: 271/281, the same as master.ktls_receive_loopback_sendfile, the CVE regression test from 257e33b, passes. The 10 failures are thektls_receive_unsupported_*_cbc_*errno cases from tests: ktls_test needs ktls_ocf loaded; CBC receive tests expect EPROTONOSUPPORT #667, which ktls: Build the OCF software backend into the kernel (fixes #667) #672 fixes.KTLS loopback with kernel receive: a guest-only program sends a 400 KiB file through a KTLS loopback connection with kernel KTLS receive on the peer. It covers 8 offset and length mixes (1 byte to 400 KiB, unaligned and page-aligned) and 10 suites (AES-GCM 128/256 and ChaCha20-Poly1305 for TLS 1.2 and 1.3; AES-CBC for TLS 1.0, 1.1 and 1.2).
rxwriteuserCBC runs use userspace decryption in every mode, because KTLS receive doesn't support CBC.
No lock-order reversals and no panics during the tests.
🤖 Generated with Claude Code
Summary by Sourcery
Restore KTLS loopback receive support for records backed by anonymous sendfile pages while preserving protection against shared file-backed buffers.
Bug Fixes:
Enhancements: