[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CABPxzYKz738rET0vYsgJJcuZw_fOff3juFG54e6ThTFu5b2BtQ@mail.gmail.com>
Date: Fri, 26 Oct 2018 18:36:34 +0530
From: Krishna Chaitanya <chaitanya.mgit@...il.com>
To: netdev <netdev@...r.kernel.org>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>
Subject: [BPF] "padded" structures are not supported by BPF
Hi,
With below config BPF doesn't seem to support "padded" structures. Is
this a bug or expected?
Kernel Version: 4.15.0-34, Intel, Ubuntu. Below is the BPF JIT output.
struct info {
u16 seq_num;
u32 packet_num;
};
bpf: Failed to load program: Permission denied
0: (69) r1 = *(u16 *)(r1 +12)
1: (6b) *(u16 *)(r10 -8) = r1
2: (b7) r1 = 1000000
3: (63) *(u32 *)(r10 -4) = r1
4: (b7) r1 = 0
5: (63) *(u32 *)(r10 -12) = r1
6: (18) r1 = 0xffff8f86f2998e00
8: (bf) r2 = r10
9: (07) r2 += -12
10: (85) call bpf_map_lookup_elem#1
11: (bf) r6 = r0
12: (15) if r6 == 0x0 goto pc+13
R0=map_value(id=0,off=0,ks=4,vs=4,imm=0)
R6=map_value(id=0,off=0,ks=4,vs=4,imm=0) R10=fp0
13: (61) r1 = *(u32 *)(r6 +0)
R0=map_value(id=0,off=0,ks=4,vs=4,imm=0)
R6=map_value(id=0,off=0,ks=4,vs=4,imm=0) R10=fp0
14: (63) *(u32 *)(r10 -16) = r1
15: (18) r1 = 0xffff8f86f2999400
17: (bf) r2 = r10
18: (07) r2 += -16
19: (bf) r3 = r10
20: (07) r3 += -8
21: (b7) r4 = 0
22: (85) call bpf_map_update_elem#2
invalid indirect read from stack off -8+2 size 8
Traceback (most recent call last):
b = BPF(text=bpf_source)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 337, in __init__
self._trace_autoload()
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 1038,
in _trace_autoload
fn = self.load_func(func_name, BPF.TRACEPOINT)
File "/usr/lib/python2.7/dist-packages/bcc/__init__.py", line 377,
in load_func
(func_name, errstr))
Exception: Failed to load BPF program tracepoint__<Snip>: Permission denied
If we add "__packed" to above struct is compiled successfully.
--
Thanks,
Regards,
Chaitanya T K.
Powered by blists - more mailing lists