All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages()
@ 2026-06-30  8:01 Christian König
  2026-06-30  8:03 ` sashiko-bot
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Christian König @ 2026-06-30  8:01 UTC (permalink / raw)
  To: sumit.semwal, linux-media, dri-devel, linaro-mm-sig, lizhi.hou,
	Max.Zhen, Mario.Limonciello, airlied, karol.wachowski
  Cc: Christian König

We recently had another incident where two drivers put pages they got from
get_user_pages() into a DMA-buf and cause quite a number of problems.

Explicitely document that this is not something exporters can do.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/dma-buf/dma-buf.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 71f37544a5c6..aa5af4f439c2 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -685,6 +685,14 @@ static struct file *dma_buf_getfile(size_t size, int flags)
  *
  * For the detailed semantics exporters are expected to implement see
  * &dma_buf_ops.
+ *
+ * It is explicitely forbidden for exporters to expose buffers they don't "own"
+ * as DMA-buf. This includes pages acquired by get_user_pages() or other import
+ * mechanism. Not following this rule can create numerous security problems.
+ *
+ * It is also strongly discouraged to expose the same backing store through
+ * multiple DMA-bufs at the same time. This eventually creates aliasing and
+ * cache coherency problems which are extremely hard to debug and fix.
  */
 
 /**
-- 
2.43.0


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

* Re: [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages()
  2026-06-30  8:01 [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages() Christian König
@ 2026-06-30  8:03 ` sashiko-bot
  2026-06-30 13:42 ` Mario Limonciello
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: sashiko-bot @ 2026-06-30  8:03 UTC (permalink / raw)
  To: Christian König; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Misspelling of the word 'explicitly' as 'explicitely' in both the commit message and the newly added source code comments. Additionally, 'import mechanism' is slightly awkward grammatically and would read better as 'import mechanisms'.
--

commit d403e672a4ce196480792c8a6cdd1c4a2ffcf542
Author: Christian König <ckoenig.leichtzumerken@gmail.com>

dma-buf: explicitely forbid exposing pages from get_user_pages()

This commit documents that DMA-buf exporters are forbidden from exposing
pages they do not own, such as those acquired by get_user_pages(). It also
discourages exposing the same backing store through multiple DMA-bufs to
avoid aliasing and cache coherency problems.

> dma-buf: explicitely forbid exposing pages from get_user_pages()

[Severity: Low]
This isn't a bug, but there is a typo (explicitely) in the subject line.

> Explicitely document that this is not something exporters can do.

[Severity: Low]
This isn't a bug, but there is a typo (Explicitely) in the commit message.

> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index d504c636dc294..b2efc3085e6d6 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -685,6 +685,14 @@ static struct file *dma_buf_getfile(size_t size, int flags)
>   *
>   * For the detailed semantics exporters are expected to implement see
>   * &dma_buf_ops.
> + *
> + * It is explicitely forbidden for exporters to expose buffers they don't "own"
> + * as DMA-buf. This includes pages acquired by get_user_pages() or other import
> + * mechanism. Not following this rule can create numerous security problems.

[Severity: Low]
This isn't a bug, but there is a typo (explicitely) in the new comment.
Additionally, would it read better to use the plural "mechanisms" here
instead of "mechanism"?

> + *
> + * It is also strongly discouraged to expose the same backing store through
> + * multiple DMA-bufs at the same time. This eventually creates aliasing and
> + * cache coherency problems which are extremely hard to debug and fix.
>   */

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260630080112.1117341-1-christian.koenig@amd.com?part=1

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

* Re: [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages()
  2026-06-30  8:01 [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages() Christian König
  2026-06-30  8:03 ` sashiko-bot
@ 2026-06-30 13:42 ` Mario Limonciello
  2026-07-07  9:06 ` Christian König
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2026-06-30 13:42 UTC (permalink / raw)
  To: Christian König, sumit.semwal, linux-media, dri-devel,
	linaro-mm-sig, lizhi.hou, Max.Zhen, airlied, karol.wachowski
  Cc: Christian König



On 6/30/26 03:01, Christian König wrote:
> We recently had another incident where two drivers put pages they got from
> get_user_pages() into a DMA-buf and cause quite a number of problems.
> 
> Explicitely document that this is not something exporters can do.

I think it would be a good idea to send this up to 
https://github.com/masoncl/review-prompts/blob/main/kernel/subsystem/drm.md 
as well.

That's what Sashiko uses and it will help flag this in case it happens 
in future.

> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/dma-buf/dma-buf.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 71f37544a5c6..aa5af4f439c2 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -685,6 +685,14 @@ static struct file *dma_buf_getfile(size_t size, int flags)
>    *
>    * For the detailed semantics exporters are expected to implement see
>    * &dma_buf_ops.
> + *
> + * It is explicitely forbidden for exporters to expose buffers they don't "own"
> + * as DMA-buf. This includes pages acquired by get_user_pages() or other import
> + * mechanism. Not following this rule can create numerous security problems.
> + *
> + * It is also strongly discouraged to expose the same backing store through
> + * multiple DMA-bufs at the same time. This eventually creates aliasing and
> + * cache coherency problems which are extremely hard to debug and fix.
>    */
>   
>   /**


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

* Re: [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages()
  2026-06-30  8:01 [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages() Christian König
  2026-06-30  8:03 ` sashiko-bot
  2026-06-30 13:42 ` Mario Limonciello
@ 2026-07-07  9:06 ` Christian König
  2026-07-07 15:41 ` Max Zhen
  2026-07-07 16:54 ` Lizhi Hou
  4 siblings, 0 replies; 6+ messages in thread
From: Christian König @ 2026-07-07  9:06 UTC (permalink / raw)
  To: Christian König, sumit.semwal, linux-media, dri-devel,
	linaro-mm-sig, lizhi.hou, Max.Zhen, Mario.Limonciello, airlied,
	karol.wachowski, Simona Vetter

Gentle ping.

Apart from the spelling mistakes Sashiko already pointed out, any comments on that?

Regards,
Christian.

On 6/30/26 10:01, Christian König wrote:
> We recently had another incident where two drivers put pages they got from
> get_user_pages() into a DMA-buf and cause quite a number of problems.
> 
> Explicitely document that this is not something exporters can do.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>  drivers/dma-buf/dma-buf.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 71f37544a5c6..aa5af4f439c2 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -685,6 +685,14 @@ static struct file *dma_buf_getfile(size_t size, int flags)
>   *
>   * For the detailed semantics exporters are expected to implement see
>   * &dma_buf_ops.
> + *
> + * It is explicitely forbidden for exporters to expose buffers they don't "own"
> + * as DMA-buf. This includes pages acquired by get_user_pages() or other import
> + * mechanism. Not following this rule can create numerous security problems.
> + *
> + * It is also strongly discouraged to expose the same backing store through
> + * multiple DMA-bufs at the same time. This eventually creates aliasing and
> + * cache coherency problems which are extremely hard to debug and fix.
>   */
>  
>  /**


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

* Re: [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages()
  2026-06-30  8:01 [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages() Christian König
                   ` (2 preceding siblings ...)
  2026-07-07  9:06 ` Christian König
@ 2026-07-07 15:41 ` Max Zhen
  2026-07-07 16:54 ` Lizhi Hou
  4 siblings, 0 replies; 6+ messages in thread
From: Max Zhen @ 2026-07-07 15:41 UTC (permalink / raw)
  To: Christian König, sumit.semwal, linux-media, dri-devel,
	linaro-mm-sig, lizhi.hou, Mario.Limonciello, airlied,
	karol.wachowski
  Cc: Christian König



On 6/30/2026 Tue 01:01, Christian König wrote:
> We recently had another incident where two drivers put pages they got from
> get_user_pages() into a DMA-buf and cause quite a number of problems.
> 
> Explicitely document that this is not something exporters can do.
> 
> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Max Zhen <max.zhen@amd.com>
> ---
>   drivers/dma-buf/dma-buf.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 71f37544a5c6..aa5af4f439c2 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -685,6 +685,14 @@ static struct file *dma_buf_getfile(size_t size, int flags)
>    *
>    * For the detailed semantics exporters are expected to implement see
>    * &dma_buf_ops.
> + *
> + * It is explicitely forbidden for exporters to expose buffers they don't "own"
> + * as DMA-buf. This includes pages acquired by get_user_pages() or other import
> + * mechanism. Not following this rule can create numerous security problems.
> + *
> + * It is also strongly discouraged to expose the same backing store through
> + * multiple DMA-bufs at the same time. This eventually creates aliasing and
> + * cache coherency problems which are extremely hard to debug and fix.
>    */
>   
>   /**


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

* Re: [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages()
  2026-06-30  8:01 [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages() Christian König
                   ` (3 preceding siblings ...)
  2026-07-07 15:41 ` Max Zhen
@ 2026-07-07 16:54 ` Lizhi Hou
  4 siblings, 0 replies; 6+ messages in thread
From: Lizhi Hou @ 2026-07-07 16:54 UTC (permalink / raw)
  To: Christian König, sumit.semwal, linux-media, dri-devel,
	linaro-mm-sig, Max.Zhen, Mario.Limonciello, airlied,
	karol.wachowski
  Cc: Christian König


On 6/30/26 01:01, Christian König wrote:
> We recently had another incident where two drivers put pages they got from
> get_user_pages() into a DMA-buf and cause quite a number of problems.
>
> Explicitely document that this is not something exporters can do.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
>   drivers/dma-buf/dma-buf.c | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 71f37544a5c6..aa5af4f439c2 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -685,6 +685,14 @@ static struct file *dma_buf_getfile(size_t size, int flags)
>    *
>    * For the detailed semantics exporters are expected to implement see
>    * &dma_buf_ops.
> + *
> + * It is explicitely forbidden for exporters to expose buffers they don't "own"
> + * as DMA-buf. This includes pages acquired by get_user_pages() or other import
> + * mechanism. Not following this rule can create numerous security problems.
> + *
> + * It is also strongly discouraged to expose the same backing store through
> + * multiple DMA-bufs at the same time. This eventually creates aliasing and
> + * cache coherency problems which are extremely hard to debug and fix.
>    */
Reviewed-by: Lizhi Hou <lizhi.hou@amd.com>
>   
>   /**

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

end of thread, other threads:[~2026-07-07 16:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30  8:01 [PATCH] dma-buf: explicitely forbid exposing pages from get_user_pages() Christian König
2026-06-30  8:03 ` sashiko-bot
2026-06-30 13:42 ` Mario Limonciello
2026-07-07  9:06 ` Christian König
2026-07-07 15:41 ` Max Zhen
2026-07-07 16:54 ` Lizhi Hou

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.