From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59D42A0C46; Fri, 6 Aug 2021 15:20:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D011C412AE; Fri, 6 Aug 2021 15:19:57 +0200 (CEST) Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) by mails.dpdk.org (Postfix) with ESMTP id E864240040 for ; Thu, 5 Aug 2021 13:35:52 +0200 (CEST) Received: by mail-wm1-f46.google.com with SMTP id l4-20020a05600c1d04b02902506f89ad2dso5350666wms.1 for ; Thu, 05 Aug 2021 04:35:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JngJCMuX44l6VZMfJnq/cQJUm0R3vdJm/BNoamzScN8=; b=B+PPOhHr8akcWKVgWMlEaAxCDOnevPo82eR9phVtVc2Vi54+mmTTb1WFvbdKD9oHdl wqwQ7fzcN3S5kRuscye/4Q4JTlnYE7KrRVdk3mlpq7fZUz4e1HGylm8ciPs1USg3djVh hMrVKUX0VhnYjs4hgDzQ8s6mOrQhLNg3+WewFIV7a2CydFwItGHlzk72DKkkWDGZ4BMa FujaB39zqMrw28RqUuOwkHj4XDkv8eKLIW+SJXVI2Siwm7sBffkt/CM3r8MiXZUdBASr j26J/DZR+BHa7uraICeU3RglWJezpyAf6kJZjrfRd+7vpA5IGL1U5BwuYXuIr7GLJ0qv aLxw== 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=JngJCMuX44l6VZMfJnq/cQJUm0R3vdJm/BNoamzScN8=; b=S7Mq1URAUWobk10FwQlvLVp7S18K9Uv3y8T0unn6uON0Y10RYhZyd+AJvPIoXOxK+D 090oaErC6CTdyjE49cCZm2AfuGH80dNEw1mQaANHQ+brUQqLJWuKlXLlzUod3U6GNHfW q7ryeEIMipeY9sdz8mDaOyOTGB5jSrfJYJJTZ/DrO9vknxshYL/6R8CzDMo1KTw1MvLN JhAc5DHv5/Ho/1NlDd77cVQi72XABdH/wRReKVr3ZrONy2g6xk7YacMeEBCvGGNp9awE 2hpvKnTW+TfvlmB2ZCKMqxOTRhhWnnSxAM5NGK3jeRfG5G3qVQUmfeuCEkSpY3RLYylF d0Fg== X-Gm-Message-State: AOAM530UHHqcz8DC3KRvJvWa12jfpqzJDDTFXp9wOeBwxMEmohX2QjR3 8Ym4r2aYhFgVIK36Ep0/+zU= X-Google-Smtp-Source: ABdhPJwd6garQXqcjjFxdwIyXV8LdyPCSxN7uC1vlJGq/ZPDdN/YdDvWId8qohvP5gkxf8CTtiV6jA== X-Received: by 2002:a1c:1b55:: with SMTP id b82mr14774426wmb.121.1628163352725; Thu, 05 Aug 2021 04:35:52 -0700 (PDT) Received: from tucornea-dev-machine.localdomain ([193.226.172.44]) by smtp.gmail.com with ESMTPSA id w4sm6297952wrm.24.2021.08.05.04.35.52 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Aug 2021 04:35:52 -0700 (PDT) From: Tudor Cornea To: jingjing.wu@intel.com, beilei.xing@intel.com Cc: qi.z.zhang@intel.com, dev@dpdk.org, Tudor Cornea Date: Thu, 5 Aug 2021 14:35:23 +0300 Message-Id: <1628163323-87134-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 X-Mailman-Approved-At: Fri, 06 Aug 2021 15:19:54 +0200 Subject: [dpdk-dev] [PATCH] net/iavf: fix overflow in maximum packet length config X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" The len variable, used in the computation of max_pkt_len could overflow, if used to store the result of the following computation: rxq->rx_buf_len * IAVF_MAX_CHAINED_RX_BUFFERS Since, we could define the mbuf size to have a large value (i.e 13312), and IAVF_MAX_CHAINED_RX_BUFFERS is defined as 5, the computation mentioned above could potentially result in a value which might be bigger than MAX_USHORT. The result will be that Jumbo Frames will not work properly A similar fix was submitted for the ice driver Signed-off-by: Tudor Cornea --- drivers/net/iavf/iavf_ethdev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c index 574cfe0..dc5cbc2 100644 --- a/drivers/net/iavf/iavf_ethdev.c +++ b/drivers/net/iavf/iavf_ethdev.c @@ -574,13 +574,14 @@ iavf_init_rxq(struct rte_eth_dev *dev, struct iavf_rx_queue *rxq) { struct iavf_hw *hw = IAVF_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_dev_data *dev_data = dev->data; - uint16_t buf_size, max_pkt_len, len; + uint16_t buf_size, max_pkt_len; buf_size = rte_pktmbuf_data_room_size(rxq->mp) - RTE_PKTMBUF_HEADROOM; /* Calculate the maximum packet length allowed */ - len = rxq->rx_buf_len * IAVF_MAX_CHAINED_RX_BUFFERS; - max_pkt_len = RTE_MIN(len, dev->data->dev_conf.rxmode.max_rx_pkt_len); + max_pkt_len = RTE_MIN((uint32_t) + rxq->rx_buf_len * IAVF_MAX_CHAINED_RX_BUFFERS, + dev->data->dev_conf.rxmode.max_rx_pkt_len); /* Check if the jumbo frame and maximum packet length are set * correctly. -- 2.7.4