From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D515DA034E for ; Wed, 27 May 2020 16:17:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9AEEE1DA17; Wed, 27 May 2020 16:17:24 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 1C31B1DA71; Wed, 27 May 2020 16:17:22 +0200 (CEST) IronPort-SDR: K2MjQ6HdbHYXXaMDDWFurOPCbwT9VbWSze0ql7CYEqvG9egO5OozvQD+xDXZ2CkojR1xxEgQbU HlbSctpTGAmQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 May 2020 07:17:22 -0700 IronPort-SDR: zN7ZubpC55EAhEK9gDSdFBaBdf3qPmVWReMc30jB2rJIidta3eA/pkuAej0LF/jfpWBa+X7j89 W9VnGVnVdW7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,441,1583222400"; d="scan'208";a="291608845" Received: from sivswdev08.ir.intel.com ([10.237.217.47]) by fmsmga004.fm.intel.com with ESMTP; 27 May 2020 07:17:21 -0700 From: Konstantin Ananyev To: dev@dpdk.org Cc: jerinj@marvell.com, stephen@networkplumber.org, mb@smartsharesystems.com, Konstantin Ananyev , stable@dpdk.org Date: Wed, 27 May 2020 15:16:50 +0100 Message-Id: <20200527141653.15576-3-konstantin.ananyev@intel.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20200527141653.15576-1-konstantin.ananyev@intel.com> References: <20200518155245.11380-1-konstantin.ananyev@intel.com> <20200527141653.15576-1-konstantin.ananyev@intel.com> Subject: [dpdk-stable] [PATCH v2 2/5] bpf: fix add/sub min/max estimations X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" eval_add()/eval_sub() not always correctly estimate minimum and maximum possible values of add/sub operations. Fixes: 8021917293d0 ("bpf: add extra validation for input BPF program") Cc: stable@dpdk.org Signed-off-by: Konstantin Ananyev --- lib/librte_bpf/bpf_validate.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/librte_bpf/bpf_validate.c b/lib/librte_bpf/bpf_validate.c index 6bd6f78e9..80d21fabb 100644 --- a/lib/librte_bpf/bpf_validate.c +++ b/lib/librte_bpf/bpf_validate.c @@ -226,7 +226,7 @@ eval_add(struct bpf_reg_val *rd, const struct bpf_reg_val *rs, uint64_t msk) struct bpf_reg_val rv; rv.u.min = (rd->u.min + rs->u.min) & msk; - rv.u.max = (rd->u.min + rs->u.max) & msk; + rv.u.max = (rd->u.max + rs->u.max) & msk; rv.s.min = (rd->s.min + rs->s.min) & msk; rv.s.max = (rd->s.max + rs->s.max) & msk; @@ -254,10 +254,10 @@ eval_sub(struct bpf_reg_val *rd, const struct bpf_reg_val *rs, uint64_t msk) { struct bpf_reg_val rv; - rv.u.min = (rd->u.min - rs->u.min) & msk; - rv.u.max = (rd->u.min - rs->u.max) & msk; - rv.s.min = (rd->s.min - rs->s.min) & msk; - rv.s.max = (rd->s.max - rs->s.max) & msk; + rv.u.min = (rd->u.min - rs->u.max) & msk; + rv.u.max = (rd->u.max - rs->u.min) & msk; + rv.s.min = (rd->s.min - rs->s.max) & msk; + rv.s.max = (rd->s.max - rs->s.min) & msk; /* * if at least one of the operands is not constant, -- 2.17.1