From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Duoming Zhou <duoming@zju.edu.cn>,
Paolo Abeni <pabeni@redhat.com>, Sasha Levin <sashal@kernel.org>,
jes@trained-monkey.org, davem@davemloft.net, kuba@kernel.org,
linux-hippi@sunsite.dk, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.10 7/9] drivers: net: hippi: Fix deadlock in rr_close()
Date: Tue, 26 Apr 2022 15:02:28 -0400 [thread overview]
Message-ID: <20220426190232.2351606-7-sashal@kernel.org> (raw)
In-Reply-To: <20220426190232.2351606-1-sashal@kernel.org>
From: Duoming Zhou <duoming@zju.edu.cn>
[ Upstream commit bc6de2878429e85c1f1afaa566f7b5abb2243eef ]
There is a deadlock in rr_close(), which is shown below:
(Thread 1) | (Thread 2)
| rr_open()
rr_close() | add_timer()
spin_lock_irqsave() //(1) | (wait a time)
... | rr_timer()
del_timer_sync() | spin_lock_irqsave() //(2)
(wait timer to stop) | ...
We hold rrpriv->lock in position (1) of thread 1 and
use del_timer_sync() to wait timer to stop, but timer handler
also need rrpriv->lock in position (2) of thread 2.
As a result, rr_close() will block forever.
This patch extracts del_timer_sync() from the protection of
spin_lock_irqsave(), which could let timer handler to obtain
the needed lock.
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Link: https://lore.kernel.org/r/20220417125519.82618-1-duoming@zju.edu.cn
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/hippi/rrunner.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index 22010384c4a3..b9646b369f8e 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1353,7 +1353,9 @@ static int rr_close(struct net_device *dev)
rrpriv->fw_running = 0;
+ spin_unlock_irqrestore(&rrpriv->lock, flags);
del_timer_sync(&rrpriv->timer);
+ spin_lock_irqsave(&rrpriv->lock, flags);
writel(0, ®s->TxPi);
writel(0, ®s->IpRxPi);
--
2.35.1
next prev parent reply other threads:[~2022-04-26 19:03 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-26 19:02 [PATCH AUTOSEL 5.10 1/9] ASoC: Intel: soc-acpi: correct device endpoints for max98373 Sasha Levin
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 2/9] ASoC: wm8731: Disable the regulator when probing fails Sasha Levin
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 3/9] ext4: fix bug_on in start_this_handle during umount filesystem Sasha Levin
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 4/9] ip6_gre: Avoid updating tunnel->tun_hlen in __gre6_xmit() Sasha Levin
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 5/9] x86: __memcpy_flushcache: fix wrong alignment if size > 2^32 Sasha Levin
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 6/9] cifs: destage any unwritten data to the server before calling copychunk_write Sasha Levin
2022-04-26 19:02 ` Sasha Levin [this message]
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 8/9] powerpc/perf: Fix 32bit compile Sasha Levin
2022-04-26 19:02 ` [PATCH AUTOSEL 5.10 9/9] ata: pata_marvell: Check the 'bmdma_addr' beforing reading Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220426190232.2351606-7-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=duoming@zju.edu.cn \
--cc=jes@trained-monkey.org \
--cc=kuba@kernel.org \
--cc=linux-hippi@sunsite.dk \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox