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=-6.3 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,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT 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 E939BC43461 for ; Mon, 14 Sep 2020 13:29:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6404B214F1 for ; Mon, 14 Sep 2020 13:29:32 +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="FJYW5Zpk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6404B214F1 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 BAEB5900003; Mon, 14 Sep 2020 09:29:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B5EC4900002; Mon, 14 Sep 2020 09:29:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9FE9E900003; Mon, 14 Sep 2020 09:29:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0104.hostedemail.com [216.40.44.104]) by kanga.kvack.org (Postfix) with ESMTP id 88F9C900002 for ; Mon, 14 Sep 2020 09:29:31 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 3B005289D9 for ; Mon, 14 Sep 2020 13:29:31 +0000 (UTC) X-FDA: 77261748942.10.nerve39_2e0582527109 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin10.hostedemail.com (Postfix) with ESMTP id 06D9C16A4A9 for ; Mon, 14 Sep 2020 13:29:31 +0000 (UTC) X-HE-Tag: nerve39_2e0582527109 X-Filterd-Recvd-Size: 4082 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 13:29:30 +0000 (UTC) Received: by mail-ed1-f49.google.com with SMTP id n22so17628520edt.4 for ; Mon, 14 Sep 2020 06:29:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O337qWgiQtRxWseaQqzKcsApKROYygDiI0vsqDOyWvw=; b=FJYW5Zpkr+69Ontc35YOWyp+mL3+YJfwB6//npnOq0Ga13hSRTyG9rqdWj4+XoSTwl 0uaNEpWiH5ReO87er2LlifBH3NPFWwDgSJtyPPqhcyG9S/rx7NEmE2AK4OmD6az3c7DC ECmjZ+seRByPUAp7C5IfbE7h8FYRsyZttir92Zt789sOyIpU3j3rWB5nvqqs7dr7cMO7 peRappoBTy37hf78g1FzRQmgX/YXKNbYhx8gcXWfsYlOOW3rf6mbLtBBMJyHEnWS3jjd 9WjyGB1FJEwRD3WS9vt6zSYCrduQ5EHUPtPT6cB1Pg5lJ5U61W3Gr9AcU4++WYHupOt9 R9ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=O337qWgiQtRxWseaQqzKcsApKROYygDiI0vsqDOyWvw=; b=LW40UXbcDCiuXpl6XSphkBApXjswbW0iD22NVVYHhhkXaD2vFcctgJViMwSACVPdv3 MnTaal6ORupMinDvT7wN0q0ZlUiMFJYuBqiIOC6QokFIxNo+AtLyfIkGhEApCW8HEiAQ EbQLKnJ8avlVcJKtZq0VxDTEr8kA0cIbfbsobINa+mwl3PPwhSGolTvWLXwBUX4mN/6d 8b73Yx/NaSw+hlue3gHdeyxwpkiLEor5+HgmQtfinRq0nZ1gY6n3THTlADBVb29g1z+x xUdk5dIg0ThRxALoOh5euRKgF5NMfeaK7ehzUVaQuERqOI/FCDEaWIp49EE3fyVGY01t GuFQ== X-Gm-Message-State: AOAM532pU9sLwXjKH/iRzfiOMqQc2xqGc3A6b57c1e4Je+BtA+NhjQgX /5Sxs+9v3AJV9eSv8A39ZZU= X-Google-Smtp-Source: ABdhPJwJsiXZY3KpcwY1vzYkVg2ohf4EGDVpkoGXaNUtWvR8WeUIIoXfyp3ei6G37Iy9uvNZbC5ExA== X-Received: by 2002:aa7:d78f:: with SMTP id s15mr16965480edq.322.1600090169251; Mon, 14 Sep 2020 06:29:29 -0700 (PDT) Received: from abel.fritz.box ([2a02:908:1252:fb60:6179:d701:8021:da3d]) by smtp.gmail.com with ESMTPSA id d6sm9575625edm.31.2020.09.14.06.29.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 06:29:28 -0700 (PDT) From: "=?UTF-8?q?Christian=20K=C3=B6nig?=" X-Google-Original-From: =?UTF-8?q?Christian=20K=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 Subject: Changing vma->vm_file in dma_buf_mmap() Date: Mon, 14 Sep 2020 15:29:18 +0200 Message-Id: <20200914132920.59183-1-christian.koenig@amd.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Rspamd-Queue-Id: 06D9C16A4A9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000335, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Andrew, I'm the new DMA-buf maintainer and Daniel and others came up with patches= extending the use of the dma_buf_mmap() function. Now this function is doing something a bit odd by changing the vma->vm_fi= le while installing a VMA in the mmap() system call The background here is that DMA-buf allows device drivers to export buffe= r which are then imported into another device driver. The mmap() handler = of the importing device driver then find that the pgoff belongs to the ex= porting 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 bre= aks here? If it's not legal we should probably block any new users of the dma_buf_m= map() function and consider what should happen with the two existing ones= . If that is legal I would like to document this by adding a new vma_set_fi= le() function which does the necessary reference count dance. Thanks in advance, Christian.