Snap for 13659452 from 32075d5ef9 to 25Q4-release

Change-Id: I18d57a1eb9670a95e0ed45e03f034d83b0eda496
This commit is contained in:
Android Build Coastguard Worker 2025-06-17 16:28:00 -07:00
commit 93a9e91f3a
4 changed files with 8 additions and 50 deletions

View file

@ -102,6 +102,7 @@ rust_binary {
name: "bpfloader",
defaults: ["bpfloader_defaults"],
required: [
"bpftool",
"timeInState.bpf",
],
product_variables: {

View file

@ -866,23 +866,6 @@ int loadProg(const char* elfPath, bool* isCritical, const Location& location) {
return ret;
}
// Networking-related program types are limited to the Tethering Apex
// to prevent things from breaking due to conflicts on mainline updates
// (exception made for socket filters, ie. xt_bpf for potential use in iptables,
// or for attaching to sockets directly)
constexpr bpf_prog_type kPlatformAllowedProgTypes[] = {
BPF_PROG_TYPE_KPROBE,
BPF_PROG_TYPE_PERF_EVENT,
BPF_PROG_TYPE_SOCKET_FILTER,
BPF_PROG_TYPE_TRACEPOINT,
BPF_PROG_TYPE_UNSPEC, // Will be replaced with fuse bpf program type
};
constexpr bpf_prog_type kMemEventsAllowedProgTypes[] = {
BPF_PROG_TYPE_TRACEPOINT,
BPF_PROG_TYPE_SOCKET_FILTER,
};
// see b/162057235. For arbitrary program types, the concern is that due to the lack of
// SELinux access controls over BPF program attachpoints, we have no way to control the
// attachment of programs to shared resources (or to detect when a shared resource
@ -892,20 +875,6 @@ constexpr bpf_prog_type kVendorAllowedProgTypes[] = {
};
const Location locations[] = {
// Core operating system
{
.dir = "/system/etc/bpf/",
.prefix = "",
.allowedProgTypes = kPlatformAllowedProgTypes,
.allowedProgTypesLength = arraysize(kPlatformAllowedProgTypes),
},
// memevents
{
.dir = "/system/etc/bpf/memevents/",
.prefix = "memevents/",
.allowedProgTypes = kMemEventsAllowedProgTypes,
.allowedProgTypesLength = arraysize(kMemEventsAllowedProgTypes),
},
// Vendor operating system
{
.dir = "/vendor/etc/bpf/",
@ -967,23 +936,19 @@ int createSysFsBpfSubDir(const char* const prefix) {
// ----- extern C stuff for rust below here -----
void initLogging() {
void vendorBpfLoader() {
// since we only ever get called from mainline NetBpfLoad
// (see packages/modules/Connectivity/netbpfload/NetBpfLoad.cpp around line 516)
// and there no arguments, so we can just pretend/assume this is the case.
const char* argv[] = {"/system/bin/bpfloader", NULL};
android::base::InitLogging(const_cast<char**>(argv), &android::base::KernelLogger);
}
void createBpfFsSubDirectories() {
for (const auto& location : android::bpf::locations) {
if (android::bpf::createSysFsBpfSubDir(location.prefix)) {
exit(120);
}
}
}
void legacyBpfLoader() {
// Load all ELF objects, create programs and maps, and pin them
for (const auto& location : android::bpf::locations) {
if (android::bpf::loadAllElfObjects(location)) {
@ -996,9 +961,7 @@ void legacyBpfLoader() {
exit(121);
}
}
}
void execNetBpfLoadDone() {
const char* args[] = {"/apex/com.android.tethering/bin/netbpfload", "done", NULL};
execve(args[0], (char**)args, environ);
ALOGE("FATAL: execve(): %d[%s]", errno, strerror(errno));

View file

@ -640,14 +640,11 @@ fn main() {
load_libbpf_progs();
info!("Loading legacy BPF progs");
// SAFETY: Linking in the existing legacy bpfloader functionality.
// Any of the four following bindgen functions can abort() or exit()
// on failure and execNetBpfLoadDone() execve()'s.
// SAFETY: Linking in the existing legacy vendor bpfloader functionality.
// The following bindgen function can abort() or exit() on failure,
// but will usually execve().
unsafe {
bpf_android_bindgen::initLogging();
bpf_android_bindgen::createBpfFsSubDirectories();
bpf_android_bindgen::legacyBpfLoader();
bpf_android_bindgen::execNetBpfLoadDone();
bpf_android_bindgen::vendorBpfLoader();
}
}

View file

@ -47,11 +47,8 @@ extern "C" {
#define __noreturn
#endif // __cplusplus
// The C++ portion of the BpfLoader is exposed as 3 functions to be called in order.
void initLogging();
void createBpfFsSubDirectories();
void legacyBpfLoader();
__noreturn void execNetBpfLoadDone();
// The C++ portion of the BpfLoader is exposed as a terminal function.
__noreturn void vendorBpfLoader();
#ifdef __cplusplus
} // extern C