CVE-2023-52447 bpf: Defer the free of inner map when necessary

High 7.8 Published Updated

A use-after-free vulnerability in the Linux kernel BPF subsystem allows attackers to potentially execute arbitrary code or escalate privileges.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Local or same network only
Victim action needed
Not needed
Fix
Available

What is CVE-2023-52447?

CVE-2023-52447 is a high-severity use after free vulnerability in Linux kernel, published on 22 Feb 2024. It can only be exploited from the same machine or local network, with no action from the victim.

Official description

In the Linux kernel, the following vulnerability has been resolved:

bpf: Defer the free of inner map when necessary

When updating or deleting an inner map in map array or map htab, the map may still be accessed by non-sleepable program or sleepable program. However bpf_map_fd_put_ptr() decreases the ref-counter of the inner map directly through bpf_map_put(), if the ref-counter is the last one (which is true for most cases), the inner map will be freed by ops->map_free() in a kworker. But for now, most .map_free() callbacks don't use synchronize_rcu() or its variants to wait for the elapse of a RCU grace period, so after the invocation of ops->map_free completes, the bpf program which is accessing the inner map may incur use-after-free problem.

Fix the free of inner map by invoking bpf_map_free_deferred() after both one RCU grace period and one tasks trace RCU grace period if the inner map has been removed from the outer map before. The deferment is accomplished by using call_rcu() or call_rcu_tasks_trace() when releasing the last ref-counter of bpf map. The newly-added rcu_head field in bpf_map shares the same storage space with work field to reduce the size of bpf_map.

Weakness: CWE-416

Which versions are affected by CVE-2023-52447?

It affects 1 product.

Products include Linux kernel.

How do I fix CVE-2023-52447?

Apply the vendor's patch.

Upgrade to the fixed version. These bugs are found with fuzzing and sanitisers and avoided by memory-safe languages. More about Use after free.

Is CVE-2023-52447 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-52447 exists.

All Linux kernel vulnerabilities

Sources

Also known as AZL-35453, AZL-35786, BELL-CVE-2023-52447, DEBIAN-CVE-2023-52447, GHSA-wvjr-h8mr-f8gw, UBUNTU-CVE-2023-52447.

Is CVE-2023-52447 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free