• Antoine Tenart's avatar
    net: embed num_tc in the xps maps · 255c04a8
    Antoine Tenart authored
    The xps cpus/rxqs map is accessed using dev->num_tc, which is used when
    allocating the map. But later updates of dev->num_tc can lead to having
    a mismatch between the maps and how they're accessed. In such cases the
    map values do not make any sense and out of bound accesses can occur
    (that can be easily seen using KASAN).
    
    This patch aims at fixing this by embedding num_tc into the maps, using
    the value at the time the map is created. This brings two improvements:
    - The maps can be accessed using the embedded num_tc, so we know for
      sure we won't have out of bound accesses.
    - Checks can be made before accessing the maps so we know the values
      retrieved will make sense.
    
    We also update __netif_set_xps_queue to conditionally copy old maps from
    dev_maps in the new one only if the number of traffic classes from both
    maps match.
    Signed-off-by: default avatarAntoine Tenart <atenart@kernel.org>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    255c04a8
dev.c 287 KB