bpf: Clean-up bpf_verifier_vlog() for BPF_LOG_KERNEL log level
authorHou Tao <houtao1@huawei.com>
Wed, 1 Dec 2021 07:34:57 +0000 (15:34 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 1 Dec 2021 17:46:32 +0000 (09:46 -0800)
commit436d404cc8ff573a417cb3b6a5c76655121aceac
treebe37121c3f88a2247d6c4ce24726bf4de3d96bc4
parente30c8fd310c77313633a47eb5c1f2ce23d353c18
bpf: Clean-up bpf_verifier_vlog() for BPF_LOG_KERNEL log level

An extra newline will output for bpf_log() with BPF_LOG_KERNEL level
as shown below:

[   52.095704] BPF:The function test_3 has 12 arguments. Too many.
[   52.095704]
[   52.096896] Error in parsing func ptr test_3 in struct bpf_dummy_ops

Now all bpf_log() are ended by newline, but not all btf_verifier_log()
are ended by newline, so checking whether or not the log message
has the trailing newline and adding a newline if not.

Also there is no need to calculate the left userspace buffer size
for kernel log output and to truncate the output by '\0' which
has already been done by vscnprintf(), so only do these for
userspace log output.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20211201073458.2731595-2-houtao1@huawei.com
kernel/bpf/verifier.c