CVE-2025-38040: Microsoft Linux Kernels Exposure Across Azure and WSL

  • Thread Author
Microsoft’s advisory that CVE-2025-38040 affects “Azure Linux” is technically correct as a first-tranche disclosure, but it is incomplete as a statement of exposure risk for Microsoft’s entire product portfolio — and it understates what maintainers and operators need to check to be sure they are not affected. The vulnerability is a kernel-level change to the serial modem-control GPIO helpers (the serial_mctrl_gpio helpers) that was backported into multiple stable kernel trees; any Microsoft product that ships, distributes, or runs a Linux kernel configured to include those helpers — or that uses a distribution kernel containing the affected drivers — can be impacted. The practical exposure depends on three concrete facts: whether the kernel source for a product contains the serial_mctrl_gpio code, whether the kernel configuration for that product enabled it (built-in or as a module), and whether the deployed kernel version is older than the patch level that introduced the split disable APIs. This article unpacks the technical details, shows how to determine whether a given Microsoft product is affected, evaluates Microsoft’s initial disclosure, and provides a clear remediation and detection playbook for system administrators and service owners.

Dim blue workstation with dual monitors showing code and a PATCH file beside a motherboard.Background / Overview​

The issue described by CVE-2025-38040 arises from how the Linux kernel’s serial modem-control GPIO helpers disable modem-status interrupts. Historically, the helper function used to disable modem-status (MS) GPIO IRQs when a serial device no longer needed to monitor modem-control lines. That helper — mctrl_gpio_disable_ms — could end up calling a blocking API (disable_irq) from an atomic or otherwise non‑sleepable context when invoked by certain serial drivers. When a sleeping function is called from an invalid (atomic) context the kernel produces a “BUG: sleeping function called from invalid context” splat and may panic or otherwise become unstable. The kernel patch for this CVE splits the single disable API into two explicit variants:
  • mctrl_gpio_disable_ms_sync — disables IRQ handling and waits for any pending IRQ processing to complete (blocking, safe only when sleeping is allowed), and
  • mctrl_gpio_disable_ms_no_sync — disables IRQ handling and returns immediately (non‑blocking, safe for atomic contexts).
The patch replaces the single callsite with a decision point in upstream drivers so the appropriate API is chosen depending on whether the caller holds locks or is otherwise in an atomic context. The change was applied to many stable kernel trees and distributed by Linux distribution vendors as part of normal kernel maintenance.
Why this matters: serial drivers used on embedded SoCs, single‑board computers, and some general purpose platforms can call the modem-control helpers when toggling flow control or configuring modem lines. If a driver calls the blocking variant in an atomic context, a kernel panic or oops is possible — an availability impact. This is not a remote code execution vulnerability by default; it is an availability and stability issue that can be triggered locally by device drivers or code paths that touch those serial APIs.

How the vulnerability manifests technically​

The root cause, in plain engineering terms​

The kernel’s prior single-function implementation of disabling modem-status GPIO IRQs performed a blocking operation (disable_irq) under some conditions. Some serial drivers, when changing line settings or flow control, do so in contexts that are protected by port locks or are otherwise non-sleepable. Invoking a function that may sleep from such a context triggers kernel diagnostics (CONFIG_DEBUG_ATOMIC_SLEEP) and can cause a fatal error or panic on kernels with that debugging configuration, or unpredictable behavior in production kernels.

What the patch changed​

The core patch introduces explicit API semantics: callers that may be in atomic contexts must call the “no_sync” (non-blocking) variant; callers that may sleep call the “sync” (blocking) variant. This prevents inadvertent sleeping in atomic contexts and eliminates the root cause of the BUG traces observed on affected platforms.

Typical call stacks where the issue was observed​

Reported splats surfaced on Atmel SAMA5D27 platforms using the atmel_serial driver. The stack traces showed disable_irq being invoked from mctrl_gpio_disable_ms while the thread was not allowed to sleep. Typical stack traces share the pattern: uart_set_termios → tty_set_termios → port / driver flow-control or modem-status code → atmel_disable_ms → mctrl_gpio_disable_ms → disable_irq → __might_resched check. Those traces allow maintainers to hunt similar call paths in other drivers.

Which Microsoft products include the library?​

Microsoft’s public statement for CVE-2025-38040 identified Azure Linux as a Microsoft product that includes the serial_mctrl_gpio helpers and may therefore be potentially affected. That statement is accurate as a conservative, early disclosure, but it is not an exhaustive inventory of Microsoft products that could use the code. The set of Microsoft products to evaluate includes at least:
  • Azure Linux image kernels and Microsoft-maintained kernels used on Azure guest images.
  • The Windows Subsystem for Linux (WSL) kernel build that Microsoft ships as part of WSL2 (Windows includes and ships a Microsoft-built Linux kernel image).
  • Any other Microsoft product that packages or distributes a Linux kernel as part of the product (for example, appliance-style offerings, certain Azure services that ship prebuilt images, or internal appliance images for cloud services).
Two important technical caveats shape whether a listed product is actually “affected”:
  • Presence in source is not the same as exposure. The serial_mctrl_gpio code has been part of the upstream kernel tree for many kernel versions (the driver has existed for years). A Microsoft product that uses a Linux kernel tree that contains the file is not automatically vulnerable — the kernel must have been configured with the option that builds the module or compiles the helper into the kernel image (CONFIG_SERIAL_MCTRL_GPIO), or the distribution’s upstream kernel must have the relevant drivers enabled that depend on it (for example, AT91/Atmel, IMX, many SoC serial drivers, or 8250 UART variants). In short: the driver’s presence in the kernel tree is necessary but not sufficient.
  • The kernel must be at a version older than the patch release for that specific kernel series. Upstream and stable kernel releases received the change on various timelines, and vendors rebased and shipped fixes in different stable-release branches. If a product ships a kernel version that already contains the fix, the product is not exposed to the issue.
Therefore, Microsoft’s statement that Azure Linux includes the library is meaningful but incomplete: other Microsoft products that ship or embed Linux kernels (notably WSL2’s kernel) must be validated on a per-product basis.

Evidence and cross‑checks (what operators should assume)​

  • The serial mctrl GPIO helpers are part of the upstream kernel driver set and are used by multiple serial drivers (Atmel, imx, 8250-related drivers, others). The kernel docs and driver sources explicitly list the mctrl helpers as a helper API for modem-control lines via GPIO.
  • The upstream kernel patch split the disable API into sync and no_sync variants; that change appears in stable kernel merge logs and in the driver diffs for the 6.1/6.6/6.12/6.14/6.15 series as a backport/fix for the issue.
  • Multiple Linux distribution vendors (Debian, Ubuntu, Red Hat, SUSE, Amazon Linux, Oracle Linux and others) treated the issue as a kernel bug and published advisories and fixed kernel packages referencing the same change.
These independent signals (kernel upstream change, vendor advisories, distribution fixes) confirm the scope of the code change and the kinds of kernels and drivers that may be affected. That said: to determine product exposure in Microsoft’s portfolio, you must confirm the kernel configuration and version used in each product image.

How to determine if a Microsoft product (or any Linux host) is affected — step‑by‑step​

This checklist prioritizes high-confidence, actionable checks. For any host or product image, follow these steps:
  • Identify the running kernel release:
    1. uname -r
    2. cat /proc/version
    These tell you the exact kernel release string.
  • Check whether the kernel was built with the serial_mctrl_gpio driver option:
  • If /proc/config.gz exists:
  • zcat /proc/config.gz | grep -i SERIAL_MCTRL
  • Else check the kernel config installed in /boot:
  • grep -i SERIAL_MCTRL /boot/config-$(uname -r)
  • Alternatively, if you have access to the kernel build tree, inspect drivers/tty/serial/Kconfig and drivers/tty/serial/serial_mctrl_gpio.c for the relevant symbols.
