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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 C359DC43461 for ; Mon, 14 Sep 2020 14:06:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 27D2220E65 for ; Mon, 14 Sep 2020 14:06:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="a39sUxr3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27D2220E65 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 669A96B0068; Mon, 14 Sep 2020 10:06:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61B436B006C; Mon, 14 Sep 2020 10:06:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 509DC6B006E; Mon, 14 Sep 2020 10:06:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0160.hostedemail.com [216.40.44.160]) by kanga.kvack.org (Postfix) with ESMTP id 3B53D6B0068 for ; Mon, 14 Sep 2020 10:06:52 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DE1CC18041CE2 for ; Mon, 14 Sep 2020 14:06:51 +0000 (UTC) X-FDA: 77261843022.16.pet44_56013fb27109 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id D909D1003CA93 for ; Mon, 14 Sep 2020 14:06:43 +0000 (UTC) X-HE-Tag: pet44_56013fb27109 X-Filterd-Recvd-Size: 4365 Received: from mail-il1-f194.google.com (mail-il1-f194.google.com [209.85.166.194]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 14:06:36 +0000 (UTC) Received: by mail-il1-f194.google.com with SMTP id y9so9042542ilq.2 for ; Mon, 14 Sep 2020 07:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=1e7EGdpnwDvG5r/s0x2CkKUWWFCbx737ZFsalB8mkco=; b=a39sUxr3jeP/BLuXvYZo5sQYTUREOKDSpSwalRJaZBhMGYM+lo31MmddPsUALNOng5 /pZZXE7TPZHU3Szy3pZ0M+Y7rQU5RZzpYMQik6eioTzucTKTD+y67pI5dGdksh+4k+fZ YrXO59uQCWgPiDFnRS4rhoWXqM0kmjSKBsbv15/QISxk14r7m+ZcNfvQ/z6PVkxyIoJy UbnYIurXjHDP+sSpVVlq9lVeKT91leZtIS+xsjXHznwlopScLnrz8829U/bsElTDP4YP /IGmxLr/+zpukVDvwgZ00Fe6hMFMlGuwgSNLlOKiT95ofedRBEkBwZuwNBkv2+haVnAW jlaQ== 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:content-transfer-encoding :in-reply-to; bh=1e7EGdpnwDvG5r/s0x2CkKUWWFCbx737ZFsalB8mkco=; b=HZEgJohdZcHwt+IYKVMT5zktUKXmTQRTyd8hNYy8zpoJOf8uPgUeHFA96Ah97ZnTuT +Ye6nwJW+zfmwIJLXDJ4KQn4JHweNFZDfBWduDHQICNFdHq6N9rV0Ru6Jk0DnBzk5imq RxZWFni9/6K3wPS4Z/L/9ESikyO5jw7yOHe9qC5X7JerOIcpJnJ6ni+w3EPx2iGWAKPN 1eE2aO6QMbAMPIGaD/PLm1jMK9Q8ZtDyBvPFmYM3HNBz12niej7Sj0j5QK2FfnhZD5GS xiEleTJ1cBCnE7AfsXta1AKrrWX6IZNAWCKYa27c7cBEU/FZLXrWBhyOjDCBc+YLeYSO c9wg== X-Gm-Message-State: AOAM5319Pbu5eCJszvA4n++8t638iyfZZuZeIXGkO/RICFgZ5w+OLfyp 4nhhM40Zs4IJrxAd/l8xPyG5DA== X-Google-Smtp-Source: ABdhPJyF/sDYVopZg/BDQqrwTkESVkwSEOqsuOwDOcgGLzbWX7RzPa41tgaMCaw6uC7C6w4gVaxWqg== X-Received: by 2002:a05:6e02:5a5:: with SMTP id k5mr11987669ils.28.1600092394945; Mon, 14 Sep 2020 07:06:34 -0700 (PDT) Received: from ziepe.ca ([206.223.160.26]) by smtp.gmail.com with ESMTPSA id v14sm5988511iol.17.2020.09.14.07.06.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Sep 2020 07:06:34 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kHp7o-005y7Z-Sl; Mon, 14 Sep 2020 11:06:32 -0300 Date: Mon, 14 Sep 2020 11:06:32 -0300 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: akpm@linux-foundation.org, 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 Subject: Re: Changing vma->vm_file in dma_buf_mmap() Message-ID: <20200914140632.GD1221970@ziepe.ca> References: <20200914132920.59183-1-christian.koenig@amd.com> <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> X-Rspamd-Queue-Id: D909D1003CA93 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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: On Mon, Sep 14, 2020 at 03:30:47PM +0200, Christian K=C3=B6nig wrote: > Am 14.09.20 um 15:29 schrieb Christian K=C3=B6nig: > > Hi Andrew, > >=20 > > I'm the new DMA-buf maintainer and Daniel and others came up with > > patches extending the use of the dma_buf_mmap() function. > >=20 > > Now this function is doing something a bit odd by changing the > > vma->vm_file while installing a VMA in the mmap() system call It doesn't look obviously safe as mmap_region() has an interesting mix of file and vma->file Eg it calls mapping_unmap_writable() using both routes What about security? Is it OK that some other random file, maybe in another process, is being linked to this mmap? > > The background here is that DMA-buf allows device drivers to > > export buffer which are then imported into another device > > driver. The mmap() handler of the importing device driver then > > find that the pgoff belongs to the exporting device and so > > redirects the mmap() call there. So the pgoff is some virtualized thing? Jason