From patchwork Tue Apr 16 11:07:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Romanovsky X-Patchwork-Id: 10902735 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 620E214DB for ; Tue, 16 Apr 2019 11:07:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35BE928905 for ; Tue, 16 Apr 2019 11:07:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 275EE28942; Tue, 16 Apr 2019 11:07:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0FB328905 for ; Tue, 16 Apr 2019 11:07:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727240AbfDPLHz (ORCPT ); Tue, 16 Apr 2019 07:07:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:42130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726672AbfDPLHz (ORCPT ); Tue, 16 Apr 2019 07:07:55 -0400 Received: from localhost (unknown [193.47.165.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 554072073F; Tue, 16 Apr 2019 11:07:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555412875; bh=+NlHH29PNinf5h5CgeIZuS/MtzfdOtEDlPRXDDmfg5s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QTynSrkOWzOLxwi0PHxqtQG9PjkvDeHVyYpGnxrUyE1JF0KC+ImLsE7//NjYnTSin 14Q8d0PyJuQPzfdwmAc+vyXLQm4VLyVb6gG1VC9UqjsNRBKeFJdaejKlbJ3lGQzNrl l6IYSXOC7Dk7Oaj5nLmp/Y8HRA7KthHQ0t7ax4Bc= From: Leon Romanovsky To: Doug Ledford , Jason Gunthorpe Cc: Leon Romanovsky , RDMA mailing list , Andrea Arcangeli , Feras Daoud , Haggai Eran , Jason Gunthorpe , Saeed Mahameed , linux-netdev Subject: [PATCH rdma-next 3/6] RDMA/ucontext: Do not allow BAR mappings to be executable Date: Tue, 16 Apr 2019 14:07:27 +0300 Message-Id: <20190416110730.32230-4-leon@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190416110730.32230-1-leon@kernel.org> References: <20190416110730.32230-1-leon@kernel.org> MIME-Version: 1.0 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe These are not code pages and should never be executed. Cc: stable@vger.kernel.org Fixes: 5f9794dc94f5 ("RDMA/ucontext: Add a core API for mmaping driver IO memory") Signed-off-by: Jason Gunthorpe Signed-off-by: Leon Romanovsky --- drivers/infiniband/core/uverbs_main.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index fef4519d1241..3ef6474cd201 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c @@ -889,6 +889,10 @@ static struct rdma_umap_priv *rdma_user_mmap_pre(struct ib_ucontext *ucontext, struct ib_uverbs_file *ufile = ucontext->ufile; struct rdma_umap_priv *priv; + if (vma->vm_flags & VM_EXEC) + return ERR_PTR(-EINVAL); + vma->vm_flags &= ~VM_MAYEXEC; + if (vma->vm_end - vma->vm_start != size) return ERR_PTR(-EINVAL);