Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3378386ybc; Mon, 18 Nov 2019 14:22:56 -0800 (PST) X-Google-Smtp-Source: APXvYqwt+1HTRtU8VfktQd1vg5Xc8nB2PFb8lu+cL7u0rmWmIx1HB/dWDOVgItfS57NARUTB2YeO X-Received: by 2002:adf:e74e:: with SMTP id c14mr3036096wrn.124.1574115776384; Mon, 18 Nov 2019 14:22:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574115776; cv=none; d=google.com; s=arc-20160816; b=DUJkFhmHvlYvx1L5Nd/P9+XzqESXz24Z60bxDmHjPYYRPLrnjoYSb1+7TBvPNJxYXX cik12IhJo/e8vfmf1EPI6VBwnFLnxsgbbL6CqwZsxpY3AUQo5/GGd1k7lSxcw6NOoG8/ 5cNXuswoQIeEKGBjzW7PUyYd/p0WApMrfbW6ls2HHBfnk50oYxCGIc8ngOISMCoEWTmP 14lj2Q8dGmVNfkuSd3ssePP4GLTWAM8hfzuDkmThfGtqcy4T+KXAuxsuoNNguOINnmhN rRRbbffOTLd1gd7vStKg0v+O/6V07OPHG1wMNnBdblW3JzWLOWZrue0yUrummAxTZQIb GP3g== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=k8tXvyojuzIpGqqZbdiFU+fQa+u+1+HqoxvD/bINmWw=; b=ehd0wUk+xRJKpAVEylVhs8YJWYBFFUxtF8NlXLT9qEczjhWw6bXsvutx1lHcITTnmd mtcvefCLPjXOF1aL9G3JbDczHgwesBQvQvUuQrNwUwe1mqPRWsE3kyCISVZyfW4Meluh pqrfohi5trSufmtQ1pwZqZhFsSOslgN7BrM99DKaDpRTpZuUA194nNBSuCHfSkTeG1Qn E53YFnaxFxmSQpoBCtGkbV92+9QO8dHiosMG2/rYp3kfRSVr4UNemUee2ObWSLHr/J5+ hpNAZvsORZAvaAjIFAYnhJqwOfQMFghfb2E2/K3xRthawSPFbL9LKUce1UB7mIq8GLvG 1nng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=Wfm+A2UU; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si13926834eda.258.2019.11.18.14.22.31; Mon, 18 Nov 2019 14:22:56 -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=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b=Wfm+A2UU; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726830AbfKRWVg (ORCPT + 99 others); Mon, 18 Nov 2019 17:21:36 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36325 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbfKRWVg (ORCPT ); Mon, 18 Nov 2019 17:21:36 -0500 Received: by mail-lf1-f68.google.com with SMTP id r14so8564345lff.3 for ; Mon, 18 Nov 2019 14:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=k8tXvyojuzIpGqqZbdiFU+fQa+u+1+HqoxvD/bINmWw=; b=Wfm+A2UU5wPRDg1SMAD6R61AQ5XyyAcA+QYMX0gxvsq0xwoogOpUdq2vuhCw0RF1ms Vtl5xTF58LswzSMtdjNRgdKYQ5myagl5Cg+mpUKtsAbte6sm29VGozNtwra7ysUujc1r eRe34JI3RrFyEDetqkXzaGmAII12jYrHnsui/Z1jFpwPC7vmnb2Sd3gSD2Bi3gEFm/pE MehhKnZ6MbbGBxkdEjfJ9sAjoHmkQ/jOS1quGveC8iqwuxKdhl/mG72iXkCF0DlIv40M jrkTp7c0O6aZqQVPC+Pb7+bPI4ZwnNLd+ZGD6D8imsql97huDrYthu2GNcHYT/l0mY/f JbpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=k8tXvyojuzIpGqqZbdiFU+fQa+u+1+HqoxvD/bINmWw=; b=hG3oTGRiAw8XecLrOy4re8x9jOa6QjGZfQzzBz//wk6SUuD6UrqbKVOZvn7zlfR2+O jQA+K+NRCx2A4Zs0E3mRj3UisY5WkXVj7ct2lPwthO/sU+OtwAc+3kNRL8CJdixQjHej RkPvsEfEfON/mzchR+LadJrbVE/dQ/Ixu5GBD4jjkj3CAWJXaH8UyjeuJD9BzCFSI8+F wbYOldcsZrd0j/7X2jBnQ18Qdg7yfNT+LNtNFcEfKGFvhNhPOoT+ERryzG/PPdDCC5l1 R+ixOZmMvu6lZ8ZCwSI4N4lh1cKDJOF/MbA+Bnm6ax+NZO/Tm+A4ycHN49wfCDr0F7It 8aNw== X-Gm-Message-State: APjAAAXi3+V3/nmerMbcQ3cYJdKIblfUSQSk9OvYQREG1/yacEpYl1RG obVgOzfXQpnbEWrDbv5x70WTzQ== X-Received: by 2002:a05:6512:49c:: with SMTP id v28mr1197714lfq.9.1574115694006; Mon, 18 Nov 2019 14:21:34 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id m18sm9528509ljg.3.2019.11.18.14.21.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Nov 2019 14:21:33 -0800 (PST) Date: Mon, 18 Nov 2019 14:21:20 -0800 From: Jakub Kicinski To: Jonathan Toppins Cc: netdev@vger.kernel.org, Ariel Elior , Sudarsana Kalluru , GR-everest-linux-l2@marvell.com, "David S. Miller" , linux-kernel@vger.kernel.org Subject: Re: [PATCH net-next] bnx2x: initialize ethtool info->fw_version before use Message-ID: <20191118142120.2cec693d@cakuba.netronome.com> In-Reply-To: References: Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 18 Nov 2019 12:07:53 -0500, Jonathan Toppins wrote: > 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: > @@ -1111,6 +1111,8 @@ static void bnx2x_get_drvinfo(struct net_device *dev, > int ext_dev_info_offset; > u32 mbi; > > + info->fw_version[0] = 0; > + > strlcpy(info->driver, DRV_MODULE_NAME, sizeof(info->driver)); > strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); I don't know systemtap, so it's very unclear what you're trying to fix here. Setting random fields of info to 0 seems pointless as the entire structure is zeroed before the call in ethtool_get_drvinfo(). Please explain.