Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2439438imj; Mon, 18 Feb 2019 06:06:39 -0800 (PST) X-Google-Smtp-Source: AHgI3IY1Y5E6zguO+w7Q/0rQSNqzySNWhx76Tf4ZvPJJDXOkY2hBCEw9pTJR5/EPOfBGoL85aj40 X-Received: by 2002:a17:902:7604:: with SMTP id k4mr24812566pll.232.1550498799129; Mon, 18 Feb 2019 06:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550498799; cv=none; d=google.com; s=arc-20160816; b=SQEuJGCzffGxG91vVLqpbXILKv6wyQD8uvkxedsKHgNQhLYt/Khou2fUHFk6OM5gRb 4RypEkm/v6uDP+TbzRrgV7ZQGJwG/l9OJzvezgGAchCe5o6IAjrTMGMFqwDh0FWZmm7R b263x0YcECOVBJSLKhYuvhUZzh7+3zwSxzVfroJjttDraLoB+v6LYLBN9d5Q0qHmBf86 Y67b74gQUH+pKhJiTuIDy8w2hq4XUH57ZEb2VOC+PJ6x0qzC4itvZXWswE32bd8Ktd38 wDgkODQ7zav/YQTXQSLMCa1sID6xy11qYBFex+JTPJXxzniuM96gMjBO86UxmQQGZxDh 9NYQ== 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=57L69IEHzNClaSlC64wtNnGPat6P3zCxXErUTFLVTWY=; b=hNd+OVBcfcZRHpbXXiH9QGj9fWATCavScYpAqMUni5axlpCqcAO9Qh3roUvAtRNkOC Yhymp6k2gfTXVfNoeLw3TRdUQIgYMCiCgRqNj3TuhVR+AXt7YrxG3Hy9xTmodzFzFLEb KC0MTPQX8uOrj4Zxna8rTJetn1FtjJF8ET9pZtzCjMpgw4XpQUY5WAWiqRVazvf34jln cjQ0hUZKP5dLg61xWMVTZu2wGTpUhTyuK3cL65NtVUm/DIjEmD1yIL8Mod48yNd8D1IF jQW2fH/4Uq+8wVyWP1uCuigiQmC2MDgDVKCLqKAYeBgU+LVAwyGz9Zs9kDuZbvM1RHW+ Ck3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iJ3IVvW2; 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 s5si13591452plr.211.2019.02.18.06.06.23; Mon, 18 Feb 2019 06:06:39 -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=iJ3IVvW2; 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 S2389270AbfBROEV (ORCPT + 99 others); Mon, 18 Feb 2019 09:04:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:46758 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389292AbfBROES (ORCPT ); Mon, 18 Feb 2019 09:04:18 -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 6A989204FD; Mon, 18 Feb 2019 14:04:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498656; bh=RTfE8NovRPUJOtkUSdd9F0AyPweE/AvGZTs++Vj8JKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iJ3IVvW2B0i28shBJVFEGWp1wRXAXfyRPGT4o1P1A67n0GZKciXElzcAqt0f/Wo49 T9Ab+SX10ucXSfnKMY0bOwgg/3Y1TBkDJ3/UY8yhoSmpGUMmEubKU83QsNzIaG1m8B EOAUqnh/xETLOYNAcD4oh5+1jFs/EKpHEOubXiUw= 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.4 079/143] net: dp83640: expire old TX-skb Date: Mon, 18 Feb 2019 14:43:27 +0100 Message-Id: <20190218133531.969424919@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133529.099444112@linuxfoundation.org> References: <20190218133529.099444112@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.4-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 @@ -890,14 +890,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; @@ -912,6 +912,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)); @@ -1461,6 +1466,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) { @@ -1473,6 +1479,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;