From patchwork Tue Jul 21 12:02:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Baum X-Patchwork-Id: 74570 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id A68F7A0526; Tue, 21 Jul 2020 14:02:40 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C44F1BFEF; Tue, 21 Jul 2020 14:02:40 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 541BA1BFEE for ; Tue, 21 Jul 2020 14:02:39 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from matan@mellanox.com) with SMTP; 21 Jul 2020 15:02:34 +0300 Received: from pegasus07.mtr.labs.mlnx (pegasus07.mtr.labs.mlnx [10.210.16.112]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 06LC2YM5025565; Tue, 21 Jul 2020 15:02:34 +0300 From: Michael Baum To: dev@dpdk.org Cc: matan@mellanox.com, viacheslavo@mellanox.com, stable@dpdk.org Date: Tue, 21 Jul 2020 12:02:32 +0000 Message-Id: <1595332952-7035-1-git-send-email-michaelba@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] net/mlx5: fix unlimited scan in switch info detection 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" In mlx5_sysfs_switch_info function, the driver gets switch information associated with network interface. The driver writes the port name into buffer and translates it. However, when it writes the name, it does not limit writing to the buffer size. Limit writing to the size of the buffer. Fixes: 1256805dd54d ("net/mlx5: move Linux-specific functions") Cc: stable@dpdk.org Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_ethdev_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c index 1735157..3d3dd2e 100644 --- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c +++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c @@ -1067,7 +1067,7 @@ struct ethtool_link_settings { file = fopen(phys_port_name, "rb"); if (file != NULL) { - ret = fscanf(file, "%s", port_name); + ret = fscanf(file, "%" RTE_STR(IF_NAMESIZE) "s", port_name); fclose(file); if (ret == 1) mlx5_translate_port_name(port_name, &data);