If you see CONFIG_SERIAL_MCTRL_GPIO=y or =m, the module is built in or available. If it’s =m, check whether the module is present on disk (modinfo serial_mctrl_gpio) and whether it’s loaded.
  • Verify whether the serial drivers that call the helpers are present and enabled:
  • List UART-related modules: lsmod | egrep 'atmel|imx|8250|serial'
  • Check /lib/modules/$(uname -r)/kernel/drivers/tty/serial for driver files like atmel_serial. If those drivers are present, they may exercise the mctrl helpers.
  • Check kernel version against patch thresholds:
  • Many vendors published fixed kernel versions in stable branches. If your kernel is older than the fixed release for your major stable series, you should assume you need a kernel update.
  • If your kernel is a vendor-supplied distro kernel, consult your distro’s advisory to confirm whether the packaged kernel includes the patch.
  • Inspect logs for past occurrences:
  • dmesg | egrep -i 'sleeping function called from invalid context|mctrl_gpio|disable_irq|BUG:'
  • If you’ve seen the exact BUG trace referenced in public advisories (with mctrl_gpio_disable_ms → disable_irq in the call stack), you have observed the root cause already.
  • For WSL2 users and Windows admins:
  • WSL2 runs a Microsoft-provided Linux kernel image on Windows. The WSL kernel configuration may include various serial helpers. If you build your own WSL kernel or use the Microsoft-distributed kernel, check the Microsoft WSL kernel config (Microsoft/config-wsl in the WSL kernel source tree) for CONFIG_SERIAL_MCTRL_GPIO. If the option is set, follow the same version/config checks as above, and update the WSL kernel to a patched build when available.
  • Azure cloud images:
  • Virtual machines running on Azure are subject to the distribution kernel they use. If you’re running Microsoft-maintained Azure Linux images, check the distro advisory or Microsoft update guidance for an applicable kernel package. If you run a user-managed image (Ubuntu, RHEL, SLES, etc. check the distro advisory for that kernel.

Remediation guidance — concrete steps​

  • Apply vendor kernel updates. The canonical fix is a kernel update that contains the split disable APIs and the updated callsites. For distribution kernels, accept the kernel package updates rolled out by your distro vendor. For Microsoft‑maintained kernels (Azure Linux or WSL), apply Microsoft’s published kernel updates or fetch the patched kernel builds as recommended by Microsoft.
  • If you maintain your own kernel builds (including custom WSL kernels), rebuild against an upstream kernel that contains the fix and ensure that all serial drivers call the correct API variant. Prefer safe defaults:
  • Replace calls to the old single disable API with the appropriate sync/no_sync variant based on whether the caller may sleep.
  • In environments where kernel patching is tightly controlled (embedded devices, appliances), inspect driver callsites that touch serial_mctrl_gpio and ensure they use the no_sync variant from atomic contexts.
  • As a short-term mitigation when patching is not possible:
  • Isolate or disable the affected serial driver(s) where practical (blacklist the module with modprobe.d if the serial device is not required).
  • Disable debugging options that cause visible splats (CONFIG_DEBUG_ATOMIC_SLEEP) is not a robust mitigation — do not rely on disabling diagnostics to prevent crashes in production.

Detection and monitoring​

Ongoing detection can save hours in incident triage. Key monitoring signals include:
  • Kernel logs for the specific BUG trace signature featuring mctrl_gpio_disable_ms → disable_irq.
  • System crashes or kernel panics around serial driver activity (for example, when toggling flow control or at device initialization).
  • Unexpected reboots or worker thread stack traces in dmesg referencing uart_set_termios, atmel_disable_ms, or similar call paths.
  • For managed fleets, correlate kernel versions and CONFIG_SERIAL_MCTRL_GPIO-enabled images; prioritize patching of images where the option is enabled.
Set a simple daily search across fleet logs for the distinct strings previously listed to catch early signs of triggered behavior.

Risk analysis: impact, exploitability, and scale​

  • Impact category: The vulnerability primarily affects availability (stability and crashes). There are no known reports that it enables privilege escalation, information disclosure, or remote code execution by itself.
  • Exploitability: This is not an easy remote exploit. The vulnerability requires local conditions: code paths that trigger modem-control disable sequences while in atomic contexts, or drivers that call the old blocking helper in an invalid context. On many general-purpose servers the affected callpaths may be dormant unless specific serial devices or driver interactions occur.
  • Scale: Because the serial_mctrl_gpio helper is used by a set of serial drivers common on embedded and SoC platforms, embedded Linux devices, IoT appliances, and specialized boards are at higher risk than typical x86 cloud VMs. However, cloud images that include distribution kernels with the older code path — and Microsoft-provided kernels that enable the helper — should be audited and patched where necessary.
  • Microsoft product exposure: Azure Linux was correctly called out as including the library. The WSL kernel, Microsoft’s own kernel builds for WSL2, and any Microsoft image/distribution that packages a Linux kernel might include the helper depending on kernel config. Operators should not assume “Azure Linux only” — the presence of the helper in multiple distributions and kernel versions means the potential blast radius extends beyond a single Microsoft product unless you have validated kernel configs and versions across your Microsoft-hosted stacks.

Why Microsoft’s initial wording is conservative but insufficient​

Microsoft’s published line — that Azure Linux includes the open-source library and that the company will update if additional product impact is found — is a typical, cautious disclosure pattern. It communicates that Microsoft’s immediate inventory has identified Azure Linux images as containing the code, and it promises updates if the product impact expands.
From a security engineering and operator perspective, however, that statement should be accompanied by two things:
  • A clear list (or a machine‑readable feed) of Microsoft products and images that ship kernels containing the helper and their current remediation status; and
  • Guidance for users of Microsoft products that ship Linux kernels (e.g., WSL) on how to verify their kernel configuration and how to obtain patched kernels.
Until Microsoft provides an exhaustive inventory across their kernel-bearing products, customers and sysadmins are best served by treating any Microsoft product that ships a Linux kernel as “needs verification” rather than presuming it is unaffected.

Practical checklist for Microsoft customers and administrators​

  • Inventory all Microsoft-hosted Linux instances and all endpoints that run Microsoft-supplied Linux kernels (including WSL2 instances on developer desktops).
  • For each instance, run:
  • uname -r
  • grep -i SERIAL_MCTRL /boot/config-$(uname -r) || zcat /proc/config.gz | grep -i SERIAL_MCTRL
  • lsmod | grep -E 'serial_mctrl|atmel|imx|8250'
  • dmesg | egrep -i 'mctrl_gpio|disable_irq|sleeping function called from invalid context|atmel_disable_ms'
  • Prioritize patching images and devices where CONFIG_SERIAL_MCTRL_GPIO is enabled (built-in or module) and kernel version is older than the fixed release for that kernel series.
  • For WSL2, if you use the Microsoft-supplied kernel, watch the Microsoft WSL channels for kernel updates; if you use a customized WSL kernel, rebuild from an upstream commit that includes the fix and replace the kernel binary used by WSL.

Conclusion​

CVE-2025-38040 is a classic kernel robustness fix: the upstream kernel maintainers made the helper semantics explicit to prevent sleeping in atomic contexts. Microsoft’s immediate disclosure naming Azure Linux is accurate as a targeted inventory result, but it is not a blanket assurance that no other Microsoft product includes the library. Any Microsoft product that bundles a Linux kernel or supplies kernel images — notably WSL2 and Azure VM images — should be treated as needing verification.
Operators should assume risk unless they confirm three facts for each relevant image or product: the kernel version is patched (post-fix release), the kernel config does not enable the legacy behavior where it is used unsafely, or corrective mitigations have been applied. The simplest practical steps are to check the kernel config and update to a patched kernel or patched distribution package. Because the issue is primarily an availability/stability issue rather than a confidentiality or integrity exploit, prioritize remediation for production systems where serial drivers, embedded devices, or SoC-specific kernels are in use.

Source: MSRC Security Update Guide - Microsoft Security Response Center
 

Back
Top