From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by dpdk.org (Postfix) with ESMTP id 2E9721B16B for ; Mon, 21 May 2018 13:44:44 +0200 (CEST) Received: by mail-wm0-f66.google.com with SMTP id o78-v6so26177656wmg.0 for ; Mon, 21 May 2018 04:44:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ik7COszU0faCgQUDf3Hff7eTtzDwDqhMHKqsDGyj4RM=; b=uc8clTsYx2X5+kmatJsjqbQN4TwHZ5gJXcXG7dDEwHkuJmtlambYz4u13Y6/sAAQR1 JSIOt3RtnSexifQCni42xj0sgIamhQ+Xf+e3BXbVJ9PAsiewks7wcyAN9m59+tXZ80YH eLSGwlQFBTsC0OKYrCQZcx10sjgAsiLYMuGVRp04SC/t2GFoWflkvge3aPIm2DI2DqbV fXTbdFnOo2h73ZyhgEZRvopD0mfcLyn7m49HwdfVRqPctZfwNfzc7c9FhDxpsl1xT/F2 VcsryQgqTxIIxZMCd/DVP/eQZMufcT/JhOjtYB1ufBAaGvclepXyMa69MZliWnbFIF3L Lbfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ik7COszU0faCgQUDf3Hff7eTtzDwDqhMHKqsDGyj4RM=; b=It2QIhigR3O1MLVT6Jtv7o6TFC2Xxf7h9zkTy6OTa6RreO0iVS2dUq6VuYn4R2+ed5 3jp0NQdnO8MkTmez0UEKQ4ejljlkLRRY/Kdjll3MM/40MlhseTHEJgwJyqH2PNBdNQMi nopb/ZUxCLmaVeH2thK4QhaDAmFUQ6PX7QOzEbmDNdTrZclvJehZBR5ECYmm643Q7i0j ubU5IlFdbgt1Uxa1CjQxqTw9+6kwILMpEFeIwQQ94CsASo7MVL0vC5o6AxbfVJHBLNzK NUuq4rO2l22II3Pe9Nfwa+3Hkkr1BNnxL2OT8NKJjonhCGDNMy18ZP4l7aaSVTGakjxF VGPA== X-Gm-Message-State: ALKqPwfZEt20vUyG1jBgipWIGeD/613gIeSfmzA/NJ0y2NhE0cjp/UjU xa19BWrAbx99HinbAAt4GX383Q== X-Google-Smtp-Source: AB8JxZp3V85vwYhlcqFNz5rjeYqJi6HB/qcpXP+UXq4n0rhk443BbltLJXuXJoHHS7T9BydSfjRrHQ== X-Received: by 2002:a1c:5ec9:: with SMTP id s192-v6mr9903896wmb.54.1526903083807; Mon, 21 May 2018 04:44:43 -0700 (PDT) Received: from 6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id m15-v6sm14159052wri.8.2018.05.21.04.44.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 May 2018 04:44:43 -0700 (PDT) Date: Mon, 21 May 2018 13:44:28 +0200 From: Adrien Mazarguil To: Ferruh Yigit Cc: dev@dpdk.org, stable@dpdk.org, Qi Zhang Message-ID: <20180521114345.690-2-adrien.mazarguil@6wind.com> References: <20180516154052.16836-1-adrien.mazarguil@6wind.com> <20180521114345.690-1-adrien.mazarguil@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180521114345.690-1-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-stable] [PATCH v2 2/2] ethdev: fix shallow copy of flow API RAW item 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: , X-List-Received-Date: Mon, 21 May 2018 11:44:44 -0000 Like original commit mentioned below, this fix synchronizes flow rule copy function with testpmd's own implementation following "app/testpmd: fix copy of raw flow item (revisited)". It addresses a crash that occurs when feeding a RAW pattern item to rte_flow_copy(). Besides external applications, two PMDs (bonding and failsafe) rely on this function internally. Note the scope of this patch is limited to the RAW pattern item and has no impact on all others. Fixes: 972bf3610611 ("ethdev: fix shallow copy of flow API RSS action") Cc: stable@dpdk.org Cc: Qi Zhang Signed-off-by: Adrien Mazarguil --- v2 changes: - Fixed commit ID on "Fixes" line. - Described the crash addressed by this patch so people do not have to derive this information from the referenced commits. --- lib/librte_ethdev/rte_flow.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 7947529da..b2afba089 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -300,17 +300,26 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, enum item_spec_type type) { size_t size = 0; - const void *item_spec = + const void *data = type == ITEM_SPEC ? item->spec : type == ITEM_LAST ? item->last : type == ITEM_MASK ? item->mask : NULL; - if (!item_spec) + if (!item->spec || !data) goto empty; switch (item->type) { union { const struct rte_flow_item_raw *raw; + } spec; + union { + const struct rte_flow_item_raw *raw; + } last; + union { + const struct rte_flow_item_raw *raw; + } mask; + union { + const struct rte_flow_item_raw *raw; } src; union { struct rte_flow_item_raw *raw; @@ -318,11 +327,21 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, size_t off; case RTE_FLOW_ITEM_TYPE_RAW: - src.raw = item_spec; + spec.raw = item->spec; + last.raw = item->last ? item->last : item->spec; + mask.raw = item->mask ? item->mask : &rte_flow_item_raw_mask; + src.raw = data; dst.raw = buf; off = RTE_ALIGN_CEIL(sizeof(struct rte_flow_item_raw), sizeof(*src.raw->pattern)); - size = off + src.raw->length * sizeof(*src.raw->pattern); + if (type == ITEM_SPEC || + (type == ITEM_MASK && + ((spec.raw->length & mask.raw->length) >= + (last.raw->length & mask.raw->length)))) + size = spec.raw->length & mask.raw->length; + else + size = last.raw->length & mask.raw->length; + size = off + size * sizeof(*src.raw->pattern); if (dst.raw) { memcpy(dst.raw, src.raw, sizeof(*src.raw)); dst.raw->pattern = memcpy((uint8_t *)dst.raw + off, @@ -333,7 +352,7 @@ flow_item_spec_copy(void *buf, const struct rte_flow_item *item, default: size = rte_flow_desc_item[item->type].size; if (buf) - memcpy(buf, item_spec, size); + memcpy(buf, data, size); break; } empty: -- 2.11.0