Xen Security Advisory 391 v3 (CVE-2021-28711,CVE-2021-28712,CVE-2021-28713) - Rogue backends can cause DoS of guests via high frequency events
Subsystems (6)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Xen Security Advisory CVE-2021-28711,CVE-2021-28712,CVE-2021-28713 / XSA-391
version 3
Rogue backends can cause DoS of guests via high frequency events
UPDATES IN VERSION 3
====================
Public release
ISSUE DESCRIPTION
=================
Xen offers the ability to run PV backends in regular unprivileged guests, typically referred to as "driver domains". Running PV backends in driver domains has one primary security advantage: if a driver domain gets compromised, it doesn't have the privileges to take over the system.
However, a malicious driver domain could try to attack other guests via sending events at a high frequency leading to a Denial of Service in the guest due to trying to service interrupts for elongated amounts of time.
There are three affected backends:
* blkfront patch 1, CVE-2021-28711
* netfront patch 2, CVE-2021-28712
* hvc_xen (console) patch 3, CVE-2021-28713
IMPACT
======
Potentially malicious PV backends can cause guest DoS due to unhardened frontends in the guests, even though this ought to have been prevented by containing them within a driver domain.
VULNERABLE SYSTEMS
==================
All guests being serviced by potentially malicious backends are vulnerable, even if those backends are running in a less privileged environment. The vulnerability is not affecting the host, but the guests.
MITIGATION
==========
There is no known mitigation available.
RESOLUTION
==========
Applying the attached patches resolves this issue.
xsa391-linux-1.patch Linux 5.15 xsa391-linux-2.patch Linux 5.15 xsa391-linux-3.patch Linux 5.15
$ sha256sum xsa391* e55d3f15a85ff31e62a291981de89f7b0c08da807db9b2a6a2b9cbb2e29847cd xsa391-linux-1.patch 163fc4b9966768eb74e3bc1858a0b0254eff771898bd5f4d71806beeae0ffd2a xsa391-linux-2.patch de888abe8d11d3204b4033b304cf3d66104a65956089e23f1736db682d3cedc4 xsa391-linux-3.patch $
CREDITS
=======
This issue was discovered by Jürgen Groß of SUSE.
DEPLOYMENT DURING EMBARGO
=========================
Deployment of patches or mitigations is NOT permitted (except where all the affected systems and VMs are administered and used only by organisations which are members of the Xen Project Security Issues Predisclosure List). Specifically, deployment on public cloud systems is NOT permitted.
This is because the patches need to be applied to the guests, which will be visible by the guest administrators.
Deployment is permitted only AFTER the embargo ends.
(Note: this during-embargo deployment notice is retained in post-embargo publicly released Xen Project advisories, even though it is then no longer applicable. This is to enable the community to have oversight of the Xen Project Security Team's decisionmaking.)
For more information about permissible uses of embargoed information, consult the Xen Project community's agreed Security Policy:
http://www.xenproject.org/security-policy.html
-----BEGIN PGP SIGNATURE-----
iQFABAEBCAAqFiEEI+MiLBRfRHX6gGCng/4UyVfoK9kFAmG8srwMHHBncEB4ZW4u b3JnAAoJEIP+FMlX6CvZz/kH/RFI60D9qJnbNmDMgtbvihwn+jeHI0ejS7en8Ojf CL9QftZ2+YdyxjMISOHCCaWgUKQQyF/n9chF5sMMOkWRfUPL2TDPPKTmEnC9XMOq MYIftwT0OoMAVVhrRU3FZUZtpvTeQstofOYhBGhElmeEibYU+DbjKiv4agTEE3+8 9M3cxDk3Zw9cO1/6tU3kYtPkbxVP3r6kZQSHnpRnKLbABXWJB3Y02cX09tU//mV7 2REisCWKViLcKoupYTUOQHPWOD+VFE48mwKB4D9H9t9aTyn5PVjH/jVhiGrqbbic ia8a0AKi5F9l8xIKha81+TGIbjCY+HCuLbaShRDnaU9/2Qc=
=wKo2
-----END PGP SIGNATURE-----
From 26b2bd1077b811a5fae92fdd9586703fd81a7ad1 Mon Sep 17 00:00:00 2001
From: Juergen Gross <[email protected]>
Date: Wed, 1 Dec 2021 13:00:04 +0100
Subject: [PATCH 1/3] xen/blkfront: harden blkfront against event channel
storms
The Xen blkfront driver is still vulnerable for an attack via excessive number of events sent by the backend. Fix that by using lateeoi event channels.
This is CVE-2021-28711, part of XSA-391
--- drivers/block/xen-blkfront.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/block/xen-blkfront.c +12 -3
@@ -1512,9 +1512,12 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)unsigned long flags;struct blkfront_ring_info *rinfo = (struct blkfront_ring_info *)dev_id;struct blkfront_info *info = rinfo->dev_info; +unsigned int eoiflag =XEN_EOI_FLAG_SPURIOUS ; -if (unlikely (info->connected !=BLKIF_STATE_CONNECTED )) +if (unlikely (info->connected !=BLKIF_STATE_CONNECTED )) { +xen_irq_lateeoi (irq,XEN_EOI_FLAG_SPURIOUS );return IRQ_HANDLED ; + }spin_lock_irqsave (&rinfo->ring_lock, flags); again:
@@ -1530,6 +1533,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)unsigned long id;unsigned int op; + eoiflag =0 ; +RING_COPY_RESPONSE (&rinfo->ring, i, &bret); id = bret.id;
@@ -1646,6 +1651,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)spin_unlock_irqrestore (&rinfo->ring_lock, flags); +xen_irq_lateeoi (irq, eoiflag); +return IRQ_HANDLED ; err:
@@ -1653,6 +1660,8 @@ static irqreturn_t blkif_interrupt(int irq, void *dev_id)spin_unlock_irqrestore (&rinfo->ring_lock, flags); +/* No EOI in order to avoid further interrupts. */ +pr_alert ("%s disabled for further use\n" , info->gd->disk_name);return IRQ_HANDLED ; }
@@ -1692,8 +1701,8 @@ static int setup_blkring(struct xenbus_device *dev,if (err) goto fail; - err =bind_evtchn_to_irqhandler (rinfo->evtchn, blkif_interrupt,0 , -"blkif" , rinfo); + err =bind_evtchn_to_irqhandler_lateeoi (rinfo->evtchn, blkif_interrupt, +0 ,"blkif" , rinfo);if (err <=0 ) {xenbus_dev_fatal (dev, err,"bind_evtchn_to_irqhandler failed" );
Signature · 1 line
2.26.2
From 805e6302ee38313d6c4e6162332ec3a6682ca068 Mon Sep 17 00:00:00 2001
From: Juergen Gross <[email protected]>
Date: Wed, 1 Dec 2021 13:00:04 +0100
Subject: [PATCH 2/3] xen/netfront: harden netfront against event channel
storms
The Xen netfront driver is still vulnerable for an attack via excessive number of events sent by the backend. Fix that by using lateeoi event channels.
For being able to detect the case of no rx responses being added while the carrier is down a new lock is needed in order to update and test rsp_cons and the number of seen unconsumed responses atomically.
This is CVE-2021-28712, part of XSA-391
--- drivers/net/xen-netfront.c | 125 ++++++++++++++++++++++++++++--------- 1 file changed, 94 insertions(+), 31 deletions(-)
drivers/net/xen-netfront.c +94 -31
250 lines not on this page · raw message
Signature · 1 line
2.26.2
From a93dbd03e8a3e2fa0e1039dee122e47819708759 Mon Sep 17 00:00:00 2001
From: Juergen Gross <[email protected]>
Date: Wed, 1 Dec 2021 13:00:04 +0100
Subject: [PATCH 3/3] xen/console: harden hvc_xen against event channel
storms
The Xen console driver is still vulnerable for an attack via excessive number of events sent by the backend. Fix that by using a lateeoi event channel.
For the normal domU initial console this requires the introduction of bind_evtchn_to_irq_lateeoi() as there is no xenbus device available at the time the event channel is bound to the irq.
As the decision whether an interrupt was spurious or not requires to test for bytes having been read from the backend, move sending the event into the if statement, as sending an event without having found any bytes to be read is making no sense at all.
This is CVE-2021-28713, part of XSA-391
--- drivers/tty/hvc/hvc_xen.c | 30 +++++++++++++++++++++++++++--- drivers/xen/events/events_base.c | 6 ++++++ include/xen/events.h | 1 + 3 files changed, 34 insertions(+), 3 deletions(-)
drivers/tty/hvc/hvc_xen.c +27 -3
@@ -37,6 +37,8 @@ struct xencons_info {struct xenbus_device *xbdev;struct xencons_interface *intf;unsigned int evtchn; +XENCONS_RING_IDX out_cons; +unsigned int out_cons_same;struct hvc_struct *hvc;int irq;int vtermno;
@@ -138,6 +140,8 @@ static int domU_read_console(uint32_t vtermno, char *buf, int len)XENCONS_RING_IDX cons, prod;int recv =0 ;struct xencons_info *xencons =vtermno_to_xencons (vtermno); +unsigned int eoiflag =0 ; +if (xencons ==NULL )return -EINVAL ; intf = xencons->intf;
@@ -157,7 +161,27 @@ static int domU_read_console(uint32_t vtermno, char *buf, int len)mb ();/* read ring before consuming */ intf->in_cons = cons; -notify_daemon (xencons); +/* +* When to mark interrupt having been spurious: +* - there was no new data to be read, and +* - the backend did not consume some output bytes, and +* - the previous round with no read data didn't see consumed bytes +* (we might have a race with an interrupt being in flight while +* updating xencons->out_cons, so account for that by allowing one +* round without any visible reason) +*/ +if (intf->out_cons != xencons->out_cons) { + xencons->out_cons = intf->out_cons; + xencons->out_cons_same =0 ; + } +if (recv) { +notify_daemon (xencons); + }else if (xencons->out_cons_same++ >1 ) { + eoiflag =XEN_EOI_FLAG_SPURIOUS ; + } + +xen_irq_lateeoi (xencons->irq, eoiflag); +return recv; }
@@ -386,7 +410,7 @@ static int xencons_connect_backend(struct xenbus_device *dev,if (ret)return ret; info->evtchn = evtchn; - irq =bind_evtchn_to_irq (evtchn); + irq =bind_interdomain_evtchn_to_irq_lateeoi (dev, evtchn);if (irq <0 )return irq; info->irq = irq;
@@ -551,7 +575,7 @@ static int __init xen_hvc_init(void)return r; info =vtermno_to_xencons (HVC_COOKIE ); - info->irq =bind_evtchn_to_irq (info->evtchn); + info->irq =bind_evtchn_to_irq_lateeoi (info->evtchn); }if (info->irq <0 ) info->irq =0 ;/* NO_IRQ */
drivers/xen/events/events_base.c +6 -0
@@ -1251,6 +1251,12 @@ int bind_evtchn_to_irq(evtchn_port_t evtchn) }EXPORT_SYMBOL_GPL (bind_evtchn_to_irq); +int bind_evtchn_to_irq_lateeoi (evtchn_port_t evtchn) +{ +return bind_evtchn_to_irq_chip (evtchn, &xen_lateeoi_chip,NULL ); +} +EXPORT_SYMBOL_GPL (bind_evtchn_to_irq_lateeoi); +static int bind_ipi_to_irq (unsigned int ipi,unsigned int cpu) {struct evtchn_bind_ipi bind_ipi;
include/xen/events.h +1 -0
@@ -17,6 +17,7 @@ struct xenbus_device;unsigned xen_evtchn_nr_channels (void );int bind_evtchn_to_irq (evtchn_port_t evtchn); +int bind_evtchn_to_irq_lateeoi (evtchn_port_t evtchn); int bind_evtchn_to_irqhandler(evtchn_port_t evtchn, irq_handler_t handler, unsigned long irqflags, const char *devname,
Signature · 1 line
2.26.2