Netdev List
 help / color / mirror / Atom feed
From: Kuniyuki Iwashima <kuniyu@google.com>
To: yuyanghuang@google.com
Cc: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com,
	 horms@kernel.org, idosch@nvidia.com, kuba@kernel.org,
	 linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com,  stable@vger.kernel.org,
	xiyou.wangcong@gmail.com,  Kuniyuki Iwashima <kuniyu@google.com>
Subject: Re: [PATCH net v3] ipv4: igmp: remove multicast group from hash table on device destruction
Date: Thu,  2 Jul 2026 05:49:42 +0000	[thread overview]
Message-ID: <20260702054952.639157-1-kuniyu@google.com> (raw)
In-Reply-To: <20260701235014.73505-1-yuyanghuang@google.com>

From: Yuyang Huang <yuyanghuang@google.com>
Date: Thu,  2 Jul 2026 08:50:14 +0900
> When a device is destroyed under RTNL, ip_mc_destroy_dev() iterates through
> the multicast list and calls ip_ma_put() on each membership, scheduling
> them for RCU reclamation. However, they are not unlinked from the device's
> multicast hash table (mc_hash).
> 
> Since the device remains published in dev->ip_ptr until after
> ip_mc_destroy_dev() completes, concurrent RCU readers traversing mc_hash
> can still locate and access the multicast group after its refcount is
> decremented. If the RCU callback runs and frees the group while a reader is
> accessing it, a use-after-free occurs.
> 
> Fix this by unlinking the multicast group from mc_hash using
> ip_mc_hash_remove() before scheduling it for reclamation.
> 
> BUG: KASAN: slab-use-after-free in ip_check_mc_rcu+0x149/0x3f0
> Read of size 4 at addr ffff888009bf1408 by task mausezahn/2276
> 
> Call Trace:
>  <IRQ>
>  dump_stack_lvl+0x67/0x90
>  print_report+0x175/0x7c0
>  kasan_report+0x147/0x180
>  ip_check_mc_rcu+0x149/0x3f0
>  udp_v4_early_demux+0x36d/0x12d0
>  ip_rcv_finish_core+0xb8b/0x1390
>  ip_rcv_finish+0x54/0x120
>  NF_HOOK+0x213/0x2b0
>  __netif_receive_skb+0x126/0x340
>  process_backlog+0x4f2/0xf00
>  __napi_poll+0x92/0x2c0
>  net_rx_action+0x583/0xc60
>  handle_softirqs+0x236/0x7f0
>  do_softirq+0x57/0x80
>  </IRQ>
> 
> Allocated by task 2239:
>  kasan_save_track+0x3e/0x80
>  __kasan_kmalloc+0x72/0x90
>  ____ip_mc_inc_group+0x31a/0xa40
>  __ip_mc_join_group+0x334/0x3f0
>  do_ip_setsockopt+0x16fa/0x2010
>  ip_setsockopt+0x3f/0x90
>  do_sock_setsockopt+0x1ad/0x300
> 
> Freed by task 0:
>  kasan_save_track+0x3e/0x80
>  kasan_save_free_info+0x40/0x50
>  __kasan_slab_free+0x3a/0x60
>  __rcu_free_sheaf_prepare+0xd4/0x220
>  rcu_free_sheaf+0x36/0x190
>  rcu_core+0x8d9/0x12f0
>  handle_softirqs+0x236/0x7f0
> 
> Fixes: e9897071350b ("igmp: hash a hash table to speedup ip_check_mc_rcu()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuyang Huang <yuyanghuang@google.com>

Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>

  reply	other threads:[~2026-07-02  5:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 23:50 [PATCH net v3] ipv4: igmp: remove multicast group from hash table on device destruction Yuyang Huang
2026-07-02  5:49 ` Kuniyuki Iwashima [this message]
2026-07-02  7:05 ` Ido Schimmel

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=20260702054952.639157-1-kuniyu@google.com \
    --to=kuniyu@google.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yuyanghuang@google.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