Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /* Copyright (c) 2019 Carlos Neira cneirabustos@gmail.com */
0003 
0004 #include <linux/bpf.h>
0005 #include <stdint.h>
0006 #include <bpf/bpf_helpers.h>
0007 
0008 __u64 user_pid = 0;
0009 __u64 user_tgid = 0;
0010 __u64 dev = 0;
0011 __u64 ino = 0;
0012 
0013 SEC("tracepoint/syscalls/sys_enter_nanosleep")
0014 int handler(const void *ctx)
0015 {
0016     struct bpf_pidns_info nsdata;
0017 
0018     if (bpf_get_ns_current_pid_tgid(dev, ino, &nsdata, sizeof(struct bpf_pidns_info)))
0019         return 0;
0020 
0021     user_pid = nsdata.pid;
0022     user_tgid = nsdata.tgid;
0023 
0024     return 0;
0025 }
0026 
0027 char _license[] SEC("license") = "GPL";