Skip to contentSkip to conversation

xen/gntdev: Do not destroy context while dma-bufs are in use

PATCH Applied Oleksandr Andrushchenko 3 participants 19 messages Feb 14, 2019 – Feb 17, 2019 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 xen/gntdev: Do not destroy context while dma-bufs are in use

From: Oleksandr Andrushchenko <[email protected]>

If there are exported DMA buffers which are still in use and grant device is closed by either normal user-space close or by a signal this leads to the grant device context to be destroyed, thus making it not possible to correctly destroy those exported buffers when they are returned back to gntdev and makes the module crash:

[  339.617540] [<ffff00000854c0d8>] dmabuf_exp_ops_release+0x40/0xa8
[  339.617560] [<ffff00000867a6e8>] dma_buf_release+0x60/0x190
[  339.617577] [<ffff0000082211f0>] __fput+0x88/0x1d0
[  339.617589] [<ffff000008221394>] ____fput+0xc/0x18
[  339.617607] [<ffff0000080ed4e4>] task_work_run+0x9c/0xc0
[  339.617622] [<ffff000008089714>] do_notify_resume+0xfc/0x108

Fix this by referencing gntdev on each DMA buffer export and unreferencing on buffer release.

---
 drivers/xen/gntdev-dmabuf.c | 12 +++++++++++-
 drivers/xen/gntdev-dmabuf.h |  2 +-
 drivers/xen/gntdev.c        |  2 +-
 3 files changed, 13 insertions(+), 3 deletions(-)
drivers/xen/gntdev-dmabuf.c +11 -1
index cba6b586bfbd..d97fcfc5e558 100644
@@ -80,6 +80,12 @@ struct gntdev_dmabuf_priv {
 	struct list_head imp_list;
 	/* This is the lock which protects dma_buf_xxx lists. */
 	struct mutex lock;
+	/*
+	 * We reference this file while exporting dma-bufs, so
+	 * the grant device context is not destroyed while there are
+	 * external users alive.
+	 */
+	struct file *filp;
 };
 
 /* DMA buffer export support. */
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
 
 	dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
 	list_del(&gntdev_dmabuf->next);
+	fput(gntdev_dmabuf->priv->filp);
 	kfree(gntdev_dmabuf);
 }
 
@@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
 	mutex_lock(&args->dmabuf_priv->lock);
 	list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
 	mutex_unlock(&args->dmabuf_priv->lock);
+	get_file(gntdev_dmabuf->priv->filp);
 	return 0;
 
 fail:
@@ -834,7 +842,7 @@ long gntdev_ioctl_dmabuf_imp_release(struct gntdev_priv *priv,
 	return dmabuf_imp_release(priv->dmabuf_priv, op.fd);
 }
 
-struct gntdev_dmabuf_priv *gntdev_dmabuf_init(void)
+struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp)
 {
 	struct gntdev_dmabuf_priv *priv;
 
@@ -847,6 +855,8 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(void)
 	INIT_LIST_HEAD(&priv->exp_wait_list);
 	INIT_LIST_HEAD(&priv->imp_list);
 
+	priv->filp = filp;
+
 	return priv;
 }
 
drivers/xen/gntdev-dmabuf.h +1 -1
index 7220a53d0fc5..3d9b9cf9d5a1 100644
@@ -14,7 +14,7 @@
 struct gntdev_dmabuf_priv;
 struct gntdev_priv;
 
-struct gntdev_dmabuf_priv *gntdev_dmabuf_init(void);
+struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp);
 
 void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv);
 
drivers/xen/gntdev.c +1 -1
index b0b02a501167..9d8e02cfd480 100644
@@ -600,7 +600,7 @@ static int gntdev_open(struct inode *inode, struct file *flip)
 	mutex_init(&priv->lock);
 
 #ifdef CONFIG_XEN_GNTDEV_DMABUF
-	priv->dmabuf_priv = gntdev_dmabuf_init();
+	priv->dmabuf_priv = gntdev_dmabuf_init(flip);
 	if (IS_ERR(priv->dmabuf_priv)) {
 		ret = PTR_ERR(priv->dmabuf_priv);
 		kfree(priv);
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 xen/gntdev: Check and release imported dma-bufs on close

From: Oleksandr Andrushchenko <[email protected]>

Check if there are any imported dma-bufs left not released by user-space when grant device's release callback is called and free those if this is the case. This can happen if user-space leaks the buffers because of a bug or application has been terminated for any reason.

---
 drivers/xen/gntdev-dmabuf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/xen/gntdev-dmabuf.c +9 -0
index d97fcfc5e558..2c4f324f8626 100644
@@ -745,6 +745,14 @@ static int dmabuf_imp_release(struct gntdev_dmabuf_priv *priv, u32 fd)
 	return 0;
 }
 
