[PATCH] net: sched: hfsc: dont intepret cls results when asked to drop

Ma Ke posted 1 patch 2 years, 4 months ago
There is a newer version of this series
net/sched/sch_hfsc.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH] net: sched: hfsc: dont intepret cls results when asked to drop
Posted by Ma Ke 2 years, 4 months ago
If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume
res.class contains a valid pointer.

Signed-off-by: Ma Ke <make_ruc2021@163.com>
---
 net/sched/sch_hfsc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index 3554085bc2be..2a76027b14e6 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1135,6 +1135,8 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 	head = &q->root;
 	tcf = rcu_dereference_bh(q->root.filter_list);
 	while (tcf && (result = tcf_classify(skb, NULL, tcf, &res, false)) >= 0) {
+		if (result == TC_ACT_SHOT)
+			return NULL;
 #ifdef CONFIG_NET_CLS_ACT
 		switch (result) {
 		case TC_ACT_QUEUED:
-- 
2.37.2
Re: [PATCH] net: sched: hfsc: dont intepret cls results when asked to drop
Posted by Eric Dumazet 2 years, 4 months ago
On Fri, Sep 15, 2023 at 2:37 PM Ma Ke <make_ruc2021@163.com> wrote:
>
> If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume
> res.class contains a valid pointer.
>
> Signed-off-by: Ma Ke <make_ruc2021@163.com>
> ---
>  net/sched/sch_hfsc.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
> index 3554085bc2be..2a76027b14e6 100644
> --- a/net/sched/sch_hfsc.c
> +++ b/net/sched/sch_hfsc.c
> @@ -1135,6 +1135,8 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
>         head = &q->root;
>         tcf = rcu_dereference_bh(q->root.filter_list);
>         while (tcf && (result = tcf_classify(skb, NULL, tcf, &res, false)) >= 0) {
> +               if (result == TC_ACT_SHOT)
> +                       return NULL;
>  #ifdef CONFIG_NET_CLS_ACT
>                 switch (result) {
>                 case TC_ACT_QUEUED:
> --
> 2.37.2
>

Same comment, already handled at iine 1145