Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756238AbbKDTj3 (ORCPT ); Wed, 4 Nov 2015 14:39:29 -0500 Received: from www62.your-server.de ([213.133.104.62]:42532 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755937AbbKDTj1 (ORCPT ); Wed, 4 Nov 2015 14:39:27 -0500 Message-ID: <563A5EEA.6020007@iogearbox.net> Date: Wed, 04 Nov 2015 20:39:22 +0100 From: Daniel Borkmann User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: "Shi, Yang" , Z Lim CC: Xi Wang , Catalin Marinas , stable@vger.kernel.org, LKML , "linux-arm-kernel@lists.infradead.org" , Alexei Starovoitov Subject: Re: [PATCH] arm64: bpf: fix div-by-zero case References: <1446620204-4228-1-git-send-email-zlim.lnx@gmail.com> <563A4C9A.7000002@linaro.org> <563A5171.5070608@linaro.org> In-Reply-To: <563A5171.5070608@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1800 Lines: 54 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 -- 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/