Linux Serial subsystem development
 help / color / mirror / Atom feed
* [PATCH v3 0/2] tty: n_gsm: fix gsm_queue() UAF and add a base regression test
@ 2026-06-20 16:56 Weiming Shi
  2026-06-20 16:56 ` [PATCH v3 1/2] tty: n_gsm: fix use-after-free in gsm_queue() control frame dispatch Weiming Shi
  2026-06-20 16:56 ` [PATCH v3 2/2] selftests: tty: add base regression test for n_gsm line discipline Weiming Shi
  0 siblings, 2 replies; 3+ messages in thread
From: Weiming Shi @ 2026-06-20 16:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Jiri Slaby, Shuah Khan
  Cc: Starke, Daniel, Xiang Mei, linux-serial, linux-kselftest,
	linux-kernel, Weiming Shi

The receive worker walks gsm->dlci[] without gsm->mutex while a
concurrent GSMIOC_SETCONF -> gsm_cleanup_mux() frees the DLCIs, so the
control handlers can dereference a freed gsm_dlci. v1's NULL check only
narrowed the window; this series fixes the use-after-free itself by
pinning each DLCI the dispatch dereferences with its existing tty_port
reference (dlci_get/put), so the data path stays lock-free.

v3:
 - Drop the cmpxchg() in gsm_dlci_free(); the pin alone fixes the UAF (Greg).
 - Keep the addr bounds check at each call site, not in the helper (Daniel).
 - Correct the Fixes: tag to the refcount commit (Daniel).
 - Add the AI-assist tag to patch 1 and trim the comments (Daniel).

Verification (KASAN, panic_on_warn=1): a reproducer targeting the MSC
handler crashes the unpatched kernel and survives 200+ race rounds on
this series. The selftest passes on both the clean and patched kernel
(pass:3 fail:0 skip:0).

Weiming Shi (2):
  tty: n_gsm: fix use-after-free in gsm_queue() control frame dispatch
  selftests: tty: add base regression test for n_gsm line discipline

 drivers/tty/n_gsm.c                          |  73 +++-
 tools/testing/selftests/tty/.gitignore       |   1 +
 tools/testing/selftests/tty/Makefile         |   2 +-
 tools/testing/selftests/tty/config           |   1 +
 tools/testing/selftests/tty/tty_n_gsm_test.c | 344 +++++++++++++++++++
 5 files changed, 414 insertions(+), 7 deletions(-)
 create mode 100644 tools/testing/selftests/tty/tty_n_gsm_test.c

-- 
2.43.0


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

end of thread, other threads:[~2026-06-20 17:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-20 16:56 [PATCH v3 0/2] tty: n_gsm: fix gsm_queue() UAF and add a base regression test Weiming Shi
2026-06-20 16:56 ` [PATCH v3 1/2] tty: n_gsm: fix use-after-free in gsm_queue() control frame dispatch Weiming Shi
2026-06-20 16:56 ` [PATCH v3 2/2] selftests: tty: add base regression test for n_gsm line discipline Weiming Shi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox