Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/net/bpfjit Add bpfjit_jmp_ja_overflow test.
details: https://anonhg.NetBSD.org/src/rev/23ad70c68e57
branches: trunk
changeset: 336092:23ad70c68e57
user: alnsn <alnsn%NetBSD.org@localhost>
date: Wed Feb 11 23:29:48 2015 +0000
description:
Add bpfjit_jmp_ja_overflow test.
diffstat:
tests/net/bpfjit/t_bpfjit.c | 35 +++++++++++++++++++++++++++++++++--
1 files changed, 33 insertions(+), 2 deletions(-)
diffs (63 lines):
diff -r e8d81fb030eb -r 23ad70c68e57 tests/net/bpfjit/t_bpfjit.c
--- a/tests/net/bpfjit/t_bpfjit.c Wed Feb 11 23:17:16 2015 +0000
+++ b/tests/net/bpfjit/t_bpfjit.c Wed Feb 11 23:29:48 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_bpfjit.c,v 1.5 2015/02/11 22:37:55 alnsn Exp $ */
+/* $NetBSD: t_bpfjit.c,v 1.6 2015/02/11 23:29:48 alnsn Exp $ */
/*-
* Copyright (c) 2011-2012, 2014 Alexander Nasonov.
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: t_bpfjit.c,v 1.5 2015/02/11 22:37:55 alnsn Exp $");
+__RCSID("$NetBSD: t_bpfjit.c,v 1.6 2015/02/11 23:29:48 alnsn Exp $");
#include <sys/param.h>
#include <sys/mbuf.h>
@@ -1700,6 +1700,36 @@
ATF_CHECK(code == NULL);
}
+ATF_TC(bpfjit_jmp_ja_overflow);
+ATF_TC_HEAD(bpfjit_jmp_ja_overflow, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Test BPF_JMP+BPF_JA with negative offset");
+}
+
+ATF_TC_BODY(bpfjit_jmp_ja_overflow, tc)
+{
+ static struct bpf_insn insns[] = {
+ BPF_STMT(BPF_JMP+BPF_JA, 1),
+ BPF_STMT(BPF_RET+BPF_K, 777),
+ BPF_STMT(BPF_JMP+BPF_JA, UINT32_MAX - 1), // -2
+ BPF_STMT(BPF_RET+BPF_K, 0)
+ };
+
+ bpfjit_func_t code;
+ size_t insn_count = sizeof(insns) / sizeof(insns[0]);
+
+ RZ(rump_init());
+
+ /* Jumps with negative offsets work only in userspace. */
+ ATF_CHECK(!prog_validate(insns, insn_count));
+
+ rump_schedule();
+ code = rumpns_bpfjit_generate_code(NULL, insns, insn_count);
+ rump_unschedule();
+ ATF_CHECK(code == NULL);
+}
+
ATF_TC(bpfjit_jmp_jgt_k);
ATF_TC_HEAD(bpfjit_jmp_jgt_k, tc)
{
@@ -4491,6 +4521,7 @@
ATF_TP_ADD_TC(tp, bpfjit_alu_neg);
ATF_TP_ADD_TC(tp, bpfjit_jmp_ja);
ATF_TP_ADD_TC(tp, bpfjit_jmp_ja_invalid);
+ ATF_TP_ADD_TC(tp, bpfjit_jmp_ja_overflow);
ATF_TP_ADD_TC(tp, bpfjit_jmp_jgt_k);
ATF_TP_ADD_TC(tp, bpfjit_jmp_jge_k);
ATF_TP_ADD_TC(tp, bpfjit_jmp_jeq_k);
Home |
Main Index |
Thread Index |
Old Index