All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] libbpf: Add additional null-pointer checking in make_parent_dir
@ 2022-04-21 13:00 Gaosheng Cui
  2022-04-21 16:55 ` Andrii Nakryiko
  0 siblings, 1 reply; 5+ messages in thread
From: Gaosheng Cui @ 2022-04-21 13:00 UTC (permalink / raw)
  To: cuigaosheng1, ast, daniel, andrii, kafai, songliubraving, yhs,
	john.fastabend, kpsingh
  Cc: netdev, bpf, linux-kernel, gongruiqi1, wangweiyang2

The make_parent_dir is called without null-pointer checking for path,
such as bpf_link__pin. To ensure there is no null-pointer dereference
in make_parent_dir, so make_parent_dir requires additional null-pointer
checking for path.

Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
---
 tools/lib/bpf/libbpf.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index b53e51884f9e..5786e6184bf5 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -7634,6 +7634,9 @@ static int make_parent_dir(const char *path)
 	char *dname, *dir;
 	int err = 0;
 
+	if (path == NULL)
+		return -EINVAL;
+
 	dname = strdup(path);
 	if (dname == NULL)
 		return -ENOMEM;
-- 
2.25.1


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

end of thread, other threads:[~2022-04-22 22:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 13:00 [PATCH -next] libbpf: Add additional null-pointer checking in make_parent_dir Gaosheng Cui
2022-04-21 16:55 ` Andrii Nakryiko
2022-04-22  2:45   ` cuigaosheng
2022-04-22  2:55   ` cuigaosheng
2022-04-22 21:46     ` Andrii Nakryiko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.