linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Martin Hundebøll" <mhu@silicom.dk>
To: Russ Weight <russell.h.weight@intel.com>,
	mdf@kernel.org, linux-fpga@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: trix@redhat.com, lgoncalv@redhat.com, yilun.xu@intel.com,
	hao.wu@intel.com, matthew.gerlach@intel.com
Subject: Re: [PATCH v6 2/7] fpga: sec-mgr: enable secure updates
Date: Wed, 2 Dec 2020 14:40:53 +0100	[thread overview]
Message-ID: <d9be1ac7-3a44-dca0-c989-49c672e21b85@silicom.dk> (raw)
In-Reply-To: <25ee1ab1-3d81-d9b9-240d-143a9936d0f8@intel.com>

Hi Russ,

On 02/12/2020 00.30, Russ Weight wrote:
> 
> On 12/1/20 12:47 AM, Martin Hundebøll wrote:
>> Hi Russ,
>>
>> On 01/12/2020 00.54, Russ Weight wrote:
>>> Thanks Martin. I'll work on a fix for this.
>> Attached is my in-house fix.
>>
>> // Martin
>>
>>> On 11/26/20 6:02 AM, Martin Hundebøll wrote:
>>>> Hi Russ,
>>>>
>>>> I found another thing while testing this...
>>>>
>>>> On 06/11/2020 02.09, Russ Weight wrote:
>>>>
>>>> <snip>
>>>>
>>>>> +static ssize_t filename_store(struct device *dev, struct device_attribute *attr,
>>>>> +                  const char *buf, size_t count)
>>>>> +{
>>>>> +    struct fpga_sec_mgr *smgr = to_sec_mgr(dev);
>>>>> +    int ret = count;
>>>>> +
>>>>> +    if (count == 0 || count >= PATH_MAX)
>>>>> +        return -EINVAL;
>>>>> +
>>>>> +    mutex_lock(&smgr->lock);
>>>>> +    if (smgr->driver_unload || smgr->progress != FPGA_SEC_PROG_IDLE) {
>>>>> +        ret = -EBUSY;
>>>>> +        goto unlock_exit;
>>>>> +    }
>>>>> +
>>>>> +    smgr->filename = kstrndup(buf, count - 1, GFP_KERNEL);
>>>> The `count - 1` is meant to remove a trailing newline, but opae-sdk writes the filename without newline, so better do it conditionally...
> After looking at how kstrndup() is used elsewhere, and after
> doing some experimentation, I think the best fix may be to just
> remove the "- 1":
> 
>      smgr->filename = kstrndup(buf, count, GFP_KERNEL);
> 
> The code shouldn't have assumed a "\n", and I don't think the
> kernel should be required to do white-space cleanup.
> 
> Does this fix seem OK to you?

Since we always use opae-sdk to write the filename, we wouldn't even notice.

While your'e at it, kerneldoc in mm/util.c suggests to use kmemdup_nul() 
when the size is known.

// Martin

  reply	other threads:[~2020-12-02 13:42 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-06  1:08 [PATCH v6 0/7] FPGA Security Manager Class Driver Russ Weight
2020-11-06  1:08 ` [PATCH v6 1/7] fpga: sec-mgr: fpga security manager class driver Russ Weight
2020-11-15 23:03   ` Moritz Fischer
2020-11-20  2:39     ` Russ Weight
2020-11-20  6:26       ` Moritz Fischer
2020-11-06  1:09 ` [PATCH v6 2/7] fpga: sec-mgr: enable secure updates Russ Weight
2020-11-19  9:28   ` Martin Hundebøll
2020-11-26 14:02   ` Martin Hundebøll
2020-11-30 23:54     ` Russ Weight
2020-12-01  8:47       ` Martin Hundebøll
2020-12-01 23:30         ` Russ Weight
2020-12-02 13:40           ` Martin Hundebøll [this message]
2020-11-06  1:09 ` [PATCH v6 3/7] fpga: sec-mgr: expose sec-mgr update status Russ Weight
2020-11-06  1:09 ` [PATCH v6 4/7] fpga: sec-mgr: expose sec-mgr update errors Russ Weight
2020-11-06  1:09 ` [PATCH v6 5/7] fpga: sec-mgr: expose sec-mgr update size Russ Weight
2020-11-06  1:09 ` [PATCH v6 6/7] fpga: sec-mgr: enable cancel of secure update Russ Weight
2020-11-06  1:09 ` [PATCH v6 7/7] fpga: sec-mgr: expose hardware error info Russ Weight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d9be1ac7-3a44-dca0-c989-49c672e21b85@silicom.dk \
    --to=mhu@silicom.dk \
    --cc=hao.wu@intel.com \
    --cc=lgoncalv@redhat.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.gerlach@intel.com \
    --cc=mdf@kernel.org \
    --cc=russell.h.weight@intel.com \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).