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: <CAM_iQpUZRRf91pA3a2dJpa0a+rLY-2jg4c196C9R9_nuS_ovBA@mail.gmail.com>
Date:   Thu, 21 Mar 2019 11:26:56 -0700
From:   Cong Wang <xiyou.wangcong@...il.com>
To:     Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc:     John Hurley <john.hurley@...ronome.com>,
        Jiri Pirko <jiri@...lanox.com>,
        David Miller <davem@...emloft.net>,
        Linux Kernel Network Developers <netdev@...r.kernel.org>,
        Vlad Buslov <vladbu@...lanox.com>, oss-drivers@...ronome.com
Subject: Re: [PATCH net 1/1] net: sched: fix cleanup NULL pointer exception in act_mirr

On Thu, Mar 21, 2019 at 11:22 AM Jakub Kicinski
<jakub.kicinski@...ronome.com> wrote:
>
> On Thu, 21 Mar 2019 11:05:21 -0700, Cong Wang wrote:
> > On Wed, Mar 20, 2019 at 11:12 AM John Hurley <john.hurley@...ronome.com> wrote:
> > >
> > > A new mirred action is created by the tcf_mirred_init function. This
> > > contains a list head struct which is inserted into a global list on
> > > successful creation of a new action. However, after a creation, it is
> > > still possible to error out if the egress device does not exist. This
> > > calls the act_mirr cleanup function via __tcf_idr_release and
> > > __tcf_action_put. This cleanup function tries to delete the list entry
> > > which is as yet uninitialised, leading to a NULL pointer exception.
> >
> > Hmm, good catch but can this be just fixed by initializing it before
> > taking the netdevice refcnt? Like this:
> >
> > @@ -163,6 +163,9 @@ static int tcf_mirred_init(struct net *net, struct
> > nlattr *nla,
> >         m->tcf_action = parm->action;
> >         m->tcfm_eaction = parm->eaction;
> >
> > +       if (ret == ACT_P_CREATED)
> > +               INIT_LIST_HEAD(&m->tcfm_list);
> > +
> >         if (parm->ifindex) {
> >                 dev = dev_get_by_index(net, parm->ifindex);
> >                 if (!dev) {
> >
> > which is also much simpler.
>
> That's the initial way John fixed it, but I asked him to go back to the
> previous way this code was written.
>
> I think having the parameters validated before any allocations happen
> is less error prone, especially with the strange way actions get the
> release call even when init failed.  It's just a more reliable code
> patter for actions' init callback.

The point is a simpler version is better for -net and -stable,
and for review too.

You can always refactor it for net-next if you feel necessary.

Thanks.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