[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20141122183059.GC6994@mwanda>
Date: Sat, 22 Nov 2014 21:30:59 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Alexei Starovoitov <ast@...nel.org>
Cc: netdev@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: [patch -next] bpf: null dereference allocating large arrays
There is a typo here, "array" is null so we can't dereference it and
also the size calculation should match the kzalloc() on the lines
before.
Signed-off-by: Dan Carpenter <dan.carpenter@...cle.com>
diff --git a/kernel/bpf/arraymap.c b/kernel/bpf/arraymap.c
index 58b80c1..662a412 100644
--- a/kernel/bpf/arraymap.c
+++ b/kernel/bpf/arraymap.c
@@ -38,7 +38,7 @@ static struct bpf_map *array_map_alloc(union bpf_attr *attr)
array = kzalloc(sizeof(*array) + attr->max_entries * elem_size,
GFP_USER | __GFP_NOWARN);
if (!array) {
- array = vzalloc(array->map.max_entries * array->elem_size);
+ array = vzalloc(sizeof(*array) + attr->max_entries * elem_size);
if (!array)
return ERR_PTR(-ENOMEM);
}
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists