~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/bpf/progs/test_unpriv_bpf_disabled.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2022, Oracle and/or its affiliates. */
  3 
  4 #include "vmlinux.h"
  5 
  6 #include <bpf/bpf_helpers.h>
  7 #include <bpf/bpf_tracing.h>
  8 #include "bpf_misc.h"
  9 
 10 __u32 perfbuf_val = 0;
 11 __u32 ringbuf_val = 0;
 12 
 13 int test_pid;
 14 
 15 struct {
 16         __uint(type, BPF_MAP_TYPE_ARRAY);
 17         __uint(max_entries, 1);
 18         __type(key, __u32);
 19         __type(value, __u32);
 20 } array SEC(".maps");
 21 
 22 struct {
 23         __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
 24         __uint(max_entries, 1);
 25         __type(key, __u32);
 26         __type(value, __u32);
 27 } percpu_array SEC(".maps");
 28 
 29 struct {
 30         __uint(type, BPF_MAP_TYPE_HASH);
 31         __uint(max_entries, 1);
 32         __type(key, __u32);
 33         __type(value, __u32);
 34 } hash SEC(".maps");
 35 
 36 struct {
 37         __uint(type, BPF_MAP_TYPE_PERCPU_HASH);
 38         __uint(max_entries, 1);
 39         __type(key, __u32);
 40         __type(value, __u32);
 41 } percpu_hash SEC(".maps");
 42 
 43 struct {
 44         __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY);
 45         __type(key, __u32);
 46         __type(value, __u32);
 47 } perfbuf SEC(".maps");
 48 
 49 struct {
 50         __uint(type, BPF_MAP_TYPE_RINGBUF);
 51         __uint(max_entries, 1 << 12);
 52 } ringbuf SEC(".maps");
 53 
 54 struct {
 55         __uint(type, BPF_MAP_TYPE_PROG_ARRAY);
 56         __uint(max_entries, 1);
 57         __uint(key_size, sizeof(__u32));
 58         __uint(value_size, sizeof(__u32));
 59 } prog_array SEC(".maps");
 60 
 61 SEC("fentry/" SYS_PREFIX "sys_nanosleep")
 62 int sys_nanosleep_enter(void *ctx)
 63 {
 64         int cur_pid;
 65 
 66         cur_pid = bpf_get_current_pid_tgid() >> 32;
 67 
 68         if (cur_pid != test_pid)
 69                 return 0;
 70 
 71         bpf_perf_event_output(ctx, &perfbuf, BPF_F_CURRENT_CPU, &perfbuf_val, sizeof(perfbuf_val));
 72         bpf_ringbuf_output(&ringbuf, &ringbuf_val, sizeof(ringbuf_val), 0);
 73 
 74         return 0;
 75 }
 76 
 77 SEC("perf_event")
 78 int handle_perf_event(void *ctx)
 79 {
 80         return 0;
 81 }
 82 
 83 char _license[] SEC("license") = "GPL";
 84 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php