This allows devices to pretend that they are on a different kernel version, in order to support different bpf features when kernel backports are in place.
Test: set ro.bpf.kver_override=5.10.239 in product.prop on sm8250 device
based on 4.19 kernel with 5.10 bpf backported, skfilter_oom_kill
loaded: bpftool prog | grep skfilter_oom_k
Change-Id: Ic32a279c562679408728483d5a5ed79a70af217d
kyasuauthored and Thomas Turnercommited 2026-01-24 09:11:09 +00:00
Programs that use __kcfg values will have .kconfig sections that may not
have a pinned map descriptor. Allow them to be loaded.
Bug: 419635765
Test: manual. loaded program with .kconfig section.
Change-Id: Ifbfbfd443e034da21cbf8e7d456e7ad23dcd34b5
Signed-off-by: Tiffany Yang <ynaffit@google.com>
Introduce an 'auto_attach' flag to the ProgDesc struct.
When this flag is true, bpfloader attaches the BPF program and pins
the resulting link. This makes the attachment persist across framework
reboots, only being removed when the device itself reboots.
This simplifies client-side logic, as clients no longer need to
manage attachments or handle missed events after a restart. They can
assume the program is always attached and simply read from the maps.
This is particularly useful for collecting statistics that would
otherwise be corrupted by framework restarts and for capturing events
that occur during early boot, before client processes are running.
Bug: 419635765
Bug: 438637519
Test: manual, load and auto attach ag/35064705
Change-Id: Iffcde8972778b9152f4732e65c221eb72523ea34
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Replace periods with underscores in prog/map pin paths to align with
libbpf's sanitize_pin_path() behavior. The BPF filesystem (bpffs)
disallows periods in filenames, and this change prevents pinning
errors for maps with names containing them, such as .rodata sections.
Bug: 419635765
Bug: 438637519
Test: manual, load maps names containing . from ag/35064705
Change-Id: I55dd4caf38c3ccc39bccd6ea670b647c330d6793
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Certain BPF progams have sections .rodata.str1.1 or <name>.data for
global data. These sections are processed/loaded implicitly by libbpf,
but it may be useful for the developer to pin them. Change the logic so
if a descriptor for these sections is found, pin them. If not, ignore
them and don't cause a failure.
Bug: 401458418
Test: Manual: program with bpf_printk and global data loads.
Change-Id: Ib3be55cf903e24c6692730b57b0ce90c9a9e0795
Signed-off-by: Neill Kapron <nkapron@google.com>
The error messages now specify whether a "Map descriptor" or a "Prog descriptor" was not found, providing more clarity.
Test: N/A, text only change
Flag: EXEMPT trivial
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I7ce4806979a616f8330e5cca4d70c7ea2a1a256a
Maciej Żenczykowskicommited 2025-08-13 14:30:19 -07:00
It doesn't exist in current builds, and we have the vendor bpf loader in C++ to handle /vendor/etc/bpf anyway.
It's unclear how to handle it from rust due to platform vs vendor skew...
Test: TreeHugger
Flag: EXEMPT no-op
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I3ef707399445f91966e747d615dbf828d779a5ae
Maciej Żenczykowskicommited 2025-07-28 17:56:52 -07:00
as all are already present
(while at it add 'inheritance' from a default struct)
Test: TreeHugger
Flag: EXEMPT no-op
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I94258b8f5f8565193bfb688d50422733caf8dbf3
Maciej Żenczykowskicommited 2025-07-28 17:55:20 -07:00
(/etc is a symlink to /system/etc anyway)
Test: TreeHugger
Flag: EXEMPT no-op
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I4d5b1b34066b97589779a43b8eaeed785edb611c
Maciej Żenczykowskicommited 2025-07-25 21:28:22 -07:00
(Technically a no-op, since the file doesn't exist yet)
Test: TreeHugger
Flag: EXEMPT no-op
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie72de49e452994a5dca97559d86fa2d7bb4bedcb
Maciej Żenczykowskicommited 2025-07-25 21:01:36 -07:00
since we only support skfilter/ we can simplify this
(support for any future other vendor types should be added to the rust loader)
Test: TreeHugger
Flag: EXEMPT cleanup
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I72ad38c056728ef768ee70bc38471c3e9d368f60
Maciej Żenczykowskicommited 2025-07-16 08:55:36 -07:00
Really just spurious logging code.
If you're working on a device (as opposed to looking at bugreports)
you can get this information with for example 'bpftool':
$ adb shell bpftool map show pinned '/sys/fs/bpf/map_bpfRingbufProg_test_ringbuf'
77: ringbuf name test_ringbuf flags 0x0
key 0B value 0B max_entries 4096 memlock 16696B
$ adb shell bpftool prog show pinned /sys/fs/bpf/vendor/prog_filterPowerSupplyEvents_skfilter_power_supply
82: socket_filter name skfilter_power_ tag b8b4693584760391
loaded_at 2025-07-16T08:44:56-0700 uid 0
xlated 848B jited 470B memlock 4096B
Test: TreeHugger
Flag: EXEMPT cleanup
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ie7baf7cf5df9c25ad2d159767584670361e8c6eb
Maciej Żenczykowskicommited 2025-07-16 08:47:49 -07:00
This was primarily meant as a safety check for mainline,
it's not really needed in platform bpf loader.
Test: TreeHugger
Flag: EXEMPT cleanup
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I615f54f10baa75f641129507ecce9159ff31a740
Maciej Żenczykowskicommited 2025-07-16 08:39:23 -07:00
Afterwards we still have:
I BpfLoader: Platform BpfLoader loading critical for healthd ELF object /vendor/etc/bpf/filterPowerSupplyEvents.o with license Apache 2.0
W BpfLoader: No maps section could be found in elf object
D BpfLoader: prog /sys/fs/bpf/vendor/prog_filterPowerSupplyEvents_skfilter_power_supply id 82
$ adbz shell ls -lZ /sys/fs/bpf /sys/fs/bpf/vendor
/sys/fs/bpf:
total 0
...
drwxrwxrwt 2 root root u:object_r:fs_bpf_vendor:s0 0 2025-07-15 23:53 vendor
/sys/fs/bpf/vendor:
total 0
-r--r----- 1 root system u:object_r:fs_bpf_vendor:s0 0 2025-07-15 23:53 prog_filterPowerSupplyEvents_skfilter_power_supply
Test: TreeHugger
Flag: EXEMPT no-op
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I66a6fc3abf8f5c4c52f6a47476c251e97f1f6e14
Maciej Żenczykowskicommited 2025-07-15 23:57:34 -07:00
(while at it remove fuse bpf support, which isn't needed for vendor)
Test: TreeHugger
Flag: EXEMPT no-op
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ic7293b94644d933a908a252ab794ae64f88b5865
Maciej Żenczykowskicommited 2025-07-15 23:50:52 -07:00
We want to read this from traced_probes, which is AID_NOBODY. And
SELinux does a far more thorough job of controlling access than Unix
permissions do.
Bug: 422976190
Test: ls -l, and checked WIP traced_probes implementation.
Change-Id: I51a6486c5d7bf85f922f79a89a7a7fbdb9bc79f2
Simon MacMullencommited 2025-06-30 08:54:29 -07:00
This will allow us to use a genfscon SELinux rule to get finer grained access control.
Bug: 422976190
Test: Recorded a Perfetto trace with statsd atom CPU_CYCLES_PER_UID_CLUSTER, tested manually with go/atomtester.
Change-Id: Ic16da605b9d7150d42176c428f0e1ecaf4a9472f
Simon MacMullencommited 2025-06-26 16:31:52 +00:00
These are now generated by the build system when needed.
Bug: 421990777
Test: m
Change-Id: I961ba203989325e58428a7b3068326fc89debaa8
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Convert readme to markdown; refactor existing descriptions;
add instructions on how to add vmlinux.h for new kernels.
Bug: 421990777
Test: N/A
Change-Id: Idc61221e729d034c5fedb458bd18db02fade713a
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
no need for the complexity, as it is only for vendor now
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia807f7ee8aeca25d92e60e46f180ffe536eef87c
Maciej Żenczykowskicommited 2025-06-17 04:18:41 -07:00