]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
l2tp: fix tunnel and session refcount leak on seq_file release
authorEric Dumazet <edumazet@google.com>
Tue, 11 Aug 2026 14:46:51 +0000 (14:46 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 13 Aug 2026 09:49:31 +0000 (11:49 +0200)
commit9006c116dd111d457bf5d074990210f70a4ad2c8
tree1e3e52af0001c78554a494b98e1a7e5fe62058c6
parent120977e2c096deea4e866e4273be9220b957c29e
l2tp: fix tunnel and session refcount leak on seq_file release

In pppol2tp_proc_open() and l2tp_dfs_seq_open(), iteration state
(pd->tunnel and pd->session) is kept in seq_file private data to allow
iteration across multiple read() system calls.

However, if userspace closes /proc/net/pppol2tp or /sys/kernel/debug/l2tp/tunnels
before reading to end-of-file (EOF), any tunnel or session reference stored in
pd->tunnel / pd->session is left un-dropped when seq_file private data is freed.

Fix this by dropping any remaining pd->tunnel and pd->session references in
pppol2tp_proc_release() and l2tp_dfs_seq_release() when closing the file.

Fixes: 0e0c3fee3a59 ("l2tp: hold reference on tunnels printed in pppol2tp proc file")
Fixes: f726214d9b23 ("l2tp: hold reference on tunnels printed in l2tp/tunnels debugfs file")
Reported-by: syzbot+d6fa74e3f19d6ee01e3a@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/netdev/6a760f32.01d0871a.3a0d52.004f.GAE@google.com/T/#u
Assisted-by: Jetski:Gemini-3.1-Pro
Cc: James Chapman <jchapman@katalix.com>
Cc: Guillaume Nault <gnault@redhat.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260811144651.2733424-1-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/l2tp/l2tp_debugfs.c
net/l2tp/l2tp_ppp.c