kernel/bpf/core.c:183:49: sparse: error: arithmetics on pointers to functions

From: kbuild test robot
Date: Mon Mar 11 2019 - 10:45:56 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 12ad143e1b803e541e48b8ba40f550250259ecdd
commit: c454a46b5efd8eff8880e88ece2976e60a26bf35 bpf: Add bpf_line_info support
date: 3 months ago
reproduce:
# apt-get install sparse
git checkout c454a46b5efd8eff8880e88ece2976e60a26bf35
make ARCH=x86_64 allmodconfig
make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

All errors (new ones prefixed by >>):

include/linux/slab.h:332:43: sparse: warning: dubious: x & !y
include/linux/slab.h:332:43: sparse: warning: dubious: x & !y
>> kernel/bpf/core.c:183:49: sparse: error: arithmetics on pointers to functions
kernel/bpf/core.c:733:6: sparse: warning: symbol 'bpf_jit_alloc_exec' was not declared. Should it be static?
kernel/bpf/core.c:738:13: sparse: warning: symbol 'bpf_jit_free_exec' was not declared. Should it be static?
include/linux/slab.h:332:43: sparse: warning: dubious: x & !y
kernel/bpf/core.c:1778:9: sparse: warning: incorrect type in argument 1 (different address spaces)
kernel/bpf/core.c:1778:9: sparse: expected struct callback_head *head
kernel/bpf/core.c:1778:9: sparse: got struct callback_head [noderef] <asn:4> *
include/linux/slab.h:332:43: sparse: warning: dubious: x & !y
kernel/bpf/core.c:1852:44: sparse: warning: incorrect type in initializer (different address spaces)
kernel/bpf/core.c:1852:44: sparse: expected struct bpf_prog_array_item *item
kernel/bpf/core.c:1852:44: sparse: got struct bpf_prog_array_item [noderef] <asn:4> *
kernel/bpf/core.c:1876:26: sparse: warning: incorrect type in assignment (different address spaces)
kernel/bpf/core.c:1876:26: sparse: expected struct bpf_prog_array_item *existing
kernel/bpf/core.c:1876:26: sparse: got struct bpf_prog_array_item [noderef] <asn:4> *
kernel/bpf/core.c:1910:26: sparse: warning: incorrect type in assignment (different address spaces)
kernel/bpf/core.c:1910:26: sparse: expected struct bpf_prog_array_item *[assigned] existing
kernel/bpf/core.c:1910:26: sparse: got struct bpf_prog_array_item [noderef] <asn:4> *
include/trace/events/xdp.h:28:1: sparse: warning: Using plain integer as NULL pointer
include/trace/events/xdp.h:53:1: sparse: warning: Using plain integer as NULL pointer
include/trace/events/xdp.h:111:1: sparse: warning: Using plain integer as NULL pointer
include/trace/events/xdp.h:126:1: sparse: warning: Using plain integer as NULL pointer
include/trace/events/xdp.h:161:1: sparse: warning: Using plain integer as NULL pointer
include/trace/events/xdp.h:196:1: sparse: warning: Using plain integer as NULL pointer
include/trace/events/xdp.h:231:1: sparse: warning: Using plain integer as NULL pointer
kernel/bpf/core.c:1156:18: sparse: warning: Initializer entry defined twice
kernel/bpf/core.c:1158:17: sparse: also defined here

vim +183 kernel/bpf/core.c

133
134 /* The jit engine is responsible to provide an array
135 * for insn_off to the jited_off mapping (insn_to_jit_off).
136 *
137 * The idx to this array is the insn_off. Hence, the insn_off
138 * here is relative to the prog itself instead of the main prog.
139 * This array has one entry for each xlated bpf insn.
140 *
141 * jited_off is the byte off to the last byte of the jited insn.
142 *
143 * Hence, with
144 * insn_start:
145 * The first bpf insn off of the prog. The insn off
146 * here is relative to the main prog.
147 * e.g. if prog is a subprog, insn_start > 0
148 * linfo_idx:
149 * The prog's idx to prog->aux->linfo and jited_linfo
150 *
151 * jited_linfo[linfo_idx] = prog->bpf_func
152 *
153 * For i > linfo_idx,
154 *
155 * jited_linfo[i] = prog->bpf_func +
156 * insn_to_jit_off[linfo[i].insn_off - insn_start - 1]
157 */
158 void bpf_prog_fill_jited_linfo(struct bpf_prog *prog,
159 const u32 *insn_to_jit_off)
160 {
161 u32 linfo_idx, insn_start, insn_end, nr_linfo, i;
162 const struct bpf_line_info *linfo;
163 void **jited_linfo;
164
165 if (!prog->aux->jited_linfo)
166 /* Userspace did not provide linfo */
167 return;
168
169 linfo_idx = prog->aux->linfo_idx;
170 linfo = &prog->aux->linfo[linfo_idx];
171 insn_start = linfo[0].insn_off;
172 insn_end = insn_start + prog->len;
173
174 jited_linfo = &prog->aux->jited_linfo[linfo_idx];
175 jited_linfo[0] = prog->bpf_func;
176
177 nr_linfo = prog->aux->nr_linfo - linfo_idx;
178
179 for (i = 1; i < nr_linfo && linfo[i].insn_off < insn_end; i++)
180 /* The verifier ensures that linfo[i].insn_off is
181 * strictly increasing
182 */
> 183 jited_linfo[i] = prog->bpf_func +
184 insn_to_jit_off[linfo[i].insn_off - insn_start - 1];
185 }
186

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

Attachment: .config.gz
Description: application/gzip