Multiple Kernel Vulnerabilities Affecting All Qualcomm Devices
Published on blog.zimperium.com
Eight months ago, the Zimperium research team (zLabs) disclosed to Qualcomm two kernel vulnerabilities affecting all Android devices with Qualcomm chipsets.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
The target is the QSEECOM driver, which stands for QTI Secure Execution Environment Communicator. It is a kernel driver that lets Normal World user-space processes talk to the Secure World, also known as the TrustZone. The API it exposes is a set of ioctl calls on the /dev/qseecom device.
Only a set of privileged Android services has access to /dev/qseecom. The author frames this work as a continuation of earlier research into vulnerabilities in such privileged services (CVE-2017-13253, CVE-2018-9411 and CVE-2018-9539). The two bugs described here were reported to Qualcomm and designated CVE-2019-14041 (a race condition) and CVE-2019-14040 (a use after free of a kernel memory mapping). Qualcomm published fixes in its February 2020 security bulletin.

The author notes that the race condition is less reliable and can produce different results, so the use after free gets the deeper treatment.
Setup
The report does not describe a lab setup, tooling or a specific device build. The preconditions it does state are structural: the attacker needs a way to reach the QSEECOM ioctl interface, which in normal Android is only available to privileged services. The proof-of-concept source for both bugs is published on GitHub:
Finding it
The race condition (CVE-2019-14041)
The race stems from one function, __qseecom_update_cmd_buf, and its 64-bit equivalent __qseecom_update_cmd_buf_64, which behaves the same way for the purposes of the race. The function updates a buffer intended for the TrustZone with pointers the TrustZone can understand.
To avoid duplicate code, the function handles two different cases in which such buffers need to be modified. As a result it can be reached from two completely different ioctls. In some parts it still has to behave differently depending on which ioctl it was originally called from, and it does so by checking data->type:

source
In one case data->type is QSEECOM_CLIENT_APP; in the other it is QSEECOM_LISTENER_SERVICE. Checks of this kind appear throughout the function.
The problem is that data is a pointer to a qseecom_dev_handle struct, which is attached to the open /dev/qseecom file the ioctl is being performed on. That raises the question: can data->type be modified while __qseecom_update_cmd_buf is running?

source
Running the ioctl QSEECOM_IOCTL_APP_LOADED_QUERY_REQ instantly modifies data->type. There are mechanisms to limit ioctls from running concurrently, but they only take effect after data->type has been changed. Running this ioctl at the same time as __qseecom_update_cmd_buf therefore causes a race condition.
The function starts with behaviour that matches a data->type of QSEECOM_LISTENER_SERVICE and continues with behaviour that matches QSEECOM_CLIENT_APP. Depending on where exactly the race hits, this can cause different types of memory corruption. Most are relatively harmless, such as a NULL dereference, but some conditions cause a buffer overflow, which is dangerous and possibly exploitable.
The use after free (CVE-2019-14040)
Background
Communication between Normal World user-space and the TrustZone uses the ION mechanism. ION lets user-space processes allocate memory from special heaps that behave differently from regular memory; the process can map that memory into its own address space and read and write it as it wishes.
With QSEECOM, an open /dev/qseecom file can be made to reference an allocated ION buffer, and the kernel then uses that buffer for further communication with the TrustZone. The buffer is mostly intended for the user-space process to read and write, but the kernel itself can sometimes modify it too, through __qseecom_update_cmd_buf.

source
The code above handles a user-space request to reference an allocated ION buffer. Several parameters about the buffer are saved, such as a handle and a mapping of it in kernel space. data is again a pointer to a struct attached to the open /dev/qseecom file.

How ION buffer usage looks in QSEECOM
When the ION buffer is released, the kernel handle to it is set to NULL:

source

QSEECOM data after ION buffer is released
That possible NULL is then used when the kernel tries to use the ION buffer. The handle is verified not to be NULL:

source
The flaw
Looking at the code that references an ION buffer from an open /dev/qseecom file:

