VOOZH about

URL: https://thenewstack.io/linux-kernel-5-10-introduces-static-calls-to-prevent-speculative-execution-attacks/

⇱ Linux Kernel 5.10 Introduces Static Calls to Prevent Speculative Execution Attacks - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2020-12-28 13:20:04
Linux Kernel 5.10 Introduces Static Calls to Prevent Speculative Execution Attacks
feature,
Linux / Security

Linux Kernel 5.10 Introduces Static Calls to Prevent Speculative Execution Attacks

The release of the Linux 5.10 kernel brings a new feature to protect against speculative execution attacks. That feature is called static calls and is a replacement for global function pointers in the Linux kernel.
Dec 28th, 2020 1:20pm by Jack Wallen
👁 Featued image for: Linux Kernel 5.10 Introduces Static Calls to Prevent Speculative Execution Attacks
Feature image via Pixabay.

You might be familiar with Spectre, a speculative execution vulnerability within x86 processors that breaks the isolation between various applications, allowing an attacker to trick programs into leaking secrets to the hacker. To make matters worse, the safety checks created to protect against such attacks actually make those applications even more vulnerable to Spectre.

The likes of Spectre and Spectre version 2 (otherwise known as the branch target injection — CVE-2017-5715) are operating system agnostic, so every platform on the market had to take steps to protect users and data against such an attack.

The release of the Linux 5.10 kernel brings a new feature that does just that — protect against speculative execution attacks. That feature is called static calls and is a replacement for global function pointers in the Linux kernel.

The new static call function is static_call() which uses code patching to allow direct calls (as opposed to indirect calls) and offer the flexibility of function pointers with an improved performance, especially in cases where retpolines would be used.

Wait, what?

What Is a Retpoline?

A retpoline is a return trampoline that makes use of an infinite loop that is never executed to prevent a CPU from speculating the target of an indirect jump. This system also uses a Return Stack Buffer (RSB) as a prediction structure, similar to a branch predictor for return instructions. To make sure the RSB cannot be maliciously trained out of the infinite loop, retpolines always start with a direct call to make sure the RSB predicts an infinite loop.

Retpolines were not the original mitigation against Spectre, but were created by Google after the original Spectre mitigation was found to cause relative slowdowns on certain CPU architectures (both AMD and Intel) and under specific workloads.

You can check to see if your running kernel contains full retpoline support by issuing the command:

cat /sys/devices/system/cpu/vulnerabilities/spectre_v2

You should see something similar to:

Full generic retpoline, IBPB: conditional, IBRS_FW, STIBP: conditional, RSB filling

After Microsoft realized its original solution couldn’t compete with Google’s, it implemented the retpoline in Windows 10. In 2018, retpolines found their way into the Linux kernel, thereby protecting the open source platform against such attacks.

However, retpolines were never an ideal solution. Developers had to go out of their way to avoid indirect calls, as they had to now be implemented with retpolines.

What is an indirect call? These calls happen when the address of a function to be called isn’t known at compile time. Instead, the address is stored in a pointer variable so it can then be used at run time. As many have (unfortunately) discovered, those indirect calls are easily exploitable by speculative execution attacks.

Retpolines avoided storing addresses in pointer variables. However, retpolines introduce the following problems:

  1. Slows down when correctly predicted.
  2. Drastically slows down when incorrectly predicted.
  3. Interferes with Intel’s CET and other protections.
  4. It’s overly complicated.

So, much to the dismay of developers, retpolines weren’t that much better than the original Spectre mitigation.

Static Calls to the Rescue

Since the inception of retpolines, kernel developers have been scrambling to find a better solution, one that doesn’t work from a location within writable memory where the indirect jumps can be found.

That’s where static calls come into play. A static call uses a location in executable memory (instead of writable memory) that contains a jump instruction pointing to a target function. Executing a static call requires a call to the special location, which then jumps to the actual target. This is called a classic code trampoline and completely avoids the use of retpolines.

How to Declare a Static Call

Before you can use a static call, you must first declare them with one of two macros:

DEFINE_STATIC_CALL(name, target);

or

DECLARE_STATIC_CALL(name, target);

DEFINE_STATIC_CALL creates a new static call with a given name that points at the function target(). DECLARE_STATIC_CALL declares the existence of a static call that is elsewhere defined.

The actual calling of a static call is handled with:

static_call(name)(args...);

You define the call with name, which will cause a jump through the trampoline, directly to the target function. If the function returns, say, a value of X, then static_call() will return a value of X.

Welcome Static Calls to the Linux Kernel

As of kernel 5.10, static calls are now a reality. That means the foundation of the Linux operating system is protected against the likes of Spectre V1/2, without suffering from the issues introduced by retpolines.

Read more about the Linux kernel static calls (written by Josh Poimboeuf) here, where you can see the kernel patch he created to employ this new feature.

Although the Linux kernel 5.10 hasn’t found its way into the majority of distributions (as of now, most Ubuntu-based distributions are running kernel 5.8), you should expect this kernel to hit the likes of Ubuntu in April 2021, in version 21.04.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
The Linux Foundation is a sponsor of The New Stack.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.