@@ -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
@@ -1731,7 +1731,7 @@ static int copy_verifier_state(struct bpf_verifier_state *dst_state,
1731
1731
1732
1732
dst_state->jmp_history = copy_array(dst_state->jmp_history, src->jmp_history,
1733
1733
src->jmp_history_cnt, sizeof(*dst_state->jmp_history),
1734
- GFP_USER );
1734
+ GFP_KERNEL_ACCOUNT );
1735
1735
if (!dst_state->jmp_history)
1736
1736
return -ENOMEM;
1737
1737
dst_state->jmp_history_cnt = src->jmp_history_cnt;
@@ -1760,7 +1760,7 @@ static int copy_verifier_state(struct bpf_verifier_state *dst_state,
1760
1760
for (i = 0; i <= src->curframe; i++) {
1761
1761
dst = dst_state->frame[i];
1762
1762
if (!dst) {
1763
- dst = kzalloc(sizeof(*dst), GFP_KERNEL );
1763
+ dst = kzalloc(sizeof(*dst), GFP_KERNEL_ACCOUNT );
1764
1764
if (!dst)
1765
1765
return -ENOMEM;
1766
1766
dst_state->frame[i] = dst;
@@ -1874,7 +1874,7 @@ static struct bpf_scc_visit *scc_visit_alloc(struct bpf_verifier_env *env,
1874
1874
info = env->scc_info[scc];
1875
1875
num_visits = info ? info->num_visits : 0;
1876
1876
new_sz = sizeof(*info) + sizeof(struct bpf_scc_visit) * (num_visits + 1);
1877
- info = kvrealloc(env->scc_info[scc], new_sz, GFP_KERNEL );
1877
+ info = kvrealloc(env->scc_info[scc], new_sz, GFP_KERNEL_ACCOUNT );
1878
1878
if (!info)
1879
1879
return NULL;
1880
1880
env->scc_info[scc] = info;
@@ -2095,7 +2095,7 @@ static struct bpf_verifier_state *push_stack(struct bpf_verifier_env *env,
2095
2095
struct bpf_verifier_stack_elem *elem;
2096
2096
int err;
2097
2097
2098
- elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL );
2098
+ elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL_ACCOUNT );
2099
2099
if (!elem)
2100
2100
goto err;
2101
2101
@@ -2862,7 +2862,7 @@ static struct bpf_verifier_state *push_async_cb(struct bpf_verifier_env *env,
2862
2862
struct bpf_verifier_stack_elem *elem;
2863
2863
struct bpf_func_state *frame;
2864
2864
2865
- elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL );
2865
+ elem = kzalloc(sizeof(struct bpf_verifier_stack_elem), GFP_KERNEL_ACCOUNT );
2866
2866
if (!elem)
2867
2867
goto err;
2868
2868
@@ -2885,7 +2885,7 @@ static struct bpf_verifier_state *push_async_cb(struct bpf_verifier_env *env,
2885
2885
*/
2886
2886
elem->st.branches = 1;
2887
2887
elem->st.in_sleepable = is_sleepable;
2888
- frame = kzalloc(sizeof(*frame), GFP_KERNEL );
2888
+ frame = kzalloc(sizeof(*frame), GFP_KERNEL_ACCOUNT );
2889
2889
if (!frame)
2890
2890
goto err;
2891
2891
init_func_state(env, frame,
@@ -3237,7 +3237,7 @@ static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)
3237
3237
return -EINVAL;
3238
3238
}
3239
3239
3240
- tab = kzalloc(sizeof(*tab), GFP_KERNEL );
3240
+ tab = kzalloc(sizeof(*tab), GFP_KERNEL_ACCOUNT );
3241
3241
if (!tab)
3242
3242
return -ENOMEM;
3243
3243
prog_aux->kfunc_tab = tab;
@@ -3253,7 +3253,7 @@ static int add_kfunc_call(struct bpf_verifier_env *env, u32 func_id, s16 offset)
3253
3253
return 0;
3254
3254
3255
3255
if (!btf_tab && offset) {
3256
- btf_tab = kzalloc(sizeof(*btf_tab), GFP_KERNEL );
3256
+ btf_tab = kzalloc(sizeof(*btf_tab), GFP_KERNEL_ACCOUNT );
3257
3257
if (!btf_tab)
3258
3258
return -ENOMEM;
3259
3259
prog_aux->kfunc_btf_tab = btf_tab;
@@ -3939,7 +3939,7 @@ static int push_jmp_history(struct bpf_verifier_env *env, struct bpf_verifier_st
3939
3939
3940
3940
cnt++;
3941
3941
alloc_size = kmalloc_size_roundup(size_mul(cnt, sizeof(*p)));
3942
- p = krealloc(cur->jmp_history, alloc_size, GFP_USER );
3942
+ p = krealloc(cur->jmp_history, alloc_size, GFP_KERNEL_ACCOUNT );
3943
3943
if (!p)
3944
3944
return -ENOMEM;
3945
3945
cur->jmp_history = p;
@@ -10356,7 +10356,7 @@ static int setup_func_entry(struct bpf_verifier_env *env, int subprog, int calls
10356
10356
}
10357
10357
10358
10358
caller = state->frame[state->curframe];
10359
- callee = kzalloc(sizeof(*callee), GFP_KERNEL );
10359
+ callee = kzalloc(sizeof(*callee), GFP_KERNEL_ACCOUNT );
10360
10360
if (!callee)
10361
10361
return -ENOMEM;
10362
10362
state->frame[state->curframe + 1] = callee;
@@ -17693,17 +17693,18 @@ static int check_cfg(struct bpf_verifier_env *env)
17693
17693
int *insn_stack, *insn_state, *insn_postorder;
17694
17694
int ex_insn_beg, i, ret = 0;
17695
17695
17696
- insn_state = env->cfg.insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
17696
+ insn_state = env->cfg.insn_state = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
17697
17697
if (!insn_state)
17698
17698
return -ENOMEM;
17699
17699
17700
- insn_stack = env->cfg.insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
17700
+ insn_stack = env->cfg.insn_stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
17701
17701
if (!insn_stack) {
17702
17702
kvfree(insn_state);
17703
17703
return -ENOMEM;
17704
17704
}
17705
17705
17706
- insn_postorder = env->cfg.insn_postorder = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL);
17706
+ insn_postorder = env->cfg.insn_postorder =
17707
+ kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT);
17707
17708
if (!insn_postorder) {
17708
17709
kvfree(insn_state);
17709
17710
kvfree(insn_stack);
@@ -17837,7 +17838,7 @@ static int check_btf_func_early(struct bpf_verifier_env *env,
17837
17838
urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
17838
17839
min_size = min_t(u32, krec_size, urec_size);
17839
17840
17840
- krecord = kvcalloc(nfuncs, krec_size, GFP_KERNEL | __GFP_NOWARN);
17841
+ krecord = kvcalloc(nfuncs, krec_size, GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
17841
17842
if (!krecord)
17842
17843
return -ENOMEM;
17843
17844
@@ -17937,7 +17938,7 @@ static int check_btf_func(struct bpf_verifier_env *env,
17937
17938
urecord = make_bpfptr(attr->func_info, uattr.is_kernel);
17938
17939
17939
17940
krecord = prog->aux->func_info;
17940
- info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL | __GFP_NOWARN);
17941
+ info_aux = kcalloc(nfuncs, sizeof(*info_aux), GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
17941
17942
if (!info_aux)
17942
17943
return -ENOMEM;
17943
17944
@@ -18023,7 +18024,7 @@ static int check_btf_line(struct bpf_verifier_env *env,
18023
18024
* pass in a smaller bpf_line_info object.
18024
18025
*/
18025
18026
linfo = kvcalloc(nr_linfo, sizeof(struct bpf_line_info),
18026
- GFP_KERNEL | __GFP_NOWARN);
18027
+ GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
18027
18028
if (!linfo)
18028
18029
return -ENOMEM;
18029
18030
@@ -19408,7 +19409,7 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
19408
19409
if (loop) {
19409
19410
struct bpf_scc_backedge *backedge;
19410
19411
19411
- backedge = kzalloc(sizeof(*backedge), GFP_KERNEL );
19412
+ backedge = kzalloc(sizeof(*backedge), GFP_KERNEL_ACCOUNT );
19412
19413
if (!backedge)
19413
19414
return -ENOMEM;
19414
19415
err = copy_verifier_state(&backedge->state, cur);
@@ -19472,7 +19473,7 @@ static int is_state_visited(struct bpf_verifier_env *env, int insn_idx)
19472
19473
* When looping the sl->state.branches will be > 0 and this state
19473
19474
* will not be considered for equivalence until branches == 0.
19474
19475
*/
19475
- new_sl = kzalloc(sizeof(struct bpf_verifier_state_list), GFP_KERNEL );
19476
+ new_sl = kzalloc(sizeof(struct bpf_verifier_state_list), GFP_KERNEL_ACCOUNT );
19476
19477
if (!new_sl)
19477
19478
return -ENOMEM;
19478
19479
env->total_states++;
@@ -22976,13 +22977,13 @@ static int do_check_common(struct bpf_verifier_env *env, int subprog)
22976
22977
env->prev_linfo = NULL;
22977
22978
env->pass_cnt++;
22978
22979
22979
- state = kzalloc(sizeof(struct bpf_verifier_state), GFP_KERNEL );
22980
+ state = kzalloc(sizeof(struct bpf_verifier_state), GFP_KERNEL_ACCOUNT );
22980
22981
if (!state)
22981
22982
return -ENOMEM;
22982
22983
state->curframe = 0;
22983
22984
state->speculative = false;
22984
22985
state->branches = 1;
22985
- state->frame[0] = kzalloc(sizeof(struct bpf_func_state), GFP_KERNEL );
22986
+ state->frame[0] = kzalloc(sizeof(struct bpf_func_state), GFP_KERNEL_ACCOUNT );
22986
22987
if (!state->frame[0]) {
22987
22988
kfree(state);
22988
22989
return -ENOMEM;
@@ -23208,7 +23209,7 @@ static void print_verification_stats(struct bpf_verifier_env *env)
23208
23209
int bpf_prog_ctx_arg_info_init(struct bpf_prog *prog,
23209
23210
const struct bpf_ctx_arg_aux *info, u32 cnt)
23210
23211
{
23211
- prog->aux->ctx_arg_info = kmemdup_array(info, cnt, sizeof(*info), GFP_KERNEL );
23212
+ prog->aux->ctx_arg_info = kmemdup_array(info, cnt, sizeof(*info), GFP_KERNEL_ACCOUNT );
23212
23213
prog->aux->ctx_arg_info_size = cnt;
23213
23214
23214
23215
return prog->aux->ctx_arg_info ? 0 : -ENOMEM;
@@ -24152,7 +24153,7 @@ static int compute_live_registers(struct bpf_verifier_env *env)
24152
24153
* - repeat the computation while {in,out} fields changes for
24153
24154
* any instruction.
24154
24155
*/
24155
- state = kvcalloc(insn_cnt, sizeof(*state), GFP_KERNEL );
24156
+ state = kvcalloc(insn_cnt, sizeof(*state), GFP_KERNEL_ACCOUNT );
24156
24157
if (!state) {
24157
24158
err = -ENOMEM;
24158
24159
goto out;
@@ -24244,10 +24245,10 @@ static int compute_scc(struct bpf_verifier_env *env)
24244
24245
* - 'low[t] == n' => smallest preorder number of the vertex reachable from 't' is 'n';
24245
24246
* - 'dfs' DFS traversal stack, used to emulate explicit recursion.
24246
24247
*/
24247
- stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
24248
- pre = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
24249
- low = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL );
24250
- dfs = kvcalloc(insn_cnt, sizeof(*dfs), GFP_KERNEL );
24248
+ stack = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
24249
+ pre = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
24250
+ low = kvcalloc(insn_cnt, sizeof(int), GFP_KERNEL_ACCOUNT );
24251
+ dfs = kvcalloc(insn_cnt, sizeof(*dfs), GFP_KERNEL_ACCOUNT );
24251
24252
if (!stack || !pre || !low || !dfs) {
24252
24253
err = -ENOMEM;
24253
24254
goto exit;
@@ -24381,7 +24382,7 @@ static int compute_scc(struct bpf_verifier_env *env)
24381
24382
dfs_sz--;
24382
24383
}
24383
24384
}
24384
- env->scc_info = kvcalloc(next_scc_id, sizeof(*env->scc_info), GFP_KERNEL );
24385
+ env->scc_info = kvcalloc(next_scc_id, sizeof(*env->scc_info), GFP_KERNEL_ACCOUNT );
24385
24386
if (!env->scc_info) {
24386
24387
err = -ENOMEM;
24387
24388
goto exit;
@@ -24409,7 +24410,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24409
24410
/* 'struct bpf_verifier_env' can be global, but since it's not small,
24410
24411
* allocate/free it every time bpf_check() is called
24411
24412
*/
24412
- env = kvzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL );
24413
+ env = kvzalloc(sizeof(struct bpf_verifier_env), GFP_KERNEL_ACCOUNT );
24413
24414
if (!env)
24414
24415
return -ENOMEM;
24415
24416
@@ -24472,7 +24473,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24472
24473
24473
24474
env->explored_states = kvcalloc(state_htab_size(env),
24474
24475
sizeof(struct list_head),
24475
- GFP_USER );
24476
+ GFP_KERNEL_ACCOUNT );
24476
24477
ret = -ENOMEM;
24477
24478
if (!env->explored_states)
24478
24479
goto skip_full_check;
@@ -24603,7 +24604,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24603
24604
/* if program passed verifier, update used_maps in bpf_prog_info */
24604
24605
env->prog->aux->used_maps = kmalloc_array(env->used_map_cnt,
24605
24606
sizeof(env->used_maps[0]),
24606
- GFP_KERNEL );
24607
+ GFP_KERNEL_ACCOUNT );
24607
24608
24608
24609
if (!env->prog->aux->used_maps) {
24609
24610
ret = -ENOMEM;
@@ -24618,7 +24619,7 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr, bpfptr_t uattr, __u3
24618
24619
/* if program passed verifier, update used_btfs in bpf_prog_aux */
24619
24620
env->prog->aux->used_btfs = kmalloc_array(env->used_btf_cnt,
24620
24621
sizeof(env->used_btfs[0]),
24621
- GFP_KERNEL );
24622
+ GFP_KERNEL_ACCOUNT );
24622
24623
if (!env->prog->aux->used_btfs) {
24623
24624
ret = -ENOMEM;
24624
24625
goto err_release_maps;
0 commit comments