Thread (5 messages) 5 messages, 3 authors, 2025-12-23

Re: [PATCH net v2] ipv6: fix a BUG in rt6_get_pcpu_route() under PREEMPT_RT

From: Eric Dumazet <edumazet@google.com>
Date: 2025-12-22 08:51:11
Also in: linux-rt-devel, lkml

On Fri, Dec 19, 2025 at 3:52 AM Jiayuan Chen [off-list ref] wrote:
On PREEMPT_RT kernels, after rt6_get_pcpu_route() returns NULL, the
current task can be preempted. Another task running on the same CPU
may then execute rt6_make_pcpu_route() and successfully install a
pcpu_rt entry. When the first task resumes execution, its cmpxchg()
in rt6_make_pcpu_route() will fail because rt6i_pcpu is no longer
NULL, triggering the BUG_ON(prev). It's easy to reproduce it by adding
mdelay() after rt6_get_pcpu_route().

Using preempt_disable/enable is not appropriate here because
ip6_rt_pcpu_alloc() may sleep.

Fix this by:
1. Removing the BUG_ON and instead handling the race gracefully by
   freeing our allocation and returning the existing pcpu_rt when
   cmpxchg() fails.
2. Keeping the BUG_ON for non-PREEMPT_RT kernels, since preemption
   should not occur in this context and a cmpxchg failure would
   indicate a real bug.

Link: https://syzkaller.appspot.com/bug?extid=9b35e9bc0951140d13e6
Fixes: 951f788a80ff ("ipv6: fix a BUG in rt6_get_pcpu_route()")
I would rather find when PREEMPT_RT was added/enabled, there is no
point blaming such an old commit
which was correct at the time, and forcing pointless backports to old
linux kernels.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help