https://github.com/torvalds/linux
Revision a620c1632629b42369e78448acc7b384fe1faf48 authored by David Daney on 23 June 2009, 23:20:56 UTC, committed by Ralf Baechle on 24 June 2009, 17:34:41 UTC
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>
1 parent f696a10
Tip revision: a620c1632629b42369e78448acc7b384fe1faf48 authored by David Daney on 23 June 2009, 23:20:56 UTC
Staging: octeon-ethernet: Fix race freeing transmit buffers.
Staging: octeon-ethernet: Fix race freeing transmit buffers.
Tip revision: a620c16
File | Mode | Size |
---|---|---|
Documentation | ||
arch | ||
block | ||
crypto | ||
drivers | ||
firmware | ||
fs | ||
include | ||
init | ||
ipc | ||
kernel | ||
lib | ||
mm | ||
net | ||
samples | ||
scripts | ||
security | ||
sound | ||
tools | ||
usr | ||
virt | ||
.gitignore | -rw-r--r-- | 945 bytes |
.mailmap | -rw-r--r-- | 3.9 KB |
COPYING | -rw-r--r-- | 18.3 KB |
CREDITS | -rw-r--r-- | 91.7 KB |
Kbuild | -rw-r--r-- | 2.4 KB |
MAINTAINERS | -rw-r--r-- | 147.7 KB |
Makefile | -rw-r--r-- | 53.8 KB |
README | -rw-r--r-- | 17.0 KB |
REPORTING-BUGS | -rw-r--r-- | 3.1 KB |
Computing file changes ...