• Wei Wang's avatar
    ipv6: grab rt->rt6i_ref before allocating pcpu rt · a94b9367
    Wei Wang authored
    After rwlock is replaced with rcu and spinlock, ip6_pol_route() will be
    called with only rcu held. That means rt6 route deletion could happen
    simultaneously with rt6_make_pcpu_rt(). This could potentially cause
    memory leak if rt6_release() is called right before rt6_make_pcpu_rt()
    on the same route.
    
    This patch grabs rt->rt6i_ref safely before calling rt6_make_pcpu_rt()
    to make sure rt6_release() will not get triggered while
    rt6_make_pcpu_rt() is in progress. And rt6_release() is called after
    rt6_make_pcpu_rt() is finished.
    
    Note: As we are incrementing rt->rt6i_ref in ip6_pol_route(), there is a
    very slim chance that fib6_purge_rt() will be triggered unnecessarily
    when deleting a route if ip6_pol_route() running on another thread picks
    this route as well and tries to make pcpu cache for it.
    Signed-off-by: default avatarWei Wang <weiwan@google.com>
    Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    a94b9367
route.c 116 KB