Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2688597imj; Mon, 11 Feb 2019 07:03:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IZPDP80qc85nKNbUyQtgVIl094Y9WmfyeI0UDzIidLh683mDLKwWX8Vflil4XPzxKT6YkmA X-Received: by 2002:a62:5f07:: with SMTP id t7mr36917536pfb.108.1549897422312; Mon, 11 Feb 2019 07:03:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897422; cv=none; d=google.com; s=arc-20160816; b=Gf7XaDdptGjIDzSoSqo06xOBPW7uaNqWjWz8/eSRJdRkSWcf1oJLBPMZJmoJSpIMTe s7oSPF1nsflOhMA8+E+XL4ElsGiMIYkxdx+KmenjDhUX36UUj59TknMXahJuUoyv07rE R72XyBgCkhc1z9LFwl1JRyzUhuWyNtCBzehTTV0FftUYR6KtucU6VM1t+FzQVk93m2id IaH2et2PxdAe15pjj3AM62+wVRGMgG9cxR4Eio5dG3be2RvkRWv+fOnCyEURL2/xbpQL FELPM9BRutIgyPj11QeAYTHgYHxmU/Ah1B0GjU+rLYiYFovJroK5XwxjB1+hw6z0e/s+ ZfjQ== 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=Op9YQhOke2LOoI/bA5dyKaAOJT6DLLyKvzoh2Kh3wak=; b=w6FuZ6e7e2PiA9SIklDvydCrJpgls7VFZcMn1t7UQEt/8HuMLBj67ruyPO50LIdz+S 0tcWUgXHbFNTJYG/7waS4/WCIv+kswXhxGYwuEXCo7AzBPbBFpmME/0fQR+k8b7JSuET UGZG/JkdGRMFNDOLvw4nhwLI7UhZYGqeiphSdX3XtwmhfMhxvwE+t5tPpfWk2JQHgEtq O/0au/SfWAu4r2zXbbsrAUmMEMShpSIRyjbE1+pRo+eJN3xZezkIn+mTop02UpWD92WW U1DhW1IbGg9x28BVIW9eWBw51MbljlpZvv1BQGyoARa9+28HiBoky/XYePvmp7WCqWWM jzxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="nz+XA9/d"; 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 t27si9669302pga.3.2019.02.11.07.03.21; Mon, 11 Feb 2019 07:03:42 -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="nz+XA9/d"; 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 S2390378AbfBKPCQ (ORCPT + 99 others); Mon, 11 Feb 2019 10:02:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:50422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390373AbfBKPCP (ORCPT ); Mon, 11 Feb 2019 10:02:15 -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 A73A4222A6; Mon, 11 Feb 2019 15:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897334; bh=09BxljRR+I3MLk0mcth2Ext/qkTV01fOcb3itM2o3X0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nz+XA9/dLCQAaUCOZbqPqe6nGJjoHSTL9l5/B3PiyKhq5q+mFct6c2klwkwM65/cu 73W2RXn+JmNMyQM3tP10nekOmO57ymxz+mHAFgILYnsfSXPKVrKJ8yU1v+/44xiDXy QpkFRLtHCUZyYzBlPqeHwjX1CgVu02ciYrjsi6L4= 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.14 168/205] net: dp83640: expire old TX-skb Date: Mon, 11 Feb 2019 15:19:26 +0100 Message-Id: <20190211141839.345736028@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 @@ -893,14 +893,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; @@ -915,6 +915,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)); @@ -1466,6 +1471,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) { @@ -1478,6 +1484,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;