summaryrefslogtreecommitdiff
path: root/internal/generate
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-28 10:43:37 +0300
committerPaul Buetow <paul@buetow.org>2026-05-28 10:43:37 +0300
commitff8774b5ce3f6b37e5152d0dc06ae46b7a36d1da (patch)
tree7224ccb001a0945216d6e30b5b9c326396ceba76 /internal/generate
parent99e99c6ea35ae97e84d727449f9ad7c4c0a9fa23 (diff)
close_range: honor last bound and CLOSE_RANGE_CLOEXEC flag
close_range was captured as a single-fd fd_event carrying only first, so the runtime evicted every tracked fd >= first, ignoring the last upper bound and the flags. Bounded calls wrongly dropped still-open higher fds, and CLOSE_RANGE_CLOEXEC (which keeps fds open) was treated as a full close. Reclassify close_range to the two_fd_event kind, mapping fd_a/fd_b/extra to first/last/flags. The runtime now closes only the inclusive [first, last] range (a negative last from ~0U means unbounded) and skips eviction when CLOSE_RANGE_CLOEXEC is set or the syscall fails. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'internal/generate')
-rw-r--r--internal/generate/classify.go11
-rw-r--r--internal/generate/classify_test.go1
2 files changed, 9 insertions, 3 deletions
diff --git a/internal/generate/classify.go b/internal/generate/classify.go
index 7dcbf5a..b7e9c0f 100644
--- a/internal/generate/classify.go
+++ b/internal/generate/classify.go
@@ -241,9 +241,14 @@ var nameOnlyKindsTable = map[string]TracepointKind{
"sys_enter_epoll_ctl": KindEpollCtl,
"sys_enter_move_mount": KindTwoFd,
- "sys_enter_statmount": KindNull,
- "sys_enter_listmount": KindNull,
- "sys_enter_listns": KindNull,
+ // close_range(first, last, flags) needs all three arguments, so it is a
+ // two_fd_event (fd_a=first, fd_b=last, extra=flags) rather than a single-fd
+ // fd_event. This lets the runtime honour the upper bound and the
+ // CLOSE_RANGE_CLOEXEC flag instead of closing every fd >= first.
+ "sys_enter_close_range": KindTwoFd,
+ "sys_enter_statmount": KindNull,
+ "sys_enter_listmount": KindNull,
+ "sys_enter_listns": KindNull,
"sys_enter_poll": KindPoll,
"sys_enter_ppoll": KindPoll,
diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go
index 618274a..46947e2 100644
--- a/internal/generate/classify_test.go
+++ b/internal/generate/classify_test.go
@@ -1401,6 +1401,7 @@ func TestClassifySyscallPairAccepted(t *testing.T) {
{"mount", FormatMount, FormatExitMount, KindPathname},
{"umount", FormatUmount, FormatExitUmount, KindPathname},
{"move_mount", FormatMoveMount, FormatExitMoveMount, KindTwoFd},
+ {"close_range", syntheticEnter("close_range", 9322), syntheticExit("close_range", 9321), KindTwoFd},
{"kcmp", syntheticEnter("kcmp", 9324), syntheticExit("kcmp", 9323), KindTwoFd},
{"kexec_file_load", syntheticEnter("kexec_file_load", 9326), syntheticExit("kexec_file_load", 9325), KindFd},
{"membarrier", syntheticEnter("membarrier", 9328), syntheticExit("membarrier", 9327), KindNull},