All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH kvmtool] virtio/pci: explicit zero unknown devices features
@ 2025-08-14 15:37 Paolo Abeni
  2025-08-14 16:07 ` Cristian Marussi
  2025-08-19 11:01 ` Will Deacon
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Abeni @ 2025-08-14 15:37 UTC (permalink / raw)
  To: kvm; +Cc: Cristian Marussi, Will Deacon

The linux kernel implementation for the virtio_net driver recently
gained support for virtio features above the 64th bit.

It relies on the hypervisor to clear the features data for unknown /
unsupported features range.

The current pci-modern implementation, in such scenario, leaves the
data memory untouched, which causes the guest kernel assuming "random"
features are supported (and possibly leaks host memory contents).

Explicitly clear the features data for unsupported range.

Reported-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 virtio/pci-modern.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/virtio/pci-modern.c b/virtio/pci-modern.c
index c5b4bc5..ef2f3e2 100644
--- a/virtio/pci-modern.c
+++ b/virtio/pci-modern.c
@@ -156,8 +156,10 @@ static bool virtio_pci__common_read(struct virtio_device *vdev,
 		ioport__write32(data, val);
 		break;
 	case VIRTIO_PCI_COMMON_DF:
-		if (vpci->device_features_sel > 1)
+		if (vpci->device_features_sel > 1) {
+			ioport__write32(data, 0);
 			break;
+		}
 		features |= vdev->ops->get_host_features(vpci->kvm, vpci->dev);
 		val = features >> (32 * vpci->device_features_sel);
 		ioport__write32(data, val);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-19 11:01 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-14 15:37 [PATCH kvmtool] virtio/pci: explicit zero unknown devices features Paolo Abeni
2025-08-14 16:07 ` Cristian Marussi
2025-08-19 11:01 ` Will Deacon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.