Skip to content

tsi: fix tsi_create and hijack AF_INET6 - #100

Closed
slp wants to merge 1 commit into
libkrun:mainfrom
slp:fix-tsi-create
Closed

slp wants to merge 1 commit into
libkrun:mainfrom
slp:fix-tsi-create

Conversation

@slp

@slp slp commented Sep 8, 2025

Copy link
Copy Markdown
Collaborator

Fix an issue where tsi_create may attempt to exit releasing sockets that hasn't been allocated.

While there, make "tsi_hijack" also hijack AF_INET6 sockets. Some applications (like ones built with recent Go libraries) attempt to bind to AF_INET6 sockets only, relying on the kernel's ability to bind on AF_INET transparently. For TSI, this means those sockets won't be hijacked and exposed to the host.

By hijacking AF_INET6 sockets, the application receives EAFNOSUPPORT when binding the socket, leading to it attempting again to bind using AF_INET.

Fixes: #99

Fix an issue where tsi_create may attempt to exit releasing
sockets that hasn't been allocated.

While there, make "tsi_hijack" also hijack AF_INET6 sockets. Some
applications (like ones built with recent Go libraries) attempt
to bind to AF_INET6 sockets only, relying on the kernel's ability
to bind on AF_INET transparently. For TSI, this means those
sockets won't be hijacked and exposed to the host.

By hijacking AF_INET6 sockets, the application receives
EAFNOSUPPORT when binding the socket, leading to it attempting
again to bind using AF_INET.

Fixes: libkrun#99

Signed-off-by: Sergio Lopez <slp@redhat.com>
@raphaelcoeffic

Copy link
Copy Markdown

This works for me now, thanks a lot! Starting the API as usual, which would normally bring up MPTCP and dual-stack socket. With this patch in place, I get only IPv4 TCP, as expected.

# ss -ltnp sport 3000
State              Recv-Q             Send-Q                          Local Address:Port                           Peer Address:Port             Process                                          
LISTEN             0                  4096                                  0.0.0.0:3000                                0.0.0.0:*                 users:(("VM:nuc",pid=72134,fd=566))             

@slp
slp marked this pull request as draft September 12, 2025 16:05
@slp

slp commented Sep 12, 2025

Copy link
Copy Markdown
Collaborator Author

Turns our hijacking AF_INET6 and returning EAFNOSUPPORT breaks many applications, such as nginx. So we need to do the right thing and implement transparency support for AF_INET6 too.

Closing this one in favor of #101

@slp slp closed this Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel NULL pointer dereference when MPTCP socket creation is attempted

2 participants