[PATCH net] netlabel: fix a race in netlbl_unlhsh_condremove_iface()
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Nov 27 09:28:11 UTC 2026
> From: Linkui Xiao <xiaolinkui at kylinos.cn>
>
> netlbl_unlhsh_condremove_iface() unlinks an interface entry and queues it
> for freeing without checking ->valid, so it can do both a second time for
> an entry that somebody else has already removed.
>
> netlbl_unlhsh_remove() looks the entry up under RCU, drops the lock,
> removes the address entry and only then calls condremove_iface(). If a
> NETDEV_DOWN notifier runs in between it takes netlbl_unlhsh_lock, clears
> ->valid and does list_del_rcu() plus call_rcu() on the same entry, and
> nothing serialises the notifier against a STATICREMOVE doit, which only
> holds genl_lock. The second list_del_rcu() then dereferences the
> LIST_POISON2 that the first one left in ->prev, and the second call_rcu()
> queues an rcu_head that is already queued, so the entry is freed twice.
>
> The default entry can hit the same thing without any notifier: smackfs
> reaches netlbl_unlhsh_remove() through netlbl_cfg_unlbl_static_del() and
> is not serialised against a concurrent STATICREMOVEDEF, so two callers can
> each remove one address from the same entry and both find it empty.
>
> Check ->valid before unlinking, the way netlbl_unlhsh_netdev_handler() and
> netlbl_domhsh_remove_entry() already do. Everything that invalidates an
> entry does so under netlbl_unlhsh_lock, so the check is reliable.
>
> Fixes: 8cc44579d1bd ("NetLabel: Introduce static network labels for unlabeled connections")
> Signed-off-by: Linkui Xiao <xiaolinkui at kylinos.cn>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127092325.3563681-1-xiaolinkui@126.com?part=1
More information about the Linux-security-module-archive
mailing list