В ядре Linux устранена следующая уязвимость:
nfsd: исправлена утечка кредитных ссылок в nfsd_nl_threads_set_doit().
syzbot сообщил об утечке памяти структуры cred. [0]
nfsd_nl_threads_set_doit() передает get_current_cred() в
nfsd_svc(), но put_cred() после этого не вызывается. В конце концов учетные данные передаются в _svc_xprt_create(),
который вызывает get_cred() с учетной записью для структуры svc_xprt. Владение счетчиком ссылок функцией get_current_cred() не является
переносится куда угодно и просто сливается.
nfsd_svc() также вызывается из write_threads(), но это
не перемещайте туда файл->f_cred.
nfsd_nl_threads_set_doit() вызывается из sendmsg() и
current->cred не исчезает.
Давайте используем current_cred() в nfsd_nl_threads_set_doit().
[0]:
ОШИБКА: утечка памяти.
объект без ссылки 0xffff888108b89480 (размер 184):
comm "syz-executor", pid 5994, jiffies 4294943386
шестнадцатеричный дамп (первые 32 байта):
01 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 ..............
обратная трассировка (crc 369454a7):
kmemleak_alloc_recursive include/linux/kmemleak.h:44 [встроенный]
slab_post_alloc_hook мм/slub.c:4958 [встроенный]
slab_alloc_node мм/slub.c:5263 [встроенный]
kmem_cache_alloc_noprof+0x412/0x580 мм/slub.c:5270
подготовить_creds+0x22/0x600 ядро/cred.c:185
copy_creds+0x44/0x290 ядро/cred.c:286
copy_process+0x7a7/0x2870 ядро/fork.c:2086
kernel_clone+0xac/0x6e0 ядро/fork.c:2651
__do_sys_clone+0x7f/0xb0 ядро/fork.c:2792
do_syscall_x64 Arch/x86/entry/syscall_64.c:63 [встроенный]
do_syscall_64+0xa4/0xf80 Arch/x86/entry/syscall_64.c:94
запись_SYSCALL_64_after_hwframe+0x77/0x7f
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: nfsd: Fix cred ref leak in nfsd_nl_threads_set_doit(). syzbot reported memory leak of struct cred. [0] nfsd_nl_threads_set_doit() passes get_current_cred() to nfsd_svc(), but put_cred() is not called after that. The cred is finally passed down to _svc_xprt_create(), which calls get_cred() with the cred for struct svc_xprt. The ownership of the refcount by get_current_cred() is not transferred to anywhere and is just leaked. nfsd_svc() is also called from write_threads(), but it does not bump file->f_cred there. nfsd_nl_threads_set_doit() is called from sendmsg() and current->cred does not go away. Let's use current_cred() in nfsd_nl_threads_set_doit(). [0]: BUG: memory leak unreferenced object 0xffff888108b89480 (size 184): comm "syz-executor", pid 5994, jiffies 4294943386 hex dump (first 32 bytes): 01 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 369454a7): kmemleak_alloc_recursive include/linux/kmemleak.h:44 [inline] slab_post_alloc_hook mm/slub.c:4958 [inline] slab_alloc_node mm/slub.c:5263 [inline] kmem_cache_alloc_noprof+0x412/0x580 mm/slub.c:5270 prepare_creds+0x22/0x600 kernel/cred.c:185 copy_creds+0x44/0x290 kernel/cred.c:286 copy_process+0x7a7/0x2870 kernel/fork.c:2086 kernel_clone+0xac/0x6e0 kernel/fork.c:2651 __do_sys_clone+0x7f/0xb0 kernel/fork.c:2792 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xa4/0xf80 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f