net: fix use after free in xps
authorAntoine Tenart <atenart@kernel.org>
Thu, 18 Mar 2021 18:37:51 +0000 (19:37 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Mar 2021 21:56:22 +0000 (14:56 -0700)
commit2d05bf015308275f7c67a780f70026077285cfc0
treeb73d016a2d2f6a8432ac2f6f04c0d971408723ac
parent2db6cdaebac83c13acb165594b09282fa03cec89
net: fix use after free in xps

When setting up an new dev_maps in __netif_set_xps_queue, we remove and
free maps from unused CPUs/rx-queues near the end of the function; by
calling remove_xps_queue. However it's possible those maps are also part
of the old not-freed-yet dev_maps, which might be used concurrently.
When that happens, a map can be freed while its corresponding entry in
the old dev_maps table isn't NULLed, leading to: "BUG: KASAN:
use-after-free" in different places.

This fixes the map freeing logic for unused CPUs/rx-queues, to also NULL
the map entries from the old dev_maps table.

Signed-off-by: Antoine Tenart <atenart@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/dev.c