public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Kai Zen <kai.aizen.dev@gmail.com>
Cc: stable@vger.kernel.org, Kai Aizen <kai@snailsploit.com>
Subject: Re: Subject: [PATCH net] tipc: fix UAF race in tipc_mon_peer_up/down/remove_peer vs bearer teardown
Date: Mon, 30 Mar 2026 07:45:00 +0200	[thread overview]
Message-ID: <2026033051-primate-headache-5bf9@gregkh> (raw)
In-Reply-To: <CALynFi5UR5NUQLn8-rx66AoD72Qn0Chji_m+hVFrXL4cReNJ1A@mail.gmail.com>

On Sun, Mar 29, 2026 at 11:23:49PM +0300, Kai Zen wrote:
> CVE-2025-40280 fixed tipc_mon_reinit_self() accessing monitors[] from a
> workqueue without RTNL.  That patch closed the workqueue path by adding
> rtnl_lock() around the call.
> 
> However, three additional functions in the same subsystem access
> tipc_net->monitors[] from softirq context with no RCU protection at all:
> 
>   tipc_mon_peer_up()      - called from tipc_node_write_unlock()
>   tipc_mon_peer_down()    - called from tipc_node_write_unlock()
>   tipc_mon_remove_peer()  - called from tipc_node_link_down()
> 
> These three are invoked from the packet receive path (tipc_rcv ->
> tipc_node_write_unlock / tipc_node_link_down) and hold only the per-node
> rwlock, not RTNL.
> 
> Concurrently, bearer_disable() -- which always holds RTNL per its own
> inline documentation -- calls tipc_mon_delete(), which:
> 
>   1. acquires mon->lock
>   2. sets tn->monitors[bearer_id] = NULL
>   3. frees all peer entries
>   4. releases mon->lock
>   5. calls kfree(mon)                     <-- no synchronize_rcu()
> 
> The race is structural: there is no shared lock between the data-path
> reader (which reads monitors[id] then acquires mon->lock) and the
> teardown path (which acquires mon->lock, NULLs the slot, then frees).
> A softirq thread can read a non-NULL mon pointer, get preempted, and
> resume after kfree(mon) has run on another CPU, then call
> write_lock_bh(&mon->lock) on freed memory:
> 
>   CPU 0 (softirq / tipc_rcv)            CPU 1 (RTNL / bearer_disable)
>   tipc_mon_peer_up()
>     mon = tipc_monitor(net, id)
>     [mon is non-NULL]
>                                          tipc_mon_delete()
>                                            write_lock_bh(&mon->lock)
>                                            tn->monitors[id] = NULL
>                                            ...
>                                            write_unlock_bh(&mon->lock)
>                                            kfree(mon)
>     write_lock_bh(&mon->lock)   <-- UAF
> 
> The fix mirrors the existing bearer_list[] pattern in the same module:
> convert monitors[] to __rcu, use rcu_assign_pointer() on creation,
> RCU_INIT_POINTER() + synchronize_rcu() on deletion (before the kfree),
> and the appropriate rcu_dereference_bh() vs rtnl_dereference() variant
> at each read site depending on execution context.
> 
> synchronize_rcu() in tipc_mon_delete() is placed after the
> write_unlock_bh() and before timer_shutdown_sync() + kfree() to ensure
> all softirq-context readers that already observed the old pointer have
> completed before the memory is freed.
> 
> Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework")
> Cc: stable@vger.kernel.org
> Signed-off-by: Kai Aizen <kai.aizen.dev@gmail.com>
> ---
>  net/tipc/core.h    |  2 +-
>  net/tipc/monitor.c | 51 ++++++++++++++++++++++++++++++++--------------
>  2 files changed, 37 insertions(+), 16 deletions(-)

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

      reply	other threads:[~2026-03-30  5:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-29 20:23 Subject: [PATCH net] tipc: fix UAF race in tipc_mon_peer_up/down/remove_peer vs bearer teardown Kai Zen
2026-03-30  5:45 ` Greg KH [this message]

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=2026033051-primate-headache-5bf9@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=kai.aizen.dev@gmail.com \
    --cc=kai@snailsploit.com \
    --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