All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tty: n_gsm: avoid reactivation without previous cleanup
@ 2026-07-06 14:20 Dmitry Antipov
  2026-07-06 14:20 ` [PATCH 2/2] tty: n_gsm: issue mutex_destroy() from gsm_dlci_free() Dmitry Antipov
  2026-07-06 14:35 ` [PATCH 1/2] tty: n_gsm: avoid reactivation without previous cleanup Greg Kroah-Hartman
  0 siblings, 2 replies; 8+ messages in thread
From: Dmitry Antipov @ 2026-07-06 14:20 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby
  Cc: linux-serial, lvc-project, Dmitry Antipov,
	syzbot+b5d1f455d385b2c7da3c

Initially reported by syzbot at as memory leak, actual issue is an attempt
to configure DLCI 0 (via 'ioctl(..., GSMIOC_SETCONF_EXT, ...)') more than
once without previous cleanup (likely requested with GSM_FL_RESTART). To
prevent such a scenario, including racy attempts to do it from multiple
threads, adjust 'gsm_activate_mux()' to grab GSM mux's mutex and throw
-EBUSY if DLCI 0 was configured already.

Reported-by: syzbot+b5d1f455d385b2c7da3c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b5d1f455d385b2c7da3c
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/tty/n_gsm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
index c13e050de83b..ce447477ccf3 100644
--- a/drivers/tty/n_gsm.c
+++ b/drivers/tty/n_gsm.c
@@ -3186,6 +3186,11 @@ static int gsm_activate_mux(struct gsm_mux *gsm)
 	struct gsm_dlci *dlci;
 	int ret;
 
+	guard(mutex)(&gsm->mutex);
+
+	if (unlikely(gsm->dlci[0]))
+		return -EBUSY;
+
 	dlci = gsm_dlci_alloc(gsm, 0);
 	if (dlci == NULL)
 		return -ENOMEM;
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-07-07  5:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-06 14:20 [PATCH 1/2] tty: n_gsm: avoid reactivation without previous cleanup Dmitry Antipov
2026-07-06 14:20 ` [PATCH 2/2] tty: n_gsm: issue mutex_destroy() from gsm_dlci_free() Dmitry Antipov
2026-07-07  3:24   ` Jiri Slaby
2026-07-06 14:35 ` [PATCH 1/2] tty: n_gsm: avoid reactivation without previous cleanup Greg Kroah-Hartman
2026-07-06 14:49   ` Dmitry Antipov
2026-07-06 15:18     ` Greg Kroah-Hartman
2026-07-07  5:47       ` Dmitry Antipov
2026-07-07  5:58         ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.