Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp676944pxk; Wed, 16 Sep 2020 14:10:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQ0CHp1fd5Uk+/O5MVnmtJjiTftnbKVayPiFJ/qaceQIpYp3b0G0t9BcqF8Rc+Wt5qJz0n X-Received: by 2002:a17:906:556:: with SMTP id k22mr26829183eja.369.1600290607595; Wed, 16 Sep 2020 14:10:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600290607; cv=none; d=google.com; s=arc-20160816; b=dr/K9AORbuwzz6pupkp4QawVSF+7g/nGrTutnrD8zEHpMwiWkSHd6B5VAtPcdB65Xd RiK5d7DrvW+4mI5RTzCtmXJznSbjhKF5Mx3ULqsNErq5bp1Vlo3DIxd3s6tKScouTMYA Wlnskyy0YMkM/IyHqNCzb5+TIOGAOvZiNwIerQ1PVo6/aqR5YHiMMn0HoJEkHoCoDsYK qTz+CZnOjC/gocTSaBEwEvpVznAbBfyMsLynWci/tf9HruUoNzHucnNDvX6HLlcXcQZs DtTwSAOnWpyd5b3o6muNCvm1MdIYN+JzQ/jzg0PwPnbcc8M0UXb+3ZaboxVFnP6xuVZf iwkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=8V25O9GYxPP08UjsTrSAXuZaUN2B3+YItzTAVwD6sSg=; b=fzEs5ne9FvAi+i9xk1dm2s+9LIRS1FDlMoHlyX1YVXqKvOIpetFzE2GKOxvYv5XuMi oGssz+muvtWTilBxWBXsnaq7xTjqTipQUSSUpglrxQXb8g5bs3vS6zbSEghqNnI0zARw 7+ax9WYsQAv8t7k2czx7FY3J85ZWQwDNY9MWzinDiCDtLXoBMMgeXkEP9pUkVe8JSosd V8SwkfSmI96A3IbykRigX8wO0orfdjkflJZrkIHc+zHXaLi4B1dBPeNT3w6ViMrH0nXa OVfVBEdXWD7hnniZ1gGja8XEThpOTn/TaSrsDmay4kZl8j3WXo97yXN6QFr987fJ+7Jv UQvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=esGUjUoG; 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 z13si9533032edx.167.2020.09.16.14.09.44; Wed, 16 Sep 2020 14:10:07 -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=esGUjUoG; 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 S1726159AbgIPVIs (ORCPT + 99 others); Wed, 16 Sep 2020 17:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726456AbgIPQDj (ORCPT ); Wed, 16 Sep 2020 12:03:39 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EEDDBC02C2A2 for ; Wed, 16 Sep 2020 08:24:17 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id y5so7073591otg.5 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=BQtzhLkCKK+PRRO+cS7V+X5V5kTrFEnmGKZpnipU4E2JBcUf+/CJZADfHxMWWnRvRK VLTg39M+9UKZ6EK9hRl6qe3eFpzrLvxGr8t6/dVeq1Gzf+7tBeFlpFQYKLUKM9VKuYgz JiT8Dl5dWrG2x2rPVDYMzXM/0ATEcjosKHBQyEZag9VH9sPpi/8RW9wd3rcnZFTitsGV TOVx9kA6Xs6MfM1A14pxn7992mNi3eGv0cBKC12Ofux2fsCYkam48aHmr1PE7Vv9jKW3 A+EDIu8Nm7wB5/VAY7uJKR2d9ksTVbI8d+tI+a7YBF+msFPB0VNC477BHxE/TGSNM+qu cTqA== X-Gm-Message-State: AOAM5339FxVupvAbmXs7tt2/cMpLPpWO7/KbF8ShsFfy3ctkbuOaEl3Z 7uskZmp4o5KlzI8MGiuFSz5gTwP1qlWEvducrTSlC0ws1jPuyg== 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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