|
74 | 74 | 1ULL << CAP_BPF)
|
75 | 75 | #define UNPRIV_SYSCTL "kernel/unprivileged_bpf_disabled"
|
76 | 76 | static bool unpriv_disabled = false;
|
| 77 | +static bool jit_disabled; |
77 | 78 | static int skips;
|
78 | 79 | static bool verbose = false;
|
79 | 80 | static int verif_log_level = 0;
|
@@ -1355,6 +1356,16 @@ static bool is_skip_insn(struct bpf_insn *insn)
|
1355 | 1356 | return memcmp(insn, &skip_insn, sizeof(skip_insn)) == 0;
|
1356 | 1357 | }
|
1357 | 1358 |
|
| 1359 | +static bool is_ldimm64_insn(struct bpf_insn *insn) |
| 1360 | +{ |
| 1361 | + return insn->code == (BPF_LD | BPF_IMM | BPF_DW); |
| 1362 | +} |
| 1363 | + |
| 1364 | +static bool insn_is_pseudo_func(struct bpf_insn *insn) |
| 1365 | +{ |
| 1366 | + return is_ldimm64_insn(insn) && insn->src_reg == BPF_PSEUDO_FUNC; |
| 1367 | +} |
| 1368 | + |
1358 | 1369 | static int null_terminated_insn_len(struct bpf_insn *seq, int max_len)
|
1359 | 1370 | {
|
1360 | 1371 | int i;
|
@@ -1622,6 +1633,16 @@ static void do_test_single(struct bpf_test *test, bool unpriv,
|
1622 | 1633 | alignment_prevented_execution = 0;
|
1623 | 1634 |
|
1624 | 1635 | if (expected_ret == ACCEPT || expected_ret == VERBOSE_ACCEPT) {
|
| 1636 | + if (fd_prog < 0 && saved_errno == EINVAL && jit_disabled) { |
| 1637 | + for (i = 0; i < prog_len; i++, prog++) { |
| 1638 | + if (!insn_is_pseudo_func(prog)) |
| 1639 | + continue; |
| 1640 | + printf("SKIP (callbacks are not allowed in non-JITed programs)\n"); |
| 1641 | + skips++; |
| 1642 | + goto close_fds; |
| 1643 | + } |
| 1644 | + } |
| 1645 | + |
1625 | 1646 | if (fd_prog < 0) {
|
1626 | 1647 | printf("FAIL\nFailed to load prog '%s'!\n",
|
1627 | 1648 | strerror(saved_errno));
|
@@ -1844,6 +1865,8 @@ int main(int argc, char **argv)
|
1844 | 1865 | return EXIT_FAILURE;
|
1845 | 1866 | }
|
1846 | 1867 |
|
| 1868 | + jit_disabled = !is_jit_enabled(); |
| 1869 | + |
1847 | 1870 | /* Use libbpf 1.0 API mode */
|
1848 | 1871 | libbpf_set_strict_mode(LIBBPF_STRICT_ALL);
|
1849 | 1872 |
|
|
0 commit comments