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

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

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ 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.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 /* Copyright (c) 2024 Google LLC. */
  3 
  4 #include <vmlinux.h>
  5 #include <bpf/bpf_helpers.h>
  6 #include <bpf/bpf_tracing.h>
  7 
  8 #include "bpf_misc.h"
  9 #include "bpf_experimental.h"
 10 
 11 static char buf[64];
 12 
 13 SEC("lsm.s/file_open")
 14 __success
 15 int BPF_PROG(get_task_exe_file_and_put_kfunc_from_current_sleepable)
 16 {
 17         struct file *acquired;
 18 
 19         acquired = bpf_get_task_exe_file(bpf_get_current_task_btf());
 20         if (!acquired)
 21                 return 0;
 22 
 23         bpf_put_file(acquired);
 24         return 0;
 25 }
 26 
 27 SEC("lsm/file_open")
 28 __success
 29 int BPF_PROG(get_task_exe_file_and_put_kfunc_from_current_non_sleepable, struct file *file)
 30 {
 31         struct file *acquired;
 32 
 33         acquired = bpf_get_task_exe_file(bpf_get_current_task_btf());
 34         if (!acquired)
 35                 return 0;
 36 
 37         bpf_put_file(acquired);
 38         return 0;
 39 }
 40 
 41 SEC("lsm.s/task_alloc")
 42 __success
 43 int BPF_PROG(get_task_exe_file_and_put_kfunc_from_argument,
 44              struct task_struct *task)
 45 {
 46         struct file *acquired;
 47 
 48         acquired = bpf_get_task_exe_file(task);
 49         if (!acquired)
 50                 return 0;
 51 
 52         bpf_put_file(acquired);
 53         return 0;
 54 }
 55 
 56 SEC("lsm.s/inode_getattr")
 57 __success
 58 int BPF_PROG(path_d_path_from_path_argument, struct path *path)
 59 {
 60         int ret;
 61 
 62         ret = bpf_path_d_path(path, buf, sizeof(buf));
 63         __sink(ret);
 64         return 0;
 65 }
 66 
 67 SEC("lsm.s/file_open")
 68 __success
 69 int BPF_PROG(path_d_path_from_file_argument, struct file *file)
 70 {
 71         int ret;
 72         struct path *path;
 73 
 74         /* The f_path member is a path which is embedded directly within a
 75          * file. Therefore, a pointer to such embedded members are still
 76          * recognized by the BPF verifier as being PTR_TRUSTED as it's
 77          * essentially PTR_TRUSTED w/ a non-zero fixed offset.
 78          */
 79         path = &file->f_path;
 80         ret = bpf_path_d_path(path, buf, sizeof(buf));
 81         __sink(ret);
 82         return 0;
 83 }
 84 
 85 char _license[] SEC("license") = "GPL";
 86 

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