From: Daniel Borkmann <daniel@iogearbox.net>
To: William Tu <u9012063@gmail.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>
Subject: Re: [RFC PATCH net-next] bpf: fix potential percpu map overcopy to user.
Date: Thu, 20 Oct 2016 21:39:49 +0200 [thread overview]
Message-ID: <58091D85.9060701@iogearbox.net> (raw)
In-Reply-To: <CALDO+SZbWbMPFsj10hR3XEB1696s0ENRoBttrT5T3O=DQ445XQ@mail.gmail.com>
On 10/20/2016 08:41 PM, William Tu wrote:
> On Thu, Oct 20, 2016 at 9:58 AM, Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
>> On Thu, Oct 20, 2016 at 06:04:38PM +0200, Daniel Borkmann wrote:
>>>
>>> diff --git a/tools/testing/selftests/bpf/test_maps.c b/tools/testing/selftests/bpf/test_maps.c
>>> index ee384f0..d4832e8 100644
>>> --- a/tools/testing/selftests/bpf/test_maps.c
>>> +++ b/tools/testing/selftests/bpf/test_maps.c
>>> @@ -25,6 +25,33 @@
>>>
>>> static int map_flags;
>>>
>>> +static unsigned int num_possible_cpus(void)
>>> +{
>>> + static const char *fcpu = "/sys/devices/system/cpu/possible";
>>> + unsigned int val, possible_cpus = 0;
>>> + char buff[128];
>>> + FILE *fp;
>>> +
>>> + fp = fopen(fcpu, "r");
>>> + if (!fp) {
>>> + printf("Failed to open %s: '%s'!\n", fcpu, strerror(errno));
>>> + exit(1);
>>> + }
>>> +
>>> + while (fgets(buff, sizeof(buff), fp)) {
>>> + if (sscanf(buff, "%*u-%u", &val) == 1)
>>> + possible_cpus = val;
>>> + }
>>
>> looks great to me.
>> Could you move it into bpf_sys.h or somehow make it common in libbpf
>> and reuse it in samples/bpf/ ?
>> Since quite a few samples need this fix as well.
Ahh, true.
>> Thanks!
>
> Looks good to me. I tested it and it works fine.
Okay, thanks. I'll fix that up, mid-term we should try and move most of
that over to kernel selftests/bpf, and reuse tools/lib/bpf/.
> Thanks!
> William
prev parent reply other threads:[~2016-10-20 19:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-16 16:41 [RFC PATCH net-next] bpf: fix potential percpu map overcopy to user William Tu
2016-10-19 0:50 ` Alexei Starovoitov
2016-10-19 5:31 ` William Tu
2016-10-19 10:05 ` Daniel Borkmann
2016-10-20 19:21 ` William Tu
2016-10-19 15:15 ` Daniel Borkmann
2016-10-20 16:04 ` Daniel Borkmann
2016-10-20 16:58 ` Alexei Starovoitov
2016-10-20 18:41 ` William Tu
2016-10-20 19:39 ` 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=58091D85.9060701@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=alexei.starovoitov@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=u9012063@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.