memory leak in do_timer_create
syzbot
syzbotHello,
syzbot found the following issue on:
HEAD commit: 24172e0d7990 Merge tag 'arm64-fixes' of git://git.kernel.o.. git tree: upstream console output: https://syzkaller.appspot.com/x/log.txt?x=165417cd980000 kernel config: https://syzkaller.appspot.com/x/.config?x=cb128cd5cb439809 dashboard link: https://syzkaller.appspot.com/bug?extid=9c47ad18f978d4394986 compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40 syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15004914580000 C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ea6b42580000
Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/ded911fa4408/disk-24172e0d.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/a1f3e61cb784/vmlinux-24172e0d.xz
kernel image: https://storage.googleapis.com/syzbot-assets/b92fd0e25cb7/bzImage-24172e0d.xz
IMPORTANT: if you fix the issue, please add the following tag to the commit:
2025/11/12 09:47:51 executed programs: 5
BUG: memory leak
unreferenced object 0xffff888108465800 (size 384):
comm "syz.0.17", pid 6100, jiffies 4294944668
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 1025e73e):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4983 [inline]
slab_alloc_node mm/slub.c:5288 [inline]
kmem_cache_alloc_noprof+0x397/0x5a0 mm/slub.c:5295
alloc_posix_timer kernel/time/posix-timers.c:429 [inline]
do_timer_create+0xe0/0x800 kernel/time/posix-timers.c:478
__do_sys_timer_create kernel/time/posix-timers.c:584 [inline]
__se_sys_timer_create kernel/time/posix-timers.c:573 [inline]
__x64_sys_timer_create+0xdb/0xf0 kernel/time/posix-timers.c:573
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
BUG: memory leak
unreferenced object 0xffff8881084a0000 (size 384):
comm "syz.0.18", pid 6104, jiffies 4294944670
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc 63c47fd0):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4983 [inline]
slab_alloc_node mm/slub.c:5288 [inline]
kmem_cache_alloc_noprof+0x397/0x5a0 mm/slub.c:5295
alloc_posix_timer kernel/time/posix-timers.c:429 [inline]
do_timer_create+0xe0/0x800 kernel/time/posix-timers.c:478
__do_sys_timer_create kernel/time/posix-timers.c:584 [inline]
__se_sys_timer_create kernel/time/posix-timers.c:573 [inline]
__x64_sys_timer_create+0xdb/0xf0 kernel/time/posix-timers.c:573
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
BUG: memory leak
unreferenced object 0xffff8881084a0180 (size 384):
comm "syz.0.19", pid 6107, jiffies 4294944671
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc d769495f):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4983 [inline]
slab_alloc_node mm/slub.c:5288 [inline]
kmem_cache_alloc_noprof+0x397/0x5a0 mm/slub.c:5295
alloc_posix_timer kernel/time/posix-timers.c:429 [inline]
do_timer_create+0xe0/0x800 kernel/time/posix-timers.c:478
__do_sys_timer_create kernel/time/posix-timers.c:584 [inline]
__se_sys_timer_create kernel/time/posix-timers.c:573 [inline]
__x64_sys_timer_create+0xdb/0xf0 kernel/time/posix-timers.c:573
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
BUG: memory leak
unreferenced object 0xffff888108464600 (size 384):
comm "syz.0.20", pid 6127, jiffies 4294945201
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc a3c907e):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4983 [inline]
slab_alloc_node mm/slub.c:5288 [inline]
kmem_cache_alloc_noprof+0x397/0x5a0 mm/slub.c:5295
alloc_posix_timer kernel/time/posix-timers.c:429 [inline]
do_timer_create+0xe0/0x800 kernel/time/posix-timers.c:478
__do_sys_timer_create kernel/time/posix-timers.c:584 [inline]
__se_sys_timer_create kernel/time/posix-timers.c:573 [inline]
__x64_sys_timer_create+0xdb/0xf0 kernel/time/posix-timers.c:573
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
BUG: memory leak
unreferenced object 0xffff8881084a0300 (size 384):
comm "syz.0.21", pid 6128, jiffies 4294945201
hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace (crc bb0da4da):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline]
slab_post_alloc_hook mm/slub.c:4983 [inline]
slab_alloc_node mm/slub.c:5288 [inline]
kmem_cache_alloc_noprof+0x397/0x5a0 mm/slub.c:5295
alloc_posix_timer kernel/time/posix-timers.c:429 [inline]
do_timer_create+0xe0/0x800 kernel/time/posix-timers.c:478
__do_sys_timer_create kernel/time/posix-timers.c:584 [inline]
__se_sys_timer_create kernel/time/posix-timers.c:573 [inline]
__x64_sys_timer_create+0xdb/0xf0 kernel/time/posix-timers.c:573
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0xa4/0xfa0 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7fconnection error: failed to recv *flatrpc.ExecutorMessageRawT: EOF
---
This report is generated by a bot. It may contain errors. See https://goo.gl/tpsmEJ for more information about syzbot. syzbot engineers can be reached at [email protected].
syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title
If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.
If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)
If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report
If you want to undo deduplication, reply with:
#syz undup
syzbot
syzbotForwarded:
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject:
Author: [email protected]
#syz test
syzbot
syzbotForwarded:
In reply to syzbotFor archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject:
Author: [email protected]
#syz test
syzbot
syzbotForwarded:
In reply to syzbotFor archival purposes, forwarding an incoming command email to [email protected], [email protected].
For archival purposes, forwarding an incoming command email to [email protected], [email protected].
***
Subject:
Author: [email protected]
#syz test
PATCH 1/1 posix-timers: Plug a potential memory leak
In reply to syzbotWhen posix timer creation is set to allocate a given timer ID and the access to the user space value faults, the function terminates without freeing the already allocated posix timer structure.
Move the allocation after the user space access to cure that.
--- kernel/time/posix-timers.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/time/posix-timers.c +6 -6
@@ -475,12 +475,6 @@ static int do_timer_create(clockid_t whiif (!kc->timer_create)return -EOPNOTSUPP ; - new_timer =alloc_posix_timer (); -if (unlikely (!new_timer)) -return -EAGAIN ; - -spin_lock_init (&new_timer->it_lock); -/* Special case for CRIU to restore timers with a given timer ID. */ if (unlikely (current->signal->timer_create_restore_ids)) {if (copy_from_user (&req_id, created_timer_id,sizeof (req_id)))
@@ -490,6 +484,12 @@ static int do_timer_create(clockid_t whireturn -EINVAL ; } + new_timer =alloc_posix_timer (); +if (unlikely (!new_timer)) +return -EAGAIN ; + +spin_lock_init (&new_timer->it_lock); +/* * Add the timer to the hash table. The timer is not yet valid * after insertion, but has a unique ID allocated.