В ядре Linux была устранена следующая уязвимость: 9p: don't decrement a server-owned zero nlink A 9P2000.L server может сообщить nlink0 для обычного файла, который все еще существует. На монтировании кэшасвободного или кэшаfscache, поиск хранит значение set_nlink(). Более поздний успешный вызов v9fs_dec_count(), который по-прежнему вызывает drop_nlink() для не директории. drop_nlink() предупреждает, и количество неподписанных ссылок оборачивается в 4294967295. fstat() на дескриптор, открытый до того, как отключенная ссылка показывает 0 до и 4294967295 после.
The warning on the unpatched kernel, trimmed: WARNING: fs/inode.c:408 at drop_nlink+0xac/0xd0, CPU#1: trigger/188 CPU: 1 UID: 0 PID: 188 Comm: trigger Tainted: G N 7.3.0-rc4-00537-ga3ff15db6820 #1 PREEMPT(lazy) RIP: 0010:drop_nlink+0xac/0xd0 Call Trace: <TASK> v9fs_remove+0x529/0x750 vfs_unlink+0x2f0/0xbd0 filename_unlinkat+0x340/0x6c0 __x64_sys_unlink+0x46/0x70 do_syscall_64+0xe8/0x4f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> ---[ end trace 0000000000000000 ]--- Directories whose cached nlink is at most 2 already skip this decrement, because the exported filesystem may not maintain nlink (commit ac89b2ef9b559). cache=none skips it as well (commit 574aa0b479947). cache=mmap does not take this path: it sets neither CACHE_META nor CACHE_LOOSE. Обычный файл в кэше — свободный или кэш — fscache по-прежнему работает. Его количество пришло из GETATTR и может уже равняться нулю, поэтому пропустите уменьшение, когда i_nlink уже равен 0.
Проверено на 7.3-rc4-00537-ga3ff15db6820 только с этим изменением. Сервер, который рекламирует nlink0 и принимает отсоединение, больше не предупреждает, и открытый дескриптор остается на nlink 0. Честный сервер на том же самом креплении по-прежнему идет от 1 до 0.
Отклонённая ссылка оставляет счёт без изменений. cachenone is unchanged. С panic_on_warn неисправленное ядро паникует на предупреждение; исправленное ядро не делает.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: 9p: don't decrement a server-owned zero nlink A 9P2000.L server can report nlink=0 for a regular file that still exists. On a cache=loose or cache=fscache mount, lookup stores that value with set_nlink(). A later successful unlink calls v9fs_dec_count(), which still calls drop_nlink() for a non-directory. drop_nlink() warns, and the unsigned link count wraps to 4294967295. fstat() on a descriptor opened before the unlink shows 0 before and 4294967295 after. The warning on the unpatched kernel, trimmed: WARNING: fs/inode.c:408 at drop_nlink+0xac/0xd0, CPU#1: trigger/188 CPU: 1 UID: 0 PID: 188 Comm: trigger Tainted: G N 7.3.0-rc4-00537-ga3ff15db6820 #1 PREEMPT(lazy) RIP: 0010:drop_nlink+0xac/0xd0 Call Trace: <TASK> v9fs_remove+0x529/0x750 vfs_unlink+0x2f0/0xbd0 filename_unlinkat+0x340/0x6c0 __x64_sys_unlink+0x46/0x70 do_syscall_64+0xe8/0x4f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK> ---[ end trace 0000000000000000 ]--- Directories whose cached nlink is at most 2 already skip this decrement, because the exported filesystem may not maintain nlink (commit ac89b2ef9b559). cache=none skips it as well (commit 574aa0b479947). cache=mmap does not take this path: it sets neither CACHE_META nor CACHE_LOOSE. A regular file on cache=loose or cache=fscache still does. Its count came from GETATTR and may already be zero, so skip the decrement when i_nlink is already 0. Verified on 7.3-rc4-00537-ga3ff15db6820 with only this change. A server that advertises nlink=0 and accepts the unlink no longer warns, and the open descriptor stays at nlink 0. An honest server on the same mount still goes from 1 to 0. A rejected unlink leaves the count unchanged. cache=none is unchanged. With panic_on_warn the unpatched kernel panics on the warning; the patched kernel does not.