linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: daniel.starke@siemens.com
To: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
	jirislaby@kernel.org
Cc: linux-kernel@vger.kernel.org, Daniel Starke <daniel.starke@siemens.com>
Subject: [PATCH 1/1] tty: n_gsm: fix deadlock in gsmtty_open()
Date: Thu, 17 Feb 2022 00:05:55 -0800	[thread overview]
Message-ID: <20220217080555.5387-7-daniel.starke@siemens.com> (raw)
In-Reply-To: <20220217080555.5387-1-daniel.starke@siemens.com>

In the current implementation the user may open a virtual tty which then
could fail to establish the underlying DLCI. The function gsmtty_open()
gets stuck in tty_port_block_til_ready() while waiting for a carrier rise.
This happens if the remote side fails to acknowledge the link establishment
request in time or completely. At some point gsm_dlci_close() is called
to abort the link establishment attempt. The function tries to inform the
associated virtual tty by performing a hangup. But the blocking loop within
tty_port_block_til_ready() is not informed about this event.
The patch proposed here fixes this by resetting the initialization state of
the virtual tty to ensure the loop exits and triggering it to make
tty_port_block_til_ready() return.

Fixes: e1eaea46bb40 ("tty: n_gsm line discipline")
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Starke <daniel.starke@siemens.com>
---
 drivers/tty/n_gsm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index 0b1808e3a912..e61a47c349e3 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -1451,6 +1451,9 @@ static void gsm_dlci_close(struct gsm_dlci *dlci)
 	if (dlci->addr != 0) {
 		tty_port_tty_hangup(&dlci->port, false);
 		kfifo_reset(&dlci->fifo);
+		/* Ensure that gsmtty_open() can return. */
+		tty_port_set_initialized(&dlci->port, 0);
+		wake_up_interruptible(&dlci->port.open_wait);
 	} else
 		dlci->gsm->dead = true;
 	/* Unregister gsmtty driver,report gsmtty dev remove uevent for user */
-- 
2.25.1


  parent reply	other threads:[~2022-02-17  8:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-17  8:05 [PATCH 1/1] tty: n_gsm: fix encoding of control signal octet bit DV daniel.starke
2022-02-17  8:05 ` [PATCH 1/1] tty: n_gsm: fix encoding of command/response bit daniel.starke
2022-02-17  8:05 ` [PATCH 1/1] tty: n_gsm: fix proper link termination after failed open daniel.starke
2022-02-17  8:05 ` [PATCH 1/1] tty: n_gsm: fix NULL pointer access due to DLCI release daniel.starke
2022-02-17  8:05 ` [PATCH 1/1] tty: n_gsm: fix wrong tty control line for flow control daniel.starke
2022-02-17  8:05 ` [PATCH 1/1] tty: n_gsm: fix wrong modem processing in convergence layer type 2 daniel.starke
2022-02-17  8:05 ` daniel.starke [this message]
2022-02-17  9:56 ` [PATCH 1/1] tty: n_gsm: fix encoding of control signal octet bit DV Greg KH

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=20220217080555.5387-7-daniel.starke@siemens.com \
    --to=daniel.starke@siemens.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@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).