aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm64/net/bpf_jit_comp.c2
-rw-r--r--arch/s390/net/bpf_jit_comp.c2
-rw-r--r--arch/x86/net/bpf_jit_comp.c2
-rw-r--r--include/linux/filter.h13
4 files changed, 14 insertions, 5 deletions
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 05d12104d270..a785554916c0 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -898,7 +898,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
898 898
899 bpf_flush_icache(header, ctx.image + ctx.idx); 899 bpf_flush_icache(header, ctx.image + ctx.idx);
900 900
901 set_memory_ro((unsigned long)header, header->pages); 901 bpf_jit_binary_lock_ro(header);
902 prog->bpf_func = (void *)ctx.image; 902 prog->bpf_func = (void *)ctx.image;
903 prog->jited = 1; 903 prog->jited = 1;
904 904
diff --git a/arch/s390/net/bpf_jit_comp.c b/arch/s390/net/bpf_jit_comp.c
index f1d0e62ec1dd..b49c52a02087 100644
--- a/arch/s390/net/bpf_jit_comp.c
+++ b/arch/s390/net/bpf_jit_comp.c
@@ -1327,7 +1327,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
1327 print_fn_code(jit.prg_buf, jit.size_prg); 1327 print_fn_code(jit.prg_buf, jit.size_prg);
1328 } 1328 }
1329 if (jit.prg_buf) { 1329 if (jit.prg_buf) {
1330 set_memory_ro((unsigned long)header, header->pages); 1330 bpf_jit_binary_lock_ro(header);
1331 fp->bpf_func = (void *) jit.prg_buf; 1331 fp->bpf_func = (void *) jit.prg_buf;
1332 fp->jited = 1; 1332 fp->jited = 1;
1333 } 1333 }
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 18a62e208826..32322ce9b405 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -1165,7 +1165,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
1165 1165
1166 if (image) { 1166 if (image) {
1167 bpf_flush_icache(header, image + proglen); 1167 bpf_flush_icache(header, image + proglen);
1168 set_memory_ro((unsigned long)header, header->pages); 1168 bpf_jit_binary_lock_ro(header);
1169 prog->bpf_func = (void *)image; 1169 prog->bpf_func = (void *)image;
1170 prog->jited = 1; 1170 prog->jited = 1;
1171 } else { 1171 } else {
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 0c1cc9143cb2..0c167fdee5f7 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -551,7 +551,7 @@ static inline bool bpf_prog_was_classic(const struct bpf_prog *prog)
551 551
552#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0])) 552#define bpf_classic_proglen(fprog) (fprog->len * sizeof(fprog->filter[0]))
553 553
554#ifdef CONFIG_DEBUG_SET_MODULE_RONX 554#ifdef CONFIG_ARCH_HAS_SET_MEMORY
555static inline void bpf_prog_lock_ro(struct bpf_prog *fp) 555static inline void bpf_prog_lock_ro(struct bpf_prog *fp)
556{ 556{
557 set_memory_ro((unsigned long)fp, fp->pages); 557 set_memory_ro((unsigned long)fp, fp->pages);
@@ -562,6 +562,11 @@ static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
562 set_memory_rw((unsigned long)fp, fp->pages); 562 set_memory_rw((unsigned long)fp, fp->pages);
563} 563}
564 564
565static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
566{
567 set_memory_ro((unsigned long)hdr, hdr->pages);
568}
569
565static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 570static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr)
566{ 571{
567 set_memory_rw((unsigned long)hdr, hdr->pages); 572 set_memory_rw((unsigned long)hdr, hdr->pages);
@@ -575,10 +580,14 @@ static inline void bpf_prog_unlock_ro(struct bpf_prog *fp)
575{ 580{
576} 581}
577 582
583static inline void bpf_jit_binary_lock_ro(struct bpf_binary_header *hdr)
584{
585}
586
578static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr) 587static inline void bpf_jit_binary_unlock_ro(struct bpf_binary_header *hdr)
579{ 588{
580} 589}
581#endif /* CONFIG_DEBUG_SET_MODULE_RONX */ 590#endif /* CONFIG_ARCH_HAS_SET_MEMORY */
582 591
583static inline struct bpf_binary_header * 592static inline struct bpf_binary_header *
584bpf_jit_binary_hdr(const struct bpf_prog *fp) 593bpf_jit_binary_hdr(const struct bpf_prog *fp)