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.9 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 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 ED90EC43461 for ; Mon, 14 Sep 2020 14:07:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3D132074B for ; Mon, 14 Sep 2020 14:07:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="a39sUxr3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgINOHf (ORCPT ); Mon, 14 Sep 2020 10:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726800AbgINOGg (ORCPT ); Mon, 14 Sep 2020 10:06:36 -0400 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8796C061788 for ; Mon, 14 Sep 2020 07:06:35 -0700 (PDT) Received: by mail-il1-x141.google.com with SMTP id h2so5680820ilo.12 for ; Mon, 14 Sep 2020 07:06:35 -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=IPlAv7K7895OL8SkHOACzvMwxGjfkNGAYdR8f+5OO8byYFxZlilyxxhMLqYR4antgU ewl6UQMe694jk1tuqFJfi5cv298YYFu80liGox67Q3nSUDPMFF3B0DIoRw75cm8/X1eJ WRLRL+BhV9y5UhNFxP/yFvva7SY/T/4jf2jUa1dfRVpEofPZOHAy1LV7MRWUSu2wxoRn HA+pC64f2XwdfZGNq8L81OZMBysk1C2nLf4DDR1xQwRYz9/xF4jJWBPHdkL+KllXXVmg n5EXCW3V5moso9SojDBSjzB0f3ZKB0mubCHm8RUNCqVDp8tjDS6trsp3bSCkXERYUHwf CAxA== X-Gm-Message-State: AOAM531143aYXXyblcwsT1aINai4aYdhiDw/5Qfs2IbXIjfc7lJlyV+I DMmD3tldw0QSiqQKdDZLh3cR3w== 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 Content-Transfer-Encoding: 8bit In-Reply-To: <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 03:30:47PM +0200, Christian König wrote: > Am 14.09.20 um 15:29 schrieb Christian König: > > 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_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