Skip to contentSkip to conversation

vfio-ccw: be less trusting

PATCH In review Cornelia Huck 2 participants 5 messages Feb 22, 2018 – Mar 2, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover vfio-ccw: be less trusting

I'm currently prototyping hsch()/csch() support for vfio-ccw, and stumbled over this: We currently expect any I/O to be in command-mode, but don't take care to actively reject transport-mode. This is not an issue with QEMU (which rejects transport-mode ORBs before even the css backend gets to it), but better play safe.

Should we want to support transport-mode in the future, we'll probably need to introduce a capability for it that needs to be enabled by user space.

[I also still have the doc patch from some time ago queued. Let's see if we'll collect more patches.]

Cornelia Huck (1):
vfio-ccw: fence off transport mode

 drivers/s390/cio/vfio_ccw_fsm.c | 5 +++++
 1 file changed, 5 insertions(+)
Signature · 1 line
2.13.6
#1 lore raw

PATCH 1/1 vfio-ccw: fence off transport mode

vfio-ccw only supports command mode for channel programs, not transport mode. User space is supposed to already take care of that and pass us command-mode ORBs only, but better make sure and return an error to the caller instead of trying to process tcws as ccws.

---
 drivers/s390/cio/vfio_ccw_fsm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/s390/cio/vfio_ccw_fsm.c +5 -0
index c30420c517b1..ff6963ad6e39 100644
@@ -124,6 +124,11 @@ static void fsm_io_request(struct vfio_ccw_private *private,
 	if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) {
 		orb = (union orb *)io_region->orb_area;
 
+		/* Don't try to build a cp if transport mode is specified. */
+		if (orb->tm.b) {
+			io_region->ret_code = -EOPNOTSUPP;
+			goto err_out;
+		}
 		io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev),
 					      orb);
 		if (io_region->ret_code)
Signature · 1 line
2.13.6
Acked-by on v1 1/1
#2 lore raw

Re: [PATCH 1/1] vfio-ccw: fence off transport mode

Quoted 6 lines · Cornelia Huck

vfio-ccw only supports command mode for channel programs, not transport mode. User space is supposed to already take care of that and pass us command-mode ORBs only, but better make sure and return an error to the caller instead of trying to process tcws as ccws.

Quoted 9 lines
---
 drivers/s390/cio/vfio_ccw_fsm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/s390/cio/vfio_ccw_fsm.c +0 -0
index c30420c517b1..ff6963ad6e39 100644

drivers/s390/cio/vfio_ccw_fsm.c static void fsm_io_request(struct vfio_ccw_private *private, · line 129

Quoted 6 lines
drivers/s390/cio/vfio_ccw_fsm.c +3 -0
@@ -124,6 +124,11 @@ static void fsm_io_request(struct vfio_ccw_private *private,
 	if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) {
 		orb = (union orb *)io_region->orb_area;
 
+		/* Don't try to build a cp if transport mode is specified. */
+		if (orb->tm.b) {
+			io_region->ret_code = -EOPNOTSUPP;

I guess now we communicate this as appropriately as possible.

Quoted 6 lines
drivers/s390/cio/vfio_ccw_fsm.c +2 -0
+			goto err_out;
+		}
 		io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev),
 					      orb);
 		if (io_region->ret_code)
#3 lore raw

Re: [PATCH 1/1] vfio-ccw: fence off transport mode

Quoted 9 lines · On Thu, 1 Mar 2018 15:51:05 +0100 Halil Pasic <[email protected]> wrote:
Quoted 6 lines · Cornelia Huck

vfio-ccw only supports command mode for channel programs, not transport mode. User space is supposed to already take care of that and pass us command-mode ORBs only, but better make sure and return an error to the caller instead of trying to process tcws as ccws.

Thanks!

Quoted 13 lines
Quoted 13 lines
---
 drivers/s390/cio/vfio_ccw_fsm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/s390/cio/vfio_ccw_fsm.c +0 -0
index c30420c517b1..ff6963ad6e39 100644
@@ -124,6 +124,11 @@ static void fsm_io_request(struct vfio_ccw_private *private,
 	if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) {
 		orb = (union orb *)io_region->orb_area;
 
Quoted 5 lines

drivers/s390/cio/vfio_ccw_fsm.c static void fsm_io_request(struct vfio_ccw_private *private, · line 129

Quoted 3 lines
drivers/s390/cio/vfio_ccw_fsm.c +3 -0
+		/* Don't try to build a cp if transport mode is specified. */
+		if (orb->tm.b) {
+			io_region->ret_code = -EOPNOTSUPP;  

I guess now we communicate this as appropriately as possible.

Yes. We certainly only want to return an error to user space; it is their responsibility to correctly reflect that to the guest (and even more their responsibility to not present us with a transport orb in the first place...)

Quoted 8 lines
Quoted 7 lines
drivers/s390/cio/vfio_ccw_fsm.c +2 -0
+			goto err_out;
+		}
 		io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev),
 					      orb);
 		if (io_region->ret_code)
#4 lore raw

Re: [PATCH 1/1] vfio-ccw: fence off transport mode

In reply to Cornelia Huck
Quoted 16 lines · On Thu, 22 Feb 2018 16:39:59 +0100 Cornelia Huck <[email protected]> wrote:

vfio-ccw only supports command mode for channel programs, not transport mode. User space is supposed to already take care of that and pass us command-mode ORBs only, but better make sure and return an error to the caller instead of trying to process tcws as ccws.

---
 drivers/s390/cio/vfio_ccw_fsm.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/s390/cio/vfio_ccw_fsm.c +0 -0
index c30420c517b1..ff6963ad6e39 100644
@@ -124,6 +124,11 @@ static void fsm_io_request(struct vfio_ccw_private *private,
 	if (scsw->cmd.fctl & SCSW_FCTL_START_FUNC) {

drivers/s390/cio/vfio_ccw_fsm.c static void fsm_io_request(struct vfio_ccw_private *private, · line 134

Quoted 10 lines
drivers/s390/cio/vfio_ccw_fsm.c +5 -0
 		orb = (union orb *)io_region->orb_area;
 
+		/* Don't try to build a cp if transport mode is specified. */
+		if (orb->tm.b) {
+			io_region->ret_code = -EOPNOTSUPP;
+			goto err_out;
+		}
 		io_region->ret_code = cp_init(&private->cp, mdev_dev(mdev),
 					      orb);
 		if (io_region->ret_code)

Queued.

I'll probably send a pull request next week.