Re: [PATCH bpf-next 3/6] bpf: switch BPF verifier log to be a rotating log by default

kernel test robot
2023-03-17T05:08:04Z

Hi Andrii,

I love your patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url: https://github.com/intel-lab-lkp/linux/commits/Andrii-Nakryiko/bpf-split-off-basic-BPF-verifier-log-into-separate-file/20230317-023431
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20230316183013.2882810-4-andrii%40kernel.org
patch subject: [PATCH bpf-next 3/6] bpf: switch BPF verifier log to be a rotating log by default
config: i386-randconfig-a002-20230313 (https://download.01.org/0day-ci/archive/20230317/202303171242.biyrTbVN-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/f2876fe2427e5bdfbbb27980025b969c93f46c4b
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andrii-Nakryiko/bpf-split-off-basic-BPF-verifier-log-into-separate-file/20230317-023431
git checkout f2876fe2427e5bdfbbb27980025b969c93f46c4b
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303171242.biyrTbVN-lkp@intel.com/

All errors (new ones prefixed by >>):

ld: kernel/bpf/log.o: in function `bpf_verifier_vlog':
>> kernel/bpf/log.c:59: undefined reference to `__umoddi3'
>> ld: kernel/bpf/log.c:60: undefined reference to `__umoddi3'
ld: kernel/bpf/log.o: in function `bpf_vlog_finalize':
kernel/bpf/log.c:212: undefined reference to `__umoddi3'

vim +59 kernel/bpf/log.c

17
18 void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt,
19 va_list args)
20 {
21 unsigned int n;
22
23 n = vscnprintf(log->kbuf, BPF_VERIFIER_TMP_LOG_SIZE, fmt, args);
24
25 WARN_ONCE(n >= BPF_VERIFIER_TMP_LOG_SIZE - 1,
26 "verifier log line truncated - local buffer too short\n");
27
28 if (log->level == BPF_LOG_KERNEL) {
29 bool newline = n > 0 && log->kbuf[n - 1] == '\n';
30
31 pr_err("BPF: %s%s", log->kbuf, newline ? "" : "\n");
32 return;
33 }
34
35 if (log->level & BPF_LOG_FIXED) {
36 n = min(log->len_total - bpf_log_used(log) - 1, n);
37 log->kbuf[n] = '\0';
38 n += 1;
39
40 if (copy_to_user(log->ubuf + log->end_pos, log->kbuf, n))
41 goto fail;
42
43 log->end_pos += n - 1; /* don't count terminating '\0' */
44 } else {
45 u64 new_end, new_start, cur_pos;
46 u32 buf_start, buf_end, new_n;
47
48 log->kbuf[n] = '\0';
49 n += 1;
50
51 new_end = log->end_pos + n;
52 if (new_end - log->start_pos >= log->len_total)
53 new_start = new_end - log->len_total;
54 else
55 new_start = log->start_pos;
56 new_n = min(n, log->len_total);
57 cur_pos = new_end - new_n;
58
> 59 buf_start = cur_pos % log->len_total;
> 60 buf_end = new_end % log->len_total;
61 /* new_end and buf_end are exclusive indices, so if buf_end is
62 * exactly zero, then it actually points right to the end of
63 * ubuf and there is no wrap around
64 */
65 if (buf_end == 0)
66 buf_end = log->len_total;
67
68 /* if buf_start > buf_end, we wrapped around;
69 * if buf_start == buf_end, then we fill ubuf completely; we
70 * can't have buf_start == buf_end to mean that there is
71 * nothing to write, because we always write at least
72 * something, even if terminal '\0'
73 */
74 if (buf_start < buf_end) {
75 /* message fits within contiguous chunk of ubuf */
76 if (copy_to_user(log->ubuf + buf_start,
77 log->kbuf + n - new_n,
78 buf_end - buf_start))
79 goto fail;
80 } else {
81 /* message wraps around the end of ubuf, copy in two chunks */
82 if (copy_to_user(log->ubuf + buf_start,
83 log->kbuf + n - new_n,
84 log->len_total - buf_start))
85 goto fail;
86 if (copy_to_user(log->ubuf,
87 log->kbuf + n - buf_end,
88 buf_end))
89 goto fail;
90 }
91
92 log->start_pos = new_start;
93 log->end_pos = new_end - 1; /* don't count terminating '\0' */
94 }
95
96 return;
97 fail:
98 log->ubuf = NULL;
99 }
100

--
0-DAY CI Kernel Test Service