Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2660221imj; Mon, 11 Feb 2019 06:37:21 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ+7AyKl2MIVYIWE6DjH+hlDIZWvs8co34iHVA3D/cpAA6YaJb0NZC4QQzG3kuVn0b5QYnJ X-Received: by 2002:a17:902:704c:: with SMTP id h12mr38695689plt.30.1549895841160; Mon, 11 Feb 2019 06:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549895841; cv=none; d=google.com; s=arc-20160816; b=ZjtqB2vNQcHcMwxw/uqED1FQSQjVEyYoUafke3NNkZSuOVd/JqcNf9SrINoTALwzHS uljvHVkY2Zm+3B2mlXTk7VeFvmkfeNDb12GlAzvc7qo9JU3kRNlqr1n4BLGZni35ZAw0 ggOE8c8E+ld9Zj+e+w8DUc69GQchmHZVDUujBwCFXXCTzlXLldJAlBCDA4oDFNjdPkjY zOC+ItTolC9lxg06XFiQs4UNk2bHVeG48VyEn1hwO2lwF/m8aL93goSdBR529ICJkiGJ cRwlZNestH2W3Bbv62PlxFpvaGHzYgEreAk6F7ooeAfyLL5ujgpfQe3/s/3UBvjN15an RfcA== 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=lWBQIQ8FimfbM8WhR3HX3T1e3/YIGJ4oHbbrDO/xpLo=; b=IACN7gcbhssrsj6ee0Uct77ufPL43+HKxwZQVYGYBheoZb5M/q2d65h+TeHqaCq/i3 sBZP+EBXheFI5Pp1ImklhaVzd3ZuIqDM9mudwsKxTsUoVn93PSzIZW1KC2d7VRtJbQXj uQiffHu74fo0lu92n3PDVnN8LRY9e9UyCgH26RkcDjxHgYjEvhP1XQJ64CXQM0BeCoNu 48ore05IB8wayVsmRa922L9Wgl9rd3/PL+HfaE+/30M/ZanjiivzsI3n1qF3lnUH09Xu jrB1UmzvXnC/WLxICs3dteT3KbL1jVjbzNuzhF1YuM0fM6wqb6shZ+zaXtWvF7LHDcT/ W/pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=u0lDgxRX; 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 f13si9299016pgv.164.2019.02.11.06.37.05; Mon, 11 Feb 2019 06:37:21 -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=u0lDgxRX; 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 S1730972AbfBKOfK (ORCPT + 99 others); Mon, 11 Feb 2019 09:35:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:43650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730963AbfBKOfH (ORCPT ); Mon, 11 Feb 2019 09:35:07 -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 426EB20700; Mon, 11 Feb 2019 14:35:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895705; bh=NNKqMCN/k/TP/RBnw5dfn5dUfgdbZAup/EisBFeg91U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u0lDgxRXiORaNR0+xtReML9fR6qaYn9eKUK59suxtYh+eYyfZvn1TsFmL24LwYo/L RyHL40BwiAalF5f5ZNmL8NjUMkMT6sZWLsQuv8cv5NxDQtq8sjmBwZOEAoOF/xldLX HrCPyDgOdopTqKoQzUX2ZjKHx22fBEPMWPJvFAeQ= 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.20 295/352] net: dp83640: expire old TX-skb Date: Mon, 11 Feb 2019 15:18:42 +0100 Message-Id: <20190211141905.662732944@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-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 @@ -898,14 +898,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; @@ -920,6 +920,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)); @@ -1472,6 +1477,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) { @@ -1484,6 +1490,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;