netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Alexei Starovoitov <ast@kernel.org>, davem@davemloft.net
Cc: daniel@iogearbox.net, edumazet@google.com,
	netdev@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH bpf] bpf: fix 32-bit divide by zero
Date: Thu, 18 Jan 2018 14:30:54 -0800	[thread overview]
Message-ID: <1516314654.3606.28.camel@gmail.com> (raw)
In-Reply-To: <20180113025952.3451758-1-ast@kernel.org>

On Fri, 2018-01-12 at 18:59 -0800, Alexei Starovoitov wrote:
> due to some JITs doing if (src_reg == 0) check in 64-bit mode
> for div/mod opreations mask upper 32-bits of src register
> before doing the check
> 

Is the plan to fix JIT, and if they can all be fixed,
revert this patch ?

x86 patch would be something like :

diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 87f214fbe66ec163d24b12b6defc7edab612ecc9..91e4ab69573e09f793eb1c1e29d1b5ffad1d5dc7 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -548,8 +548,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
 			if (BPF_SRC(insn->code) == BPF_X) {
 				/* if (src_reg == 0) return 0 */
 
-				/* cmp r11, 0 */
-				EMIT4(0x49, 0x83, 0xFB, 0x00);
+				if (BPF_CLASS(insn->code) == BPF_ALU64) {
+					/* cmp r11, 0 */
+					EMIT4(0x49, 0x83, 0xFB, 0x00);
+				} else {
+					/* cmp r11d, 0 */
+					EMIT4(0x41, 0x83, 0xFB, 0x00);
+				}
 
 				/* jne .+9 (skip over pop, pop, xor and jmp) */
 				EMIT2(X86_JNE, 1 + 1 + 2 + 5);

  parent reply	other threads:[~2018-01-18 22:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-13  2:59 [PATCH bpf] bpf: fix 32-bit divide by zero Alexei Starovoitov
2018-01-13 16:45 ` Alexei Starovoitov
2018-01-14 22:06 ` Daniel Borkmann
2018-01-18 22:30 ` Eric Dumazet [this message]
2018-01-18 22:40   ` Alexei Starovoitov
2018-01-18 23:33     ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1516314654.3606.28.camel@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).