* [PATCH net v2] net/sched: fix use-after-free in __tcf_action_put()
@ 2026-10-08 18:13 Jérémy Jean
2026-10-10 14:51 ` Simon Horman
0 siblings, 1 reply; 2+ messages in thread
From: Jérémy Jean @ 2026-10-08 18:13 UTC (permalink / raw)
To: Jamal Hadi Salim, Jiri Pirko
Cc: Jakub Kicinski, netdev, linux-kernel, Jérémy Jean, stable
__tcf_action_put() decrements the reference count before decrementing the
binding count. Another thread can free the action between these operations,
causing the binding-count update to access freed memory. KASAN reports it
as:
BUG: KASAN: slab-use-after-free in __tcf_action_put+0x327/0x340
Write of size 4 at addr ff11000000d46420 by task tc-put-pause/64
Hold the action IDR mutex across both counter updates and IDR removal,
keeping cleanup outside the lock.
Fixes: 16af6067392c ("net: sched: implement reference counted action release")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
---
Change in v2:
- Invert the condition of the test.
v1: https://lore.kernel.org/all/20260930211839.620410-2-Jeremy.Jean@oss.cyber.gouv.fr/
net/sched/act_api.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index e45a63be397c..9eb1dec14cb1 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -372,9 +372,10 @@ static int __tcf_action_put(struct tc_action *p, bool bind)
{
struct tcf_idrinfo *idrinfo = p->idrinfo;
- if (refcount_dec_and_mutex_lock(&p->tcfa_refcnt, &idrinfo->lock)) {
- if (bind)
- atomic_dec(&p->tcfa_bindcnt);
+ mutex_lock(&idrinfo->lock);
+ if (bind)
+ atomic_dec(&p->tcfa_bindcnt);
+ if (refcount_dec_and_test(&p->tcfa_refcnt)) {
idr_remove(&idrinfo->action_idr, p->tcfa_index);
mutex_unlock(&idrinfo->lock);
@@ -382,9 +383,7 @@ static int __tcf_action_put(struct tc_action *p, bool bind)
return 1;
}
- if (bind)
- atomic_dec(&p->tcfa_bindcnt);
-
+ mutex_unlock(&idrinfo->lock);
return 0;
}
--
2.47.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net v2] net/sched: fix use-after-free in __tcf_action_put()
2026-10-08 18:13 [PATCH net v2] net/sched: fix use-after-free in __tcf_action_put() Jérémy Jean
@ 2026-10-10 14:51 ` Simon Horman
0 siblings, 0 replies; 2+ messages in thread
From: Simon Horman @ 2026-10-10 14:51 UTC (permalink / raw)
To: Jérémy Jean
Cc: Jamal Hadi Salim, Jiri Pirko, Jakub Kicinski, netdev,
linux-kernel, stable
On Thu, Oct 08, 2026 at 06:13:49PM +0000, Jérémy Jean wrote:
> __tcf_action_put() decrements the reference count before decrementing the
> binding count. Another thread can free the action between these operations,
> causing the binding-count update to access freed memory. KASAN reports it
> as:
>
> BUG: KASAN: slab-use-after-free in __tcf_action_put+0x327/0x340
> Write of size 4 at addr ff11000000d46420 by task tc-put-pause/64
>
> Hold the action IDR mutex across both counter updates and IDR removal,
> keeping cleanup outside the lock.
>
> Fixes: 16af6067392c ("net: sched: implement reference counted action release")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Jérémy Jean <Jeremy.Jean@oss.cyber.gouv.fr>
> ---
>
> Change in v2:
> - Invert the condition of the test.
>
> v1: https://lore.kernel.org/all/20260930211839.620410-2-Jeremy.Jean@oss.cyber.gouv.fr/
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-10 14:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-08 18:13 [PATCH net v2] net/sched: fix use-after-free in __tcf_action_put() Jérémy Jean
2026-10-10 14:51 ` Simon Horman
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®