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]
Date:   Sat, 25 Feb 2023 09:14:44 +0100
From:   Eric Dumazet <edumazet@...gle.com>
To:     Paul Blakey <paulb@...dia.com>
Cc:     netdev@...r.kernel.org, Saeed Mahameed <saeedm@...dia.com>,
        Paolo Abeni <pabeni@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Jamal Hadi Salim <jhs@...atatu.com>,
        Cong Wang <xiyou.wangcong@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Marcelo Ricardo Leitner <marcelo.leitner@...il.com>,
        Oz Shlomo <ozsh@...dia.com>, Jiri Pirko <jiri@...dia.com>,
        Roi Dayan <roid@...dia.com>, Vlad Buslov <vladbu@...dia.com>,
        Ido Schimmel <idosch@...dia.com>,
        Simon Horman <simon.horman@...igine.com>
Subject: Re: [PATCH net-next v13 3/8] net/sched: flower: Move filter handle
 initialization earlier

On Sat, Feb 25, 2023 at 8:54 AM Paul Blakey <paulb@...dia.com> wrote:
>
>
>
> On 23/02/2023 12:24, Eric Dumazet wrote:
> > On Fri, Feb 17, 2023 at 11:36 PM Paul Blakey <paulb@...dia.com> wrote:
> >>
> >> To support miss to action during hardware offload the filter's
> >> handle is needed when setting up the actions (tcf_exts_init()),
> >> and before offloading.
> >>
> >> Move filter handle initialization earlier.
> >>
> >> Signed-off-by: Paul Blakey <paulb@...dia.com>
> >> Reviewed-by: Jiri Pirko <jiri@...dia.com>
> >> Reviewed-by: Simon Horman <simon.horman@...igine.com>
> >> Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@...il.com>
> >> ---
> >
> > Error path is now potentially crashing because net pointer has not
> > been initialized.
> >
> > I plan fixing this issue with the following:
> >
> > diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
> > index e960a46b05205bb0bca7dc0d21531e4d6a3853e3..475fe222a85566639bac75fc4a95bf649a10357d
> > 100644
> > --- a/net/sched/cls_flower.c
> > +++ b/net/sched/cls_flower.c
> > @@ -2200,8 +2200,9 @@ static int fl_change(struct net *net, struct
> > sk_buff *in_skb,
> >                  fnew->flags = nla_get_u32(tb[TCA_FLOWER_FLAGS]);
> >
> >                  if (!tc_flags_valid(fnew->flags)) {
> > +                       kfree(fnew);
> >                          err = -EINVAL;
> > -                       goto errout;
> > +                       goto errout_tb;
> >                  }
> >          }
> >
> > @@ -2226,8 +2227,10 @@ static int fl_change(struct net *net, struct
> > sk_buff *in_skb,
> >                  }
> >                  spin_unlock(&tp->lock);
> >
> > -               if (err)
> > -                       goto errout;
> > +               if (err) {
> > +                       kfree(fnew);
> > +                       goto errout_tb;
> > +               }
> >          }
> >          fnew->handle = handle;
> >
> > @@ -2337,7 +2340,6 @@ static int fl_change(struct net *net, struct
> > sk_buff *in_skb,
> >          fl_mask_put(head, fnew->mask);
> >   errout_idr:
> >          idr_remove(&head->handle_idr, fnew->handle);
> > -errout:
> >          __fl_put(fnew);
> >   errout_tb:
> >          kfree(tb);
>
>
> Notice that the bug was before this patch as well.
> We init exts->net only in  fl_set_parms()->tcf_exts_validate(exts), and
> before this patch we called __fl_put() on two errors before that (like
> if tcf_exts_init() failed).
>
>
> Here, its the same, we can't call __fl_put(fnew) till we called
> fl_set_parms(). So you're missing this "goto errorout_idr":
>
>
>         err = tcf_exts_init_ex(&fnew->exts, net, TCA_FLOWER_ACT, 0, tp, handle,
> !tc_skip_hw(fnew->flags));
>         if (err < 0)
>                 goto errout_idr;
>
> Thanks,
> Paul.
>

The bug I am talking about is triggering because ->net pointer is not
initialized.

->net pointer is initialized in  tcf_exts_init_ex(), before any error
can be returned.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