Skip to content

Commit f7a3f52

Browse files
Mark Yacoubwulf7
authored andcommitted
drm: Copy drm_wait_vblank to user before returning
[ Upstream commit fa0b1ef5f7a694f48e00804a391245f3471aa155 ] [Why] Userspace should get back a copy of drm_wait_vblank that's been modified even when drm_wait_vblank_ioctl returns a failure. Rationale: drm_wait_vblank_ioctl modifies the request and expects the user to read it back. When the type is RELATIVE, it modifies it to ABSOLUTE and updates the sequence to become current_vblank_count + sequence (which was RELATIVE), but now it became ABSOLUTE. drmWaitVBlank (in libdrm) expects this to be the case as it modifies the request to be Absolute so it expects the sequence to would have been updated. The change is in compat_drm_wait_vblank, which is called by drm_compat_ioctl. This change of copying the data back regardless of the return number makes it en par with drm_ioctl, which always copies the data before returning. [How] Return from the function after everything has been copied to user. Fixes IGT:kms_flip::modeset-vs-vblank-race-interruptible Tested on ChromeOS Trogdor(msm) Reviewed-by: Michel Dänzer <[email protected]> Signed-off-by: Mark Yacoub <[email protected]> Signed-off-by: Sean Paul <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 6f65f77 commit f7a3f52

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/gpu/drm/drm_ioc32.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,8 +866,6 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
866866
req.request.sequence = req32.request.sequence;
867867
req.request.signal = req32.request.signal;
868868
err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED);
869-
if (err)
870-
return err;
871869

872870
req32.reply.type = req.reply.type;
873871
req32.reply.sequence = req.reply.sequence;
@@ -876,7 +874,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
876874
if (copy_to_user(argp, &req32, sizeof(req32)))
877875
return -EFAULT;
878876

879-
return 0;
877+
return err;
880878
}
881879

882880
#if defined(CONFIG_X86)

0 commit comments

Comments
 (0)