source
The code does not accept any user-space request without checking it. There are multiple checks along the function to verify the request. The check shown above is one example: if the length in the request is greater than the length of the ION buffer (the len variable), the request is invalid.
The issue is exactly in this check. What happens to the parameters in data if the length in the request is too big? More importantly, what happens if that open /dev/qseecom file already referenced an ION buffer that was freed?

QSEECOM data after ION buffer is released then a request with bad length is received
In that scenario the handle is no longer NULL, but the rest of the parameters are not modified, so they still point to the previously referenced ION buffer. For instance, sb_virt points to a memory mapping that was already freed. Attempts to use the referenced ION buffer from the kernel still work, because the handle is no longer NULL. That is the use after free: when the kernel uses the ION buffer it modifies a memory mapping that was already freed.
Exploitation
The report does not include the requests or payloads themselves; it describes the two bugs and points to the PoCs on GitHub. The mechanics it does describe are as follows.
Step 1: Reach the QSEECOM ioctl interface
An attacker needs to be able to issue ioctls on /dev/qseecom. In normal Android only privileged services have that access, so the bugs are reached through such a service, or through a chain that first compromises one.
Step 2 (race): overlap two ioctls on the same open file
Run QSEECOM_IOCTL_APP_LOADED_QUERY_REQ concurrently with an ioctl that reaches __qseecom_update_cmd_buf. The first changes data->type immediately; the concurrency limits only apply afterwards. The update function then switches mid-run from QSEECOM_LISTENER_SERVICE behaviour to QSEECOM_CLIENT_APP behaviour, and depending on where the race lands the result is anything from a NULL dereference to a buffer overflow.
Step 3 (use after free): free the buffer, then send a bad length
- Make the open
/dev/qseecomfile reference an ION buffer. - Release the ION buffer, which sets the kernel handle to NULL but leaves the other parameters in place.
- Send a request whose length is larger than the buffer length, so the length check rejects it before the rest of the parameters are updated.
- The handle is no longer NULL, so the kernel proceeds to use the buffer, and
sb_virtand the other parameters still point at the freed mapping. The kernel then modifies freed memory.
Root cause
Two distinct mistakes.
For CVE-2019-14041, a single function serves two callers and branches on data->type, a field of a struct attached to the open file rather than to the call. The field can be changed by another ioctl (QSEECOM_IOCTL_APP_LOADED_QUERY_REQ) while the function is running, and the mechanisms that limit concurrent ioctls only take effect after the change. The function therefore mixes the two behaviours within one execution.
For CVE-2019-14040, the length check rejects an oversized request before the parameters in data are updated, but it does not clear or invalidate the previously stored buffer parameters. Releasing the buffer only NULLs the handle, and the later NULL check on the handle is the only guard before the buffer is used. A rejected request therefore leaves a non-NULL handle next to stale pointers to freed memory, and the kernel writes through them.
Impact
Combined with the earlier zLabs vulnerabilities (CVE-2017-13253, CVE-2018-9411 and CVE-2018-9539), these bugs could let a malicious app with no permissions achieve full root capabilities. The report lists what such an app could then do:
- Read all private data on the device, such as photos, videos, text messages (including end-to-end encrypted messaging apps like WhatsApp or Telegram) and email attachments.
- Obtain credentials for any app the user is logged into, giving direct access to company or personal data.
- Record video and audio through the camera and microphone without the user's knowledge.
The author stresses that the use after free is far more reliable than the race condition. In theory, an entirely unprivileged attacker could chain these bugs to reach complete root privileges. The direct precondition remains access to /dev/qseecom through a privileged service.
Fix
Qualcomm assigned CVE-2019-14040 and CVE-2019-14041 and published fixes in its February 2020 security bulletin. The report does not describe the patches themselves. The timeline it gives:
| Date | Event |
|---|---|
| July 31, 2019 | Vulnerabilities discovered |
| August 4, 2019 | Details and PoCs sent to Qualcomm |
| November 4, 2019 | Qualcomm says patches were sent to vendors |
| February 3, 2020 | Qualcomm publishes the security bulletin |
| March 3, 2020 | Samsung distributes fixes in its March security update |
| April 6, 2020 | Google distributes fixes in its April security update |
Variants to test
- Other ioctls that mutate per-file state. Look for ioctls that write fields of the struct attached to the open file (like
data->type) and can run concurrently with a function that reads those fields. A positive result is a function that observes two different values of the same field in one execution, visible as inconsistent branches or a crash. - Shared handlers for multiple callers. Find functions reached from more than one ioctl that branch on caller identity. If the identity lives in per-file state rather than being passed as an argument, the same race is likely present.
- Rejected requests that skip cleanup. For every validation failure path, check whether previously stored pointers, handles or lengths are left intact. A positive result is a later operation that uses a stale pointer after a request was rejected.
- Release paths that only NULL one field. When a resource is freed, check whether every reference to it is cleared. A positive result is a non-NULL handle next to a dangling mapping, as in
sb_virthere. - 64-bit equivalents. The report notes
__qseecom_update_cmd_buf_64behaves the same way for the race, so the same overlap should be tried against the 64-bit path.
What happened, in plain words
Eight months before this post was published, a security research team at Zimperium (called zLabs) told Qualcomm about two bugs in the software that runs on Qualcomm chips. Qualcomm makes the processors inside a very large number of Android phones. Because the bugs sit in code that every one of those phones runs, the team described them as affecting all Android devices with Qualcomm chipsets.

