dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Chad Versace <chadversary@chromium.org>
To: dri-devel@lists.freedesktop.org,
	Gustavo Padovan <gustavo@padovan.org>,
	Daniel Vetter <daniel@ffwll.ch>, Rob Clark <robdclark@gmail.com>,
	Chris Wilson <chris@chris-wilson.co.uk>
Subject: Re: Why does OUT_FENCE_PTR point not to an fd (s32) but to an s64?
Date: Fri, 6 Jan 2017 13:13:21 -0800	[thread overview]
Message-ID: <20170106211321.GA93747@chadversary.pdx.corp.google.com> (raw)
In-Reply-To: <20170106210455.GA87963@chadversary.pdx.corp.google.com>

+rantogno

Rafael, I finally discovered the source of the bug I was hitting.

On Fri 06 Jan 2017, Chad Versace wrote:
> Was this a mistake in the API? If so, can we fix this ABI mistake before
> kernel consumers rely on this?
> 
> I naïvely expected that OUT_FENCE_PTR would be a pointer to, obviously, a fence
> fd (s32 __user *). But it's not. It's s64 __user *. Due to that surprise, I
> spent several hours chasing down weird corruption in Rob Clark's kmscube. The
> kernel unexpectedly cleared the 32 bits *above* an `int kms_fence_fd` in
> userspace.
> 
> For reference, here's the relevant DRM code.
> 
>     // file: drivers/gpu/drm/drm_atomic.c
>     struct drm_out_fence_state {
>             s64 __user *out_fence_ptr;
>             struct sync_file *sync_file;
>             int fd;
>     };
>     
>     static int setup_out_fence(struct drm_out_fence_state *fence_state,
>                                struct dma_fence *fence)
>     {
>             fence_state->fd = get_unused_fd_flags(O_CLOEXEC);
>             if (fence_state->fd < 0)
>                     return fence_state->fd;
>     
>             if (put_user(fence_state->fd, fence_state->out_fence_ptr))
>                     return -EFAULT;
>     
>             fence_state->sync_file = sync_file_create(fence);
>             if (!fence_state->sync_file)
>                     return -ENOMEM;
>     
>             return 0;
>     }
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  reply	other threads:[~2017-01-06 21:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-06 21:04 Why does OUT_FENCE_PTR point not to an fd (s32) but to an s64? Chad Versace
2017-01-06 21:13 ` Chad Versace [this message]
2017-01-09 10:23 ` Daniel Vetter
2017-01-10 20:58   ` Laurent Pinchart
2017-01-12 19:17     ` Gustavo Padovan
2017-01-12 19:26       ` Daniel Vetter
2017-01-12 19:29         ` Laurent Pinchart
2017-01-12 19:34           ` Gustavo Padovan
2017-01-13 21:31             ` Chad Versace

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170106211321.GA93747@chadversary.pdx.corp.google.com \
    --to=chadversary@chromium.org \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gustavo@padovan.org \
    --cc=robdclark@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox