Skip to content

Commit 9badaf7

Browse files
committed
Remove support for Uprobe, Lsm, and CgroupSkb program types across the codebase. Update type definitions, context handling, and related tests.
1 parent b8f9541 commit 9badaf7

11 files changed

Lines changed: 10 additions & 99 deletions

src/ast.ml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type attribute =
3535

3636
(** Program types supported by KernelScript *)
3737
type program_type =
38-
| Xdp | Tc | Kprobe | Uprobe | Tracepoint | Lsm | CgroupSkb | StructOps
38+
| Xdp | Tc | Kprobe | Tracepoint | StructOps
3939

4040
(** Map types for eBPF maps *)
4141
type map_type =
@@ -73,8 +73,8 @@ and bpf_type =
7373
| Function of bpf_type list * bpf_type
7474
| Map of bpf_type * bpf_type * map_type * int (* key_type, value_type, map_type, size *)
7575
(* Built-in context types *)
76-
| Xdp_md | UprobeContext
77-
| TracepointContext | LsmContext | CgroupSkbContext
76+
| Xdp_md
77+
| TracepointContext
7878
| Xdp_action
7979
(* Program reference types *)
8080
| ProgramRef of program_type
@@ -550,10 +550,7 @@ let string_of_program_type = function
550550
| Xdp -> "xdp"
551551
| Tc -> "tc"
552552
| Kprobe -> "kprobe"
553-
| Uprobe -> "uprobe"
554553
| Tracepoint -> "tracepoint"
555-
| Lsm -> "lsm"
556-
| CgroupSkb -> "cgroup_skb"
557554
| StructOps -> "struct_ops"
558555

559556
let string_of_map_type = function
@@ -602,10 +599,7 @@ let rec string_of_bpf_type = function
602599
(string_of_map_type map_type)
603600
size
604601
| Xdp_md -> "xdp_md"
605-
| UprobeContext -> "UprobeContext"
606602
| TracepointContext -> "TracepointContext"
607-
| LsmContext -> "LsmContext"
608-
| CgroupSkbContext -> "CgroupSkbContext"
609603
| Xdp_action -> "xdp_action"
610604
| ProgramRef pt -> string_of_program_type pt
611605
| ProgramHandle -> "ProgramHandle"

src/ebpf_c_codegen.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,10 +324,7 @@ let rec ebpf_type_from_ir_type = function
324324
| IRContext XdpCtx -> "struct xdp_md"
325325
| IRContext TcCtx -> "struct __sk_buff"
326326
| IRContext KprobeCtx -> "struct pt_regs"
327-
| IRContext UprobeCtx -> "struct pt_regs"
328327
| IRContext TracepointCtx -> "void"
329-
| IRContext LsmCtx -> "void"
330-
| IRContext CgroupSkbCtx -> "struct __sk_buff"
331328
| IRAction Xdp_actionType -> "int"
332329
| IRAction TcActionType -> "int"
333330
| IRAction GenericActionType -> "int"

src/ir.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ and ir_type =
145145
| IRRingbuf of ir_type * int (* Ring buffer object: (value_type, size) *)
146146

147147
and context_type =
148-
| XdpCtx | TcCtx | KprobeCtx | UprobeCtx | TracepointCtx | LsmCtx | CgroupSkbCtx
148+
| XdpCtx | TcCtx | KprobeCtx | TracepointCtx
149149

150150
and action_type =
151151
| Xdp_actionType | TcActionType | GenericActionType
@@ -712,10 +712,7 @@ let rec ast_type_to_ir_type = function
712712
IRPointer (ast_type_to_ir_type t, bounds)
713713
| Result (t1, t2) -> IRResult (ast_type_to_ir_type t1, ast_type_to_ir_type t2)
714714
| Xdp_md -> IRContext XdpCtx
715-
| UprobeContext -> IRContext UprobeCtx
716715
| TracepointContext -> IRContext TracepointCtx
717-
| LsmContext -> IRContext LsmCtx
718-
| CgroupSkbContext -> IRContext CgroupSkbCtx
719716
| Xdp_action -> IRAction Xdp_actionType
720717
| UserType name -> IRStruct (name, []) (* Resolved by type checker *)
721718
| Function (param_types, return_type) ->
@@ -840,8 +837,7 @@ let rec string_of_ir_type = function
840837
| IRStructOps (name, _) -> Printf.sprintf "struct_ops %s" name
841838
| IRContext ctx -> Printf.sprintf "context %s" (match ctx with
842839
| XdpCtx -> "xdp" | TcCtx -> "tc" | KprobeCtx -> "kprobe"
843-
| UprobeCtx -> "uprobe" | TracepointCtx -> "tracepoint"
844-
| LsmCtx -> "lsm" | CgroupSkbCtx -> "cgroup_skb")
840+
| TracepointCtx -> "tracepoint")
845841
| IRAction action -> Printf.sprintf "action %s" (match action with
846842
| Xdp_actionType -> "xdp" | TcActionType -> "tc"
847843
| GenericActionType -> "generic")

src/ir_generator.ml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,10 +329,7 @@ let determine_arrow_access_type ctx obj_val field expr_type_opt =
329329
| XdpCtx -> "xdp"
330330
| TcCtx -> "tc"
331331
| KprobeCtx -> "kprobe"
332-
| UprobeCtx -> "uprobe"
333332
| TracepointCtx -> "tracepoint"
334-
| LsmCtx -> "lsm"
335-
| CgroupSkbCtx -> "cgroup_skb"
336333
in
337334
(match Kernelscript_context.Context_codegen.get_context_field_c_type ctx_type_str field with
338335
| Some c_type -> c_type_to_ir_type c_type
@@ -380,10 +377,7 @@ let ir_context_type_to_string = function
380377
| XdpCtx -> "xdp"
381378
| TcCtx -> "tc"
382379
| KprobeCtx -> "kprobe"
383-
| UprobeCtx -> "uprobe"
384380
| TracepointCtx -> "tracepoint"
385-
| LsmCtx -> "lsm"
386-
| CgroupSkbCtx -> "cgroup_skb"
387381

388382
(** Map context field names to IR access types using BTF-integrated context codegen *)
389383
(* No longer needed - we use BTF field names directly *)
@@ -2776,10 +2770,7 @@ let lower_multi_program ast symbol_table source_name =
27762770
| "xdp" -> Ast.Xdp
27772771
| "tc" -> Ast.Tc
27782772
| "kprobe" -> Ast.Kprobe
2779-
| "uprobe" -> Ast.Uprobe
27802773
| "tracepoint" -> Ast.Tracepoint
2781-
| "lsm" -> Ast.Lsm
2782-
| "cgroup_skb" -> Ast.CgroupSkb
27832774
| _ -> failwith ("Unknown program type: " ^ prog_type_str)
27842775
in
27852776
Some {

src/multi_program_analyzer.ml

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,13 @@ let get_execution_context = function
4848
execution_stage = "packet_receive_late";
4949
can_drop_packets = true;
5050
}
51-
| CgroupSkb -> {
52-
program_type = CgroupSkb;
53-
hook_point = "cgroup_skb_filter";
54-
stack_layer = 3; (* LATEST - after TC *)
55-
execution_stage = "cgroup_filtering";
56-
can_drop_packets = true;
57-
}
58-
| Lsm -> {
59-
program_type = Lsm;
60-
hook_point = "security_hooks (various points)";
61-
stack_layer = 0; (* NOT in linear packet path - scattered throughout kernel *)
62-
execution_stage = "security_enforcement";
63-
can_drop_packets = true;
64-
}
6551
| Kprobe -> {
6652
program_type = Kprobe;
6753
hook_point = "kernel_function_entry/exit";
6854
stack_layer = 0; (* Can run anywhere - not in packet path *)
6955
execution_stage = "dynamic_tracing";
7056
can_drop_packets = false;
7157
}
72-
| Uprobe -> {
73-
program_type = Uprobe;
74-
hook_point = "user_function_entry/exit";
75-
stack_layer = 0; (* Userspace *)
76-
execution_stage = "user_tracing";
77-
can_drop_packets = false;
78-
}
7958
| Tracepoint -> {
8059
program_type = Tracepoint;
8160
hook_point = "static_kernel_tracepoint";
@@ -133,10 +112,7 @@ let extract_programs (ast: declaration list) : program_def list =
133112
| "xdp" -> Xdp
134113
| "tc" -> Tc
135114
| "kprobe" -> Kprobe
136-
| "uprobe" -> Uprobe
137115
| "tracepoint" -> Tracepoint
138-
| "lsm" -> Lsm
139-
| "cgroup_skb" -> CgroupSkb
140116
| "struct_ops" -> StructOps
141117
| _ -> failwith ("Unknown program type: " ^ prog_type_str)
142118
in
@@ -463,10 +439,7 @@ let get_program_types_from_ast (ast: declaration list) : program_type list =
463439
| "xdp" -> Xdp :: acc
464440
| "tc" -> Tc :: acc
465441
| "kprobe" -> Kprobe :: acc
466-
| "uprobe" -> Uprobe :: acc
467442
| "tracepoint" -> Tracepoint :: acc
468-
| "lsm" -> Lsm :: acc
469-
| "cgroup_skb" -> CgroupSkb :: acc
470443
| _ -> acc)
471444
| _ -> acc)
472445
| _ -> acc

src/tail_call_analyzer.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ let extract_program_type attr_list =
5656
| "xdp" -> Some Xdp
5757
| "tc" -> Some Tc
5858
| "kprobe" -> Some Kprobe
59-
| "uprobe" -> Some Uprobe
6059
| "tracepoint" -> Some Tracepoint
61-
| "lsm" -> Some Lsm
62-
| "cgroup_skb" -> Some CgroupSkb
6360
| _ -> None)
6461
| _ -> None
6562

