Skip to content

Commit cfae16e

Browse files
dcarattigregkh
authored andcommitted
net/sched: act_mirred: better wording on protection against excessive stack growth
[ Upstream commit 78dcdff ] with commit e2ca070 ("net: sched: protect against stack overflow in TC act_mirred"), act_mirred protected itself against excessive stack growth using per_cpu counter of nested calls to tcf_mirred_act(), and capping it to MIRRED_RECURSION_LIMIT. However, such protection does not detect recursion/loops in case the packet is enqueued to the backlog (for example, when the mirred target device has RPS or skb timestamping enabled). Change the wording from "recursion" to "nesting" to make it more clear to readers. CC: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Davide Caratti <dcaratti@redhat.com> Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> [ skulkarni: Adjusted patch for file 'act_mirred.c' - hunk #4/4 wrt the mainline commit ] Stable-dep-of: ca22da2 ("act_mirred: use the backlog for nested calls to mirred ingress") Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 02ca042 commit cfae16e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

net/sched/act_mirred.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
static LIST_HEAD(mirred_list);
2929
static DEFINE_SPINLOCK(mirred_list_lock);
3030

31-
#define MIRRED_RECURSION_LIMIT 4
32-
static DEFINE_PER_CPU(unsigned int, mirred_rec_level);
31+
#define MIRRED_NEST_LIMIT 4
32+
static DEFINE_PER_CPU(unsigned int, mirred_nest_level);
3333

3434
static bool tcf_mirred_is_act_redirect(int action)
3535
{
@@ -225,7 +225,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
225225
struct sk_buff *skb2 = skb;
226226
bool m_mac_header_xmit;
227227
struct net_device *dev;
228-
unsigned int rec_level;
228+
unsigned int nest_level;
229229
int retval, err = 0;
230230
bool use_reinsert;
231231
bool want_ingress;
@@ -236,11 +236,11 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
236236
int mac_len;
237237
bool at_nh;
238238

239-
rec_level = __this_cpu_inc_return(mirred_rec_level);
240-
if (unlikely(rec_level > MIRRED_RECURSION_LIMIT)) {
239+
nest_level = __this_cpu_inc_return(mirred_nest_level);
240+
if (unlikely(nest_level > MIRRED_NEST_LIMIT)) {
241241
net_warn_ratelimited("Packet exceeded mirred recursion limit on dev %s\n",
242242
netdev_name(skb->dev));
243-
__this_cpu_dec(mirred_rec_level);
243+
__this_cpu_dec(mirred_nest_level);
244244
return TC_ACT_SHOT;
245245
}
246246

@@ -310,7 +310,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
310310
err = tcf_mirred_forward(res->ingress, skb);
311311
if (err)
312312
tcf_action_inc_overlimit_qstats(&m->common);
313-
__this_cpu_dec(mirred_rec_level);
313+
__this_cpu_dec(mirred_nest_level);
314314
return TC_ACT_CONSUMED;
315315
}
316316
}
@@ -322,7 +322,7 @@ static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
322322
if (tcf_mirred_is_act_redirect(m_eaction))
323323
retval = TC_ACT_SHOT;
324324
}
325-
__this_cpu_dec(mirred_rec_level);
325+
__this_cpu_dec(mirred_nest_level);
326326

327327
return retval;
328328
}

0 commit comments

Comments
 (0)