From: Victor Nogueira <victor@mojatatu.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, jhs@mojatatu.com, jiri@resnulli.us
Cc: horms@kernel.org, baowen.zheng@corigine.com,
louis.peens@corigine.com, pctammela@mojatatu.com,
netdev@vger.kernel.org
Subject: [PATCH net 4/4] net/sched: act_mirred: account for TCA_MIRRED_BLOCKID in get_fill_size
Date: Mon, 24 Aug 2026 12:39:03 -0300 [thread overview]
Message-ID: <20260824153903.4143642-5-victor@mojatatu.com> (raw)
In-Reply-To: <20260824153903.4143642-1-victor@mojatatu.com>
tcf_mirred_get_fill_size() only budgets TCA_MIRRED_PARMS, but
tcf_mirred_dump() also emits TCA_MIRRED_BLOCKID whenever the action was
created with a block instead of a device. So tcf_mirred_get_fill_size is
missing 8 bytes in its accounting.
Fix this issue by accounting for TCA_MIRRED_BLOCKID unconditionally:
it costs 8 bytes for device-mirred actions and avoids having to read
tcfm_blockid outside tcf_lock, where a concurrent replace could change
it between sizing and dumping.
Note: Dumping mirred with blocks currently works in most use cases, but
would break in some corner cases, for example, if there are 20 blockcast
mirred actions in one request, each with a non-ANY hw_stats and a
non-zero user flag, with a listener on RTNLGRP_TC (or NLM_F_ECHO):
budget 180 B/action -> attr_size = 20*180 + 24 = 3624
-> alloc_skb(3776) = 3776, tailroom exactly 3776
emitted 196 B/action -> 20*196 + 24 = 3944 > 3776
-> tca_get_fill() fails
Fixes: 42f39036cda8 ("net/sched: act_mirred: Allow mirred to block")
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
---
net/sched/act_mirred.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/sched/act_mirred.c b/net/sched/act_mirred.c
index 553342c55cf7..1c98e4d81ebe 100644
--- a/net/sched/act_mirred.c
+++ b/net/sched/act_mirred.c
@@ -607,7 +607,8 @@ tcf_mirred_get_dev(const struct tc_action *a,
static size_t tcf_mirred_get_fill_size(const struct tc_action *act)
{
- return nla_total_size(sizeof(struct tc_mirred));
+ return nla_total_size(sizeof(struct tc_mirred)) /* TCA_MIRRED_PARMS */
+ + nla_total_size(sizeof(u32)); /* TCA_MIRRED_BLOCKID */
}
static void tcf_offload_mirred_get_dev(struct flow_action_entry *entry,
--
2.55.0
next prev parent reply other threads:[~2026-08-24 15:39 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-24 15:38 [PATCH net 0/4] net/sched: Fix remaining actions notification accounting issues Victor Nogueira
2026-08-24 15:39 ` [PATCH net 1/4] net/sched: act_api: budget all shared attributes in notify skbs Victor Nogueira
2026-08-27 8:44 ` Simon Horman
2026-08-27 18:37 ` Victor Nogueira
2026-08-24 15:39 ` [PATCH net 2/4] net/sched: act_api: size the RTM_GETACTION reply from the actions Victor Nogueira
2026-08-27 8:49 ` Simon Horman
2026-08-27 18:38 ` Victor Nogueira
2026-08-24 15:39 ` [PATCH net 3/4] net/sched: act_api: fix skb sizing and action leak on reoffload delete Victor Nogueira
2026-08-25 15:36 ` Pedro Tammela
2026-08-24 15:39 ` Victor Nogueira [this message]
2026-08-27 8:53 ` [PATCH net 4/4] net/sched: act_mirred: account for TCA_MIRRED_BLOCKID in get_fill_size Simon Horman
2026-08-27 18:39 ` Victor Nogueira
2026-08-27 9:24 ` Paolo Abeni
2026-08-27 18:40 ` Victor Nogueira
2026-08-28 23:10 ` [PATCH net 0/4] net/sched: Fix remaining actions notification accounting issues patchwork-bot+netdevbpf
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=20260824153903.4143642-5-victor@mojatatu.com \
--to=victor@mojatatu.com \
--cc=baowen.zheng@corigine.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=louis.peens@corigine.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pctammela@mojatatu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox