[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <083dceba-cc14-5aaf-1661-0ce5e29f161a@nvidia.com>
Date: Sat, 25 Feb 2023 09:53:50 +0200
From: Paul Blakey <paulb@...dia.com>
To: Eric Dumazet <edumazet@...gle.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 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.
Powered by blists - more mailing lists