From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 779E1C433E0 for ; Fri, 26 Jun 2020 20:08:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BFA020720 for ; Fri, 26 Jun 2020 20:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726107AbgFZUIQ (ORCPT ); Fri, 26 Jun 2020 16:08:16 -0400 Received: from mga01.intel.com ([192.55.52.88]:8814 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725823AbgFZUIQ (ORCPT ); Fri, 26 Jun 2020 16:08:16 -0400 IronPort-SDR: 6CUANNw87mm0T/cC4tTQ5Qu1D4l9JrvWd6EFJO5g+M7FMZIQSGAXfxuAn1IJVJ5t5Wj74Brufz t3Wu3Ez7lh3A== X-IronPort-AV: E=McAfee;i="6000,8403,9664"; a="163495099" X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="163495099" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2020 13:08:15 -0700 IronPort-SDR: DFxhAN9uAkgMQalhsvNo9cBN/6ui9Dzq1fygm1mPOL8AVTs4uAwUqd36H8Rr7JhvRtvzPtOvP2 Uv4rlwNWx0Cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,284,1589266800"; d="scan'208";a="302432552" Received: from iweiny-desk2.sc.intel.com ([10.3.52.147]) by fmsmga004.fm.intel.com with ESMTP; 26 Jun 2020 13:08:15 -0700 Date: Fri, 26 Jun 2020 13:08:15 -0700 From: Ira Weiny To: Thomas Ruf Cc: Dave Jiang , Vinod Koul , Federico Vaga , Dan Williams , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, "Kumar, Sanjay K" , "Luck, Tony" Subject: Re: DMA Engine: Transfer From Userspace Message-ID: <20200626200815.GC2454695@iweiny-DESK2.sc.intel.com> References: <5614531.lOV4Wx5bFT@harkonnen> <20200621072457.GA2324254@vkoul-mobl> <581f1761-e582-c770-169a-ee3374baf25c@intel.com> <84270660.632865.1593072688966@mailbusiness.ionos.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <84270660.632865.1593072688966@mailbusiness.ionos.de> User-Agent: Mutt/1.11.1 (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 25, 2020 at 10:11:28AM +0200, Thomas Ruf wrote: > > > On 25 June 2020 at 02:42 Dave Jiang wrote: > > > > > > > > > > On 6/21/2020 12:24 AM, Vinod Koul wrote: > > > On 19-06-20, 16:31, Dave Jiang wrote: > > >> > > >> > > >> On 6/19/2020 3:47 PM, Federico Vaga wrote: > > >>> Hello, > > >>> > > >>> is there the possibility of using a DMA engine channel from userspace? > > >>> > > >>> Something like: > > >>> - configure DMA using ioctl() (or whatever configuration mechanism) > > >>> - read() or write() to trigger the transfer > > >>> > > >> > > >> I may have supposedly promised Vinod to look into possibly providing > > >> something like this in the future. But I have not gotten around to do that > > >> yet. Currently, no such support. > > > > > > And I do still have serious reservations about this topic :) Opening up > > > userspace access to DMA does not sound very great from security point of > > > view. > > > > What about doing it with DMA engine that supports PASID? That way the user can > > really only trash its own address space and kernel is protected. > > Sounds interesting! Not sure if this is really needed in that case... > I have already implemented checks of vm_area_struct for contiguous memory or even do a get_user_pages_fast for user memory to pin it (hope that is the correct term here). Of course i have to do that for every involved page. FWIW there is a new pin_user_pages_fast()/unpin_user_page() interface now. Ira > But i will do some checks if my code is really suitable to avoid misusage. > > Best regards, > Thomas