diff options
| author | Mark Brown <broonie@kernel.org> | 2017-08-21 16:50:23 -0400 |
|---|---|---|
| committer | Mark Brown <broonie@kernel.org> | 2017-08-21 16:50:23 -0400 |
| commit | bf9790bcdca582a7a3a0c10550a52ba2a9efc5c9 (patch) | |
| tree | f6325c050ad109e95ba8ae932f9fd5f1483f1dae /tools | |
| parent | 728c4a87f31d30669a103dac1851a15f4e2af03c (diff) | |
| parent | f13db334bf7b68b0086d04ab6a51517ba41123b4 (diff) | |
Merge branch 'topic/const' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into asoc-blackfin
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/build/feature/test-bpf.c | 2 | ||||
| -rwxr-xr-x | tools/kvm/kvm_stat/kvm_stat | 22 | ||||
| -rw-r--r-- | tools/lib/bpf/bpf.c | 7 | ||||
| -rw-r--r-- | tools/lib/bpf/bpf.h | 2 | ||||
| -rw-r--r-- | tools/perf/ui/browser.c | 2 | ||||
| -rw-r--r-- | tools/perf/util/evsel.c | 8 | ||||
| -rw-r--r-- | tools/perf/util/machine.c | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/bpf/test_align.c | 2 | ||||
| -rw-r--r-- | tools/testing/selftests/bpf/test_pkt_md_access.c | 11 | ||||
| -rw-r--r-- | tools/testing/selftests/bpf/test_progs.c | 8 | ||||
| -rw-r--r-- | tools/testing/selftests/bpf/test_verifier.c | 527 | ||||
| -rw-r--r-- | tools/testing/selftests/futex/Makefile | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | tools/testing/selftests/kmod/kmod.sh | 4 | ||||
| -rwxr-xr-x[-rw-r--r--] | tools/testing/selftests/sysctl/sysctl.sh | 0 | ||||
| -rw-r--r-- | tools/testing/selftests/timers/freq-step.c | 7 |
15 files changed, 568 insertions, 38 deletions
diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c index 7598361ef1f1..da2172ff9662 100644 --- a/tools/build/feature/test-bpf.c +++ b/tools/build/feature/test-bpf.c | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | # define __NR_bpf 280 | 11 | # define __NR_bpf 280 |
| 12 | # elif defined(__sparc__) | 12 | # elif defined(__sparc__) |
| 13 | # define __NR_bpf 349 | 13 | # define __NR_bpf 349 |
| 14 | # elif defined(__s390__) | ||
| 15 | # define __NR_bpf 351 | ||
| 14 | # else | 16 | # else |
| 15 | # error __NR_bpf not defined. libbpf does not support your arch. | 17 | # error __NR_bpf not defined. libbpf does not support your arch. |
| 16 | # endif | 18 | # endif |
diff --git a/tools/kvm/kvm_stat/kvm_stat b/tools/kvm/kvm_stat/kvm_stat index dd8f00cfb8b4..32283d88701a 100755 --- a/tools/kvm/kvm_stat/kvm_stat +++ b/tools/kvm/kvm_stat/kvm_stat | |||
| @@ -474,7 +474,7 @@ class Provider(object): | |||
| 474 | @staticmethod | 474 | @staticmethod |
| 475 | def is_field_wanted(fields_filter, field): | 475 | def is_field_wanted(fields_filter, field): |
| 476 | """Indicate whether field is valid according to fields_filter.""" | 476 | """Indicate whether field is valid according to fields_filter.""" |
| 477 | if not fields_filter: | 477 | if not fields_filter or fields_filter == "help": |
| 478 | return True | 478 | return True |
| 479 | return re.match(fields_filter, field) is not None | 479 | return re.match(fields_filter, field) is not None |
| 480 | 480 | ||
| @@ -1413,8 +1413,8 @@ performance. | |||
| 1413 | 1413 | ||
| 1414 | Requirements: | 1414 | Requirements: |
| 1415 | - Access to: | 1415 | - Access to: |
| 1416 | /sys/kernel/debug/kvm | 1416 | %s |
| 1417 | /sys/kernel/debug/trace/events/* | 1417 | %s/events/* |
| 1418 | /proc/pid/task | 1418 | /proc/pid/task |
| 1419 | - /proc/sys/kernel/perf_event_paranoid < 1 if user has no | 1419 | - /proc/sys/kernel/perf_event_paranoid < 1 if user has no |
| 1420 | CAP_SYS_ADMIN and perf events are used. | 1420 | CAP_SYS_ADMIN and perf events are used. |
| @@ -1434,7 +1434,7 @@ Interactive Commands: | |||
| 1434 | s set update interval | 1434 | s set update interval |
| 1435 | x toggle reporting of stats for individual child trace events | 1435 | x toggle reporting of stats for individual child trace events |
| 1436 | Press any other key to refresh statistics immediately. | 1436 | Press any other key to refresh statistics immediately. |
| 1437 | """ | 1437 | """ % (PATH_DEBUGFS_KVM, PATH_DEBUGFS_TRACING) |
| 1438 | 1438 | ||
| 1439 | class PlainHelpFormatter(optparse.IndentedHelpFormatter): | 1439 | class PlainHelpFormatter(optparse.IndentedHelpFormatter): |
| 1440 | def format_description(self, description): | 1440 | def format_description(self, description): |
| @@ -1496,7 +1496,8 @@ Press any other key to refresh statistics immediately. | |||
| 1496 | action='store', | 1496 | action='store', |
| 1497 | default=DEFAULT_REGEX, | 1497 | default=DEFAULT_REGEX, |
| 1498 | dest='fields', | 1498 | dest='fields', |
| 1499 | help='fields to display (regex)', | 1499 | help='''fields to display (regex) |
| 1500 | "-f help" for a list of available events''', | ||
| 1500 | ) | 1501 | ) |
| 1501 | optparser.add_option('-p', '--pid', | 1502 | optparser.add_option('-p', '--pid', |
| 1502 | action='store', | 1503 | action='store', |
| @@ -1559,6 +1560,17 @@ def main(): | |||
| 1559 | 1560 | ||
| 1560 | stats = Stats(options) | 1561 | stats = Stats(options) |
| 1561 | 1562 | ||
| 1563 | if options.fields == "help": | ||
| 1564 | event_list = "\n" | ||
| 1565 | s = stats.get() | ||
| 1566 | for key in s.keys(): | ||
| 1567 | if key.find('(') != -1: | ||
| 1568 | key = key[0:key.find('(')] | ||
| 1569 | if event_list.find('\n' + key + '\n') == -1: | ||
| 1570 | event_list += key + '\n' | ||
| 1571 | sys.stdout.write(event_list) | ||
| 1572 | return "" | ||
| 1573 | |||
| 1562 | if options.log: | 1574 | if options.log: |
| 1563 | log(stats) | 1575 | log(stats) |
| 1564 | elif not options.once: | 1576 | elif not options.once: |
diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 7e0405e1651d..e5bbb090bf88 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c | |||
| @@ -39,6 +39,8 @@ | |||
| 39 | # define __NR_bpf 280 | 39 | # define __NR_bpf 280 |
| 40 | # elif defined(__sparc__) | 40 | # elif defined(__sparc__) |
| 41 | # define __NR_bpf 349 | 41 | # define __NR_bpf 349 |
| 42 | # elif defined(__s390__) | ||
| 43 | # define __NR_bpf 351 | ||
| 42 | # else | 44 | # else |
| 43 | # error __NR_bpf not defined. libbpf does not support your arch. | 45 | # error __NR_bpf not defined. libbpf does not support your arch. |
| 44 | # endif | 46 | # endif |
| @@ -120,7 +122,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
| 120 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 122 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
| 121 | size_t insns_cnt, int strict_alignment, | 123 | size_t insns_cnt, int strict_alignment, |
| 122 | const char *license, __u32 kern_version, | 124 | const char *license, __u32 kern_version, |
| 123 | char *log_buf, size_t log_buf_sz) | 125 | char *log_buf, size_t log_buf_sz, int log_level) |
| 124 | { | 126 | { |
| 125 | union bpf_attr attr; | 127 | union bpf_attr attr; |
| 126 | 128 | ||
| @@ -131,7 +133,7 @@ int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
| 131 | attr.license = ptr_to_u64(license); | 133 | attr.license = ptr_to_u64(license); |
| 132 | attr.log_buf = ptr_to_u64(log_buf); | 134 | attr.log_buf = ptr_to_u64(log_buf); |
| 133 | attr.log_size = log_buf_sz; | 135 | attr.log_size = log_buf_sz; |
| 134 | attr.log_level = 2; | 136 | attr.log_level = log_level; |
| 135 | log_buf[0] = 0; | 137 | log_buf[0] = 0; |
| 136 | attr.kern_version = kern_version; | 138 | attr.kern_version = kern_version; |
| 137 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; | 139 | attr.prog_flags = strict_alignment ? BPF_F_STRICT_ALIGNMENT : 0; |
| @@ -314,7 +316,6 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len) | |||
| 314 | int err; | 316 | int err; |
| 315 | 317 | ||
| 316 | bzero(&attr, sizeof(attr)); | 318 | bzero(&attr, sizeof(attr)); |
| 317 | bzero(info, *info_len); | ||
| 318 | attr.info.bpf_fd = prog_fd; | 319 | attr.info.bpf_fd = prog_fd; |
| 319 | attr.info.info_len = *info_len; | 320 | attr.info.info_len = *info_len; |
| 320 | attr.info.info = ptr_to_u64(info); | 321 | attr.info.info = ptr_to_u64(info); |
diff --git a/tools/lib/bpf/bpf.h b/tools/lib/bpf/bpf.h index 16de44a14b48..418c86e69bcb 100644 --- a/tools/lib/bpf/bpf.h +++ b/tools/lib/bpf/bpf.h | |||
| @@ -38,7 +38,7 @@ int bpf_load_program(enum bpf_prog_type type, const struct bpf_insn *insns, | |||
| 38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, | 38 | int bpf_verify_program(enum bpf_prog_type type, const struct bpf_insn *insns, |
| 39 | size_t insns_cnt, int strict_alignment, | 39 | size_t insns_cnt, int strict_alignment, |
| 40 | const char *license, __u32 kern_version, | 40 | const char *license, __u32 kern_version, |
| 41 | char *log_buf, size_t log_buf_sz); | 41 | char *log_buf, size_t log_buf_sz, int log_level); |
| 42 | 42 | ||
| 43 | int bpf_map_update_elem(int fd, const void *key, const void *value, | 43 | int bpf_map_update_elem(int fd, const void *key, const void *value, |
| 44 | __u64 flags); | 44 | __u64 flags); |
diff --git a/tools/perf/ui/browser.c b/tools/perf/ui/browser.c index a4d3762cd825..83874b0e266c 100644 --- a/tools/perf/ui/browser.c +++ b/tools/perf/ui/browser.c | |||
| @@ -704,7 +704,7 @@ static void __ui_browser__line_arrow_down(struct ui_browser *browser, | |||
| 704 | ui_browser__gotorc(browser, row, column + 1); | 704 | ui_browser__gotorc(browser, row, column + 1); |
| 705 | SLsmg_draw_hline(2); | 705 | SLsmg_draw_hline(2); |
| 706 | 706 | ||
| 707 | if (row++ == 0) | 707 | if (++row == 0) |
| 708 | goto out; | 708 | goto out; |
| 709 | } else | 709 | } else |
| 710 | row = 0; | 710 | row = 0; |
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 87b431886670..413f74df08de 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c | |||
| @@ -273,7 +273,7 @@ struct perf_evsel *perf_evsel__new_cycles(void) | |||
| 273 | struct perf_event_attr attr = { | 273 | struct perf_event_attr attr = { |
| 274 | .type = PERF_TYPE_HARDWARE, | 274 | .type = PERF_TYPE_HARDWARE, |
| 275 | .config = PERF_COUNT_HW_CPU_CYCLES, | 275 | .config = PERF_COUNT_HW_CPU_CYCLES, |
| 276 | .exclude_kernel = 1, | 276 | .exclude_kernel = geteuid() != 0, |
| 277 | }; | 277 | }; |
| 278 | struct perf_evsel *evsel; | 278 | struct perf_evsel *evsel; |
| 279 | 279 | ||
| @@ -298,8 +298,10 @@ struct perf_evsel *perf_evsel__new_cycles(void) | |||
| 298 | goto out; | 298 | goto out; |
| 299 | 299 | ||
| 300 | /* use asprintf() because free(evsel) assumes name is allocated */ | 300 | /* use asprintf() because free(evsel) assumes name is allocated */ |
| 301 | if (asprintf(&evsel->name, "cycles%.*s", | 301 | if (asprintf(&evsel->name, "cycles%s%s%.*s", |
| 302 | attr.precise_ip ? attr.precise_ip + 1 : 0, ":ppp") < 0) | 302 | (attr.precise_ip || attr.exclude_kernel) ? ":" : "", |
| 303 | attr.exclude_kernel ? "u" : "", | ||
| 304 | attr.precise_ip ? attr.precise_ip + 1 : 0, "ppp") < 0) | ||
| 303 | goto error_free; | 305 | goto error_free; |
| 304 | out: | 306 | out: |
| 305 | return evsel; | 307 | return evsel; |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 5de2b86b9880..2e9eb6aa3ce2 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
| @@ -2209,7 +2209,7 @@ int machine__get_kernel_start(struct machine *machine) | |||
| 2209 | machine->kernel_start = 1ULL << 63; | 2209 | machine->kernel_start = 1ULL << 63; |
| 2210 | if (map) { | 2210 | if (map) { |
| 2211 | err = map__load(map); | 2211 | err = map__load(map); |
| 2212 | if (map->start) | 2212 | if (!err) |
| 2213 | machine->kernel_start = map->start; | 2213 | machine->kernel_start = map->start; |
| 2214 | } | 2214 | } |
| 2215 | return err; | 2215 | return err; |
diff --git a/tools/testing/selftests/bpf/test_align.c b/tools/testing/selftests/bpf/test_align.c index bccebd935907..29793694cbc7 100644 --- a/tools/testing/selftests/bpf/test_align.c +++ b/tools/testing/selftests/bpf/test_align.c | |||
| @@ -380,7 +380,7 @@ static int do_test_single(struct bpf_align_test *test) | |||
| 380 | prog_len = probe_filter_length(prog); | 380 | prog_len = probe_filter_length(prog); |
| 381 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | 381 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, |
| 382 | prog, prog_len, 1, "GPL", 0, | 382 | prog, prog_len, 1, "GPL", 0, |
| 383 | bpf_vlog, sizeof(bpf_vlog)); | 383 | bpf_vlog, sizeof(bpf_vlog), 2); |
| 384 | if (fd_prog < 0) { | 384 | if (fd_prog < 0) { |
| 385 | printf("Failed to load program.\n"); | 385 | printf("Failed to load program.\n"); |
| 386 | printf("%s", bpf_vlog); | 386 | printf("%s", bpf_vlog); |
diff --git a/tools/testing/selftests/bpf/test_pkt_md_access.c b/tools/testing/selftests/bpf/test_pkt_md_access.c index 71729d47eb85..7956302ecdf2 100644 --- a/tools/testing/selftests/bpf/test_pkt_md_access.c +++ b/tools/testing/selftests/bpf/test_pkt_md_access.c | |||
| @@ -12,12 +12,23 @@ | |||
| 12 | 12 | ||
| 13 | int _version SEC("version") = 1; | 13 | int _version SEC("version") = 1; |
| 14 | 14 | ||
| 15 | #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ | ||
| 15 | #define TEST_FIELD(TYPE, FIELD, MASK) \ | 16 | #define TEST_FIELD(TYPE, FIELD, MASK) \ |
| 16 | { \ | 17 | { \ |
| 17 | TYPE tmp = *(volatile TYPE *)&skb->FIELD; \ | 18 | TYPE tmp = *(volatile TYPE *)&skb->FIELD; \ |
| 18 | if (tmp != ((*(volatile __u32 *)&skb->FIELD) & MASK)) \ | 19 | if (tmp != ((*(volatile __u32 *)&skb->FIELD) & MASK)) \ |
| 19 | return TC_ACT_SHOT; \ | 20 | return TC_ACT_SHOT; \ |
| 20 | } | 21 | } |
| 22 | #else | ||
| 23 | #define TEST_FIELD_OFFSET(a, b) ((sizeof(a) - sizeof(b)) / sizeof(b)) | ||
| 24 | #define TEST_FIELD(TYPE, FIELD, MASK) \ | ||
| 25 | { \ | ||
| 26 | TYPE tmp = *((volatile TYPE *)&skb->FIELD + \ | ||
| 27 | TEST_FIELD_OFFSET(skb->FIELD, TYPE)); \ | ||
| 28 | if (tmp != ((*(volatile __u32 *)&skb->FIELD) & MASK)) \ | ||
| 29 | return TC_ACT_SHOT; \ | ||
| 30 | } | ||
| 31 | #endif | ||
| 21 | 32 | ||
| 22 | SEC("test1") | 33 | SEC("test1") |
| 23 | int process(struct __sk_buff *skb) | 34 | int process(struct __sk_buff *skb) |
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c index 5855cd3d3d45..1f7dd35551b9 100644 --- a/tools/testing/selftests/bpf/test_progs.c +++ b/tools/testing/selftests/bpf/test_progs.c | |||
| @@ -340,6 +340,7 @@ static void test_bpf_obj_id(void) | |||
| 340 | 340 | ||
| 341 | /* Check getting prog info */ | 341 | /* Check getting prog info */ |
| 342 | info_len = sizeof(struct bpf_prog_info) * 2; | 342 | info_len = sizeof(struct bpf_prog_info) * 2; |
| 343 | bzero(&prog_infos[i], info_len); | ||
| 343 | prog_infos[i].jited_prog_insns = ptr_to_u64(jited_insns); | 344 | prog_infos[i].jited_prog_insns = ptr_to_u64(jited_insns); |
| 344 | prog_infos[i].jited_prog_len = sizeof(jited_insns); | 345 | prog_infos[i].jited_prog_len = sizeof(jited_insns); |
| 345 | prog_infos[i].xlated_prog_insns = ptr_to_u64(xlated_insns); | 346 | prog_infos[i].xlated_prog_insns = ptr_to_u64(xlated_insns); |
| @@ -369,6 +370,7 @@ static void test_bpf_obj_id(void) | |||
| 369 | 370 | ||
| 370 | /* Check getting map info */ | 371 | /* Check getting map info */ |
| 371 | info_len = sizeof(struct bpf_map_info) * 2; | 372 | info_len = sizeof(struct bpf_map_info) * 2; |
| 373 | bzero(&map_infos[i], info_len); | ||
| 372 | err = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i], | 374 | err = bpf_obj_get_info_by_fd(map_fds[i], &map_infos[i], |
| 373 | &info_len); | 375 | &info_len); |
| 374 | if (CHECK(err || | 376 | if (CHECK(err || |
| @@ -394,7 +396,7 @@ static void test_bpf_obj_id(void) | |||
| 394 | nr_id_found = 0; | 396 | nr_id_found = 0; |
| 395 | next_id = 0; | 397 | next_id = 0; |
| 396 | while (!bpf_prog_get_next_id(next_id, &next_id)) { | 398 | while (!bpf_prog_get_next_id(next_id, &next_id)) { |
| 397 | struct bpf_prog_info prog_info; | 399 | struct bpf_prog_info prog_info = {}; |
| 398 | int prog_fd; | 400 | int prog_fd; |
| 399 | 401 | ||
| 400 | info_len = sizeof(prog_info); | 402 | info_len = sizeof(prog_info); |
| @@ -418,6 +420,8 @@ static void test_bpf_obj_id(void) | |||
| 418 | nr_id_found++; | 420 | nr_id_found++; |
| 419 | 421 | ||
| 420 | err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); | 422 | err = bpf_obj_get_info_by_fd(prog_fd, &prog_info, &info_len); |
| 423 | prog_infos[i].jited_prog_insns = 0; | ||
| 424 | prog_infos[i].xlated_prog_insns = 0; | ||
| 421 | CHECK(err || info_len != sizeof(struct bpf_prog_info) || | 425 | CHECK(err || info_len != sizeof(struct bpf_prog_info) || |
| 422 | memcmp(&prog_info, &prog_infos[i], info_len), | 426 | memcmp(&prog_info, &prog_infos[i], info_len), |
| 423 | "get-prog-info(next_id->fd)", | 427 | "get-prog-info(next_id->fd)", |
| @@ -436,7 +440,7 @@ static void test_bpf_obj_id(void) | |||
| 436 | nr_id_found = 0; | 440 | nr_id_found = 0; |
| 437 | next_id = 0; | 441 | next_id = 0; |
| 438 | while (!bpf_map_get_next_id(next_id, &next_id)) { | 442 | while (!bpf_map_get_next_id(next_id, &next_id)) { |
| 439 | struct bpf_map_info map_info; | 443 | struct bpf_map_info map_info = {}; |
| 440 | int map_fd; | 444 | int map_fd; |
| 441 | 445 | ||
| 442 | info_len = sizeof(map_info); | 446 | info_len = sizeof(map_info); |
diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 404aec520812..d3ed7324105e 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | * License as published by the Free Software Foundation. | 8 | * License as published by the Free Software Foundation. |
| 9 | */ | 9 | */ |
| 10 | 10 | ||
| 11 | #include <endian.h> | ||
| 11 | #include <asm/types.h> | 12 | #include <asm/types.h> |
| 12 | #include <linux/types.h> | 13 | #include <linux/types.h> |
| 13 | #include <stdint.h> | 14 | #include <stdint.h> |
| @@ -1098,7 +1099,7 @@ static struct bpf_test tests[] = { | |||
| 1098 | "check skb->hash byte load permitted", | 1099 | "check skb->hash byte load permitted", |
| 1099 | .insns = { | 1100 | .insns = { |
| 1100 | BPF_MOV64_IMM(BPF_REG_0, 0), | 1101 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 1101 | #ifdef __LITTLE_ENDIAN | 1102 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 1102 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, | 1103 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, |
| 1103 | offsetof(struct __sk_buff, hash)), | 1104 | offsetof(struct __sk_buff, hash)), |
| 1104 | #else | 1105 | #else |
| @@ -1135,7 +1136,7 @@ static struct bpf_test tests[] = { | |||
| 1135 | "check skb->hash byte load not permitted 3", | 1136 | "check skb->hash byte load not permitted 3", |
| 1136 | .insns = { | 1137 | .insns = { |
| 1137 | BPF_MOV64_IMM(BPF_REG_0, 0), | 1138 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 1138 | #ifdef __LITTLE_ENDIAN | 1139 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 1139 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, | 1140 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, |
| 1140 | offsetof(struct __sk_buff, hash) + 3), | 1141 | offsetof(struct __sk_buff, hash) + 3), |
| 1141 | #else | 1142 | #else |
| @@ -1244,7 +1245,7 @@ static struct bpf_test tests[] = { | |||
| 1244 | "check skb->hash half load permitted", | 1245 | "check skb->hash half load permitted", |
| 1245 | .insns = { | 1246 | .insns = { |
| 1246 | BPF_MOV64_IMM(BPF_REG_0, 0), | 1247 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 1247 | #ifdef __LITTLE_ENDIAN | 1248 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 1248 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, | 1249 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, |
| 1249 | offsetof(struct __sk_buff, hash)), | 1250 | offsetof(struct __sk_buff, hash)), |
| 1250 | #else | 1251 | #else |
| @@ -1259,7 +1260,7 @@ static struct bpf_test tests[] = { | |||
| 1259 | "check skb->hash half load not permitted", | 1260 | "check skb->hash half load not permitted", |
| 1260 | .insns = { | 1261 | .insns = { |
| 1261 | BPF_MOV64_IMM(BPF_REG_0, 0), | 1262 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 1262 | #ifdef __LITTLE_ENDIAN | 1263 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 1263 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, | 1264 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, |
| 1264 | offsetof(struct __sk_buff, hash) + 2), | 1265 | offsetof(struct __sk_buff, hash) + 2), |
| 1265 | #else | 1266 | #else |
| @@ -4969,7 +4970,7 @@ static struct bpf_test tests[] = { | |||
| 4969 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 4970 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
| 4970 | sizeof(struct test_val), 4), | 4971 | sizeof(struct test_val), 4), |
| 4971 | BPF_MOV64_IMM(BPF_REG_4, 0), | 4972 | BPF_MOV64_IMM(BPF_REG_4, 0), |
| 4972 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 4973 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
| 4973 | BPF_MOV64_IMM(BPF_REG_3, 0), | 4974 | BPF_MOV64_IMM(BPF_REG_3, 0), |
| 4974 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 4975 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
| 4975 | BPF_MOV64_IMM(BPF_REG_0, 0), | 4976 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| @@ -4995,7 +4996,7 @@ static struct bpf_test tests[] = { | |||
| 4995 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 4996 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
| 4996 | sizeof(struct test_val) + 1, 4), | 4997 | sizeof(struct test_val) + 1, 4), |
| 4997 | BPF_MOV64_IMM(BPF_REG_4, 0), | 4998 | BPF_MOV64_IMM(BPF_REG_4, 0), |
| 4998 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 4999 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
| 4999 | BPF_MOV64_IMM(BPF_REG_3, 0), | 5000 | BPF_MOV64_IMM(BPF_REG_3, 0), |
| 5000 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 5001 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
| 5001 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5002 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| @@ -5023,7 +5024,7 @@ static struct bpf_test tests[] = { | |||
| 5023 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 5024 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
| 5024 | sizeof(struct test_val) - 20, 4), | 5025 | sizeof(struct test_val) - 20, 4), |
| 5025 | BPF_MOV64_IMM(BPF_REG_4, 0), | 5026 | BPF_MOV64_IMM(BPF_REG_4, 0), |
| 5026 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 5027 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
| 5027 | BPF_MOV64_IMM(BPF_REG_3, 0), | 5028 | BPF_MOV64_IMM(BPF_REG_3, 0), |
| 5028 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 5029 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
| 5029 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5030 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| @@ -5050,7 +5051,7 @@ static struct bpf_test tests[] = { | |||
| 5050 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, | 5051 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_2, |
| 5051 | sizeof(struct test_val) - 19, 4), | 5052 | sizeof(struct test_val) - 19, 4), |
| 5052 | BPF_MOV64_IMM(BPF_REG_4, 0), | 5053 | BPF_MOV64_IMM(BPF_REG_4, 0), |
| 5053 | BPF_JMP_REG(BPF_JGE, BPF_REG_4, BPF_REG_2, 2), | 5054 | BPF_JMP_REG(BPF_JSGE, BPF_REG_4, BPF_REG_2, 2), |
| 5054 | BPF_MOV64_IMM(BPF_REG_3, 0), | 5055 | BPF_MOV64_IMM(BPF_REG_3, 0), |
| 5055 | BPF_EMIT_CALL(BPF_FUNC_probe_read), | 5056 | BPF_EMIT_CALL(BPF_FUNC_probe_read), |
| 5056 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5057 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| @@ -5422,7 +5423,7 @@ static struct bpf_test tests[] = { | |||
| 5422 | "check bpf_perf_event_data->sample_period byte load permitted", | 5423 | "check bpf_perf_event_data->sample_period byte load permitted", |
| 5423 | .insns = { | 5424 | .insns = { |
| 5424 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5425 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 5425 | #ifdef __LITTLE_ENDIAN | 5426 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 5426 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, | 5427 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_1, |
| 5427 | offsetof(struct bpf_perf_event_data, sample_period)), | 5428 | offsetof(struct bpf_perf_event_data, sample_period)), |
| 5428 | #else | 5429 | #else |
| @@ -5438,7 +5439,7 @@ static struct bpf_test tests[] = { | |||
| 5438 | "check bpf_perf_event_data->sample_period half load permitted", | 5439 | "check bpf_perf_event_data->sample_period half load permitted", |
| 5439 | .insns = { | 5440 | .insns = { |
| 5440 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5441 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 5441 | #ifdef __LITTLE_ENDIAN | 5442 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 5442 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, | 5443 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, |
| 5443 | offsetof(struct bpf_perf_event_data, sample_period)), | 5444 | offsetof(struct bpf_perf_event_data, sample_period)), |
| 5444 | #else | 5445 | #else |
| @@ -5454,7 +5455,7 @@ static struct bpf_test tests[] = { | |||
| 5454 | "check bpf_perf_event_data->sample_period word load permitted", | 5455 | "check bpf_perf_event_data->sample_period word load permitted", |
| 5455 | .insns = { | 5456 | .insns = { |
| 5456 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5457 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 5457 | #ifdef __LITTLE_ENDIAN | 5458 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 5458 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, | 5459 | BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, |
| 5459 | offsetof(struct bpf_perf_event_data, sample_period)), | 5460 | offsetof(struct bpf_perf_event_data, sample_period)), |
| 5460 | #else | 5461 | #else |
| @@ -5481,7 +5482,7 @@ static struct bpf_test tests[] = { | |||
| 5481 | "check skb->data half load not permitted", | 5482 | "check skb->data half load not permitted", |
| 5482 | .insns = { | 5483 | .insns = { |
| 5483 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5484 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 5484 | #ifdef __LITTLE_ENDIAN | 5485 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 5485 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, | 5486 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, |
| 5486 | offsetof(struct __sk_buff, data)), | 5487 | offsetof(struct __sk_buff, data)), |
| 5487 | #else | 5488 | #else |
| @@ -5497,7 +5498,7 @@ static struct bpf_test tests[] = { | |||
| 5497 | "check skb->tc_classid half load not permitted for lwt prog", | 5498 | "check skb->tc_classid half load not permitted for lwt prog", |
| 5498 | .insns = { | 5499 | .insns = { |
| 5499 | BPF_MOV64_IMM(BPF_REG_0, 0), | 5500 | BPF_MOV64_IMM(BPF_REG_0, 0), |
| 5500 | #ifdef __LITTLE_ENDIAN | 5501 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 5501 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, | 5502 | BPF_LDX_MEM(BPF_H, BPF_REG_0, BPF_REG_1, |
| 5502 | offsetof(struct __sk_buff, tc_classid)), | 5503 | offsetof(struct __sk_buff, tc_classid)), |
| 5503 | #else | 5504 | #else |
| @@ -5510,6 +5511,504 @@ static struct bpf_test tests[] = { | |||
| 5510 | .errstr = "invalid bpf_context access", | 5511 | .errstr = "invalid bpf_context access", |
| 5511 | .prog_type = BPF_PROG_TYPE_LWT_IN, | 5512 | .prog_type = BPF_PROG_TYPE_LWT_IN, |
| 5512 | }, | 5513 | }, |
| 5514 | { | ||
| 5515 | "bounds checks mixing signed and unsigned, positive bounds", | ||
| 5516 | .insns = { | ||
| 5517 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5518 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5519 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5520 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5521 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5522 | BPF_FUNC_map_lookup_elem), | ||
| 5523 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
| 5524 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5525 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5526 | BPF_MOV64_IMM(BPF_REG_2, 2), | ||
| 5527 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 3), | ||
| 5528 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 4, 2), | ||
| 5529 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5530 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5531 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5532 | BPF_EXIT_INSN(), | ||
| 5533 | }, | ||
| 5534 | .fixup_map1 = { 3 }, | ||
| 5535 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5536 | .errstr = "R0 min value is negative", | ||
| 5537 | .result = REJECT, | ||
| 5538 | .result_unpriv = REJECT, | ||
| 5539 | }, | ||
| 5540 | { | ||
| 5541 | "bounds checks mixing signed and unsigned", | ||
| 5542 | .insns = { | ||
| 5543 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5544 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5545 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5546 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5547 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5548 | BPF_FUNC_map_lookup_elem), | ||
| 5549 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
| 5550 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5551 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5552 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5553 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), | ||
| 5554 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5555 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5556 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5557 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5558 | BPF_EXIT_INSN(), | ||
| 5559 | }, | ||
| 5560 | .fixup_map1 = { 3 }, | ||
| 5561 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5562 | .errstr = "R0 min value is negative", | ||
| 5563 | .result = REJECT, | ||
| 5564 | .result_unpriv = REJECT, | ||
| 5565 | }, | ||
| 5566 | { | ||
| 5567 | "bounds checks mixing signed and unsigned, variant 2", | ||
| 5568 | .insns = { | ||
| 5569 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5570 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5571 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5572 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5573 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5574 | BPF_FUNC_map_lookup_elem), | ||
| 5575 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5576 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5577 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5578 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5579 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5), | ||
| 5580 | BPF_MOV64_IMM(BPF_REG_8, 0), | ||
| 5581 | BPF_ALU64_REG(BPF_ADD, BPF_REG_8, BPF_REG_1), | ||
| 5582 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_8, 1, 2), | ||
| 5583 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_8), | ||
| 5584 | BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0), | ||
| 5585 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5586 | BPF_EXIT_INSN(), | ||
| 5587 | }, | ||
| 5588 | .fixup_map1 = { 3 }, | ||
| 5589 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5590 | .errstr = "R8 invalid mem access 'inv'", | ||
| 5591 | .result = REJECT, | ||
| 5592 | .result_unpriv = REJECT, | ||
| 5593 | }, | ||
| 5594 | { | ||
| 5595 | "bounds checks mixing signed and unsigned, variant 3", | ||
| 5596 | .insns = { | ||
| 5597 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5598 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5599 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5600 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5601 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5602 | BPF_FUNC_map_lookup_elem), | ||
| 5603 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), | ||
| 5604 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5605 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5606 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5607 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 4), | ||
| 5608 | BPF_MOV64_REG(BPF_REG_8, BPF_REG_1), | ||
| 5609 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_8, 1, 2), | ||
| 5610 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_8), | ||
| 5611 | BPF_ST_MEM(BPF_B, BPF_REG_8, 0, 0), | ||
| 5612 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5613 | BPF_EXIT_INSN(), | ||
| 5614 | }, | ||
| 5615 | .fixup_map1 = { 3 }, | ||
| 5616 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5617 | .errstr = "R8 invalid mem access 'inv'", | ||
| 5618 | .result = REJECT, | ||
| 5619 | .result_unpriv = REJECT, | ||
| 5620 | }, | ||
| 5621 | { | ||
| 5622 | "bounds checks mixing signed and unsigned, variant 4", | ||
| 5623 | .insns = { | ||
| 5624 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5625 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5626 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5627 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5628 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5629 | BPF_FUNC_map_lookup_elem), | ||
| 5630 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
| 5631 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5632 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5633 | BPF_MOV64_IMM(BPF_REG_2, 1), | ||
| 5634 | BPF_ALU64_REG(BPF_AND, BPF_REG_1, BPF_REG_2), | ||
| 5635 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5636 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5637 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5638 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5639 | BPF_EXIT_INSN(), | ||
| 5640 | }, | ||
| 5641 | .fixup_map1 = { 3 }, | ||
| 5642 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5643 | .errstr = "R0 min value is negative", | ||
| 5644 | .result = REJECT, | ||
| 5645 | .result_unpriv = REJECT, | ||
| 5646 | }, | ||
| 5647 | { | ||
| 5648 | "bounds checks mixing signed and unsigned, variant 5", | ||
| 5649 | .insns = { | ||
| 5650 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5651 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5652 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5653 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5654 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5655 | BPF_FUNC_map_lookup_elem), | ||
| 5656 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5657 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5658 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5659 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5660 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 5), | ||
| 5661 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 4), | ||
| 5662 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 4), | ||
| 5663 | BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), | ||
| 5664 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5665 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5666 | BPF_EXIT_INSN(), | ||
| 5667 | }, | ||
| 5668 | .fixup_map1 = { 3 }, | ||
| 5669 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5670 | .errstr = "R0 invalid mem access", | ||
| 5671 | .result = REJECT, | ||
| 5672 | .result_unpriv = REJECT, | ||
| 5673 | }, | ||
| 5674 | { | ||
| 5675 | "bounds checks mixing signed and unsigned, variant 6", | ||
| 5676 | .insns = { | ||
| 5677 | BPF_MOV64_IMM(BPF_REG_2, 0), | ||
| 5678 | BPF_MOV64_REG(BPF_REG_3, BPF_REG_10), | ||
| 5679 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_3, -512), | ||
| 5680 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5681 | BPF_LDX_MEM(BPF_DW, BPF_REG_4, BPF_REG_10, -16), | ||
| 5682 | BPF_MOV64_IMM(BPF_REG_6, -1), | ||
| 5683 | BPF_JMP_REG(BPF_JGT, BPF_REG_4, BPF_REG_6, 5), | ||
| 5684 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_4, 1, 4), | ||
| 5685 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_4, 1), | ||
| 5686 | BPF_MOV64_IMM(BPF_REG_5, 0), | ||
| 5687 | BPF_ST_MEM(BPF_H, BPF_REG_10, -512, 0), | ||
| 5688 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5689 | BPF_FUNC_skb_load_bytes), | ||
| 5690 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5691 | BPF_EXIT_INSN(), | ||
| 5692 | }, | ||
| 5693 | .errstr_unpriv = "R4 min value is negative, either use unsigned", | ||
| 5694 | .errstr = "R4 min value is negative, either use unsigned", | ||
| 5695 | .result = REJECT, | ||
| 5696 | .result_unpriv = REJECT, | ||
| 5697 | }, | ||
| 5698 | { | ||
| 5699 | "bounds checks mixing signed and unsigned, variant 7", | ||
| 5700 | .insns = { | ||
| 5701 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5702 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5703 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5704 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5705 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5706 | BPF_FUNC_map_lookup_elem), | ||
| 5707 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
| 5708 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5709 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5710 | BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024), | ||
| 5711 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), | ||
| 5712 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5713 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5714 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5715 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5716 | BPF_EXIT_INSN(), | ||
| 5717 | }, | ||
| 5718 | .fixup_map1 = { 3 }, | ||
| 5719 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5720 | .errstr = "R0 min value is negative", | ||
| 5721 | .result = REJECT, | ||
| 5722 | .result_unpriv = REJECT, | ||
| 5723 | }, | ||
| 5724 | { | ||
| 5725 | "bounds checks mixing signed and unsigned, variant 8", | ||
| 5726 | .insns = { | ||
| 5727 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5728 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5729 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5730 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5731 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5732 | BPF_FUNC_map_lookup_elem), | ||
| 5733 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 7), | ||
| 5734 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5735 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5736 | BPF_MOV64_IMM(BPF_REG_2, 1024 * 1024 * 1024 + 1), | ||
| 5737 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, 3), | ||
| 5738 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5739 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5740 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5741 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5742 | BPF_EXIT_INSN(), | ||
| 5743 | }, | ||
| 5744 | .fixup_map1 = { 3 }, | ||
| 5745 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5746 | .errstr = "R0 min value is negative", | ||
| 5747 | .result = REJECT, | ||
| 5748 | .result_unpriv = REJECT, | ||
| 5749 | }, | ||
| 5750 | { | ||
| 5751 | "bounds checks mixing signed and unsigned, variant 9", | ||
| 5752 | .insns = { | ||
| 5753 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5754 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5755 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5756 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5757 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5758 | BPF_FUNC_map_lookup_elem), | ||
| 5759 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5760 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5761 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5762 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5763 | BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), | ||
| 5764 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5765 | BPF_EXIT_INSN(), | ||
| 5766 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5767 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5768 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5769 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5770 | BPF_EXIT_INSN(), | ||
| 5771 | }, | ||
| 5772 | .fixup_map1 = { 3 }, | ||
| 5773 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5774 | .errstr = "R0 min value is negative", | ||
| 5775 | .result = REJECT, | ||
| 5776 | .result_unpriv = REJECT, | ||
| 5777 | }, | ||
| 5778 | { | ||
| 5779 | "bounds checks mixing signed and unsigned, variant 10", | ||
| 5780 | .insns = { | ||
| 5781 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5782 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5783 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5784 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5785 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5786 | BPF_FUNC_map_lookup_elem), | ||
| 5787 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 10), | ||
| 5788 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5789 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5790 | BPF_LD_IMM64(BPF_REG_2, -9223372036854775808ULL), | ||
| 5791 | BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), | ||
| 5792 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5793 | BPF_EXIT_INSN(), | ||
| 5794 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5795 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5796 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5797 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5798 | BPF_EXIT_INSN(), | ||
| 5799 | }, | ||
| 5800 | .fixup_map1 = { 3 }, | ||
| 5801 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5802 | .errstr = "R0 min value is negative", | ||
| 5803 | .result = REJECT, | ||
| 5804 | .result_unpriv = REJECT, | ||
| 5805 | }, | ||
| 5806 | { | ||
| 5807 | "bounds checks mixing signed and unsigned, variant 11", | ||
| 5808 | .insns = { | ||
| 5809 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5810 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5811 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5812 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5813 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5814 | BPF_FUNC_map_lookup_elem), | ||
| 5815 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5816 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5817 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5818 | BPF_MOV64_IMM(BPF_REG_2, 0), | ||
| 5819 | BPF_JMP_REG(BPF_JGT, BPF_REG_2, BPF_REG_1, 2), | ||
| 5820 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5821 | BPF_EXIT_INSN(), | ||
| 5822 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5823 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5824 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5825 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5826 | BPF_EXIT_INSN(), | ||
| 5827 | }, | ||
| 5828 | .fixup_map1 = { 3 }, | ||
| 5829 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5830 | .errstr = "R0 min value is negative", | ||
| 5831 | .result = REJECT, | ||
| 5832 | .result_unpriv = REJECT, | ||
| 5833 | }, | ||
| 5834 | { | ||
| 5835 | "bounds checks mixing signed and unsigned, variant 12", | ||
| 5836 | .insns = { | ||
| 5837 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5838 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5839 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5840 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5841 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5842 | BPF_FUNC_map_lookup_elem), | ||
| 5843 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5844 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5845 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5846 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5847 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
| 5848 | /* Dead branch. */ | ||
| 5849 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5850 | BPF_EXIT_INSN(), | ||
| 5851 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5852 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5853 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5854 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5855 | BPF_EXIT_INSN(), | ||
| 5856 | }, | ||
| 5857 | .fixup_map1 = { 3 }, | ||
| 5858 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5859 | .errstr = "R0 min value is negative", | ||
| 5860 | .result = REJECT, | ||
| 5861 | .result_unpriv = REJECT, | ||
| 5862 | }, | ||
| 5863 | { | ||
| 5864 | "bounds checks mixing signed and unsigned, variant 13", | ||
| 5865 | .insns = { | ||
| 5866 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5867 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5868 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5869 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5870 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5871 | BPF_FUNC_map_lookup_elem), | ||
| 5872 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5873 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5874 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5875 | BPF_MOV64_IMM(BPF_REG_2, -6), | ||
| 5876 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
| 5877 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5878 | BPF_EXIT_INSN(), | ||
| 5879 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5880 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5881 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5882 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5883 | BPF_EXIT_INSN(), | ||
| 5884 | }, | ||
| 5885 | .fixup_map1 = { 3 }, | ||
| 5886 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5887 | .errstr = "R0 min value is negative", | ||
| 5888 | .result = REJECT, | ||
| 5889 | .result_unpriv = REJECT, | ||
| 5890 | }, | ||
| 5891 | { | ||
| 5892 | "bounds checks mixing signed and unsigned, variant 14", | ||
| 5893 | .insns = { | ||
| 5894 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5895 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5896 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5897 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5898 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5899 | BPF_FUNC_map_lookup_elem), | ||
| 5900 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), | ||
| 5901 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5902 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5903 | BPF_MOV64_IMM(BPF_REG_2, 2), | ||
| 5904 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
| 5905 | BPF_MOV64_IMM(BPF_REG_7, 1), | ||
| 5906 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, 0, 2), | ||
| 5907 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5908 | BPF_EXIT_INSN(), | ||
| 5909 | BPF_ALU64_REG(BPF_ADD, BPF_REG_7, BPF_REG_1), | ||
| 5910 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_7, 4, 2), | ||
| 5911 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_7), | ||
| 5912 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5913 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5914 | BPF_EXIT_INSN(), | ||
| 5915 | }, | ||
| 5916 | .fixup_map1 = { 3 }, | ||
| 5917 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5918 | .errstr = "R0 min value is negative", | ||
| 5919 | .result = REJECT, | ||
| 5920 | .result_unpriv = REJECT, | ||
| 5921 | }, | ||
| 5922 | { | ||
| 5923 | "bounds checks mixing signed and unsigned, variant 15", | ||
| 5924 | .insns = { | ||
| 5925 | BPF_LDX_MEM(BPF_W, BPF_REG_9, BPF_REG_1, | ||
| 5926 | offsetof(struct __sk_buff, mark)), | ||
| 5927 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5928 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5929 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5930 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5931 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5932 | BPF_FUNC_map_lookup_elem), | ||
| 5933 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 8), | ||
| 5934 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5935 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5936 | BPF_MOV64_IMM(BPF_REG_2, -1), | ||
| 5937 | BPF_MOV64_IMM(BPF_REG_8, 2), | ||
| 5938 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_9, 42, 6), | ||
| 5939 | BPF_JMP_REG(BPF_JSGT, BPF_REG_8, BPF_REG_1, 3), | ||
| 5940 | BPF_JMP_IMM(BPF_JSGT, BPF_REG_1, 1, 2), | ||
| 5941 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5942 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5943 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5944 | BPF_EXIT_INSN(), | ||
| 5945 | BPF_JMP_REG(BPF_JGT, BPF_REG_1, BPF_REG_2, -3), | ||
| 5946 | BPF_JMP_IMM(BPF_JA, 0, 0, -7), | ||
| 5947 | }, | ||
| 5948 | .fixup_map1 = { 4 }, | ||
| 5949 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5950 | .errstr = "R0 min value is negative", | ||
| 5951 | .result = REJECT, | ||
| 5952 | .result_unpriv = REJECT, | ||
| 5953 | }, | ||
| 5954 | { | ||
| 5955 | "bounds checks mixing signed and unsigned, variant 16", | ||
| 5956 | .insns = { | ||
| 5957 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5958 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5959 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5960 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5961 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5962 | BPF_FUNC_map_lookup_elem), | ||
| 5963 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 4), | ||
| 5964 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -16, -8), | ||
| 5965 | BPF_LDX_MEM(BPF_DW, BPF_REG_1, BPF_REG_10, -16), | ||
| 5966 | BPF_MOV64_IMM(BPF_REG_2, -6), | ||
| 5967 | BPF_JMP_REG(BPF_JGE, BPF_REG_2, BPF_REG_1, 2), | ||
| 5968 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5969 | BPF_EXIT_INSN(), | ||
| 5970 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 5971 | BPF_JMP_IMM(BPF_JGT, BPF_REG_0, 1, 2), | ||
| 5972 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5973 | BPF_EXIT_INSN(), | ||
| 5974 | BPF_ST_MEM(BPF_B, BPF_REG_0, 0, 0), | ||
| 5975 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 5976 | BPF_EXIT_INSN(), | ||
| 5977 | }, | ||
| 5978 | .fixup_map1 = { 3 }, | ||
| 5979 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 5980 | .errstr = "R0 min value is negative", | ||
| 5981 | .result = REJECT, | ||
| 5982 | .result_unpriv = REJECT, | ||
| 5983 | }, | ||
| 5984 | { | ||
| 5985 | "subtraction bounds (map value)", | ||
| 5986 | .insns = { | ||
| 5987 | BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), | ||
| 5988 | BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), | ||
| 5989 | BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), | ||
| 5990 | BPF_LD_MAP_FD(BPF_REG_1, 0), | ||
| 5991 | BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, | ||
| 5992 | BPF_FUNC_map_lookup_elem), | ||
| 5993 | BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 9), | ||
| 5994 | BPF_LDX_MEM(BPF_B, BPF_REG_1, BPF_REG_0, 0), | ||
| 5995 | BPF_JMP_IMM(BPF_JGT, BPF_REG_1, 0xff, 7), | ||
| 5996 | BPF_LDX_MEM(BPF_B, BPF_REG_3, BPF_REG_0, 1), | ||
| 5997 | BPF_JMP_IMM(BPF_JGT, BPF_REG_3, 0xff, 5), | ||
| 5998 | BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_3), | ||
| 5999 | BPF_ALU64_IMM(BPF_RSH, BPF_REG_1, 56), | ||
| 6000 | BPF_ALU64_REG(BPF_ADD, BPF_REG_0, BPF_REG_1), | ||
| 6001 | BPF_LDX_MEM(BPF_B, BPF_REG_0, BPF_REG_0, 0), | ||
| 6002 | BPF_EXIT_INSN(), | ||
| 6003 | BPF_MOV64_IMM(BPF_REG_0, 0), | ||
| 6004 | BPF_EXIT_INSN(), | ||
| 6005 | }, | ||
| 6006 | .fixup_map1 = { 3 }, | ||
| 6007 | .errstr_unpriv = "R0 pointer arithmetic prohibited", | ||
| 6008 | .errstr = "R0 min value is negative, either use unsigned index or do a if (index >=0) check.", | ||
| 6009 | .result = REJECT, | ||
| 6010 | .result_unpriv = REJECT, | ||
| 6011 | }, | ||
| 5513 | }; | 6012 | }; |
| 5514 | 6013 | ||
| 5515 | static int probe_filter_length(const struct bpf_insn *fp) | 6014 | static int probe_filter_length(const struct bpf_insn *fp) |
| @@ -5633,7 +6132,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, | |||
| 5633 | 6132 | ||
| 5634 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, | 6133 | fd_prog = bpf_verify_program(prog_type ? : BPF_PROG_TYPE_SOCKET_FILTER, |
| 5635 | prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, | 6134 | prog, prog_len, test->flags & F_LOAD_WITH_STRICT_ALIGNMENT, |
| 5636 | "GPL", 0, bpf_vlog, sizeof(bpf_vlog)); | 6135 | "GPL", 0, bpf_vlog, sizeof(bpf_vlog), 1); |
| 5637 | 6136 | ||
| 5638 | expected_ret = unpriv && test->result_unpriv != UNDEF ? | 6137 | expected_ret = unpriv && test->result_unpriv != UNDEF ? |
| 5639 | test->result_unpriv : test->result; | 6138 | test->result_unpriv : test->result; |
diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selftests/futex/Makefile index e2fbb890aef9..7c647f619d63 100644 --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile | |||
| @@ -14,7 +14,7 @@ all: | |||
| 14 | done | 14 | done |
| 15 | 15 | ||
| 16 | override define RUN_TESTS | 16 | override define RUN_TESTS |
| 17 | @if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi | 17 | $(OUTPUT)/run.sh |
| 18 | endef | 18 | endef |
| 19 | 19 | ||
| 20 | override define INSTALL_RULE | 20 | override define INSTALL_RULE |
diff --git a/tools/testing/selftests/kmod/kmod.sh b/tools/testing/selftests/kmod/kmod.sh index 8cecae9a8bca..7956ea3be667 100644..100755 --- a/tools/testing/selftests/kmod/kmod.sh +++ b/tools/testing/selftests/kmod/kmod.sh | |||
| @@ -473,8 +473,8 @@ usage() | |||
| 473 | echo " all Runs all tests (default)" | 473 | echo " all Runs all tests (default)" |
| 474 | echo " -t Run test ID the number amount of times is recommended" | 474 | echo " -t Run test ID the number amount of times is recommended" |
| 475 | echo " -w Watch test ID run until it runs into an error" | 475 | echo " -w Watch test ID run until it runs into an error" |
| 476 | echo " -c Run test ID once" | 476 | echo " -s Run test ID once" |
| 477 | echo " -s Run test ID x test-count number of times" | 477 | echo " -c Run test ID x test-count number of times" |
| 478 | echo " -l List all test ID list" | 478 | echo " -l List all test ID list" |
| 479 | echo " -h|--help Help" | 479 | echo " -h|--help Help" |
| 480 | echo | 480 | echo |
diff --git a/tools/testing/selftests/sysctl/sysctl.sh b/tools/testing/selftests/sysctl/sysctl.sh index ec232c3cfcaa..ec232c3cfcaa 100644..100755 --- a/tools/testing/selftests/sysctl/sysctl.sh +++ b/tools/testing/selftests/sysctl/sysctl.sh | |||
diff --git a/tools/testing/selftests/timers/freq-step.c b/tools/testing/selftests/timers/freq-step.c index e8c61830825a..22312eb4c941 100644 --- a/tools/testing/selftests/timers/freq-step.c +++ b/tools/testing/selftests/timers/freq-step.c | |||
| @@ -229,10 +229,9 @@ static void init_test(void) | |||
| 229 | printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t", | 229 | printf("CLOCK_MONOTONIC_RAW+CLOCK_MONOTONIC precision: %.0f ns\t\t", |
| 230 | 1e9 * precision); | 230 | 1e9 * precision); |
| 231 | 231 | ||
| 232 | if (precision > MAX_PRECISION) { | 232 | if (precision > MAX_PRECISION) |
| 233 | printf("[SKIP]\n"); | 233 | ksft_exit_skip("precision: %.0f ns > MAX_PRECISION: %.0f ns\n", |
| 234 | ksft_exit_skip(); | 234 | 1e9 * precision, 1e9 * MAX_PRECISION); |
| 235 | } | ||
| 236 | 235 | ||
| 237 | printf("[OK]\n"); | 236 | printf("[OK]\n"); |
| 238 | srand(ts.tv_sec ^ ts.tv_nsec); | 237 | srand(ts.tv_sec ^ ts.tv_nsec); |
