[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89i+2KYH+DKrNPttbmrvx992P+ufgo=QWyvr1Ku6b=1BY0Q@mail.gmail.com>
Date: Mon, 14 Feb 2022 17:54:27 -0800
From: Eric Dumazet <edumazet@...gle.com>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: Eric Dumazet <eric.dumazet@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
netdev <netdev@...r.kernel.org>,
Jamal Hadi Salim <jhs@...atatu.com>,
Jiri Pirko <jiri@...nulli.us>,
syzbot <syzkaller@...glegroups.com>
Subject: Re: [PATCH net] net: sched: limit TC_ACT_REPEAT loops
On Mon, Feb 14, 2022 at 5:41 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> On Mon, Feb 14, 2022 at 12:34:34PM -0800, Eric Dumazet wrote:
> > From: Eric Dumazet <edumazet@...gle.com>
> > diff --git a/net/sched/act_api.c b/net/sched/act_api.c
> > index 32563cef85bfa29679f3790599b9d34ebd504b5c..b1fb395ca7c1e12945dc70219608eb166e661203 100644
> > --- a/net/sched/act_api.c
> > +++ b/net/sched/act_api.c
> > @@ -1037,6 +1037,7 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
> > restart_act_graph:
> > for (i = 0; i < nr_actions; i++) {
> > const struct tc_action *a = actions[i];
> > + int repeat_ttl;
> >
> > if (jmp_prgcnt > 0) {
> > jmp_prgcnt -= 1;
> > @@ -1045,11 +1046,17 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions,
> >
> > if (tc_act_skip_sw(a->tcfa_flags))
> > continue;
> > +
> > + repeat_ttl = 10;
>
> Not sure if there is any use case of repeat action with 10+ repeats...
> Use a sufficiently larger one to be 100% safe?
I have no idea of what the practical limit would be ?
100, 1000, time limit ?
>
> > repeat:
> > ret = a->ops->act(skb, a, res);
> > - if (ret == TC_ACT_REPEAT)
> > - goto repeat; /* we need a ttl - JHS */
> > -
> > + if (unlikely(ret == TC_ACT_REPEAT)) {
> > + if (--repeat_ttl != 0)
> > + goto repeat;
> > + /* suspicious opcode, stop pipeline */
>
> This comment looks not match and unnecessary?
This is copied from the comments found in the following lines.
/* faulty opcode, stop pipeline */
and
else /* faulty graph, stop pipeline */
To me it is not clear why we return TC_ACT_OK and not TC_ACT_SHOT for
' faulty opcode/graph '
>
> > + pr_err_once("TC_ACT_REPEAT abuse ?\n");
>
> Usually we use net_warn_ratelimited().
Yep
Powered by blists - more mailing lists