Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1342763pxb; Thu, 16 Sep 2021 05:35:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXcbhbPxN3yjeKbtx86bH9lePMRfEeHEki5FdCR2NxM19TRH5XJ3W34sRIJoyYtsGKRkte X-Received: by 2002:a17:907:2658:: with SMTP id ar24mr6245307ejc.329.1631795735080; Thu, 16 Sep 2021 05:35:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631795735; cv=none; d=google.com; s=arc-20160816; b=C71UYUnOlBf8pBUkVtx+gwKrhTp4TkGFuc4hbRI9KOkW8A6R86xHTeOsryTDKiV3QV JQB6DSrxn8W5GanZehAWmarymYWLUhepA+KeAqODYB6U/DdHv6IJcEW3wlQbVzGhX2sh FTtrhtCZkx2Fk8gFIob0ZPU4esXgVoOIYQbw5GUEcG5AAmf2LQJStS/VtjBjeydda4tZ iBy9GmG6sPBj7xyeyvT/3mxgP8+dsLEYGOy38imc2onnbwqKLs4hifljE6NB3cDyzsTt F4aipiEhf2Q6LlCWwQZ6qPpsyXb7U5JhDA/tpWecy/ZZ5NjpX4rlsieTXI97MBFHVTNr WYZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=yVn4bOUftTP0XsVCYOhP2MVjOD5RXLBjZ2je0UhYRc0=; b=VPdtORuSNueuK9DT+jk4F6rQ8BdgeBQF31pAbE+bLpRQLrNf/L6eRBJKF1bSIUwy2/ 2X4aqBnVwYlfhuc/tV2fNgK3SK0RsfD4EFPFVDWX7ZgPidtho7qy9WbvCuP5G9kXhzNa Uyo+JrTBjR6IgU59MCjPAzFehtBq8bwxJOEI6UODakfB1HKOPWofgDySA1WEU5C0AKyp iMYovHp244WNchZe6SQy1zVEC5fcRfgLaL2BPKvjB/ogG4wFIZBFA53ZElJvpLfe0RwV y4sby5DuYTRNqqHRAQZZL2rStpWQeEVN5m1BrBvfFekTFKQsVwjOxVY3TK80wpqSQmue 7DqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=UllxjW1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 26si3593156eji.590.2021.09.16.05.35.09; Thu, 16 Sep 2021 05:35:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=UllxjW1p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235767AbhIPMdA (ORCPT + 99 others); Thu, 16 Sep 2021 08:33:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239471AbhIPMc7 (ORCPT ); Thu, 16 Sep 2021 08:32:59 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD5EEC061766 for ; Thu, 16 Sep 2021 05:31:38 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id t8so9238724wrq.4 for ; Thu, 16 Sep 2021 05:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=yVn4bOUftTP0XsVCYOhP2MVjOD5RXLBjZ2je0UhYRc0=; b=UllxjW1pQN4AmYZEbLg7VrErGUqD+1ja2ihP7bNIWt/uTZGlmL71/XP9jjO6KhmKY0 fiRtXpVcCH1hQKOY2jdfchmwYGS0XP4lfMRLycLsW6+OfxpIvDESU51aAUOmrcst/rON qWFSoQtqfz711rHCKql1DqY94oNcjEZ2J6WVI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=yVn4bOUftTP0XsVCYOhP2MVjOD5RXLBjZ2je0UhYRc0=; b=6lM2Oe0xBRcsAAVF+ZAiMofKxM8AEOmJUmmXH1+lbJ4x7QFvPfqW1XnRjfPTl2D1FD POQsy/8DNsvQLKnvdKDmsD6dQbbGpShk4cxDz5meB/z/+wO5NVOiypvnI741QGR8hyMQ yzPzNNnV3GcpPT4QkHNRJBTnAC2UA2z4/3ODtxTXNfN/1MPQmudbLHwUzqiQwSjYaMIl nl6l3Htd+paLC5auKAIEhJTVDeS4s74jl1tHK6Nx8PuY74vEvbTWORDdYxwRicCzVdJW pwxF7NBDMU3Yztd5+zyzIjIk7ZdIXgbEBez/X/pFT2n4B5ISv9yYPIEHUUE946Q3kBvi CzAA== X-Gm-Message-State: AOAM530zLJUT6vVdsHT+g6Jt/ZyKvjrR/9s0zikkYLdnVSK9sNt3p4BM nxg/CBWOnEh7yM77dcZCDZhVow== X-Received: by 2002:a5d:6da9:: with SMTP id u9mr5766027wrs.155.1631795497459; Thu, 16 Sep 2021 05:31:37 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id g5sm3285526wrq.80.2021.09.16.05.31.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Sep 2021 05:31:36 -0700 (PDT) Date: Thu, 16 Sep 2021 14:31:34 +0200 From: Daniel Vetter To: Oded Gabbay Cc: Jason Gunthorpe , "Linux-Kernel@Vger. Kernel. Org" , Greg Kroah-Hartman , Christian =?iso-8859-1?Q?K=F6nig?= , Gal Pressman , Yossi Leybovich , Maling list - DRI developers , linux-rdma , Linux Media Mailing List , Doug Ledford , Dave Airlie , Alex Deucher , Leon Romanovsky , Christoph Hellwig , amd-gfx list , "moderated list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [PATCH v6 0/2] Add p2p via dmabuf to habanalabs Message-ID: Mail-Followup-To: Oded Gabbay , Jason Gunthorpe , "Linux-Kernel@Vger. Kernel. Org" , Greg Kroah-Hartman , Christian =?iso-8859-1?Q?K=F6nig?= , Gal Pressman , Yossi Leybovich , Maling list - DRI developers , linux-rdma , Linux Media Mailing List , Doug Ledford , Dave Airlie , Alex Deucher , Leon Romanovsky , Christoph Hellwig , amd-gfx list , "moderated list:DMA BUFFER SHARING FRAMEWORK" References: <20210912165309.98695-1-ogabbay@kernel.org> <20210914161218.GF3544071@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 5.10.0-8-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 15, 2021 at 10:45:36AM +0300, Oded Gabbay wrote: > On Tue, Sep 14, 2021 at 7:12 PM Jason Gunthorpe wrote: > > > > On Tue, Sep 14, 2021 at 04:18:31PM +0200, Daniel Vetter wrote: > > > On Sun, Sep 12, 2021 at 07:53:07PM +0300, Oded Gabbay wrote: > > > > Hi, > > > > Re-sending this patch-set following the release of our user-space TPC > > > > compiler and runtime library. > > > > > > > > I would appreciate a review on this. > > > > > > I think the big open we have is the entire revoke discussions. Having the > > > option to let dma-buf hang around which map to random local memory ranges, > > > without clear ownership link and a way to kill it sounds bad to me. > > > > > > I think there's a few options: > > > - We require revoke support. But I've heard rdma really doesn't like that, > > > I guess because taking out an MR while holding the dma_resv_lock would > > > be an inversion, so can't be done. Jason, can you recap what exactly the > > > hold-up was again that makes this a no-go? > > > > RDMA HW can't do revoke. Like why? I'm assuming when the final open handle or whatever for that MR is closed, you do clean up everything? Or does that MR still stick around forever too? > > So we have to exclude almost all the HW and several interesting use > > cases to enable a revoke operation. > > > > > - For non-revokable things like these dma-buf we'd keep a drm_master > > > reference around. This would prevent the next open to acquire > > > ownership rights, which at least prevents all the nasty potential > > > problems. > > > > This is what I generally would expect, the DMABUF FD and its DMA > > memory just floats about until the unrevokable user releases it, which > > happens when the FD that is driving the import eventually gets closed. > This is exactly what we are doing in the driver. We make sure > everything is valid until the unrevokable user releases it and that > happens only when the dmabuf fd gets closed. > And the user can't close it's fd of the device until he performs the > above, so there is no leakage between users. Maybe I got the device security model all wrong, but I thought Guadi is single user, and the only thing it protects is the system against the Gaudi device trhough iommu/device gart. So roughly the following can happen: 1. User A opens gaudi device, sets up dma-buf export 2. User A registers that with RDMA, or anything else that doesn't support revoke. 3. User A closes gaudi device 4. User B opens gaudi device, assumes that it has full control over the device and uploads some secrets, which happen to end up in the dma-buf region user A set up 5. User B extracts secrets. > > I still don't think any of the complexity is needed, pinnable memory > > is a thing in Linux, just account for it in mlocked and that is > > enough. It's not mlocked memory, it's mlocked memory and I can exfiltrate it. Mlock is fine, exfiltration not so much. It's mlock, but a global pool and if you didn't munlock then the next mlock from a completely different user will alias with your stuff. Or is there something that prevents that? Oded at least explain that gaudi works like a gpu from 20 years ago, single user, no security at all within the device. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch