В ядре Linux устранена следующая уязвимость:
bpf: отклонять помощники перенаправления без bpf_net_context
Помощники bpf_redirect*() и skb_do_redirect() получают данные для каждой задачи.
bpf_redirect_info через bpf_net_ctx_get_ri(), который разыменовывает
current->bpf_net_context безоговорочно. Этот контекст установлен
на путях, по которым выполняется tc BPF, например sch_handle_{ingress,egress}(),
*за исключением* случая, когда {cls,act}_bpf был прикреплен к правильному
qдиск. Программа, запущенная оттуда, достигает разыменования NULL двумя способами:
* Он напрямую вызывает bpf_redirect(), который разыменовывает контекст в
верхняя часть помощника:
tc qdisc добавить корневой дескриптор dev eth0 1: красный предел 1 МБ мин. 10 КБ макс. 20 КБ \
avpkt 1000 пакет 100 qevent Early_drop блок 10
tc фильтр добавить блок 10 pref 1 bpf obj redirect.o
* Он просто возвращает TC_ACT_REDIRECT без вспомогательного вызова: tcf_qevent_handle()
затем отправляется в skb_do_redirect(), который разыменовывает контекст
Вместо того, чтобы расширять управление bpf_net_context на путь qdisc,
заставить помощники перенаправления отказываться работать, когда контекст не существует, и
заставить tcf_qevent_handle() вынести вердикт TC_ACT_REDIRECT вместо
вызов skb_do_redirect().
Предыдущее поведение было сбоем, поэтому ничего регрессирует, не поддерживая его.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: bpf: Reject redirect helpers without a bpf_net_context The bpf_redirect*() helpers and skb_do_redirect() obtain the per-task bpf_redirect_info via bpf_net_ctx_get_ri(), which dereferences the current->bpf_net_context unconditionally. That context is established on the paths that run tc BPF such as sch_handle_{ingress,egress}(), *except* for the case where {cls,act}_bpf was attached to a proper qdisc. A program running from there reaches the NULL deref in two ways: * It calls bpf_redirect() directly, which dereferences the context at the top of the helper: tc qdisc add dev eth0 root handle 1: red limit 1MB min 10KB max 20KB \ avpkt 1000 burst 100 qevent early_drop block 10 tc filter add block 10 pref 1 bpf obj redirect.o * It simply returns TC_ACT_REDIRECT without helper call: tcf_qevent_handle() then dispatches to skb_do_redirect(), which dereferences the context Rather than extending bpf_net_context management into the qdisc path, make the redirect helpers refuse to operate when no context exists, and have tcf_qevent_handle() drop a TC_ACT_REDIRECT verdict instead of calling skb_do_redirect(). Previous behaviour was a crash, so nothing regresses by not supporting it.