From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Duoming Zhou <duoming@zju.edu.cn>,
Jiri Slaby <jirislaby@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>,
davem@davemloft.net, pabeni@redhat.com,
gregkh@linuxfoundation.org, mkl@pengutronix.de,
dmitry.torokhov@gmail.com, bigeasy@linutronix.de, arnd@arndb.de,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.19 12/12] drivers: net: slip: fix NPD bug in sl_tx_timeout()
Date: Mon, 11 Apr 2022 20:51:45 -0400 [thread overview]
Message-ID: <20220412005148.351391-12-sashal@kernel.org> (raw)
In-Reply-To: <20220412005148.351391-1-sashal@kernel.org>
From: Duoming Zhou <duoming@zju.edu.cn>
[ Upstream commit ec4eb8a86ade4d22633e1da2a7d85a846b7d1798 ]
When a slip driver is detaching, the slip_close() will act to
cleanup necessary resources and sl->tty is set to NULL in
slip_close(). Meanwhile, the packet we transmit is blocked,
sl_tx_timeout() will be called. Although slip_close() and
sl_tx_timeout() use sl->lock to synchronize, we don`t judge
whether sl->tty equals to NULL in sl_tx_timeout() and the
null pointer dereference bug will happen.
(Thread 1) | (Thread 2)
| slip_close()
| spin_lock_bh(&sl->lock)
| ...
... | sl->tty = NULL //(1)
sl_tx_timeout() | spin_unlock_bh(&sl->lock)
spin_lock(&sl->lock); |
... | ...
tty_chars_in_buffer(sl->tty)|
if (tty->ops->..) //(2) |
... | synchronize_rcu()
We set NULL to sl->tty in position (1) and dereference sl->tty
in position (2).
This patch adds check in sl_tx_timeout(). If sl->tty equals to
NULL, sl_tx_timeout() will goto out.
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Jiri Slaby <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20220405132206.55291-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/net/slip/slip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c
index 5d864f812955..3ec8d16a4633 100644
--- a/drivers/net/slip/slip.c
+++ b/drivers/net/slip/slip.c
@@ -471,7 +471,7 @@ static void sl_tx_timeout(struct net_device *dev)
spin_lock(&sl->lock);
if (netif_queue_stopped(dev)) {
- if (!netif_running(dev))
+ if (!netif_running(dev) || !sl->tty)
goto out;
/* May be we must check transmitter timeout here ?
--
2.35.1
prev parent reply other threads:[~2022-04-12 1:08 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-12 0:51 [PATCH AUTOSEL 4.19 01/12] drm/amd: Add USBC connector ID Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 02/12] drm/amdkfd: Check for potential null return of kmalloc_array() Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 03/12] Drivers: hv: vmbus: Prevent load re-ordering when reading ring buffer Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 04/12] scsi: target: tcmu: Fix possible page UAF Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 05/12] scsi: ibmvscsis: Increase INITIAL_SRP_LIMIT to 1024 Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 06/12] net: micrel: fix KS8851_MLL Kconfig Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 07/12] ata: libata-core: Disable READ LOG DMA EXT for Samsung 840 EVOs Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 08/12] gpu: ipu-v3: Fix dev_dbg frequency output Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 09/12] arm64: alternatives: mark patch_alternative() as `noinstr` Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 10/12] drm/amd/display: Fix allocate_mst_payload assert on resume Sasha Levin
2022-04-12 0:51 ` [PATCH AUTOSEL 4.19 11/12] scsi: mvsas: Add PCI ID of RocketRaid 2640 Sasha Levin
2022-04-12 0:51 ` Sasha Levin [this message]
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=20220412005148.351391-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=dmitry.torokhov@gmail.com \
--cc=duoming@zju.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkl@pengutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).