xen/gntdev: fix error handling in ioctl
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ 68b025c813c2eb41ff25628e3d4952d5185eb1a4 · < 16d3ccdabb8dee9be2cdcd6d3f9a125572ec0454| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
xen/gntdev: fix error handling in ioctl
When gntdev_ioctl_map_grant_ref() fails to copy the operation result back to userspace after successfully adding the mapping to the list, the error path returns -EFAULT without releasing the reference acquired by gntdev_alloc_map(). The mapping remains in priv->maps with a refcount of 1, causing a memory leak and a dangling list entry.
Additionally, gntdev_add_map() may modify map->index to avoid overlap with existing mappings. Therefore, the index returned to userspace must be obtained after gntdev_add_map() completes.
Fix this by holding the mutex across gntdev_add_map(), retrieving the correct index, and copy_to_user(). If copy_to_user() fails, remove the mapping from the list and release the reference while still holding the lock.
Fix these issues by properly handling all error cases.
From the CVE record · Linux
The Linux kernel’s xen/gntdev ioctl can leave a mapping on its list and leak memory if copying a successfully added mapping’s result to userspace fails. A local user able to invoke the ioctl could trigger this error path. The ioctl can also return an incorrect mapping index when an overlap causes the index to change.
Teams running Linux kernels with the xen/gntdev component should check their vendor’s advisory; affected versions were not provided.