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

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

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ 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 Meta Platforms, Inc. and affiliates. */
  3 
  4 #include <linux/bpf.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include <bpf/bpf_core_read.h>
  7 
  8 struct task_struct___bad {
  9         int pid;
 10         int fake_field;
 11         void *fake_field_subprog;
 12 } __attribute__((preserve_access_index));
 13 
 14 SEC("?raw_tp/sys_enter")
 15 int bad_relo(const void *ctx)
 16 {
 17         static struct task_struct___bad *t;
 18 
 19         return bpf_core_field_size(t->fake_field);
 20 }
 21 
 22 static __noinline int bad_subprog(void)
 23 {
 24         static struct task_struct___bad *t;
 25 
 26         /* ugliness below is a field offset relocation */
 27         return (void *)&t->fake_field_subprog - (void *)t;
 28 }
 29 
 30 SEC("?raw_tp/sys_enter")
 31 int bad_relo_subprog(const void *ctx)
 32 {
 33         static struct task_struct___bad *t;
 34 
 35         return bad_subprog() + bpf_core_field_size(t->pid);
 36 }
 37 
 38 struct {
 39         __uint(type, BPF_MAP_TYPE_ARRAY);
 40         __uint(max_entries, 1);
 41         __type(key, int);
 42         __type(value, int);
 43 } existing_map SEC(".maps");
 44 
 45 struct {
 46         __uint(type, BPF_MAP_TYPE_ARRAY);
 47         __uint(max_entries, 1);
 48         __type(key, int);
 49         __type(value, int);
 50 } missing_map SEC(".maps");
 51 
 52 SEC("?raw_tp/sys_enter")
 53 int use_missing_map(const void *ctx)
 54 {
 55         int zero = 0, *value;
 56 
 57         value = bpf_map_lookup_elem(&existing_map, &zero);
 58 
 59         value = bpf_map_lookup_elem(&missing_map, &zero);
 60 
 61         return value != NULL;
 62 }
 63 
 64 extern int bpf_nonexistent_kfunc(void) __ksym __weak;
 65 
 66 SEC("?raw_tp/sys_enter")
 67 int use_missing_kfunc(const void *ctx)
 68 {
 69         bpf_nonexistent_kfunc();
 70 
 71         return 0;
 72 }
 73 
 74 char _license[] SEC("license") = "GPL";
 75 

~ [ 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