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-next>] [day] [month] [year] [list]
Date:   Sun, 20 May 2018 14:08:57 +0100
From:   Mathieu Xhonneux <m.xhonneux@...il.com>
To:     netdev@...r.kernel.org
Cc:     daniel@...earbox.net, alexei.starovoitov@...il.com
Subject: [PATCH] bpf: fix mem leak in error path of lwt bpf setup

In bpf_parse_prog, if bpf_prog_get_type fails, the function is
immediately terminated without freeing the previously allocated
prog->name.
This patch adds a kfree before the return.

Signed-off-by: Mathieu Xhonneux <m.xhonneux@...il.com>
---
 net/core/lwt_bpf.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c
index e7e626fb87bb..e142a7a32e46 100644
--- a/net/core/lwt_bpf.c
+++ b/net/core/lwt_bpf.c
@@ -223,8 +223,10 @@ static int bpf_parse_prog(struct nlattr *attr, struct bpf_lwt_prog *prog,
 
 	fd = nla_get_u32(tb[LWT_BPF_PROG_FD]);
 	p = bpf_prog_get_type(fd, type);
-	if (IS_ERR(p))
+	if (IS_ERR(p)) {
+		kfree(prog->name);
 		return PTR_ERR(p);
+	}
 
 	prog->prog = p;
 
-- 
2.16.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