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] [thread-next>] [day] [month] [year] [list]
Message-ID: <x49tvpd78rq.fsf@segfault.boston.devel.redhat.com>
Date:   Thu, 05 Jul 2018 16:00:25 -0400
From:   Jeff Moyer <jmoyer@...hat.com>
To:     Dan Williams <dan.j.williams@...el.com>
Cc:     Matthew Wilcox <willy@...radead.org>,
        Johannes Thumshirn <jthumshirn@...e.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ross Zwisler <ross.zwisler@...ux.intel.com>,
        Vishal Verma <vishal.l.verma@...el.com>,
        Dave Jiang <dave.jiang@...el.com>,
        Christoph Hellwig <hch@....de>,
        linux-nvdimm <linux-nvdimm@...ts.01.org>,
        Linux MM <linux-mm@...ck.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 13/13] libnvdimm, namespace: Publish page structure init state / control

Dan Williams <dan.j.williams@...el.com> writes:

> On Thu, Jul 5, 2018 at 12:49 PM, Matthew Wilcox <willy@...radead.org> wrote:
>> On Thu, Jul 05, 2018 at 07:46:05AM -0700, Dan Williams wrote:
>>> On Thu, Jul 5, 2018 at 1:29 AM, Johannes Thumshirn <jthumshirn@...e.de> wrote:
>>> > On Wed, Jul 04, 2018 at 11:50:13PM -0700, Dan Williams wrote:
>>> >> +static ssize_t memmap_state_store(struct device *dev,
>>> >> +             struct device_attribute *attr, const char *buf, size_t len)
>>> >> +{
>>> >> +     int i;
>>> >> +     struct nd_pfn *nd_pfn = to_nd_pfn_safe(dev);
>>> >> +     struct memmap_async_state *async = &nd_pfn->async;
>>> >> +
>>> >> +     if (strcmp(buf, "sync") == 0)
>>> >> +             /* pass */;
>>> >> +     else if (strcmp(buf, "sync\n") == 0)
>>> >> +             /* pass */;
>>> >> +     else
>>> >> +             return -EINVAL;
>>> >
>>> > Hmm what about:
>>> >
>>> >         if (strncmp(buf, "sync", 4))
>>> >            return -EINVAL;
>>> >
>>> > This collapses 6 lines into 4.
>>>
>>> ...but that also allows 'echo "syncAndThenSomeGarbage" >
>>> /sys/.../memmap_state' to succeed.
>>
>>         if (strncmp(buf, "sync", 4))
>>                 return -EINVAL;
>>         if (buf[4] != '\0' && buf[4] != '\n')
>>                 return -EINVAL;
>>
>
> Not sure that's a win either, I'd rather just:
>
> +       if (strcmp(buf, "sync") == 0 || strcmp(buf, "sync\n") == 0)
> +               /* pass */;
> +       else
> +               return -EINVAL;
>
> If we're trying to save those 2 lines.

WFM.  I don't like that I had to go digging around in sysfs
documentation to convince myself that strcmp was safe, but I guess
that's my problem.  ;-)

Cheers,
Jeff

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