Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpf: add _impl suffix for bpf_stream_vprintk() kfunc

Rename bpf_stream_vprintk() to bpf_stream_vprintk_impl().

This makes bpf_stream_vprintk() follow the already established "_impl"
suffix-based naming convention for kfuncs with the bpf_prog_aux
argument provided by the verifier implicitly. This convention will be
taken advantage of with the upcoming KF_IMPLICIT_ARGS feature to
preserve backwards compatibility to BPF programs.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com>
Link: https://lore.kernel.org/r/20251104-implv2-v3-2-4772b9ae0e06@meta.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Ihor Solodrai <ihor.solodrai@linux.dev>

authored by

Mykyta Yatsenko and committed by
Alexei Starovoitov
137cc92f ea0714d6

+20 -19
+1 -1
kernel/bpf/helpers.c
··· 4380 4380 #if defined(CONFIG_BPF_LSM) && defined(CONFIG_CGROUPS) 4381 4381 BTF_ID_FLAGS(func, bpf_cgroup_read_xattr, KF_RCU) 4382 4382 #endif 4383 - BTF_ID_FLAGS(func, bpf_stream_vprintk, KF_TRUSTED_ARGS) 4383 + BTF_ID_FLAGS(func, bpf_stream_vprintk_impl, KF_TRUSTED_ARGS) 4384 4384 BTF_ID_FLAGS(func, bpf_task_work_schedule_signal_impl, KF_TRUSTED_ARGS) 4385 4385 BTF_ID_FLAGS(func, bpf_task_work_schedule_resume_impl, KF_TRUSTED_ARGS) 4386 4386 BTF_KFUNCS_END(common_btf_ids)
+2 -1
kernel/bpf/stream.c
··· 355 355 * Avoid using enum bpf_stream_id so that kfunc users don't have to pull in the 356 356 * enum in headers. 357 357 */ 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_impl(int stream_id, const char *fmt__str, const void *args, 359 + u32 len__sz, void *aux__prog) 359 360 { 360 361 struct bpf_bprintf_data data = { 361 362 .get_bin_args = true,
+1 -1
tools/bpf/bpftool/Documentation/bpftool-prog.rst
··· 182 182 183 183 bpftool prog tracelog { stdout | stderr } *PROG* 184 184 Dump the BPF stream of the program. BPF programs can write to these streams 185 - at runtime with the **bpf_stream_vprintk**\ () kfunc. The kernel may write 185 + at runtime with the **bpf_stream_vprintk_impl**\ () kfunc. The kernel may write 186 186 error messages to the standard error stream. This facility should be used 187 187 only for debugging purposes. 188 188
+13 -13
tools/lib/bpf/bpf_helpers.h
··· 315 315 ___param, sizeof(___param)); \ 316 316 }) 317 317 318 - extern int bpf_stream_vprintk(int stream_id, const char *fmt__str, const void *args, 319 - __u32 len__sz, void *aux__prog) __weak __ksym; 318 + extern int bpf_stream_vprintk_impl(int stream_id, const char *fmt__str, const void *args, 319 + __u32 len__sz, void *aux__prog) __weak __ksym; 320 320 321 - #define bpf_stream_printk(stream_id, fmt, args...) \ 322 - ({ \ 323 - static const char ___fmt[] = fmt; \ 324 - unsigned long long ___param[___bpf_narg(args)]; \ 325 - \ 326 - _Pragma("GCC diagnostic push") \ 327 - _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ 328 - ___bpf_fill(___param, args); \ 329 - _Pragma("GCC diagnostic pop") \ 330 - \ 331 - bpf_stream_vprintk(stream_id, ___fmt, ___param, sizeof(___param), NULL);\ 321 + #define bpf_stream_printk(stream_id, fmt, args...) \ 322 + ({ \ 323 + static const char ___fmt[] = fmt; \ 324 + unsigned long long ___param[___bpf_narg(args)]; \ 325 + \ 326 + _Pragma("GCC diagnostic push") \ 327 + _Pragma("GCC diagnostic ignored \"-Wint-conversion\"") \ 328 + ___bpf_fill(___param, args); \ 329 + _Pragma("GCC diagnostic pop") \ 330 + \ 331 + bpf_stream_vprintk_impl(stream_id, ___fmt, ___param, sizeof(___param), NULL); \ 332 332 }) 333 333 334 334 /* Use __bpf_printk when bpf_printk call has 3 or fewer fmt args
+3 -3
tools/testing/selftests/bpf/progs/stream_fail.c
··· 10 10 __failure __msg("Possibly NULL pointer passed") 11 11 int stream_vprintk_null_arg(void *ctx) 12 12 { 13 - bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0, NULL); 13 + bpf_stream_vprintk_impl(BPF_STDOUT, "", NULL, 0, NULL); 14 14 return 0; 15 15 } 16 16 ··· 18 18 __failure __msg("R3 type=scalar expected=") 19 19 int stream_vprintk_scalar_arg(void *ctx) 20 20 { 21 - bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0, NULL); 21 + bpf_stream_vprintk_impl(BPF_STDOUT, "", (void *)46, 0, NULL); 22 22 return 0; 23 23 } 24 24 ··· 26 26 __failure __msg("arg#1 doesn't point to a const string") 27 27 int stream_vprintk_string_arg(void *ctx) 28 28 { 29 - bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0, NULL); 29 + bpf_stream_vprintk_impl(BPF_STDOUT, ctx, NULL, 0, NULL); 30 30 return 0; 31 31 } 32 32