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:   Wed, 17 Jun 2020 16:45:05 -0400
From:   Paul Moore <paul@...l-moore.com>
To:     "Gustavo A. R. Silva" <gustavoars@...nel.org>
Cc:     Eric Paris <eparis@...hat.com>, linux-audit@...hat.com,
        linux-kernel@...r.kernel.org,
        "Gustavo A. R. Silva" <gustavo@...eddedor.com>,
        Kees Cook <keescook@...omium.org>
Subject: Re: [PATCH] audit: Use struct_size() helper in alloc_chunk

On Mon, Jun 1, 2020 at 11:36 AM Paul Moore <paul@...l-moore.com> wrote:
> On Sun, May 24, 2020 at 4:47 PM Gustavo A. R. Silva
> <gustavoars@...nel.org> wrote:
> > One of the more common cases of allocation size calculations is finding
> > the size of a structure that has a zero-sized array at the end, along
> > with memory for some number of elements for that array. For example:
> >
> > struct audit_chunk {
> >         ...
> >         struct node {
> >                 struct list_head list;
> >                 struct audit_tree *owner;
> >                 unsigned index;         /* index; upper bit indicates 'will prune' */
> >         } owners[];
> > };
> >
> > Make use of the struct_size() helper instead of an open-coded version
> > in order to avoid any potential type mistakes.
> >
> > So, replace the following form:
> >
> > offsetof(struct audit_chunk, owners) + count * sizeof(struct node);
> >
> > with:
> >
> > struct_size(chunk, owners, count)
> >
> > This code was detected with the help of Coccinelle.
> >
> > Signed-off-by: Gustavo A. R. Silva <gustavoars@...nel.org>
> > ---
> >  kernel/audit_tree.c | 4 +---
> >  1 file changed, 1 insertion(+), 3 deletions(-)
>
> Thanks, this looks reasonable to me, but it came in too late for the
> v5.8 merge window (I dislike taking changes past -rc5/6 unless
> critical).  Once the merge window closes I'll merge this into
> audit/next.

FYI, I just merged this into audit/next.  Thanks!

-- 
paul moore
www.paul-moore.com

Powered by blists - more mailing lists