Bug 296498 - ktls broken in 15.0-RELEASE-p10
Summary: ktls broken in 15.0-RELEASE-p10
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2026-07-03 14:35 UTC by Patrick Mackinlay
Modified: 2026-09-03 07:22 UTC (History)
4 users (show)

See Also:
markj: mfc-stable15+
markj: mfc-stable14+
markj: needs_errata?


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Mackinlay 2026-07-03 14:35:09 UTC
I recently upgraded from  15.0-RELEASE-p9 to 15.0-RELEASE-p10 and a ktls test I have running as part of a software build for several years stopped working. This test simply creates a local TLS connection and sends some data to and from the peers. The test uses openssl (base) with  SSL_OP_ENABLE_KTLS such that ktls is used if enabled (which it has been for several years).

Since the kernel upgrade I get a EBADMSG error in the server when reading the initial data sent from the client.

Note that if I dont set SSL_OP_ENABLE_KTLS on either end of the connection the test works fine. It also works fine for kern.ipc.tls.enable=0
Comment 1 Patrick Mackinlay 2026-07-03 17:55:37 UTC
The was broken in commit
https://cgit.freebsd.org/src/commit/?id=540a315cdb46d6aa3cdbb3797710db652b3c4f4a
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2026-07-03 18:39:38 UTC
^Triage: Cc: committer in question.
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2026-07-03 20:03:43 UTC
Are you able to test patches?  If so, does this fix the problem? https://reviews.freebsd.org/D57557
Comment 4 Patrick Mackinlay 2026-07-03 20:50:28 UTC
(In reply to Mark Johnston from comment #3)

Yes! This does fix it, I applied it directly to the tree at the broken commit (since I had that built)
Comment 5 commit-hook freebsd_committer freebsd_triage 2026-07-29 20:01:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=815976ee14121bafe8a8ab002459d32f8928f2de

commit 815976ee14121bafe8a8ab002459d32f8928f2de
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-29 18:45:36 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-07-29 19:30:37 +0000

    ktls: Propagate EPG_FLAG_ANON to mapped mbufs

    Otherwise ktls_mbuf_crypto_state() will reject 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.

    PR:             296498
    Fixes:          3444414cb463 ("ktls: Don't attempt to modify non-anonymous mbufs on the receive path")
    Reviewed by:    gallatin, jhb
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D57557

 sys/kern/kern_mbuf.c | 3 +++
 sys/kern/uipc_ktls.c | 3 ++-
 sys/sys/mbuf.h       | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2026-08-05 15:17:02 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0af1065b3a5721a9e5433622dcc8a7adb96ad2ed

commit 0af1065b3a5721a9e5433622dcc8a7adb96ad2ed
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-29 18:45:36 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-08-05 15:15:14 +0000

    ktls: Propagate EPG_FLAG_ANON to mapped mbufs

    Otherwise ktls_mbuf_crypto_state() will reject 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.

    PR:             296498
    Fixes:          3444414cb463 ("ktls: Don't attempt to modify non-anonymous mbufs on the receive path")
    Reviewed by:    gallatin, jhb
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D57557

    (cherry picked from commit 815976ee14121bafe8a8ab002459d32f8928f2de)

 sys/kern/kern_mbuf.c | 3 +++
 sys/kern/uipc_ktls.c | 3 ++-
 sys/sys/mbuf.h       | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2026-08-06 15:02:00 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=9d2e5039ee18eb9545b26a8934e650c1f06139cb

commit 9d2e5039ee18eb9545b26a8934e650c1f06139cb
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-07-29 18:45:36 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-08-06 13:24:43 +0000

    ktls: Propagate EPG_FLAG_ANON to mapped mbufs

    Otherwise ktls_mbuf_crypto_state() will reject 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.

    PR:             296498
    Fixes:          3444414cb463 ("ktls: Don't attempt to modify non-anonymous mbufs on the receive path")
    Reviewed by:    gallatin, jhb
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D57557

    (cherry picked from commit 815976ee14121bafe8a8ab002459d32f8928f2de)

 sys/kern/kern_mbuf.c | 3 +++
 sys/kern/uipc_ktls.c | 3 ++-
 sys/sys/mbuf.h       | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)
Comment 8 Wes Morgan 2026-08-30 02:36:12 UTC
This seems like it was MFC'd, but I'm still experiencing the problem. Noticed that pkg was complaining about bad checksums from my poudriere builds and finally narrowed it down to this issue. Turning off ktls or using HTTP/2 in lighttpd "bypasses" the issue.
Comment 9 Patrick Mackinlay 2026-09-03 07:22:07 UTC
Its not in

Its not in 15.1-RELEASE-p3