A bug in a phone's core software is serious because of what it can lead to. The researchers say that these two bugs, combined with three earlier bugs the same team had already found (CVE-2017-13253, CVE-2018-9411 and CVE-2018-9539), could let a malicious app that was never given any permissions reach full root capabilities. "Root" is the name for the highest level of control on an Android or Linux system: the account that can do anything. An ordinary app runs with very limited rights on purpose, so that a bad app cannot wreck the phone. Reaching root means those limits are gone.
The post lists what an app in that position could do:
- Read all private data stored on the device, like photos, videos, text messages (including end-to-end encrypted messaging apps like WhatsApp or Telegram), email attachments or practically anything else you can think of that is on the device.
- Obtain all credentials to any app the user is logged onto. With the username and password, the attacker has direct access to valuable company or personal data.
- Record video/audio through camera and microphone without the user knowledge.
After the report, Qualcomm gave the two bugs official tracking numbers, CVE-2019-14040 and CVE-2019-14041, and published fixes in its February security bulletin. A CVE number is a public label for a known security flaw, so that everyone can refer to the same bug unambiguously.
The rest of this article walks through the technical explanation, explaining each idea from scratch.
Background you need first
What a driver is
A computer's operating system is split into two broad halves. The kernel is the core: it is the only code allowed to touch the hardware directly, manage memory, and decide which program may do what. User space is where ordinary programs run, with restricted rights, asking the kernel for anything they need.
A driver is a piece of kernel code that knows how to talk to one specific piece of hardware or one specific subsystem. When a program wants to use that hardware, it does not poke the hardware itself; it asks the driver, and the driver does the privileged work on its behalf.
What QSEECOM is
The driver at the centre of this story is called QSEECOM, which stands for QTI Secure Execution Environment Communicator. On Qualcomm chips there are two worlds:
- the Normal World, where Android and your apps live;
- the Secure World, also called the TrustZone, a separate, locked-down environment that handles sensitive operations such as checking your fingerprint or storing cryptographic keys.
QSEECOM is the bridge. It lets programs in the Normal World send requests to the Secure World. The Secure World is deliberately isolated, so this bridge is a security-sensitive piece of code: it is one of the few doors between the ordinary world and the trusted one.
What an API and an ioctl are
An API (application programming interface) is the agreed set of requests one piece of software accepts from another. Think of a restaurant menu: you cannot walk into the kitchen and cook, but you can order any dish on the menu, and the kitchen handles it. The menu is the API.
The API QSEECOM offers is a set of ioctl calls on a special file, /dev/qseecom. An ioctl (short for "input/output control") is a general way for a program to send a command plus some data to a driver. On Linux and Android, devices appear as files under /dev, and a program opens one and issues commands against it. Each command has a name, and the driver decides what to do with it.
Who can use it
Only a set of privileged Android services has access to /dev/qseecom. In other words, the door is not open to every app; it is open to a handful of system services that Android trusts. The author points out that he has described multiple vulnerabilities affecting this sort of service in previous blog posts, and frames this work as the next step in achieving complete kernel privileges. The point is important for understanding impact: the bugs live behind a door that normal apps cannot open, so reaching them means going through a privileged service, or first compromising one.
The two bugs in one line each
- CVE-2019-14041: a race condition, which can cause all sorts of memory corruptions, depending on where exactly the race hits.
- CVE-2019-14040: a use after free of a kernel memory mapping.
A race condition is what happens when two operations run at the same time and the result depends on which one gets there first. Think of two people editing the same shared document: if one changes a heading while the other is still reading it, the second person may act on a heading that no longer exists. A use after free is simpler to state: a program frees a block of memory (hands it back, saying "I am done with this"), and then later uses it anyway. The memory may have been given to someone else in the meantime, so writing to it corrupts whatever now lives there.
The author says the race condition is less reliable and can cause different results, so he spends more time on the use after free.
The race condition (CVE-2019-14041)
One function, two callers
The race condition issue stems from one function: __qseecom_update_cmd_buf, and also its 64 bit equivalent __qseecom_update_cmd_buf_64, which for the sake of the race condition operates the same way. A function is a named block of code that does one job; other code calls it by name and it runs.
What does this function do? In short, its purpose is to update a buffer intended to be sent to the TrustZone with pointers the TrustZone can understand. A buffer is just a chunk of memory used to hold data while it is being moved around. A pointer is a number that says where in memory something sits, like a street address rather than the house itself. The Normal World and the Secure World describe memory differently, so before a request crosses the bridge, the driver rewrites the addresses inside it into a form the TrustZone understands.
In order to avoid duplicate code, the function is designed to handle two different cases in which such buffers are needed to be modified. Writing the same logic twice is a maintenance headache: fix a bug in one copy and the other copy still has it. So the developers made one function serve both cases. The author notes, with some regret, that no such design exists for handling 64 bit cases; the 64 bit function has a lot of code duplication.
Because one function serves two callers, it can be reached from two completely different ioctls. But in some parts the function still has to behave differently depending on which ioctl it was originally called from. In order to do this, the function checks data->type:

