Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1262495

Re: [PATCH] arm64: bpf: fix div-by-zero case

From "Shi, Yang" <yang.shi@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH] arm64: bpf: fix div-by-zero case
Date 2015-11-04 19:30 +0100
Message-ID <qraYO-411-27@gated-at.bofh.it> (permalink)
References <qr0d4-5pG-7@gated-at.bofh.it> <qr0mJ-5J7-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 11/3/2015 11:04 PM, Xi Wang wrote:
> On Tue, Nov 3, 2015 at 10:56 PM, Zi Shen Lim <zlim.lnx@gmail.com> wrote:
>>          case BPF_ALU | BPF_DIV | BPF_X:
>>          case BPF_ALU64 | BPF_DIV | BPF_X:
>> +       {
>> +               const u8 r0 = bpf2a64[BPF_REG_0];
>> +
>> +               /* if (src == 0) return 0 */
>> +               jmp_offset = 3; /* skip ahead to else path */
>> +               check_imm19(jmp_offset);
>> +               emit(A64_CBNZ(is64, src, jmp_offset), ctx);
>> +               emit(A64_MOVZ(1, r0, 0, 0), ctx);
>> +               jmp_offset = epilogue_offset(ctx);
>> +               check_imm26(jmp_offset);
>> +               emit(A64_B(jmp_offset), ctx);
>> +               /* else */
>>                  emit(A64_UDIV(is64, dst, dst, src), ctx);
>>                  break;
>> +       }
>>          case BPF_ALU | BPF_MOD | BPF_X:
>>          case BPF_ALU64 | BPF_MOD | BPF_X:
>
> BPF_MOD might need the same fix.

Agreed, and we may need add one more test cases in test_bpf module to 
cover MOD?

Yang

>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] arm64: bpf: fix div-by-zero case Zi Shen Lim <zlim.lnx@gmail.com> - 2015-11-04 08:00 +0100
  Re: [PATCH] arm64: bpf: fix div-by-zero case Xi Wang <xi.wang@gmail.com> - 2015-11-04 08:10 +0100
    Re: [PATCH] arm64: bpf: fix div-by-zero case "Shi, Yang" <yang.shi@linaro.org> - 2015-11-04 19:30 +0100
      Re: [PATCH] arm64: bpf: fix div-by-zero case "Shi, Yang" <yang.shi@linaro.org> - 2015-11-04 19:50 +0100
        Re: [PATCH] arm64: bpf: fix div-by-zero case Daniel Borkmann <daniel@iogearbox.net> - 2015-11-04 20:40 +0100
      Re: [PATCH] arm64: bpf: fix div-by-zero case Z Lim <zlim.lnx@gmail.com> - 2015-11-04 20:00 +0100
  Re: [PATCH] arm64: bpf: fix div-by-zero case "Shi, Yang" <yang.shi@linaro.org> - 2015-11-04 19:10 +0100

csiph-web