From: Daniel Borkmann <daniel@iogearbox.net>
To: Song Liu <songliubraving@fb.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, kernel-team@fb.com,
kpsingh@kernel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: add tests for bpf_find_vma
Date: Mon, 1 Nov 2021 23:26:36 +0100 [thread overview]
Message-ID: <25320fdb-bf37-9fd2-869c-72657de8e9a8@iogearbox.net> (raw)
In-Reply-To: <20211027220043.1937648-3-songliubraving@fb.com>
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;
> +}
>
prev parent reply other threads:[~2021-11-01 22:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-27 22:00 [PATCH bpf-next 0/2] introduce bpf_find_vma Song Liu
2021-10-27 22:00 ` [PATCH bpf-next 1/2] bpf: introduce helper bpf_find_vma Song Liu
2021-11-01 22:23 ` Daniel Borkmann
2021-11-03 23:54 ` Song Liu
2021-11-04 5:56 ` Song Liu
2021-10-27 22:00 ` [PATCH bpf-next 2/2] selftests/bpf: add tests for bpf_find_vma Song Liu
2021-11-01 22:26 ` Daniel Borkmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25320fdb-bf37-9fd2-869c-72657de8e9a8@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=kpsingh@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).