В ядре Linux устранена следующая уязвимость:
nfs: исправить UAF при прямой записи
В производстве мы постоянно сталкиваемся со следующим предупреждением
------------[вырезать здесь]------------
refcount_t: опустошение; использовать после бесплатно. ВНИМАНИЕ: ЦП: 17 PID: 1800359 в lib/refcount.c:28 refcount_warn_saturate+0x9c/0xe0
Рабочая очередь: nfsiod nfs_direct_write_schedule_work [nfs]
RIP: 0010:refcount_warn_saturate+0x9c/0xe0
ПКРУ: 55555554
Отслеживание вызова:
<ЗАДАЧА>
? __warn+0x9f/0x130
? refcount_warn_saturate+0x9c/0xe0
? report_bug+0xcc/0x150
? handle_bug+0x3d/0x70
? exc_invalid_op+0x16/0x40
? asm_exc_invalid_op+0x16/0x20
? refcount_warn_saturate+0x9c/0xe0
nfs_direct_write_schedule_work+0x237/0x250 [nfs]
процесс_one_work+0x12f/0x4a0
рабочий_поток+0x14e/0x3b0
? ZSTD_getCParams_internal+0x220/0x220
kthread+0xdc/0x120
? __btf_name_valid+0xa0/0xa0
ret_from_fork+0x1f/0x30
Это связано с тем, что мы выполняем nfs_direct_request дважды подряд. Источником этого является то, что когда нам нужно отправить запросы на фиксацию, мы
обработать их и отправить, а затем на пути завершения для
фиксировать запросы, которые у нас есть
если (nfs_commit_end(cinfo.mds))
nfs_direct_write_complete (dreq);
Однако, поскольку мы отправляем асинхронные запросы, иногда у нас возникает
тот, который завершается до того, как мы отправим следующий, поэтому в конечном итоге мы вызываем
дважды завершите nfs_direct_request.
Единственное место, где мы используем nfs_generic_commit_list(), — это
__nfs_commit_inode, который оборачивает этот вызов в
nfs_commit_begin();
nfs_commit_end();
Это общий шаблон для этого стиля обработки завершения.
это также повторяется в прямом коде с помощью get_dreq()/put_dreq().
вызовы там, где мы обрабатываем события, а также в путях завершения. Исправьте это, используя тот же шаблон для запросов на фиксацию. Раньше, когда у меня запускался стресс Rockdb на 200 узлах, это предупреждение появлялось
каждые 10 минут.
С моим патчем стресс-тест работает уже несколько часов без хлопков.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: nfs: fix UAF in direct writes In production we have been hitting the following warning consistently ------------[ cut here ]------------ refcount_t: underflow; use-after-free. WARNING: CPU: 17 PID: 1800359 at lib/refcount.c:28 refcount_warn_saturate+0x9c/0xe0 Workqueue: nfsiod nfs_direct_write_schedule_work [nfs] RIP: 0010:refcount_warn_saturate+0x9c/0xe0 PKRU: 55555554 Call Trace: <TASK> ? __warn+0x9f/0x130 ? refcount_warn_saturate+0x9c/0xe0 ? report_bug+0xcc/0x150 ? handle_bug+0x3d/0x70 ? exc_invalid_op+0x16/0x40 ? asm_exc_invalid_op+0x16/0x20 ? refcount_warn_saturate+0x9c/0xe0 nfs_direct_write_schedule_work+0x237/0x250 [nfs] process_one_work+0x12f/0x4a0 worker_thread+0x14e/0x3b0 ? ZSTD_getCParams_internal+0x220/0x220 kthread+0xdc/0x120 ? __btf_name_valid+0xa0/0xa0 ret_from_fork+0x1f/0x30 This is because we're completing the nfs_direct_request twice in a row. The source of this is when we have our commit requests to submit, we process them and send them off, and then in the completion path for the commit requests we have if (nfs_commit_end(cinfo.mds)) nfs_direct_write_complete(dreq); However since we're submitting asynchronous requests we sometimes have one that completes before we submit the next one, so we end up calling complete on the nfs_direct_request twice. The only other place we use nfs_generic_commit_list() is in __nfs_commit_inode, which wraps this call in a nfs_commit_begin(); nfs_commit_end(); Which is a common pattern for this style of completion handling, one that is also repeated in the direct code with get_dreq()/put_dreq() calls around where we process events as well as in the completion paths. Fix this by using the same pattern for the commit requests. Before with my 200 node rocksdb stress running this warning would pop every 10ish minutes. With my patch the stress test has been running for several hours without popping.
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 7
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
— |
5.10.215
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.11
|
5.15.154
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.16
|
6.1.84
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.2
|
6.6.24
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.7
|
6.7.12
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.8
|
6.8.3
|
|
Debian Debian_Linux
cpe:2.3:o:debian:debian_linux:10.0:*:*:*:*:*:*:*
|
— | — |