dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-buf: Fix SET_NAME ioctl uapi
@ 2020-04-07 13:30 Daniel Vetter
  2020-04-09  3:58 ` Sumit Semwal
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Vetter @ 2020-04-07 13:30 UTC (permalink / raw)
  To: DRI Development
  Cc: Daniel Vetter, Chenbo Feng, Greg Hackmann, linaro-mm-sig,
	minchan, jenhaochen, Daniel Vetter, Martin Liu, surenb,
	linux-media

The uapi is the same on 32 and 64 bit, but the number isnt. Everyone
who botched this please re-read:

https://www.kernel.org/doc/html/v5.4-preprc-cpu/ioctl/botching-up-ioctls.html

Also, the type argument for the ioctl macros is for the type the void
__user *arg pointer points at, which in this case would be the
variable-sized char[] of a 0 terminated string. So this was botched in
more than just the usual ways.

Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Chenbo Feng <fengc@google.com>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Cc: minchan@kernel.org
Cc: surenb@google.com
Cc: jenhaochen@google.com
Cc: Martin Liu <liumartin@google.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/dma-buf/dma-buf.c    | 3 ++-
 include/uapi/linux/dma-buf.h | 4 ++++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 570c923023e6..1d923b8e4c59 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -388,7 +388,8 @@ static long dma_buf_ioctl(struct file *file,
 
 		return ret;
 
-	case DMA_BUF_SET_NAME:
+	case DMA_BUF_SET_NAME_A:
+	case DMA_BUF_SET_NAME_B:
 		return dma_buf_set_name(dmabuf, (const char __user *)arg);
 
 	default:
diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
index dbc7092e04b5..21dfac815dc0 100644
--- a/include/uapi/linux/dma-buf.h
+++ b/include/uapi/linux/dma-buf.h
@@ -39,6 +39,10 @@ struct dma_buf_sync {
 
 #define DMA_BUF_BASE		'b'
 #define DMA_BUF_IOCTL_SYNC	_IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
+/* 32/64bitness of this uapi was botched in android, there's no difference
+ * between them in actual uapi, they're just different numbers. */
 #define DMA_BUF_SET_NAME	_IOW(DMA_BUF_BASE, 1, const char *)
+#define DMA_BUF_SET_NAME_A	_IOW(DMA_BUF_BASE, 1, u32)
+#define DMA_BUF_SET_NAME_B	_IOW(DMA_BUF_BASE, 1, u64)
 
 #endif
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-buf: Fix SET_NAME ioctl uapi
  2020-04-07 13:30 [PATCH] dma-buf: Fix SET_NAME ioctl uapi Daniel Vetter
@ 2020-04-09  3:58 ` Sumit Semwal
  2020-04-23 14:51   ` Martin Liu
  0 siblings, 1 reply; 4+ messages in thread
From: Sumit Semwal @ 2020-04-09  3:58 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Chenbo Feng, Greg Hackmann, Linaro MM SIG, minchan, Jenhao Chen,
	DRI Development, Daniel Vetter, Martin Liu, Suren Baghdasaryan,
	open list:DMA BUFFER SHARING FRAMEWORK

Thanks for the patch, Daniel!


On Tue, 7 Apr 2020 at 19:00, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
>
> The uapi is the same on 32 and 64 bit, but the number isnt. Everyone
> who botched this please re-read:
>
> https://www.kernel.org/doc/html/v5.4-preprc-cpu/ioctl/botching-up-ioctls.html
>
> Also, the type argument for the ioctl macros is for the type the void
> __user *arg pointer points at, which in this case would be the
> variable-sized char[] of a 0 terminated string. So this was botched in
> more than just the usual ways.

Yes, it shouldn't have passed through the cracks; my apologies!

>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Chenbo Feng <fengc@google.com>
> Cc: Greg Hackmann <ghackmann@google.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: linux-media@vger.kernel.org
> Cc: linaro-mm-sig@lists.linaro.org
> Cc: minchan@kernel.org
> Cc: surenb@google.com
> Cc: jenhaochen@google.com
> Cc: Martin Liu <liumartin@google.com>

Martin,
Could I request you to test this one with the 4 combinations of 32-bit
/ 64-bit userspace and kernel, and let us know that all 4 are working
alright? If yes, please consider giving your tested-by here.

> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> ---
>  drivers/dma-buf/dma-buf.c    | 3 ++-
>  include/uapi/linux/dma-buf.h | 4 ++++
>  2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 570c923023e6..1d923b8e4c59 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -388,7 +388,8 @@ static long dma_buf_ioctl(struct file *file,
>
>                 return ret;
>
> -       case DMA_BUF_SET_NAME:
> +       case DMA_BUF_SET_NAME_A:
> +       case DMA_BUF_SET_NAME_B:
>                 return dma_buf_set_name(dmabuf, (const char __user *)arg);
>
>         default:
> diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
> index dbc7092e04b5..21dfac815dc0 100644
> --- a/include/uapi/linux/dma-buf.h
> +++ b/include/uapi/linux/dma-buf.h
> @@ -39,6 +39,10 @@ struct dma_buf_sync {
>
>  #define DMA_BUF_BASE           'b'
>  #define DMA_BUF_IOCTL_SYNC     _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
> +/* 32/64bitness of this uapi was botched in android, there's no difference
> + * between them in actual uapi, they're just different numbers. */
>  #define DMA_BUF_SET_NAME       _IOW(DMA_BUF_BASE, 1, const char *)
> +#define DMA_BUF_SET_NAME_A     _IOW(DMA_BUF_BASE, 1, u32)
> +#define DMA_BUF_SET_NAME_B     _IOW(DMA_BUF_BASE, 1, u64)
>
>  #endif
> --
> 2.25.1
>
Best,
Sumit.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-buf: Fix SET_NAME ioctl uapi
  2020-04-09  3:58 ` Sumit Semwal
