Repository navigation
Conversation
tsi_stream_getsockopt() calls isocket->ops->getsockopt or vsocket->ops->getsockopt unconditionally, but vsock_dgram_ops and the AF_UNIX proto_ops have no getsockopt. A getsockopt() at a level other than SOL_SOCKET on a TSI datagram socket that was proxied through vsock (for example IP_TOS on a connected UDP socket; reported with Chromium and systemd-resolved) calls a NULL pointer and oopses the guest kernel. Check the pointer and return -EOPNOTSUPP, which is what do_sock_getsockopt() returns for a socket without getsockopt. Also set err for an unexpected status instead of returning it uninitialized. Closes: libkrun#140 Signed-off-by: Daniel JB Clark <djbclark@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
djbclark
requested review from
MatiasVara,
jakecorrenti,
slp and
tylerfanelli
as code owners
October 17, 2026 21:07
The NULL-pointer fix only needs the getsockopt guards. Status is always S_HYBRID/S_INET/S_VSOCK, and the original switch had no default; keep that. Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Closes #140.
tsi_stream_getsockopt()(also used for TSI datagram sockets) callsisocket->ops->getsockoptorvsocket->ops->getsockoptwithout a NULL check, butvsock_dgram_opsand the AF_UNIXproto_opshave nogetsockopt. So agetsockopt()at a level other thanSOL_SOCKETon a socket proxied through vsock oopses the guest. Minimal trigger, on 6.12.109:This guards both calls and returns
-EOPNOTSUPP, which is whatdo_sock_getsockopt()returns for a socket withoutgetsockopt, the fix proposed in #140. It also setserrfor an unexpected status. The setsockopt paths already have this guard.The change is folded into
0011-Transparent-Socket-Impersonation-implementation.patch, the way #107 did it; onlyaf_tsi.c's hunk and the diffstat change. Checked: the full series applies to linux-6.12.109 withpatch -p1as the Makefile does,0012applies without offsets, andnet/tsi/af_tsi.obuilds for x86_64 withW=1with no new warnings. I have not booted a guest with it; the same patch is proposed for SIPB's Hyades (https://forgejo.mit.edu/SIPB/hyades/pulls/12), where the repro can be run.Prepared with an AI coding assistant; reviewed by me.