Netdev List
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Daniel Borkmann <daniel@iogearbox.net>, netdev@vger.kernel.org
Cc: ast@kernel.org
Subject: Re: [PATCH] bpf: test_maps: Avoid possible out of bound access
Date: Tue, 5 Feb 2019 11:23:58 -0200	[thread overview]
Message-ID: <ec77e28c-5b8f-23c2-a4a6-ad6829919144@debian.org> (raw)
In-Reply-To: <c42914fc-503f-abb9-b7e9-8f7360c9587a@iogearbox.net>

Hi Daniel,

On 2/4/19 6:57 PM, Daniel Borkmann wrote:
> There are couple more test_*() functions that need to be converted if we do
> the change to unsigned:
> 
> tools/testing/selftests/bpf/test_maps.c:48:static void test_hashmap(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:138:static void test_hashmap_sizes(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:158:static void test_hashmap_percpu(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:285:static void test_hashmap_walk(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:356:static void test_arraymap(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:411:static void test_arraymap_percpu(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:507:static void test_devmap(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:522:static void test_queuemap(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:580:static void test_stackmap(int task, void *data)
> tools/testing/selftests/bpf/test_maps.c:645:static void test_sockmap(int tasks, void *data)

That is a good idea. I haven't change them because the 'task' argument was
not being used at all, hence no GCC warning also. But due to the
__run_parallel() function parameter, I agree that we need to change them all.

Also, we need to change the test_update_delete(unsigned int fn, void *data)
function, which is also called through __run_parallel():

	run_parallel(TASKS, test_update_delete, data);

>>  {
>>  	struct bpf_map *bpf_map_rx, *bpf_map_tx, *bpf_map_msg, *bpf_map_break;
>>  	int map_fd_msg = 0, map_fd_rx = 0, map_fd_tx = 0, map_fd_break;
>> @@ -1261,7 +1261,7 @@ static void test_map_large(void)
>>  	printf("Fork %d tasks to '" #FN "'\n", N); \
>>  	__run_parallel(N, FN, DATA)
>>  
>> -static void __run_parallel(int tasks, void (*fn)(int task, void *data),
>> +static void __run_parallel(unsigned int tasks, void (*fn)(int task, void *data),
> 
> This would also need conversion to unsigned for the func arg above so that
> we don't type mismatch.

Ack!

I am sending a V2 soon. Than you!

      reply	other threads:[~2019-02-05 13:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04 16:27 [PATCH] bpf: test_maps: Avoid possible out of bound access Breno Leitao
2019-02-04 17:15 ` David Miller
2019-02-04 20:57 ` Daniel Borkmann
2019-02-05 13:23   ` Breno Leitao [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=ec77e28c-5b8f-23c2-a4a6-ad6829919144@debian.org \
    --to=leitao@debian.org \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /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