Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3236464ybi; Mon, 10 Jun 2019 06:57:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGJjLJC8uGx4Zjd/VYo/DSx+5YX6B5gSUWrnme1zcOfrhliN7yypQQu+Fdy0O8VCQ9tGuM X-Received: by 2002:a63:e645:: with SMTP id p5mr15805462pgj.4.1560175026488; Mon, 10 Jun 2019 06:57:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560175026; cv=none; d=google.com; s=arc-20160816; b=S/2Z/ClDybFH2jMdmUoXnutSQVfli0yRUHyDBPePRxaRYte/DJqEoYHY2hsd7GbLWa /DQoGjThozGeFrR9qLzpy/AycSf/jA8pelvuo3nptnFnpTglPDCHvgfckgk3Wen7fFRo 2+GbgT38kw6hHiiXNOHdchfkSgwYZ5CmM+bj2PVOwuarHAjq8U+VdrVimaiiicQUyl4h rOFUk8o1LvXEDFb1mizh5CU+F4WWeyDsNpnX5LhMxEUuxT66qzjACEjuX/TvcJSbG6Us VQrh0hjYXbgpgCs3gORfFLHM5py/xdj87kr/2iCdbaZsfSa6Sm+KcJGddh8yGGwPchyC fZ4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=0iFhWgLzOJNdYq9gXTPHkbkfyjgUHt8/OwobjE7KYpU=; b=o3OTbPAHxV0xqM4rYE86Dg0zdrrPTpEO99YL/lGNFvt6HaKwtjSdwdPWQtoq7Lk+nr B52koZJPCK4jE2qcCpm+GAeEFp1uFzx+VWhY9tCgZkIe6pDyKsE06kU9XWFnde6Fjt6V 7RE58qxwocLUxMlVXfEmQ9fhsRQ3Ci7TgL33aruheIlZyxRLikhRScNvW8P+Hz+Wl/Bs QYuC5/8u/C/MBinI15+W6m0QAEYVBfWxVdc2dt6bOpaHgxZI/xj7OiIzUYghD/IDTa9L IvyseeVx5XHp9bHRDyUWkhd5NE6RLf4sPy0N2jskcF11cesgvYogpS5YEly6kQkFIQ+1 MLrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r129si9894550pgr.307.2019.06.10.06.56.51; Mon, 10 Jun 2019 06:57:06 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390594AbfFJNz4 (ORCPT + 99 others); Mon, 10 Jun 2019 09:55:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:32920 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389373AbfFJNz4 (ORCPT ); Mon, 10 Jun 2019 09:55:56 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id BBE4BABD2; Mon, 10 Jun 2019 13:55:53 +0000 (UTC) Date: Mon, 10 Jun 2019 15:55:53 +0200 From: Michal Hocko To: Ajay Kaher Cc: aarcange@redhat.com, jannh@google.com, oleg@redhat.com, peterx@redhat.com, rppt@linux.ibm.com, jgg@mellanox.com, yishaih@mellanox.com, dledford@redhat.com, sean.hefty@intel.com, hal.rosenstock@gmail.com, matanb@mellanox.com, leonro@mellanox.com, linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, srivatsab@vmware.com, amakhalov@vmware.com Subject: Re: [PATCH] [v4.14.y] infiniband: fix race condition between infiniband mlx4, mlx5 driver and core dumping Message-ID: <20190610135553.GH30967@dhcp22.suse.cz> References: <1560199937-23476-1-git-send-email-akaher@vmware.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1560199937-23476-1-git-send-email-akaher@vmware.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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