From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 29DFEA0679 for ; Fri, 5 Apr 2019 18:31:24 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F1E81B563; Fri, 5 Apr 2019 18:31:21 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id A6E331B562 for ; Fri, 5 Apr 2019 18:31:19 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id y13so3546598pfm.11 for ; Fri, 05 Apr 2019 09:31:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wA2R7QQad9oaW4s92wFbZGL4+bYMW53UU5WsTRbIvT4=; b=Fv0tywHljMEU/9rYmFlgNsTceUK09e8HUl7LjhsqGCBV4DsWW7rYYzjD1fnCviPSVZ Imt+HwpF8QIAzK2VebePoWJwqsOB85pRLTxDyYVqlFHA7v46hHe50Eo/GGgBueuYqpG5 i+0QEfPrSb0WwFdGVbUnn3q6V+VfdBhKDEe0RLiGWZkWNg4dhCnVDF+7rS0atF0+dqeK VYmJbH5UvljkAgau0xL+XhvQWaXttdOIa17YtSfSMV7GoOgboC5GZxCOTUttChvm0/id jceAWzniYCmQ2TjVVWMEPjI5Pjth4TNT7Eh1tQGVvmGefSTAyW1aXaGVLSbfZWumXE1F BWjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wA2R7QQad9oaW4s92wFbZGL4+bYMW53UU5WsTRbIvT4=; b=HSEU42/vLLPY1Bc7EWm3xgOGwiYSOvGFo5n0kq0hLA2LK0I9YPxYIjxFENQyqi8Eps HsuNAT7TYCcKeqTFl8RnsUsFsB41+YbuDf1pIdC12GNqUAtwxuUPafQCVHEQJAkZ5aAq VnePqCqfS5ZqLI3SpHp+DNZBpIbSJ8NGj5mNXmBXr8wyzRG4GlyFZf1k89eg3rC42GiK 0xTUXJX05B/reTAAbOq8S8vg6jm3Do23GmBQivWAnCIUmyHCbElBL8tPxasJCGp4al4Y B8Lh868YVZgHLWCq59XLtTeQHoKMUBOS2Mxrl70vtQZFVvcnC7qrIb/T2iAxVbokinxj 3dfg== X-Gm-Message-State: APjAAAVDizszHwYrv1TuXRc7q2aCnaAKG5PhDehWb4JGzGogTqpgCEC2 xNcoRcyAART2Wism69Ql0rWxhv5dy4M= X-Google-Smtp-Source: APXvYqykGLuR+PTCu1qEsbdzwLE2uGGQ1AIDSn2s6sph57vZB+O4g0yEnGe776UOqvqM6nKoHWI3Mg== X-Received: by 2002:a65:53cb:: with SMTP id z11mr12777705pgr.139.1554481878255; Fri, 05 Apr 2019 09:31:18 -0700 (PDT) Received: from localhost.localdomain ([167.220.102.127]) by smtp.gmail.com with ESMTPSA id h10sm34242764pfj.79.2019.04.05.09.31.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Apr 2019 09:31:16 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Fri, 5 Apr 2019 09:31:15 -0700 Message-Id: <20190405163115.5068-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190405000343.24424-1-stephen@networkplumber.org> References: <20190405000343.24424-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2] virtio: fix buffer leak on vlan insert X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190405163115.qCYFrftenroZxqX2_fz6l26m_HByzvvJMmTzbSTZ10w@z> The function rte_vlan_insert may allocate a new buffer for the vlan header and return a different mbuf than originally passed. In this case, the stored mbuf in txm[] array could point to wrong buffer. Fixes: dd856dfcb9e7 ("virtio: use any layout on Tx") Signed-off-by: Stephen Hemminger --- v2 - catch a couple more places. The virtio code needs some refactoring to not have 3 copies of same loop... drivers/net/virtio/virtio_rxtx.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c index e6f3706d6fe1..8c56f238f965 100644 --- a/drivers/net/virtio/virtio_rxtx.c +++ b/drivers/net/virtio/virtio_rxtx.c @@ -2003,6 +2003,8 @@ virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, rte_pktmbuf_free(txm); continue; } + /* vlan_insert may add a header mbuf */ + tx_pkts[nb_tx] = txm; } /* optimize ring usage */ @@ -2090,6 +2092,8 @@ virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) rte_pktmbuf_free(txm); continue; } + /* vlan_insert may add a header mbuf */ + tx_pkts[nb_tx] = txm; } /* optimize ring usage */ @@ -2193,6 +2197,8 @@ virtio_xmit_pkts_inorder(void *tx_queue, rte_pktmbuf_free(txm); continue; } + /* vlan_insert may add a header mbuf */ + tx_pkts[nb_tx] = txm; } /* optimize ring usage */ -- 2.17.1