From patchwork Tue Oct 6 09:24:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 7333881 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9E0E2BEEA4 for ; Tue, 6 Oct 2015 09:25:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD8DE2064B for ; Tue, 6 Oct 2015 09:24:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 428662065B for ; Tue, 6 Oct 2015 09:24:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752604AbbJFJYy (ORCPT ); Tue, 6 Oct 2015 05:24:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:35599 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752385AbbJFJYx (ORCPT ); Tue, 6 Oct 2015 05:24:53 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1D4EAAC4E; Tue, 6 Oct 2015 09:24:51 +0000 (UTC) Received: by quack.suse.cz (Postfix, from userid 1000) id 6CEBB8282F; Tue, 6 Oct 2015 11:24:50 +0200 (CEST) From: Jan Kara To: linux-mm@kvack.org Cc: Jan Kara , Roland Dreier , linux-rdma@vger.kernel.org Subject: [PATCH 5/7] IB/mthca: Convert mthca_map_user_db() to use get_user_pages_fast() Date: Tue, 6 Oct 2015 11:24:28 +0200 Message-Id: <1444123470-4932-6-git-send-email-jack@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1444123470-4932-1-git-send-email-jack@suse.com> References: <1444123470-4932-1-git-send-email-jack@suse.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jan Kara Function mthca_map_user_db() appears to call get_user_pages() without holding mmap_sem. Fix the bug by using get_user_pages_fast() instead which also takes care of the locking. CC: Roland Dreier CC: linux-rdma@vger.kernel.org Signed-off-by: Jan Kara --- drivers/infiniband/hw/mthca/mthca_memfree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 7d2e42dd6926..c3543b27a2a7 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c @@ -472,8 +472,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar, goto out; } - ret = get_user_pages(current, current->mm, uaddr & PAGE_MASK, 1, 1, 0, - pages, NULL); + ret = get_user_pages_fast(uaddr & PAGE_MASK, 1, 1, pages); if (ret < 0) goto out;