net/mlx5e: Check for NOT_READY flag state after locking
CVE: CVE-2023-53581
Component: kernel
Severity: Moderate
CVSS v3: 7.0/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H
Release date: 2023-01-01T00:00:00+00:00

A race condition was found in the Linux kernel Mellanox mlx5 network driver's  traffic control offload flow management. 
A local user with privileges to configure traffic control flower filters can trigger concurrent flow deletion operations where the NOT_READY flag is checked before acquiring the necessary lock, allowing a workqueue task to concurrently remove the flow from the unready_flows list, which causes double-removal from the linked list and results in list corruption leading to denial of service via kernel crash or potentially memory corruption.

Statement: The issue arises because of incorrect lock ordering in the flow deletion path. When mlx5e_tc_del_fdb_flow() processes a flow deletion, it first checks the NOT_READY flag to determine if the flow is on the unready_flows list, then acquires the uplink_priv->unready_flows_lock mutex to remove it. However, between the flag check and lock acquisition, a workqueue task can acquire the same lock and remove the flow from the list. When the original thread then acquires the lock and attempts list removal, it performs a double-removal on an entry that is no longer in the list. This corrupts the linked list pointers, causing subsequent list operations to access freed memory containing poison values (0xdead000000000100). The race window is narrow, requiring the workqueue to execute between the flag check and lock acquisition. While this reliably causes kernel crashes when the race occurs, the underlying list corruption represents a memory safety violation that could potentially be leveraged for more sophisticated attacks with careful timing and heap manipulation.

Remediation:
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258

The system must be rebooted for this update to take effect.
To mitigate this issue, prevent the mlx5_core module from loading. See https://access.redhat.com/solutions/41278 for instructions on blacklisting kernel modules.