lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sat, 30 Dec 2023 21:12:22 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: bpf@...r.kernel.org, netdev@...r.kernel.org,
 kernel-janitors@...r.kernel.org, Alexei Starovoitov <ast@...nel.org>,
 Andrii Nakryiko <andrii@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
 Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
 John Fastabend <john.fastabend@...il.com>, KP Singh <kpsingh@...nel.org>,
 Martin KaFai Lau <martin.lau@...ux.dev>, Song Liu <song@...nel.org>,
 Stanislav Fomichev <sdf@...gle.com>, Yonghong Song <yonghong.song@...ux.dev>
Cc: LKML <linux-kernel@...r.kernel.org>
Subject: [PATCH 4/5] bpf: Return directly after a failed
 bpf_map_kmalloc_node() in bpf_cgroup_storage_alloc()

From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sat, 30 Dec 2023 20:06:02 +0100

The kfree() function was called in one case by
the bpf_cgroup_storage_alloc() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

Thus return directly after a call of the function “bpf_map_kmalloc_node”
failed at the beginning.

Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
 kernel/bpf/local_storage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/bpf/local_storage.c b/kernel/bpf/local_storage.c
index a04f505aefe9..e16a80c93cd7 100644
--- a/kernel/bpf/local_storage.c
+++ b/kernel/bpf/local_storage.c
@@ -514,7 +514,7 @@ struct bpf_cgroup_storage *bpf_cgroup_storage_alloc(struct bpf_prog *prog,
 	storage = bpf_map_kmalloc_node(map, sizeof(struct bpf_cgroup_storage),
 				       gfp, map->numa_node);
 	if (!storage)
-		goto enomem;
+		return ERR_PTR(-ENOMEM);

 	if (stype == BPF_CGROUP_STORAGE_SHARED) {
 		storage->buf = bpf_map_kmalloc_node(map, size, gfp,
--
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