mirror of
https://github.com/varun-r-mallya/Python-BPF.git
synced 2026-12-06 18:08:36 +00:00
The four shapes from the shelved remind-deref list, plus the aliasing control, with IR-shape assertions: a null-checked dereference, and no pointer stored into an integer slot. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
38 lines
674 B
Python
38 lines
674 B
Python
# An integer struct field takes the value a map-lookup pointer points at.
|
|
from pythonbpf import bpf, map, struct, section, bpfglobal, compile
|
|
from pythonbpf.maps import HashMap
|
|
from ctypes import c_void_p, c_int64, c_uint32, c_uint64
|
|
|
|
|
|
@bpf
|
|
@map
|
|
def m() -> HashMap:
|
|
return HashMap(key=c_uint32, value=c_uint64, max_entries=4)
|
|
|
|
|
|
@bpf
|
|
@struct
|
|
class rec:
|
|
val: c_uint64
|
|
|
|
|
|
@bpf
|
|
@section("tracepoint/raw_syscalls/sys_enter")
|
|
def prog(ctx: c_void_p) -> c_int64:
|
|
k = c_uint32(1)
|
|
p = m.lookup(k)
|
|
q = m.lookup(k) # noqa: F841
|
|
if p:
|
|
r = rec()
|
|
r.val = p
|
|
return c_int64(0)
|
|
|
|
|
|
@bpf
|
|
@bpfglobal
|
|
def LICENSE() -> str:
|
|
return "GPL"
|
|
|
|
|
|
compile()
|