Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp335249img; Mon, 18 Mar 2019 04:21:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeRWRIO1Z/5ndNSu/9T1ZToi0MKOrQLApl+vanGNFuptrW2n4Wa/do7L9BnGXE13for7SC X-Received: by 2002:aa7:8b0c:: with SMTP id f12mr18549264pfd.154.1552908118087; Mon, 18 Mar 2019 04:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552908118; cv=none; d=google.com; s=arc-20160816; b=XZ9Iw1EDS7Huve3WxJd3LNqLAciq6MIt9EJsZd5kPl28/83J9+n/Q6pQgejVbyFyEx xDQ/jjpKPGHb/7/Q8TE9sraF4JXIoe36iUEd1FTKmyUHT/sz76EuWUT+eWw6z/32RRdW el8kJVSqZhy0V1zy5kFUkDusvYTM8c+YZzOhIwFnA+W+kYSZv2hALZ9NbsEw9zENm21k TBX6QtKvpZU+PV8y5ZhS+UPgY9V2XXetBryySYISKWep8sBY/mRh+0zFXKvXWan6wIfx Doe6ceh0JTh+QBbgR9k9BBKg8FAQCFqrLmkrR8H/0jCtOP07zu7HZlWumzyHJlSvXcnV jYTQ== 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=Ge7TxntwVS7q0o31nRUbeoDa+FrXVE9oXOJip+O/HJI=; b=lUs00XxjUEA0qpRNAIFGJrYGbIN1nxMOE4PakDaUePTnh79iiGiXIg3G/80HfCPMRB 3p17pVF5oNCqqoqp8KY9D3Bfeb0HGLhRZID0iLbAMmqN6Wi8S17DN72H+39OG1k0e8PV yyalUm2ByppUqJQg4io8w+71xUw4gwS8aGzxs/UfEnVykZASnJIhupGVO2ascKDQkx4b Z2UKwSdBWV6q5WPu4l7V74T1xXoFwahn1rhYR22bpa/23vTDadq4Ru0iP7/Xm7pxfrwP JAm990bUJ7Ee1hbM6T8tpuyWL4/JLrsfinPhazWDWXx3NjryoAObklqBJAZZprRuoh9e Cl2A== 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 l2si9391342pfc.287.2019.03.18.04.21.43; Mon, 18 Mar 2019 04:21:58 -0700 (PDT) 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 S1727245AbfCRLUa (ORCPT + 99 others); Mon, 18 Mar 2019 07:20:30 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:59933 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727012AbfCRLU3 (ORCPT ); Mon, 18 Mar 2019 07:20:29 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id 0AFBD8056F; Mon, 18 Mar 2019 12:20:20 +0100 (CET) Date: Mon, 18 Mar 2019 12:20:28 +0100 From: Pavel Machek To: Rasmus Villemoes Cc: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Jacek Anaszewski , LKML , linux-leds@vger.kernel.org Subject: Re: [PATCH v2 1/6] leds: netdev trigger: use memcpy in device_name_store Message-ID: <20190318112027.GA6101@amd> References: <20190313202615.22883-1-linux@rasmusvillemoes.dk> <20190314140619.3309-1-linux@rasmusvillemoes.dk> <20190314140619.3309-2-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="wRRV7LY7NUeQGEoC" Content-Disposition: inline In-Reply-To: <20190314140619.3309-2-linux@rasmusvillemoes.dk> 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 --wRRV7LY7NUeQGEoC Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu 2019-03-14 15:06:14, Rasmus Villemoes wrote: > If userspace doesn't end the input with a newline (which can easily > happen if the write happens from a C program that does write(fd, > iface, strlen(iface))), we may end up including garbage from a > previous, longer value in the device_name. For example >=20 > # cat device_name >=20 > # printf 'eth12' > device_name > # cat device_name > eth12 > # printf 'eth3' > device_name > # cat device_name > eth32 >=20 > I highly doubt anybody is relying on this behaviour, so switch to > simply copying the bytes (we've already checked that size is < > IFNAMSIZ) and unconditionally zero-terminate it; of course, we also > still have to strip a trailing newline. >=20 > This is also preparation for future patches. >=20 > Signed-off-by: Rasmus Villemoes Acked-by: Pavel Machek --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --wRRV7LY7NUeQGEoC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlyPfvsACgkQMOfwapXb+vKOvgCgqiyTfYd0+V2ObT2VRP6kXG3J upAAn17RsHq8Gx6/q0Ui7GNZEKg1GBfd =ZsZF -----END PGP SIGNATURE----- --wRRV7LY7NUeQGEoC--