OSDN Git Service

bpf: arsh is not supported in 32 bit alu thus reject it
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 30 Jan 2018 02:37:42 +0000 (03:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 3 Feb 2018 16:04:24 +0000 (17:04 +0100)
commit7dcda40e52ff0712a2d7d5353c1722cb1f994330
treeacb34785034a37a8802bb36efaae8d3703a01d49
parent28c486744e6de4d882a1d853aa63d99fcba4b7a6
bpf: arsh is not supported in 32 bit alu thus reject it

[ upstream commit 7891a87efc7116590eaba57acc3c422487802c6f ]

The following snippet was throwing an 'unknown opcode cc' warning
in BPF interpreter:

  0: (18) r0 = 0x0
  2: (7b) *(u64 *)(r10 -16) = r0
  3: (cc) (u32) r0 s>>= (u32) r0
  4: (95) exit

Although a number of JITs do support BPF_ALU | BPF_ARSH | BPF_{K,X}
generation, not all of them do and interpreter does neither. We can
leave existing ones and implement it later in bpf-next for the
remaining ones, but reject this properly in verifier for the time
being.

Fixes: 17a5267067f3 ("bpf: verifier (add verifier core)")
Reported-by: syzbot+93c4904c5c70348a6890@syzkaller.appspotmail.com
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/verifier.c