source
What this snippet shows, in plain words: the function checks data->type to decide how to behave. In one case data->type would be QSEECOM_CLIENT_APP. In the other case it would be QSEECOM_LISTENER_SERVICE. Depending on which one it sees, it takes a different path. Checks like this exist all throughout the function, so the function's behaviour is decided, again and again, by reading that one field.
The field that should not change
The issue is that data is actually a pointer to a qseecom_dev_handle struct, which is attached to the open /dev/qseecom file the ioctl is being performed on. A struct is a bundle of related values kept together under one name, like a form with several fields. This particular struct belongs to the open file: it holds the state of that one connection to the driver.
That leads to the question the author poses: what if it is possible to modify data->type while __qseecom_update_cmd_buf is running?

source
Turns out that running the ioctl QSEECOM_IOCTL_APP_LOADED_QUERY_REQ instantly modifies data->type. That is the trigger. There are some mechanisms to limit ioctls from running concurrently, meaning the driver does try to stop two commands from being processed at the same moment. But those mechanisms only come into effect after data->type was changed. The change happens first; the protection kicks in afterwards. Running this ioctl at the same time __qseecom_update_cmd_buf is running would therefore cause a race condition.
What goes wrong
The function will start with a behaviour that matches a data->type of QSEECOM_LISTENER_SERVICE but will continue with a behaviour that matches a data->type of QSEECOM_CLIENT_APP. In other words, halfway through its work the function changes its mind about which caller it is serving, because the field it keeps consulting was rewritten underneath it. It is like a chef who starts cooking one dish, reads the order ticket again halfway through, and finishes cooking a different dish, with the ingredients of both mixed in the pan.
This can cause different types of memory corruption, depending on where exactly the race hits. Memory corruption means memory ends up holding something it should not: a value written past the end of its space, a structure half-updated, and so on. While most of these are relatively harmless like a NULL dereference, some conditions can cause a buffer overflow, which is actually dangerous and can be possibly exploited. A NULL dereference is when code tries to use address zero, which is guaranteed to be invalid; the program usually crashes, which is bad but not a security hole by itself. A buffer overflow is when code writes more data than a buffer can hold, spilling into neighbouring memory; that is the classic way attackers take control, because they can choose what gets written where.
That is the vulnerability: a shared function whose behaviour depends on a field that another command can change mid-run.
The use after free (CVE-2019-14040)
Background: what ION is
In order to let Normal World user-space processes communicate with the TrustZone the ION mechanism is used. The author notes that the reason for this is unfortunately out of the scope of the blog post, so we take it as given.
In short, the ION mechanism allows user-space processes to allocate memory out of special heaps which behave differently than other regular memory. A heap here means a pool of memory that a program can ask for pieces of. "Special" matters because some hardware, including the TrustZone, can only work with memory that has particular physical properties, so it cannot just use any ordinary allocation. The user-space processes can then map it into their own memory space and read/write to it as they wish. Mapping means making a region of memory appear inside a program's address space so the program can read and write it like any other variable.
The way ION works with QSEECOM is that an open /dev/qseecom file can be made to reference an allocated ION buffer. The kernel then knows to use that buffer for further communications with the TrustZone. While it's mostly intended for the user-space process to read/write from that ION buffer, the kernel itself can sometimes modify it as well, done by __qseecom_update_cmd_buf which was described in the previous section. So the same piece of memory is shared: the app can touch it, and the kernel can touch it.

