В ядре Linux была устранена следующая уязвимость: null_blk: сериализация магазинов атрибутов configfs с блокировкой The NULLB_DEVICE_ATTR _store takes no lock: apply_fn атрибутов (submit_queues, poll_queues) получают dev->NAME, написанных снова после возвращения apply_fn, вне его блокировки; атрибуты APPLYNULLL полностью без блокировки. configfs только сериализует магазины per-open-file, так что параллельные магазины на отдельных гонках. Для атрибутов apply_fn, как только один магазин apply_fn перенастроил аппаратное обеспечение, второй (потерянный) магазин все еще может перезаписать dev->NAME после этого. Это оставляет dev->submit_queues не синхронизированным с количеством живых очередей, которые позже попадают в WARN_ON_ONCE () в null_map_queues ().
Для атрибутов !apply_fn power_store()'s null_add_dev () проверяет и строит устройство под «lock», но устанавливает CONFIGURED только после этого. Магазин, проскальзывающий во время этого окна, может изменить середину настройки поля - например, zone_nr_conv может быть поднят выше nr_zones после того, как он уже был зажат, что приводит к доступу out-of-bounds dev->zones. Возьмите «lock» в макросе вокруг вызова apply_fn, теста CONFIGURED и поля write и переместите его из nullb_apply_submit_queues()/ nullb_apply_poll_queues (), чтобы оба пути были покрыты один раз.
Это сериализирует магазины с настройкой power_store's и друг с другом.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: null_blk: serialize configfs attribute stores with the lock The NULLB_DEVICE_ATTR _store takes no lock: apply_fn attributes (submit_queues, poll_queues) get dev->NAME written again after apply_fn returns, outside its lock; APPLY=NULL attributes are entirely lockless. configfs only serializes stores per-open-file, so concurrent stores on separate fds race. For apply_fn attributes, once one store's apply_fn has reconfigured the hardware, a second (losing) store can still overwrite dev->NAME afterwards. This leaves dev->submit_queues out of sync with the live queue count, which is later caught by the WARN_ON_ONCE() in null_map_queues(). For !apply_fn attributes, power_store()'s null_add_dev() validates and builds the device under "lock" but only sets CONFIGURED afterwards. A store slipping in during this window can change a field mid-setup -- for example, zone_nr_conv can be pushed above nr_zones after it has already been clamped, leading to an out-of-bounds dev->zones[] access. Take "lock" in the macro around the apply_fn call, the CONFIGURED test and the field write, and move it out of nullb_apply_submit_queues()/ nullb_apply_poll_queues() so both paths are covered once. This serializes stores with power_store's setup and with each other.