Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Thu, 18 Mar 2021 23:47:24 +0000
From: Piotr Krysiuk <>
Subject: [CVE-2020-27171] Numeric error when restricting speculative pointer
 arithmetic allows unprivileged local users to leak content of kernel memory

Numeric error in the Linux kernel mechanism to mitigate speculatively
out-of-bounds loads (Spectre mitigation) has been identified.

Unprivileged BPF programs running on affected 64-bit systems can
exploit this to execute speculatively out-of-bounds loads from 4GB
window within the kernel memory. This can be abused to extract
contents of kernel memory via side-channel.

The identified issue is when computing ptr_limit for preventing
out-of-bounds speculation on pointer arithmetic. The computation of
ptr_limit is off-by-one whenever the pointer moves to the left.

The computed ptr_limit is zero in particular when subtracting zero
offset from a pointer that is already at the beginning of map element
value. This leads to integer underflow in fixup_bpf_calls() where
sanitization code is generated.

I developed a PoC to demonstrate how unprivileged local users can
extract contents of kernel memory.

The PoC has been shared privately with <> to assist
with fix development.

The patches are available from BPF subsystem public git repository. The
minimal fix is:

* bpf: Fix off-by-one for area size in creating mask to left [

However it is recommended to apply the whole series as it includes
fix for another speculatively out-of-bounds vulnerability in BPF
[CVE-2020-27170] that I reported at the same time and some additional
hardening of the affected code:

* bpf: Prohibit alu ops for pointer types not defining ptr_limit [
* bpf: Fix off-by-one for area size in creating mask to left [
* bpf: Simplify alu_limit masking for pointer arithmetic [
* bpf: Add sanity check for upper ptr_limit [
* bpf, selftests: Fix up some test_verifier cases for unprivileged [

# Discoverer

Piotr Krysiuk <>

# References

CVE-2020-27171 (reserved via

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.