lkml.org 
[lkml]   [2015]   [Nov]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] arm64: bpf: fix div-by-zero case
On 11/04/2015 07:41 PM, Shi, Yang wrote:
...
>>> Agreed, and we may need add one more test cases in test_bpf module to cover
>>> MOD?
>>
>> Let me know if you have a test case ready :)
>
> Does the below change look like a valid test?
>
> + "MOD default X",
> + .u.insns = {
> + /*
> + * A = 0x42
> + * A = A mod X ; this halt the filter execution if X is 0
> + * ret 0x42
> + */
> + BPF_STMT(BPF_LD | BPF_IMM, 0x42),
> + BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0),
> + BPF_STMT(BPF_RET | BPF_K, 0x42),
> + },
> + CLASSIC | FLAG_NO_DATA,
> + {},
> + { {0x1, 0x0 } },
> + },
> + {
> + "MOD default A",
> + .u.insns = {
> + /*
> + * A = A mod 1
> + * ret A
> + */
> + BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1),
> + BPF_STMT(BPF_RET | BPF_A, 0x0),
> + },
> + CLASSIC | FLAG_NO_DATA,
> + {},
> + { {0x1, 0x0 } },
> + },
>
> My test result with it:
> test_bpf: #284 MOD default X jited:1 ret 66 != 0 FAIL (1 times)
> test_bpf: #285 MOD default A jited:1 102 PASS
>
> If it looks right, I will post a patch to add the test cases.

Looks good to me.

Thanks,
Daniel


\
 
 \ /
  Last update: 2015-11-04 21:01    [W:0.051 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site