WSL2-Linux-Kernel/drivers/staging/octeon
David Daney a620c16326 Staging: octeon-ethernet: Fix race freeing transmit buffers.
The existing code had the following race:

Thread-1                       Thread-2

inc/read in_use
                               inc/read in_use
inc tx_free_list[qos].len
                               inc tx_free_list[qos].len

The actual in_use value was incremented twice, but thread-1 is going
to free memory based on its stale value, and will free one too many
times.  The result is that memory is freed back to the kernel while
its packet is still in the transmit buffer.  If the memory is
overwritten before it is transmitted, the hardware will put a valid
checksum on it and send it out (just like it does with good packets).
If by chance the TCP flags are clobbered but not the addresses or
ports, the result can be a broken TCP stream.

The fix is to track the number of freed packets in a single location
(a Fetch-and-Add Unit register).  That way it can never get out of sync
with itself.

We try to free up to MAX_SKB_TO_FREE (currently 10) buffers at a time.
If fewer are available we adjust the free count with the difference.
The action of claiming buffers to free is atomic so two threads cannot
claim the same buffers.

Signed-off-by: David Daney <ddaney@caviumnetworks.com>
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
2009-06-24 18:34:41 +01:00
..
Kconfig Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
Makefile Staging: octeon-ethernet: Convert to use net_device_ops. 2009-06-24 18:34:41 +01:00
cvmx-address.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-asxx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-cmd-queue.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-cmd-queue.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-config.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-dbg-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-fau.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-fpa-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-fpa.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-fpa.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-gmxx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-board.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-board.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-fpa.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-fpa.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-loop.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-loop.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-npi.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-npi.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-rgmii.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-rgmii.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-sgmii.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-sgmii.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-spi.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-spi.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-util.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-util.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-xaui.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper-xaui.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-helper.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-interrupt-decodes.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-interrupt-rsl.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-ipd.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-mdio.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-packet.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pcsx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pcsxx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pip-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pip.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pko-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pko.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pko.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-pow.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-scratch.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-smix-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-spi.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-spi.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-spxx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-srxx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-stxx-defs.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
cvmx-wqe.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-defines.h Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
ethernet-mdio.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-mdio.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-mem.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-mem.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-proc.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-proc.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-rgmii.c Staging: octeon-ethernet: Convert to use net_device_ops. 2009-06-24 18:34:41 +01:00
ethernet-rx.c Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-rx.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-sgmii.c Staging: octeon-ethernet: Convert to use net_device_ops. 2009-06-24 18:34:41 +01:00
ethernet-spi.c Staging: octeon-ethernet: Convert to use net_device_ops. 2009-06-24 18:34:41 +01:00
ethernet-tx.c Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
ethernet-tx.h Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
ethernet-util.h Staging: Add octeon-ethernet driver files. 2009-06-17 11:06:30 +01:00
ethernet-xaui.c Staging: octeon-ethernet: Convert to use net_device_ops. 2009-06-24 18:34:41 +01:00
ethernet.c Staging: octeon-ethernet: Fix race freeing transmit buffers. 2009-06-24 18:34:41 +01:00
octeon-ethernet.h Staging: octeon-ethernet: Convert to use net_device_ops. 2009-06-24 18:34:41 +01:00