From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0075.outbound.protection.outlook.com [104.47.40.75]) by dpdk.org (Postfix) with ESMTP id 6C6C998 for ; Sat, 18 Aug 2018 03:46:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XVgGcC8QfRLSjZ4N0NYy/WaBw0n4pzca+umgqS0U8xg=; b=qJsjH9JXew6ctFnVWotG/0RLV7izD1yX14daGlKkSD0cmCpbF5yQWNx4CDBVXTRmwc6G0IdGaTuhOEpEKJ27FRFqfzt7RNKjslo+V8+JqqaGhQuLk0kmYipc8+RG2EKWlzdDl7qxxZ1w+7J0t1r0tVV1ALx/DMYX8d+epu/++hM= Received: from sc2-edge-ivybridge-12.eng.vmware.com (66.170.99.2) by BN3PR05MB2481.namprd05.prod.outlook.com (2a01:111:e400:7bb4::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.10; Sat, 18 Aug 2018 01:46:08 +0000 From: Jia Yu To: dev@dpdk.org Cc: declan.doherty@intel.com, chas3@att.com Date: Fri, 17 Aug 2018 17:10:09 -0700 Message-Id: <1534551009-16550-1-git-send-email-jyu@vmware.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [66.170.99.2] X-ClientProxiedBy: BL0PR02CA0084.namprd02.prod.outlook.com (2603:10b6:208:51::25) To BN3PR05MB2481.namprd05.prod.outlook.com (2a01:111:e400:7bb4::22) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ee90c740-c48f-463d-2e0e-08d604ac5ecf X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BN3PR05MB2481; X-Microsoft-Exchange-Diagnostics: 1; BN3PR05MB2481; 3:54pkIBvLEue8KmgGoHtVt5aIFCyByDqEJ41PsxKSRg5NpOE3WouKzyrwqL7PCbZCCQW5OCY1amcydsYOzWkyZyeCyD49X/brjMf/TpFMLPeqV4itlbmXpEpNB7mok7ekILVFVEXYMT7ytgpiQ4od2BIo25M65CUT5O0LO0T54Jgce7IvM/MOGajijg8SE3888gXmaBvRtnge68jYkP0I8OMF9FNIu/MxpnNiE7MRu+pkvTEIkbZdD3cyDnAgcHud; 25:flA/UiygdKVYAKbvZ6ygK6dZurgVzRsS/0jaB/aUGgAvWk9ERo8MANPP8wqjDEljRAP8OxOuaLVQTBG6WjGveIPW2oD8XeDtYvhGg12KC8Z9wBb2Y+E24hV4ixlia+bZyhgOyzLqNid6TpsX/+44AYo7WD0eFGcDVWc4uOV/Z4WmH/c2J2gjaujw571OeR8DbzzsxheEhTeWKjPy5FMfDHWw2iaMsWlOxJZ8hycgaa3bpinuo3gr77veoHUxXLDy/TXD2j5F1uUJStyysRikghxFZITvhTyIXjs8Vo4Uwf5aM7io/ekjuxr3N2y+PKwuaT4hfJw8KhkiHfHGp3Qh8g==; 31:bk/79WBenGpTy3N3X7NBHcm42IlQ8RvWD0XzcXFORebt4BL4VKo4+pEaHELTGC65iW7Jls3fZ7dKlmNFiRzaAn5VTy+aty5nUe0jqypVQDl3GxoFIwSos2qq8JOMIImrIlhauNh5Wh7DPQWglB1zbQDDbTXE9l4G8qxxXmpmty8mBaYpiuiDVgV/6E1kqMo4l7SeT8RXsbXRil+DuhztJEHFDf28vuziCayYGy0atd8= X-MS-TrafficTypeDiagnostic: BN3PR05MB2481: Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jyu@vmware.com; BCL: 0 X-Microsoft-Exchange-Diagnostics: 1; BN3PR05MB2481; 20:zTB2vgdXKOpXTj1QPn0xxNlzgLU0X4OcsPPZ7cX2JmAyWbYIcDzJtl9rKGox01i6aiSzZQt0O0mWYbQTP14mau/CdtdlamvHbYFeo15m+RP1zJd+Bp9DQP0TW16wONntKE5KkYcGK4QgF+h+5+4mZRSeKCsU5UYYxRAwm71ltq7s7ltwOt7531JUg8aodUW2ORX7yKNo2ZRY0FqC0rsl/X0EyOKOx5+ea2CnMmY3qUiQr6KHIbzQ15d6QffvVOUrrlE5Q8C4VE8/fzJ2wzmclSLrSNx4pUlh1wsy3YFKWTWhwBH05PcC826mAVhoQWohbpQyKNb2h0irR1rmFHXGTeGoLM8IgAVU6SsCgEZtb43XhUl/xbGhTaNNwpfz+8mv4N1bTPrXcOl90t5im8YHBO17z8groC8a+0dYeIV1gLK43PhcOTNv46XQPOfdUe45t74IEWFuEFmljCHXxa2NNcZkgPSO+LxyzOLFQ37CXcD1evLxaHQvKsmNRG2PFEeuYAzn2apQNME8ANoL4iuKd0dviogf7f0dCN2H1NfNX2hDmFERF+QdqyyBb+Eu154WNLhwzixaYbJzZI2ovG/+uNYX9UbtgfwFv4B9AxKg37c=; 4:D+VEvK0/CJTDBKGvq31QAl8qdfFUgOEyqN6/kIKMz+YrWIhAkioixjXdTulVLjO+ZGUyePtdRjZpiRDhjIpkkd1X7BAuitEFjMA/xe93uQy4YPps5VS6dXvw57I3rq6MxVNy3t6feBRrStWbr717zv9UUb0iGQjO4PMZgUNz3dM4o+Lkmn6I/cj4IgTR7DrIrn1PnmDvNVyeiCoWR5SpnxKO10JbaQKe3lzyFgYLumdgXGUbSEXs7bTIVB08IGZsB/8BEsJ/ybUKNyeqr9nZXDmLoVjH/SsDY1oxf1WLzc1DuxQnmHNcyMe57JkYHyVw X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(61668805478150); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(20180801012)(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(201708071742011)(7699016); SRVR:BN3PR05MB2481; BCL:0; PCL:0; RULEID:; SRVR:BN3PR05MB2481; X-Forefront-PRVS: 076804FE30 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(366004)(39860400002)(376002)(396003)(136003)(189003)(199004)(86362001)(7696005)(52116002)(51416003)(48376002)(486006)(186003)(16526019)(66066001)(2906002)(476003)(47776003)(478600001)(956004)(316002)(2616005)(3846002)(6116002)(1857600001)(53936002)(16586007)(26005)(4326008)(386003)(50466002)(25786009)(97736004)(6916009)(2351001)(68736007)(5660300001)(6486002)(36756003)(2361001)(106356001)(50226002)(81156014)(105586002)(8936002)(8676002)(7736002)(81166006)(305945005); DIR:OUT; SFP:1101; SCL:1; SRVR:BN3PR05MB2481; H:sc2-edge-ivybridge-12.eng.vmware.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: vmware.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN3PR05MB2481; 23:/49xZnrlvUzqFDwOInQoc3c8zHzPCejanoVnT/ulc?= =?us-ascii?Q?7I0SmwyCK0L9eyyxefF0bvXCcmO5LLAy+u6w/oPXLQO3+tdMQq8m77RMw24v?= =?us-ascii?Q?H9li1OsJaZegjbNXX3EBa/GqIyuSVRxWl94utuneKMu/9+0Zu3uvPFQCrNdS?= =?us-ascii?Q?OYcO3WKfwHow5z8P/6uglnAXN/7HKdqWGYB6K6yVuNpMvdUernQoqMme4eTn?= =?us-ascii?Q?0LjUmH4Cu+IBC7ThnGB5WPbYwc67Jfs/VMEy2Jv8LcHHdV3OTut/ufe9YsFM?= =?us-ascii?Q?wuWEXJajNbvo0sRk5eiUG6e0JOZZyOdtMKWXx0obUHXoBs0wQnhZBeavMaB0?= =?us-ascii?Q?66hGfeCLzcfa1qXXfSgrEnIqXx4dfz1ZmpgSajMQgJNbxnAfivyPVATapy4D?= =?us-ascii?Q?alpHu/ETXdHhWL2Zrji4pjiHKfJMXCpdeuzPINZffmPsdwCk7FvW6xXliSDU?= =?us-ascii?Q?n1+HGzJKrK20GfZ4EfmYjPlW1LYVBgS/VuKMQ8BQus9drdx0EhWbPgf/nWif?= =?us-ascii?Q?gI+VhEgojFZ2BdIG569pAc7SZouBhxrI/IGCxx/jpEwM2VmBEnm1W56/uJ/r?= =?us-ascii?Q?+HGOFIinUyJhgn11RJVTRkNLq3S7yPOC+98jJZdUIo5+8Qc3HI2zpa6cJ8vL?= =?us-ascii?Q?ZWd1AQ1vDJX41n2f2FwqkiABwxW2X5PAza1CTSxIgxWURLvTyCT+KurdUKsm?= =?us-ascii?Q?2NSwtOAG9cQ78lrskJbBceP2tsfz52E6o3Rj93zoVmi1ZZa+dAiB9PzhR/t+?= =?us-ascii?Q?hvX6JivR2HsX2DSeabd7H8ICzf1FHZmhx+YePlOFGor8KiRUFD7/xb7b7vjD?= =?us-ascii?Q?ngCBh0l3YwrdRdMukuiOR7hdYN5Auw28j/xo/Zw03vneCC6+R4WrNck3W61D?= =?us-ascii?Q?WPWSHM2HxMoaBa74v8tyUq3OX0nxK4WJW1YzklwnE1j9/RKyHa5qGkBIr9Ic?= =?us-ascii?Q?jBX8prVpIBAegp7LnKct5RPgIpQ6flIs5qlxPmVzt5gYcgNyUHoKNottKike?= =?us-ascii?Q?kIpA6St4qtYgNMYCZbHMHUmMPIOKrHF5mnwiemyHwILSQBFcAZPvKk5os9xT?= =?us-ascii?Q?buHMihvDU4KczbvCip/omVhP1QnwHNvryG62TiXCIYr+iMXYXvViKAvGUUX6?= =?us-ascii?Q?VVQpzcS2atbRmZNl95g7ZElkRJyGHMZ?= X-Microsoft-Antispam-Message-Info: 4/vuSwUbOow3bUxSONwcxDNgTzzVRsTwDChv47m5Iq4NzKtfl1VaCCNegtm9Yc4DLS1TBM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KgWhcHwRThDwL5EdEtAL0wNRlWOUynCXuVZKooaOPt3qUBKjPDXRW6VPeXDps/p97yUOZhqdkvHRKEWKthYrhARV9zR+ApIUQtmlZtfAI17GEALJNmcXejaEv09eaCbi6Bi1RR5pMkLlNUToCGj2n1rwcVS9aVVG4QOkCET SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN3PR05MB2481; 20:aFGhhOIcCgBrNDtMJgDFp2HQQSUpkJTecqG0T4FFlIFGwVk/KsUXInqnc7ZBwbIWM9VGChMiBWzeF2a1/944ovr34QWh0FVBp8cZz+u+LUNAj6euoqLjg/ICjsZWHmz4c34AcANDAxvTTvO/HmmmaJcuFfEddSWpUn3hDD2iHEQ= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2018 01:46:08.7192 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ee90c740-c48f-463d-2e0e-08d604ac5ecf X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR05MB2481 Subject: [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 01:46:13 -0000 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. 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