Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.4-rc2 104 lines 2.0 kB view raw
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright (c) 2023 Meta Platforms, Inc. and affiliates. */ 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5#include <bpf/bpf_tracing.h> 6#include <bpf/bpf_core_read.h> 7#include "bpf_misc.h" 8 9char _license[] SEC("license") = "GPL"; 10 11static long stack[256]; 12 13/* 14 * KPROBE contexts 15 */ 16 17__weak int kprobe_typedef_ctx_subprog(bpf_user_pt_regs_t *ctx) 18{ 19 return bpf_get_stack(ctx, &stack, sizeof(stack), 0); 20} 21 22SEC("?kprobe") 23__success 24int kprobe_typedef_ctx(void *ctx) 25{ 26 return kprobe_typedef_ctx_subprog(ctx); 27} 28 29#define pt_regs_struct_t typeof(*(__PT_REGS_CAST((struct pt_regs *)NULL))) 30 31__weak int kprobe_struct_ctx_subprog(pt_regs_struct_t *ctx) 32{ 33 return bpf_get_stack((void *)ctx, &stack, sizeof(stack), 0); 34} 35 36SEC("?kprobe") 37__success 38int kprobe_resolved_ctx(void *ctx) 39{ 40 return kprobe_struct_ctx_subprog(ctx); 41} 42 43/* this is current hack to make this work on old kernels */ 44struct bpf_user_pt_regs_t {}; 45 46__weak int kprobe_workaround_ctx_subprog(struct bpf_user_pt_regs_t *ctx) 47{ 48 return bpf_get_stack(ctx, &stack, sizeof(stack), 0); 49} 50 51SEC("?kprobe") 52__success 53int kprobe_workaround_ctx(void *ctx) 54{ 55 return kprobe_workaround_ctx_subprog(ctx); 56} 57 58/* 59 * RAW_TRACEPOINT contexts 60 */ 61 62__weak int raw_tp_ctx_subprog(struct bpf_raw_tracepoint_args *ctx) 63{ 64 return bpf_get_stack(ctx, &stack, sizeof(stack), 0); 65} 66 67SEC("?raw_tp") 68__success 69int raw_tp_ctx(void *ctx) 70{ 71 return raw_tp_ctx_subprog(ctx); 72} 73 74/* 75 * RAW_TRACEPOINT_WRITABLE contexts 76 */ 77 78__weak int raw_tp_writable_ctx_subprog(struct bpf_raw_tracepoint_args *ctx) 79{ 80 return bpf_get_stack(ctx, &stack, sizeof(stack), 0); 81} 82 83SEC("?raw_tp") 84__success 85int raw_tp_writable_ctx(void *ctx) 86{ 87 return raw_tp_writable_ctx_subprog(ctx); 88} 89 90/* 91 * PERF_EVENT contexts 92 */ 93 94__weak int perf_event_ctx_subprog(struct bpf_perf_event_data *ctx) 95{ 96 return bpf_get_stack(ctx, &stack, sizeof(stack), 0); 97} 98 99SEC("?perf_event") 100__success 101int perf_event_ctx(void *ctx) 102{ 103 return perf_event_ctx_subprog(ctx); 104}