]> git.hungrycats.org Git - linux/commitdiff
slip: remove slip_hangup() to fix use-after-free in slip_receive_buf()
authorEric Dumazet <edumazet@google.com>
Wed, 26 Aug 2026 10:52:38 +0000 (10:52 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 27 Aug 2026 19:38:27 +0000 (12:38 -0700)
Jaeyoung Chung and Eulgyu Kim reported a slab-use-after-free read
in slip_receive_buf() when racing against tty hangup.

tty_ldisc_hangup() calls ld->ops->hangup() while holding only
a read lock on tty->ldisc_sem (via tty_ldisc_ref()).
Because slip_hangup() simply called slip_close(), it ran concurrently
with reader functions such as slip_receive_buf().

slip_close() unregisters and frees the net device and its private
struct slip, causing concurrent reader threads in slip_receive_buf()
to dereference freed memory.

Line discipline close() is already guaranteed to be called under
the write lock of tty->ldisc_sem during hangup processing
(in tty_ldisc_reinit() or tty_ldisc_kill()).

Remove slip_hangup() so teardown is serialized cleanly by slip_close().

Fixes: 5342b77c4123 ("slip: Clean up create and destroy")
Reported-by: Jaeyoung Chung <jjy600901@snu.ac.kr>
Reported-by: Eulgyu Kim <eulgyukim@snu.ac.kr>
Closes: https://lore.kernel.org/netdev/20260825150655.1450271-1-jjy600901@snu.ac.kr/
Cc: Qingfang Deng <qingfang.deng@linux.dev>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260826105238.3323436-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/slip/slip.c

index 85b2438e892351e83946c546bea1c9185e98f3c1..fdd6f63fb849e339ec9e345750caec98ae2e9c00 100644 (file)
@@ -886,8 +886,6 @@ err_exit:
  * Close down a SLIP channel.
  * This means flushing out any pending queues, and then returning. This
  * call is serialized against other ldisc functions.
- *
- * We also use this method fo a hangup event
  */
 
 static void slip_close(struct tty_struct *tty)
@@ -915,11 +913,6 @@ static void slip_close(struct tty_struct *tty)
        unregister_netdev(sl->dev);
        /* sl_uninit() has dropped the slip_devs[] entry by now */
 }
-
-static void slip_hangup(struct tty_struct *tty)
-{
-       slip_close(tty);
-}
  /************************************************************************
   *                    STANDARD SLIP ENCAPSULATION                      *
   ************************************************************************/
@@ -1280,7 +1273,6 @@ static struct tty_ldisc_ops sl_ldisc = {
        .name           = "slip",
        .open           = slip_open,
        .close          = slip_close,
-       .hangup         = slip_hangup,
        .ioctl          = slip_ioctl,
        .receive_buf    = slip_receive_buf,
        .write_wakeup   = slip_write_wakeup,