[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <25320fdb-bf37-9fd2-869c-72657de8e9a8@iogearbox.net>
Date: Mon, 1 Nov 2021 23:26:36 +0100
From: Daniel Borkmann <daniel@...earbox.net>
To: Song Liu <songliubraving@...com>, bpf@...r.kernel.org,
netdev@...r.kernel.org
Cc: ast@...nel.org, andrii@...nel.org, kernel-team@...com,
kpsingh@...nel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: add tests for bpf_find_vma
On 10/28/21 12:00 AM, Song Liu wrote:
[...]
> +static __u64
> +check_vma(struct task_struct *task, struct vm_area_struct *vma,
> + struct callback_ctx *data)
> +{
> + if (vma->vm_file)
> + bpf_probe_read_kernel_str(d_iname, DNAME_INLINE_LEN - 1,
> + vma->vm_file->f_path.dentry->d_iname);
> +
> + /* check for VM_EXEC */
> + if (vma->vm_flags & VM_EXEC)
> + found_vm_exec = 1;
> +
Could you also add test cases that verifier will reject write attempts to task/vma
for the callback?
> + return 0;
> +}
> +
> +SEC("kprobe/__x64_sys_getpgid")
> +int handle_getpid(void)
> +{
> + struct task_struct *task = bpf_get_current_task_btf();
> + struct callback_ctx data = {0};
> +
> + if (task->pid != target_pid)
> + return 0;
> +
> + find_addr_ret = bpf_find_vma(task, addr, check_vma, &data, 0);
> +
> + /* this should return -ENOENT */
> + find_zero_ret = bpf_find_vma(task, 0, check_vma, &data, 0);
> + return 0;
> +}
> +
> +SEC("perf_event")
> +int handle_pe(void)
> +{
> + struct task_struct *task = bpf_get_current_task_btf();
> + struct callback_ctx data = {0};
> +
> + if (task->pid != target_pid)
> + return 0;
> +
> + find_addr_ret = bpf_find_vma(task, addr, check_vma, &data, 0);
> +
> + /* In NMI, this should return -EBUSY, as the previous call is using
> + * the irq_work.
> + */
> + find_zero_ret = bpf_find_vma(task, 0, check_vma, &data, 0);
> + return 0;
> +}
>
Powered by blists - more mailing lists