netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch -next] bpf: off by one in check_map_func_compatibility()
@ 2015-08-13 20:27 Dan Carpenter
  2015-08-13 20:31 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2015-08-13 20:27 UTC (permalink / raw)
  To: Alexei Starovoitov, Kaixu Xia; +Cc: netdev, kernel-janitors

The loop iterates one space too far, so we might read beyond the end of
the func_limit[] array.

Fixes: 35578d798400 ('bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 48e1c71..ed12e38 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -853,7 +853,7 @@ static int check_map_func_compatibility(struct bpf_map *map, int func_id)
 	if (!map)
 		return 0;
 
-	for (i = 0; i <= ARRAY_SIZE(func_limit); i++) {
+	for (i = 0; i < ARRAY_SIZE(func_limit); i++) {
 		bool_map = (map->map_type == func_limit[i].map_type);
 		bool_func = (func_id == func_limit[i].func_id);
 		/* only when map & func pair match it can continue.

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [patch -next] bpf: off by one in check_map_func_compatibility()
  2015-08-13 20:27 [patch -next] bpf: off by one in check_map_func_compatibility() Dan Carpenter
@ 2015-08-13 20:31 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2015-08-13 20:31 UTC (permalink / raw)
  To: Dan Carpenter, Alexei Starovoitov, Kaixu Xia; +Cc: netdev, kernel-janitors

On 08/13/2015 10:27 PM, Dan Carpenter wrote:
> The loop iterates one space too far, so we might read beyond the end of
> the func_limit[] array.
>
> Fixes: 35578d798400 ('bpf: Implement function bpf_perf_event_read() that get the selected hardware PMU conuter')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks for the fix, Dan!

There's however already one queued up here:

https://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=140d8b335a9beb234fd0ed9a15aa6a47f47fd771

> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 48e1c71..ed12e38 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -853,7 +853,7 @@ static int check_map_func_compatibility(struct bpf_map *map, int func_id)
>   	if (!map)
>   		return 0;
>
> -	for (i = 0; i <= ARRAY_SIZE(func_limit); i++) {
> +	for (i = 0; i < ARRAY_SIZE(func_limit); i++) {
>   		bool_map = (map->map_type == func_limit[i].map_type);
>   		bool_func = (func_id == func_limit[i].func_id);
>   		/* only when map & func pair match it can continue.
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-08-13 20:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 20:27 [patch -next] bpf: off by one in check_map_func_compatibility() Dan Carpenter
2015-08-13 20:31 ` Daniel Borkmann

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).