• Herbert Xu's avatar
    [NET]: Fully plug netigh_create/inetdev_destroy race. · cb402627
    Herbert Xu authored
    So here is a patch to make sure that there is a barrier between the
    reading of dev->*_ptr and *dev->neigh_parms.
    
    With these barriers in place, it's clear that *dev->neigh_parms can no
    longer be NULL since once the parms are allocated, that pointer is never
    reset to NULL again.  Therefore I've also removed the parms check in
    these paths.
    
    They were bogus to begin with since if they ever triggered then we'll
    have dead neigh entries stuck in the hash table.
    
    Unfortunately I couldn't arrange for this to happen with DECnet due
    to the dn_db->parms.up() call that's sandwiched between the assignment
    of dev->dn_ptr and dn_db->neigh_parms.  So I've kept the parms check
    there but it will now fail instead of continuing.  I've also added an
    smp_wmb() there so that at least we won't be reading garbage from
    dn_db->neigh_parms.
    
    DECnet is also buggy since there is no locking at all in the destruction
    path.  It either needs locking or RCU like IPv4.
    Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    cb402627
dn_neigh.c 18 KB