Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1378255pxb; Thu, 16 Sep 2021 06:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX0RYUfoVWXiyuY9M2ZxdY6nF8W5mxpo4o4nalE1h5hLKWS6jKKioA/Td1PPPDAkeh5sh0 X-Received: by 2002:a7b:cb97:: with SMTP id m23mr4032556wmi.70.1631798462103; Thu, 16 Sep 2021 06:21:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631798462; cv=none; d=google.com; s=arc-20160816; b=YMAdOGBfeWCWqA84PAwwyBFZJwsVD9Yotzb5wZihpvjKqWu3I8U2w4GPv1Y5EzhXqF //1WEzq/bcb/Z6C+sMca/TuMHjiyytB1iPbFKP30TdWse61t4JH80BiA7Hws0y8oN3bM 7pzpcqnd46SRUvRpd0mWRIPfIflHIV2eSTApSK1ojwdtX4siCqRclvW1Q+zlQodWB3lt ZRgadpHnmYx03s/SpnFrD1NurQqAF9eAcUOrr+IHnAzl0SCstXNj1yy6VTN0TVYPImaX Mu+SisMy1KLSpToAcR7QIl3R69dTIo+Mbep4etVZU21rS/W27py6BXhwuqXB/NjrQ9Al Sqdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=2SG+H3kPevlJgkQQvQK9AWnLbdaQxjj73VmdBEz2Wec=; b=nWAbMT40tiwsqAQbI5ng07p2X5jCmMMDs725feHVcaouEOffHI3FxoM+2vzWaPjYIK uXopNy2XUH2d1z/APLcq1uWbqqn+zTp53E3W0kg03/wnPyz/YTyJBHI8K8NfMrDAiVEC ddtPzvmjtsDQ9GI+oH9goDvCI3rl/r4ZAzwi72FxooIZmBxW/PCqOihWwrOpkKvfUypS XWTdTxNmuNHVsPWE7BN9bCqI3AWr06YXKXtnZV+yuDdVu/SgCyhmUAd+DmQC9bOTs6LA +mSL0Q1U94GZgxgoRrvo9fEvnQaAaPADM5KOY84IT/nmYfdIYBjywbg5mo8y3SEv07lU PBhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uBB97KZc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f4si3006838edv.542.2021.09.16.06.20.38; Thu, 16 Sep 2021 06:21:02 -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=@kernel.org header.s=k20201202 header.b=uBB97KZc; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239964AbhIPNR4 (ORCPT + 99 others); Thu, 16 Sep 2021 09:17:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:59788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239805AbhIPNRv (ORCPT ); Thu, 16 Sep 2021 09:17:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5F5CC61209; Thu, 16 Sep 2021 13:16:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631798191; bh=2SG+H3kPevlJgkQQvQK9AWnLbdaQxjj73VmdBEz2Wec=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=uBB97KZcafpcr9Fvmgxvt3cex2msqbDU833CT4y17phe93ZFrk+tasiQfh9bRUXTV lAFpyotnHfPKhe53lFUNoer4RLfO4P3T2/eB24OS8LSoXCX3v7tk8A22RQucMqvGda ENYrGzxn4SrST1ZwMk+qy8ehrg3OgY7CYdchkXE5AjKe62/PJiQA94XUjs2wVDxotm FxmadI38cxNwaCIfbUwTIs6IObCc4xT1XLghPGTosfQ6/qNOFsj1qgjf3/oJ0qV3p4 oFGW7umR+E5aZbSItLQT6GKyp+gYWISx/voRSUzEitrSAozO5Oywx3EOJB7glEBdO8 MllPzht7VdI4w== Received: by mail-oi1-f179.google.com with SMTP id v2so8976495oie.6; Thu, 16 Sep 2021 06:16:31 -0700 (PDT) X-Gm-Message-State: AOAM531qcvlLyCPEd0he8iYOfP0YSGJpSDQCKPX7709//7omKCl9YniU +TAA7gTFm87AvmPyTzPb02iwWgI4rEbXoExudhE= X-Received: by 2002:a05:6808:2193:: with SMTP id be19mr8915077oib.102.1631798190674; Thu, 16 Sep 2021 06:16:30 -0700 (PDT) MIME-Version: 1.0 References: <20210912165309.98695-1-ogabbay@kernel.org> <20210914161218.GF3544071@ziepe.ca> In-Reply-To: From: Oded Gabbay Date: Thu, 16 Sep 2021 16:16:03 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v6 0/2] Add p2p via dmabuf to habanalabs To: Jason Gunthorpe , Daniel Vetter Cc: "Linux-Kernel@Vger. Kernel. Org" , Greg Kroah-Hartman , =?UTF-8?Q?Christian_K=C3=B6nig?= , 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" , dsinger@habana.ai Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 3:44 PM Oded Gabbay wrote: > > On Thu, Sep 16, 2021 at 3:31 PM Daniel Vetter wrote: > > > > 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 > This can not happen without User A closing the FD of the dma-buf it exported. > We prevent User A from closing the device because when it exported the > dma-buf, the driver's code took a refcnt of the user's private > structure. You can see that in export_dmabuf_common() in the 2nd > patch. There is a call there to hl_ctx_get. > So even if User A calls close(device_fd), the driver won't let any > other user open the device until User A closes the fd of the dma-buf > object. > > Moreover, once User A will close the dma-buf fd and the device is > released, the driver will scrub the device memory (this is optional > for systems who care about security). > > And AFAIK, User A can't close the dma-buf fd once it registered it > with RDMA, without doing unregister. > This can be seen in ib_umem_dmabuf_get() which calls dma_buf_get() > which does fget(fd) Adding Daniel, I don't know how his email got dropped when I replied to him...