From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 425AE2BCE for ; Mon, 8 Apr 2019 18:04:26 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id y6so7597797plt.1 for ; Mon, 08 Apr 2019 09:04:26 -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; bh=LdJsFo7g5gOt45seOasuWar16gkKvjlP7uWvcuUctdo=; b=B78zKVBtGkCm6w5qcqzCJCmRDJPyddXyZtuIcahqOz1xxMzPnL+ulL5Tf6ePzsK4kT uGsCWZbYlcEOcWjHthEvQeVQu+rd6xLfh4deHhaRTeYqrF+8O5dXSSUsKcIKEABP3gDP CQc3GdYQawNcaUzMHwwr3550LPP4VVzf+SsvZGJ20GnT/N0oTrXP+qFtgNYzOCaqQXKR tVcDiA0yVG8FcBNi4Puol64Ld0wydsJYLjo5iMmyKQ+oOngtu1+wIYfrQ16ioGykD8uD KJ4R/ToH8Qtjhmm2z8LP5uzciyjW7CQrU+IibPTQ4lXCexXTW8RScRpyKaG5Xwhk0Ot4 XCag== 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; bh=LdJsFo7g5gOt45seOasuWar16gkKvjlP7uWvcuUctdo=; b=mqYh+VR1hlJNiY6vFsyYGs2OKY+mxuJ5yLmwLLek6pjiDfuojxy1opHubbaZwER+uE jGL7HK49cs1cGFJm/AFkJ09oDgFJLfsa49PtXhiAn+Ym3uqecY67zbl5nptv4xv8MXLN /D4zQI4MTdNraDyJFpCsFjjjPgeSslMWoAEZWKmvsIlOYnr5Qqxy78Kb8e3f3TBuaInO dR9x+ZyHdQRkR4EoW10+EScKC66m1NZYNKvgXpW0Id+rVnFvk4Zgn2pX1PkIzLeBuRML NVMSoVPmVvB2kGmQ/z/tPv/Ay5WNoIvwjuYx9SE+Sq1X5I9kIsPMkeXLW3GJmqGKul1M 7Wlw== X-Gm-Message-State: APjAAAUbkkl3/tsDAJ1P2XgCpN4dBTU1G+NcNhZTQDWo7BYpAyHiHKpm leE6Qkrt2sUukDPpNiJZ+JlSQDFD6C2jqQ== X-Google-Smtp-Source: APXvYqzsYwh9nbdwhrolGN5GW6PyrN5KhTbTatX2RXzuFvaudRTLriNIiaf4sijBw9uLuy/i57Daug== X-Received: by 2002:a17:902:868e:: with SMTP id g14mr31164816plo.183.1554739464980; Mon, 08 Apr 2019 09:04:24 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z7sm293210pgh.81.2019.04.08.09.04.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 09:04:23 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 8 Apr 2019 09:04:19 -0700 Message-Id: <20190408160419.7409-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/af_packet: fix vlan_insert corruption 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: , X-List-Received-Date: Mon, 08 Apr 2019 16:04:26 -0000 If the af_packet transmit is sending a VLAN packet, and the transmit path to the kernel os full, then it would mismanage the outgoing mbuf. The original mbuf would end up being freed twice, once by AF_PACKET PMD and once by caller. Reported-by: Chas Williams <3chas3@gmail.com> Signed-off-by: Stephen Hemminger --- drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 99e13fe48a30..24a68c26d665 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -200,6 +200,12 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) continue; } + /* point at the next incoming frame */ + if ((ppd->tp_status != TP_STATUS_AVAILABLE) && + (poll(&pfd, 1, -1) < 0)) + break; + + /* insert vlan info if necessary */ if (mbuf->ol_flags & PKT_TX_VLAN_PKT) { if (rte_vlan_insert(&mbuf)) { @@ -208,11 +214,6 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } } - /* point at the next incoming frame */ - if ((ppd->tp_status != TP_STATUS_AVAILABLE) && - (poll(&pfd, 1, -1) < 0)) - break; - /* copy the tx frame data */ pbuf = (uint8_t *) ppd + TPACKET2_HDRLEN - sizeof(struct sockaddr_ll); -- 2.17.1 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 C86C0A0096 for ; Mon, 8 Apr 2019 18:04:28 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 300DC2C54; Mon, 8 Apr 2019 18:04:27 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 425AE2BCE for ; Mon, 8 Apr 2019 18:04:26 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id y6so7597797plt.1 for ; Mon, 08 Apr 2019 09:04:26 -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; bh=LdJsFo7g5gOt45seOasuWar16gkKvjlP7uWvcuUctdo=; b=B78zKVBtGkCm6w5qcqzCJCmRDJPyddXyZtuIcahqOz1xxMzPnL+ulL5Tf6ePzsK4kT uGsCWZbYlcEOcWjHthEvQeVQu+rd6xLfh4deHhaRTeYqrF+8O5dXSSUsKcIKEABP3gDP CQc3GdYQawNcaUzMHwwr3550LPP4VVzf+SsvZGJ20GnT/N0oTrXP+qFtgNYzOCaqQXKR tVcDiA0yVG8FcBNi4Puol64Ld0wydsJYLjo5iMmyKQ+oOngtu1+wIYfrQ16ioGykD8uD KJ4R/ToH8Qtjhmm2z8LP5uzciyjW7CQrU+IibPTQ4lXCexXTW8RScRpyKaG5Xwhk0Ot4 XCag== 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; bh=LdJsFo7g5gOt45seOasuWar16gkKvjlP7uWvcuUctdo=; b=mqYh+VR1hlJNiY6vFsyYGs2OKY+mxuJ5yLmwLLek6pjiDfuojxy1opHubbaZwER+uE jGL7HK49cs1cGFJm/AFkJ09oDgFJLfsa49PtXhiAn+Ym3uqecY67zbl5nptv4xv8MXLN /D4zQI4MTdNraDyJFpCsFjjjPgeSslMWoAEZWKmvsIlOYnr5Qqxy78Kb8e3f3TBuaInO dR9x+ZyHdQRkR4EoW10+EScKC66m1NZYNKvgXpW0Id+rVnFvk4Zgn2pX1PkIzLeBuRML NVMSoVPmVvB2kGmQ/z/tPv/Ay5WNoIvwjuYx9SE+Sq1X5I9kIsPMkeXLW3GJmqGKul1M 7Wlw== X-Gm-Message-State: APjAAAUbkkl3/tsDAJ1P2XgCpN4dBTU1G+NcNhZTQDWo7BYpAyHiHKpm leE6Qkrt2sUukDPpNiJZ+JlSQDFD6C2jqQ== X-Google-Smtp-Source: APXvYqzsYwh9nbdwhrolGN5GW6PyrN5KhTbTatX2RXzuFvaudRTLriNIiaf4sijBw9uLuy/i57Daug== X-Received: by 2002:a17:902:868e:: with SMTP id g14mr31164816plo.183.1554739464980; Mon, 08 Apr 2019 09:04:24 -0700 (PDT) Received: from shemminger-XPS-13-9360.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z7sm293210pgh.81.2019.04.08.09.04.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 09:04:23 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 8 Apr 2019 09:04:19 -0700 Message-Id: <20190408160419.7409-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/af_packet: fix vlan_insert corruption 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: <20190408160419.v7kTHJqH-2bPu_6L4NA4gqo_mRsG6uChWBdEhH7wwyI@z> If the af_packet transmit is sending a VLAN packet, and the transmit path to the kernel os full, then it would mismanage the outgoing mbuf. The original mbuf would end up being freed twice, once by AF_PACKET PMD and once by caller. Reported-by: Chas Williams <3chas3@gmail.com> Signed-off-by: Stephen Hemminger --- drivers/net/af_packet/rte_eth_af_packet.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index 99e13fe48a30..24a68c26d665 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -200,6 +200,12 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) continue; } + /* point at the next incoming frame */ + if ((ppd->tp_status != TP_STATUS_AVAILABLE) && + (poll(&pfd, 1, -1) < 0)) + break; + + /* insert vlan info if necessary */ if (mbuf->ol_flags & PKT_TX_VLAN_PKT) { if (rte_vlan_insert(&mbuf)) { @@ -208,11 +214,6 @@ eth_af_packet_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts) } } - /* point at the next incoming frame */ - if ((ppd->tp_status != TP_STATUS_AVAILABLE) && - (poll(&pfd, 1, -1) < 0)) - break; - /* copy the tx frame data */ pbuf = (uint8_t *) ppd + TPACKET2_HDRLEN - sizeof(struct sockaddr_ll); -- 2.17.1