В ядре Linux устранена следующая уязвимость:
btrfs: пропустить глобальный учет резерва блоков для спасательных монтировок
[ОШИБКА]
Монтирование с помощью Rescue=ibadroots после повреждения дерева группы блоков.
root запускает разыменование NULL-указателя:
ОШИБКА: разыменование нулевого указателя ядра, адрес: 0000000000000100
RIP: 0010:btrfs_update_global_block_rsv+0x9d/0x1c0 [btrfs]
Отслеживание вызова:
fill_dummy_bgs+0xd4/0x120 [btrfs]
open_ctree+0xc6e/0x1ca0 [btrfs]
btrfs_get_tree+0x50d/0xa40 [btrfs]
Тот же сбой происходит с поврежденным корнем дерева полосы рейда, через
btrfs_read_block_groups() вместо fill_dummy_bgs().
[ПРИЧИНА]
При использовании escape=ibadroots функция btrfs_read_roots() позволяет продолжить монтирование.
когда любой корень не может быть прочитан, остается соответствующий корневой указатель
NULL, пока его бит функции на диске остается установленным.
btrfs_update_global_block_rsv() затем разыменовывает отсутствующий корень на основе
только на этой функции.
[ИСПРАВЛЕНО]
Спасательные монтирования полностью доступны только для чтения и не могут запускать транзакции, поэтому
глобальный резерв никогда не израсходуется. В разделе btrfs_is_full_ro() отметьте
зарезервировать как полный и вернуть до проведения учета.
А поскольку нам нужно проверить, смонтирована ли фс полностью RO, экспортируем
fs_is_full_ro() как btrfs_is_full_ro() и переместите его в fs.h.
[Поместите в этот коммит экспорта fs_is_full_ro(). ]
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: btrfs: skip global block reserve accounting for rescue mounts [BUG] Mounting with rescue=ibadroots after corrupting the block group tree root triggers a NULL pointer dereference: BUG: kernel NULL pointer dereference, address: 0000000000000100 RIP: 0010:btrfs_update_global_block_rsv+0x9d/0x1c0 [btrfs] Call Trace: fill_dummy_bgs+0xd4/0x120 [btrfs] open_ctree+0xc6e/0x1ca0 [btrfs] btrfs_get_tree+0x50d/0xa40 [btrfs] The same crash occurs with a corrupted raid stripe tree root, via btrfs_read_block_groups() instead of fill_dummy_bgs(). [CAUSE] With rescue=ibadroots, btrfs_read_roots() allows the mount to continue when either root cannot be read, leaving the corresponding root pointer NULL while its on-disk feature bit remains set. btrfs_update_global_block_rsv() then dereferences the missing root based on the feature bit alone. [FIX] Rescue mounts are fully read-only and cannot start transactions, so the global reserve is never consumed. Under btrfs_is_full_ro(), mark the reserve as full and return before performing the accounting. And since we need to check if the fs is mount fully RO, export fs_is_full_ro() as btrfs_is_full_ro(), and move it to fs.h. [ Squash the fs_is_full_ro() export commit into this one. ]