The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 0/2] ipack: ipoctal: fix races and UAFs during module removal
@ 2026-07-01  2:01 Pei Xiao
  2026-07-01  2:01 ` [PATCH 1/2] ipack: ipoctal: fix UAF, null-ptr-deref, and use-after-free in cleanup on remove Pei Xiao
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Pei Xiao @ 2026-07-01  2:01 UTC (permalink / raw)
  To: vaibhavgupta40, jens.taprogge, gregkh, kees, industrypack-devel,
	linux-kernel
  Cc: Pei Xiao, Shuangpeng Bai

When the ipoctal device is removed while a userspace process still
holds a tty fd open, several races and use-after-free bugs can be
triggered.  This series addresses the following issues:

1. UAF of struct ipoctal: the remove callback freed ipoctal via
   kfree() while in-flight tty ops could still be accessing it.

2. NULL dereference in ipoctal_write_tty(): __ipoctal_remove() freed
   xmit_buf while a concurrent write() could still dereference it.

3. UAF in ipoctal_cleanup(): ipack_put_carrier(ipoctal->dev) walked
   through ipoctal->dev to reach the carrier module, but the
   ipack_device could have already been freed by then.

4. Page faults due to devm_ioremap() regions being unmapped while
   tty ops still access hardware registers.

5. TOCTOU race between the removed-flag check and the subsequent
   hardware access in each tty op.

Patch 1 introduces kref-based lifetime management, caches the
carrier owner module pointer to avoid chasing a dangling dev->bus
pointer, adds a "removed" flag with checks in all tty ops that
touch hardware, and adds a NULL guard on xmit_buf in the write path.

Patch 2 adds a read-write semaphore (remove_sem) to close the
TOCTOU window: the tty ops hold the read lock for the duration of
the hardware access, while __ipoctal_remove() acquires the write
lock when setting the removed flag, ensuring that once removed is
true no in-flight tty op is still inside a critical section.

Reported-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
Link: https://lore.kernel.org/lkml/178144969601.60470.1257088106279546587@gmail.com/

Pei Xiao (2):
  ipack: ipoctal: fix UAF, null-ptr-deref, and use-after-free in cleanup
    on remove
  ipack: ipoctal: add rwsem to guard against TOCTOU in remove path

 drivers/ipack/devices/ipoctal.c | 60 ++++++++++++++++++++++++++++++---
 1 file changed, 56 insertions(+), 4 deletions(-)

--
2.25.1


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

end of thread, other threads:[~2026-07-01 11:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01  2:01 [PATCH 0/2] ipack: ipoctal: fix races and UAFs during module removal Pei Xiao
2026-07-01  2:01 ` [PATCH 1/2] ipack: ipoctal: fix UAF, null-ptr-deref, and use-after-free in cleanup on remove Pei Xiao
2026-07-01  2:01 ` [PATCH 2/2] ipack: ipoctal: add rwsem to guard against TOCTOU in remove path Pei Xiao
2026-07-01  5:41 ` [PATCH 0/2] ipack: ipoctal: fix races and UAFs during module removal Greg KH
2026-07-01  6:16   ` Pei Xiao
2026-07-01 10:37     ` Greg KH
2026-07-01 11:08       ` Pei Xiao

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