@@ -833,22 +833,21 @@ static int __init bpf_jit_charge_init(void)
833
833
}
834
834
pure_initcall (bpf_jit_charge_init );
835
835
836
- int bpf_jit_charge_modmem (u32 pages )
836
+ int bpf_jit_charge_modmem (u32 size )
837
837
{
838
- if (atomic_long_add_return (pages , & bpf_jit_current ) >
839
- (bpf_jit_limit >> PAGE_SHIFT )) {
838
+ if (atomic_long_add_return (size , & bpf_jit_current ) > bpf_jit_limit ) {
840
839
if (!bpf_capable ()) {
841
- atomic_long_sub (pages , & bpf_jit_current );
840
+ atomic_long_sub (size , & bpf_jit_current );
842
841
return - EPERM ;
843
842
}
844
843
}
845
844
846
845
return 0 ;
847
846
}
848
847
849
- void bpf_jit_uncharge_modmem (u32 pages )
848
+ void bpf_jit_uncharge_modmem (u32 size )
850
849
{
851
- atomic_long_sub (pages , & bpf_jit_current );
850
+ atomic_long_sub (size , & bpf_jit_current );
852
851
}
853
852
854
853
void * __weak bpf_jit_alloc_exec (unsigned long size )
@@ -879,11 +878,11 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
879
878
size = round_up (proglen + sizeof (* hdr ) + 128 , PAGE_SIZE );
880
879
pages = size / PAGE_SIZE ;
881
880
882
- if (bpf_jit_charge_modmem (pages ))
881
+ if (bpf_jit_charge_modmem (size ))
883
882
return NULL ;
884
883
hdr = bpf_jit_alloc_exec (size );
885
884
if (!hdr ) {
886
- bpf_jit_uncharge_modmem (pages );
885
+ bpf_jit_uncharge_modmem (size );
887
886
return NULL ;
888
887
}
889
888
@@ -906,7 +905,7 @@ void bpf_jit_binary_free(struct bpf_binary_header *hdr)
906
905
u32 pages = hdr -> pages ;
907
906
908
907
bpf_jit_free_exec (hdr );
909
- bpf_jit_uncharge_modmem (pages );
908
+ bpf_jit_uncharge_modmem (pages << PAGE_SHIFT );
910
909
}
911
910
912
911
/* This symbol is only overridden by archs that have different
0 commit comments