Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3387025ybc; Thu, 21 Nov 2019 07:36:36 -0800 (PST) X-Google-Smtp-Source: APXvYqysDYyiO7yQT1MMwWuexQ7lCavGqK45xTGqbboIl4QQzD5aUQnp4GIMwlLUox32byyxWIDT X-Received: by 2002:a1c:98c5:: with SMTP id a188mr10652532wme.133.1574350596323; Thu, 21 Nov 2019 07:36:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574350596; cv=none; d=google.com; s=arc-20160816; b=uCjeYrHj2RR2zowAJUxzT4ABCJwQssJVZOhqyNO6ClPARA4Wrav7SRLBFCvVaKLUdV mGfEgRK+jcokRaNms7FrIVyUMnbQ1TemA3GJ+xIh1tI4mLsZKShL7AHHSa/39Lw3akxy LHQxCiKNbBc57cWVpaDmmNOf/Th9TlXR0lVQxWGOSN/LoF5uD//xKJkIVvvami9zp3qP 2lqwXuqvHpl8uMqaGIr5KmmzAjKM9hxNiBxG5wA8CIJpHCylUEtjXKCyYEtbTiKJ9Nwj 0QR1Ro6QneS0qG7mdbsZ9O0t5/pEWJbqIYrxao+7xKIRv6b+C9ACTH8oVyQTwDJG1vVk zf5A== 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 :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=kfoyBiheCXoRXxD7Lpi9YrTBihHIpm6fCbHrblKsdWo=; b=FGMLGChpbWYfMQi4iNjn8wg6N2/gQNGAKj7tQ33plPyMS9LmYUJ9IV3K8sQeInMdRF ZI94KYQBM1ak7GrJldjZ6kmJWHT5T73Jh5DBu2TEeJlBrFPphjkI0ToimdmEX9SDLYdL 4dKCx3OWN9t70MtLm+7aCmubhebLOH6V2sE6vRxiiOjmjeBNt96oaLhQdLV8Be+e1PyI ng4DLJOoG3SV2ZhQzBHpUA1u3uTOxUSNMAdwHSMPkQC+5dSJT6+UqlUfxTaNuBXsq1QB HPJND6lYvx5gnL0P43u1O34HZVM0ypHHWuID8NUDRP4wXTqRMQGJFdVHtFrbfv7oKQ/k TtjA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c31si2432805edb.56.2019.11.21.07.36.09; Thu, 21 Nov 2019 07:36:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726658AbfKUPek convert rfc822-to-8bit (ORCPT + 99 others); Thu, 21 Nov 2019 10:34:40 -0500 Received: from mga06.intel.com ([134.134.136.31]:54896 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbfKUPej (ORCPT ); Thu, 21 Nov 2019 10:34:39 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Nov 2019 07:34:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,226,1571727600"; d="scan'208";a="216158521" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga001.fm.intel.com with ESMTP; 21 Nov 2019 07:34:39 -0800 Received: from fmsmsx121.amr.corp.intel.com (10.18.125.36) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 21 Nov 2019 07:34:38 -0800 Received: from fmsmsx117.amr.corp.intel.com ([169.254.3.27]) by fmsmsx121.amr.corp.intel.com ([169.254.6.42]) with mapi id 14.03.0439.000; Thu, 21 Nov 2019 07:34:38 -0800 From: "Williams, Mitch A" To: Pavel Machek , Greg Kroah-Hartman , "Loktionov, Aleksandr" CC: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , "Bowers, AndrewX" , "Kirsher, Jeffrey T" , Sasha Levin Subject: RE: [PATCH 4.19 079/422] i40e: use correct length for strncpy Thread-Topic: [PATCH 4.19 079/422] i40e: use correct length for strncpy Thread-Index: AQHVnpnuJAXG2g2RHUipXk6/Nek15KeV95QA///NAFA= Date: Thu, 21 Nov 2019 15:34:38 +0000 Message-ID: References: <20191119051400.261610025@linuxfoundation.org> <20191119051404.622986351@linuxfoundation.org> <20191121103504.GC26882@amd> In-Reply-To: <20191121103504.GC26882@amd> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiM2NjZTMxNTYtMzJjZi00YTY5LWIzNWYtM2NkNWQwNGFmYTlmIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU0tYM0NFNm9xaXk2dWJFR2JoMmFsY3JNZWdHaFYxQWpTTlRNQVAxMm4wMHVvUnFnNk96TEZRbzlrSGpWK1RxXC8ifQ== x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.1.200.107] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > -----Original Message----- > From: Pavel Machek > Sent: Thursday, November 21, 2019 2:35 AM > To: Greg Kroah-Hartman > Cc: linux-kernel@vger.kernel.org; stable@vger.kernel.org; Williams, Mitch A > ; Bowers, AndrewX ; > Kirsher, Jeffrey T ; Sasha Levin > > Subject: Re: [PATCH 4.19 079/422] i40e: use correct length for strncpy > > Hi! > > > From: Mitch Williams > > > > [ Upstream commit 7eb74ff891b4e94b8bac48f648a21e4b94ddee64 ] > > > > Caught by GCC 8. When we provide a length for strncpy, we should not > > include the terminating null. So we must tell it one less than the size > > of the destination buffer. > > > +++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c > > @@ -694,7 +694,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf) > > if (!IS_ERR_OR_NULL(pf->ptp_clock)) > > return 0; > > > > - strncpy(pf->ptp_caps.name, i40e_driver_name, sizeof(pf->ptp_caps.name)); > > + strncpy(pf->ptp_caps.name, i40e_driver_name, > > + sizeof(pf->ptp_caps.name) - 1); > > pf->ptp_caps.owner = THIS_MODULE; > > pf->ptp_caps.max_adj = 999999999; > > pf->ptp_caps.n_ext_ts = 0; > > So... pf is allocated with kzalloc, which will provide the null > termination... so the code is okay. > > On the other hand, the = 0 below is unneeded by the same logic, so > this is a bit confusing. > > Best regards, > Pavel Thanks for catching this, Pavel. Aleksandr Loktionov owns this driver now. He can get this taken care of. -Mitch > -- > (english) http://www.livejournal.com/~pavelmachek > (cesky, pictures) > http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html