summaryrefslogtreecommitdiff
path: root/internal/generate
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-21 18:02:16 +0300
committerPaul Buetow <paul@buetow.org>2026-05-21 18:02:16 +0300
commitd29bdc79feb118dcbc27a4aa4a0bd14216b1664e (patch)
treeaf28c263a813a5114f06641a34a7ac8da3144ebe /internal/generate
parent1a0f4086b0dff03eebcc22f1b5522cc1a9c25643 (diff)
o7 classify landlock add-rule and restrict-self as fd
Diffstat (limited to 'internal/generate')
-rw-r--r--internal/generate/classify.go4
-rw-r--r--internal/generate/classify_test.go23
-rw-r--r--internal/generate/codegen_test.go10
3 files changed, 37 insertions, 0 deletions
diff --git a/internal/generate/classify.go b/internal/generate/classify.go
index e42d4a0..5660eb1 100644
--- a/internal/generate/classify.go
+++ b/internal/generate/classify.go
@@ -257,6 +257,10 @@ func classifyNameOnly(name string) (ClassificationResult, bool) {
return ClassificationResult{Kind: KindEventfd}, true
case "sys_exit_landlock_create_ruleset":
return ClassificationResult{Kind: KindEventfd}, true
+ case "sys_enter_landlock_add_rule":
+ return ClassificationResult{Kind: KindFd}, true
+ case "sys_enter_landlock_restrict_self":
+ return ClassificationResult{Kind: KindFd}, true
case "sys_enter_fsopen":
return ClassificationResult{Kind: KindEventfd}, true
case "sys_exit_fsopen":
diff --git a/internal/generate/classify_test.go b/internal/generate/classify_test.go
index ae77fb0..ece25c6 100644
--- a/internal/generate/classify_test.go
+++ b/internal/generate/classify_test.go
@@ -887,6 +887,27 @@ func TestClassifyM7NameOnlyKinds(t *testing.T) {
}
}
+func TestClassifyO7NameOnlyKinds(t *testing.T) {
+ tests := []string{
+ "sys_enter_landlock_add_rule",
+ "sys_enter_landlock_restrict_self",
+ }
+ for _, name := range tests {
+ t.Run(name, func(t *testing.T) {
+ r := ClassifyFormat(&Format{
+ Name: name,
+ ExternalFields: []Field{
+ {Type: "long", Name: "__syscall_nr"},
+ {Type: "long", Name: "arg0"},
+ },
+ })
+ if r.Kind != KindFd {
+ t.Fatalf("%s: got kind %d, want KindFd", name, r.Kind)
+ }
+ })
+ }
+}
+
func TestClassify67NameOnlyKinds(t *testing.T) {
tests := []struct {
name string
@@ -1333,6 +1354,8 @@ func TestClassifySyscallPairAccepted(t *testing.T) {
{"inotify_init1", syntheticEnter("inotify_init1", 9346), syntheticExit("inotify_init1", 9345), KindEventfd},
{"fanotify_init", syntheticEnter("fanotify_init", 9348), syntheticExit("fanotify_init", 9347), KindEventfd},
{"landlock_create_ruleset", syntheticEnter("landlock_create_ruleset", 9350), syntheticExit("landlock_create_ruleset", 9349), KindEventfd},
+ {"landlock_add_rule", syntheticEnter("landlock_add_rule", 9418), syntheticExit("landlock_add_rule", 9417), KindFd},
+ {"landlock_restrict_self", syntheticEnter("landlock_restrict_self", 9420), syntheticExit("landlock_restrict_self", 9419), KindFd},
{"fsopen", syntheticEnter("fsopen", 9352), syntheticExit("fsopen", 9351), KindEventfd},
{"pidfd_open", syntheticEnter("pidfd_open", 9320), syntheticExit("pidfd_open", 9319), KindPidfd},
{"pidfd_send_signal", syntheticEnter("pidfd_send_signal", 9322), syntheticExit("pidfd_send_signal", 9321), KindFd},
diff --git a/internal/generate/codegen_test.go b/internal/generate/codegen_test.go
index f469b6c..f44e456 100644
--- a/internal/generate/codegen_test.go
+++ b/internal/generate/codegen_test.go
@@ -43,6 +43,16 @@ func TestGenerateProcessMadviseHandlerUsesFirstArgumentAsFd(t *testing.T) {
requireContains(t, output, "ev->fd = (__s32)ctx->args[0];")
}
+func TestGenerateLandlockAddRuleHandlerUsesFirstArgumentAsFd(t *testing.T) {
+ output := GenerateTracepointsC(mustParseAll(t, syntheticPair("landlock_add_rule")))
+
+ requireContains(t, output, `SEC("tracepoint/syscalls/sys_enter_landlock_add_rule")`)
+ requireContains(t, output, "struct fd_event *ev")
+ requireContains(t, output, "ev->event_type = ENTER_FD_EVENT;")
+ requireContains(t, output, "ev->trace_id = SYS_ENTER_LANDLOCK_ADD_RULE;")
+ requireContains(t, output, "ev->fd = (__s32)ctx->args[0];")
+}
+
func TestGenerateOpenHandler(t *testing.T) {
output := generateFromPair(t, FormatOpenat, FormatExitOpenat)