source
The code above handles a request from user-space to reference an allocated ION buffer. As can be seen, multiple parameters regarding the ION buffer are saved, like a handle and a mapping of it in kernel space. A handle is an identifier the kernel keeps for a resource, a bit like a coat-check ticket: you do not carry the coat around, you carry the ticket and the attendant fetches the coat. data is the same as in the previous section, a pointer to a struct which is attached to the open /dev/qseecom file. So all these saved parameters live in that per-file struct.

How ION buffer usage looks in QSEECOM
This diagram is captioned "How ION buffer usage looks in QSEECOM".
One thing to note is that when releasing the ION buffer the kernel handle to it is set to NULL:

source
In plain words: the release code clears the handle field, setting it to NULL. NULL is a special value meaning "nothing". So after a release, the struct says "I have no buffer" as far as the handle is concerned.

QSEECOM data after ION buffer is released
This picture is captioned "QSEECOM data after ION buffer is released".
This possible NULL is then used when trying to use the ION buffer from the kernel. The handle is verified to not be NULL:

source
That snippet is the guard: before using the buffer, the kernel checks that the handle is not NULL, and refuses to continue if it is. This is a sensible check, and it is exactly the check the bug will slip past.
The flaw
Let's take a closer look at the code which references an ION buffer from an open /dev/qseecom file:

source
Obviously, this code doesn't just allow any request from user-space without checking it first. There are multiple checks along this function to completely verify the request coming from user-space. The check displayed in the code above is one example: if the length in the request is more than the length of the ION buffer (the len variable) then the request is invalid. In plain words: the app says "use this buffer, and here is how much data I am putting in it"; the kernel compares that amount against the size of the buffer it has on record, and rejects the request if the app claims more than fits.
The issue, though, is exactly in this check. What would happen to the parameters in data if the length in the request is too big? More importantly, what would happen if that open /dev/qseecom file already referenced an ION buffer before but that was freed?

