1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include <linux/bpf.h> 18 #include <stdbool.h> 19 #include <stdint.h> 20 #include <bpf_helpers.h> 21 22 DEFINE_BPF_RINGBUF_EXT(output_buf, __u64, 4096, AID_UPROBESTATS, AID_UPROBESTATS, 0600, "", "", 23 PRIVATE, BPFLOADER_MIN_VER, BPFLOADER_MAX_VER, LOAD_ON_ENG, LOAD_ON_USER, 24 LOAD_ON_USERDEBUG); 25 26 DEFINE_BPF_PROG("uprobe/bitmap_constructor_heap", AID_UPROBESTATS, AID_UPROBESTATS, BPF_KPROBE2) 27 (void* this_ptr, void* buffer_address, __u32 size) { 28 __u64* output = bpf_output_buf_reserve(); 29 if (output == NULL) return 1; 30 (*output) = 123; 31 bpf_output_buf_submit(output); 32 return 0; 33 } 34 35 LICENSE("GPL"); 36