From: Jakub Kicinski <kuba@kernel.org>
To: p@1g4.org
Cc: Jakub Kicinski <kuba@kernel.org>,
stable@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [net,v1,2/3] net/sched: act_gate: fix schedule updates with RCU swap
Date: Mon, 19 Jan 2026 11:12:38 -0800 [thread overview]
Message-ID: <20260119191238.1240882-1-kuba@kernel.org> (raw)
In-Reply-To: <20260116112522.159480-3-p@1g4.org>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
net/sched: act_gate: fix schedule updates with RCU swap
This patch switches act_gate parameters to an RCU-protected pointer and
uses prepare-then-swap to avoid races during schedule updates.
> diff --git a/net/sched/act_gate.c b/net/sched/act_gate.c
> index c1f75f272757..6934df233df5 100644
> --- a/net/sched/act_gate.c
> +++ b/net/sched/act_gate.c
[ ... ]
> + if (!list_empty(&newp.entries)) {
> + list_splice_init(&newp.entries, &p->entries);
> + p->num_entries = newp.num_entries;
> + } else if (ret != ACT_P_CREATED) {
> + struct tcfg_gate_entry *entry, *ne;
> +
> + list_for_each_entry(entry, &oldp->entries, list) {
> + ne = kmemdup(entry, sizeof(*ne), GFP_KERNEL);
> + if (!ne) {
> + err = -ENOMEM;
> + goto free_p;
> + }
> + INIT_LIST_HEAD(&ne->list);
> + list_add_tail(&ne->list, &p->entries);
> + }
> + p->num_entries = oldp->num_entries;
> + }
[ ... ]
> +free_p:
> + kfree(p);
When kmemdup() fails partway through the loop copying entries from
oldp->entries to p->entries, can the entries already added to p->entries
be leaked? The jump to free_p calls kfree(p) but p->entries may contain
allocated entries that are not released first.
The release_entry_list() call at release_new_entries releases newp.entries
rather than p->entries:
> +release_new_entries:
> + release_entry_list(&newp.entries);
It looks like release_entry_list(&p->entries) should be called before
kfree(p) at the free_p label.
next prev parent reply other threads:[~2026-01-19 19:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 11:25 [PATCH net v1 0/3] act_gate fixes and gate selftest update Paul Moses
2026-01-16 11:25 ` [PATCH net v1 1/3] selftests: tc-testing: fix gate replace schedule Paul Moses
2026-01-16 11:26 ` [PATCH net v1 2/3] net/sched: act_gate: fix schedule updates with RCU swap Paul Moses
2026-01-19 19:12 ` Jakub Kicinski [this message]
2026-01-16 11:26 ` [PATCH net v1 3/3] net/sched: act_gate: zero-initialize netlink dump struct Paul Moses
2026-01-19 19:14 ` Jakub Kicinski
2026-01-19 18:32 ` [PATCH net v1 0/3] act_gate fixes and gate selftest update Jakub Kicinski
2026-01-19 18:50 ` Paul Moses
2026-01-19 19:12 ` Jakub Kicinski
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=20260119191238.1240882-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=p@1g4.org \
--cc=stable@vger.kernel.org \
/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