* [PATCH 4.14-stable backport] vfio: ccw: only free cp on final interrupt
@ 2019-04-01 13:14 Cornelia Huck
2019-04-01 13:52 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Cornelia Huck @ 2019-04-01 13:14 UTC (permalink / raw)
To: stable; +Cc: farman
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: stable@vger.kernel.org # v4.12+
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
(cherry picked from commit 50b7f1b7236bab08ebbbecf90521e84b068d7a17)
---
drivers/s390/cio/vfio_ccw_drv.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
index ae7a49ade414..d22759eb6640 100644
--- a/drivers/s390/cio/vfio_ccw_drv.c
+++ b/drivers/s390/cio/vfio_ccw_drv.c
@@ -70,20 +70,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;
}
--
2.17.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 4.14-stable backport] vfio: ccw: only free cp on final interrupt
2019-04-01 13:14 [PATCH 4.14-stable backport] vfio: ccw: only free cp on final interrupt Cornelia Huck
@ 2019-04-01 13:52 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2019-04-01 13:52 UTC (permalink / raw)
To: Cornelia Huck; +Cc: stable, farman
On Mon, Apr 01, 2019 at 03:14:25PM +0200, Cornelia Huck wrote:
> 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: stable@vger.kernel.org # v4.12+
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Cornelia Huck <cohuck@redhat.com>
> (cherry picked from commit 50b7f1b7236bab08ebbbecf90521e84b068d7a17)
> ---
> drivers/s390/cio/vfio_ccw_drv.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-01 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-01 13:14 [PATCH 4.14-stable backport] vfio: ccw: only free cp on final interrupt Cornelia Huck
2019-04-01 13:52 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).