Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2675463imj; Mon, 11 Feb 2019 06:52:25 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ0+jwjIiLI2pJEdcfFv3eUY3lHa/QFV87CbpGQY5fV2A0kN1WSwwQZKZaESLROIteRGoSq X-Received: by 2002:a17:902:780a:: with SMTP id p10mr38674145pll.54.1549896745537; Mon, 11 Feb 2019 06:52:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549896745; cv=none; d=google.com; s=arc-20160816; b=LKUNdVPXO98OlWs0hXjoV7Ztu8k6+Xe1duUqyrQ+WVTbTxHc0dJ2G4lvGxzAuoZz7S pxUZk1wARTL2Yg1wLWNsP5hD1ujJ4pd1XxYdLS1Soxg4vBn0tsvMfbQYw3s5UUwm7vwJ te0be1osyMN1bvTNBxx7qgXdZyfOYl5rCrsj1v6060ys0Dn6UH4rNEM2PjZKDtzLFOOL x4STFhqrOLX+2QUp2L1XvihoFqomhd44T5I4YGMjGEq8syj96wzrjZUhZ7+mtqmZewtx veBeTLpffrkZyBMBSMEAbJWsb20MVp81RG8JveLiXLpHCC/f39B1z8MVSzI62TTzj2B1 AJHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NM9LgYWFGs7Aparsmx8HBFfEwWfe3XOZUhAFzqlP5jQ=; b=eXf8bJE6yqpePzbwYP/tEO3C3oHu2NxckWLAy7W15vi0kxsdO17RkSJGWzdwN/rMbk XWERegeMyL2/uZT9Pc14+ZMUA6tAiAE87vPqvKDRnh8r9LHtRCzhdLmtWXxi/kefAIh2 uJsu+l++ms5LUlEs0TgNR10W87aZN9JJJp8f3qKdVV8Y1JfHv2IDtJjmdDIyxL+wK8qz Lj5vLBsdpTcpJIPdvBnLtXF61I45Ea4dVq+Mmu9HCpI/okmB214FXFsE5HLye7WUG/FC 9bB6nxAhvdIB/qKB7dgw6Y8SgPaqWh/5NuDOx2VRxTTCpFHy1O0jDc2fJGiria4aM2LR Io5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JXPpPs2r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r10si7630440pgr.489.2019.02.11.06.52.09; Mon, 11 Feb 2019 06:52:25 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JXPpPs2r; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388229AbfBKOvN (ORCPT + 99 others); Mon, 11 Feb 2019 09:51:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:37172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388217AbfBKOvL (ORCPT ); Mon, 11 Feb 2019 09:51:11 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6939A2081B; Mon, 11 Feb 2019 14:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549896669; bh=08EROL8kChbKpcPpafWNh31j5TzGEgYfuhRVF7WnzxQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JXPpPs2rbC0Vn8vsZjTp+26e+O5J2VmeekqwWUvUuPFklyZJbz470g+6n+W376oiy 2hmL2UvmEJkp1rQM/n/HyGUczo3N+Ks7ZPbguaHp5heEQIzjCoFJF3qO7Vou2Lj2lk tuH2oz1xgv4lBh0hVE2JGuKw4YBpay3pCcTFOLTs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , Kurt Kanzenbach , Richard Cochran , "David S. Miller" Subject: [PATCH 4.19 262/313] net: dp83640: expire old TX-skb Date: Mon, 11 Feb 2019 15:19:02 +0100 Message-Id: <20190211141910.816559687@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141852.749630980@linuxfoundation.org> References: <20190211141852.749630980@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sebastian Andrzej Siewior [ Upstream commit 53bc8d2af08654659abfadfd3e98eb9922ff787c ] During sendmsg() a cloned skb is saved via dp83640_txtstamp() in ->tx_queue. After the NIC sends this packet, the PHY will reply with a timestamp for that TX packet. If the cable is pulled at the right time I don't see that packet. It might gets flushed as part of queue shutdown on NIC's side. Once the link is up again then after the next sendmsg() we enqueue another skb in dp83640_txtstamp() and have two on the list. Then the PHY will send a reply and decode_txts() attaches it to the first skb on the list. No crash occurs since refcounting works but we are one packet behind. linuxptp/ptp4l usually closes the socket and opens a new one (in such a timeout case) so those "stale" replies never get there. However it does not resume normal operation anymore. Purge old skbs in decode_txts(). Fixes: cb646e2b02b2 ("ptp: Added a clock driver for the National Semiconductor PHYTER.") Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Kurt Kanzenbach Acked-by: Richard Cochran Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/phy/dp83640.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -896,14 +896,14 @@ static void decode_txts(struct dp83640_p struct phy_txts *phy_txts) { struct skb_shared_hwtstamps shhwtstamps; + struct dp83640_skb_info *skb_info; struct sk_buff *skb; - u64 ns; u8 overflow; + u64 ns; /* We must already have the skb that triggered this. */ - +again: skb = skb_dequeue(&dp83640->tx_queue); - if (!skb) { pr_debug("have timestamp but tx_queue empty\n"); return; @@ -918,6 +918,11 @@ static void decode_txts(struct dp83640_p } return; } + skb_info = (struct dp83640_skb_info *)skb->cb; + if (time_after(jiffies, skb_info->tmo)) { + kfree_skb(skb); + goto again; + } ns = phy2txts(phy_txts); memset(&shhwtstamps, 0, sizeof(shhwtstamps)); @@ -1470,6 +1475,7 @@ static bool dp83640_rxtstamp(struct phy_ static void dp83640_txtstamp(struct phy_device *phydev, struct sk_buff *skb, int type) { + struct dp83640_skb_info *skb_info = (struct dp83640_skb_info *)skb->cb; struct dp83640_private *dp83640 = phydev->priv; switch (dp83640->hwts_tx_en) { @@ -1482,6 +1488,7 @@ static void dp83640_txtstamp(struct phy_ /* fall through */ case HWTSTAMP_TX_ON: skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; + skb_info->tmo = jiffies + SKB_TIMESTAMP_TIMEOUT; skb_queue_tail(&dp83640->tx_queue, skb); break;