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 AD017C43461 for ; Mon, 14 Sep 2020 18:26:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1EA8421D7B for ; Mon, 14 Sep 2020 18:26: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="AHU/AtiF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1EA8421D7B 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 45C786B0062; Mon, 14 Sep 2020 14:26:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E7378E0003; Mon, 14 Sep 2020 14:26:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 287E66B0074; Mon, 14 Sep 2020 14:26:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id 0F7526B0062 for ; Mon, 14 Sep 2020 14:26:52 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C11228249980 for ; Mon, 14 Sep 2020 18:26:51 +0000 (UTC) X-FDA: 77262498222.22.cook17_40065e12710a Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 965DC18038E68 for ; Mon, 14 Sep 2020 18:26:51 +0000 (UTC) X-HE-Tag: cook17_40065e12710a X-Filterd-Recvd-Size: 4750 Received: from mail-ej1-f67.google.com (mail-ej1-f67.google.com [209.85.218.67]) by imf40.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 18:26:51 +0000 (UTC) Received: by mail-ej1-f67.google.com with SMTP id gr14so1389008ejb.1 for ; Mon, 14 Sep 2020 11:26:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=rRCccI3O7Q3cBqCSADJ9p4p+tEsMBm/uVKtxbUUahJg=; b=AHU/AtiFLbe3+YZTSiSO41xN3EYAURxPkCRh+hyV2jBoPZbsqwzbhpl0akYfJBMPh2 GdoV/jU0y46ZvoaNtPW5sVRWLONy7foziuLCeS1APrEX8izp6/it+zrdWHvQUOjPECV8 kB7W1+i3+4RQmCjcYSgt8GmVX60YbKXvrYQ935YbMGmcC+Y3RrmejwX9MuUqN/4gxW+w p9wyDOyjmoAnidi0YOCj7SvrMJ4axu2Wgsuk7CwANUckz/Frkghi87fW2cv/ABBYL0YV xb4eWMau1U5Byo4YNt3vlVYn6A8mZH4KW40UkwdZmk/fyI2XhIUesHolLHBTj+uM0sjB W+7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=rRCccI3O7Q3cBqCSADJ9p4p+tEsMBm/uVKtxbUUahJg=; b=GbluptpG+Rq1T01/IDLj9YBRxUEcCZIWFrD/Y2MG4gdzkNeBKEKR50t4jSeGYs0s9V Jef7blnZld4K1XiNdDsRpvU+jvlzY5f6edjnrb7ozQ/cfFTwljjY/UOkh4dRJ4THDijc v6Ye/Ehn9YAKiZb6ytSWZCSJk8QpB6nx1B0wrU8o8j8e4XkUpoNBYA1DN4C9MjqxvyT7 hiHBG5GVgW/QaYbBDfjQJ96zlnnreyhyGaNaiUBHyMSh15ioQFQrx65T9eRq6M6jDP69 wGGUHlkm/mUNBYu2sAZNcbcvPZ61zj6oKrhB7iiPmHaK/feckDuyEgzSv6zzdWHFfoWf SLoA== X-Gm-Message-State: AOAM532hRmCDIzlxt1dwrHhmccOuMFiRq2wgYAQ1JQ6bBvSfrzwWH68/ Cs0lR+9Imq3iFqW8conNCwI= X-Google-Smtp-Source: ABdhPJz2+wxT5cFNCOXfBWV9IOT32aJMuEc+G7OyK+aP3oDWfuWU/cXhqKfbYJVkKAeo1FWAagaPJg== X-Received: by 2002:a17:906:a101:: with SMTP id t1mr15720702ejy.203.1600108009977; Mon, 14 Sep 2020 11:26: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 b6sm9871930eds.46.2020.09.14.11.26.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Sep 2020 11:26:49 -0700 (PDT) Reply-To: christian.koenig@amd.com Subject: Re: Changing vma->vm_file in dma_buf_mmap() To: Jason Gunthorpe 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 References: <20200914132920.59183-1-christian.koenig@amd.com> <40cd26ae-b855-4627-5a13-4dcea5d622f6@gmail.com> <20200914140632.GD1221970@ziepe.ca> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: <9302e4e0-0ff0-8b00-ada1-85feefb49e88@gmail.com> Date: Mon, 14 Sep 2020 20:26: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: <20200914140632.GD1221970@ziepe.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US X-Rspamd-Queue-Id: 965DC18038E68 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 16:06 schrieb Jason Gunthorpe: > 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, >>> >>> 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 Thanks for the hint, going to take a look at that code tomorrow. > What about security? Is it OK that some other random file, maybe in > another process, is being linked to this mmap? Good question, I have no idea. That's why I send out this mail. >>> 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? Yes, absolutely. Christian. > > Jason