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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 3, 2015 at 10:56 PM, Zi Shen Lim <zlim.lnx@xxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]