From patchwork Fri Feb 2 15:18:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 126729 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp736024ljc; Fri, 2 Feb 2018 07:19:25 -0800 (PST) X-Google-Smtp-Source: AH8x2242/PE1UPykUupHd395/rKLK841K7mMNj0/UnWo1BF/Ifu1zRqEP3q/CKR99/bieyqfuh3X X-Received: by 2002:a17:902:6006:: with SMTP id r6-v6mr18974372plj.78.1517584764871; Fri, 02 Feb 2018 07:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517584764; cv=none; d=google.com; s=arc-20160816; b=yq0O7HzSS33FikunC2eOXiHmUcercXQ3DaecMKwOG631pwAgTqDuE00gtt2DY2WYQW SefTOnCHqQGNHHSEyyID5bweiPE8f6JjVOSIH645q6NNa9mPUkfhXX2CXPftCIk1VHox 65G6mkg8Wpj+8swMCUUbYhLuYh/as06W3Cng2lkGO2xwGQu5eUCpd5iu++uxmony2Fwv kyqKp8CPagk0Il1Bt9GgQZXrkn0O2+FIzl66E/vhnxq4tL9A4FCwc2yuSL9797M9WbUQ r5pwANHb8ut7poltKSUCAvPMaYCel/vE5H3Eed2ZvnLkILUH4p1/lPNgZW8+ZvWJTGOM JKJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=gqYYTbsVCQ6huIRLjGsCBSA+ePUtBqKsmy2uLm8LZn4=; b=U/6I9+q2VPSorTKCPOx29yjXLG4mGRJSm8jSeURP07ZPfYhhxypnSIglgMXSaXcA1f 7WgNzow4E+iSE57bq1q4xT55r1Wvx3mS8nbkkypOm32iB0ePGSqCFJWczrZWZEOhpIpT nNrFLLaERvJsLbQxCJjr0TO0uj1pOxg9r+P0lf6KPA0XEH9ewK7uuZVEp4tLmHcaYgvb JlKW4qHKJG1VTiR1Rq6hN2i2Q1rv6myWGBafDOB/VGs0BmgYZootRpyP7GWcVsoAfsI0 6ox89mIBHMRPIPWjfnJmzvkZCe+Pc5bepat9EuSRu018k27OSFMJxJQW2bUeQG6stywO yRfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-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 p14-v6si1990668plo.420.2018.02.02.07.19.24; Fri, 02 Feb 2018 07:19:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611AbeBBPTS (ORCPT + 8 others); Fri, 2 Feb 2018 10:19:18 -0500 Received: from mout.kundenserver.de ([212.227.126.130]:47513 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751472AbeBBPTQ (ORCPT ); Fri, 2 Feb 2018 10:19:16 -0500 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MVVCo-1eEcIw1LXq-00YgHC; Fri, 02 Feb 2018 16:18:56 +0100 From: Arnd Bergmann To: Ganesh Goudar Cc: Nicolas Pitre , Andi Kleen , Arnd Bergmann , "David S. Miller" , Herbert Xu , Rahul Lakkireddy , Kumar Sanghvi , Harsh Jain , Atul Gupta , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: cxgb4: avoid memcpy beyond end of source buffer Date: Fri, 2 Feb 2018 16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SrJ6o+j63L0smHNkmS26SKYa7eCAwrpX kMnaKe19kohJKVRDH4Qgo8B2eV9hOy/5cz+1PA== Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Building with link-time-optimizations revealed that the cxgb4 driver does a fixed-size memcpy() from a variable-length constant string into the network interface name: In function 'memcpy', inlined from 'cfg_queues_uld.constprop' at drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c:335:2, inlined from 'cxgb4_register_uld.constprop' at drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c:719:9: include/linux/string.h:350:3: error: call to '__read_overflow2' declared with attribute error: detected read beyond size of object passed as 2nd parameter __read_overflow2(); ^ I can see two equally workable solutions: either we use a strncpy() instead of the memcpy() to stop at the end of the input, or we make the source buffer fixed length as well. This implements the latter. Signed-off-by: Arnd Bergmann --- drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h index 1d37672902da..a14e8db51cdc 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h @@ -355,7 +355,7 @@ struct cxgb4_lld_info { }; struct cxgb4_uld_info { - const char *name; + char name[IFNAMSIZ]; void *handle; unsigned int nrxq; unsigned int rxq_size;