For almost three years, a serious vulnerability in the Linux kernel could have allowed attackers to take full control over Linux-based PCs, servers, Android phones and other embedded devices.

The flaw, which stems from the kernel's keyring facility, allows applications running under a local user to execute code in the kernel. As a result, an attacker with access to only a limited account on a Linux system can escalate their privileges to root.

The vulnerability, tracked as CVE-2016-0728, was found and reported to the Linux kernel security team and several Linux distribution maintainers by researchers from an Israeli threat defense start-up called Perception Point.

The Linux kernel is the core of all Linux-based operating systems, including Android. Its keyring facility provides a way for applications to store sensitive information such as authentication and encryption keys inside the kernel, where other user-space applications cannot access it.

The Perception Point researchers found a way to trick the kernel into freeing a still-referenced keyring object and then to overwrite it with malicious content so it gets executed. According to them, the vulnerability was introduced in kernel version 3.8, released in Feb. 2013.

Linux distributions will release security patches for this vulnerability this week, so users should update their kernels as soon as possible. However, some systems will likely remain vulnerable for some time to come, if not indefinitely.

For example, automatic updates are not enabled on many Linux-based production servers, said Yevgeny Pats, co-founder and CEO of Perception Point. In such environments administrators sometimes have to test the updates before deploying them, which can introduce significant patching delays.

What makes this vulnerability stand out compared to other Linux kernel privilege escalation flaws is that it affects all architectures, including ARM.

This means that many embedded devices that run one of the affected kernel versions released over the past three years are also vulnerable. This includes devices running Android 4.4 (KitKat) and later, which currently account for almost 70% of all Android devices.

The Android ecosystem is known for its version fragmentation and long update delays. Google shares security patches with Android device manufacturers, which then have to apply them to their separately maintained source code trees and build updated firmware packages for each of their products. Some of the updates then need to be distributed to users with the help of mobile carriers.

Most Android devices receive software support for only 18 months, after which they're cut off from patches. This means that a considerable number of devices will never receive a fix for this vulnerability.

The situation is not very different with consumer routers and other embedded devices that need to be manually updated by users and for which firmware patches are rare to begin with.

CPU-based protections like Supervisor Mode Access Prevention (SMAP) and Supervisor Mode Execution Protection (SMEP), or features like SELinux on Android can make exploiting this vulnerability harder, but there are ways to bypass such mitigations, Pats said.

Perception Point is not aware of any attack exploiting this vulnerability in the wild, but the company believes that computer emergency response teams and larger security vendors might be in a better position to discover if such attacks have happened.