Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Jérémy Jean
Thu, 08 Oct 2026 18:13
[PATCH net v2] net/sched: fix use-after-free in __tcf_action_put()
Author: Jérémy Jean
Date: Thu, 08 Oct 2026 18:13
Date: Thu, 08 Oct 2026 18:13
57 lines
8230 bytes
8230 bytes
__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
Re: [PATCH net v2] net/sched: fix use-after-free in __tcf_action_put()
Author: Simon Horman
Date: Sat, 10 Oct 2026 14:51
Date: Sat, 10 Oct 2026 14:51
25 lines
6327 bytes
6327 bytes
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>
Re: [PATCH net v2] net/sched: fix use-after-free in __tcf_action_put()
Author: patchwork-bot+netdevbpf
Date: Thu, 15 Oct 2026 11:10
Date: Thu, 15 Oct 2026 11:10
25 lines
6303 bytes
6303 bytes
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Thu, 8 Oct 2026 18:13:49 +0000 you 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
>
> [...]
Here is the summary with links:
- [net,v2] net/sched: fix use-after-free in __tcf_action_put()
https://git.kernel.org/netdev/net/c/7b16eb911091
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads