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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 B79C4C4742C for ; Tue, 10 Nov 2020 14:44:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 309C1207BB for ; Tue, 10 Nov 2020 14:44:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="EKf0wqjh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732195AbgKJOoM (ORCPT ); Tue, 10 Nov 2020 09:44:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730200AbgKJOoM (ORCPT ); Tue, 10 Nov 2020 09:44:12 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14869C0613CF for ; Tue, 10 Nov 2020 06:44:11 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id p19so2159330wmg.0 for ; Tue, 10 Nov 2020 06:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=X4vUCbZyJ1/CJiuVNPzRZXx6UspNaZqxadNszyTjElM=; b=EKf0wqjhjoi8CDQBN/YapYVcD9ppM8MymSKwgFzwh+6C8G528otoa9GfWvPSa1VN+x ttzIUaZwKWq951JtrKF3g5hlKY4bYwQdIrh0rp9mmmNzCK1ulIOSNz1aQnzO1B9D55+z z5xjqgkdbXu1FxvK+92WZIPqE/6XO2jesgAG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=X4vUCbZyJ1/CJiuVNPzRZXx6UspNaZqxadNszyTjElM=; b=cFEo1QsDSOsj8FYRwuzOO2MHmDWDavWlPRHdkEu1XITDe2ETA//qtoGdtQQj+nDbOs HVaZG0PJEneMJsssAFaDTG/9/Icmplm0uCCT/C7RF0yQXifmeq9maJmcKfhO8En+LWOf oHqdHyZaiUU3ux5Y1fz6S3LghDVtZfOOZ9db0yPhFMHCnxUTbQwA0a7lEyI3+XbADwt5 n1B6iWBDInTiOi6PeBul1wlDU6GHDMyMe2AsVxdFz1yVdK1/y/pRsnbMrbpKwGh9ow2d wH2joQoWBLnXgnWNcJxhU8tlCsrmCEfEsVqbgxN9mM5+o5vjV3sjtvxw9CTL79ur48jV eesQ== X-Gm-Message-State: AOAM533unL2hW6cEpH71ULEFla1NzT/XT8kJaaWFQiYZyLUFaMDJ9qZE Ssf7kOQpcISMIciNbpu/nwHC6w== X-Google-Smtp-Source: ABdhPJzvA98qUEPUaJPVXtedEF5rKAoJOw1c/CBxkwRdVX+xWolXlj0cCNgVgBA+mX1/y3lk+tCuQA== X-Received: by 2002:a7b:c845:: with SMTP id c5mr5087088wml.135.1605019449854; Tue, 10 Nov 2020 06:44:09 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id v9sm17009623wrp.11.2020.11.10.06.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 06:44:09 -0800 (PST) Date: Tue, 10 Nov 2020 15:44:07 +0100 From: Daniel Vetter To: Jason Gunthorpe Cc: Daniel Vetter , "Xiong, Jianxin" , Leon Romanovsky , "linux-rdma@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Doug Ledford , "Vetter, Daniel" , Christian Koenig Subject: Re: [PATCH v8 1/5] RDMA/umem: Support importing dma-buf as user memory region Message-ID: <20201110144407.GM401619@phenom.ffwll.local> References: <1604616489-69267-1-git-send-email-jianxin.xiong@intel.com> <1604616489-69267-2-git-send-email-jianxin.xiong@intel.com> <20201106000851.GK36674@ziepe.ca> <20201106163953.GR36674@ziepe.ca> <20201110141445.GI401619@phenom.ffwll.local> <20201110142757.GM244516@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201110142757.GM244516@ziepe.ca> X-Operating-System: Linux phenom 5.7.0-1-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org On Tue, Nov 10, 2020 at 10:27:57AM -0400, Jason Gunthorpe wrote: > On Tue, Nov 10, 2020 at 03:14:45PM +0100, Daniel Vetter wrote: > > On Fri, Nov 06, 2020 at 12:39:53PM -0400, Jason Gunthorpe wrote: > > > On Fri, Nov 06, 2020 at 04:34:07PM +0000, Xiong, Jianxin wrote: > > > > > > > > The user could specify a length that is beyond the dma buf, can > > > > > the dma buf length be checked during get? > > > > > > > > In order to check the length, the buffer needs to be mapped. That can be done. > > > > > > Do DMA bufs even have definitate immutable lengths? Going to be a > > > probelm if they can shrink > > > > Yup. Unfortunately that's not document in the structures themselves, > > there's just some random comments sprinkled all over that dma-buf size is > > invariant, e.g. see the @mmap kerneldoc in dma_buf_ops: > > > > https://dri.freedesktop.org/docs/drm/driver-api/dma-buf.html?highlight=dma_buf_ops#c.dma_buf_ops > > > > "Because dma-buf buffers have invariant size over their lifetime, ..." > > > > Jianxin, can you pls do a kerneldoc patch which updates the comment for > > dma_buf.size and dma_buf_export_info.size? > > So we can check the size without doing an attachment? Yeah size should be invariant over the lifetime of the dma_buf (it's also needed for dma_buf_vmap kernel cpu access and dma_buf_mmap userspace mmap forwarding). No lock or attachment needed. But like I said, would be good to have the kerneldoc patch to make this clear. The history here is that the X shm extension suffered badly from resizeable storage object exploits of the X server, this is why both dma-buf (and also drm_gem_buffer_object before that generalization) and memfd are size sealed. -Daniel > That means the flow should be put back to how it was a series or two > ago where the SGL is only attached during page fault with the entire > programming sequence under the resv lock > > Jason -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 86A8BC388F7 for ; Tue, 10 Nov 2020 14:44:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D762E206B2 for ; Tue, 10 Nov 2020 14:44:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="EKf0wqjh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D762E206B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1FA6489B03; Tue, 10 Nov 2020 14:44:12 +0000 (UTC) Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 29D5689B03 for ; Tue, 10 Nov 2020 14:44:11 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id p22so3231267wmg.3 for ; Tue, 10 Nov 2020 06:44:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=X4vUCbZyJ1/CJiuVNPzRZXx6UspNaZqxadNszyTjElM=; b=EKf0wqjhjoi8CDQBN/YapYVcD9ppM8MymSKwgFzwh+6C8G528otoa9GfWvPSa1VN+x ttzIUaZwKWq951JtrKF3g5hlKY4bYwQdIrh0rp9mmmNzCK1ulIOSNz1aQnzO1B9D55+z z5xjqgkdbXu1FxvK+92WZIPqE/6XO2jesgAG0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=X4vUCbZyJ1/CJiuVNPzRZXx6UspNaZqxadNszyTjElM=; b=pyYV1D3Os0eQ1AMm67knoYQLTgTvtcAZ+tzOFUJucLKmXijZoLlNKkYXFEiqYimysp Ns3H0DWWFsHWeeRYNCV71Y+4yzub9eOBNth0tCUeH8V5Hevp0s4+iD3dgIHSDxF1JjOS RjqrY6dO98znJQYN5oa9m8ZZpx8iik0NzL6PiPZaNcU6iVa7rDpbcw+Awqtdr2++n6e7 ETkfC+OFpOQtPR5E5N5x+xOW3/76KMLJKGiE9pRqBmyLwmWgedek3EoiH8XlwMIlGsor ry8H7dxRQqt1LkIbE2e55oqxin9rvxV8iC2ccGdy+T7I/LZXgAL4dSRbHwVruJ89Ywsv FDAA== X-Gm-Message-State: AOAM532iH5FaG1hKX0RVJ9ExUwHnoIQnuBMxsVqLwYHH5ah32HpKuH2A HvMIMjBSUOCTpPMK1hHgKypxlQ== X-Google-Smtp-Source: ABdhPJzvA98qUEPUaJPVXtedEF5rKAoJOw1c/CBxkwRdVX+xWolXlj0cCNgVgBA+mX1/y3lk+tCuQA== X-Received: by 2002:a7b:c845:: with SMTP id c5mr5087088wml.135.1605019449854; Tue, 10 Nov 2020 06:44:09 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id v9sm17009623wrp.11.2020.11.10.06.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 06:44:09 -0800 (PST) Date: Tue, 10 Nov 2020 15:44:07 +0100 From: Daniel Vetter To: Jason Gunthorpe Subject: Re: [PATCH v8 1/5] RDMA/umem: Support importing dma-buf as user memory region Message-ID: <20201110144407.GM401619@phenom.ffwll.local> References: <1604616489-69267-1-git-send-email-jianxin.xiong@intel.com> <1604616489-69267-2-git-send-email-jianxin.xiong@intel.com> <20201106000851.GK36674@ziepe.ca> <20201106163953.GR36674@ziepe.ca> <20201110141445.GI401619@phenom.ffwll.local> <20201110142757.GM244516@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20201110142757.GM244516@ziepe.ca> X-Operating-System: Linux phenom 5.7.0-1-amd64 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leon Romanovsky , "linux-rdma@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , Doug Ledford , "Vetter, Daniel" , Christian Koenig , "Xiong, Jianxin" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Tue, Nov 10, 2020 at 10:27:57AM -0400, Jason Gunthorpe wrote: > On Tue, Nov 10, 2020 at 03:14:45PM +0100, Daniel Vetter wrote: > > On Fri, Nov 06, 2020 at 12:39:53PM -0400, Jason Gunthorpe wrote: > > > On Fri, Nov 06, 2020 at 04:34:07PM +0000, Xiong, Jianxin wrote: > > > > > > > > The user could specify a length that is beyond the dma buf, can > > > > > the dma buf length be checked during get? > > > > > > > > In order to check the length, the buffer needs to be mapped. That can be done. > > > > > > Do DMA bufs even have definitate immutable lengths? Going to be a > > > probelm if they can shrink > > > > Yup. Unfortunately that's not document in the structures themselves, > > there's just some random comments sprinkled all over that dma-buf size is > > invariant, e.g. see the @mmap kerneldoc in dma_buf_ops: > > > > https://dri.freedesktop.org/docs/drm/driver-api/dma-buf.html?highlight=dma_buf_ops#c.dma_buf_ops > > > > "Because dma-buf buffers have invariant size over their lifetime, ..." > > > > Jianxin, can you pls do a kerneldoc patch which updates the comment for > > dma_buf.size and dma_buf_export_info.size? > > So we can check the size without doing an attachment? Yeah size should be invariant over the lifetime of the dma_buf (it's also needed for dma_buf_vmap kernel cpu access and dma_buf_mmap userspace mmap forwarding). No lock or attachment needed. But like I said, would be good to have the kerneldoc patch to make this clear. The history here is that the X shm extension suffered badly from resizeable storage object exploits of the X server, this is why both dma-buf (and also drm_gem_buffer_object before that generalization) and memfd are size sealed. -Daniel > That means the flow should be put back to how it was a series or two > ago where the SGL is only attached during page fault with the entire > programming sequence under the resv lock > > Jason -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel