lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 27 Oct 2017 21:16:08 +0200
From:   "Rafael J. Wysocki" <rafael@...nel.org>
To:     Andy Shevchenko <andy.shevchenko@...il.com>
Cc:     "Rafael J. Wysocki" <rafael@...nel.org>,
        "Rafael J. Wysocki" <rjw@...ysocki.net>, ramesh.thomas@...el.com,
        Linux PM <linux-pm@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        Reinette Chatre <reinette.chatre@...el.com>,
        Alex Shi <alex.shi@...aro.org>,
        Ulf Hansson <ulf.hansson@...aro.org>
Subject: Re: [PATCH] PM / QoS: Fix device resume latency PM QoS

On Fri, Oct 27, 2017 at 8:52 PM, Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Thu, Oct 26, 2017 at 11:38 AM, Rafael J. Wysocki <rafael@...nel.org> wrote:
>> On Wed, Oct 25, 2017 at 10:06 PM, Andy Shevchenko
>> <andy.shevchenko@...il.com> wrote:
>>> On Tue, Oct 24, 2017 at 11:49 AM, Rafael J. Wysocki <rjw@...ysocki.net> wrote:
>>>> On Tuesday, October 24, 2017 7:54:09 AM CEST Ramesh Thomas wrote:
>>>>> On 2017-10-20 at 13:27:34 +0200, Rafael J. Wysocki wrote:
>>>
>>>>> >  static ssize_t pm_qos_resume_latency_store(struct device *dev,
>>>>> > @@ -228,11 +235,19 @@ static ssize_t pm_qos_resume_latency_sto
>>>>> >     s32 value;
>>>>> >     int ret;
>>>
>>>>> > +   if (!kstrtos32(buf, 0, &value)) {
>>>>> > +           /*
>>>>> > +            * Prevent users from writing negative or "no constraint" values
>>>>> > +            * directly.
>>>>> > +            */
>>>>> > +           if (value < 0 || value == PM_QOS_RESUME_LATENCY_NO_CONSTRAINT)
>>>>> > +                   return -EINVAL;
>>>
>>>>> > +           if (value == 0)
>>>>> > +                   value = PM_QOS_RESUME_LATENCY_NO_CONSTRAINT;
>>>>> > +   } else if (!strcmp(buf, "n/a") || !strcmp(buf, "n/a\n")) {
>>>>>
>>>>> Can the 2 checks for "n/a" be combined by checking first 3 characters?
>>>>
>>>> No, because "n/asomething" would then match too.
>>>
>>> If I don't missed anything, kernfs is aware of \n which means the
>>> first check is enough.
>>> Am I correct?
>>
>> I'm not sure, honestly. :-)
>
> Okay, just a summary:
> 1. kernfs guarantees that buffer is NULL terminated
> 2. sysfs guarantees that the buffer is not empty
> 3. kstrto* are aware of '\n'
> 4. sysfs_streq() and __sysfs_match_string() are aware of '\n'
>
> Thus, we just may use sysfs_streq() for that.
>
> I will prepare a clean up patch on top of this fix if you are okay with it.

OK, but then please cover all similar cases in this file.

Thanks,
Rafael

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