5.5medium
xdp: use flags field to disambiguate broadcast redirect
- Severity
- 5.5medium CVSS:3.1 by NVD
- Exploit likelihood
- 0.22% (higher than 14% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- Linux
Description
In the Linux kernel, the following vulnerability has been resolved: xdp: use flags field to disambiguate broadcast redirect When redirecting a packet using XDP, the bpf_redirect_map() helper will set up the redirect destination information in struct bpf_redirect_info (using the __bpf_xdp_redirect_map() helper function), and the xdp_do_redirect() function will read this information after the XDP program returns and pass the frame on to the right redirect destination. When using the BPF_F_BROADCAST flag to do multicast redirect to a whole map, __bpf_xdp_redirect_map() sets the 'map' pointer in struct bpf_redirect_info to point to the destination map to be broadcast. And xdp_do_redirect() reacts to the value of this map pointer to decide whether it's dealing with a broadcast or a single-value redirect. However, if the destination map is being destroyed before xdp_do_redirect() is called, the map pointer will be cleared out (by bpf_clear_redirect_map()) without waiting for any XDP programs to stop running. This causes xdp_do_redirect() to think that the redirect was to a single target, but the target pointer is also NULL (since broadcast redirects don't have a single target), so this causes a crash when a NULL pointer is passed to dev_map_enqueue(). To fix this, change xdp_do_redirect() to react directly to the presence of the BPF_F_BROADCAST flag in the 'flags' value in struct bpf_redirect_info to disambiguate between a single-target and a broadcast redirect. And only read the 'map' pointer if the broadcast flag is set, aborting if that has been cleared out in the meantime. This prevents the crash, while keeping the atomic (cmpxchg-based) clearing of the map pointer itself, and without adding any more checks in the non-broadcast fast path.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| Linux Linux | from e624d4ed4aa8cc3c69d1359b0aaea539203ed266 before 12481f30128fbebc2eeb55eb2d56390fdfa30c5e, from e624d4ed4aa8cc3c69d1359b0aaea539203ed266 before 272bfb019f3cc018f654b992115774e77b4f3ffc, from e624d4ed4aa8cc3c69d1359b0aaea539203ed266 before e22e25820fa04ea5eaac4ef7ee200e9923f466a4, from e624d4ed4aa8cc3c69d1359b0aaea539203ed266 before 6fd81f9d333e7b3532036577b1beb74ba1323553, from e624d4ed4aa8cc3c69d1359b0aaea539203ed266 before 5bcf0dcbf9066348058b88a510c57f70f384c92c, 5.14 Not affected: before 5.14, from 5.15.159 up to 5.15.*, from 6.1.91 up to 6.1.*, from 6.6.31 up to 6.6.*, from 6.8.10 up to 6.8.*, from 6.9 up to * | CVE List |
| linux linux_kernel | from 5.14 before 5.15.159, from 5.16 before 6.1.91, from 6.2 before 6.6.31, from 6.7 before 6.8.10, 6.9 | NVD |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
In the Linux kernel, the following vulnerability has been resolved: xdp: use flags field to disambiguate broadcast redirect When redirecting a packet using XDP, the bpf_redirect_map() helper will set up the redirect destination information in struct bpf_redirect_info (using the __bpf_xdp_redirect_map() helper function), and the xdp_do_redirect() function will read this information after the XDP program returns and pass the frame on to the right redirect destination. When using the BPF_F_BROADCAST flag to do multicast redirect to a whole map, __bpf_xdp_redirect_map() sets the 'map' pointer in struct bpf_redirect_info to point to the destination map to be broadcast. And xdp_do_redirect() reacts to the value of this map pointer to decide whether it's dealing with a broadcast or a single-value redirect. However, if the destination map is being destroyed before xdp_do_redirect() is called, the map pointer will be cleared out (by bpf_clear_redirect_map()) without waiting for any XDP programs to stop running. This causes xdp_do_redirect() to think that the redirect was to a single target, but the target pointer is also NULL (since broadcast redirects don't have a single target), so this causes a crash when a NULL pointer is passed to dev_map_enqueue(). To fix this, change xdp_do_redirect() to react directly to the presence of the BPF_F_BROADCAST flag in the 'flags' value in struct bpf_redirect_info to disambiguate between a single-target and a broadcast redirect. And only read the 'map' pointer if the broadcast flag is set, aborting if that has been cleared out in the meantime. This prevents the crash, while keeping the atomic (cmpxchg-based) clearing of the map pointer itself, and without adding any more checks in the non-broadcast fast path.
NVD (es)
En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: xdp: use el campo flags para eliminar la ambigüedad de la redirección de transmisión Al redireccionar un paquete usando XDP, el asistente bpf_redirect_map() configurará la información del destino de redireccionamiento en la estructura bpf_redirect_info (usando el asistente __bpf_xdp_redirect_map() función), y la función xdp_do_redirect() leerá esta información después de que el programa XDP regrese y pasará el framework al destino de redireccionamiento correcto. Cuando se utiliza el indicador BPF_F_BROADCAST para realizar una redirección de multidifusión a un mapa completo, __bpf_xdp_redirect_map() establece el puntero 'mapa' en la estructura bpf_redirect_info para que apunte al mapa de destino que se va a transmitir. Y xdp_do_redirect() reacciona al valor de este puntero de mapa para decidir si se trata de una transmisión o una redirección de valor único. Sin embargo, si el mapa de destino se destruye antes de llamar a xdp_do_redirect(), el puntero del mapa se borrará (mediante bpf_clear_redirect_map()) sin esperar a que deje de ejecutarse ningún programa XDP. Esto hace que xdp_do_redirect() piense que la redirección fue a un único objetivo, pero el puntero de destino también es NULL (dado que las redirecciones de difusión no tienen un único objetivo), por lo que esto provoca un bloqueo cuando se pasa un puntero NULL a dev_map_enqueue( ). Para solucionar este problema, cambie xdp_do_redirect() para reaccionar directamente a la presencia del indicador BPF_F_BROADCAST en el valor 'flags' en la estructura bpf_redirect_info para eliminar la ambigüedad entre un redireccionamiento de destino único y de transmisión. Y solo lea el puntero del 'mapa' si la bandera de transmisión está activada, abortando si se ha borrado mientras tanto. Esto evita el bloqueo, manteniendo al mismo tiempo la limpieza atómica (basada en cmpxchg) del puntero del mapa y sin agregar más comprobaciones en la ruta rápida sin transmisión.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-36937 changed 2026-05-11 | CVE Terms of Use |
| NVD | CVE-2024-36937 changed 2026-06-17 | Public domain |