@ 2020-04-23 14:51   ` Martin Liu
  2020-04-28 10:37     ` Sumit Semwal
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Liu @ 2020-04-23 14:51 UTC (permalink / raw)
  To: Sumit Semwal
  Cc: Todd Kjos, Daniel Vetter, Chenbo Feng, Greg Hackmann,
	Linaro MM SIG, minchan, Jenhao Chen, DRI Development,
	Daniel Vetter, Suren Baghdasaryan,
	open list:DMA BUFFER SHARING FRAMEWORK

On Thu, Apr 09, 2020 at 09:28:16AM +0530, Sumit Semwal wrote:
> Thanks for the patch, Daniel!
> 
> 
> On Tue, 7 Apr 2020 at 19:00, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> >
> > The uapi is the same on 32 and 64 bit, but the number isnt. Everyone
> > who botched this please re-read:
> >
> > https://www.kernel.org/doc/html/v5.4-preprc-cpu/ioctl/botching-up-ioctls.html
> >
> > Also, the type argument for the ioctl macros is for the type the void
> > __user *arg pointer points at, which in this case would be the
> > variable-sized char[] of a 0 terminated string. So this was botched in
> > more than just the usual ways.
> 
> Yes, it shouldn't have passed through the cracks; my apologies!
> 
> >
> > Cc: Sumit Semwal <sumit.semwal@linaro.org>
> > Cc: Chenbo Feng <fengc@google.com>
> > Cc: Greg Hackmann <ghackmann@google.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Cc: linux-media@vger.kernel.org
> > Cc: linaro-mm-sig@lists.linaro.org
> > Cc: minchan@kernel.org
> > Cc: surenb@google.com
> > Cc: jenhaochen@google.com
> > Cc: Martin Liu <liumartin@google.com>
> 
> Martin,
> Could I request you to test this one with the 4 combinations of 32-bit
> / 64-bit userspace and kernel, and let us know that all 4 are working
> alright? If yes, please consider giving your tested-by here.
>
Hi Sumit, Daniel,
Sorry for being late to the tests. I finished the tests on 32/64 apps
with 64 bit kernel and they were fine. Unfortunately, I couldn't have a 32
bit kernel to run the tests somehow. However, this should work from the
code logic. Hope this is okay to you and thanks for Todd's help.

Tested-by: Martin Liu <liumartin@google.com>
Reviewed-by: Martin Liu <liumartin@google.com>

> > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > ---
> >  drivers/dma-buf/dma-buf.c    | 3 ++-
> >  include/uapi/linux/dma-buf.h | 4 ++++
> >  2 files changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > index 570c923023e6..1d923b8e4c59 100644
> > --- a/drivers/dma-buf/dma-buf.c
> > +++ b/drivers/dma-buf/dma-buf.c
> > @@ -388,7 +388,8 @@ static long dma_buf_ioctl(struct file *file,
> >
> >                 return ret;
> >
> > -       case DMA_BUF_SET_NAME:
> > +       case DMA_BUF_SET_NAME_A:
> > +       case DMA_BUF_SET_NAME_B:
> >                 return dma_buf_set_name(dmabuf, (const char __user *)arg);
> >
> >         default:
> > diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
> > index dbc7092e04b5..21dfac815dc0 100644
> > --- a/include/uapi/linux/dma-buf.h
> > +++ b/include/uapi/linux/dma-buf.h
> > @@ -39,6 +39,10 @@ struct dma_buf_sync {
> >
> >  #define DMA_BUF_BASE           'b'
> >  #define DMA_BUF_IOCTL_SYNC     _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
> > +/* 32/64bitness of this uapi was botched in android, there's no difference
> > + * between them in actual uapi, they're just different numbers. */
> >  #define DMA_BUF_SET_NAME       _IOW(DMA_BUF_BASE, 1, const char *)
> > +#define DMA_BUF_SET_NAME_A     _IOW(DMA_BUF_BASE, 1, u32)
> > +#define DMA_BUF_SET_NAME_B     _IOW(DMA_BUF_BASE, 1, u64)
> >
> >  #endif
> > --
> > 2.25.1
> >
> Best,
> Sumit.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] dma-buf: Fix SET_NAME ioctl uapi
  2020-04-23 14:51   ` Martin Liu
@ 2020-04-28 10:37     ` Sumit Semwal
  0 siblings, 0 replies; 4+ messages in thread
From: Sumit Semwal @ 2020-04-28 10:37 UTC (permalink / raw)
  To: Martin Liu
  Cc: Todd Kjos, Daniel Vetter, Chenbo Feng, Greg Hackmann,
	Linaro MM SIG, minchan, Jenhao Chen, DRI Development,
	Daniel Vetter, Suren Baghdasaryan,
	open list:DMA BUFFER SHARING FRAMEWORK

Thanks Daniel, Martin,

On Thu, 23 Apr 2020 at 20:21, Martin Liu <liumartin@google.com> wrote:
>
> On Thu, Apr 09, 2020 at 09:28:16AM +0530, Sumit Semwal wrote:
> > Thanks for the patch, Daniel!
> >
> >
> > On Tue, 7 Apr 2020 at 19:00, Daniel Vetter <daniel.vetter@ffwll.ch> wrote:
> > >
> > > The uapi is the same on 32 and 64 bit, but the number isnt. Everyone
> > > who botched this please re-read:
> > >
> > > https://www.kernel.org/doc/html/v5.4-preprc-cpu/ioctl/botching-up-ioctls.html
> > >
> > > Also, the type argument for the ioctl macros is for the type the void
> > > __user *arg pointer points at, which in this case would be the
> > > variable-sized char[] of a 0 terminated string. So this was botched in
> > > more than just the usual ways.
> >
> > Yes, it shouldn't have passed through the cracks; my apologies!
> >
> > >
> > > Cc: Sumit Semwal <sumit.semwal@linaro.org>
> > > Cc: Chenbo Feng <fengc@google.com>
> > > Cc: Greg Hackmann <ghackmann@google.com>
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: linux-media@vger.kernel.org
> > > Cc: linaro-mm-sig@lists.linaro.org
> > > Cc: minchan@kernel.org
> > > Cc: surenb@google.com
> > > Cc: jenhaochen@google.com
> > > Cc: Martin Liu <liumartin@google.com>
> >
> > Martin,
> > Could I request you to test this one with the 4 combinations of 32-bit
> > / 64-bit userspace and kernel, and let us know that all 4 are working
> > alright? If yes, please consider giving your tested-by here.
> >
> Hi Sumit, Daniel,
> Sorry for being late to the tests. I finished the tests on 32/64 apps
> with 64 bit kernel and they were fine. Unfortunately, I couldn't have a 32
> bit kernel to run the tests somehow. However, this should work from the
> code logic. Hope this is okay to you and thanks for Todd's help.
>
> Tested-by: Martin Liu <liumartin@google.com>
> Reviewed-by: Martin Liu <liumartin@google.com>

Applied to drm-misc-fixes.
>
> > > Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
> > > ---
> > >  drivers/dma-buf/dma-buf.c    | 3 ++-
> > >  include/uapi/linux/dma-buf.h | 4 ++++
> > >  2 files changed, 6 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> > > index 570c923023e6..1d923b8e4c59 100644
> > > --- a/drivers/dma-buf/dma-buf.c
> > > +++ b/drivers/dma-buf/dma-buf.c
> > > @@ -388,7 +388,8 @@ static long dma_buf_ioctl(struct file *file,
> > >
> > >                 return ret;
> > >
> > > -       case DMA_BUF_SET_NAME:
> > > +       case DMA_BUF_SET_NAME_A:
> > > +       case DMA_BUF_SET_NAME_B:
> > >                 return dma_buf_set_name(dmabuf, (const char __user *)arg);
> > >
> > >         default:
> > > diff --git a/include/uapi/linux/dma-buf.h b/include/uapi/linux/dma-buf.h
> > > index dbc7092e04b5..21dfac815dc0 100644
> > > --- a/include/uapi/linux/dma-buf.h
> > > +++ b/include/uapi/linux/dma-buf.h
> > > @@ -39,6 +39,10 @@ struct dma_buf_sync {
> > >
> > >  #define DMA_BUF_BASE           'b'
> > >  #define DMA_BUF_IOCTL_SYNC     _IOW(DMA_BUF_BASE, 0, struct dma_buf_sync)
> > > +/* 32/64bitness of this uapi was botched in android, there's no difference
> > > + * between them in actual uapi, they're just different numbers. */
> > >  #define DMA_BUF_SET_NAME       _IOW(DMA_BUF_BASE, 1, const char *)
> > > +#define DMA_BUF_SET_NAME_A     _IOW(DMA_BUF_BASE, 1, u32)
> > > +#define DMA_BUF_SET_NAME_B     _IOW(DMA_BUF_BASE, 1, u64)
> > >
> > >  #endif
> > > --
> > > 2.25.1
> > >
> > Best,
> > Sumit.
Best,
Sumit.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-28 10:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07 13:30 [PATCH] dma-buf: Fix SET_NAME ioctl uapi Daniel Vetter
2020-04-09  3:58 ` Sumit Semwal
2020-04-23 14:51   ` Martin Liu
2020-04-28 10:37     ` Sumit Semwal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).