Philippe Mathieu-Daudé <[email protected]> writes:
> On 25/11/25 10:03, Markus Armbruster wrote:
>> Markus Armbruster <[email protected]> writes:
>>
>>> Retrieve the @errno set by ioctl() before we call accel_ioctl_end()
>>> instead of afterwards, so it works whether accel_ioctl_end() preserves
>>> @errno or not.
>>>
>>> Signed-off-by: Markus Armbruster <[email protected]>
>>
>> I did not check whether the assumption holds or not.
>
> Indeed, on Linux the futex syscall is called via qemu_event_set.
So ...
>> If it doesn't,
>> then this needs
>>
>> Fixes: a27dd2de68f3 (KVM: keep track of running ioctls)
... we definitely want this tag, and the commit message should be
clarified as well. Here's my try:
kvm: Fix kvm_vm_ioctl() and kvm_device_ioctl() return value
These functions wrap ioctl(). When ioctl() fails, it sets @errno.
The wrappers then return that @errno negated.
Except they call accel_ioctl_end() between calling ioctl() and reading
@errno. accel_ioctl_end() can clobber @errno, e.g. when a futex()
system call fails. Seems unlikely, but it's a bug all the same.
Fix by retrieving @errno before calling accel_ioctl_end().
Fixes: a27dd2de68f3 (KVM: keep track of running ioctls)
> LGTM.
>
> Reviewed-by: Philippe Mathieu-Daudé <[email protected]>
Thanks!