netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools: bpf_jit_disasm: check for klogctl failure
@ 2016-05-05 22:39 Colin King
  2016-05-05 22:46 ` Daniel Borkmann
  0 siblings, 1 reply; 3+ messages in thread
From: Colin King @ 2016-05-05 22:39 UTC (permalink / raw)
  To: David S . Miller, netdev; +Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

klogctl can fail and return -ve len, so check for this and
return NULL to avoid passing a (size_t)-1 to malloc.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 tools/net/bpf_jit_disasm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/net/bpf_jit_disasm.c b/tools/net/bpf_jit_disasm.c
index 5b32413..544b05a 100644
--- a/tools/net/bpf_jit_disasm.c
+++ b/tools/net/bpf_jit_disasm.c
@@ -98,6 +98,9 @@ static char *get_klog_buff(unsigned int *klen)
 	char *buff;
 
 	len = klogctl(CMD_ACTION_SIZE_BUFFER, NULL, 0);
+	if (len < 0)
+		return NULL;
+
 	buff = malloc(len);
 	if (!buff)
 		return NULL;
-- 
2.8.1

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

end of thread, other threads:[~2016-05-09  3:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-05 22:39 [PATCH] tools: bpf_jit_disasm: check for klogctl failure Colin King
2016-05-05 22:46 ` Daniel Borkmann
2016-05-09  3:33   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).