From: Gustavo Padovan <gustavo@padovan.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Chad Versace <chadversary@chromium.org>, dri-devel@lists.freedesktop.org
Subject: Re: Why does OUT_FENCE_PTR point not to an fd (s32) but to an s64?
Date: Thu, 12 Jan 2017 17:34:07 -0200 [thread overview]
Message-ID: <20170112193407.GD16017@joana> (raw)
In-Reply-To: <3347856.CHH5B2jR7L@avalon>
2017-01-12 Laurent Pinchart <laurent.pinchart@ideasonboard.com>:
> Hi Daniel,
>
> On Thursday 12 Jan 2017 20:26:40 Daniel Vetter wrote:
> > On Thu, Jan 12, 2017 at 05:17:26PM -0200, Gustavo Padovan wrote:
> > > 2017-01-10 Laurent Pinchart <laurent.pinchart@ideasonboard.com>:
> > >> On Monday 09 Jan 2017 11:23:23 Daniel Vetter wrote:
> > >>> On Fri, Jan 06, 2017 at 01:04:55PM -0800, 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.
> > >>>
> > >>> Never use unsized types for uabi. I guess we could have used s32, but
> > >>> then someone is going to store this in a long and it goes boom on 64
> > >>> bit,
> > >>
> > >> Why so ? And why do we care ? The commonly accepted practice is to store
> > >> file descriptors in int variables. s32 is an int on all platforms, so
> > >> that's fine too. If we use a s32 pointer here, and someone decides to
> > >> store it in a long, bool or cast it to a complex, that's their problem
> > >> :-)
> > >
> > > The only thing that really needs to be s64 here is the OUT_FENCE_PTR
> > > property in the Atomic interface because we carry a pointer there, but
> > > all the manipulation after that is actually done after can easily be
> > > done on s32 or int.
> > >
> > > We can't expect that userspace will know that we store as s64 and clear
> > > the bits above if a int was passed down. if we use s32 we will be in
> > > complaince with other linux apis that deals with fds. I'd say we fix
> > > this before it can cause more damage out there.
> >
> > Changing uabi is kinda tricky, but it's still very new, so if we make sure
> > it gets applied everywhere and doesn't accidentally ship we can it. Iirc
> > fences are only in 4.10, so we should be fine ...
>
> Correct. That sounds good to me, there's still time for a v4.10-rc fix.
I'd expect users defining an int and hitting the issue Chad hit instead
of going to long types. So I hope we are safe here. I'll prepare a
patch to make it s32.
Gustavo
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2017-01-12 19:34 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
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 [this message]
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=20170112193407.GD16017@joana \
--to=gustavo@padovan.org \
--cc=chadversary@chromium.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=laurent.pinchart@ideasonboard.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.