В ядре Linux устранена следующая уязвимость:
bnxt: исправлено отсутствие переполнения головы при увеличении головы XDP. Тест xdp.py test_xdp_native_adjst_head_grow_data завершается сбоем при запуске
машина bnxt (и тоже вылетает в NIPA). Судя по всему, баг - это недополнение в bnxt_rx_multi_page_skb, что
строит голову скб:
napi_build_skb(data_ptr - bp->rx_offset, rxr->rx_page_size);
Проблема с этим выражением заключается в том, что в страничном режиме rx_offset имеет следующий вид:
bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM;
Что оценивается (по крайней мере, на x86_64) как 258.
Тест test_xdp_native_adjst_head_grow_data проверяет случай, когда
голова отрегулирована на -256. При запуске этого теста data_ptr сдвигается на frag_start + 2 (где
frag_start = адрес_страницы(страница) + смещение). Затем вызывается bnxt_rx_multi_page_skb и napi_build_skb.
выражение вычитает 258, попадая по адресу перед frag_start.
Это может быть либо предыдущим фрагментом, либо предыдущей физической страницей, когда смещение < 256 (например, если фрагмент начинается со смещения 0). Когда skb освобождается, ссылка на фрагмент пула страниц удаляется. либо не та страница, либо неправильный фрагмент нужной страницы. В любом В этом случае поврежденный счетчик ссылок может привести к тому, что страница будет недоступна. преждевременно переработаны, пока они еще используются.
После (неправильной) переработки он
может быть роздан снова, и при демонтаже драйвера это приведет к
дважды бесплатно. При фиксации исправлений этот код был обновлен для обработки случая, когда
Размер исходной страницы >= 64 КБ, но это непреднамеренно сломало голову.
случай. Чтобы исправить это, добавьте поле смещения в структуру bnxt_sw_rx_bd, отражающее
существующее поле смещения в структуре bnxt_sw_rx_agg_bd.
Заполните его на
выделение и сохранение его при повторном использовании. В bnxt_rx_multi_page_skb используйте новое добавленное поле смещения для вычисления
фрагмент запускается и передается в napi_build_skb. Настройте макет
с skb_reserve.
Есть два случая: случай некорректировки и случай корректировки. В обоих случаях skb создается по адресу page_address(page) + смещение до
учитывать случай, когда собственный размер страницы >= 64 КБ и skb_reserve
вызывается с data_ptr - (page_address(page) + offset). Это
разница равна bp->rx_offset, если data_ptr не был перемещен, или
bp->rx_offset + xdp_adjust, когда XDP настраивал головку.
Повторный запуск неудачного теста с примененной фиксацией приводит к тому, что тест
успешно выполнить до завершения. В других реализациях rx_skb_func такой проблемы нет.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: bnxt: fix head underflow on XDP head-grow The xdp.py test test_xdp_native_adjst_head_grow_data crashes when run on a bnxt machine (and also crashes in NIPA). It seems that the bug is an underflow in bnxt_rx_multi_page_skb, which builds the skb head: napi_build_skb(data_ptr - bp->rx_offset, rxr->rx_page_size); The problem with this expression is that in page mode, rx_offset is: bp->rx_offset = NET_IP_ALIGN + XDP_PACKET_HEADROOM; Which evaluates (at least on x86_64) to 258. The test test_xdp_native_adjst_head_grow_data tests a case where the head is adjusted by -256. When this test runs, data_ptr is shifted to frag_start + 2 (where frag_start = page_address(page) + offset). Then, bnxt_rx_multi_page_skb is invoked and the napi_build_skb expression subtracts 258, landing at an address before frag_start. This could be either the previous fragment or the previous physical page when the offset is < 256 (e.g. if the fragment started at offset 0). When the skb is freed, the page pool fragment reference is dropped on either the wrong page or the wrong frag of the right page. In either case, the corrupted reference count can lead to the page being prematurely recycled while still in use. Once (incorrectly) recycled, it can be handed out again and on driver teardown this would result in a double free. The commit under fixes updated this code to handle the case where the native page size is >= 64k, but it unintentionally broke the head grow case. To fix this, add an offset field to struct bnxt_sw_rx_bd, mirroring the existing offset field in struct bnxt_sw_rx_agg_bd. Populate it on allocation and preserve it on reuse. In bnxt_rx_multi_page_skb, use the newly added offset field to compute the fragment start and pass that to napi_build_skb. Adjust the layout with skb_reserve. There are two cases, the non-adjustment case and the adjustment case. In both cases, the skb is built at page_address(page) + offset to account for the case where the native page size >= 64K and skb_reserve is called with data_ptr - (page_address(page) + offset). That difference equals bp->rx_offset when data_ptr was not moved, or bp->rx_offset + xdp_adjust when XDP adjusted the head. Re-running the failing test with this commit applied causes the test to run successfully to completion. The other rx_skb_func implementations don't have this issue.
Характеристики атаки
Последствия
Строка CVSS v3.1