Skip to content

tun: validate acquired Linux TUN packet formats - #142

Merged
raggi merged 1 commit into
tailscalefrom
raggi/recover-tun-9c2b5db8
Nov 21, 2026
Merged

raggi merged 1 commit into
tailscalefrom
raggi/recover-tun-9c2b5db8

Conversation

@raggi

@raggi raggi commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Reject embedded NULs in interface names and check the flags returned by
TUNGETIFF against the requested packet format. Permit older kernels to
ignore IFF_MULTI_QUEUE, but reject unexpected multiqueue mode or
incompatible TUN, packet-info, or virtio-header flags.

For queues using virtio headers, require the header size expected by our
packet parser and native byte order. Treat unavailable byte-order ioctls
as native-endian defaults for compatibility with older kernels.

Keep these safety checks separate from interface acquisition and active
queue accounting. Add table-driven tests for incompatible headers and
queue cleanup after validation or initialization failure.

Updates tailscale/tailscale#22475

Signed-off-by: James Tucker james@tailscale.com

@raggi
raggi marked this pull request as ready for review November 20, 2026 22:04
@raggi
raggi force-pushed the raggi/recover-tun-725b0470 branch from 8f7edfc to bdf9922 Compare November 20, 2026 22:45
@raggi
raggi force-pushed the raggi/recover-tun-9c2b5db8 branch 2 times, most recently from b151d0d to 611c1cb Compare November 20, 2026 23:01
@raggi
raggi changed the base branch from raggi/recover-tun-725b0470 to tailscale November 20, 2026 23:01

@illotum illotum left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Took me a while to parse the flag predicate.

Reject embedded NULs in interface names and check the flags returned by
TUNGETIFF against the requested packet format. Permit older kernels to
ignore IFF_MULTI_QUEUE, but reject unexpected multiqueue mode or
incompatible TUN, packet-info, or virtio-header flags.

For queues using virtio headers, require the header size expected by our
packet parser and native byte order. Treat unavailable byte-order ioctls
as native-endian defaults for compatibility with older kernels.

Keep these safety checks separate from interface acquisition and active
queue accounting. Add table-driven tests for incompatible headers and
queue cleanup after validation or initialization failure.

Updates tailscale/tailscale#22475

Signed-off-by: James Tucker <james@tailscale.com>
Change-Id: I9c2b5db868840ec2ad3b9a272598e4e388c34de4
@raggi
raggi force-pushed the raggi/recover-tun-9c2b5db8 branch from 611c1cb to 1d7ef0d Compare November 20, 2026 23:46
@raggi

raggi commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

LGTM. Took me a while to parse the flag predicate.

totally fair, i split it out into some local variables for clarity

@raggi
raggi merged commit a8c4fbf into tailscale Nov 21, 2026
15 checks passed
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.

2 participants