* Re: [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
2019-06-10 20:52 [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping Ajay Kaher
@ 2019-06-10 13:55 ` Michal Hocko
2019-06-10 16:05 ` Jason Gunthorpe
2019-06-14 14:41 ` Ajay Kaher
2 siblings, 0 replies; 5+ messages in thread
From: Michal Hocko @ 2019-06-10 13:55 UTC (permalink / raw)
To: Ajay Kaher
Cc: aarcange, jannh, oleg, peterx, rppt, jgg, yishaih, dledford,
sean.hefty, hal.rosenstock, matanb, leonro, linux-rdma,
linux-kernel, stable, srivatsab, amakhalov
On Tue 11-06-19 02:22:17, Ajay Kaher wrote:
> This patch is the extension of following upstream commit to fix
> the race condition between get_task_mm() and core dumping
> for IB->mlx4 and IB->mlx5 drivers:
>
> commit 04f5866e41fb ("coredump: fix race condition between
> mmget_not_zero()/get_task_mm() and core dumping")'
>
> Thanks to Jason for pointing this.
>
> Signed-off-by: Ajay Kaher <akaher@vmware.com>
> ---
> drivers/infiniband/hw/mlx4/main.c | 4 +++-
> drivers/infiniband/hw/mlx5/main.c | 3 +++
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index e2beb18..0299c06 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -1197,6 +1197,8 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
> * mlx4_ib_vma_close().
> */
> down_write(&owning_mm->mmap_sem);
> + if (!mmget_still_valid(owning_mm))
> + goto skip_mm;
> for (i = 0; i < HW_BAR_COUNT; i++) {
> vma = context->hw_bar_info[i].vma;
> if (!vma)
I have missed this part in 4.4 stable backport. Thanks for catching it.
I have updated my backport.
> @@ -1215,7 +1217,7 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
> /* context going to be destroyed, should not access ops any more */
> context->hw_bar_info[i].vma->vm_ops = NULL;
> }
> -
> +skip_mm:
> up_write(&owning_mm->mmap_sem);
> mmput(owning_mm);
> put_task_struct(owning_process);
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
2019-06-10 20:52 [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping Ajay Kaher
2019-06-10 13:55 ` Michal Hocko
@ 2019-06-10 16:05 ` Jason Gunthorpe
2019-06-14 14:41 ` Ajay Kaher
2 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2019-06-10 16:05 UTC (permalink / raw)
To: Ajay Kaher
Cc: aarcange, jannh, oleg, peterx, rppt, mhocko, Yishai Hadas,
dledford, sean.hefty, hal.rosenstock, Matan Barak,
Leon Romanovsky, linux-rdma, linux-kernel, stable, srivatsab,
amakhalov
On Tue, Jun 11, 2019 at 02:22:17AM +0530, Ajay Kaher wrote:
> This patch is the extension of following upstream commit to fix
> the race condition between get_task_mm() and core dumping
> for IB->mlx4 and IB->mlx5 drivers:
>
> commit 04f5866e41fb ("coredump: fix race condition between
> mmget_not_zero()/get_task_mm() and core dumping")'
>
> Thanks to Jason for pointing this.
>
> Signed-off-by: Ajay Kaher <akaher@vmware.com>
> ---
> drivers/infiniband/hw/mlx4/main.c | 4 +++-
> drivers/infiniband/hw/mlx5/main.c | 3 +++
> 2 files changed, 6 insertions(+), 1 deletion(-)
Acked-by: Jason Gunthorpe <jgg@mellanox.com>
Jason
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
@ 2019-06-10 20:52 Ajay Kaher
2019-06-10 13:55 ` Michal Hocko
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ajay Kaher @ 2019-06-10 20:52 UTC (permalink / raw)
To: aarcange, jannh, oleg, peterx, rppt, jgg, mhocko
Cc: yishaih, dledford, sean.hefty, hal.rosenstock, matanb, leonro,
linux-rdma, linux-kernel, stable, akaher, srivatsab, amakhalov
This patch is the extension of following upstream commit to fix
the race condition between get_task_mm() and core dumping
for IB->mlx4 and IB->mlx5 drivers:
commit 04f5866e41fb ("coredump: fix race condition between
mmget_not_zero()/get_task_mm() and core dumping")'
Thanks to Jason for pointing this.
Signed-off-by: Ajay Kaher <akaher@vmware.com>
---
drivers/infiniband/hw/mlx4/main.c | 4 +++-
drivers/infiniband/hw/mlx5/main.c | 3 +++
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index e2beb18..0299c06 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -1197,6 +1197,8 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
* mlx4_ib_vma_close().
*/
down_write(&owning_mm->mmap_sem);
+ if (!mmget_still_valid(owning_mm))
+ goto skip_mm;
for (i = 0; i < HW_BAR_COUNT; i++) {
vma = context->hw_bar_info[i].vma;
if (!vma)
@@ -1215,7 +1217,7 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
/* context going to be destroyed, should not access ops any more */
context->hw_bar_info[i].vma->vm_ops = NULL;
}
-
+skip_mm:
up_write(&owning_mm->mmap_sem);
mmput(owning_mm);
put_task_struct(owning_process);
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
index 13a9206..3fbe396 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1646,6 +1646,8 @@ static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
* mlx5_ib_vma_close.
*/
down_write(&owning_mm->mmap_sem);
+ if (!mmget_still_valid(owning_mm))
+ goto skip_mm;
mutex_lock(&context->vma_private_list_mutex);
list_for_each_entry_safe(vma_private, n, &context->vma_private_list,
list) {
@@ -1662,6 +1664,7 @@ static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
kfree(vma_private);
}
mutex_unlock(&context->vma_private_list_mutex);
+skip_mm:
up_write(&owning_mm->mmap_sem);
mmput(owning_mm);
put_task_struct(owning_process);
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
2019-06-10 20:52 [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping Ajay Kaher
2019-06-10 13:55 ` Michal Hocko
2019-06-10 16:05 ` Jason Gunthorpe
@ 2019-06-14 14:41 ` Ajay Kaher
2019-06-14 14:55 ` Greg KH
2 siblings, 1 reply; 5+ messages in thread
From: Ajay Kaher @ 2019-06-14 14:41 UTC (permalink / raw)
To: aarcange, jannh, oleg, peterx, rppt, jgg, mhocko
Cc: yishaih, dledford, sean.hefty, hal.rosenstock, matanb, leonro,
linux-rdma, linux-kernel, stable, Srivatsa Bhat, Alexey Makhalov,
Greg KH, Linus Torvalds
On 10/06/19, 6:22 PM, "Ajay Kaher" <akaher@vmware.com> wrote:
> This patch is the extension of following upstream commit to fix
> the race condition between get_task_mm() and core dumping
> for IB->mlx4 and IB->mlx5 drivers:
>
> commit 04f5866e41fb ("coredump: fix race condition between
> mmget_not_zero()/get_task_mm() and core dumping")'
>
> Thanks to Jason for pointing this.
>
> Signed-off-by: Ajay Kaher <akaher@vmware.com>
> Acked-by: Jason Gunthorpe <jgg@mellanox.com>
Greg, I hope you would like to review and proceed further with this patch.
> ---
> drivers/infiniband/hw/mlx4/main.c | 4 +++-
> drivers/infiniband/hw/mlx5/main.c | 3 +++
> 2 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
> index e2beb18..0299c06 100644
> --- a/drivers/infiniband/hw/mlx4/main.c
> +++ b/drivers/infiniband/hw/mlx4/main.c
> @@ -1197,6 +1197,8 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
> * mlx4_ib_vma_close().
> */
> down_write(&owning_mm->mmap_sem);
> + if (!mmget_still_valid(owning_mm))
> + goto skip_mm;
> for (i = 0; i < HW_BAR_COUNT; i++) {
> vma = context->hw_bar_info[i].vma;
> if (!vma)
> @@ -1215,7 +1217,7 @@ static void mlx4_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
> /* context going to be destroyed, should not access ops any more */
> context->hw_bar_info[i].vma->vm_ops = NULL;
> }
> -
> +skip_mm:
> up_write(&owning_mm->mmap_sem);
> mmput(owning_mm);
> put_task_struct(owning_process);
> diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c
> index 13a9206..3fbe396 100644
> --- a/drivers/infiniband/hw/mlx5/main.c
> +++ b/drivers/infiniband/hw/mlx5/main.c
> @@ -1646,6 +1646,8 @@ static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
> * mlx5_ib_vma_close.
> */
> down_write(&owning_mm->mmap_sem);
> + if (!mmget_still_valid(owning_mm))
> + goto skip_mm;
> mutex_lock(&context->vma_private_list_mutex);
> list_for_each_entry_safe(vma_private, n, &context->vma_private_list,
> list) {
> @@ -1662,6 +1664,7 @@ static void mlx5_ib_disassociate_ucontext(struct ib_ucontext *ibcontext)
> kfree(vma_private);
> }
> mutex_unlock(&context->vma_private_list_mutex);
> +skip_mm:
> up_write(&owning_mm->mmap_sem);
> mmput(owning_mm);
> put_task_struct(owning_process);
> --
> 2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping
2019-06-14 14:41 ` Ajay Kaher
@ 2019-06-14 14:55 ` Greg KH
0 siblings, 0 replies; 5+ messages in thread
From: Greg KH @ 2019-06-14 14:55 UTC (permalink / raw)
To: Ajay Kaher
Cc: aarcange, jannh, oleg, peterx, rppt, jgg, mhocko, yishaih,
dledford, sean.hefty, hal.rosenstock, matanb, leonro, linux-rdma,
linux-kernel, stable, Srivatsa Bhat, Alexey Makhalov,
Linus Torvalds
On Fri, Jun 14, 2019 at 02:41:39PM +0000, Ajay Kaher wrote:
>
> On 10/06/19, 6:22 PM, "Ajay Kaher" <akaher@vmware.com> wrote:
>
> > This patch is the extension of following upstream commit to fix
> > the race condition between get_task_mm() and core dumping
> > for IB->mlx4 and IB->mlx5 drivers:
> >
> > commit 04f5866e41fb ("coredump: fix race condition between
> > mmget_not_zero()/get_task_mm() and core dumping")'
> >
> > Thanks to Jason for pointing this.
> >
> > Signed-off-by: Ajay Kaher <akaher@vmware.com>
> > Acked-by: Jason Gunthorpe <jgg@mellanox.com>
>
> Greg, I hope you would like to review and proceed further with this patch.
If this is all calmed down now, I'll look at it next week, thanks.
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-14 14:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-10 20:52 [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping Ajay Kaher
2019-06-10 13:55 ` Michal Hocko
2019-06-10 16:05 ` Jason Gunthorpe
2019-06-14 14:41 ` Ajay Kaher
2019-06-14 14:55 ` Greg KH
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).