aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.co.jp>2021-08-14 10:57:16 +0900
committerAndrii Nakryiko <andrii@kernel.org>2021-08-15 00:13:33 -0700
commit3478cfcfcddff0f3aad82891be2992e51c4f7936 (patch)
treeff61e1fb09f3bda022c3e7034f8ca32413f14ab8 /kernel/bpf
parentbpf: af_unix: Implement BPF iterator for UNIX domain socket. (diff)
downloadlinux-dev-3478cfcfcddff0f3aad82891be2992e51c4f7936.tar.xz
linux-dev-3478cfcfcddff0f3aad82891be2992e51c4f7936.zip
bpf: Support "%c" in bpf_bprintf_prepare().
/proc/net/unix uses "%c" to print a single-byte character to escape '\0' in the name of the abstract UNIX domain socket. The following selftest uses it, so this patch adds support for "%c". Note that it does not support wide character ("%lc" and "%llc") for simplicity. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.co.jp> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20210814015718.42704-3-kuniyu@amazon.co.jp
Diffstat (limited to 'kernel/bpf')
-rw-r--r--kernel/bpf/helpers.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index 32761be48143..4e8540716187 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -908,6 +908,20 @@ fmt_str:
num_spec++;
continue;
+ } else if (fmt[i] == 'c') {
+ if (!tmp_buf)
+ goto nocopy_fmt;
+
+ if (tmp_buf_end == tmp_buf) {
+ err = -ENOSPC;
+ goto out;
+ }
+
+ *tmp_buf = raw_args[num_spec];
+ tmp_buf++;
+ num_spec++;
+
+ continue;
}
sizeof_cur_arg = sizeof(int);