• W
    ipv6: replace dst_hold() with dst_hold_safe() in routing code · d3843fe5
    Wei Wang 提交于
    With rwlock, it is safe to call dst_hold() in the read thread because
    read thread is guaranteed to be separated from write thread.
    However, after we replace rwlock with rcu, it is no longer safe to use
    dst_hold(). A dst might already have been deleted but is waiting for the
    rcu grace period to pass before freeing the memory when a read thread is
    trying to do dst_hold(). This could potentially cause double free issue.
    
    So this commit replaces all dst_hold() with dst_hold_safe() in all read
    thread to avoid this double free issue.
    And in order to make the code more compact, a new function ip6_hold_safe()
    is introduced. It calls dst_hold_safe() first, and if that fails, it will
    either fall back to hold and return net->ipv6.ip6_null_entry or set rt to
    NULL according to the caller's need.
    Signed-off-by: NWei Wang <weiwan@google.com>
    Signed-off-by: NMartin KaFai Lau <kafai@fb.com>
    Signed-off-by: NEric Dumazet <edumazet@google.com>
    Signed-off-by: NDavid S. Miller <davem@davemloft.net>
    d3843fe5
addrconf.c 159.9 KB