Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3076954ybc; Mon, 18 Nov 2019 09:09:53 -0800 (PST) X-Google-Smtp-Source: APXvYqxaOLKqvGinqF07th3MG65pyJI//+P7afe1VHKPNNsLInTl3oTFUQoSBhqwB3U3TsweRyaL X-Received: by 2002:a17:906:2786:: with SMTP id j6mr27632462ejc.206.1574096993268; Mon, 18 Nov 2019 09:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574096993; cv=none; d=google.com; s=arc-20160816; b=YzDqzszIaaugUTzKZ/HLPKyuthl3njX4OJLghU5viSgowQ1hJV9OYIc4HXW9IXr9q1 QnPTo5rNQ/Fd/AqfCJXKIXN89gl+r21BHuxhtZut7OKf1e5FZE7nAXxK1wUYZD7DrAtZ to/UHdJQJFgrxgFDBzzYK1ceLkaNwSuZ2ROfsOhSCy9ckQuiISvdG9z0L1iST7JqX5+7 ybaKIXp9j/OGueR4fcQw0h00AwLKTkuptqQ5G8HMnuVo+17hGrS09Hc6afTWX0f1rhCX dOXqunm5KPjJ95pVVSJKu+GjmJfsxuKsM3XILm7LNIcgCTpMjm94v+Bti6T31dmedkDA 5NGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:message-id:date :subject:cc:to:from:dkim-signature; bh=VPhkdVuE4r8k1SoS9flKCm6UkmJ4VwiHYivf993T13I=; b=WN6AU7u1EwID6KplT3ArgR3Wa35DeMjT4BnOOUIlGdNHgbkFDLZV1QX/i+Uz+U0vQ9 8qjKv7YjwoBVzSOlfoxKgkmAq8i3a43fGlTFpW3zKAUhnDM++b0sPKFF2a3rZiBtYjA/ NIX7OYi2nFFLvrbEj/eaIm7IUup09MgGY3wsz1L7Gz1/TIMyAiruILIy3ArxWSO/XvAS renQKV8Z2raAgJC5DY85bOP1UfxhEEPJGJjNl3SlJI6Jmwf8k3FGtJFxvdc8Bm1vtBWX LFAhdFDaPMscJtMkezvV+wwn4hb6vEIRO1UxPOSqSnVBUh8o53Uee3iKaTjFzPShSUN1 DSNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="d2EJBd/U"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s13si11847134ejx.144.2019.11.18.09.09.26; Mon, 18 Nov 2019 09:09:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="d2EJBd/U"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726912AbfKRRI0 (ORCPT + 99 others); Mon, 18 Nov 2019 12:08:26 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:30441 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726887AbfKRRI0 (ORCPT ); Mon, 18 Nov 2019 12:08:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574096905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=VPhkdVuE4r8k1SoS9flKCm6UkmJ4VwiHYivf993T13I=; b=d2EJBd/UmZj6wOpEFWH3cb/t2/8BHzd7W44zjfJc7BRpHErZD63kZHgZ8QbnwyeQHiPYQ2 yuy6t1W8CABNaMkURPAxJZH0dEegBlsFnT+ceHygE3Nq4Sbuct7WHDPYtn3KVf+bY4XwxZ 9kYCqS3Mn30IZXD+rbIjRrxJUnsLTrs= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-293-MmOcKuRKMUm7pxyva_uVWQ-1; Mon, 18 Nov 2019 12:08:22 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BC85D477; Mon, 18 Nov 2019 17:08:20 +0000 (UTC) Received: from jtoppins.rdu.csb (ovpn-121-82.rdu2.redhat.com [10.10.121.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5EC5F60307; Mon, 18 Nov 2019 17:08:18 +0000 (UTC) From: Jonathan Toppins To: netdev@vger.kernel.org Cc: Ariel Elior , Sudarsana Kalluru , GR-everest-linux-l2@marvell.com, "David S. Miller" , linux-kernel@vger.kernel.org Subject: [PATCH net-next] bnx2x: initialize ethtool info->fw_version before use Date: Mon, 18 Nov 2019 12:07:53 -0500 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: MmOcKuRKMUm7pxyva_uVWQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If the info->fw_version has garbage in the buffer this can lead to a BUG() being generated in strlcat() due to the use of strlen(). Initialize the buffer before use. The use of a systemtap script can demonstrate the problem by injecting garbage into fw_version: [root@localhost ~]# cat net-info.stp // // compile and run with command //# stap -g net-info.stp // probe begin { printf("net-info version 01.01\n")} function memset(msg:long) %{ =09memset((char*)STAP_ARG_msg,-1,196); %} probe module("bnx2x").function("bnx2x_get_drvinfo") { printf("In function\n"); memset(register("rsi")); } [root@localhost ~]# stap -g net-info.stp & net-info version 01.01 [root@localhost ~]# ethtool -i eth1 Signed-off-by: Jonathan Toppins --- drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/= net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index 4a0ba6801c9e..49b906396dcf 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c @@ -1111,6 +1111,8 @@ static void bnx2x_get_drvinfo(struct net_device *dev, =09int ext_dev_info_offset; =09u32 mbi; =20 +=09info->fw_version[0] =3D 0; + =09strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); =09strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); =20 --=20 2.16.4