summaryrefslogtreecommitdiff
path: root/samples/seccomp/bpf-helper.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2015-02-18 00:47:58 +0300
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-18 01:34:55 +0300
commit3a9af0bd34410a255d27024ea1bc28dc4e3a0044 (patch)
treefc248a3d7edb3e0ef323c9352f6467a476a86b01 /samples/seccomp/bpf-helper.c
parent52644c9ab3faefbfbf07a19c24c4e74e33cfd796 (diff)
downloadlinux-3a9af0bd34410a255d27024ea1bc28dc4e3a0044.tar.xz
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 <keescook@chromium.org> Reported-by: Robert Swiecki <swiecki@google.com> Tested-by: Robert Swiecki <swiecki@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'samples/seccomp/bpf-helper.c')
-rw-r--r--samples/seccomp/bpf-helper.c6
1 files changed, 6 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
#include <string.h>
#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;