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: <CAHp75Vd1kx63WPOYb0KsSCHvazEv8=7-qcn3E+QBmdRBrztpMw@mail.gmail.com>
Date:   Fri, 5 Feb 2021 13:07:59 +0200
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Alexandru Ardelean <ardeleanalex@...il.com>
Cc:     Alexandru Ardelean <alexandru.ardelean@...log.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        linux-iio <linux-iio@...r.kernel.org>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Michael Hennerich <Michael.Hennerich@...log.com>,
        Jonathan Cameron <jic23@...nel.org>,
        Nuno Sá <nuno.sa@...log.com>,
        "Bogdan, Dragos" <dragos.bogdan@...log.com>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v3 06/11] iio: core: merge buffer/ & scan_elements/ attributes

On Thu, Feb 4, 2021 at 3:41 PM Alexandru Ardelean
<ardeleanalex@...il.com> wrote:
> On Wed, Feb 3, 2021 at 12:04 PM Andy Shevchenko
> <andy.shevchenko@...il.com> wrote:
> > On Mon, Feb 1, 2021 at 5:28 PM Alexandru Ardelean
> > <alexandru.ardelean@...log.com> wrote:

...

> > > +       group->attrs = kcalloc(buffer_attrcount + 1,
> > > +                              sizeof(struct attribute *), GFP_KERNEL);
> > > +       if (!group->attrs)
> > > +               return -ENOMEM;
> > > +
> > > +       memcpy(group->attrs, buffer_attrs,
> > > +              buffer_attrcount * sizeof(struct attribute *));
> >
> > kmemdup() ?
> > Perhaps introduce kmemdup_array().
>
> doesn't add much benefit from what i can tell;
> and it complicates things with the fact that we need to add the extra
> null terminator element;
> [1] if we kmemdup(buffer_attrcount + 1) , the copy an extra element we
> don't need, which needs to be null-ed

Ah, I see now. Thanks for pointing it out!


> > > +       group->attrs = kcalloc(scan_el_attrcount + 1,
> > > +                              sizeof(struct attribute *), GFP_KERNEL);
> > > +       if (!group->attrs) {
> > > +               ret = -ENOMEM;
> > > +               goto error_free_buffer_attrs;
> > > +       }
> > > +
> > > +       memcpy(group->attrs, &buffer_attrs[buffer_attrcount],
> > > +              scan_el_attrcount * sizeof(struct attribute *));
> >
> > Ditto.
>
> continuing from [1]
> here it may be worse, because kmemdup() would copy 1 element from
> undefined memory;


-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