vhost: fix vhost_get_avail_idx for a non empty ring
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ d3bb267bbdcba199568f1325743d9d501dea0560 · < 09861858a68342f851f71c669ac0f69865c32151| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
vhost: fix vhost_get_avail_idx for a non empty ring
vhost_get_avail_idx is supposed to report whether it has updated vq->avail_idx. Instead, it returns whether all entries have been consumed, which is usually the same. But not always - in drivers/vhost/net.c and when mergeable buffers have been enabled, the driver checks whether the combined entries are big enough to store an incoming packet. If not, the driver re-enables notifications with available entries still in the ring. The incorrect return value from vhost_get_avail_idx propagates through vhost_enable_notify and causes the host to livelock if the guest is not making progress, as vhost will immediately disable notifications and retry using the available entries.
This goes back to commit d3bb267bbdcb ("vhost: cache avail index in vhost_enable_notify()") which changed vhost_enable_notify() to compare the freshly read avail index against vq->last_avail_idx instead of the previously cached vq->avail_idx. Commit 7ad472397667 ("vhost: move smp_rmb() into vhost_get_avail_idx()") then carried over the same comparison when refactoring vhost_enable_notify() to call the unified vhost_get_avail_idx().
The obvious fix is to make vhost_get_avail_idx do what the comment says it does and report whether new entries have been added.
From the CVE record · Linux
The Linux kernel’s vhost_get_avail_idx() can return the wrong result when entries remain in the ring. With mergeable buffers enabled in vhost networking, a guest that is not making progress can cause the host to livelock if the available entries cannot hold an incoming packet. The input does not specify authentication or user-interaction requirements.
Engineers running Linux hosts that use vhost networking with mergeable buffers should check their kernel versions against the vendor advisory; affected versions are not specified here.