提交 621df030 编写于 作者: X Xie He 提交者: Yang Yingliang

net: hdlc_ppp: Fix issues when mod_timer is called while timer is running

[ Upstream commit 1fef7359 ]

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: e022c2f0 ("WAN: new synchronous PPP implementation for generic HDLC.")
Cc: Krzysztof Halasa <khc@pm.waw.pl>
Signed-off-by: NXie He <xie.he.0141@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 304cf949
...@@ -572,6 +572,13 @@ static void ppp_timer(struct timer_list *t) ...@@ -572,6 +572,13 @@ static void ppp_timer(struct timer_list *t)
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&ppp->lock, 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) { switch (proto->state) {
case STOPPING: case STOPPING:
case REQ_SENT: case REQ_SENT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册