Patch "[PATCH 015/135] e1000: fix data race between tx_ring->next_to_clean" has been added to the 4.4-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
[PATCH 015/135] e1000: fix data race between tx_ring->next_to_clean
to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
0015-e1000-fix-data-race-between-tx_ring-next_to_clean.patch
and it can be found in the queue-4.4 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
234b1ae373e7d281952a1de697ab308b044d9137Mon Sep 17 00:00:00 2001
From: Dmitriy Vyukov <[email protected]>
Date: Tue, 8 Sep 2015 10:52:44 +0200
Subject: [PATCH 015/135] e1000: fix data race between tx_ring->next_to_clean
[ Upstream commit 9eab46b7cb8d0b0dcf014bf7b25e0e72b9e4d929 ]
e1000_clean_tx_irq cleans buffers and sets tx_ring->next_to_clean, then e1000_xmit_frame reuses the cleaned buffers. But there are no memory barriers when buffers gets recycled, so the recycled buffers can be corrupted.
Use smp_store_release to update tx_ring->next_to_clean and smp_load_acquire to read tx_ring->next_to_clean to properly hand off buffers from e1000_clean_tx_irq to e1000_xmit_frame.
The data race was found with KernelThreadSanitizer (KTSAN).
--- drivers/net/ethernet/intel/e1000/e1000.h | 7 +++++-- drivers/net/ethernet/intel/e1000/e1000_main.c | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/e1000/e1000.h +5 -2
@@ -213,8 +213,11 @@ struct e1000_rx_ring { };#define E1000_DESC_UNUSED (R ) \ - ((((R)->next_to_clean > (R)->next_to_use) \ - ? 0 : (R)->count) + (R)->next_to_clean - (R)->next_to_use - 1) +({ \ + unsigned int clean = smp_load_acquire(&(R)->next_to_clean); \ + unsigned int use = READ_ONCE((R)->next_to_use); \ + (clean > use ? 0 : (R)->count) + clean - use - 1; \ +})#define E1000_RX_DESC_EXT (R , i) \ (&(((union e1000_rx_desc_extended *)((R).desc))[i]))
drivers/net/ethernet/intel/e1000/e1000_main.c +4 -1
@@ -3876,7 +3876,10 @@ static bool e1000_clean_tx_irq(struct e1 eop_desc =E1000_TX_DESC (*tx_ring, eop); } - tx_ring->next_to_clean = i; +/* Synchronize with E1000_DESC_UNUSED called from e1000_xmit_frame, +* which will reuse the cleaned buffers. +*/ +smp_store_release (&tx_ring->next_to_clean, i);netdev_completed_queue (netdev, pkts_compl, bytes_compl);
Patches currently in stable-queue which might be from [email protected] are
queue-4.4/0015-e1000-fix-data-race-between-tx_ring-next_to_clean.patch