From 3a9af0bd34410a255d27024ea1bc28dc4e3a0044 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 17 Feb 2015 13:47:58 -0800 Subject: samples/seccomp: improve label helper Fixes a potential corruption with uninitialized stack memory in the seccomp BPF sample program. [akpm@linux-foundation.org: coding-style fixlet] Signed-off-by: Kees Cook Reported-by: Robert Swiecki Tested-by: Robert Swiecki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- samples/seccomp/bpf-helper.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'samples/seccomp/bpf-helper.c') diff --git a/samples/seccomp/bpf-helper.c b/samples/seccomp/bpf-helper.c index 579cfe331886..05cb4d5ff9f5 100644 --- a/samples/seccomp/bpf-helper.c +++ b/samples/seccomp/bpf-helper.c @@ -10,6 +10,7 @@ */ #include +#include #include #include "bpf-helper.h" @@ -63,6 +64,11 @@ __u32 seccomp_bpf_label(struct bpf_labels *labels, const char *label) { struct __bpf_label *begin = labels->labels, *end; int id; + + if (labels->count == BPF_LABELS_MAX) { + fprintf(stderr, "Too many labels\n"); + exit(1); + } if (labels->count == 0) { begin->label = label; begin->location = 0xffffffff; -- cgit v1.2.3