Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2275177pxb; Mon, 11 Jan 2021 05:49:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyQJh8cEKe82NKQvsbY6mAt62LbEbvEzm/aMvJNzrKGVBv7zwFntp//merTJYqLcZO5A+1B X-Received: by 2002:a50:fb85:: with SMTP id e5mr13889457edq.153.1610372945777; Mon, 11 Jan 2021 05:49:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610372945; cv=none; d=google.com; s=arc-20160816; b=QxB/lCsi5FLDIOzCfKO9Nn4P/sY5+VIL2Slndq0nfqnHlcRlFIM4NBRlFpsYMoWSHX zP0KKku7Q5PC6932/EEL47RPtVWQjBI5PzHDh9KjHmCLDAL+jiGvnev5eiHEZWu6udh2 /7UB3D1+q15+ltwczPd4NoWbxLGBopn+3/HfPGF3iUaUm3ez2+Qp1HT4ttzZgaJu0JoW lYHmxZH3WDAQgkSrkRcMnXgix6rKChp7ycismZmceUM1hP5up/SNNUflTCQd1sdN6d8w t0+vCaZIi3222n/mgjafqHcC95hIRxIq4DOaSQ9q1LuXpI4DfT8LG3InsSLlbEFTTXXQ Mbyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=u+Lb8ooN6RAKMJ2ejrN492l2bKxmEyb02B6ydKvNl0s=; b=XEYa6lRpM6gg2BVQnRBqx+EA0nUu3cXGBSIQ0fRD03npqv9egSPEcaIyTa1yLqWNgp 49rwYJj/YbdrjZgdJukxzKibONRXsvRC56rdWtE/ZFq/2lmax9dDzlkZB+WIhWSFo2i4 uSYNHD+6VFNUHhx4MAsp4dLKmE/aYPRQohbsgS2ZlsaxmTvDB737cBvjjY+UeGvaGWrM +cqoF1uYmGMybjK8U1FBOhXbGGPsIYYTB2NyUUWZpmtvFX4/ZlqNXmoid7uL8J8g1WWY j60sKlKyxamWBTh9YLEd6rHjxcsyBRFSK+V87rJzoaFZDb2Kt4UukXQyPWabGBEhhaWx xldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O3U8yLVo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q4si6810581eji.204.2021.01.11.05.48.41; Mon, 11 Jan 2021 05:49:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O3U8yLVo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387770AbhAKNpm (ORCPT + 99 others); Mon, 11 Jan 2021 08:45:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:58590 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731391AbhAKNL1 (ORCPT ); Mon, 11 Jan 2021 08:11:27 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id AFA5421973; Mon, 11 Jan 2021 13:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610370647; bh=/9UIJ5d6oF+oQOgHRhv35Uydujl10TUiEJufAONoLvU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3U8yLVot2FuBaYcOheBTaer0K/mV/s08hJOCoscVgWYD4+3/BoFtS6g+S8CXqlsp Sqj3czbqe6p181Fu9kNHlKCYmqTHpuXQs2VN7QbODoIkcPgj7Mh9ggzNQHSsKwUUJO WPXdVEUB3TeJqdqq4njiLxQCs+I0XMycGB9NH618= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Krzysztof Halasa , Xie He , "David S. Miller" Subject: [PATCH 5.4 37/92] net: hdlc_ppp: Fix issues when mod_timer is called while timer is running Date: Mon, 11 Jan 2021 14:01:41 +0100 Message-Id: <20210111130040.937379207@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210111130039.165470698@linuxfoundation.org> References: <20210111130039.165470698@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xie He [ Upstream commit 1fef73597fa545c35fddc953979013882fbd4e55 ] ppp_cp_event is called directly or indirectly by ppp_rx with "ppp->lock" held. It may call mod_timer to add a new timer. However, at the same time ppp_timer may be already running and waiting for "ppp->lock". In this case, there's no need for ppp_timer to continue running and it can just exit. If we let ppp_timer continue running, it may call add_timer. This causes kernel panic because add_timer can't be called with a timer pending. This patch fixes this problem. Fixes: e022c2f07ae5 ("WAN: new synchronous PPP implementation for generic HDLC.") Cc: Krzysztof Halasa Signed-off-by: Xie He Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/wan/hdlc_ppp.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/drivers/net/wan/hdlc_ppp.c +++ b/drivers/net/wan/hdlc_ppp.c @@ -569,6 +569,13 @@ static void ppp_timer(struct timer_list unsigned long flags; spin_lock_irqsave(&ppp->lock, flags); + /* mod_timer could be called after we entered this function but + * before we got the lock. + */ + if (timer_pending(&proto->timer)) { + spin_unlock_irqrestore(&ppp->lock, flags); + return; + } switch (proto->state) { case STOPPING: case REQ_SENT: