diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-30 21:37:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-30 21:37:12 +0300 |
| commit | 6be2f977861bda44d10d5f261e220619353233eb (patch) | |
| tree | f4f02419103df7db9a4cce69f9915281202ccadc /internal/generate/family_test.go | |
| parent | aeced89f46253e0b4813bbbd89362a0c4466f2d7 (diff) | |
test(setsockopt): lock in KindFd enter, UNCLASSIFIED exit, Network family
Audit of setsockopt(2) found the tracing implementation already correct:
sockfd captured at ctx->args[0] (KindFd), exit ret_event UNCLASSIFIED, and
FamilyNetwork — matching the man page and the bind/connect/getsockname/
getpeername/getsockopt siblings, with generated C/Go and docs all consistent.
Add lock-in tests mirroring prior per-syscall audits:
- TestClassifySetsockoptEnterFd: enter is KindFd with no pathname capture,
asserted against the real sockfd/level/optname/optval/optlen fields.
- TestClassifyExitSetsockoptUnclassifiedRet: exit is KindRet + UNCLASSIFIED
(0/-1 status, not a byte count).
- TestClassifyExitGetsockoptUnclassifiedRet: same for the read-side sibling.
- TestClassifySyscallFamily: pin setsockopt (enter+exit) and getsockopt to
FamilyNetwork.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate/family_test.go')
| -rw-r--r-- | internal/generate/family_test.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/generate/family_test.go b/internal/generate/family_test.go index 9fe3ecf..943994e 100644 --- a/internal/generate/family_test.go +++ b/internal/generate/family_test.go @@ -20,6 +20,16 @@ func TestClassifySyscallFamily(t *testing.T) { {"sys_enter_listen", FamilyNetwork}, {"sys_enter_getsockname", FamilyNetwork}, {"sys_enter_getpeername", FamilyNetwork}, + // setsockopt(2)/getsockopt(2) set and read socket options on the socket + // referred to by sockfd (args[0], KindFd). They are socket-configuration + // syscalls and share FamilyNetwork with the bind/connect/getsockname/ + // getpeername siblings above. Assert both enter and exit for the + // setsockopt pair so a stray reclassification of either direction trips + // this test; keep in sync with the Network list in + // docs/syscall-tracing-plan.md. + {"sys_enter_setsockopt", FamilyNetwork}, + {"sys_exit_setsockopt", FamilyNetwork}, + {"sys_enter_getsockopt", FamilyNetwork}, {"sys_enter_pipe2", FamilyIPC}, {"sys_enter_munmap", FamilyMemory}, // process_madvise(2) gives memory advice (MADV_COLD/PAGEOUT/...) about |