src/type_checker.ml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ let type_error msg pos = raise (Type_error (msg, pos))
199199
(** Resolve user types to built-in types and type aliases *)
200200
let rec resolve_user_type ctx = function
201201
| UserType "xdp_md" -> Xdp_md
202-
| UserType "UprobeContext" -> UprobeContext
203-
| UserType "TracepointContext" -> TracepointContext
204-
| UserType "LsmContext" -> LsmContext
205-
| UserType "CgroupSkbContext" -> CgroupSkbContext
206202
| UserType "xdp_action" -> Xdp_action
207203
| UserType "__sk_buff" -> Struct "__sk_buff"
208204
| UserType "int" -> I32
@@ -949,10 +945,7 @@ and type_check_arrow_access ctx obj field pos =
949945
| Pointer (Struct name) | Pointer (UserType name) -> name
950946
(* Map context types to their corresponding struct names *)
951947
| Pointer Xdp_md -> "xdp_md"
952-
| Pointer UprobeContext -> "pt_regs"
953948
| Pointer TracepointContext -> "trace_entry"
954-
| Pointer LsmContext -> "task_struct"
955-
| Pointer CgroupSkbContext -> "__sk_buff"
956949
| _ ->
957950
type_error ("Arrow access requires pointer-to-struct type, got " ^ string_of_bpf_type typed_obj.texpr_type) pos
958951
in
@@ -2425,10 +2418,7 @@ let type_check_ast ?symbol_table:(provided_symbol_table=None) ast =
24252418
| "xdp" -> Some Xdp
24262419
| "tc" -> Some Tc
24272420
| "kprobe" -> Some Kprobe
2428-
| "uprobe" -> Some Uprobe
24292421
| "tracepoint" -> Some Tracepoint
2430-
| "lsm" -> Some Lsm
2431-
| "cgroup_skb" -> Some CgroupSkb
24322422
| "kfunc" -> None (* kfuncs don't have program types *)
24332423
| "private" -> None (* private functions don't have program types *)
24342424
| "helper" -> None (* helper functions don't have program types *)
@@ -2941,12 +2931,9 @@ let rec type_check_and_annotate_ast ?symbol_table:(provided_symbol_table=None) ?
29412931
| "kprobe" ->
29422932
(* Reject old format: @kprobe without target function *)
29432933
type_error ("@kprobe requires target function specification. Use @kprobe(\"function_name\") instead.") attr_func.attr_pos
2944-
| "uprobe" -> (Some Uprobe, None)
29452934
| "tracepoint" ->
29462935
(* Reject old format: @tracepoint without category/event *)
29472936
type_error ("@tracepoint requires category/event specification. Use @tracepoint(\"category/event\") instead.") attr_func.attr_pos
2948-
| "lsm" -> (Some Lsm, None)
2949-
| "cgroup_skb" -> (Some CgroupSkb, None)
29502937
| "kfunc" -> (None, None) (* kfuncs don't have program types *)
29512938
| "private" -> (None, None) (* private functions don't have program types *)
29522939
| "helper" -> (None, None) (* helper functions don't have program types *)
@@ -3316,10 +3303,7 @@ and populate_multi_program_context ast multi_prog_analysis =
33163303
| "xdp" -> Some Xdp
33173304
| "tc" -> Some Tc
33183305
| "kprobe" -> Some Kprobe
3319-
| "uprobe" -> Some Uprobe
33203306
| "tracepoint" -> Some Tracepoint
3321-
| "lsm" -> Some Lsm
3322-
| "cgroup_skb" -> Some CgroupSkb
33233307
| _ -> None)
33243308
| _ -> None
33253309
in

src/userspace_codegen.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ let extract_function_calls_from_ir_function ir_func =
525525
let get_program_type_from_attributes attr_list =
526526
List.fold_left (fun acc attr ->
527527
match attr with
528-
| Ast.SimpleAttribute attr_name when List.mem attr_name ["xdp"; "tc"; "kprobe"; "uprobe"; "tracepoint"; "lsm"; "cgroup_skb"] ->
528+
| Ast.SimpleAttribute attr_name when List.mem attr_name ["xdp"; "tc"; "kprobe"; "tracepoint"] ->
529529
Some attr_name
530530
| _ -> acc
531531
) None attr_list

tests/test_ir.ml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ module Program_type = struct
3030
| Tc -> Format.fprintf fmt "Tc"
3131
| Tracepoint -> Format.fprintf fmt "Tracepoint"
3232
| Kprobe -> Format.fprintf fmt "Kprobe"
33-
| Uprobe -> Format.fprintf fmt "Uprobe"
34-
| Lsm -> Format.fprintf fmt "Lsm"
35-
| CgroupSkb -> Format.fprintf fmt "CgroupSkb"
3633
| StructOps -> Format.fprintf fmt "StructOps"
3734
end
3835

tests/test_parser.ml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ let test_program_types () =
226226
("xdp", Xdp);
227227
("tc", Tc);
228228
("kprobe", Kprobe);
229-
("uprobe", Uprobe);
230229
("tracepoint", Tracepoint);
231230
] in
232231

0 commit comments

Comments
 (0)