From: Simon Horman <horms@kernel.org>
To: "Hemendra M. Naik" <hemendranaik@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us,
jhs@mojatatu.com, shuah@kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, vishy0777@gmail.com,
tahiliani@nitk.edu.in
Subject: Re: [PATCH net-next v4 1/3] net/sched: sch_fq_pie: add per-flow statistics via class ops
Date: Fri, 31 Jul 2026 10:56:35 +0100 [thread overview]
Message-ID: <20260731095635.GG51943@horms.kernel.org> (raw)
In-Reply-To: <20260727164056.106203-2-hemendranaik@gmail.com>
On Mon, Jul 27, 2026 at 10:10:54PM +0530, Hemendra M. Naik wrote:
...
> +static struct tcf_block *fq_pie_tcf_block(struct Qdisc *sch, unsigned long cl,
> + struct netlink_ext_ack *extack)
> +{
> + struct fq_pie_sched_data *q = qdisc_priv(sch);
> +
> + if (cl)
> + return NULL;
> + return q->block;
> +}
Hi,
The AI-generated review of this patch on netdev-ai [1] reports several
findings. And while I'd appreciate it if you could look over each of them
the one below seems to warrant highlighting here.
[1] https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260727164056.106203-1-hemendranaik%40gmail.com?part=1
Is the side effect of making fq_pie filter-capable intended, and should
it be described in the commit message?
Before this patch fq_pie_qdisc_ops had no .cl_ops, so filter attachment
was rejected in net/sched/cls_api.c:__tcf_qdisc_find():
cops = (*q)->ops->cl_ops;
if (!cops) {
NL_SET_ERR_MSG(extack, "Qdisc not classful");
err = -EINVAL;
q->filter_list was therefore always NULL and the filter branch of
fq_pie_classify() was unreachable since fq_pie was added. With .cl_ops
present and fq_pie_tcf_block() returning q->block, 'tc filter add ...
parent <fq_pie handle>' now succeeds and classifier verdicts plus
classid-driven flow selection become live in the enqueue fast path.
That newly reachable code does not handle TC_ACT_CONSUMED:
net/sched/sch_fq_pie.c:fq_pie_classify() {
result = tcf_classify_qdisc(skb, filter, &res, false);
if (result >= 0) {
switch (result) {
case TC_ACT_STOLEN:
case TC_ACT_QUEUED:
case TC_ACT_TRAP:
*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
fallthrough;
case TC_ACT_SHOT:
return 0;
}
if (TC_H_MIN(res.classid) <= q->flows_cnt)
return TC_H_MIN(res.classid);
}
TC_ACT_CONSUMED is TC_ACT_VALUE_MAX + 1, so it is >= 0 and matches no
case arm, and control reaches the classid path. act_ct produces it
after the skb ownership has already been handed away:
net/sched/act_ct.c:tcf_ct_act() {
out_frag:
if (err != -EINPROGRESS)
tcf_action_inc_drop_qstats(&c->common);
return TC_ACT_CONSUMED;
tcf_action_exec() propagates any value != TC_ACT_PIPE and
__tcf_classify() returns it verbatim. For a filter such as
tc filter add dev eth0 parent 1: matchall action ct
with no flowid, res.classid is 0, TC_H_MIN(0) <= flows_cnt holds and 0
is returned, so fq_pie_qdisc_enqueue() frees the consumed skb a second
time:
idx = fq_pie_classify(skb, sch, &ret);
if (idx == 0) {
if (ret & __NET_XMIT_BYPASS)
qdisc_qstats_drop(sch);
__qdisc_drop(skb, to_free);
and with 'flowid 1:N' a valid flow index is returned instead, so
flow_queue_add() links the already freed skb into q->flows[idx]. Can
fragmented traffic hitting that qdisc then cause a double free or
use-after-free?
That TC_ACT_CONSUMED is expected from qdisc-attached filter chains is
also visible in net/sched/cls_api.c:tcf_qevent_handle(), which has an
explicit case TC_ACT_CONSUMED: arm that must not free the skb.
fq_codel, sfq and cake have the same missing arm, but for fq_pie the
path only becomes reachable with this patch.
...
next prev parent reply other threads:[~2026-07-31 9:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 16:40 [PATCH net-next v4 0/3] net/sched: sch_fq_pie: add per-flow class statistics Hemendra M. Naik
2026-07-27 16:40 ` [PATCH net-next v4 1/3] net/sched: sch_fq_pie: add per-flow statistics via class ops Hemendra M. Naik
2026-07-31 9:56 ` Simon Horman [this message]
2026-07-27 16:40 ` [PATCH net-next v4 2/3] selftests: tc-testing: add fq_pie per-flow class stats test Hemendra M. Naik
2026-07-27 16:40 ` [PATCH net-next v4 3/3] net/sched: pie: correct tc_pie_xstats field documentation Hemendra M. Naik
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=20260731095635.GG51943@horms.kernel.org \
--to=horms@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hemendranaik@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
--cc=tahiliani@nitk.edu.in \
--cc=vishy0777@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.