* [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close
2019-02-14 14:23 [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Oleksandr Andrushchenko
@ 2019-02-14 14:23 ` Oleksandr Andrushchenko
2019-02-15 15:06 ` [PATCH " Boris Ostrovsky
` (3 more replies)
2019-02-14 14:23 ` [PATCH " Oleksandr Andrushchenko
` (4 subsequent siblings)
5 siblings, 4 replies; 19+ messages in thread
From: Oleksandr Andrushchenko @ 2019-02-14 14:23 UTC (permalink / raw)
To: xen-devel, linux-kernel, jgross, boris.ostrovsky
Cc: andr2000, Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
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.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
drivers/xen/gntdev-dmabuf.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
index d97fcfc5e558..2c4f324f8626 100644
--- a/drivers/xen/gntdev-dmabuf.c
+++ b/drivers/xen/gntdev-dmabuf.c
@@ -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);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close
2019-02-14 14:23 ` [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close Oleksandr Andrushchenko
@ 2019-02-15 15:06 ` Boris Ostrovsky
2019-02-15 15:06 ` [Xen-devel][PATCH " Boris Ostrovsky
` (2 subsequent siblings)
3 siblings, 0 replies; 19+ messages in thread
From: Boris Ostrovsky @ 2019-02-15 15:06 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, jgross
Cc: Oleksandr Andrushchenko
On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Boris Ostrovsky@oracle.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close
2019-02-14 14:23 ` [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close Oleksandr Andrushchenko
2019-02-15 15:06 ` [PATCH " Boris Ostrovsky
@ 2019-02-15 15:06 ` Boris Ostrovsky
2019-02-17 10:40 ` [PATCH " Juergen Gross
2019-02-17 10:40 ` [Xen-devel][PATCH " Juergen Gross
3 siblings, 0 replies; 19+ messages in thread
From: Boris Ostrovsky @ 2019-02-15 15:06 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, jgross
Cc: Oleksandr Andrushchenko
On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Reviewed-by: Boris Ostrovsky@oracle.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close
2019-02-14 14:23 ` [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close Oleksandr Andrushchenko
2019-02-15 15:06 ` [PATCH " Boris Ostrovsky
2019-02-15 15:06 ` [Xen-devel][PATCH " Boris Ostrovsky
@ 2019-02-17 10:40 ` Juergen Gross
2019-02-17 10:40 ` [Xen-devel][PATCH " Juergen Gross
3 siblings, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2019-02-17 10:40 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, boris.ostrovsky
Cc: Oleksandr Andrushchenko
On 14/02/2019 15:23, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Applied-to: xen/tip.git for-linus-5.1
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close
2019-02-14 14:23 ` [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close Oleksandr Andrushchenko
` (2 preceding siblings ...)
2019-02-17 10:40 ` [PATCH " Juergen Gross
@ 2019-02-17 10:40 ` Juergen Gross
3 siblings, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2019-02-17 10:40 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, boris.ostrovsky
Cc: Oleksandr Andrushchenko
On 14/02/2019 15:23, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Applied-to: xen/tip.git for-linus-5.1
Juergen
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close
2019-02-14 14:23 [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Oleksandr Andrushchenko
2019-02-14 14:23 ` [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close Oleksandr Andrushchenko
@ 2019-02-14 14:23 ` Oleksandr Andrushchenko
2019-02-15 15:03 ` [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Boris Ostrovsky
` (3 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Oleksandr Andrushchenko @ 2019-02-14 14:23 UTC (permalink / raw)
To: xen-devel, linux-kernel, jgross, boris.ostrovsky
Cc: andr2000, Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
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.
Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
---
drivers/xen/gntdev-dmabuf.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/xen/gntdev-dmabuf.c b/drivers/xen/gntdev-dmabuf.c
index d97fcfc5e558..2c4f324f8626 100644
--- a/drivers/xen/gntdev-dmabuf.c
+++ b/drivers/xen/gntdev-dmabuf.c
@@ -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);
}
--
2.20.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 19+ messages in thread* Re: [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-14 14:23 [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Oleksandr Andrushchenko
2019-02-14 14:23 ` [Xen-devel][PATCH 2/2] xen/gntdev: Check and release imported dma-bufs on close Oleksandr Andrushchenko
2019-02-14 14:23 ` [PATCH " Oleksandr Andrushchenko
@ 2019-02-15 15:03 ` Boris Ostrovsky
2019-02-15 15:03 ` [Xen-devel][PATCH " Boris Ostrovsky
` (2 subsequent siblings)
5 siblings, 0 replies; 19+ messages in thread
From: Boris Ostrovsky @ 2019-02-15 15:03 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, jgross
Cc: Oleksandr Andrushchenko
On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>
> /* 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);
Not fget()?
-boris
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-14 14:23 [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Oleksandr Andrushchenko
` (2 preceding siblings ...)
2019-02-15 15:03 ` [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Boris Ostrovsky
@ 2019-02-15 15:03 ` Boris Ostrovsky
2019-02-15 15:07 ` [PATCH " Oleksandr Andrushchenko
2019-02-15 15:07 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
2019-02-17 10:39 ` [Xen-devel][PATCH " Juergen Gross
2019-02-17 10:39 ` [PATCH " Juergen Gross
5 siblings, 2 replies; 19+ messages in thread
From: Boris Ostrovsky @ 2019-02-15 15:03 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, jgross
Cc: Oleksandr Andrushchenko
On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>
> /* 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);
Not fget()?
-boris
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:03 ` [Xen-devel][PATCH " Boris Ostrovsky
@ 2019-02-15 15:07 ` Oleksandr Andrushchenko
2019-02-15 15:07 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
1 sibling, 0 replies; 19+ messages in thread
From: Oleksandr Andrushchenko @ 2019-02-15 15:07 UTC (permalink / raw)
To: Boris Ostrovsky, xen-devel, linux-kernel, jgross; +Cc: Oleksandr Andrushchenko
On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>
>> /* 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);
> 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
>
> -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
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:03 ` [Xen-devel][PATCH " Boris Ostrovsky
2019-02-15 15:07 ` [PATCH " Oleksandr Andrushchenko
@ 2019-02-15 15:07 ` Oleksandr Andrushchenko
2019-02-15 15:28 ` [PATCH " Boris Ostrovsky
2019-02-15 15:28 ` [Xen-devel][PATCH " Boris Ostrovsky
1 sibling, 2 replies; 19+ messages in thread
From: Oleksandr Andrushchenko @ 2019-02-15 15:07 UTC (permalink / raw)
To: Boris Ostrovsky, xen-devel, linux-kernel, jgross; +Cc: Oleksandr Andrushchenko
On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>
>> /* 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);
> 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
>
> -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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:07 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
@ 2019-02-15 15:28 ` Boris Ostrovsky
2019-02-15 15:28 ` [Xen-devel][PATCH " Boris Ostrovsky
1 sibling, 0 replies; 19+ messages in thread
From: Boris Ostrovsky @ 2019-02-15 15:28 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, jgross
Cc: Oleksandr Andrushchenko
On 2/15/19 10:07 AM, Oleksandr Andrushchenko wrote:
> On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
>> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>> /* 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);
>> 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
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:07 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
2019-02-15 15:28 ` [PATCH " Boris Ostrovsky
@ 2019-02-15 15:28 ` Boris Ostrovsky
2019-02-15 15:35 ` [PATCH " Oleksandr Andrushchenko
2019-02-15 15:35 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
1 sibling, 2 replies; 19+ messages in thread
From: Boris Ostrovsky @ 2019-02-15 15:28 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, jgross
Cc: Oleksandr Andrushchenko
On 2/15/19 10:07 AM, Oleksandr Andrushchenko wrote:
> On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
>> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>> /* 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);
>> 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
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:28 ` [Xen-devel][PATCH " Boris Ostrovsky
@ 2019-02-15 15:35 ` Oleksandr Andrushchenko
2019-02-15 15:35 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
1 sibling, 0 replies; 19+ messages in thread
From: Oleksandr Andrushchenko @ 2019-02-15 15:35 UTC (permalink / raw)
To: Boris Ostrovsky, xen-devel, linux-kernel, jgross; +Cc: Oleksandr Andrushchenko
On 2/15/19 5:28 PM, Boris Ostrovsky wrote:
> On 2/15/19 10:07 AM, Oleksandr Andrushchenko wrote:
>> On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
>>> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>>> /* 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);
>>> 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
>
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Thank you,
any chance we can get this for 5.1?
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:28 ` [Xen-devel][PATCH " Boris Ostrovsky
2019-02-15 15:35 ` [PATCH " Oleksandr Andrushchenko
@ 2019-02-15 15:35 ` Oleksandr Andrushchenko
2019-02-15 16:29 ` Juergen Gross
2019-02-15 16:29 ` [PATCH " Juergen Gross
1 sibling, 2 replies; 19+ messages in thread
From: Oleksandr Andrushchenko @ 2019-02-15 15:35 UTC (permalink / raw)
To: Boris Ostrovsky, xen-devel, linux-kernel, jgross; +Cc: Oleksandr Andrushchenko
On 2/15/19 5:28 PM, Boris Ostrovsky wrote:
> On 2/15/19 10:07 AM, Oleksandr Andrushchenko wrote:
>> On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
>>> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>>> /* 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);
>>> 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
>
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Thank you,
any chance we can get this for 5.1?
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:35 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
@ 2019-02-15 16:29 ` Juergen Gross
2019-02-15 16:29 ` [PATCH " Juergen Gross
1 sibling, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2019-02-15 16:29 UTC (permalink / raw)
To: Oleksandr Andrushchenko, Boris Ostrovsky, xen-devel, linux-kernel
Cc: Oleksandr Andrushchenko
On 15/02/2019 16:35, Oleksandr Andrushchenko wrote:
> On 2/15/19 5:28 PM, Boris Ostrovsky wrote:
>> On 2/15/19 10:07 AM, Oleksandr Andrushchenko wrote:
>>> On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
>>>> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>>>> /* 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);
>>>> 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
>>
>> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Thank you,
> any chance we can get this for 5.1?
>
Yes.
Juergen
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-15 15:35 ` [Xen-devel][PATCH " Oleksandr Andrushchenko
2019-02-15 16:29 ` Juergen Gross
@ 2019-02-15 16:29 ` Juergen Gross
1 sibling, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2019-02-15 16:29 UTC (permalink / raw)
To: Oleksandr Andrushchenko, Boris Ostrovsky, xen-devel, linux-kernel
Cc: Oleksandr Andrushchenko
On 15/02/2019 16:35, Oleksandr Andrushchenko wrote:
> On 2/15/19 5:28 PM, Boris Ostrovsky wrote:
>> On 2/15/19 10:07 AM, Oleksandr Andrushchenko wrote:
>>> On 2/15/19 5:03 PM, Boris Ostrovsky wrote:
>>>> On 2/14/19 9:23 AM, Oleksandr Andrushchenko wrote:
>>>>> /* 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);
>>>> 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
>>
>> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
> Thank you,
> any chance we can get this for 5.1?
>
Yes.
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-14 14:23 [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Oleksandr Andrushchenko
` (3 preceding siblings ...)
2019-02-15 15:03 ` [Xen-devel][PATCH " Boris Ostrovsky
@ 2019-02-17 10:39 ` Juergen Gross
2019-02-17 10:39 ` [PATCH " Juergen Gross
5 siblings, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2019-02-17 10:39 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, boris.ostrovsky
Cc: Oleksandr Andrushchenko
On 14/02/2019 15:23, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Applied to xen/tip.git for-linus-5.1
Juergen
^ permalink raw reply [flat|nested] 19+ messages in thread* Re: [PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use
2019-02-14 14:23 [Xen-devel][PATCH 1/2] xen/gntdev: Do not destroy context while dma-bufs are in use Oleksandr Andrushchenko
` (4 preceding siblings ...)
2019-02-17 10:39 ` [Xen-devel][PATCH " Juergen Gross
@ 2019-02-17 10:39 ` Juergen Gross
5 siblings, 0 replies; 19+ messages in thread
From: Juergen Gross @ 2019-02-17 10:39 UTC (permalink / raw)
To: Oleksandr Andrushchenko, xen-devel, linux-kernel, boris.ostrovsky
Cc: Oleksandr Andrushchenko
On 14/02/2019 15:23, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
>
> 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.
>
> Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
Applied to xen/tip.git for-linus-5.1
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 19+ messages in thread