@@ -1404,7 +1404,7 @@ static void *realloc_array(void *arr, size_t old_n, size_t new_n, size_t size)
1404
1404
goto out;
1405
1405
1406
1406
alloc_size = kmalloc_size_roundup(size_mul(new_n, size));
1407
- new_arr = krealloc(arr, alloc_size, GFP_KERNEL );
1407
+ new_arr = krealloc(arr, alloc_size, GFP_KERNEL_ACCOUNT );
1408
1408
if (!new_arr) {
1409
1409
kfree(arr);
1410
1410
return NULL;
@@ -1421,7 +1421,7 @@ static void *realloc_array(void *arr, size_t old_n, size_t new_n, size_t size)
1421
1421
static int copy_reference_state(struct bpf_verifier_state *dst, const struct bpf_verifier_state *src)
1422
1422
{
1423
1423
dst->refs = copy_array(dst->refs, src->refs, src->acquired_refs,
1424
- sizeof(struct bpf_reference_state), GFP_KERNEL );
1424
+ sizeof(struct bpf_reference_state), GFP_KERNEL_ACCOUNT );
1425
1425
if (!dst->refs)
1426
1426
return -ENOMEM;
1427
1427
@@ -1440,7 +1440,7 @@ static int copy_stack_state(struct bpf_func_state *dst, const struct bpf_func_st
1440
1440
size_t n = src->allocated_stack / BPF_REG_SIZE;
1441
1441
1442
1442
dst->stack = copy_array(dst->stack, src->stack, n, sizeof(struct bpf_stack_state),
1443
- GFP_KERNEL );
1443
+ GFP_KERNEL_ACCOUNT );
1444
1444
if (!dst->stack)
1445
1445
return -ENOMEM;
1446
1446
@@ -1761,7 +1761,7 @@ static int copy_verifier_state(struct bpf_verifier_state *dst_state,
1761
1761
for (i = 0; i <= src->curframe; i++) {
1762
1762
dst = dst_state->frame[i];
1763
1763
if (!dst) {
1764
- dst = kzalloc(sizeof(*dst), GFP_KERNEL );
1764
+ dst = kzalloc(sizeof(*dst), GFP_KERNEL_ACCOUNT );
1765
1765
if (!dst)
1766
1766
return -ENOMEM;
1767
1767
dst_state->frame[i] = dst;
@@ -2033,7 +2033,7 @@ static struct bpf_verifier_state *push_stack(struct bpf_verifier_env *env,
2033
2033
struct bpf_verifier_stack_elem *elem;
2034
2034
int err;
2035
2035
2036
- elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL );
2036
+ elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL_ACCOUNT );
2037
2037
if (!elem)
2038
2038
goto err;
2039
2039
@@ -2800,7 +2800,7 @@ static struct bpf_verifier_state *push_async_cb(struct bpf_verifier_env *env,
2800
2800
struct bpf_verifier_stack_elem *elem;
2801
2801
struct bpf_func_state *frame;
2802
2802
2803
- elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL );
2803
+ elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL_ACCOUNT );
2804
2804
if (!elem)
2805
2805
goto err;
2806
2806
@@ -2828,7 +2828,7 @@ static struct bpf_verifier_state *push_async_cb(struct bpf_verifier_env *env,
2828
2828
elem->st.in_sleepable = is_sleepable;
2829
2829
elem->st.insn_hist_start = env->cur_state->insn_hist_end;
2830
2830
elem->st.insn_hist_end = elem->st.insn_hist_start;
2831
- frame = kzalloc(sizeof(*frame), GFP_KERNEL );
2831
+ frame = kzalloc(sizeof(*frame), GFP_KERNEL_ACCOUNT );
2832
2832
if (!frame)
2833
2833
goto err;
2834
2834
init_func_state(env, frame,
@@ -3180,7 +3180,7 @@ static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)
3180
3180
return -EINVAL;
3181
3181
}
3182
3182
3183
- tab = kzalloc(sizeof(*tab), GFP_KERNEL );
3183
+ tab = kzalloc(sizeof(*tab), GFP_KERNEL_ACCOUNT );
3184
3184
if (!tab)
3185
3185
return -ENOMEM;
3186
3186
prog_aux->kfunc_tab = tab;
@@ -3196,7 +3196,7 @@ static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)
3196
3196
return 0;
3197
3197
3198
3198
if (!btf_tab && offset) {
3199
- btf_tab = kzalloc(sizeof(*btf_tab), GFP_KERNEL );
3199
+ btf_tab = kzalloc(sizeof(*btf_tab), GFP_KERNEL_ACCOUNT );
3200
3200
if (!btf_tab)
3201
3201
return -ENOMEM;
3202
3202
prog_aux->kfunc_btf_tab = btf_tab;
@@ -10292,7 +10292,7 @@ static int setup_func_entry(struct bpf_verifier_env *env, int subprog, int calls
10292
10292
}
10293
10293
10294
10294
caller = state->frame[state->curframe];
10295
- callee = kzalloc(sizeof(*callee), GFP_KERNEL );
10295
+ callee = kzalloc(sizeof(*callee), GFP_KERNEL_ACCOUNT );
10296
10296
if (!callee)
10297
10297
return -ENOMEM;
10298
10298
state->frame[state->curframe + 1] = callee;
@@ -17629,17 +17629,18 @@ static int check_cfg(struct bpf_verifier_env *env)
17629
17629
int *insn_stack, *insn_state, *insn_postorder;
17630
17630
int ex_insn_beg, i, ret = 0;
17631
17631
17632
- insn_state = env->cfg.insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
17632
+ insn_state = env->cfg.insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
17633
17633
if (!insn_state)
17634
17634
return -ENOMEM;
17635
17635
17636
- insn_stack = env->cfg.insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
17636
+ insn_stack = env->cfg.insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
17637
17637
if (!insn_stack) {
17638
17638
kvfree(insn_state);
17639
17639
return -ENOMEM;
17640
17640
}
17641
17641
17642
- insn_postorder = env->cfg.insn_postorder = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL);
17642
+ insn_postorder = env->cfg.insn_postorder =
17643
+ kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT);
17643
17644
if (!insn_postorder) {
17644
17645
kvfree(insn_state);
17645
17646
kvfree(insn_stack);
@@ -17773,7 +17774,7 @@ static int check_btf_func_early(struct bpf_verifier_env *env,
17773
17774
urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
17774
17775
min_size = min_t(u32, krec_size, urec_size);
17775
17776
17776
- krecord = kvcalloc(nfuncs, krec_size, GFP_KERNEL | __GFP_NOWARN);
17777
+ krecord = kvcalloc(nfuncs, krec_size, GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
17777
17778
if (!krecord)
17778
17779
return -ENOMEM;
17779
17780
@@ -17873,7 +17874,7 @@ static int check_btf_func(struct bpf_verifier_env *env,
17873
17874
urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
17874
17875
17875
17876
krecord = prog->aux->func_info;
17876
- info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
17877
+ info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
17877
17878
if (!info_aux)
17878
17879
return -ENOMEM;
17879
17880
@@ -17959,7 +17960,7 @@ static int check_btf_line(struct bpf_verifier_env *env,
17959
17960
* pass in a smaller bpf_line_info object.
17960
17961
*/
17961
17962
linfo = kvcalloc(nr_linfo, sizeof(struct bpf_line_info),
17962
- GFP_KERNEL | __GFP_NOWARN);
17963
+ GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
17963
17964
if (!linfo)
17964
17965
return -ENOMEM;
17965
17966
@@ -19306,7 +19307,7 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
19306
19307
* When looping the sl->state.branches will be > 0 and this state
19307
19308
* will not be considered for equivalence until branches == 0.
19308
19309
*/
19309
- new_sl = kzalloc(sizeof(struct bpf_verifier_state_list), GFP_KERNEL );
19310
+ new_sl = kzalloc(sizeof(struct bpf_verifier_state_list), GFP_KERNEL_ACCOUNT );
19310
19311
if (!new_sl)
19311
19312
return -ENOMEM;
19312
19313
env->total_states++;
@@ -22795,13 +22796,13 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
22795
22796
env->prev_linfo = NULL;
22796
22797
env->pass_cnt++;
22797
22798
22798
- state = kzalloc(sizeof(struct bpf_verifier_state), GFP_KERNEL );
22799
+ state = kzalloc(sizeof(struct bpf_verifier_state), GFP_KERNEL_ACCOUNT );
22799
22800
if (!state)
22800
22801
return -ENOMEM;
22801
22802
state->curframe = 0;
22802
22803
state->speculative = false;
22803
22804
state->branches = 1;
22804
- state->frame[0] = kzalloc(sizeof(struct bpf_func_state), GFP_KERNEL );
22805
+ state->frame[0] = kzalloc(sizeof(struct bpf_func_state), GFP_KERNEL_ACCOUNT );
22805
22806
if (!state->frame[0]) {
22806
22807
kfree(state);
22807
22808
return -ENOMEM;
@@ -23027,7 +23028,7 @@ static void print_verification_stats(struct bpf_verifier_env *env)
23027
23028
int bpf_prog_ctx_arg_info_init(struct bpf_prog *prog,
23028
23029
const struct bpf_ctx_arg_aux *info, u32 cnt)
23029
23030
{
23030
- prog->aux->ctx_arg_info = kmemdup_array(info, cnt, sizeof(*info), GFP_KERNEL );
23031
+ prog->aux->ctx_arg_info = kmemdup_array(info, cnt, sizeof(*info), GFP_KERNEL_ACCOUNT );
23031
23032
prog->aux->ctx_arg_info_size = cnt;
23032
23033
23033
23034
return prog->aux->ctx_arg_info ? 0 : -ENOMEM;
@@ -23971,7 +23972,7 @@ static int compute_live_registers(struct bpf_verifier_env *env)
23971
23972
* - repeat the computation while {in,out} fields changes for
23972
23973
* any instruction.
23973
23974
*/
23974
- state = kvcalloc(insn_cnt, sizeof(*state), GFP_KERNEL );
23975
+ state = kvcalloc(insn_cnt, sizeof(*state), GFP_KERNEL_ACCOUNT );
23975
23976
if (!state) {
23976
23977
err = -ENOMEM;
23977
23978
goto out;
@@ -24045,7 +24046,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24045
24046
/* 'struct bpf_verifier_env' can be global, but since it's not small,
24046
24047
* allocate/free it every time bpf_check() is called
24047
24048
*/
24048
- env = kvzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL );
24049
+ env = kvzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL_ACCOUNT );
24049
24050
if (!env)
24050
24051
return -ENOMEM;
24051
24052
@@ -24235,7 +24236,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24235
24236
/* if program passed verifier, update used_maps in bpf_prog_info */
24236
24237
env->prog->aux->used_maps = kmalloc_array(env->used_map_cnt,
24237
24238
sizeof(env->used_maps[0]),
24238
- GFP_KERNEL );
24239
+ GFP_KERNEL_ACCOUNT );
24239
24240
24240
24241
if (!env->prog->aux->used_maps) {
24241
24242
ret = -ENOMEM;
@@ -24250,7 +24251,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24250
24251
/* if program passed verifier, update used_btfs in bpf_prog_aux */
24251
24252
env->prog->aux->used_btfs = kmalloc_array(env->used_btf_cnt,
24252
24253
sizeof(env->used_btfs[0]),
24253
- GFP_KERNEL );
24254
+ GFP_KERNEL_ACCOUNT );
24254
24255
if (!env->prog->aux->used_btfs) {
24255
24256
ret = -ENOMEM;
24256
24257
goto err_release_maps;
0 commit comments