What do I do if a dentry leak in the OverlayFS of an Alibaba Cloud Linux 2 ECS instance causes a system crash?

Updated at:

This topic explains the cause of a system crash triggered by a dentry leak in OverlayFS on Elastic Compute Service (ECS) instances running Alibaba Cloud Linux 2, and describes how to fix it.

Affected systems

This issue affects ECS instances with all of the following configurations:

  • Image: Alibaba Cloud Linux 2.1903 LTS 64-bit

  • Kernel version: kernel-4.19.91-22.2.al7 or earlier

Run the following command to check your kernel version:

uname -r

Cause

The ovl_get_redirect function in OverlayFS does not acquire a lock when operating on dentry reference counts. When other CPU tasks access the same reference count concurrently, a race condition occurs, causing reference count leaks that crash the system.

The crash produces a call stack similar to the following:

[   49.810410] Call Trace:
[   49.810653]  d_delete+0x2c/0xb0
[   49.810951]  vfs_rmdir+0xfd/0x120
[   49.811264]  do_rmdir+0x14f/0x1a0
[   49.811573]  do_syscall_64+0x5b/0x190
[   49.811917]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Solution

Two fix options are available. The kernel live patch fixes the issue without requiring a restart but is a temporary measure. For a permanent fix, upgrade the kernel and restart the instance.

Warning

Kernel upgrades may cause compatibility and stability issues. Review the release notes for Alibaba Cloud Linux 2 before upgrading.

Warning

Restarting the instance temporarily stops it, which may interrupt running services and lead to data loss. Back up critical data and restart during off-peak hours.

Option 1: Upgrade the kernel (permanent fix)

Applies to: Kernel version 4.19.91-22.2.al7.x86_64 or earlier

Prerequisites

  • Root or sudo access to the instance

Upgrade the kernel

  1. Upgrade the kernel to the latest version.

    sudo yum update kernel
  2. Restart the instance for the new kernel to take effect.

    sudo reboot

Verify the fix

After the instance restarts, confirm the kernel version has been updated:

uname -r

The output should show a kernel version later than 4.19.91-22.2.al7.x86_64.

Option 2: Install a kernel live patch (temporary fix)

Applies to: Kernel versions from 4.19.91-19.1.al7.x86_64 to 4.19.91-22.2.al7.x86_64

A kernel live patch applies the fix without requiring a restart. It is a temporary measure — plan to upgrade the kernel and restart the instance when possible.

Prerequisites

  • Root or sudo access to the instance

  • Kernel version between 4.19.91-19.1.al7.x86_64 and 4.19.91-22.2.al7.x86_64 (inclusive)

Install the live patch

Run the following command to install the kernel live patch that matches your running kernel:

sudo yum install -y kernel-hotfix-4375449-`uname -r | awk -F"-" '{print $NF}'`

This command automatically detects your current kernel version and installs the corresponding kernel-hotfix-4375449 package.

Verify the fix

Confirm the patch package is installed:

rpm -q kernel-hotfix-4375449-$(uname -r | awk -F"-" '{print $NF}')

The command outputs the installed package name if the installation was successful.