{"id":"CVE-2021-47608","aliases":["CVE-2021-47608"],"related":[],"kind":"vulnerability","state":"published","title":"bpf: Fix kernel address leakage in atomic fetch","summary":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix kernel address leakage in atomic fetch\n\nThe change in commit 37086bfdc737 (\"bpf: Propagate stack bounds to registers\nin atomics w/ BPF_FETCH\") around check_mem_access() handling is buggy since\nthis would allow for unprivileged users to leak kernel pointers. For example,\nan atomic fetch/and with -1 on a stack destination which holds a spilled\npointer will migrate the spilled register type into a scalar, which can then\nbe exported out of the program (since scalar != pointer) by dumping it into\na map value.\n\nThe original implementation of XADD was preventing this situation by using\na double call to check_mem_access() one with BPF_READ and a subsequent one\nwith BPF_WRITE, in both cases passing -1 as a placeholder value instead of\nregister as per XADD semantics since it didn't contain a value fetch. The\nBPF_READ also included a check in check_stack_read_fixed_off() which rejects\nthe program if the stack slot is of __is_pointer_value() if dst_regno < 0.\nThe latter is to distinguish whether we're dealing with a regular stack spill/\nfill or some arithmetical operation which is disallowed on non-scalars, see\nalso 6e7e63cbb023 (\"bpf: Forbid XADD on spilled pointers for unprivileged\nusers\") for more context on check_mem_access() and its handling of placeholder\nvalue -1.\n\nOne minimally intrusive option to fix the leak is for the BPF_FETCH case to\ninitially check the BPF_READ case via check_mem_access() with -1 as register,\nfollowed by the actual load case with non-negative load_reg to propagate\nstack bounds to registers.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"In the Linux kernel, the following vulnerability has been resolved:\n\nbpf: Fix kernel address leakage in atomic fetch\n\nThe change in commit 37086bfdc737 (\"bpf: Propagate stack bounds to registers\nin atomics w/ BPF_FETCH\") around check_mem_access() handling is buggy since\nthis would allow for unprivileged users to leak kernel pointers. For example,\nan atomic fetch/and with -1 on a stack destination which holds a spilled\npointer will migrate the spilled register type into a scalar, which can then\nbe exported out of the program (since scalar != pointer) by dumping it into\na map value.\n\nThe original implementation of XADD was preventing this situation by using\na double call to check_mem_access() one with BPF_READ and a subsequent one\nwith BPF_WRITE, in both cases passing -1 as a placeholder value instead of\nregister as per XADD semantics since it didn't contain a value fetch. The\nBPF_READ also included a check in check_stack_read_fixed_off() which rejects\nthe program if the stack slot is of __is_pointer_value() if dst_regno < 0.\nThe latter is to distinguish whether we're dealing with a regular stack spill/\nfill or some arithmetical operation which is disallowed on non-scalars, see\nalso 6e7e63cbb023 (\"bpf: Forbid XADD on spilled pointers for unprivileged\nusers\") for more context on check_mem_access() and its handling of placeholder\nvalue -1.\n\nOne minimally intrusive option to fix the leak is for the BPF_FETCH case to\ninitially check the BPF_READ case via check_mem_access() with -1 as register,\nfollowed by the actual load case with non-negative load_reg to propagate\nstack bounds to registers.","source":"cvelist"},{"lang":"es","text":"En el kernel de Linux, se resolvió la siguiente vulnerabilidad: bpf: corrige la fuga de la dirección del kernel en la recuperación atómica. El cambio en el commit 37086bfdc737 (\"bpf: propaga los límites de la pila a los registros en atómicos con BPF_FETCH\") alrededor del manejo de check_mem_access() tiene errores ya que esto permitiría a usuarios sin privilegios filtrar punteros del kernel. Por ejemplo, una recuperación atómica/y con -1 en un destino de pila que contiene un puntero derramado migrará el tipo de registro derramado a un escalar, que luego se puede exportar fuera del programa (ya que escalar! = puntero) volcándolo en un valor de mapa. La implementación original de XADD evitaba esta situación mediante el uso de una llamada doble a check_mem_access(), una con BPF_READ y otra posterior con BPF_WRITE, en ambos casos pasando -1 como valor de marcador de posición en lugar de registrarse según la semántica de XADD, ya que no lo hacía contener una recuperación de valor. BPF_READ también incluyó una verificación en check_stack_read_fixed_off() que rechaza el programa si la ranura de la pila es de __is_pointer_value() si dst_regno &lt; 0. Esto último es para distinguir si estamos tratando con un derrame/llenado de pila regular o alguna operación aritmética que no está permitido en valores no escalares, consulte también 6e7e63cbb023 (\"bpf: Prohibir XADD en punteros dispersos para usuarios sin privilegios\") para obtener más contexto sobre check_mem_access() y su manejo del valor del marcador de posición -1. Una opción mínimamente intrusiva para solucionar la fuga es que el caso BPF_FETCH verifique inicialmente el caso BPF_READ mediante check_mem_access() con -1 como registro, seguido del caso de carga real con load_reg no negativo para propagar los límites de la pila a los registros.","source":"nvd"}],"published":"2024-06-19T14:54:06.388Z","modified":"2026-06-17T04:18:09.287Z","severity":{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":5.5,"rating":"MEDIUM"},"severities":[{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N","score":5.5,"rating":"MEDIUM"}],"cwes":[],"affected":[{"ranges":[{"type":"git","introduced":"37086bfdc737ea6f66bf68dcf16757004d68e1e1","fixed":"423628125a484538111c2c6d9bb1588eb086053b","status":"affected"},{"type":"git","introduced":"37086bfdc737ea6f66bf68dcf16757004d68e1e1","fixed":"7d3baf0afa3aa9102d6a521a8e4c41888bb79882","status":"affected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"version":"5.12","status":"affected"},{"type":"semver","introduced":"0","fixed":"5.12","status":"unaffected"},{"type":"semver","introduced":"5.15.11","lastAffected":"5.15.*","status":"unaffected"},{"type":"original_commit_for_fix","introduced":"5.16","lastAffected":"*","status":"unaffected"}],"vendor":"Linux","product":"Linux","repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","source":"cvelist"},{"ranges":[{"status":"affected","introduced":"5.12","fixed":"5.15.11"},{"status":"affected","version":"5.16"},{"status":"affected","version":"5.16"},{"status":"affected","version":"5.16"},{"status":"affected","version":"5.16"},{"status":"affected","version":"5.16"}],"vendor":"linux","product":"linux_kernel","cpe":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://git.kernel.org/stable/c/423628125a484538111c2c6d9bb1588eb086053b","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]},{"url":"https://git.kernel.org/stable/c/7d3baf0afa3aa9102d6a521a8e4c41888bb79882","tags":["patch","x-transferred"],"sources":["cvelist","nvd"]}],"credits":[],"assigner":"Linux","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2024-09-10T17:12:01.674Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2021-47608","url":"https://www.cve.org/CVERecord?id=CVE-2021-47608","licence":"CVE Terms of Use","modified":"2026-05-11T13:57:50.154Z"},{"source":"nvd","name":"NVD","id":"CVE-2021-47608","url":"https://nvd.nist.gov/vuln/detail/CVE-2021-47608","licence":"Public domain","modified":"2026-06-17T04:18:09.287Z"}],"updatedAt":"2026-11-25T22:58:08.941Z","epss":{"score":0.00211,"percentile":0.11981,"date":"2026-12-01T12:00:22.000Z"}}