QSEECOM data after ION buffer is released then a request with bad length is received
In this scenario, the handle would no longer be NULL, but the rest of the parameters won't be modified, so they will point to the previously referenced ION buffer. For instance, sb_virt would point to a memory mapping that was already freed. This is all while attempts to use the referenced ION buffer from the kernel should work, since, again, the handle is no longer NULL. This is the use after free: when attempting to use the ION buffer the kernel will modify a memory mapping that was already freed.
Let us slow that down, because it is the heart of the bug. Three things happen in sequence:
- The file references an ION buffer. The struct records a handle and a set of pointers, including
sb_virt, which points at the kernel's mapping of that buffer. - The buffer is released. The release code sets the handle to NULL, but the other fields, including
sb_virt, are left as they were. They now point at memory that has been given back. - A new request arrives with a length that is too big. The length check rejects it, and because the request is rejected, the code never gets as far as updating the parameters in
data. The handle, however, is no longer NULL, so the guard passes. So the guard passes, the kernel proceeds to use the buffer, andsb_virtstill points at the freed mapping. The kernel then writes into memory it no longer owns.
A comparison: you check out a hotel room, hand back the key, and the front desk marks the key as returned. But the room number is still written on your paperwork. If you later wave the paperwork and the desk only checks that you are not holding a key marked "returned", you get sent to a room that now belongs to someone else, and you start rearranging the furniture.
How an attacker would use this
The report does not include the requests or payloads themselves; it describes the two bugs and points to the PoCs on GitHub. A PoC, or proof of concept, is a small program written to demonstrate that a bug is real, usually by triggering it deliberately. The full source code for PoCs for both vulnerabilities is available on GitHub:
The mechanics the report does describe are as follows.
Step 1: reach the QSEECOM ioctl interface
An attacker needs to be able to issue ioctls on /dev/qseecom. In normal Android only privileged services have that access, so the bugs are reached through such a service, or through a chain that first compromises one. This is why the earlier bugs in privileged services matter: they are the way in.
Step 2 (race): overlap two ioctls on the same open file
Run QSEECOM_IOCTL_APP_LOADED_QUERY_REQ concurrently with an ioctl that reaches __qseecom_update_cmd_buf. The first changes data->type immediately; the concurrency limits only apply afterwards. The update function then switches mid-run from QSEECOM_LISTENER_SERVICE behaviour to QSEECOM_CLIENT_APP behaviour, and depending on where the race lands the result is anything from a NULL dereference to a buffer overflow. "Concurrently" means at the same time, from two threads, so that the two commands interleave.
Step 3 (use after free): free the buffer, then send a bad length
- Make the open
/dev/qseecomfile reference an ION buffer. - Release the ION buffer, which sets the kernel handle to NULL but leaves the other parameters in place.
- Send a request whose length is larger than the buffer length, so the length check rejects it before the rest of the parameters are updated.
- The handle is no longer NULL, so the kernel proceeds to use the buffer, and
sb_virtand the other parameters still point at the freed mapping. The kernel then modifies freed memory.
Why the bugs exist
The report identifies two distinct mistakes.
For CVE-2019-14041, a single function serves two callers and branches on data->type, a field of a struct attached to the open file rather than to the call. The field can be changed by another ioctl, QSEECOM_IOCTL_APP_LOADED_QUERY_REQ, while the function is running, and the mechanisms that limit concurrent ioctls only take effect after the change. The function therefore mixes the two behaviours within one execution. The design lesson is that information about "who is calling" should travel with the call, not sit in shared state that anyone can rewrite.
For CVE-2019-14040, the length check rejects an oversized request before the parameters in data are updated, but it does not clear or invalidate the previously stored buffer parameters. Releasing the buffer only NULLs the handle, and the later NULL check on the handle is the only guard before the buffer is used. A rejected request therefore leaves a non-NULL handle next to stale pointers to freed memory, and the kernel writes through them. "Stale" means out of date: the pointer still holds an old address that is no longer valid.
Impact
Combined with the earlier zLabs vulnerabilities (CVE-2017-13253, CVE-2018-9411 and CVE-2018-9539), these bugs could let a malicious app with no permissions achieve full root capabilities. The report lists what such an app could then do:
- Read all private data on the device, such as photos, videos, text messages (including end-to-end encrypted messaging apps like WhatsApp or Telegram) and email attachments.
- Obtain credentials for any app the user is logged into, giving direct access to company or personal data.
- Record video and audio through the camera and microphone without the user's knowledge.
The author stresses that the use after free is far more reliable than the race condition. Reliability matters to an attacker: a race depends on timing and may fail most of the time, while a use after free follows a fixed sequence of steps. In theory, an entirely unprivileged attacker could chain these bugs to reach complete root privileges. The direct precondition remains access to /dev/qseecom through a privileged service.
The fix and the timeline
Qualcomm assigned CVE-2019-14040 and CVE-2019-14041 and published fixes in its February 2020 security bulletin. The report does not describe the patches themselves. The timeline it gives:
| Date | Event |
|---|---|
| July 31, 2019 | Vulnerabilities discovered |
| August 4, 2019 | Details and PoCs sent to Qualcomm |
| November 4, 2019 | Qualcomm says patches were sent to vendors |
| February 3, 2020 | Qualcomm publishes the security bulletin |
| March 3, 2020 | Samsung distributes fixes in its March security update |
| April 6, 2020 | Google distributes fixes in its April security update |
A security bulletin is a public notice from a vendor listing fixed vulnerabilities, so that device makers and users know what was patched and when. The gap between discovery and a fix reaching phones is normal in this process: the vendor has to write the patch, share it with device manufacturers, and each manufacturer then ships it in its own update.
What to look for elsewhere
The report closes with takeaways, a timeline and contact details. They are written here in plain terms.
- Other ioctls that mutate per-file state. Look for ioctls that write fields of the struct attached to the open file, like
data->type, and can run concurrently with a function that reads those fields. A positive result is a function that observes two different values of the same field in one execution, visible as inconsistent branches or a crash. - Shared handlers for multiple callers. Find functions reached from more than one ioctl that branch on caller identity. If the identity lives in per-file state rather than being passed as an argument, the same race is likely present.
- Rejected requests that skip cleanup. For every validation failure path, check whether previously stored pointers, handles or lengths are left intact. A positive result is a later operation that uses a stale pointer after a request was rejected.
- Release paths that only NULL one field. When a resource is freed, check whether every reference to it is cleared. A positive result is a non-NULL handle next to a dangling mapping, as in
sb_virthere. A dangling pointer is a pointer to memory that has been freed. - 64-bit equivalents. The report notes
__qseecom_update_cmd_buf_64behaves the same way for the race, so the same overlap should be tried against the 64-bit path.
Glossary
- API: the agreed set of requests one piece of software accepts from another, like a menu you can order from.
- Buffer: a chunk of memory used to hold data while it is being moved or processed.
- Buffer overflow: writing more data into a buffer than it can hold, so the extra data spills into neighbouring memory.
- CVE: a public identifier for a known security vulnerability, so everyone can refer to the same bug.
- Driver: kernel code that knows how to operate one specific piece of hardware or subsystem on behalf of programs.
- Dangling pointer: a pointer that still holds the address of memory that has already been freed.
- Handle: an identifier the kernel keeps for a resource, which a program presents when it wants to use that resource.
- Heap: a pool of memory from which a program can request pieces at runtime.
- ION: an Android memory mechanism that lets user-space processes allocate memory from special heaps and share it with the kernel and hardware.
- ioctl: a way for a program to send a command plus data to a device driver, usually through a file under
/dev. - Kernel: the core of the operating system, the only code allowed to touch hardware and enforce permissions.
- Mapping: making a region of memory appear inside a program's address space so it can be read and written like ordinary variables.
- Memory corruption: a state where memory holds values it should not, usually because code wrote outside the intended area or used stale data.
- NULL: a special value meaning "nothing" or "no address".
- NULL dereference: code trying to use address zero, which is invalid, usually causing a crash.
- Pointer: a value that says where in memory something is stored, like a street address rather than the house.
- PoC (proof of concept): a small program that demonstrates a bug is real by triggering it.
- Privileged service: a system program on Android that runs with more rights than an ordinary app.
- QSEECOM: the Qualcomm driver that lets the Normal World talk to the Secure World through
/dev/qseecom. - Race condition: a bug where two operations running at the same time produce a wrong result depending on which one happens first.
- Root: the highest privilege level on Android and Linux, able to do anything on the device.
- Secure World / TrustZone: a separate, locked-down execution environment on the chip that handles sensitive operations.
- Security bulletin: a public vendor notice listing vulnerabilities that have been fixed.
- Stale: out of date; a stored value that no longer reflects reality.
- Struct: a bundle of related values kept together under one name, like a form with several fields.
- Use after free: using memory after it has been freed, when it may already belong to something else.
- User space: the restricted environment where ordinary programs run, as opposed to the kernel.