Skip to content

Fix connected UDP learning - #196

Merged
congwang-mk merged 1 commit into
mainfrom
udp-send-time-gating
Aug 11, 2026
Merged

Fix connected UDP learning#196
congwang-mk merged 1 commit into
mainfrom
udp-send-time-gating

Conversation

@congwang-mk

Copy link
Copy Markdown
Contributor

Summary

Fix connected UDP learning and TCP-only network profiles.

TCP-only network profiles now allow UDP socket creation so libc
DNS/address-selection probes can run, while actual UDP traffic remains gated
at connect/send/bind time.

sandlock learn now promotes a pending UDP connect when it observes an
address-less UDP send, including when connect and send happen on sibling
threads sharing the same fd table.

Tests

  • cargo test -p sandlock-core test_arg_filters_udp -- --nocapture
  • cargo test -p sandlock-core --test integration test_udp_send_time_gating_with_tcp_only_rules -- --nocapture
  • cargo test -p sandlock-cli --test learn_integration connected_udp -- --nocapture --test-threads=1

Allow TCP-only network profiles to create UDP sockets while keeping
actual UDP traffic gated at connect/send/bind time. This lets libc
DNS/address-selection probes work without opening UDP egress.

Teach sandlock learn to promote a pending UDP connect when an
address-less UDP send is observed, including when connect and send occur
on sibling threads sharing the same fd table.

Add learn-to-run connected UDP regression coverage and runtime tests
proving TCP-only rules still deny UDP send, connect, and bind
operations.

Signed-off-by: Cong Wang <cwang@multikernel.io>
@congwang-mk
congwang-mk marked this pull request as ready for review August 11, 2026 00:39
@congwang-mk

congwang-mk commented Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

@ghazariann Please take a look. Thanks!

@ghazariann

ghazariann commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

LGTM.

I just realized that I missed the comment in #165 earlier; glad this PR picks it up and fixes it, thanks!

I'm interested in whether the glibc's getaddrinfo address-sorting probe breakage in sandlock run was found analytically or empirically (if empirically, which workload exposed it? ).

Also, learn_then_run_script is a good pattern, worth generalizing and migrating more tests to it.

@congwang-mk

Copy link
Copy Markdown
Contributor Author

LGTM.

I just realized that I missed the comment in #165 earlier; glad this PR picks it up and fixes it, thanks!

I'm interested in whether the glibc's getaddrinfo address-sorting probe breakage in sandlock run was found analytically or empirically (if empirically, which workload exposed it? ).

Also, learn_then_run_script is a good pattern, worth generalizing and migrating more tests to it.

Thanks for review. I found it during a manual run of ./target/release/sandlock learn --collapse-prefix /usr -- curl "https://www.google.com"

@congwang-mk
congwang-mk merged commit 3fa1220 into main Aug 11, 2026
17 checks passed
@congwang-mk
congwang-mk deleted the udp-send-time-gating branch August 11, 2026 19:52
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