linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Saeed Mahameed <saeedm@mellanox.com>,
	Tariq Toukan <tariqt@mellanox.com>,
	Martin KaFai Lau <kafai@fb.com>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.17 56/63] net/mlx4_en: Dont reuse RX page when XDP is set
Date: Mon, 23 Jul 2018 14:25:02 +0200	[thread overview]
Message-ID: <20180723122448.472348330@linuxfoundation.org> (raw)
In-Reply-To: <20180723122446.351334162@linuxfoundation.org>

4.17-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Saeed Mahameed <saeedm@mellanox.com>

[ Upstream commit 432e629e56432064761be63bcd5e263c0920430d ]

When a new rx packet arrives, the rx path will decide whether to reuse
the remainder of the page or not according to one of the below conditions:
1. frag_info->frag_stride == PAGE_SIZE / 2
2. frags->page_offset + frag_info->frag_size > PAGE_SIZE;

The first condition is no met for when XDP is set.
For XDP, page_offset is always set to priv->rx_headroom which is
XDP_PACKET_HEADROOM and frag_info->frag_size is around mtu size + some
padding, still the 2nd release condition will hold since
XDP_PACKET_HEADROOM + 1536 < PAGE_SIZE, as a result the page will not
be released and will be _wrongly_ reused for next free rx descriptor.

In XDP there is an assumption to have a page per packet and reuse can
break such assumption and might cause packet data corruptions.

Fix this by adding an extra condition (!priv->rx_headroom) to the 2nd
case to avoid page reuse when XDP is set, since rx_headroom is set to 0
for non XDP setup and set to XDP_PACKET_HEADROOM for XDP setup.

No additional cache line is required for the new condition.

Fixes: 34db548bfb95 ("mlx4: add page recycling in receive path")
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Suggested-by: Martin KaFai Lau <kafai@fb.com>
CC: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -474,10 +474,10 @@ static int mlx4_en_complete_rx_desc(stru
 {
 	const struct mlx4_en_frag_info *frag_info = priv->frag_info;
 	unsigned int truesize = 0;
+	bool release = true;
 	int nr, frag_size;
 	struct page *page;
 	dma_addr_t dma;
-	bool release;
 
 	/* Collect used fragments while replacing them in the HW descriptors */
 	for (nr = 0;; frags++) {
@@ -500,7 +500,11 @@ static int mlx4_en_complete_rx_desc(stru
 			release = page_count(page) != 1 ||
 				  page_is_pfmemalloc(page) ||
 				  page_to_nid(page) != numa_mem_id();
-		} else {
+		} else if (!priv->rx_headroom) {
+			/* rx_headroom for non XDP setup is always 0.
+			 * When XDP is set, the above condition will
+			 * guarantee page is always released.
+			 */
 			u32 sz_align = ALIGN(frag_size, SMP_CACHE_BYTES);
 
 			frags->page_offset += sz_align;



  parent reply	other threads:[~2018-07-23 12:27 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 12:24 [PATCH 4.17 00/63] 4.17.10-stable review Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 01/63] scsi: sd_zbc: Fix variable type and bogus comment Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 02/63] scsi: qla2xxx: Fix inconsistent DMA mem alloc/free Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 03/63] scsi: qla2xxx: Fix kernel crash due to late workqueue allocation Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 04/63] scsi: qla2xxx: Fix NULL pointer dereference for fcport search Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 06/63] KVM: irqfd: fix race between EPOLLHUP and irq_bypass_register_consumer Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 07/63] KVM: VMX: Mark VMXArea with revision_id of physical CPU even when eVMCS enabled Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 08/63] x86/kvm/vmx: dont read current->thread.{fs,gs}base of legacy tasks Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 11/63] x86/events/intel/ds: Fix bts_interrupt_threshold alignment Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 12/63] x86/MCE: Remove min interval polling limitation Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 13/63] fat: fix memory allocation failure handling of match_strdup() Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 14/63] ALSA: rawmidi: Change resized buffers atomically Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 15/63] ALSA: hda/realtek - Add Panasonic CF-SZ6 headset jack quirk Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 16/63] ALSA: hda/realtek - Yet another Clevo P950 quirk entry Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 17/63] ALSA: hda: add mute led support for HP ProBook 455 G5 Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 18/63] ARCv2: [plat-hsdk]: Save accl reg pair by default Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 19/63] ARC: Fix CONFIG_SWAP Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 20/63] ARC: configs: Remove CONFIG_INITRAMFS_SOURCE from defconfigs Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 21/63] ARC: mm: allow mprotect to make stack mappings executable Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 22/63] mm: memcg: fix use after free in mem_cgroup_iter() Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 23/63] mm/huge_memory.c: fix data loss when splitting a file pmd Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 24/63] cpufreq: intel_pstate: Register when ACPI PCCH is present Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 25/63] vfio/pci: Fix potential Spectre v1 Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 26/63] vfio/spapr: Use IOMMU pageshift rather than pagesize Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 27/63] stop_machine: Disable preemption when waking two stopper threads Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 28/63] powerpc/powernv: Fix save/restore of SPRG3 on entry/exit from stop (idle) Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 31/63] Revert "drm/amd/display: Dont return ddc result and read_bytes in same return value" Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 32/63] drm/nouveau: Remove bogus crtc check in pmops_runtime_idle Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 33/63] drm/nouveau: Use drm_connector_list_iter_* for iterating connectors Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 34/63] drm/nouveau: Avoid looping through fake MST connectors Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 36/63] ipv4: Return EINVAL when ping_group_range sysctl doesnt map to user ns Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 37/63] ipv6: fix useless rol32 call on hash Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 38/63] ipv6: ila: select CONFIG_DST_CACHE Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 39/63] lib/rhashtable: consider param->min_size when setting initial table size Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 40/63] net: diag: Dont double-free TCP_NEW_SYN_RECV sockets in tcp_abort Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 41/63] net: Dont copy pfmemalloc flag in __copy_skb_header() Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 42/63] skbuff: Unconditionally copy pfmemalloc in __skb_clone() Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 43/63] net/ipv4: Set oif in fib_compute_spec_dst Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 44/63] net/ipv6: Do not allow device only routes via the multipath API Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 45/63] net: phy: fix flag masking in __set_phy_supported Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 46/63] ptp: fix missing break in switch Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 48/63] rhashtable: add restart routine in rhashtable_free_and_destroy() Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 49/63] sch_fq_codel: zero q->flows_cnt when fq_codel_init fails Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 50/63] tg3: Add higher cpu clock for 5762 Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 51/63] net: ip6_gre: get ipv6hdr after skb_cow_head() Greg Kroah-Hartman
