Skip to contentSkip to conversation

vfio: ccw: only free cp on final interrupt

GIT PULL Cornelia Huck 2 participants 2 messages Mar 11, 2019 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

When we get an interrupt for a channel program, it is not necessarily the final interrupt; for example, the issuing guest may request an intermediate interrupt by specifying the program-controlled-interrupt flag on a ccw.

We must not switch the state to idle if the interrupt is not yet final; even more importantly, we must not free the translated channel program if the interrupt is not yet final, or the host can crash during cp rewind.

Fixes e5f84dbaea59 ("vfio: ccw: return I/O results asynchronously")
Cc [email protected] # v4.12+
---
 drivers/s390/cio/vfio_ccw_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/s390/cio/vfio_ccw_drv.c +6 -2
index a10cec0e86eb..0b3b9de45c60 100644
@@ -72,20 +72,24 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
 {
 	struct vfio_ccw_private *private;
 	struct irb *irb;
+	bool is_final;
 
 	private = container_of(work, struct vfio_ccw_private, io_work);
 	irb = &private->irb;
 
+	is_final = !(scsw_actl(&irb->scsw) &
+		     (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT));
 	if (scsw_is_solicited(&irb->scsw)) {
 		cp_update_scsw(&private->cp, &irb->scsw);
-		cp_free(&private->cp);
+		if (is_final)
+			cp_free(&private->cp);
 	}
 	memcpy(private->io_region->irb_area, irb, sizeof(*irb));
 
 	if (private->io_trigger)
 		eventfd_signal(private->io_trigger, 1);
 
-	if (private->mdev)
+	if (private->mdev && is_final)
 		private->state = VFIO_CCW_STATE_IDLE;
 }
 
Signature · 1 line
2.17.2
#2 lore raw

Re: [PULL 0/1] vfio-ccw: fix for 5.1

In reply to a message not in the archive
Quoted 15 lines · On Mon, 11 Mar 2019 17:26:55 +0100 Cornelia Huck <[email protected]> wrote:

The following changes since commit 152e9b8676c6e788c6bff095c1eaae7b86df5003:

s390/vtime: steal time exponential moving average (2019-03-06 14:59:50 +0100)

are available in the Git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git tags/vfio-ccw-20190311

for you to fetch changes up to 50b7f1b7236bab08ebbbecf90521e84b068d7a17:

vfio: ccw: only free cp on final interrupt (2019-03-11 12:06:50 +0100)

----------------------------------------------------------------
Fix a host crash triggerable by the guest via a channel program.

Quoted 7 lines

----------------------------------------------------------------

Cornelia Huck (1):
vfio: ccw: only free cp on final interrupt

 drivers/s390/cio/vfio_ccw_drv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Pulled & pushed to s390/linux:fixes. Thanks.

Signature · 4 lines
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.