linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* mips:allmodconfig build failure in 3.16-rc1 due to bpf_jit code
@ 2014-06-17  2:24 Guenter Roeck
  2014-06-17  8:20 ` Daniel Borkmann
  0 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2014-06-17  2:24 UTC (permalink / raw)
  To: linux-kernel@vger.kernel.org
  Cc: Linux MIPS Mailing List, Ralf Baechle, Daniel Borkmann,
	Alexei Starovoitov

mips:allmodconfig fails in 3.16-rc1 with lots of undefined symbols.

arch/mips/net/bpf_jit.c: In function 'is_load_to_a':
arch/mips/net/bpf_jit.c:559:7: error: 'BPF_S_LD_W_LEN' undeclared (first use in this function)
arch/mips/net/bpf_jit.c:559:7: note: each undeclared identifier is reported only once for each function it appears in
arch/mips/net/bpf_jit.c:560:7: error: 'BPF_S_LD_W_ABS' undeclared (first use in this function)
arch/mips/net/bpf_jit.c:561:7: error: 'BPF_S_LD_H_ABS' undeclared (first use in this function)
arch/mips/net/bpf_jit.c:562:7: error: 'BPF_S_LD_B_ABS' undeclared (first use in this function)
arch/mips/net/bpf_jit.c:563:7: error: 'BPF_S_ANC_CPU' undeclared (first use in this function)
arch/mips/net/bpf_jit.c:564:7: error: 'BPF_S_ANC_IFINDEX' undeclared (first use in this function)
arch/mips/net/bpf_jit.c:565:7: error: 'BPF_S_ANC_MARK' undeclared (first use in this function)

and so on.

Those symbols are not defined anywhere.

The problem is due to a conflict with commit 348059313 (net: filter: get rid of BPF_S_*
enum), which removed those definitions.

Guenter

^ permalink raw reply	[flat|nested] 11+ messages in thread
* Re: mips:allmodconfig build failure in 3.16-rc1 due to bpf_jit code
@ 2014-06-17 19:38 Alexei Starovoitov
  2014-06-18  8:28 ` Markos Chandras
  0 siblings, 1 reply; 11+ messages in thread
From: Alexei Starovoitov @ 2014-06-17 19:38 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Markos Chandras, Guenter Roeck, linux-kernel@vger.kernel.org,
	Linux MIPS Mailing List, Ralf Baechle, Network Development,
	David S. Miller

On Tue, Jun 17, 2014 at 4:21 AM, Daniel Borkmann <dborkman@redhat.com> wrote:
> On 06/17/2014 01:09 PM, Markos Chandras wrote:
> ...
>>
>> Thanks for these instructions. I will try them myself once I find some
>>
>> time since I don't think bpf_jit for MIPS has ever been tested with all
>> the opcodes.
>
>
> Sounds great! If you find some tests are missing, please feel free to
> submit them as well via netdev.
>
> Best,
>
> Daniel

Daniel,

thank you for taking care of it so quickly :)
from the BPF perspective the fix looks good:
Acked-by: Alexei Starovoitov <ast@plumgrid.com>

Markos,

please do run the testsuite.
Doing quick code review of mips jit, it looks like:

- your version of pkt_type_offset() will work for little endian only.
  (we've recently fixed it in net/core/filter.c)

- vlan tag handling is incorrect, since it's missing shifts.
  classic BPF standard for vlan_tag_present has to return 1 or 0
  and not just emit_and(r_A, r_s0, VLAN_TAG_PRESENT, ctx);

- pr_warn("%s: Unhandled opcode: 0x%02x\n", __FILE__,
  is way too heavy, since when jit is on, unprivileged user can spam log.

- /* sa is 5-bits long */
  BUG_ON(sa >= BIT(5));
is wrong too. Malicious user can cause kernel crash…
Also shift A>>=33 was always allowed by classic BPF checker, so
JITs have to silently do C-equivalent version of such shift.

- /* Determine if immediate is within the 16-bit signed range */
static inline bool is_range16(s32 imm)
{
        if (imm >= SBIT(15) || imm < -SBIT(15))
                return true;
the function name and comment are doing the opposite of
actual code, which makes harder to follow.

- the rest looks pretty good!

Also you'll get a lot more mileage out of mips jit if you use eBPF
instruction set as a base for JITing. You wouldn't need to worry
about vlan, pkt_type and other classic extensions. You'll get all
extensions for free, plus seccomp, tracing, etc.

Thanks
Alexei

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2014-06-18  8:28 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-17  2:24 mips:allmodconfig build failure in 3.16-rc1 due to bpf_jit code Guenter Roeck
2014-06-17  8:20 ` Daniel Borkmann
2014-06-17 10:16   ` Daniel Borkmann
2014-06-17 10:39     ` Guenter Roeck
2014-06-17 10:56       ` Daniel Borkmann
2014-06-17 11:09         ` Markos Chandras
2014-06-17 11:21           ` Daniel Borkmann
2014-06-17 10:54     ` Markos Chandras
2014-06-17 10:58       ` Daniel Borkmann
  -- strict thread matches above, loose matches on Subject: below --
2014-06-17 19:38 Alexei Starovoitov
2014-06-18  8:28 ` Markos Chandras

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).