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]
Message-ID: <CAAa=b7dvEwg_6YJO5m4JaTdPcsaCOmDACCrof2o=7sw=Ew+OHA@mail.gmail.com>
Date:   Fri, 19 Apr 2019 20:46:08 -0500
From:   Wenwen Wang <wang6495@....edu>
To:     Paul Moore <paul@...l-moore.com>
Cc:     Eric Paris <eparis@...hat.com>,
        "moderated list:AUDIT SUBSYSTEM" <linux-audit@...hat.com>,
        open list <linux-kernel@...r.kernel.org>,
        Wenwen Wang <wang6495@....edu>
Subject: Re: [PATCH v2] audit: fix a memory leak bug

On Fri, Apr 19, 2019 at 2:28 PM Paul Moore <paul@...l-moore.com> wrote:
>
> On Fri, Apr 19, 2019 at 11:10 AM Wenwen Wang <wang6495@....edu> wrote:
> >
> > In audit_rule_change(), audit_data_to_entry() is firstly invoked to
> > translate the payload data to the kernel's rule representation. In
> > audit_data_to_entry(), depending on the audit field type, an audit tree may
> > be created in audit_make_tree(), which eventually invokes kmalloc() to
> > allocate the tree.  Since this tree is a temporary tree, it will be then
> > freed in the following execution, e.g., audit_add_rule() if the message
> > type is AUDIT_ADD_RULE or audit_del_rule() if the message type is
> > AUDIT_DEL_RULE. However, if the message type is neither AUDIT_ADD_RULE nor
> > AUDIT_DEL_RULE, i.e., the default case of the switch statement, this
> > temporary tree is not freed.
> >
> > To fix this issue, only allocate the tree when the type is AUDIT_ADD_RULE
> > or AUDIT_DEL_RULE.
> >
> > Signed-off-by: Wenwen Wang <wang6495@....edu>
> > ---
> >  kernel/auditfilter.c | 16 +++++++++++-----
> >  1 file changed, 11 insertions(+), 5 deletions(-)
>
> This looks good, it just needs some minor vertical whitespace fixes (see below).
>
> > diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
> > index 63f8b3f..923b858 100644
> > --- a/kernel/auditfilter.c
> > +++ b/kernel/auditfilter.c
> > @@ -1114,22 +1114,28 @@ int audit_rule_change(int type, int seq, void *data, size_t datasz)
> >         int err = 0;
> >         struct audit_entry *entry;
> >
> > -       entry = audit_data_to_entry(data, datasz);
> > -       if (IS_ERR(entry))
> > -               return PTR_ERR(entry);
> > -
> >         switch (type) {
> >         case AUDIT_ADD_RULE:
> > +               entry = audit_data_to_entry(data, datasz);
> > +               if (IS_ERR(entry))
> > +                       return PTR_ERR(entry);
> > +
>
> I realize you are taking the blank line from the code above, but we
> probably don't need it here.
>
> >                 err = audit_add_rule(entry);
> >                 audit_log_rule_change("add_rule", &entry->rule, !err);
> >                 break;
> > +
>
> Definitely do not add this blank line.
>
> >         case AUDIT_DEL_RULE:
> > +               entry = audit_data_to_entry(data, datasz);
> > +               if (IS_ERR(entry))
> > +                       return PTR_ERR(entry);
> > +
> >                 err = audit_del_rule(entry);
> >                 audit_log_rule_change("remove_rule", &entry->rule, !err);
> >                 break;
> > +
>
> Same here.
>
Thanks for your comments. I will remove the blank lines.

Wenwen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