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 3139BC43461 for ; Wed, 16 Sep 2020 15:29:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 43D7F223E4 for ; Wed, 16 Sep 2020 15:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="esGUjUoG" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43D7F223E4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6B87C8E0001; Wed, 16 Sep 2020 11:29:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 668CC6B006E; Wed, 16 Sep 2020 11:29:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 557438E0001; Wed, 16 Sep 2020 11:29:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0020.hostedemail.com [216.40.44.20]) by kanga.kvack.org (Postfix) with ESMTP id 3D1CB6B006C for ; Wed, 16 Sep 2020 11:29:19 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id B606E181AEF15 for ; Wed, 16 Sep 2020 15:29:18 +0000 (UTC) X-FDA: 77269308396.17.wire93_4b1619a2711a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id E44C3180CF60B for ; Wed, 16 Sep 2020 15:24:18 +0000 (UTC) X-HE-Tag: wire93_4b1619a2711a X-Filterd-Recvd-Size: 5444 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf39.hostedemail.com (Postfix) with ESMTP for ; Wed, 16 Sep 2020 15:24:18 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id o6so7083267ota.2 for ; Wed, 16 Sep 2020 08:24:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=8V25O9GYxPP08UjsTrSAXuZaUN2B3+YItzTAVwD6sSg=; b=esGUjUoGlLjSkji8zHSk6CikzTaVw9WkEHVQsTXY8XGY5G0ETObzGADcSR1/+09WH0 hF6/mPOLMGiLYfQETJ/ZudzDM17jV3+nhUaIO8GKCyhVG1PeNxTpmeh7CIIK8iLV7hTP v5VNVp+D32yvBdNdVY15b50wKe6sKtHVPV0ZI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=8V25O9GYxPP08UjsTrSAXuZaUN2B3+YItzTAVwD6sSg=; b=HXDJA0GMNhIVl4jAxFdeIV5ecQpA7Kz8+JmHFmxM4mNJQWqCY3+Kf7rT49CLD0HX10 oXvxJ+unj6eWmLMTgrpdOfjgn9pUD423Md1nBbIvBOYn0FNYh3AhNS8nZrE+dai9j5rL mgqbBs7WiBsWPtdBdKYo+FgPwCT0X+kPDqkz7x5QfxQS883PCRtMePKxxPuBEPfcfEjJ Ghqx+6EIh+3axY4z82HMKN/ATfDikI1OomC4h95oqFYv9phhJRxSDHvKyh2wF3nE13Oq AhlLCrPiY+IVIsV8dDBEU/hQB4bv6/vGVgRMOkPQxxuWFXWvhVMQAWhVAarCijEdKjT+ 6hGA== X-Gm-Message-State: AOAM531cEEAA6hRRaWeA3LvvO3AlOoulNfP1mr3w39A0ViJAQfbd7fVm NmeTOYLNXiK1/qvIMU8CGY2Xqv4ugdNSBbemVNJNrg== X-Google-Smtp-Source: ABdhPJzFIEzlayJbc8puDrgbDGaqrIK0mzqobwQtMVJQV/1fuTdhXaLAYKepB1sf6n0KyI9HMzUVHL2sC9vrHl1co8M= X-Received: by 2002:a9d:4b99:: with SMTP id k25mr17762932otf.281.1600269857273; Wed, 16 Sep 2020 08:24:17 -0700 (PDT) MIME-Version: 1.0 References: <20200914132920.59183-1-christian.koenig@amd.com> <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> <20200914140632.GD1221970@ziepe.ca> <9302e4e0-0ff0-8b00-ada1-85feefb49e88@gmail.com> <20200916095359.GD438822@phenom.ffwll.local> <20200916140710.GA8409@ziepe.ca> <8db2474f-ecb7-0e17-5f5b-145708fe44d5@amd.com> In-Reply-To: <8db2474f-ecb7-0e17-5f5b-145708fe44d5@amd.com> From: Daniel Vetter Date: Wed, 16 Sep 2020 17:24:06 +0200 Message-ID: Subject: Re: Changing vma->vm_file in dma_buf_mmap() To: =?UTF-8?Q?Christian_K=C3=B6nig?= Cc: Jason Gunthorpe , Andrew Morton , Sumit Semwal , "open list:DMA BUFFER SHARING FRAMEWORK" , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Linux Kernel Mailing List , Linux MM Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: E44C3180CF60B X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 16, 2020 at 4:14 PM Christian K=C3=B6nig wrote: > > Am 16.09.20 um 16:07 schrieb Jason Gunthorpe: > > On Wed, Sep 16, 2020 at 11:53:59AM +0200, Daniel Vetter wrote: > > > >> But within the driver, we generally need thousands of these, and that > >> tends to bring fd exhaustion problems with it. That's why all the priv= ate > >> buffer objects which aren't shared with other process or other drivers= are > >> handles only valid for a specific fd instance of the drm chardev (each > >> open gets their own namespace), and only for ioctls done on that chard= ev. > >> And for mmap we assign fake (but unique across all open fd on it) offs= ets > >> within the overall chardev. Hence all the pgoff mangling and re-mangli= ng. > > Are they still unique struct files? Just without a fdno? > > Yes, exactly. Not entirely, since dma-buf happened after drm chardev, so for that historical reason the underlying struct file is shared, since it's the drm chardev. But since that's per-device we don't have a problem in practice with different vm_ops, since those are also per-device. But yeah we could fish out some entirely hidden per-object struct file if that's required for some mm internal reasons. -Daniel > >> Hence why we'd like to be able to forward aliasing mappings and adjust= the > >> file and pgoff, while hopefully everything keeps working. I thought th= is > >> would work, but Christian noticed it doesn't really. > > It seems reasonable to me that the dma buf should be the owner of the > > VMA, otherwise like you say, there is a big mess attaching the custom > > vma ops and what not to the proper dma buf. > > > > I don't see anything obviously against this in mmap_region() - why did > > Chritian notice it doesn't really work? > > To clarify I think this might work. > > I just had the same "Is that legal?", "What about security?", etc.. > questions you raised as well. > > It seems like a source of trouble so I thought better ask somebody more > familiar with that. > > Christian. > > > > > Jason > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel --=20 Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch