• Eric Dumazet's avatar
    net: fix possible race in skb_attempt_defer_free() · 97e719a8
    Eric Dumazet authored
    A cpu can observe sd->defer_count reaching 128,
    and call smp_call_function_single_async()
    
    Problem is that the remote CPU can clear sd->defer_count
    before the IPI is run/acknowledged.
    
    Other cpus can queue more packets and also decide
    to call smp_call_function_single_async() while the pending
    IPI was not yet delivered.
    
    This is a common issue with smp_call_function_single_async().
    Callers must ensure correct synchronization and serialization.
    
    I triggered this issue while experimenting smaller threshold.
    Performing the call to smp_call_function_single_async()
    under sd->defer_lock protection did not solve the problem.
    
    Commit 5a18ceca ("smp: Allow smp_call_function_single_async()
    to insert locked csd") replaced an informative WARN_ON_ONCE()
    with a return of -EBUSY, which is often ignored.
    Test of CSD_FLAG_LOCK presence is racy anyway.
    
    Fixes: 68822bdf ("net: generalize skb freeing deferral to per-cpu lists")
    Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    97e719a8
dev.c 286 KB