Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5434936img; Wed, 27 Mar 2019 08:27:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiIg13BIrY2TNKXqneqD+Gj2zTPi07TwpuvWSKqllzKMTA34QmRg1WujcVhzruSWsdCqpT X-Received: by 2002:a63:ff66:: with SMTP id s38mr32130142pgk.120.1553700461821; Wed, 27 Mar 2019 08:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553700461; cv=none; d=google.com; s=arc-20160816; b=HXNB7Rpdy3EwRwPj++ypvuAB22m+Ma0MFY2VYVP6ygP5oCvX3jIsAnGm5UUmf3pfzS Gj+WVBT3uZHDL483WsckQQFaAb8toeKDRBzBGkKaO2qWXm5hW/4vsZWTGAZj/l3gm2yE g5PfF2Za6Ingh1ukNruyXIHA8z84613RD8Z617gcc8ZoAJ9m4YClSMfXQIc539GyQh/t MSUVmuR6CWhk6CTZRXqkqQ0p4IffgpsQWHTQ2UVb4QgbFw7lAQwrEOMQ7f2zw8VQXsly txNzV+9OPOcfeuZIgQ0+jmDnoDm3Kq+vXF/jXuC3XQgir+K2VT5tmlMRfZ3FE5Sev4IZ HTkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=5UmcYm7E7lwE/YOuO+szfo50S0UxDcJvs6IDRrUFBHM=; b=IUtUl+UwTlfRoH2EhAgirUFE3KU2wSDk+A9lNM8P2UASJTNTJQlPnpv4FaEy8ARcaP 2FOZyXYYN/k/Z2B6RuPiVokMA6s6m9mHCNuLXw5awzUinFbKtJapJ+6hwbIGwzMaB4g/ nvIzy4g/ui/fZpVJCjCEAFfe/+OhbRnE380IWNn7zPMgZjQqjnBfc9UMXqgcyJK8RxwZ hTxRBU5/lQI/eWQAAACfDoO04VMChH1LI6I3DDHTINedSq/dyEzXeDYFjVOhx1czW2UR WeX8KeTPHbSouxZmuS6gcKWCTX+Qt587GQQAiY49eHhnAWZh+x6EuD3OpAWxWnbzelCs /Gfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="Zxml6/nf"; 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 w9si16926794pgj.590.2019.03.27.08.27.25; Wed, 27 Mar 2019 08:27:41 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b="Zxml6/nf"; 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 S1729024AbfC0P0b (ORCPT + 99 others); Wed, 27 Mar 2019 11:26:31 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38943 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726208AbfC0P0b (ORCPT ); Wed, 27 Mar 2019 11:26:31 -0400 Received: by mail-lj1-f196.google.com with SMTP id l7so14773129ljg.6 for ; Wed, 27 Mar 2019 08:26:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5UmcYm7E7lwE/YOuO+szfo50S0UxDcJvs6IDRrUFBHM=; b=Zxml6/nf97vRwe4yxGF+FSpksx4hDF4019bE/5mGpP6fgaUpe1TUgbOSzIPjTfWoIj AQoJ1foCwdY4Adt2XexYNNIYB4jpPWKtOVNN8GAXrrgmAGVblrVGBt005Oqawj7JjGUw 8417igX5K03Q5GtvO86BU8vmM6wzt5eY+8pfM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5UmcYm7E7lwE/YOuO+szfo50S0UxDcJvs6IDRrUFBHM=; b=V870JujsCFtmhOQDEDqyeq0TDLLB1hMAqYkwpbeP4jVOD7c69LUWZKe8SaP65oSZGA gFqKIW3OaK18fBTdMHWIfq2lAHZLwbRROfa0Uk7keUpAoDgTav43rt99pWr7eqvFtS/y Je3xw9Lrv2v526S1PCqsacJeW0wHJyJlQn4M0m67KhTajwOVqAXE52F1dzxNXgGLAf9V X7ZIDBybUiNKpgXj4piDPpWxc0npBoMhPhdHcyvD1af2dRXgzK80SV9QKcQEHzPfMb6K 88Vm4YltoaT9xQikBv6ZyK+0vMJO8XS6VTDks8WSg+JgtqbRpc6bGeN39nju8bwm/kvX uhzQ== X-Gm-Message-State: APjAAAXdHYZpvULPYDrVQkgvRn1bg5uaNzeSO0ttRfZnX+3aey8YVn1k YF6cAeqDVn329JfzkFqc7gWERA== X-Received: by 2002:a2e:2a03:: with SMTP id q3mr4767840ljq.56.1553700389319; Wed, 27 Mar 2019 08:26:29 -0700 (PDT) Received: from [172.16.11.26] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id m23sm4761330ljh.93.2019.03.27.08.26.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Mar 2019 08:26:28 -0700 (PDT) Subject: Re: [PATCH v2 1/6] leds: netdev trigger: use memcpy in device_name_store To: Jacek Anaszewski , Rasmus Villemoes , Pavel Machek , =?UTF-8?Q?Uwe_Kleine-K=c3=b6nig?= Cc: LKML , linux-leds@vger.kernel.org References: <20190313202615.22883-1-linux@rasmusvillemoes.dk> <20190314140619.3309-1-linux@rasmusvillemoes.dk> <20190314140619.3309-2-linux@rasmusvillemoes.dk> <987c3e60-edb3-44f0-be28-434c70bb8659@gmail.com> From: Rasmus Villemoes Message-ID: Date: Wed, 27 Mar 2019 16:26:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <987c3e60-edb3-44f0-be28-434c70bb8659@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26/03/2019 20.53, Jacek Anaszewski wrote: > Hi Rasmus, > > Thank you for the patch. > > On 3/14/19 3:06 PM, 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 >> >> # cat device_name >> >> # printf 'eth12' > device_name >> # cat device_name >> eth12 >> # printf 'eth3' > device_name >> # cat device_name >> eth32 >> > > Added tag: > > Fixes: 06f502f57d0d ("leds: trigger: Introduce a NETDEV trigger") > > and applied to the fixes-for-5.1-rc3 branch. > You're stripping lines beginning with #. This is the commit in -next: commit 09466021a80c926aa7de68e5162bdfea2a117483 Author: Rasmus Villemoes Date: Thu Mar 14 15:06:14 2019 +0100 leds: netdev trigger: use memcpy in device_name_store 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 eth12 eth32 which is entirely useless and confusing. Please fix this before it actually hits mainline. And you may want to look into "git commit --cleanup" and/or "git config commit.cleanup" (scissors is much better than the default strip). Rasmus