]> Git Repo - qemu.git/commit
vfio-ccw: Do not read region ret_code after write
authorEric Farman <[email protected]>
Wed, 3 Mar 2021 16:07:39 +0000 (17:07 +0100)
committerCornelia Huck <[email protected]>
Thu, 4 Mar 2021 10:24:49 +0000 (11:24 +0100)
commitd6cd66311f527ee29c1d7b0988059cda00ad92fa
treebe0733ae11c95efb6332808ffa572e4daf5cc73b
parenta54b8ac340c20531daa89929c5ce7fed89fa401d
vfio-ccw: Do not read region ret_code after write

A pwrite() call returns the number of bytes written (or -1 on error),
and vfio-ccw compares this number with the size of the region to
determine if an error had occurred or not.

If they are not equal, this is a failure and the errno is used to
determine exactly how things failed. An errno of zero is possible
(though unlikely) in this situation and would be translated to a
successful operation.

If they ARE equal, the ret_code field is read from the region to
determine how to proceed. While the kernel sets the ret_code field
as necessary, the region and thus this field is not "written back"
to the user. So the value can only be what it was initialized to,
which is zero.

So, let's convert an unexpected length with errno of zero to a
return code of -EFAULT, and explicitly set an expected length to
a return code of zero. This will be a little safer and clearer.

Suggested-by: Matthew Rosato <[email protected]>
Signed-off-by: Eric Farman <[email protected]>
Message-Id: <20210303160739.2179378[email protected]>
Signed-off-by: Cornelia Huck <[email protected]>
hw/vfio/ccw.c
This page took 0.026637 seconds and 4 git commands to generate.