[PATCH] tools: bpf_jit_disasm: check for klogctl failure

Subsystems: networking [general], the rest

STALE3781d

3 messages, 3 authors, 2016-05-09 · open the first message on its own page

[PATCH] tools: bpf_jit_disasm: check for klogctl failure

From: Colin King <hidden>
Date: 2016-05-05 22:39:39

From: Colin Ian King <redacted>

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 <redacted>
---
 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

Re: [PATCH] tools: bpf_jit_disasm: check for klogctl failure

From: Daniel Borkmann <daniel@iogearbox.net>
Date: 2016-05-05 22:47:16

On 05/06/2016 12:39 AM, Colin King wrote:
From: Colin Ian King <redacted>

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 <redacted>
[ would be nice to get Cc'ed in future ... ]

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Re: [PATCH] tools: bpf_jit_disasm: check for klogctl failure

From: David Miller <davem@davemloft.net>
Date: 2016-05-09 03:33:35

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Fri, 06 May 2016 00:46:56 +0200
On 05/06/2016 12:39 AM, Colin King wrote:
quoted
From: Colin Ian King <redacted>

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 <redacted>
[ would be nice to get Cc'ed in future ... ]

Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help