All of lore.kernel.org
 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, James Jurack <james.jurack@ametek.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Claudiu Manoil <claudiu.manoil@nxp.com>
Subject: [PATCH 4.19 07/71] gianfar: Replace skb_realloc_headroom with skb_cow_head for PTP
Date: Mon,  9 Nov 2020 13:55:01 +0100	[thread overview]
Message-ID: <20201109125020.250512772@linuxfoundation.org> (raw)
In-Reply-To: <20201109125019.906191744@linuxfoundation.org>

From: Claudiu Manoil <claudiu.manoil@nxp.com>

[ Upstream commit d145c9031325fed963a887851d9fa42516efd52b ]

When PTP timestamping is enabled on Tx, the controller
inserts the Tx timestamp at the beginning of the frame
buffer, between SFD and the L2 frame header.  This means
that the skb provided by the stack is required to have
enough headroom otherwise a new skb needs to be created
by the driver to accommodate the timestamp inserted by h/w.
Up until now the driver was relying on skb_realloc_headroom()
to create new skbs to accommodate PTP frames.  Turns out that
this method is not reliable in this context at least, as
skb_realloc_headroom() for PTP frames can cause random crashes,
mostly in subsequent skb_*() calls, when multiple concurrent
TCP streams are run at the same time with the PTP flow
on the same device (as seen in James' report).  I also noticed
that when the system is loaded by sending multiple TCP streams,
the driver receives cloned skbs in large numbers.
skb_cow_head() instead proves to be stable in this scenario,
and not only handles cloned skbs too but it's also more efficient
and widely used in other drivers.
The commit introducing skb_realloc_headroom in the driver
goes back to 2009, commit 93c1285c5d92
("gianfar: reallocate skb when headroom is not enough for fcb").
For practical purposes I'm referencing a newer commit (from 2012)
that brings the code to its current structure (and fixes the PTP
case).

Fixes: 9c4886e5e63b ("gianfar: Fix invalid TX frames returned on error queue when time stamping")
Reported-by: James Jurack <james.jurack@ametek.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com>
Link: https://lore.kernel.org/r/20201029081057.8506-1-claudiu.manoil@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/net/ethernet/freescale/gianfar.c |   12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -2370,20 +2370,12 @@ static netdev_tx_t gfar_start_xmit(struc
 		fcb_len = GMAC_FCB_LEN + GMAC_TXPAL_LEN;
 
 	/* make space for additional header when fcb is needed */
-	if (fcb_len && unlikely(skb_headroom(skb) < fcb_len)) {
-		struct sk_buff *skb_new;
-
-		skb_new = skb_realloc_headroom(skb, fcb_len);
-		if (!skb_new) {
+	if (fcb_len) {
+		if (unlikely(skb_cow_head(skb, fcb_len))) {
 			dev->stats.tx_errors++;
 			dev_kfree_skb_any(skb);
 			return NETDEV_TX_OK;
 		}
-
-		if (skb->sk)
-			skb_set_owner_w(skb_new, skb->sk);
-		dev_consume_skb_any(skb);
-		skb = skb_new;
 	}
 
 	/* total number of fragments in the SKB */



  parent reply	other threads:[~2020-11-09 13:09 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-09 12:54 [PATCH 4.19 00/71] 4.19.156-rc1 review Greg Kroah-Hartman
2020-11-09 12:54 ` [PATCH 4.19 01/71] drm/i915: Break up error capture compression loops with cond_resched() Greg Kroah-Hartman
2020-11-09 18:20   ` Pavel Machek
2020-11-09 12:54 ` [PATCH 4.19 02/71] tipc: fix use-after-free in tipc_bcast_get_mode Greg Kroah-Hartman
2020-11-09 12:54 ` [PATCH 4.19 03/71] ptrace: fix task_join_group_stop() for the case when current is traced Greg Kroah-Hartman
2020-11-09 12:54 ` [PATCH 4.19 04/71] cadence: force nonlinear buffers to be cloned Greg Kroah-Hartman
2020-11-09 12:54 ` [PATCH 4.19 05/71] chelsio/chtls: fix memory leaks caused by a race Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 06/71] chelsio/chtls: fix always leaking ctrl_skb Greg Kroah-Hartman
2020-11-09 12:55 ` Greg Kroah-Hartman [this message]
2020-11-09 12:55 ` [PATCH 4.19 08/71] gianfar: Account for Tx PTP timestamp in the skb headroom Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 09/71] net: usb: qmi_wwan: add Telit LE910Cx 0x1230 composition Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 10/71] sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 11/71] sfp: Fix error handing in sfp_probe() Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 12/71] blktrace: fix debugfs use after free Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 13/71] btrfs: extent_io: Kill the forward declaration of flush_write_bio Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 14/71] btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 15/71] Revert "btrfs: flush write bio if we loop in extent_write_cache_pages" Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 16/71] btrfs: flush write bio if we loop in extent_write_cache_pages Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 17/71] btrfs: extent_io: Handle errors better in extent_write_full_page() Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 18/71] btrfs: extent_io: Handle errors better in btree_write_cache_pages() Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 19/71] btrfs: extent_io: add proper error handling to lock_extent_buffer_for_io() Greg Kroah-Hartman
2020-11-11 12:44   ` Pavel Machek
2020-11-11 14:39     ` Ben Hutchings
2020-11-12 16:06       ` Sasha Levin
2020-11-09 12:55 ` [PATCH 4.19 20/71] Btrfs: fix unwritten extent buffers and hangs on future writeback attempts Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 21/71] btrfs: Dont submit any btree write bio if the fs has errors Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 22/71] btrfs: Move btrfs_check_chunk_valid() to tree-check.[ch] and export it Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 23/71] btrfs: tree-checker: Make chunk item checker messages more readable Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 24/71] btrfs: tree-checker: Make btrfs_check_chunk_valid() return EUCLEAN instead of EIO Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 25/71] btrfs: tree-checker: Check chunk item at tree block read time Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 26/71] btrfs: tree-checker: Verify dev item Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 27/71] btrfs: tree-checker: Fix wrong check on max devid Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 28/71] btrfs: tree-checker: Enhance chunk checker to validate chunk profile Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 29/71] btrfs: tree-checker: Verify inode item Greg Kroah-Hartman
2020-11-11 13:13   ` Pavel Machek
2020-11-11 13:30     ` Qu Wenruo
2020-11-11 13:38       ` Pavel Machek
2020-11-11 14:04         ` Qu Wenruo
2020-11-09 12:55 ` [PATCH 4.19 30/71] btrfs: tree-checker: fix the error message for transid error Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 31/71] Fonts: Replace discarded const qualifier Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 32/71] ALSA: usb-audio: Add implicit feedback quirk for Zoom UAC-2 Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 33/71] ALSA: usb-audio: add usb vendor id as DSD-capable for Khadas devices Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 34/71] ALSA: usb-audio: Add implicit feedback quirk for Qu-16 Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 35/71] ALSA: usb-audio: Add implicit feedback quirk for MODX Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 36/71] mm: mempolicy: fix potential pte_unmap_unlock pte error Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 37/71] lib/crc32test: remove extra local_irq_disable/enable Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 38/71] kthread_worker: prevent queuing delayed work from timer_fn when it is being canceled Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 39/71] mm: always have io_remap_pfn_range() set pgprot_decrypted() Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 40/71] gfs2: Wake up when sd_glock_disposal becomes zero Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 41/71] ring-buffer: Fix recursion protection transitions between interrupt context Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 42/71] ftrace: Fix recursion check for NMI test Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 43/71] ftrace: Handle tracing when switching between context Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 44/71] tracing: Fix out of bounds write in get_trace_buf Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 45/71] futex: Handle transient "ownerless" rtmutex state correctly Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 46/71] ARM: dts: sun4i-a10: fix cpu_alert temperature Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 47/71] x86/kexec: Use up-to-dated screen_info copy to fill boot params Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 48/71] of: Fix reserved-memory overlap detection Greg Kroah-Hartman
2020-11-11 12:53   ` Pavel Machek
2020-11-11 14:34     ` Vincent Whitchurch
2020-11-09 12:55 ` [PATCH 4.19 49/71] blk-cgroup: Fix memleak on error path Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 50/71] blk-cgroup: Pre-allocate tree node on blkg_conf_prep Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 51/71] scsi: core: Dont start concurrent async scan on same host Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 52/71] vsock: use ns_capable_noaudit() on socket create Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 53/71] drm/vc4: drv: Add error handding for bind Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 54/71] ACPI: NFIT: Fix comparison to -ENXIO Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 55/71] vt: Disable KD_FONT_OP_COPY Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 56/71] fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 57/71] serial: 8250_mtk: Fix uart_get_baud_rate warning Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 58/71] serial: txx9: add missing platform_driver_unregister() on error in serial_txx9_init Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 59/71] USB: serial: cyberjack: fix write-URB completion race Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 60/71] USB: serial: option: add Quectel EC200T module support Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 61/71] USB: serial: option: add LE910Cx compositions 0x1203, 0x1230, 0x1231 Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 62/71] USB: serial: option: add Telit FN980 composition 0x1055 Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 63/71] USB: Add NO_LPM quirk for Kingston flash drive Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 64/71] usb: mtu3: fix panic in mtu3_gadget_stop() Greg Kroah-Hartman
2020-11-09 12:55 ` [PATCH 4.19 65/71] ARC: stack unwinding: avoid indefinite looping Greg Kroah-Hartman
2020-11-09 12:56 ` [PATCH 4.19 66/71] Revert "ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE" Greg Kroah-Hartman
2020-11-09 12:56 ` [PATCH 4.19 67/71] PM: runtime: Resume the device earlier in __device_release_driver() Greg Kroah-Hartman
2020-11-09 12:56 ` [PATCH 4.19 68/71] perf/core: Fix a memory leak in perf_event_parse_addr_filter() Greg Kroah-Hartman
2020-11-09 12:56 ` [PATCH 4.19 69/71] tools: perf: Fix build error in v4.19.y Greg Kroah-Hartman
2020-11-09 12:56 ` [PATCH 4.19 70/71] net: dsa: read mac address from DT for slave device Greg Kroah-Hartman
2020-11-09 12:56 ` [PATCH 4.19 71/71] arm64: dts: marvell: espressobin: Add ethernet switch aliases Greg Kroah-Hartman
2020-11-09 15:43 ` [PATCH 4.19 00/71] 4.19.156-rc1 review Jon Hunter
2020-11-09 19:22 ` Pavel Machek
2020-11-09 23:07 ` Guenter Roeck
2020-11-09 23:22 ` Shuah Khan
2020-11-10  7:44 ` Naresh Kamboju
2020-11-19  8:10 ` Pavel Machek

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=20201109125020.250512772@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=claudiu.manoil@nxp.com \
    --cc=james.jurack@ametek.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.