From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-io0-f182.google.com (mail-io0-f182.google.com [209.85.223.182]) by dpdk.org (Postfix) with ESMTP id F3DEC98 for ; Sun, 19 Aug 2018 01:50:07 +0200 (CEST) Received: by mail-io0-f182.google.com with SMTP id w11-v6so9824701iob.2 for ; Sat, 18 Aug 2018 16:50:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oPyYTprkvSkhXOyAOpfTrNnudHo/a0cLvpJmho8PuJs=; b=F0hIbO0TuidGha+zEVkW1wIGst44BUHYSxVipkW7mI1mB+KFCz8DiVYspz0SKi5rI3 Ji18N3QLaPADfWB7fxn/LJjSmw7WsCxO9eK5dMbVjN87aHTP/ssVDGncrzV/fj6YLjbz AqEMRGq6pSvtAKzmwPLiEKR3pNJULV2Ou9O4UiRY8N0pWYpfwFTnBnzFytJc+Uxq1gML PCFv+Nlfw5hcd0fx5SrK5LC895xHAazzSXxNQyvgTH7avZ7zjHeQ7fbHHegss/R0ylZ0 a/x5KuPAwHxETFNvf/L5iVkuFGFSgZUtzpvCZK3nx7MUYBAI9gURdaqSFgR+uA0uTMw7 fETA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oPyYTprkvSkhXOyAOpfTrNnudHo/a0cLvpJmho8PuJs=; b=DlM7U6tSijrMrm6k7asdZvUC9jsf9nwD2hlQz4Z41k9cBP4r3ls4AIzT18CDHiUK+x cxd/rML4OEzLdNfQdYPkwwL/TfVQkk7v93UQkhNNxvHGdxabng5SNW0QJPIcMOHAJaS6 DKhkeBtbTO95DztRVQt7fSjeu5Lbe9f2/8FHi9XXj+FRdk1jygrocpu9vdAppMFnvjau iq8vfatZyM6Ox2tM3AQB1P6Yt4zqZRfOszlg2n+bX4jaUePkRj6y80gBCo9QM0PJ+lJy FaQ4fNNByVenDrQnqwtDYit9M7mc+rfTNt5gicWoZinwxBzwojFYDjZJDEc+hOD7T3lV wEug== X-Gm-Message-State: APzg51Dm7JgkSUG4x0CT4OHjh2botRYqOixNUmT/V+fy4cCsnguLGcjK 0CcTu9CFd6dcXaK7IUoOI4slypD3YRVLpsztJUg= X-Google-Smtp-Source: ANB0VdYGeHAdYh9wpdO1BgIJyZQAH1USB0Sy2kTLwHO2rdmPtwqSSk9yFJ9641W6PGqInclR6grCy2tljERQHA+Xj1k= X-Received: by 2002:a5e:db43:: with SMTP id r3-v6mr5442327iop.215.1534636207323; Sat, 18 Aug 2018 16:50:07 -0700 (PDT) MIME-Version: 1.0 References: <1534551009-16550-1-git-send-email-jyu@vmware.com> In-Reply-To: <1534551009-16550-1-git-send-email-jyu@vmware.com> From: Chas Williams <3chas3@gmail.com> Date: Sat, 18 Aug 2018 19:49:55 -0400 Message-ID: To: jyu@vmware.com Cc: dev@dpdk.org, Declan Doherty , Chas Williams Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH] net/bonding: fix buf corruption in merging un-transmitted packets 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: Sat, 18 Aug 2018 23:50:08 -0000 On Fri, Aug 17, 2018 at 9:46 PM Jia Yu wrote: > When bond slave devices cannot transmit all packets in bufs array, > tx_burst callback shall merge the un-transmitted packets back to > bufs array. Recent merge logic introduced a bug which causes > invalid mbuf addresses being written to bufs array. > Can you expand on this a bit? What was the commit? > When caller frees the un-transmitted packets, due to invalid addresses, > application will crash. > > The fix is avoid shifting mbufs, and directly write un-transmitted > packets back to bufs array. > > Signed-off-by: Jia Yu > --- > drivers/net/bonding/rte_eth_bond_pmd.c | 98 > +++++----------------------------- > 1 file changed, 14 insertions(+), 84 deletions(-) > > diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c > b/drivers/net/bonding/rte_eth_bond_pmd.c > index 58f7377..cce973a 100644 > --- a/drivers/net/bonding/rte_eth_bond_pmd.c > +++ b/drivers/net/bonding/rte_eth_bond_pmd.c > @@ -303,7 +303,7 @@ bond_ethdev_tx_burst_8023ad_fast_queue(void *queue, > struct rte_mbuf **bufs, > uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { > 0 }; > uint16_t total_tx_count = 0, total_tx_fail_count = 0; > > - uint16_t i, j; > + uint16_t i; > > if (unlikely(nb_bufs == 0)) > return 0; > @@ -361,31 +361,9 @@ bond_ethdev_tx_burst_8023ad_fast_queue(void *queue, > struct rte_mbuf **bufs, > slave_tx_fail_count[i] = slave_nb_bufs[i] - > slave_tx_count; > total_tx_fail_count += slave_tx_fail_count[i]; > - > - /* > - * Shift bufs to beginning of array to allow > reordering > - * later > - */ > - for (j = 0; j < slave_tx_fail_count[i]; j++) { > - slave_bufs[i][j] = > - slave_bufs[i][(slave_tx_count - 1) > + j]; > - } > - } > - } > - > - /* > - * If there are tx burst failures we move packets to end of bufs to > - * preserve expected PMD behaviour of all failed transmitted being > - * at the end of the input mbuf array > - */ > - if (unlikely(total_tx_fail_count > 0)) { > - int bufs_idx = nb_bufs - total_tx_fail_count - 1; > - > - for (i = 0; i < slave_count; i++) { > - if (slave_tx_fail_count[i] > 0) { > - for (j = 0; j < slave_tx_fail_count[i]; > j++) > - bufs[bufs_idx++] = > slave_bufs[i][j]; > - } > + memcpy(&bufs[nb_bufs - total_tx_fail_count], > + &slave_bufs[i][slave_tx_count], > + slave_tx_fail_count[i] * sizeof(bufs[0])); > } > } > > @@ -715,8 +693,8 @@ bond_ethdev_tx_burst_round_robin(void *queue, struct > rte_mbuf **bufs, > tx_fail_total += tx_fail_slave; > > memcpy(&bufs[nb_pkts - tx_fail_total], > - > &slave_bufs[i][num_tx_slave], > - tx_fail_slave * > sizeof(bufs[0])); > + &slave_bufs[i][num_tx_slave], > + tx_fail_slave * sizeof(bufs[0])); > } > num_tx_total += num_tx_slave; > } > @@ -1224,7 +1202,7 @@ bond_ethdev_tx_burst_balance(void *queue, struct > rte_mbuf **bufs, > uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { > 0 }; > uint16_t total_tx_count = 0, total_tx_fail_count = 0; > > - uint16_t i, j; > + uint16_t i; > > if (unlikely(nb_bufs == 0)) > return 0; > @@ -1268,31 +1246,9 @@ bond_ethdev_tx_burst_balance(void *queue, struct > rte_mbuf **bufs, > slave_tx_fail_count[i] = slave_nb_bufs[i] - > slave_tx_count; > total_tx_fail_count += slave_tx_fail_count[i]; > - > - /* > - * Shift bufs to beginning of array to allow > reordering > - * later > - */ > - for (j = 0; j < slave_tx_fail_count[i]; j++) { > - slave_bufs[i][j] = > - slave_bufs[i][(slave_tx_count - 1) > + j]; > - } > - } > - } > - > - /* > - * If there are tx burst failures we move packets to end of bufs to > - * preserve expected PMD behaviour of all failed transmitted being > - * at the end of the input mbuf array > - */ > - if (unlikely(total_tx_fail_count > 0)) { > - int bufs_idx = nb_bufs - total_tx_fail_count - 1; > - > - for (i = 0; i < slave_count; i++) { > - if (slave_tx_fail_count[i] > 0) { > - for (j = 0; j < slave_tx_fail_count[i]; > j++) > - bufs[bufs_idx++] = > slave_bufs[i][j]; > - } > + memcpy(&bufs[nb_bufs - total_tx_fail_count], > + &slave_bufs[i][slave_tx_count], > + slave_tx_fail_count[i] * sizeof(bufs[0])); > } > } > > @@ -1322,7 +1278,7 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct > rte_mbuf **bufs, > uint16_t slave_tx_count, slave_tx_fail_count[RTE_MAX_ETHPORTS] = { > 0 }; > uint16_t total_tx_count = 0, total_tx_fail_count = 0; > > - uint16_t i, j; > + uint16_t i; > > if (unlikely(nb_bufs == 0)) > return 0; > @@ -1384,35 +1340,9 @@ bond_ethdev_tx_burst_8023ad(void *queue, struct > rte_mbuf **bufs, > slave_tx_count; > total_tx_fail_count += > slave_tx_fail_count[i]; > > - /* > - * Shift bufs to beginning of array to > allow > - * reordering later > - */ > - for (j = 0; j < slave_tx_fail_count[i]; > j++) > - slave_bufs[i][j] = > - slave_bufs[i] > - [(slave_tx_count - > 1) > - + j]; > - } > - } > - > - /* > - * If there are tx burst failures we move packets to end of > - * bufs to preserve expected PMD behaviour of all failed > - * transmitted being at the end of the input mbuf array > - */ > - if (unlikely(total_tx_fail_count > 0)) { > - int bufs_idx = nb_bufs - total_tx_fail_count - 1; > - > - for (i = 0; i < slave_count; i++) { > - if (slave_tx_fail_count[i] > 0) { > - for (j = 0; > - j < slave_tx_fail_count[i]; > - j++) { > - bufs[bufs_idx++] = > - slave_bufs[i][j]; > - } > - } > + memcpy(&bufs[nb_bufs - > total_tx_fail_count], > + &slave_bufs[i][slave_tx_count], > + slave_tx_fail_count[i] * > sizeof(bufs[0])); > } > } > } > -- > 2.7.4 > >