+static void dmabuf_imp_release_all(struct gntdev_dmabuf_priv *priv)
+{
+	struct gntdev_dmabuf *q, *gntdev_dmabuf;
+
+	list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next)
+		dmabuf_imp_release(priv, gntdev_dmabuf->fd);
+}
+
 /* DMA buffer IOCTL support. */
 
 long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
@@ -862,5 +870,6 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp)
 
 void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv)
 {
+	dmabuf_imp_release_all(priv);
 	kfree(priv);
 }
Signature · 7 lines
2.20.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw

PATCH 2/2 xen/gntdev: Check and release imported dma-bufs on close

In reply to Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Check if there are any imported dma-bufs left not released by user-space when grant device's release callback is called and free those if this is the case. This can happen if user-space leaks the buffers because of a bug or application has been terminated for any reason.

---
 drivers/xen/gntdev-dmabuf.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/xen/gntdev-dmabuf.c +9 -0
index d97fcfc5e558..2c4f324f8626 100644
@@ -745,6 +745,14 @@ static int dmabuf_imp_release(struct gntdev_dmabuf_priv *priv, u32 fd)
 	return 0;
 }
 
+static void dmabuf_imp_release_all(struct gntdev_dmabuf_priv *priv)
+{
+	struct gntdev_dmabuf *q, *gntdev_dmabuf;
+
+	list_for_each_entry_safe(gntdev_dmabuf, q, &priv->imp_list, next)
+		dmabuf_imp_release(priv, gntdev_dmabuf->fd);
+}
+
 /* DMA buffer IOCTL support. */
 
 long gntdev_ioctl_dmabuf_exp_from_refs(struct gntdev_priv *priv, int use_ptemod,
@@ -862,5 +870,6 @@ struct gntdev_dmabuf_priv *gntdev_dmabuf_init(struct file *filp)
 
 void gntdev_dmabuf_fini(struct gntdev_dmabuf_priv *priv)
 {
+	dmabuf_imp_release_all(priv);
 	kfree(priv);
 }
Signature · 1 line
2.20.1
Reviewed-by Boris on v1 2/2
#3 lore raw

Re: [PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close

Quoted 9 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Check if there are any imported dma-bufs left not released by user-space when grant device's release callback is called and free those if this is the case. This can happen if user-space leaks the buffers because of a bug or application has been terminated for any reason.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by Boris on v1 2/2
#4 lore raw

Re: [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close

In reply to Oleksandr Andrushchenko
Quoted 9 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Check if there are any imported dma-bufs left not released by user-space when grant device's release callback is called and free those if this is the case. This can happen if user-space leaks the buffers because of a bug or application has been terminated for any reason.

maintainer
#5 lore raw

Re: [PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close

In reply to Oleksandr Andrushchenko
Quoted 9 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Check if there are any imported dma-bufs left not released by user-space when grant device's release callback is called and free those if this is the case. This can happen if user-space leaks the buffers because of a bug or application has been terminated for any reason.

Applied-to: xen/tip.git for-linus-5.1

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer
#6 lore raw

Re: [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close

In reply to Oleksandr Andrushchenko
Quoted 9 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

Check if there are any imported dma-bufs left not released by user-space when grant device's release callback is called and free those if this is the case. This can happen if user-space leaks the buffers because of a bug or application has been terminated for any reason.

Applied-to: xen/tip.git for-linus-5.1

Juergen

#7 lore raw
In reply to Oleksandr Andrushchenko
Quoted 11 lines · Oleksandr Andrushchenko

/* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
 
 	dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
 	list_del(&gntdev_dmabuf->next);
+	fput(gntdev_dmabuf->priv->filp);
 	kfree(gntdev_dmabuf);
 }
 

drivers/xen/gntdev-dmabuf.c static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) · line 433

Quoted 4 lines
drivers/xen/gntdev-dmabuf.c +1 -0
@@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
 	mutex_lock(&args->dmabuf_priv->lock);
 	list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
 	mutex_unlock(&args->dmabuf_priv->lock);
+	get_file(gntdev_dmabuf->priv->filp);

Not fget()?

-boris

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#8 lore raw
In reply to Oleksandr Andrushchenko
Quoted 11 lines · Oleksandr Andrushchenko

/* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
 
 	dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
 	list_del(&gntdev_dmabuf->next);
+	fput(gntdev_dmabuf->priv->filp);
 	kfree(gntdev_dmabuf);
 }
 

drivers/xen/gntdev-dmabuf.c static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) · line 433

Quoted 4 lines
drivers/xen/gntdev-dmabuf.c +1 -0
@@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
 	mutex_lock(&args->dmabuf_priv->lock);
 	list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
 	mutex_unlock(&args->dmabuf_priv->lock);
+	get_file(gntdev_dmabuf->priv->filp);

Not fget()?

-boris

#9 lore raw
Quoted 11 lines · Boris Ostrovsky
Quoted 10 lines · Oleksandr Andrushchenko

/* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
 
  	dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
  	list_del(&gntdev_dmabuf->next);
+	fput(gntdev_dmabuf->priv->filp);
  	kfree(gntdev_dmabuf);
  }
 
Quoted 6 lines

drivers/xen/gntdev-dmabuf.c static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) · line 433

Quoted 5 lines
drivers/xen/gntdev-dmabuf.c +1 -0
@@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
  	mutex_lock(&args->dmabuf_priv->lock);
  	list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
  	mutex_unlock(&args->dmabuf_priv->lock);
+	get_file(gntdev_dmabuf->priv->filp);

Not fget()?

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

Quoted 4 lines

-boris

[1] https://elixir.bootlin.com/linux/v5.0-rc6/source/include/linux/file.h#L46
[2] https://elixir.bootlin.com/linux/v5.0-rc6/source/include/linux/fs.h#L949

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#10 lore raw
In reply to Boris Ostrovsky
Quoted 11 lines · Boris Ostrovsky
Quoted 10 lines · Oleksandr Andrushchenko

/* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
 
  	dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
  	list_del(&gntdev_dmabuf->next);
+	fput(gntdev_dmabuf->priv->filp);
  	kfree(gntdev_dmabuf);
  }
 
Quoted 6 lines

drivers/xen/gntdev-dmabuf.c static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) · line 433

Quoted 5 lines
drivers/xen/gntdev-dmabuf.c +1 -0
@@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args)
  	mutex_lock(&args->dmabuf_priv->lock);
  	list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list);
  	mutex_unlock(&args->dmabuf_priv->lock);
+	get_file(gntdev_dmabuf->priv->filp);

Not fget()?

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

Quoted 4 lines

-boris

[1] https://elixir.bootlin.com/linux/v5.0-rc6/source/include/linux/file.h#L46
[2] https://elixir.bootlin.com/linux/v5.0-rc6/source/include/linux/fs.h#L949

Reviewed-by
#11 lore raw
Quoted 16 lines · Oleksandr Andrushchenko
Quoted 15 lines · Boris Ostrovsky
Quoted 7 lines · Oleksandr Andrushchenko

    /* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
         dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
       list_del(&gntdev_dmabuf->next);
+    fput(gntdev_dmabuf->priv->filp);
       kfree(gntdev_dmabuf);
   }
Quoted 6 lines

  @@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) mutex_lock(&args->dmabuf_priv->lock); list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list); mutex_unlock(&args->dmabuf_priv->lock);
+    get_file(gntdev_dmabuf->priv->filp);

Not fget()?

Quoted 4 lines

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by
#12 lore raw
In reply to Oleksandr Andrushchenko
Quoted 16 lines · Oleksandr Andrushchenko
Quoted 15 lines · Boris Ostrovsky
Quoted 7 lines · Oleksandr Andrushchenko

    /* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
         dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
       list_del(&gntdev_dmabuf->next);
+    fput(gntdev_dmabuf->priv->filp);
       kfree(gntdev_dmabuf);
   }
Quoted 6 lines

  @@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) mutex_lock(&args->dmabuf_priv->lock); list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list); mutex_unlock(&args->dmabuf_priv->lock);
+    get_file(gntdev_dmabuf->priv->filp);

Not fget()?

Quoted 4 lines

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

#13 lore raw
Quoted 17 lines · Boris Ostrovsky
Quoted 16 lines · Oleksandr Andrushchenko
Quoted 15 lines · Boris Ostrovsky
Quoted 9 lines · Oleksandr Andrushchenko

    /* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
         dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
       list_del(&gntdev_dmabuf->next);
+    fput(gntdev_dmabuf->priv->filp);
       kfree(gntdev_dmabuf);
   }
   @@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct
 gntdev_dmabuf_export_args *args)
Quoted 4 lines

      mutex_lock(&args->dmabuf_priv->lock); list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list); mutex_unlock(&args->dmabuf_priv->lock);
+    get_file(gntdev_dmabuf->priv->filp);

Not fget()?

Quoted 6 lines
Quoted 4 lines

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

Thank you,
any chance we can get this for 5.1?

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

#14 lore raw
In reply to Boris Ostrovsky
Quoted 17 lines · Boris Ostrovsky
Quoted 16 lines · Oleksandr Andrushchenko
Quoted 15 lines · Boris Ostrovsky
Quoted 9 lines · Oleksandr Andrushchenko

    /* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
         dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv, gntdev_dmabuf);
       list_del(&gntdev_dmabuf->next);
+    fput(gntdev_dmabuf->priv->filp);
       kfree(gntdev_dmabuf);
   }
   @@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct
 gntdev_dmabuf_export_args *args)
Quoted 4 lines

      mutex_lock(&args->dmabuf_priv->lock); list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list); mutex_unlock(&args->dmabuf_priv->lock);
+    get_file(gntdev_dmabuf->priv->filp);

Not fget()?

Quoted 6 lines
Quoted 4 lines

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

Thank you,
any chance we can get this for 5.1?

maintainer
#15 lore raw
Quoted 19 lines · Oleksandr Andrushchenko
Quoted 18 lines · Boris Ostrovsky
Quoted 17 lines · Oleksandr Andrushchenko
Quoted 16 lines · Boris Ostrovsky
Quoted 8 lines · Oleksandr Andrushchenko

     /* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
          dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv,
 gntdev_dmabuf);
        list_del(&gntdev_dmabuf->next);
+    fput(gntdev_dmabuf->priv->filp);
        kfree(gntdev_dmabuf);
    }
Quoted 6 lines

   @@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) mutex_lock(&args->dmabuf_priv->lock); list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list); mutex_unlock(&args->dmabuf_priv->lock);
+    get_file(gntdev_dmabuf->priv->filp);

Not fget()?

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

Thank you,
any chance we can get this for 5.1?

Yes.

Juergen

maintainer
#16 lore raw
In reply to Oleksandr Andrushchenko
Quoted 19 lines · Oleksandr Andrushchenko
Quoted 18 lines · Boris Ostrovsky
Quoted 17 lines · Oleksandr Andrushchenko
Quoted 16 lines · Boris Ostrovsky
Quoted 8 lines · Oleksandr Andrushchenko

     /* DMA buffer export support. */

drivers/xen/gntdev-dmabuf.c +1 -0
@@ -311,6 +317,7 @@ static void dmabuf_exp_release(struct kref *kref)
          dmabuf_exp_wait_obj_signal(gntdev_dmabuf->priv,
 gntdev_dmabuf);
        list_del(&gntdev_dmabuf->next);
+    fput(gntdev_dmabuf->priv->filp);
        kfree(gntdev_dmabuf);
    }
Quoted 6 lines

   @@ -423,6 +430,7 @@ static int dmabuf_exp_from_pages(struct gntdev_dmabuf_export_args *args) mutex_lock(&args->dmabuf_priv->lock); list_add(&gntdev_dmabuf->next, &args->dmabuf_priv->exp_list); mutex_unlock(&args->dmabuf_priv->lock);
+    get_file(gntdev_dmabuf->priv->filp);

Not fget()?

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

fget wants file descriptor [1] and returns struct file *, but we already have struct file*, so I use get_file [2] which does what I need - increments the reference counter on the file

Thank you,
any chance we can get this for 5.1?

Yes.

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer Applied
#17 lore raw
In reply to Oleksandr Andrushchenko
Quoted 16 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

If there are exported DMA buffers which are still in use and grant device is closed by either normal user-space close or by a signal this leads to the grant device context to be destroyed, thus making it not possible to correctly destroy those exported buffers when they are returned back to gntdev and makes the module crash:

[  339.617540] [<ffff00000854c0d8>] dmabuf_exp_ops_release+0x40/0xa8
[  339.617560] [<ffff00000867a6e8>] dma_buf_release+0x60/0x190
[  339.617577] [<ffff0000082211f0>] __fput+0x88/0x1d0
[  339.617589] [<ffff000008221394>] ____fput+0xc/0x18
[  339.617607] [<ffff0000080ed4e4>] task_work_run+0x9c/0xc0
[  339.617622] [<ffff000008089714>] do_notify_resume+0xfc/0x108
Quoted 4 lines

Fix this by referencing gntdev on each DMA buffer export and unreferencing on buffer release.

Applied to xen/tip.git for-linus-5.1

Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer Applied
#18 lore raw
In reply to Oleksandr Andrushchenko
Quoted 16 lines · Oleksandr Andrushchenko

From: Oleksandr Andrushchenko <[email protected]>

If there are exported DMA buffers which are still in use and grant device is closed by either normal user-space close or by a signal this leads to the grant device context to be destroyed, thus making it not possible to correctly destroy those exported buffers when they are returned back to gntdev and makes the module crash:

[  339.617540] [<ffff00000854c0d8>] dmabuf_exp_ops_release+0x40/0xa8
[  339.617560] [<ffff00000867a6e8>] dma_buf_release+0x60/0x190
[  339.617577] [<ffff0000082211f0>] __fput+0x88/0x1d0
[  339.617589] [<ffff000008221394>] ____fput+0xc/0x18
[  339.617607] [<ffff0000080ed4e4>] task_work_run+0x9c/0xc0
[  339.617622] [<ffff000008089714>] do_notify_resume+0xfc/0x108
Quoted 4 lines

Fix this by referencing gntdev on each DMA buffer export and unreferencing on buffer release.

Applied to xen/tip.git for-linus-5.1

Juergen