Message ID | 20220215235305.3272331-1-eric.dumazet@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 5740d068909676d4bdb5c9c00c37a83df7728909 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v2,net] net: sched: limit TC_ACT_REPEAT loops | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net |
netdev/fixes_present | success | Fixes tag present in non-next series |
netdev/subject_prefix | success | Link |
netdev/cover_letter | success | Single patches do not need cover letters |
netdev/patch_count | success | Link |
netdev/header_inline | success | No static functions without inline keyword in header files |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/cc_maintainers | success | CCed 6 of 6 maintainers |
netdev/build_clang | success | Errors and warnings before: 18 this patch: 18 |
netdev/module_param | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Signed-off-by tag matches author and committer |
netdev/verify_fixes | success | Fixes tag looks correct |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 7 this patch: 7 |
netdev/checkpatch | warning | WARNING: Possible repeated word: 'Google' |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/source_inline | success | Was 0 now: 0 |
Hello: This patch was applied to netdev/net.git (master) by Jakub Kicinski <kuba@kernel.org>: On Tue, 15 Feb 2022 15:53:05 -0800 you wrote: > From: Eric Dumazet <edumazet@google.com> > > We have been living dangerously, at the mercy of malicious users, > abusing TC_ACT_REPEAT, as shown by this syzpot report [1]. > > Add an arbitrary limit (32) to the number of times an action can > return TC_ACT_REPEAT. > > [...] Here is the summary with links: - [v2,net] net: sched: limit TC_ACT_REPEAT loops https://git.kernel.org/netdev/net/c/5740d0689096 You are awesome, thank you!
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 32563cef85bfa29679f3790599b9d34ebd504b5c..2811348f3acc0b853f54f001b6e80ce3adbe6ad4 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 = 32; 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 */ + net_warn_ratelimited("TC_ACT_REPEAT abuse ?\n"); + return TC_ACT_OK; + } if (TC_ACT_EXT_CMP(ret, TC_ACT_JUMP)) { jmp_prgcnt = ret & TCA_ACT_MAX_PRIO_MASK; if (!jmp_prgcnt || (jmp_prgcnt > nr_actions)) {