From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DFE01A0526 for ; Tue, 21 Jul 2020 14:02:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B562E1C012; Tue, 21 Jul 2020 14:02:41 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 543E81BFEF 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-stable] [PATCH] net/mlx5: fix unlimited scan in switch info detection X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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); -- 1.8.3.1