Skip to content

Commit 0258d3b

Browse files
theihorKernel Patches Daemon
authored andcommitted
bpf: mark bpf_task_work_* kfuncs with KF_IMPLICIT_PROG_AUX_ARG
Two kfuncs that use aux__prog argument were recently added [1]: * bpf_task_work_schedule_resume * bpf_task_work_schedule_signal Update them to use the new kfunc flag and fix usages in the selftests. [1] https://lore.kernel.org/bpf/[email protected]/ Signed-off-by: Ihor Solodrai <[email protected]>
1 parent 69d5a4d commit 0258d3b

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

kernel/bpf/helpers.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,15 +4178,15 @@ static int bpf_task_work_schedule(struct task_struct *task, struct bpf_task_work
41784178
* @tw: Pointer to struct bpf_task_work in BPF map value for internal bookkeeping
41794179
* @map__map: bpf_map that embeds struct bpf_task_work in the values
41804180
* @callback: pointer to BPF subprogram to call
4181-
* @aux__prog: user should pass NULL
4181+
* @aux: pointer to bpf_prog_aux of the caller BPF program, implicitly set by the verifier
41824182
*
41834183
* Return: 0 if task work has been scheduled successfully, negative error code otherwise
41844184
*/
41854185
__bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct bpf_task_work *tw,
41864186
void *map__map, bpf_task_work_callback_t callback,
4187-
void *aux__prog)
4187+
struct bpf_prog_aux *aux)
41884188
{
4189-
return bpf_task_work_schedule(task, tw, map__map, callback, aux__prog, TWA_SIGNAL);
4189+
return bpf_task_work_schedule(task, tw, map__map, callback, aux, TWA_SIGNAL);
41904190
}
41914191

41924192
/**
@@ -4195,15 +4195,15 @@ __bpf_kfunc int bpf_task_work_schedule_signal(struct task_struct *task, struct b
41954195
* @tw: Pointer to struct bpf_task_work in BPF map value for internal bookkeeping
41964196
* @map__map: bpf_map that embeds struct bpf_task_work in the values
41974197
* @callback: pointer to BPF subprogram to call
4198-
* @aux__prog: user should pass NULL
4198+
* @aux: pointer to bpf_prog_aux of the caller BPF program, implicitly set by the verifier
41994199
*
42004200
* Return: 0 if task work has been scheduled successfully, negative error code otherwise
42014201
*/
42024202
__bpf_kfunc int bpf_task_work_schedule_resume(struct task_struct *task, struct bpf_task_work *tw,
42034203
void *map__map, bpf_task_work_callback_t callback,
4204-
void *aux__prog)
4204+
struct bpf_prog_aux *aux)
42054205
{
4206-
return bpf_task_work_schedule(task, tw, map__map, callback, aux__prog, TWA_RESUME);
4206+
return bpf_task_work_schedule(task, tw, map__map, callback, aux, TWA_RESUME);
42074207
}
42084208

42094209
__bpf_kfunc_end_defs();
@@ -4379,8 +4379,8 @@ BTF_ID_FLAGS(func, bpf_strnstr);
43794379
BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
43804380
#endif
43814381
BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS | KF_IMPLICIT_PROG_AUX_ARG)
4382-
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal, KF_TRUSTED_ARGS)
4383-
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_TRUSTED_ARGS)
4382+
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal, KF_TRUSTED_ARGS | KF_IMPLICIT_PROG_AUX_ARG)
4383+
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_TRUSTED_ARGS | KF_IMPLICIT_PROG_AUX_ARG)
43844384
BTF_ID_FLAGS(func, bpf_wq_set_callback, KF_IMPLICIT_PROG_AUX_ARG)
43854385
BTF_KFUNCS_END(common_btf_ids)
43864386

tools/testing/selftests/bpf/progs/task_work.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int oncpu_hash_map(struct pt_regs *args)
6666
if (!work)
6767
return 0;
6868

69-
bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work, NULL);
69+
bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work);
7070
return 0;
7171
}
7272

@@ -80,7 +80,7 @@ int oncpu_array_map(struct pt_regs *args)
8080
work = bpf_map_lookup_elem(&arrmap, &key);
8181
if (!work)
8282
return 0;
83-
bpf_task_work_schedule_signal(task, &work->tw, &arrmap, process_work, NULL);
83+
bpf_task_work_schedule_signal(task, &work->tw, &arrmap, process_work);
8484
return 0;
8585
}
8686

@@ -102,6 +102,6 @@ int oncpu_lru_map(struct pt_regs *args)
102102
work = bpf_map_lookup_elem(&lrumap, &key);
103103
if (!work || work->data[0])
104104
return 0;
105-
bpf_task_work_schedule_resume(task, &work->tw, &lrumap, process_work, NULL);
105+
bpf_task_work_schedule_resume(task, &work->tw, &lrumap, process_work);
106106
return 0;
107107
}

tools/testing/selftests/bpf/progs/task_work_fail.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ int mismatch_map(struct pt_regs *args)
5353
work = bpf_map_lookup_elem(&arrmap, &key);
5454
if (!work)
5555
return 0;
56-
bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work, NULL);
56+
bpf_task_work_schedule_resume(task, &work->tw, &hmap, process_work);
5757
return 0;
5858
}
5959

@@ -65,7 +65,7 @@ int no_map_task_work(struct pt_regs *args)
6565
struct bpf_task_work tw;
6666

6767
task = bpf_get_current_task_btf();
68-
bpf_task_work_schedule_resume(task, &tw, &hmap, process_work, NULL);
68+
bpf_task_work_schedule_resume(task, &tw, &hmap, process_work);
6969
return 0;
7070
}
7171

@@ -76,7 +76,7 @@ int task_work_null(struct pt_regs *args)
7676
struct task_struct *task;
7777

7878
task = bpf_get_current_task_btf();
79-
bpf_task_work_schedule_resume(task, NULL, &hmap, process_work, NULL);
79+
bpf_task_work_schedule_resume(task, NULL, &hmap, process_work);
8080
return 0;
8181
}
8282

@@ -91,6 +91,6 @@ int map_null(struct pt_regs *args)
9191
work = bpf_map_lookup_elem(&arrmap, &key);
9292
if (!work)
9393
return 0;
94-
bpf_task_work_schedule_resume(task, &work->tw, NULL, process_work, NULL);
94+
bpf_task_work_schedule_resume(task, &work->tw, NULL, process_work);
9595
return 0;
9696
}

tools/testing/selftests/bpf/progs/task_work_stress.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ int schedule_task_work(void *ctx)
5252
return 0;
5353
}
5454
err = bpf_task_work_schedule_signal(bpf_get_current_task_btf(), &work->tw, &hmap,
55-
process_work, NULL);
55+
process_work);
5656
if (err)
5757
__sync_fetch_and_add(&schedule_error, 1);
5858
else

0 commit comments

Comments
 (0)