From patchwork Fri Oct 6 11:17:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Levin, Alexander \(Sasha Levin\)" X-Patchwork-Id: 115048 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp1668015qgn; Fri, 6 Oct 2017 04:19:25 -0700 (PDT) X-Google-Smtp-Source: AOwi7QAm0ZZyyRl0cJXwqwaCG1dSfgei+0lU2cc+POyCNijh94ky/xyERn5Y6axMgURZSVE5t7gi X-Received: by 10.98.88.7 with SMTP id m7mr1918793pfb.169.1507288764899; Fri, 06 Oct 2017 04:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507288764; cv=none; d=google.com; s=arc-20160816; b=pjrV10V3NBYMC+QtOWZCAK9rFqRSQ7DM/q2d8N/TrL3irYaDPUSjoL6vDO3f1igNsf x7hY+UdOCYwbjK/lQhS17Npkcqneabhnxz017wmY8fTbM8pMSa3+ZAGv9YpgVgu+y2ue 8POnFpyu8J8fvlf+u223pCNlAM8ulBqqSbMKLwAzkFeYNw+jt7okUZsm0EtMDTxFdPZv l10kEFFupcSRP0kX0B0Cp+KSnZmxXrowfhPc1Cg9Xqb7xL2gJcW3MC8J6Iw2t18DAHvt IXDB3VDrRtklsIK1lLgLNDrGs0F7ptYAEaBBqO5gaiX89wvk10yZWCjKPwXMfO0b5vp5 D8cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:to:dkim-signature :dkim-signature:cc:from:dkim-signature:arc-authentication-results; bh=ou2cdvnRvehiMJbGlGPs28PIX3gGbwzcscEYccUIZZM=; b=HJMSGwe5P6WcNl31yyarmkq1aaCnABv6ba37yHR5+69Wmn1kijvF+FYalNF+Br0KWh T8owDbSfdMeNKGJCaDp8VwDkEZ1A0LM1PuATMaHh1UmX2H5/MdYEKPDbbSqxWpw4Lqcd 1Rv4X4vuC8pt1BZ5kOx7PgMFM6FfVY9c4kwnUG2kEiS5wPkyytTZuLT6dkPJqMzKW1pF 4mgDaBu3x4HZYpM2rdHQiq1OK0YTVfxnMqku1teAG10ND6cJYaycxsp8mbTrHpJwWt44 nos0GVHSOak2P0C22JNCAmjNoZU7XsU2hIOLqheP0NxFC9skzB12E1bWLsU+UEeoEwyR pdqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verizon.com header.s=corp header.b=Vy6Eta3v; dkim=fail header.i=@verizon.com header.s=corp header.b=ecwPJtkG; dkim=fail header.i=@verizon.com header.s=corp header.b=ecwPJtkG; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si954507pgu.126.2017.10.06.04.19.24; Fri, 06 Oct 2017 04:19:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=@verizon.com header.s=corp header.b=Vy6Eta3v; dkim=fail header.i=@verizon.com header.s=corp header.b=ecwPJtkG; dkim=fail header.i=@verizon.com header.s=corp header.b=ecwPJtkG; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=verizon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096AbdJFLTX (ORCPT + 8 others); Fri, 6 Oct 2017 07:19:23 -0400 Received: from fldsmtpe03.verizon.com ([140.108.26.142]:8203 "EHLO fldsmtpe03.verizon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097AbdJFLTW (ORCPT ); Fri, 6 Oct 2017 07:19:22 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288762; x=1538824762; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=I7r0gUjQIuPAgUoznrF+W92Vo/tGZ8nPGVVyHFQVy3c=; b=Vy6Eta3vpOnH9bKRMjd2cT1iDmpV579W7k8i/ZnEsrqILPoU/CjLCWxB 6iA9LCL9DvsWL9f/4fKoCze2Xlh9h/bdg43pTkhIr4GFPMIup9sx2UZIT UW5m/+BlGV0HXSF0oVhgIxgHAx+D9x2vQCYfWDPGUBpUi55riXu5gDaeI Q=; Received: from unknown (HELO fldsmtpi02.verizon.com) ([166.68.71.144]) by fldsmtpe03.verizon.com with ESMTP; 06 Oct 2017 11:19:20 +0000 From: "Levin, Alexander (Sasha Levin)" Cc: Arnd Bergmann , "David S . Miller" , "Levin, Alexander (Sasha Levin)" Received: from rogue-10-255-192-101.rogue.vzwcorp.com (HELO apollo.verizonwireless.com) ([10.255.192.101]) by fldsmtpi02.verizon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Oct 2017 11:19:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288757; x=1538824757; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=I7r0gUjQIuPAgUoznrF+W92Vo/tGZ8nPGVVyHFQVy3c=; b=ecwPJtkGadfV4WTskk2UGZuO9WgVB806uPt24LmylvCN3UnVMHKwUFRh aA6mIqg3kBnOWm/lwiGK3Dc/P4iGNgg7VTTh0TxHbcnWGAqV7vfLU7L4B ePUTQrq4mqISfaSxq8+4Er6/z86O/4x5H+Bd6km8V/Kx86+iEcj/YiZAa o=; Received: from surveyor.tdc.vzwcorp.com (HELO eris.verizonwireless.com) ([10.254.88.83]) by apollo.verizonwireless.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Oct 2017 07:19:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1507288757; x=1538824757; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=I7r0gUjQIuPAgUoznrF+W92Vo/tGZ8nPGVVyHFQVy3c=; b=ecwPJtkGadfV4WTskk2UGZuO9WgVB806uPt24LmylvCN3UnVMHKwUFRh aA6mIqg3kBnOWm/lwiGK3Dc/P4iGNgg7VTTh0TxHbcnWGAqV7vfLU7L4B ePUTQrq4mqISfaSxq8+4Er6/z86O/4x5H+Bd6km8V/Kx86+iEcj/YiZAa o=; X-Host: surveyor.tdc.vzwcorp.com Received: from ohtwi1exh003.uswin.ad.vzwcorp.com ([10.144.218.45]) by eris.verizonwireless.com with ESMTP/TLS/AES128-SHA256; 06 Oct 2017 11:19:17 +0000 Received: from OMZP1LUMXCA16.uswin.ad.vzwcorp.com (144.8.22.194) by OHTWI1EXH003.uswin.ad.vzwcorp.com (10.144.218.45) with Microsoft SMTP Server (TLS) id 14.3.248.2; Fri, 6 Oct 2017 07:19:17 -0400 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com (144.8.22.195) by OMZP1LUMXCA16.uswin.ad.vzwcorp.com (144.8.22.194) with Microsoft SMTP Server (TLS) id 15.0.1263.5; Fri, 6 Oct 2017 06:19:15 -0500 Received: from OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) by OMZP1LUMXCA17.uswin.ad.vzwcorp.com ([144.8.22.195]) with mapi id 15.00.1263.000; Fri, 6 Oct 2017 06:19:16 -0500 To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" Subject: [added to the v4.1 stable tree] qlge: avoid memcpy buffer overflow Thread-Topic: [added to the v4.1 stable tree] qlge: avoid memcpy buffer overflow Thread-Index: AQHTPpS6hwAAU2hXskaokq6qP5odgQ== Date: Fri, 6 Oct 2017 11:17:42 +0000 Message-ID: <20171006111704.25872-90-alexander.levin@verizon.com> References: <20171006111704.25872-1-alexander.levin@verizon.com> In-Reply-To: <20171006111704.25872-1-alexander.levin@verizon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.144.60.250] MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann This patch has been added to the v4.1 stable tree. If you have any objections, please let us know. -- 2.11.0 =============== [ Upstream commit e58f95831e7468d25eb6e41f234842ecfe6f014f ] gcc-8.0.0 (snapshot) points out that we copy a variable-length string into a fixed length field using memcpy() with the destination length, and that ends up copying whatever follows the string: inlined from 'ql_core_dump' at drivers/net/ethernet/qlogic/qlge/qlge_dbg.c:1106:2: drivers/net/ethernet/qlogic/qlge/qlge_dbg.c:708:2: error: 'memcpy' reading 15 bytes from a region of size 14 [-Werror=stringop-overflow=] memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1); Changing it to use strncpy() will instead zero-pad the destination, which seems to be the right thing to do here. The bug is probably harmless, but it seems like a good idea to address it in stable kernels as well, if only for the purpose of building with gcc-8 without warnings. Fixes: a61f80261306 ("qlge: Add ethtool register dump function.") Signed-off-by: Arnd Bergmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qlge/qlge_dbg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c index 829be21f97b2..be258d90de9e 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_dbg.c @@ -724,7 +724,7 @@ static void ql_build_coredump_seg_header( seg_hdr->cookie = MPI_COREDUMP_COOKIE; seg_hdr->segNum = seg_number; seg_hdr->segSize = seg_size; - memcpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1); + strncpy(seg_hdr->description, desc, (sizeof(seg_hdr->description)) - 1); } /*