diff options
author | jkim <jkim@FreeBSD.org> | 2008-08-28 16:40:51 +0000 |
---|---|---|
committer | jkim <jkim@FreeBSD.org> | 2008-08-28 16:40:51 +0000 |
commit | 841dbb1bffc67cc5abbd073d4025888f051e1dbe (patch) | |
tree | f97e223426d7fc908c5c9c2f528f812c59f46286 | |
parent | 30759f2655e0945a1914b588b1cc89e1f111a67b (diff) | |
download | FreeBSD-src-841dbb1bffc67cc5abbd073d4025888f051e1dbe.zip FreeBSD-src-841dbb1bffc67cc5abbd073d4025888f051e1dbe.tar.gz |
Initialize scratch memory for JIT-compiled filter when it is allocated.
Previously it may have contained unnecessary (even sensitive) data from
the previous allocation.
As a (good) side effect, scratch memory may be used to store the previous
filter state(s) safely because it is allocated and freed with filter itself.
However, use it carefully because bpf_filter(9) does not have this behavior.
MFC after: 3 days
-rw-r--r-- | sys/net/bpf_jitter.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/net/bpf_jitter.c b/sys/net/bpf_jitter.c index d15bc93..cb644f4 100644 --- a/sys/net/bpf_jitter.c +++ b/sys/net/bpf_jitter.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include <sys/sysctl.h> #else #include <stdlib.h> +#include <string.h> #include <sys/types.h> #endif @@ -67,7 +68,7 @@ bpf_jitter(struct bpf_insn *fp, int nins) /* Allocate the filter structure */ filter = (struct bpf_jit_filter *)malloc(sizeof(*filter), - M_BPFJIT, M_NOWAIT); + M_BPFJIT, M_NOWAIT | M_ZERO); if (filter == NULL) return (NULL); @@ -104,6 +105,7 @@ bpf_jitter(struct bpf_insn *fp, int nins) filter = (struct bpf_jit_filter *)malloc(sizeof(*filter)); if (filter == NULL) return (NULL); + memset(filter, 0, sizeof(*filter)); /* No filter means accept all */ if (fp == NULL || nins == 0) { |