Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp917628pxb; Wed, 1 Sep 2021 12:38:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJEbr/C/Wmy0ukEQ7R3I3fNL61K29q/eNmt0cnmQVn8qOQuyYl/hq2C1AMI26qP0XlJzN/ X-Received: by 2002:a05:6e02:174c:: with SMTP id y12mr821026ill.35.1630525108039; Wed, 01 Sep 2021 12:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630525108; cv=none; d=google.com; s=arc-20160816; b=mLFaq8hzzjXiK+dd6upryWCyszRNkzhKw2B0DM/9re/8j0f/I+O3ZrfWdVXEU09qUT FvNQ7jX81zxA74Gv7TFLcH2o2cNiZiu31brT7YYwWeTr93AnMUjtQUzvehRUmpugMCry rj42yB94lunkRuwGQSF+AhnNtVEMEv3aabk8uoxp3dkKb9zKbz7aKWJh0DeQOSdGhOoY uVpPb7o5jfDzwUeOF/a/+1ty9A2QJSqJOz/LwUiOqQdeWpTCrTUnhIdn84nnhAwP3Eph eHfli1Fi+wrPaj9/ANzJnTytska3a5IsJLATakwHTOpfpUT5hEcM0vt4doR5mEPePdXm yr7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1HIFH2eAf0WSE0Ys6taEOMVjE8atLFagBCVrF5zhYbk=; b=EhTEKAn+QgZNqOs1TDIv9HbdoOUpVovMw+16Gu4HzSbhWekc6W4EHm5fMI1HaSHn8a ZVGj00A4hHSU+O+2KPe86hYqPTmC89LiAiFbiojXyw6INrqFDL/pB8vNCMz9CYt/QJk7 GvjoMCt/OnX4Yz638FxZxDc2IVJFfqIciQbVGB4gRWvmNKTW8GjUkSY0oVGTFyqUal30 JFiDBH3LfuqQwjJEUmS7gXc//bUIky/865Z1+FSqrPSLqqv6ScM+UB/Wh5jLk6XYf71V xCi966EBurUO8TejOdSxzm3qAo4PhrOzNQxlg2HOIWa6O3C88xhCgCBqqVKDiy4/Yog4 h6Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CVCMdT92; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si500907ilg.86.2021.09.01.12.38.16; Wed, 01 Sep 2021 12:38:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=CVCMdT92; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344241AbhIAMpV (ORCPT + 99 others); Wed, 1 Sep 2021 08:45:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:40776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345073AbhIAMkn (ORCPT ); Wed, 1 Sep 2021 08:40:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C7CEA611C9; Wed, 1 Sep 2021 12:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630499817; bh=eD7Mh7yKFLunROXvwGmWc4qE4Yk8kegCJ1S1t0zEyFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CVCMdT92eodqjRxsTGG4qJgSv7auMhtFvP5Thp1JKSwWL2B+VFftZ2BP4As0BLfrw 1JogE0eUOnI5MDpCnsFBEWSBoz3sDb2uZAl+D8AsO71URJRR3Nk4021n1yM8LrjIur 5apEd6BPU5Gydp6wFIanva3m3CCADqQMP0qrZZz4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Michel=20D=C3=A4nzer?= , Mark Yacoub , Sean Paul , Sasha Levin Subject: [PATCH 5.10 067/103] drm: Copy drm_wait_vblank to user before returning Date: Wed, 1 Sep 2021 14:28:17 +0200 Message-Id: <20210901122302.824537632@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122300.503008474@linuxfoundation.org> References: <20210901122300.503008474@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mark Yacoub [ 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 Signed-off-by: Mark Yacoub Signed-off-by: Sean Paul Link: https://patchwork.freedesktop.org/patch/msgid/20210812194917.1703356-1-markyacoub@chromium.org Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_ioc32.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c index dc734d4828a1..aaf8d625ce1a 100644 --- a/drivers/gpu/drm/drm_ioc32.c +++ b/drivers/gpu/drm/drm_ioc32.c @@ -865,8 +865,6 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd, req.request.sequence = req32.request.sequence; req.request.signal = req32.request.signal; err = drm_ioctl_kernel(file, drm_wait_vblank_ioctl, &req, DRM_UNLOCKED); - if (err) - return err; req32.reply.type = req.reply.type; req32.reply.sequence = req.reply.sequence; @@ -875,7 +873,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd, if (copy_to_user(argp, &req32, sizeof(req32))) return -EFAULT; - return 0; + return err; } #if defined(CONFIG_X86) -- 2.30.2