All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiang Mei <xmei5@asu.edu>
To: Cong Wang <xiyou.wangcong@gmail.com>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com, will@willsroot.io,
	stephen@networkplumber.org
Subject: Re: [Patch v4 net 2/6] net_sched: Check the return value of qfq_choose_next_agg()
Date: Sun, 20 Jul 2025 16:34:44 -0700	[thread overview]
Message-ID: <aH19FKJmOfHHbdYo@xps> (raw)
In-Reply-To: <20250719220341.1615951-3-xiyou.wangcong@gmail.com>

On Sat, Jul 19, 2025 at 03:03:37PM -0700, Cong Wang wrote:
> qfq_choose_next_agg() could return NULL so its return value should be
> properly checked unless NULL is acceptable.
> 
> There are two cases we need to deal with:
> 
> 1) q->in_serv_agg, which is okay with NULL since it is either checked or
>    just compared with other pointer without dereferencing. In fact, it
>    is even intentionally set to NULL in one of the cases.
> 
> 2) in_serv_agg, which is a temporary local variable, which is not okay
>    with NULL, since it is dereferenced immediately, hence must be checked.
> 
> This fix corrects one of the 2nd cases, and leaving the 1st case as they are.
> 
> Although this bug is triggered with the netem duplicate change, the root
> cause is still within qfq qdisc.
> 
> Fixes: 462dbc9101ac ("pkt_sched: QFQ Plus: fair-queueing service at DRR cost")
> Cc: Xiang Mei <xmei5@asu.edu>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
> ---
>  net/sched/sch_qfq.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
> index f0eb70353744..f328a58c7b98 100644
> --- a/net/sched/sch_qfq.c
> +++ b/net/sched/sch_qfq.c
> @@ -1147,6 +1147,8 @@ static struct sk_buff *qfq_dequeue(struct Qdisc *sch)
>  		 * choose the new aggregate to serve.
>  		 */
>  		in_serv_agg = q->in_serv_agg = qfq_choose_next_agg(q);
> +		if (!in_serv_agg)
> +			return NULL;
>  		skb = qfq_peek_skb(in_serv_agg, &cl, &len);
>  	}
>  	if (!skb)
> -- 
> 2.34.1
>
Reviewed-by: Xiang Mei <xmei5@asu.edu>

Thanks for the explanations and fix. The fix makes sense to me.

  reply	other threads:[~2025-07-20 23:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-19 22:03 [Patch v4 net 0/6] netem: Fix skb duplication logic and prevent infinite loops Cong Wang
2025-07-19 22:03 ` [Patch v4 net 1/6] net_sched: Implement the right netem duplication behavior Cong Wang
2025-07-19 22:03 ` [Patch v4 net 2/6] net_sched: Check the return value of qfq_choose_next_agg() Cong Wang
2025-07-20 23:34   ` Xiang Mei [this message]
2025-07-19 22:03 ` [Patch v4 net 3/6] selftests/tc-testing: Add a nested netem duplicate test Cong Wang
2025-07-19 22:03 ` [Patch v4 net 4/6] selftests/tc-testing: Add a test case for piro with netem duplicate Cong Wang
2025-07-19 22:03 ` [Patch v4 net 5/6] selftests/tc-testing: Add a test case for mq " Cong Wang
2025-07-19 22:03 ` [Patch v4 net 6/6] selftests/tc-testing: Update test cases " Cong Wang
2025-07-21 14:00 ` [Patch v4 net 0/6] netem: Fix skb duplication logic and prevent infinite loops Jamal Hadi Salim
2025-07-21 14:27   ` Jamal Hadi Salim
2025-07-21 14:54   ` Stephen Hemminger
2025-07-30 19:17   ` Cong Wang
2025-08-01 22:04     ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aH19FKJmOfHHbdYo@xps \
    --to=xmei5@asu.edu \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=will@willsroot.io \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.