2018-07-23 12:24 ` [PATCH 4.17 52/63] sctp: introduce sctp_dst_mtu Greg Kroah-Hartman
2018-07-25 19:19   ` Marcelo Ricardo Leitner
2018-07-23 12:24 ` [PATCH 4.17 53/63] sctp: fix the issue that pathmtu may be set lower than MINSEGMENT Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 54/63] hv_netvsc: Fix napi reschedule while receive completion is busy Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 55/63] net: aquantia: vlan unicast address list correct handling Greg Kroah-Hartman
2018-07-23 12:25 ` Greg Kroah-Hartman [this message]
2018-07-23 12:25 ` [PATCH 4.17 57/63] net: systemport: Fix CRC forwarding check for SYSTEMPORT Lite Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 58/63] ipv6: make DAD fail with enhanced DAD when nonce length differs Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 59/63] net: usb: asix: replace mii_nway_restart in resume path Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 60/63] alpha: fix osf_wait4() breakage Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 61/63] drm_mode_create_lease_ioctl(): fix open-coded filp_clone_open() Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 62/63] cxl_getfile(): fix double-iput() on alloc_file() failures Greg Kroah-Hartman
2018-07-23 12:25 ` [PATCH 4.17 63/63] xhci: Fix perceived dead host due to runtime suspend race with event handler Greg Kroah-Hartman
2018-07-24  7:38 ` [PATCH 4.17 00/63] 4.17.10-stable review Naresh Kamboju
2018-07-24  8:58   ` Greg Kroah-Hartman
2018-07-24 15:58 ` Guenter Roeck
2018-07-25  7:46   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180723122448.472348330@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kafai@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=stable@vger.kernel.org \
    --cc=tariqt@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).