From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Sargun Dhillon <sargun@sargun.me>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [PATCH 1/1] tracing, bpf: Implement function bpf_probe_write
Date: Sun, 17 Jul 2016 21:11:07 -0700 [thread overview]
Message-ID: <20160718041105.GA36253@ast-mbp.thefacebook.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1607161729010.12799@ircssh.c.rugged-nimbus-611.internal>
On Sun, Jul 17, 2016 at 03:19:13AM -0700, Sargun Dhillon wrote:
>
> +static u64 bpf_copy_to_user(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5)
> +{
> + void *to = (void *) (long) r1;
> + void *from = (void *) (long) r2;
> + int size = (int) r3;
> +
> + /* check if we're in a user context */
> + if (unlikely(in_interrupt()))
> + return -EINVAL;
> + if (unlikely(!current->pid))
> + return -EINVAL;
> +
> + return copy_to_user(to, from, size);
> +}
thanks for the patch, unfortunately it's not that straightforward.
copy_to_user might fault. Try enabling CONFIG_DEBUG_ATOMIC_SLEEP and
you'll see the splat since bpf programs are protected by rcu.
Also 'current' can be null and I'm not sure what current->pid does.
So the writing to user memory either has to be verified to avoid
sleeping and faults or we need to use something like task_work_add
mechanism. Ideas are certainly welcome.
next prev parent reply other threads:[~2016-07-18 4:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 10:36 Sargun Dhillon
2016-07-13 17:08 ` Alexei Starovoitov
2016-07-13 20:31 ` Sargun Dhillon
2016-07-15 5:40 ` Alexei Starovoitov
2016-07-16 2:16 ` Sargun Dhillon
2016-07-16 2:30 ` Alexei Starovoitov
2016-07-17 10:19 ` Sargun Dhillon
2016-07-18 4:11 ` Alexei Starovoitov [this message]
2016-07-18 10:57 ` Sargun Dhillon
2016-07-19 6:13 ` Alexei Starovoitov
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=20160718041105.GA36253@ast-mbp.thefacebook.com \
--to=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=sargun@sargun.me \
/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
all inboxes | Powered by JetHome®