diff options
Diffstat (limited to 'kernel/bpf/core.c')
-rw-r--r-- | kernel/bpf/core.c | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index a9e6c04d0f4a..1e5625d46414 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c | |||
@@ -598,8 +598,6 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr, | |||
598 | bpf_fill_ill_insns(hdr, size); | 598 | bpf_fill_ill_insns(hdr, size); |
599 | 599 | ||
600 | hdr->pages = size / PAGE_SIZE; | 600 | hdr->pages = size / PAGE_SIZE; |
601 | hdr->locked = 0; | ||
602 | |||
603 | hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)), | 601 | hole = min_t(unsigned int, size - (proglen + sizeof(*hdr)), |
604 | PAGE_SIZE - sizeof(*hdr)); | 602 | PAGE_SIZE - sizeof(*hdr)); |
605 | start = (get_random_int() % hole) & ~(alignment - 1); | 603 | start = (get_random_int() % hole) & ~(alignment - 1); |
@@ -1450,22 +1448,6 @@ static int bpf_check_tail_call(const struct bpf_prog *fp) | |||
1450 | return 0; | 1448 | return 0; |
1451 | } | 1449 | } |
1452 | 1450 | ||
1453 | static int bpf_prog_check_pages_ro_locked(const struct bpf_prog *fp) | ||
1454 | { | ||
1455 | #ifdef CONFIG_ARCH_HAS_SET_MEMORY | ||
1456 | int i, err; | ||
1457 | |||
1458 | for (i = 0; i < fp->aux->func_cnt; i++) { | ||
1459 | err = bpf_prog_check_pages_ro_single(fp->aux->func[i]); | ||
1460 | if (err) | ||
1461 | return err; | ||
1462 | } | ||
1463 | |||
1464 | return bpf_prog_check_pages_ro_single(fp); | ||
1465 | #endif | ||
1466 | return 0; | ||
1467 | } | ||
1468 | |||
1469 | static void bpf_prog_select_func(struct bpf_prog *fp) | 1451 | static void bpf_prog_select_func(struct bpf_prog *fp) |
1470 | { | 1452 | { |
1471 | #ifndef CONFIG_BPF_JIT_ALWAYS_ON | 1453 | #ifndef CONFIG_BPF_JIT_ALWAYS_ON |
@@ -1524,17 +1506,7 @@ finalize: | |||
1524 | * all eBPF JITs might immediately support all features. | 1506 | * all eBPF JITs might immediately support all features. |
1525 | */ | 1507 | */ |
1526 | *err = bpf_check_tail_call(fp); | 1508 | *err = bpf_check_tail_call(fp); |
1527 | if (*err) | 1509 | |
1528 | return fp; | ||
1529 | |||
1530 | /* Checkpoint: at this point onwards any cBPF -> eBPF or | ||
1531 | * native eBPF program is read-only. If we failed to change | ||
1532 | * the page attributes (e.g. allocation failure from | ||
1533 | * splitting large pages), then reject the whole program | ||
1534 | * in order to guarantee not ending up with any W+X pages | ||
1535 | * from BPF side in kernel. | ||
1536 | */ | ||
1537 | *err = bpf_prog_check_pages_ro_locked(fp); | ||
1538 | return fp; | 1510 | return fp; |
1539 | } | 1511 | } |
1540 | EXPORT_SYMBOL_GPL(bpf_prog_select_runtime); | 1512 | EXPORT_SYMBOL_GPL(bpf_prog_select_runtime); |