Skip to content

Commit a35165c

Browse files
edumazetdavem330
authored andcommitted
ipv4: do not use this_cpu_ptr() in preemptible context
this_cpu_ptr() in preemptible context is generally bad Sep 22 05:05:55 br kernel: [ 94.608310] BUG: using smp_processor_id() in preemptible [00000000] code: ip/2261 Sep 22 05:05:55 br kernel: [ 94.608316] caller is tunnel_dst_set.isra.28+0x20/0x60 [ip_tunnel] Sep 22 05:05:55 br kernel: [ 94.608319] CPU: 3 PID: 2261 Comm: ip Not tainted 3.17.0-rc5 torvalds#82 We can simply use raw_cpu_ptr(), as preemption is safe in these contexts. Should fix https://bugzilla.kernel.org/show_bug.cgi?id=84991 Signed-off-by: Eric Dumazet <edumazet@google.com> Reported-by: Joe <joe9mail@gmail.com> Fixes: 9a4aa9a ("ipv4: Use percpu Cache route in IP tunnels") Acked-by: Tom Herbert <therbert@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 84de67b commit a35165c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/ipv4/ip_tunnel.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ static void __tunnel_dst_set(struct ip_tunnel_dst *idst,
7979
idst->saddr = saddr;
8080
}
8181

82-
static void tunnel_dst_set(struct ip_tunnel *t,
82+
static noinline void tunnel_dst_set(struct ip_tunnel *t,
8383
struct dst_entry *dst, __be32 saddr)
8484
{
85-
__tunnel_dst_set(this_cpu_ptr(t->dst_cache), dst, saddr);
85+
__tunnel_dst_set(raw_cpu_ptr(t->dst_cache), dst, saddr);
8686
}
8787

8888
static void tunnel_dst_reset(struct ip_tunnel *t)
@@ -106,7 +106,7 @@ static struct rtable *tunnel_rtable_get(struct ip_tunnel *t,
106106
struct dst_entry *dst;
107107

108108
rcu_read_lock();
109-
idst = this_cpu_ptr(t->dst_cache);
109+
idst = raw_cpu_ptr(t->dst_cache);
110110
dst = rcu_dereference(idst->dst);
111111
if (dst && !atomic_inc_not_zero(&dst->__refcnt))
112112
dst = NULL;

0 commit comments

Comments
 (0)