Received: by 10.213.65.68 with SMTP id h4csp245305imn; Fri, 23 Mar 2018 03:49:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELsCusdZ5eG3L+GNEUNSY7/orwsAZ393hx6s629fovMSMWKhGzAG+JjJ9DzH8IgnTGX1OJHj X-Received: by 2002:a17:902:6184:: with SMTP id u4-v6mr9481858plj.390.1521802153005; Fri, 23 Mar 2018 03:49:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521802152; cv=none; d=google.com; s=arc-20160816; b=SOEJeXMiQ++NP0Hm6ysxUSqOlPKJ0GedMdW7ZDktzyz1kDDQ3lpZteqMk67/xhhsWH VYtovxa2/1P+0yDoK510SSWZfqXYql6oqB3bzxKrFu5AI75xmZ26Dp7GuMfnDPCQkN8X mXnF6NmI1tfHGtYa5K597/zxWFI1uGT9ZISbtW6H3+o+mx3fSoqCWxlDz0JlHESrcdrF uTx5eOz3MJhmZUtI+HAyQgwtiFm8AfPEx86ubNas7ksic42xV1ecOquodALWEQJ5s02Z /zVcNSV/dGyIVJp0V8+DkBeeIIUO9voxhbOV75tJSk1Fp1aYi05z0wSCLANe0il0PAy0 CAiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hX/RHJxR7KJlHlNFcoDMZbfrpPsxpM8Lqz8e2AiE3as=; b=oXqkEeQOfhUrhUDxU1JP2yA7chCV068SdB9HixUqfodCahL4Ytoc6f2SKCFnflw8OT qFL1kPQrWNnq4T0lb+1c5gSQ1xXED7LWqodFIEmWCkSkHLuovIP8Fa306G8vfn7haFzk dqK/Nzy+9qy0Jo2+eGPt+Jn9s7mfTEDSHPX5fMpRmavANKQmdhNbBw1OUSgFxkSFcpz+ PZU90P2FLChVkj24zpRVjGh2LJJSkZOGPp+ii8B0IOrFxZWAenDNkx+sAgaiRb79bpHB V3JaGE5X+vb2ZiZ+Ew8/S1EAd0jTu9WRQK2Q+ggjmy/aifrnlQkUXLaZ+sRrWapHG+0g 29NA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l25si6423218pff.16.2018.03.23.03.48.58; Fri, 23 Mar 2018 03:49:12 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933396AbeCWKPC (ORCPT + 99 others); Fri, 23 Mar 2018 06:15:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:45450 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752731AbeCWKPA (ORCPT ); Fri, 23 Mar 2018 06:15:00 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E697D119C; Fri, 23 Mar 2018 10:14:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maor Gottlieb , Leon Romanovsky , Doug Ledford , Sasha Levin Subject: [PATCH 4.4 34/97] IB/mlx4: Take write semaphore when changing the vma struct Date: Fri, 23 Mar 2018 10:54:21 +0100 Message-Id: <20180323094159.597716749@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094157.535925724@linuxfoundation.org> References: <20180323094157.535925724@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Maor Gottlieb [ Upstream commit 22c3653d04bd0c67b75e99d85e0c0bdf83947df5 ] When the driver disassociate user context, it changes the vma to anonymous by setting the vm_ops to null and zap the vma ptes. In order to avoid race in the kernel, we need to take write lock before we change the vma entries. Fixes: ae184ddeca5db ('IB/mlx4_ib: Disassociate support') Signed-off-by: Maor Gottlieb Signed-off-by: Leon Romanovsky Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/mlx4/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -1041,7 +1041,7 @@ static void mlx4_ib_disassociate_ucontex /* need to protect from a race on closing the vma as part of * mlx4_ib_vma_close(). */ - down_read(&owning_mm->mmap_sem); + down_write(&owning_mm->mmap_sem); for (i = 0; i < HW_BAR_COUNT; i++) { vma = context->hw_bar_info[i].vma; if (!vma) @@ -1059,7 +1059,7 @@ static void mlx4_ib_disassociate_ucontex context->hw_bar_info[i].vma->vm_ops = NULL; } - up_read(&owning_mm->mmap_sem); + up_write(&owning_mm->mmap_sem); mmput(owning_mm); put_task_struct(owning_process); }