diff mbox

[net-next] bpf: devmap: remove unnecessary value size check

Message ID 20170816063512.14925.40390.stgit@john-Precision-Tower-5810
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

John Fastabend Aug. 16, 2017, 6:35 a.m. UTC
In the devmap alloc map logic we check to ensure that the sizeof the
values are not greater than KMALLOC_MAX_SIZE. But, in the dev map case
we ensure the value size is 4bytes earlier in the function because all
values should be netdev ifindex values.

The second check is harmless but is not needed so remove it.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
---
 kernel/bpf/devmap.c |    6 ------
 1 file changed, 6 deletions(-)

Comments

Daniel Borkmann Aug. 16, 2017, 8:39 a.m. UTC | #1
On 08/16/2017 08:35 AM, John Fastabend wrote:
> In the devmap alloc map logic we check to ensure that the sizeof the
> values are not greater than KMALLOC_MAX_SIZE. But, in the dev map case
> we ensure the value size is 4bytes earlier in the function because all
> values should be netdev ifindex values.
>
> The second check is harmless but is not needed so remove it.
>
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
David Miller Aug. 16, 2017, 6:35 p.m. UTC | #2
From: John Fastabend <john.fastabend@gmail.com>
Date: Tue, 15 Aug 2017 23:35:12 -0700

> In the devmap alloc map logic we check to ensure that the sizeof the
> values are not greater than KMALLOC_MAX_SIZE. But, in the dev map case
> we ensure the value size is 4bytes earlier in the function because all
> values should be netdev ifindex values.
> 
> The second check is harmless but is not needed so remove it.
> 
> Signed-off-by: John Fastabend <john.fastabend@gmail.com>

Applied.
diff mbox

Patch

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 7192fb6..18a72a8 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -83,12 +83,6 @@  static struct bpf_map *dev_map_alloc(union bpf_attr *attr)
 	    attr->value_size != 4 || attr->map_flags)
 		return ERR_PTR(-EINVAL);
 
-	/* if value_size is bigger, the user space won't be able to
-	 * access the elements.
-	 */
-	if (attr->value_size > KMALLOC_MAX_SIZE)
-		return ERR_PTR(-E2BIG);
-
 	dtab = kzalloc(sizeof(*dtab), GFP_USER);
 	if (!dtab)
 		return ERR_PTR(-ENOMEM);