Skip to content

Commit 69d5a4d

Browse files
theihorKernel Patches Daemon
authored andcommitted
bpf: mark bpf_stream_vprink kfunc with KF_IMPLICIT_PROG_AUX_ARG
Update bpf_stream_vprink macro in libbpf and fix call sites in the relevant selftests. Signed-off-by: Ihor Solodrai <[email protected]>
1 parent be45667 commit 69d5a4d

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

kernel/bpf/helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4378,7 +4378,7 @@ BTF_ID_FLAGS(func, bpf_strnstr);
43784378
#if defined(CONFIG_BPF_LSM) && defined(CONFIG_CGROUPS)
43794379
BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU)
43804380
#endif
4381-
BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS)
4381+
BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS | KF_IMPLICIT_PROG_AUX_ARG)
43824382
BTF_ID_FLAGS(func, bpf_task_work_schedule_signal, KF_TRUSTED_ARGS)
43834383
BTF_ID_FLAGS(func, bpf_task_work_schedule_resume, KF_TRUSTED_ARGS)
43844384
BTF_ID_FLAGS(func, bpf_wq_set_callback, KF_IMPLICIT_PROG_AUX_ARG)

kernel/bpf/stream.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,12 @@ __bpf_kfunc_start_defs();
355355
* Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the
356356
* enum in headers.
357357
*/
358-
__bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz, void *aux__prog)
358+
__bpf_kfunc int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, u32 len__sz, struct bpf_prog_aux *aux)
359359
{
360360
struct bpf_bprintf_data data = {
361361
.get_bin_args = true,
362362
.get_buf = true,
363363
};
364-
struct bpf_prog_aux *aux = aux__prog;
365364
u32 fmt_size = strlen(fmt__str) + 1;
366365
struct bpf_stream *stream;
367366
u32 data_len = len__sz;

tools/lib/bpf/bpf_helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ enum libbpf_tristate {
316316
})
317317

318318
extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args,
319-
__u32 len__sz, void *aux__prog) __weak __ksym;
319+
__u32 len__sz) __weak __ksym;
320320

321321
#define bpf_stream_printk(stream_id, fmt, args...) \
322322
({ \
@@ -328,7 +328,7 @@ extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *a
328328
___bpf_fill(___param, args); \
329329
_Pragma("GCC diagnostic pop") \
330330
\
331-
bpf_stream_vprintk(stream_id, ___fmt, ___param, sizeof(___param), NULL);\
331+
bpf_stream_vprintk(stream_id, ___fmt, ___param, sizeof(___param));\
332332
})
333333

334334
/* Use __bpf_printk when bpf_printk call has 3 or fewer fmt args

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@ SEC("syscall")
1010
__failure __msg("Possibly NULL pointer passed")
1111
int stream_vprintk_null_arg(void *ctx)
1212
{
13-
bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0, NULL);
13+
bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0);
1414
return 0;
1515
}
1616

1717
SEC("syscall")
1818
__failure __msg("R3 type=scalar expected=")
1919
int stream_vprintk_scalar_arg(void *ctx)
2020
{
21-
bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0, NULL);
21+
bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0);
2222
return 0;
2323
}
2424

2525
SEC("syscall")
2626
__failure __msg("arg#1 doesn't point to a const string")
2727
int stream_vprintk_string_arg(void *ctx)
2828
{
29-
bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0, NULL);
29+
bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0);
3030
return 0;
3131
}
3232

0 commit comments

Comments
 (0)