Vulnerabilities in eBPF allow bypassing protection against Spectre attack 4.

Two vulnerabilities have been discovered in the Linux kernel that allow the eBPF subsystem to bypass protection against the Spectre v4 attack (SSB, Speculative Store Bypass). Using a non-privileged BPF program, an attacker can create conditions for speculative execution of certain operations and determine the contents of arbitrary areas of kernel memory. The accompanying eBPF subsystems in the kernel gained access to an exploit prototype demonstrating the practical possibility of attacks. The issues have been addressed in the form of patches (1, 2), which will be included in the next Linux kernel update. Updates in distributions have not yet been formed (Debian, RHEL, SUSE, Arch, Fedora, Ubuntu).

The Spectre v4 attack method is based on recovering data that has settled in the processor cache after discarding the results of speculative execution of operations when processing alternating write and read operations using indirect addressing. When a read operation follows a write operation (e.g., mov [rbx + rcx], 0x0; mov rax, [rdx + rsi]), the offset for reading may already be known due to executing similar operations (read operations are performed significantly more often and reading can be done from the cache), and the processor can speculatively perform the read before the write, not waiting for the offset of the indirect address for writing to be calculated.

If an intersection of memory areas for writing and reading is detected after calculating the offset, the processor simply discards the already speculatively obtained result of the read and repeats this operation. This feature allows the read instruction to access the old value at a given address while the store operation is still in progress. After discarding the failed speculative operation, the cache retains traces of its execution, after which one of the methods for determining the cache content based on analyzing changes in access time to cached and uncached data may be used.

The first vulnerability (CVE-2021-35477) is caused by an oversight in the BPF program verification mechanism. To protect against Spectre 4 attacks, the verifier adds an additional instruction to save a zero value after potentially problematic memory store operations, aimed at erasing traces of the previous operation. It was assumed that the zero-write operation would execute very quickly and block speculative execution, as it depends solely on the BPF stack frame pointer. However, in practice, conditions can be created where the instruction leading to speculative execution manages to execute before the displacing store operation.

The second vulnerability (CVE-2021-3455) is related to the fact that when the BPF verifier detects potentially dangerous memory store operations, it does not consider uninitialized areas of the BPF stack, where the first write operation is unprotected. This peculiarity allows for speculative read operations that depend on uninitialized memory areas to occur before the store instruction is executed. New memory for the BPF stack is allocated without checking the contents already present in the allocated memory, and prior to executing the BPF program, there is a way to control the content of the memory area that will subsequently be allocated for the BPF stack.

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster