Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4565848pja; Thu, 21 Nov 2019 21:59:40 -0800 (PST) X-Google-Smtp-Source: APXvYqw77jbPZQrOdouqKg6b7lQjGujZQnxuVkmDwMktdS1lxJHV0Q9F4oBF5WgjLCkyT4jWDtF5 X-Received: by 2002:a17:906:86ca:: with SMTP id j10mr20127158ejy.200.1574402380303; Thu, 21 Nov 2019 21:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574402380; cv=none; d=google.com; s=arc-20160816; b=bBJAlDHySJZl46ZRjTIz9TbYMDAd8CKrPlYiId/FpCeU//0R0kDF+IUV+xJCQXNxaj tQHri5mdNudjyb4U7tYDsKmOFC4hH/Kdkmicr4Wo664BMUiKuSYn8SzFVZ7Hm+yMiiUJ PgOrYLuLrBurKIMzyx6uD9f4HVHqtfxXAxSAW3Hv2o1L4hwcWRLqWmd+zcTvUoErW4uT 9NqDhmvuODR0woei+WsMD+K7anfNy9AXOCK3ofMRzbwk56EHA1dE/B7t4/zcEitCJ9cW bo6QIAOrqX1pWV8kgZIH0iQ90mcHaEA0rUlUItFS6f7qQfS0bUkMbA9hAxeyldJqWmr5 U7qw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WA+Y90b0PTzM8FYTGX44m/J+DgX+pUeHyodnRmjGcXI=; b=AnPqLYN12pexo/cT6MIkkbSNIEXnVoVcn3wbNM5A0kAg42hvnaI29eSg/LNlQjxMKU z6py7PN6XnwSnby+2hVppDNu1DMfTu+9XccYR1jB4wiPiu++/zsio1GZ3YN1MHzbSFmr DLN6Kr33rV7po44v6gFVCCJn1wCavyU08vsmX90P8/5xABJ36F9LXyAWa3luWhKISAvR E8Ew06PkUSDdTPSGAaRHIUZ/8hhPAZxcRJ1sAPgADDPkD20gENO1VCom8v6XkBGK/zGA hY+RGvWIZ3qgEcXTl1ynXVK/Bqs/eXX9n1KQvhr5dS5efLmOnragY+F1AQ3/JhETAkz1 O06g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gDDuPMGZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y17si4614313edd.148.2019.11.21.21.59.16; Thu, 21 Nov 2019 21:59:40 -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=gDDuPMGZ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727072AbfKVFzO (ORCPT + 99 others); Fri, 22 Nov 2019 00:55:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:58776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728719AbfKVFwz (ORCPT ); Fri, 22 Nov 2019 00:52:55 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B474F2084B; Fri, 22 Nov 2019 05:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401974; bh=MbC18X3Sfxye5skgXLrpnqugMo/Tin2MGO7PyG9qQWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDDuPMGZBFoU/I11kGhClA6V0XDWQ8G/EL9stjJyrsVe3M39uG3yKUFdN0i9nTBFB 7pl+wtHwx6A8JO2m0EHyIDmR/yR3beKMB8NnQcHLgxzcwNSDvDXSglzv5ahbEuWCqR Ah2isa8xRb4NAxa0Hv1IN8K2vHajuRc4qrkLPcO8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Maciej Kwiecien , Marcin Stojek , Alexander Sverdlin , Marcelo Ricardo Leitner , "David S . Miller" , Sasha Levin , linux-sctp@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 194/219] sctp: don't compare hb_timer expire date before starting it Date: Fri, 22 Nov 2019 00:48:46 -0500 Message-Id: <20191122054911.1750-187-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Maciej Kwiecien [ Upstream commit d1f20c03f48102e52eb98b8651d129b83134cae4 ] hb_timer might not start at all for a particular transport because its start is conditional. In a result a node is not sending heartbeats. Function sctp_transport_reset_hb_timer has two roles: - initial start of hb_timer for a given transport, - update expire date of hb_timer for a given transport. The function is optimized to update timer's expire only if it is before a new calculated one but this comparison is invalid for a timer which has not yet started. Such a timer has expire == 0 and if a new expire value is bigger than (MAX_JIFFIES / 2 + 2) then "time_before" macro will fail and timer will not start resulting in no heartbeat packets send by the node. This was found when association was initialized within first 5 mins after system boot due to jiffies init value which is near to MAX_JIFFIES. Test kernel version: 4.9.154 (ARCH=arm) hb_timer.expire = 0; //initialized, not started timer new_expire = MAX_JIFFIES / 2 + 2; //or more time_before(hb_timer.expire, new_expire) == false Fixes: ba6f5e33bdbb ("sctp: avoid refreshing heartbeat timer too often") Reported-by: Marcin Stojek Tested-by: Marcin Stojek Signed-off-by: Maciej Kwiecien Reviewed-by: Alexander Sverdlin Acked-by: Marcelo Ricardo Leitner Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sctp/transport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/sctp/transport.c b/net/sctp/transport.c index 033696e6f74fb..ad158d311ffae 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c @@ -207,7 +207,8 @@ void sctp_transport_reset_hb_timer(struct sctp_transport *transport) /* When a data chunk is sent, reset the heartbeat interval. */ expires = jiffies + sctp_transport_timeout(transport); - if (time_before(transport->hb_timer.expires, expires) && + if ((time_before(transport->hb_timer.expires, expires) || + !timer_pending(&transport->hb_timer)) && !mod_timer(&transport->hb_timer, expires + prandom_u32_max(transport->rto))) sctp_transport_hold(transport); -- 2.20.1