syscall.c (3c09ec59cdea5b132212d97154d625fd34e436dd) | syscall.c (b48845af0152d790a54b8ab78cc2b7c07485fc98) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com 3 */ 4#include <linux/bpf.h> 5#include <linux/bpf_trace.h> 6#include <linux/bpf_lirc.h> 7#include <linux/bpf_verifier.h> 8#include <linux/btf.h> --- 3864 unchanged lines hidden (view full) --- 3873#define BPF_TASK_FD_QUERY_LAST_FIELD task_fd_query.probe_addr 3874 3875static int bpf_task_fd_query(const union bpf_attr *attr, 3876 union bpf_attr __user *uattr) 3877{ 3878 pid_t pid = attr->task_fd_query.pid; 3879 u32 fd = attr->task_fd_query.fd; 3880 const struct perf_event *event; | 1// SPDX-License-Identifier: GPL-2.0-only 2/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com 3 */ 4#include <linux/bpf.h> 5#include <linux/bpf_trace.h> 6#include <linux/bpf_lirc.h> 7#include <linux/bpf_verifier.h> 8#include <linux/btf.h> --- 3864 unchanged lines hidden (view full) --- 3873#define BPF_TASK_FD_QUERY_LAST_FIELD task_fd_query.probe_addr 3874 3875static int bpf_task_fd_query(const union bpf_attr *attr, 3876 union bpf_attr __user *uattr) 3877{ 3878 pid_t pid = attr->task_fd_query.pid; 3879 u32 fd = attr->task_fd_query.fd; 3880 const struct perf_event *event; |
3881 struct files_struct *files; | |
3882 struct task_struct *task; 3883 struct file *file; 3884 int err; 3885 3886 if (CHECK_ATTR(BPF_TASK_FD_QUERY)) 3887 return -EINVAL; 3888 3889 if (!capable(CAP_SYS_ADMIN)) 3890 return -EPERM; 3891 3892 if (attr->task_fd_query.flags != 0) 3893 return -EINVAL; 3894 3895 task = get_pid_task(find_vpid(pid), PIDTYPE_PID); 3896 if (!task) 3897 return -ENOENT; 3898 | 3881 struct task_struct *task; 3882 struct file *file; 3883 int err; 3884 3885 if (CHECK_ATTR(BPF_TASK_FD_QUERY)) 3886 return -EINVAL; 3887 3888 if (!capable(CAP_SYS_ADMIN)) 3889 return -EPERM; 3890 3891 if (attr->task_fd_query.flags != 0) 3892 return -EINVAL; 3893 3894 task = get_pid_task(find_vpid(pid), PIDTYPE_PID); 3895 if (!task) 3896 return -ENOENT; 3897 |
3899 files = get_files_struct(task); 3900 put_task_struct(task); 3901 if (!files) 3902 return -ENOENT; 3903 | |
3904 err = 0; | 3898 err = 0; |
3905 spin_lock(&files->file_lock); 3906 file = fcheck_files(files, fd); | 3899 file = fget_task(task, fd); 3900 put_task_struct(task); |
3907 if (!file) | 3901 if (!file) |
3908 err = -EBADF; 3909 else 3910 get_file(file); 3911 spin_unlock(&files->file_lock); 3912 put_files_struct(files); | 3902 return -EBADF; |
3913 | 3903 |
3914 if (err) 3915 goto out; 3916 | |
3917 if (file->f_op == &bpf_link_fops) { 3918 struct bpf_link *link = file->private_data; 3919 3920 if (link->ops == &bpf_raw_tp_link_lops) { 3921 struct bpf_raw_tp_link *raw_tp = 3922 container_of(link, struct bpf_raw_tp_link, link); 3923 struct bpf_raw_event_map *btp = raw_tp->btp; 3924 --- 22 unchanged lines hidden (view full) --- 3947 probe_addr); 3948 goto put_file; 3949 } 3950 3951out_not_supp: 3952 err = -ENOTSUPP; 3953put_file: 3954 fput(file); | 3904 if (file->f_op == &bpf_link_fops) { 3905 struct bpf_link *link = file->private_data; 3906 3907 if (link->ops == &bpf_raw_tp_link_lops) { 3908 struct bpf_raw_tp_link *raw_tp = 3909 container_of(link, struct bpf_raw_tp_link, link); 3910 struct bpf_raw_event_map *btp = raw_tp->btp; 3911 --- 22 unchanged lines hidden (view full) --- 3934 probe_addr); 3935 goto put_file; 3936 } 3937 3938out_not_supp: 3939 err = -ENOTSUPP; 3940put_file: 3941 fput(file); |
3955out: | |
3956 return err; 3957} 3958 3959#define BPF_MAP_BATCH_LAST_FIELD batch.flags 3960 3961#define BPF_DO_BATCH(fn) \ 3962 do { \ 3963 if (!fn) { \ --- 536 unchanged lines hidden --- | 3942 return err; 3943} 3944 3945#define BPF_MAP_BATCH_LAST_FIELD batch.flags 3946 3947#define BPF_DO_BATCH(fn) \ 3948 do { \ 3949 if (!fn) { \ --- 536 unchanged lines hidden --- |