From patchwork Tue Nov 21 23:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 13463745 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="JntkBZwi" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA85EF4 for ; Tue, 21 Nov 2023 15:00:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bnPAsnoG4Ql/L65np+UWFTFfwUa2rhaJ5aM0xOgrssNnJj7M76hxxNLqQcXuuxqG4HjCnb8/8/sN8wjvdjoiC513qXbz3fTzGRH6Bx9dqxZ/lSZ53g4vyoxOGkDurEnmMOh8Wi9xvHIduBp3UXMY5nre1IcjdmBDfiP+3qk86vp5GLX2nEa41E9I6iTz0PdeTGMuvpF/M84gz3lRv0DJnr1Xw8sgjKX15Epm0pyS9NBG46JMkAQqZPlQmy/FmLpk0Vjo7QkXzK6KTl6k0BMt0ybThoxUuxnPiBGWc+czcyg6GoqY+UE/zrpSEnSzAtv8gt3B+RhcrBrUagfzo1LrNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TagciM3ZZql5rWGCqrdL4VuaVw5FrpdZ8CMUBBO2aLs=; b=QQaPoIz3vQppOdd6Mq/eft9+Wi4Plyusrd0lQJBhF1GSyLdjOX15CKngg23B75Sf5U2jPJY8GfwKI/VeWadjAudC92g0ftPLI51BA2qOStZ1lutNaNMxlRZgyFA+oRJ7cXpS3Nu5caw9lp8Wd+u9fd72zhlPjL69TAvFQJGE6tWVj/ptjVD+D+LcmGLqMcgiGI9fWG6aPhrtd9rnmhvz7xLblaVkoVpPkfc2vEf9K93LImx7mN1HRmBhf8cDTzmi5XJMSVyBVIYQgmMT6Yo8esUQeE/6xyZeQB9tCQUChCEwEqOYhWyUWN0nC9jyUJTJr3Wds39ZICLZvrssp+flRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TagciM3ZZql5rWGCqrdL4VuaVw5FrpdZ8CMUBBO2aLs=; b=JntkBZwiPzmQHdjIXleLRjQNQv3k2bDGCAF0Gq9xjabzrC3Jq5wAreQTegi8WXVPJSWoG798JW68Y34y6+/anpdNWgSBKhhlzUUAW29nxi/pw9QN8FeL67ZGnT4wr4kL24mPwZvQUL0417AORwh15sE8ctcTlX6H/l3QA+Z3cEc6cQBzACxcEo8BYaMslnrJqqikVX5oGM/HgVOo7mD1QALKRLpKz3fUgc3oNUW/bkZHUTcc24OuBKNLCfp8oI2VuKhIlbhAY8fnXC4ElN4XSVdUxlIlXyv/0LtcbbeqyElQOhXzUxt+TsN8O0zIhW3eLSGDSZ50iX6uv4LkAzGrsw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by CH3PR12MB7667.namprd12.prod.outlook.com (2603:10b6:610:14f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Tue, 21 Nov 2023 23:00:51 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::44b4:6f7e:da62:fad4]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::44b4:6f7e:da62:fad4%3]) with mapi id 15.20.7002.027; Tue, 21 Nov 2023 23:00:46 +0000 From: Rahul Rameshbabu To: netdev@vger.kernel.org Cc: Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S. Miller" , Saeed Mahameed , Gal Pressman , Dragos Tatulea , David Laight , Rahul Rameshbabu Subject: [PATCH net v1 1/2] net/mlx5e: Correct snprintf truncation handling for fw_version buffer Date: Tue, 21 Nov 2023 15:00:21 -0800 Message-Id: <20231121230022.89102-1-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.40.1 X-ClientProxiedBy: SJ0PR05CA0045.namprd05.prod.outlook.com (2603:10b6:a03:33f::20) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|CH3PR12MB7667:EE_ X-MS-Office365-Filtering-Correlation-Id: a0d8d6c0-2603-4492-c9e4-08dbeae5b28e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ENVhXRLlSaOcShgcIjL0H3j2pIl+ngNF/eE0m4zp5wgZszqcZDt7g/IbPQfTXCe04dQC2w3+ENtUySTDgMGu5ZApfu7rq0kQiI8bksxLgVS/p5Ig8YBO8Y41rd//omYA7CqQGyLKEx9NNXoSi/cqFAzehx9hUGkCNHn6f24m/icAFbTpENzSIU17WHK/Gop8dFVFZlzNejanh1UkIKYEMsZuKIsKKE2Rz2Mi/nNxO/aBTmBa2j5FCnuEUovKs9Tf8h13OQBxQgEnWGo5fV8jr1w9ARUf8UD5nsXuHs8ErdfG8QsmSTP4v0D5jkN8kQG2g5iYiG3DHzTksDaZNqwS0yTVnGM0F2+gMSjqIeWjaI454iSz0xcMo8qTxq6QcJeN5AL5cmsaNhHluvMhZF+eU6B+2pNr1j8/ZgpxhN78VjZKQPIRSAEBOU3FW/b/RpSdKN+TV/Q1iwqdjHmYTHhDtGrPs3DEB2p69wVdZwaTAHp2+O7rcsazPF2254Kcxgzb9sOjJZLTAL2QqpR3Wh3Q6D9RCwBOpmcqi5VLN7S0fk3ATKEV2vk/dugn+bwe/kiw5ivZzRnAWfw0KS4ZGFiZcUiRzSxacef32583CbG61Yo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(366004)(396003)(346002)(376002)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(2906002)(5660300002)(8676002)(8936002)(4326008)(38100700002)(86362001)(41300700001)(36756003)(107886003)(6512007)(2616005)(1076003)(26005)(6666004)(6506007)(83380400001)(478600001)(66476007)(66556008)(54906003)(66946007)(6916009)(316002)(6486002)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CuEjwTJp+qYJIhla9HKKhalSCQPVCFZPkm8UmCSfe8NxkGL1nyXvV/c8gjKI7L/TV9o7uDYBjqiXYRZfPtUmhlv/ybj4h5igPFrhVNaPLEgE7aZEWMOhSTXTmBr5Cu5MSm4AIVkElm0aewnEwhiSytAOpidU89M1OraTRFzHejqbx34cTToiNB8eINZ89DxlBYuvNCtmBeDbIyaN3rVfycVF+9+hWXCB8cyHZl+tidPdDBcbaF4dea3BlE4wK9mSjLkJ9oQtBn5JbkJofOtz7iQwQABr5vKLwVYD7zkJOLvIXXO3Cc893uqQ409Xt6IPfTahal+tlgx5rC3DXBuyebNlu/XhYgfa1vFPnMcGeIGV+xgzJqam/MeP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bATf7wmogxbV50dt1oDBAmeEJL5oqew7OlBwe7PhO3PV+EGaWLY2vDARCHy3Cnqq1W/iEDuuTMQGZRjgv4wIH2RfB+hz4R2NnJKMbzdn3QS2WZ5CxxWIuqbpHsFpslwu3o2VuMUpkLx2xcfqkq5chy2xXTcQ7Hqzfg+tE9ji8cCAAkdQU/1Q== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: a0d8d6c0-2603-4492-c9e4-08dbeae5b28e X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 23:00:46.8499 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PsCcfo8blKDZoaTZbigVp0R+kU98bqzfjuM5MzzSW0udUA7wMM3rXx1OOQxErN4tKdkqePQ17kRhZesDWhUIHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7667 X-Patchwork-Delegate: kuba@kernel.org snprintf returns the length of the formatted string, excluding the trailing null, without accounting for truncation. This means that is the return value is greater than or equal to the size parameter, the fw_version string was truncated. Reported-by: David Laight Closes: https://lore.kernel.org/netdev/81cae734ee1b4cde9b380a9a31006c1a@AcuMS.aculab.com/ Link: https://docs.kernel.org/core-api/kernel-api.html#c.snprintf Fixes: 41e63c2baa11 ("net/mlx5e: Check return value of snprintf writing to fw_version buffer") Signed-off-by: Rahul Rameshbabu Reviewed-by: Simon Horman --- drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c index 792a0ea544cd..c7c1b667b105 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c @@ -49,7 +49,7 @@ void mlx5e_ethtool_get_drvinfo(struct mlx5e_priv *priv, count = snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%04d (%.16s)", fw_rev_maj(mdev), fw_rev_min(mdev), fw_rev_sub(mdev), mdev->board_id); - if (count == sizeof(drvinfo->fw_version)) + if (count >= sizeof(drvinfo->fw_version)) snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%04d", fw_rev_maj(mdev), fw_rev_min(mdev), fw_rev_sub(mdev)); From patchwork Tue Nov 21 23:00:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rahul Rameshbabu X-Patchwork-Id: 13463746 X-Patchwork-Delegate: kuba@kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="DPiHZsHd" Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC72D191 for ; Tue, 21 Nov 2023 15:00:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KKxWl7QVyXJP260Jvufg1ooQLpz0vDdZjN7Pt3S4stHFlf3SlzrlWOxj6U8WnAumuJdPbbri1YCXFAUVLX4ZzL3echiJdZZHP8W3NBCSHQ6+4ytfyociDmXPviTENG18xHFGipJ5YCToMtI5S+rGtUrPiTJLSO2ewTRC8tgyBSJUM+5CwNFFayLy0AZALZOF6IiQ53jN5/zYiTmBKhsn3wUvMgcTRgjy3+17DdF865cgZTqjwVOIiNwx6yT1Wa6NCnvsuUM96s29GDKnrf6eUv9ThwOaYjQD7Eufr2Lc6TQbCFgGxFls+DPJibL3NCCNtSo04fSyeqXUGq6rYEJ+Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FizMkuLUQ9CQ70jsCCHLWmL9hIqLho02Yo/Vmwp5Q1A=; b=aDALeqDSis9lS964sj+JUPBJ2gHW/dTI6zGgvEJ+dj5KQzYh2r+x3xuRXyoVasgzacE9RHvS0RNBlGbr0VGtuD3sDmfG3jpu+B+3Ob/K512nEyv266c4KrRdA03VT9QxjO0VU7gTYpJQUF2DZRt6igEUOiuZiPuMaXJGCPB23tKA7FfeXCG3zsMTtri52auXSEAjl2ytU0yfAo8GU/sfY/mZj9vauD3R16I/F4DnwD/ZHku8HZfW6gjZeqhB4xTXknUJiRjnzAq9WV8jhb4GJKG8dY4AykIzoJOc5/s9ayLesedmnCDtOPSfU8t/Yjc58GcqH6nhDYOY4Yx04y6S2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FizMkuLUQ9CQ70jsCCHLWmL9hIqLho02Yo/Vmwp5Q1A=; b=DPiHZsHd4LfeW0uC+xl8UT1NDd52PjQbTlpZRur8UHCwYyWghy5yaBiCLiHKXvxaVtnwQK1oy7mhGDEz2TIzv6ZmYYWBOR7qFx9MLBt2fRtFpdfD4TVPYg5I8LPrm/lwAjBcMH8P98+3b1GPeRyqL60km24VgjxVx3dLhqfVCAljIKS1KLBJnTGztSLuzhNsceTf9HunCUKjg5g5FqpMX5ajAL4Hwio8E2KBZyXkScs1khXWT9Escez8QJwiUMM0fJa3lRlnAyzi6NOZZdMbLm2ODJv89A9HkZg0lkkDmesfXUKf5NMwxjZ10o+HyUA13MDp+5DtqpyNEGruWjAl/A== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) by CH3PR12MB7667.namprd12.prod.outlook.com (2603:10b6:610:14f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7025.18; Tue, 21 Nov 2023 23:00:51 +0000 Received: from BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::44b4:6f7e:da62:fad4]) by BYAPR12MB2743.namprd12.prod.outlook.com ([fe80::44b4:6f7e:da62:fad4%3]) with mapi id 15.20.7002.027; Tue, 21 Nov 2023 23:00:51 +0000 From: Rahul Rameshbabu To: netdev@vger.kernel.org Cc: Jakub Kicinski , Paolo Abeni , Eric Dumazet , "David S. Miller" , Saeed Mahameed , Gal Pressman , Dragos Tatulea , David Laight , Rahul Rameshbabu Subject: [PATCH net v1 2/2] net/mlx5e: Correct snprintf truncation handling for fw_version buffer used by representors Date: Tue, 21 Nov 2023 15:00:22 -0800 Message-Id: <20231121230022.89102-2-rrameshbabu@nvidia.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231121230022.89102-1-rrameshbabu@nvidia.com> References: <20231121230022.89102-1-rrameshbabu@nvidia.com> X-ClientProxiedBy: SJ0PR05CA0042.namprd05.prod.outlook.com (2603:10b6:a03:33f::17) To BYAPR12MB2743.namprd12.prod.outlook.com (2603:10b6:a03:61::28) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB2743:EE_|CH3PR12MB7667:EE_ X-MS-Office365-Filtering-Correlation-Id: 69fcc057-7ee6-4972-e270-08dbeae5b3cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VZDGeeRTrtIAHeaXHhpHxDb+27HsNh4M3jEwjf9mCc2F14fUOUNURLN4xfmoHGMMRD2cZmA6KrOQs9ykjJQCH26PmvBtevpjeE2nr2rPT/uTRC3mS9ydH7rkrojOci/9DEjSD7ESIdEXlrKGLlprAfOMinrfaHucvnN8AGCMDirPVpgyNGvGy/ghF+8dZig6hCX81dDrhvbsmIh/IG+lP5JLC8YwBhriADBhcDsKs3o/thhmTbZz5hBnksSGbcU+gwQhPWvBurVvt+otV0Rg5L8qI8w31r6Glv/hbgvI7YFDQV0JmLUL5zWGOgDhEz98cWxads9lvu3akDhmrnMkk4CVR3mp5DMPRetDxOWJh5DV5FvjVs4J3hpSbcDgZIpUzf3m6MLe2Tdp6y1Wnp3D4sZv8SMRTwWO0gAER8ppRHOxHDmozOY3Rkh652GkZGTkW5TOdFhPKT66G+RandCLrVSxgZ8AP7RUcI7yJLWNX+RR3Rf3nsTWBx0HK7pKw0fOvA2VjYWnK5PlAmHVHMm5L6hDq8G/17+mk7g7wKAw4unTTt3nl+J16mZXB2bHWmDYVzmPqVp0L0RSvepK3e8pSpvCIKa6zy1pO0HdoR61F34= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB2743.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(136003)(366004)(396003)(346002)(376002)(230922051799003)(451199024)(64100799003)(1800799012)(186009)(2906002)(5660300002)(8676002)(8936002)(4326008)(38100700002)(86362001)(41300700001)(36756003)(107886003)(6512007)(2616005)(1076003)(26005)(6666004)(6506007)(83380400001)(478600001)(66476007)(66556008)(54906003)(66946007)(6916009)(316002)(6486002)(966005);DIR:OUT;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XGeXfGQnaGcYazniZpEcPB5ZI0auroPBitTQ7MIT1d6XrUyKbx8HpMWERIDcclgAgkcqLNE5eEB+XFiJ5sEVjWL+sEp1fS6WzBWNbVCP7PMLNTQPryLQOqwPs+C7qeIpfRP4+AyLsYT3ntVXK7FthG4LTcb0gviskv6QGGwN8L1QaGxlzokGLxvTiMZWyAGIMCz5Bdr7bV39nDcuPNW2LtYBli8mQIKIOiFjiSFxH014BGUARKH9ZT6rLA7I7GZc2TeHBBibnB1l2T+U1yxH0M7dm74bIrEklPmMk/sXYT/Ov1/znjN7vZh6rel8vAg0HasIMCLfr+KC/rK7ZKu+ufasBDvuWHq4yzWY49CoIYMBxOMjqYTrglIMdNhRNoEsm4qr5WjYfxH9tYiteqIIB3yTmghHT2dronJ8WEaLg0PqDicvPpzS6CxFhhGP8qeYZeVkRDyN+8DwaRYpfDEQxVcTmbx+tMR4QDZIsWC8dx5AcGnUWzvQAqPzqQNLYElJuA1Lspae84jUuQbAqzOtYbX/0/+8ih7mLCZInu9Glxcx/UiwqhX3oZef9TgmZ92MoUrt7kA70Ejv0GCaD7/0w== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69fcc057-7ee6-4972-e270-08dbeae5b3cb X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2743.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2023 23:00:49.1082 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RdbT0sTnOHHOn1dH8A7kjywOohlISTEzuzVDnEUQ9MMFsBXs2qn0fSImDf0Sobxx7h/WhNntrG6vSqVr7CAmew== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7667 X-Patchwork-Delegate: kuba@kernel.org snprintf returns the length of the formatted string, excluding the trailing null, without accounting for truncation. This means that is the return value is greater than or equal to the size parameter, the fw_version string was truncated. Link: https://docs.kernel.org/core-api/kernel-api.html#c.snprintf Fixes: 1b2bd0c0264f ("net/mlx5e: Check return value of snprintf writing to fw_version buffer for representors") Signed-off-by: Rahul Rameshbabu Reviewed-by: Simon Horman --- drivers/net/ethernet/mellanox/mlx5/core/en_rep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c index 3ab682bbcf86..8d6cca6e7755 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rep.c @@ -78,7 +78,7 @@ static void mlx5e_rep_get_drvinfo(struct net_device *dev, count = snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%04d (%.16s)", fw_rev_maj(mdev), fw_rev_min(mdev), fw_rev_sub(mdev), mdev->board_id); - if (count == sizeof(drvinfo->fw_version)) + if (count >= sizeof(drvinfo->fw_version)) snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), "%d.%d.%04d", fw_rev_maj(mdev), fw_rev_min(mdev), fw_rev_sub(mdev));