В ядре Linux устранена следующая уязвимость:
кэш-файлы: исправлено использование фрагментов после освобождения в кэшеfiles_withdraw_cookie(). В ходе стресс-теста с внедрением ошибок мы столкнулись со следующей проблемой:
==============================================================
ОШИБКА: KASAN: slab-use-after-free в кэшеfiles_withdraw_cookie+0x4d9/0x600
Чтение размера 8 по адресу ffff888118efc000 с помощью задачи kworker/u78:0/109. ЦП: 13 PID: 109 Связь: kworker/u78:0 Не испорчен 6.8.0-грязный #566
Отслеживание вызова:
<ЗАДАЧА>
kasan_report+0x93/0xc0
кэшфайлы_withdraw_cookie+0x4d9/0x600
fscache_cookie_state_machine+0x5c8/0x1230
fscache_cookie_worker+0x91/0x1c0
процесс_one_work+0x7fa/0x1800
[...]
Выделено заданием 117:
kmalloc_trace+0x1b3/0x3c0
кэшфайлы_acquire_volume+0xf3/0x9c0
fscache_create_volume_work+0x97/0x150
процесс_one_work+0x7fa/0x1800
[...]
Освобожден заданием 120301:
kfree+0xf1/0x2c0
кэшфайлы_withdraw_cache+0x3fa/0x920
кэшфайлы_put_unbind_pincount+0x1f6/0x250
кэшфайлы_daemon_release+0x13b/0x290
__fput+0x204/0xa00
Task_work_run+0x139/0x230
do_exit+0x87a/0x29b0
[...]
==============================================================
Ниже приведен процесс, вызывающий проблему:
р1 | п2
------------------------------------------------------------
fscache_begin_lookup
fscache_begin_volume_access
fscache_cache_is_live(fscache_cache)
кэшфайлы_daemon_release
кэшфайлы_put_unbind_pincount
кэшфайлы_daemon_unbind
cachefiles_withdraw_cache
fscache_withdraw_cache
fscache_set_cache_state (кэш, FSCACHE_CACHE_IS_WITHDRAWN);
cachefiles_withdraw_objects (кэш)
fscache_wait_for_objects(fscache)
atomic_read(&fscache_cache->object_count) == 0
fscache_perform_lookup
кэшфайлы_lookup_cookie
кэшфайлы_alloc_object
refcount_set(&object->ref, 1);
объект->объем = объем
fscache_count_object (vcookie-> кеш);
atomic_inc(&fscache_cache->object_count)
кэшфайлы_withdraw_volumes
cachefiles_withdraw_volume
fscache_withdraw_volume
__cachefiles_free_volume
kfree (cachefiles_volume)
fscache_cookie_state_machine
кэшфайлы_withdraw_cookie
кеш = объект->объем->кэш;
// кэш-файлы_объем UAF !!!
После установки FSCACHE_CACHE_IS_WITHDRAWN дождитесь поиска всех файлов cookie.
сначала завершить, а затем дождаться, пока fscache_cache->object_count == 0
избегайте выхода файла cookie после освобождения тома и его срабатывания
вышеуказанная проблема.
Поэтому перед вызовом вызовите fscache_withdraw_volume().
cachefiles_withdraw_objects(). Таким образом, после установки FSCACHE_CACHE_IS_WITHDRAWN только следующие два
будут иметь место случаи:
1) fscache_begin_lookup не работает в fscache_begin_volume_access().
2) fscache_withdraw_volume() гарантирует, что fscache_count_object() имеет
был выполнен перед вызовом fscache_wait_for_objects().
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: cachefiles: fix slab-use-after-free in cachefiles_withdraw_cookie() We got the following issue in our fault injection stress test: ================================================================== BUG: KASAN: slab-use-after-free in cachefiles_withdraw_cookie+0x4d9/0x600 Read of size 8 at addr ffff888118efc000 by task kworker/u78:0/109 CPU: 13 PID: 109 Comm: kworker/u78:0 Not tainted 6.8.0-dirty #566 Call Trace: <TASK> kasan_report+0x93/0xc0 cachefiles_withdraw_cookie+0x4d9/0x600 fscache_cookie_state_machine+0x5c8/0x1230 fscache_cookie_worker+0x91/0x1c0 process_one_work+0x7fa/0x1800 [...] Allocated by task 117: kmalloc_trace+0x1b3/0x3c0 cachefiles_acquire_volume+0xf3/0x9c0 fscache_create_volume_work+0x97/0x150 process_one_work+0x7fa/0x1800 [...] Freed by task 120301: kfree+0xf1/0x2c0 cachefiles_withdraw_cache+0x3fa/0x920 cachefiles_put_unbind_pincount+0x1f6/0x250 cachefiles_daemon_release+0x13b/0x290 __fput+0x204/0xa00 task_work_run+0x139/0x230 do_exit+0x87a/0x29b0 [...] ================================================================== Following is the process that triggers the issue: p1 | p2 ------------------------------------------------------------ fscache_begin_lookup fscache_begin_volume_access fscache_cache_is_live(fscache_cache) cachefiles_daemon_release cachefiles_put_unbind_pincount cachefiles_daemon_unbind cachefiles_withdraw_cache fscache_withdraw_cache fscache_set_cache_state(cache, FSCACHE_CACHE_IS_WITHDRAWN); cachefiles_withdraw_objects(cache) fscache_wait_for_objects(fscache) atomic_read(&fscache_cache->object_count) == 0 fscache_perform_lookup cachefiles_lookup_cookie cachefiles_alloc_object refcount_set(&object->ref, 1); object->volume = volume fscache_count_object(vcookie->cache); atomic_inc(&fscache_cache->object_count) cachefiles_withdraw_volumes cachefiles_withdraw_volume fscache_withdraw_volume __cachefiles_free_volume kfree(cachefiles_volume) fscache_cookie_state_machine cachefiles_withdraw_cookie cache = object->volume->cache; // cachefiles_volume UAF !!! After setting FSCACHE_CACHE_IS_WITHDRAWN, wait for all the cookie lookups to complete first, and then wait for fscache_cache->object_count == 0 to avoid the cookie exiting after the volume has been freed and triggering the above issue. Therefore call fscache_withdraw_volume() before calling cachefiles_withdraw_objects(). This way, after setting FSCACHE_CACHE_IS_WITHDRAWN, only the following two cases will occur: 1) fscache_begin_lookup fails in fscache_begin_volume_access(). 2) fscache_withdraw_volume() will ensure that fscache_count_object() has been executed before calling fscache_wait_for_objects().
Характеристики атаки
Последствия
Строка CVSS v3.1
Тип уязвимости (CWE)
Уязвимые продукты 3
| Конфигурация | От (включительно) | До (исключительно) |
|---|---|---|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
5.17
|
6.1.101
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.2
|
6.6.42
|
|
Linux Linux_Kernel
cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*
|
6.7
|
6.9.11
|