blob: 3aee332734ce12c6cfd86e3fbbf058b98efaa45d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
/* This file is separate because it's included both by eBPF programs (via include
* in bpf_helpers.h) and directly by the boot time bpfloader (Loader.cpp).
*/
#include <linux/bpf.h>
// These AID_* constants are permanent constants pulled from:
// system/core/libcutils/include/private/android_filesystem_config.h
//
// We need access to them from ebpf C code for map definitions
// and thus don't want to pull in the entire header file.
//
// TODO(149434314) - switch to including some appropriate header portion
#define AID_ROOT 0
#define AID_SYSTEM 1000
#define AID_NETWORK_STACK 1073
#define AID_NET_BT_ADMIN 3001
#define AID_NET_BT 3002
#define AID_INET 3003
#define AID_NET_RAW 3004
#define AID_NET_ADMIN 3005
#define AID_NET_BW_STATS 3006
#define AID_NET_BW_ACCT 3007
/*
* Map structure to be used by Android eBPF C programs. The Android eBPF loader
* uses this structure from eBPF object to create maps at boot time.
*
* The eBPF C program should define structure in the maps section using
* SEC("maps") otherwise it will be ignored by the eBPF loader.
*
* For example:
* const struct bpf_map_def SEC("maps") mymap { .type=... , .key_size=... }
*
* See 'bpf_helpers.h' for helpful macros for eBPF program use.
*/
struct bpf_map_def {
enum bpf_map_type type;
unsigned int key_size;
unsigned int value_size;
unsigned int max_entries;
unsigned int map_flags;
// The following are not supported by the Android bpfloader:
// unsigned int inner_map_idx;
// unsigned int numa_node;
unsigned int uid; // uid_t
unsigned int gid; // gid_t
unsigned int mode; // mode_t
};
struct bpf_prog_def {
unsigned int uid;
unsigned int gid;
};
|