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=-4.8 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 A0F82C43461 for ; Mon, 14 Sep 2020 13:30:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 23F12206DC for ; Mon, 14 Sep 2020 13:30:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AZo4Zrph" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 23F12206DC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 93B42900008; Mon, 14 Sep 2020 09:30:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8EABE900002; Mon, 14 Sep 2020 09:30:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 764E4900008; Mon, 14 Sep 2020 09:30:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 5E2D8900002 for ; Mon, 14 Sep 2020 09:30:51 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ED596DB58 for ; Mon, 14 Sep 2020 13:30:50 +0000 (UTC) X-FDA: 77261752260.26.ducks55_4507a6b27109 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id BF1501800B458 for ; Mon, 14 Sep 2020 13:30:50 +0000 (UTC) X-HE-Tag: ducks55_4507a6b27109 X-Filterd-Recvd-Size: 4522 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 13:30:50 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id a12so17571365eds.13 for ; Mon, 14 Sep 2020 06:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=MJZms6QlGOYEjnVyjgzH8924ZUFCbrOAjhB8S+SOw0Q=; b=AZo4Zrph06jSQFMyghqg1VeH/uJOLm2FTxlr/lwLz7LcGc0dGWMtJGTGfIa56pfqRD SfHBHsrbfH2iLoCUhK/MZHqrDpM/JA26F/AGyypmlC8llez2CWnSY5tQ3e2HcDw2L9BQ Idd41N3fpgLMR5/YftegmeplJ+0U4knjuLatzRauZq3iLjrWvmUDIVY8+gM3rBhrXqyO 5fAQ4JfxeJMiJ3yLE4UMugQzETfzbzi9LiAlrW8D3PaHaUUg0XX1Gb8R/XnjddNgeN8y hPH3z3PjWYW7jYaLwy++Ij502YqCHABMpErfK7GUyDUDXbvFsj5PDRunJeTmU9KmumUU 4vjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=MJZms6QlGOYEjnVyjgzH8924ZUFCbrOAjhB8S+SOw0Q=; b=VxOew3cm4+GKLbLyxPId6XlwGZyKx/9peuDiK6Ns0ljMWwgis8uKWAgpLgA5Wjrg8h DqmUE9qQUaXd9uGHV9edKkzwMNYwTvy9fgdt9UEF5IZXEZnONOvU6jUe1lNwSppr1GFo bVhY/g1CwG5wli9zy4VEeY0CwpieRg6+/QRnWWXnc00NKS4AbI34+5BEe8NsYsXAYImR +wOKeNLsUG+zh+uXFGIcK1erwDJY9LFwfnBMuDw19yUrr6uQjMpCf3US/eSD8HxK3GXX CS1t8uVOQTRQo/F3K3l1WSrPtfXSmuSCvksJdbJYO1byNp4QZIZQghkzwy8OCho3j1tU OOQg== X-Gm-Message-State: AOAM532wYEwIqmEhyN0cyrRnXsQhsDeit7jbZ1wPxcpaIgiXbVv1qaB9 8FsYRin8G/RZ3jSXgvJgyTw= X-Google-Smtp-Source: ABdhPJwM5ZL8+pefIM8N8Pp/HAs1Da9AhS9+TCqXwmw1+Bfwc5H4UJw/fibBFv4vSEBRyYvPybunNQ== X-Received: by 2002:a50:fb15:: with SMTP id d21mr17942730edq.150.1600090249097; Mon, 14 Sep 2020 06:30:49 -0700 (PDT) Received: from ?IPv6:2a02:908:1252:fb60:be8a:bd56:1f94:86e7? ([2a02:908:1252:fb60:be8a:bd56:1f94:86e7]) by smtp.gmail.com with ESMTPSA id nh1sm7646664ejb.21.2020.09.14.06.30.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 06:30:48 -0700 (PDT) Subject: Re: Changing vma->vm_file in dma_buf_mmap() From: =?UTF-8?Q?Christian_K=c3=b6nig?= To: akpm@linux-foundation.org Cc: sumit.semwal@linaro.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Daniel Vetter References: <20200914132920.59183-1-christian.koenig@amd.com> Message-ID: <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> Date: Mon, 14 Sep 2020 15:30:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200914132920.59183-1-christian.koenig@amd.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: BF1501800B458 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 Content-Transfer-Encoding: quoted-printable 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: Am 14.09.20 um 15:29 schrieb Christian K=C3=B6nig: > Hi Andrew, Sorry forgot to add Daniel as well. > > I'm the new DMA-buf maintainer and Daniel and others came up with patch= es extending the use of the dma_buf_mmap() function. > > Now this function is doing something a bit odd by changing the vma->vm_= file while installing a VMA in the mmap() system call > > The background here is that DMA-buf allows device drivers to export buf= fer which are then imported into another device driver. The mmap() handle= r of the importing device driver then find that the pgoff belongs to the = exporting device and so redirects the mmap() call there. > > In other words user space calls mmap() on one file descriptor, but get = a different one mapped into your virtual address space. > > My question is now: Is that legal or can you think of something which b= reaks here? > > If it's not legal we should probably block any new users of the dma_buf= _mmap() function and consider what should happen with the two existing on= es. > > If that is legal I would like to document this by adding a new vma_set_= file() function which does the necessary reference count dance. > > Thanks in advance, > Christian. > >