Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3054090ybc; Thu, 21 Nov 2019 02:36:41 -0800 (PST) X-Google-Smtp-Source: APXvYqw7unKah06QP/mpLYFQU56aB8F36c+yJqdlLf+gd8qr3irBikdv4VhIN98KG0zOGowlnuIL X-Received: by 2002:a17:906:194a:: with SMTP id b10mr13095821eje.123.1574332601306; Thu, 21 Nov 2019 02:36:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574332601; cv=none; d=google.com; s=arc-20160816; b=ra9Z9PIvy33cWJeS5UbFYNfr0HjBsrOMY/+nWoY2nvXszb8bmvAUDfDf2MKjzdfTk1 lNppZ6eIAFHWNIeQhYu6Fog07zrh7cRiGOyFakQI1B5qTjE3Q/SSIcEKVV/XngGM+ylH UKnqBpGDOL933/LeDtyFcHsrWcl3brkvu1FOQHK3xR9wkASYzWzVeoa1TRiuvE7DlF+/ 8Z0mRPHen2fII7BcRzmL9KtliYiQXWliDhN91dfLJwDEj6WU10Hy58UeOFOCOPI3EJhn sPbb7RXCwxzFKSP8wWljD1AbQpFhk6yKJI9FDDIILyUNrg45uz1/VnYi2IZnXrOdJAo9 iHiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=1wKuDoOg4JyaRZqdUj65fHTM7SdE3MN+f+Urcb65Gw0=; b=vTuYdjqUTLG3F4z1WSDZGov32oYnct2nsocP7lk5UxPEmNajHrCYkdTNpjelJXfCoV pXsJzKVLukM+KOlq0yfTCgfHZccr/iyDgpIs042Aq+Rk3C6F32ecfDw7UjDB7F4JAuPg R1k/godQjebsgrSrQom9bek2OTCC4aMKtSfIxt42RGUjrK+wOrHHFzktxSC/l54dPKly 8mBUlAilhpCLPTal5Y83rGq+oUmp5YX7fnUVWGHNVkPfNgQG8bFFroRGsq6J764EsYNg gSS2uG6anNYWtVDaM4Vfjbs9tqwixZc9vk8Gmx23JTOH28YPBBv619OyVIMqubW6d7yH 4peg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s10si1812874edh.138.2019.11.21.02.36.16; Thu, 21 Nov 2019 02:36:41 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726500AbfKUKfH (ORCPT + 99 others); Thu, 21 Nov 2019 05:35:07 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:40252 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726014AbfKUKfG (ORCPT ); Thu, 21 Nov 2019 05:35:06 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id D8DEA1C1B56; Thu, 21 Nov 2019 11:35:04 +0100 (CET) Date: Thu, 21 Nov 2019 11:35:04 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Mitch Williams , Andrew Bowers , Jeff Kirsher , Sasha Levin Subject: Re: [PATCH 4.19 079/422] i40e: use correct length for strncpy Message-ID: <20191121103504.GC26882@amd> References: <20191119051400.261610025@linuxfoundation.org> <20191119051404.622986351@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="hYooF8G/hrfVAmum" Content-Disposition: inline In-Reply-To: <20191119051404.622986351@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --hYooF8G/hrfVAmum Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Mitch Williams >=20 > [ Upstream commit 7eb74ff891b4e94b8bac48f648a21e4b94ddee64 ] >=20 > 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; > =20 > - 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 =3D THIS_MODULE; > pf->ptp_caps.max_adj =3D 999999999; > pf->ptp_caps.n_ext_ts =3D 0; So... pf is allocated with kzalloc, which will provide the null termination... so the code is okay. On the other hand, the =3D 0 below is unneeded by the same logic, so this is a bit confusing. Best regards, Pavel --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --hYooF8G/hrfVAmum Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl3WaFcACgkQMOfwapXb+vJJHACfRuY88Hc7nM5FRo+hzyQlowfF DrQAoLdm0t9gzcVpQk4tJRuS1vLYgHbO =ZNgA -----END PGP SIGNATURE----- --hYooF8G/hrfVAmum--