History

bpf: Use vmalloc special flag

Use new flag VM_FLUSH_RESET_PERMS for handling freeing of special permissioned memory in vmalloc and remove places where memory was set RW before freeing which is no longer needed. Don't track if the memory is RO anymore because it is now tracked in vmalloc.

Rick Edgecombe committed 7 years ago

Commit d53d2f71 parent 1a7b7d92 files · +3 −15Browse files

Showing the changes to include/linux (1 of 2 files). Show all

Unified · Split

include/linux/filter.h+3−14
@@ -20,6 +20,7 @@ · 19 unmodified lines
2020 #include <linux/set_memory.h>
2121 #include <linux/kallsyms.h>
2222 #include <linux/if_vlan.h>
23+#include <linux/vmalloc.h>
2324
2425 #include <net/sch_generic.h>
2526
@@ -503,7 +504,6 @@ struct bpf_prog { · 477 unmodified lines
503504 u16 pages; /* Number of allocated pages */
504505 u16 jited:1, /* Is our filter JIT'ed? */
505506 jit_requested:1,/* archs need to JIT the prog */
506− undo_set_mem:1, /* Passed set_memory_ro() checkpoint */
507507 gpl_compatible:1, /* Is filter GPL compatible? */
508508 cb_access:1, /* Is control block accessed? */
509509 dst_needed:1, /* Do we need dst entry? */
@@ -733,27 +733,17 @@ bpf_ctx_narrow_access_ok(u32 off, u32 size, u32 size_default) · 223 unmodified lines
733733
734734 static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
735735 {
736− fp->undo_set_mem = 1;
736+ set_vm_flush_reset_perms(fp);
737737 set_memory_ro((unsigned long)fp, fp->pages);
738738 }
739739
740−static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
741−{
742− if (fp->undo_set_mem)
743− set_memory_rw((unsigned long)fp, fp->pages);
744−}
745−
746740 static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
747741 {
742+ set_vm_flush_reset_perms(hdr);
748743 set_memory_ro((unsigned long)hdr, hdr->pages);
749744 set_memory_x((unsigned long)hdr, hdr->pages);
750745 }
751746
752−static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr)
753−{
754− set_memory_rw((unsigned long)hdr, hdr->pages);
755−}
756−
757747 static inline struct bpf_binary_header *
758748 bpf_jit_binary_hdr(const struct bpf_prog *fp)
759749 {
@@ -789,7 +779,6 @@ void __bpf_prog_free(struct bpf_prog *fp); · 29 unmodified lines
789779
790780 static inline void bpf_prog_unlock_free(struct bpf_prog *fp)
791781 {
792− bpf_prog_unlock_ro(fp);
793782 __bpf_prog_free(fp);
794783 }
795784

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t