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.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 37301C4363D for ; Wed, 7 Oct 2020 14:12:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BF6AD2076C for ; Wed, 7 Oct 2020 14:12:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d8LN7dGO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728605AbgJGOMS (ORCPT ); Wed, 7 Oct 2020 10:12:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728467AbgJGOMR (ORCPT ); Wed, 7 Oct 2020 10:12:17 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3558BC061755 for ; Wed, 7 Oct 2020 07:12:17 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id 33so2295324edq.13 for ; Wed, 07 Oct 2020 07:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFB+tdyXOtCPNmNlbyeGl25fBeChj1S+VT6tzzLEZ78=; b=d8LN7dGO3Ag/inP5rvlWv5j43byrHe3f2u6a2r5SiIA/iuBN1VvbkR0plJSfSgqBlh Xu6ol8DY8sIaLVYX8C/ptKWjmAW3b06V+W6maw4cEpyWOcxb/M9F7iw98CO5YNTALD0W RHBCozGcvxlKPGX6uoYJpCQxNytt1WigBKfUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFB+tdyXOtCPNmNlbyeGl25fBeChj1S+VT6tzzLEZ78=; b=giR4YYf5Ifox8BNnBn4/ked50ZNk9aaJvqiSaMzSAOBHKAbEC5RJJPhDbb6eI5vikW QOW6fllHDoeK9PD9lq87pFOBlS76uWJay/R7D57zhM0ywZ4pXcJybcMw7cl+y2ey33Ws 68Qz/Bm5nA/LIj9EtGghITWI0Gx/2twEHA8S49P8+eCO1yLt2CuQMWWrX1KJIhQiZ8oz O7SKx7TqQuAf367lQvXpaYhw/sj2NZph31M1HjKUkwEk8D0bKm4enkuHc21Yvb2AE/R0 AcjfrSAcYomIhzsO1+MoKltKAgZKrEpDRMfAdbRDca5cJpQge4kjyvYxE0S2yGNWFI0l SD1A== X-Gm-Message-State: AOAM533wLMBf4q0NbgHpGkvD3M7rTeusPz0+yv/ianzq1o1ga6bIH6PF nWQ4ZQPf56Z+USdekhG71ox5oiNZ8xiB7w== X-Google-Smtp-Source: ABdhPJyySoCBiF9GnQSPM30BSpSehuI6nB7PEEAQlRcx5gX730g1jFusIOWoKruyIMiEZdF6WpBAcw== X-Received: by 2002:a05:6402:44c:: with SMTP id p12mr3664368edw.157.1602079934664; Wed, 07 Oct 2020 07:12:14 -0700 (PDT) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com. [209.85.128.47]) by smtp.gmail.com with ESMTPSA id j22sm1408180edp.77.2020.10.07.07.12.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Oct 2020 07:12:13 -0700 (PDT) Received: by mail-wm1-f47.google.com with SMTP id d81so2491191wmc.1 for ; Wed, 07 Oct 2020 07:12:12 -0700 (PDT) X-Received: by 2002:a1c:8057:: with SMTP id b84mr3494264wmd.116.1602079932144; Wed, 07 Oct 2020 07:12:12 -0700 (PDT) MIME-Version: 1.0 References: <20201002233118.GM9916@ziepe.ca> <725819e9-4f07-3f04-08f8-b6180406b339@samsung.com> <20201007124409.GN5177@ziepe.ca> <20201007130610.GP5177@ziepe.ca> In-Reply-To: From: Tomasz Figa Date: Wed, 7 Oct 2020 16:11:59 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Daniel Vetter Cc: Jason Gunthorpe , Marek Szyprowski , DRI Development , LKML , Daniel Vetter , Andrew Morton , John Hubbard , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Dan Williams , Linux MM , Linux ARM , Pawel Osciak , Kyungmin Park , Inki Dae , Joonyoung Shim , Seung-Woo Kim , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , Oded Gabbay Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 7, 2020 at 4:09 PM Daniel Vetter wrote: > > On Wed, Oct 7, 2020 at 3:34 PM Tomasz Figa wrote: > > > > On Wed, Oct 7, 2020 at 3:06 PM Jason Gunthorpe wrote: > > > > > > On Wed, Oct 07, 2020 at 02:58:33PM +0200, Daniel Vetter wrote: > > > > On Wed, Oct 7, 2020 at 2:48 PM Tomasz Figa wrote: > > > > > > > > > > On Wed, Oct 7, 2020 at 2:44 PM Jason Gunthorpe wrote: > > > > > > > > > > > > On Wed, Oct 07, 2020 at 02:33:56PM +0200, Marek Szyprowski wrote: > > > > > > > Well, it was in vb2_get_vma() function, but now I see that it has been > > > > > > > lost in fb639eb39154 and 6690c8c78c74 some time ago... > > > > > > > > > > > > There is no guarentee that holding a get on the file says anthing > > > > > > about the VMA. This needed to check that the file was some special > > > > > > kind of file that promised the VMA layout and file lifetime are > > > > > > connected. > > > > > > > > > > > > Also, cloning a VMA outside the mm world is just really bad. That > > > > > > would screw up many assumptions the drivers make. > > > > > > > > > > > > If it is all obsolete I say we hide it behind a default n config > > > > > > symbol and taint the kernel if anything uses it. > > > > > > > > > > > > Add a big comment above the follow_pfn to warn others away from this > > > > > > code. > > > > > > > > > > Sadly it's just verbally declared as deprecated and not formally noted > > > > > anyway. There are a lot of userspace applications relying on user > > > > > pointer support. > > > > > > > > userptr can stay, it's the userptr abuse for zerocpy buffer sharing > > > > which doesn't work anymore. At least without major surgery (you'd need > > > > an mmu notifier to zap mappings and recreate them, and that pretty > > > > much breaks the v4l model of preallocating all buffers to make sure we > > > > never underflow the buffer queue). And static mappings are not coming > > > > back I think, we'll go ever more into the direction of dynamic > > > > mappings and moving stuff around as needed. > > > > > > Right, and to be clear, the last time I saw a security flaw of this > > > magnitude from a subsystem badly mis-designing itself, Linus's > > > knee-jerk reaction was to propose to remove the whole subsystem. > > > > > > Please don't take status-quo as acceptable, V4L community has to work > > > to resolve this, uABI breakage or not. The follow_pfn related code > > > must be compiled out of normal distro kernel builds. > > > > I think the userptr zero-copy hack should be able to go away indeed, > > given that we now have CMA that allows having carveouts backed by > > struct pages and having the memory represented as DMA-buf normally. > > Not sure whether there's a confusion here: dma-buf supports memory not > backed by struct page. > That's new to me. The whole API relies on sg_tables a lot, which in turn rely on struct page pointers to describe the physical memory. > > How about the regular userptr use case, though? > > > > The existing code resolves the user pointer into pages by following > > the get_vaddr_frames() -> frame_vector_to_pages() -> > > sg_alloc_table_from_pages() / vm_map_ram() approach. > > get_vaddr_frames() seems to use pin_user_pages() behind the scenes if > > the vma is not an IO or a PFNMAP, falling back to follow_pfn() > > otherwise. > > Yeah pin_user_pages is fine, it's just the VM_IO | VM_PFNMAP vma that > don't work. Ack. > > > > Is your intention to drop get_vaddr_frames() or we could still keep > > using it and if vec->is_pfns is true: > > a) if CONFIG_VIDEO_LEGACY_PFN_USERPTR is set, taint the kernel > > b) otherwise just undo and fail? > > I'm typing that patch series (plus a pile more) right now. Cool, thanks! We also need to bring back the vma_open() that somehow disappeared around 4.2, as Marek found. Best regards, Tomasz 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.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 2A9CCC4363D for ; Wed, 7 Oct 2020 14:13:36 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A408F20870 for ; Wed, 7 Oct 2020 14:13:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JcziqPvx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d8LN7dGO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A408F20870 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PbIpgPpaj4fx85G7jur4oZOlaXGcSDnBftjV9J+8gyg=; b=JcziqPvxmPwIPOptGVsE7UtNe rlCGtQPcmx5PcX6TGu5W6+Lau2fJTkktpnkZ3vlqhKZfEC2gYNOlwDgUs2xHohJOOWhuUfWyKo1pk 2Kj5T2MxFtrvKrI/s/+GhPUrv+Jb5DtjSbpHSbokvJCazFfDvgmhwwvWSaIpxp4EuJ4h7KyGJ9IP5 7cEnTKHyLMWGsWE+9MukmLTZs7UeUiK1gypgKCva/9c5fqXEM8nf6PkBxPMWvk3wzUlJlvQFDXa7E N11DBPFSCmdGPUOSkNV27Z93BDhBUPMPiCeEDCVjawpa/dn3lX0AjZRsCvJkpEVFByAZpWQGb66QN ke1VL52Qg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQAB1-00026K-KI; Wed, 07 Oct 2020 14:12:19 +0000 Received: from mail-ed1-x542.google.com ([2a00:1450:4864:20::542]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQAAz-00025E-7u for linux-arm-kernel@lists.infradead.org; Wed, 07 Oct 2020 14:12:18 +0000 Received: by mail-ed1-x542.google.com with SMTP id l16so2337991eds.3 for ; Wed, 07 Oct 2020 07:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFB+tdyXOtCPNmNlbyeGl25fBeChj1S+VT6tzzLEZ78=; b=d8LN7dGO3Ag/inP5rvlWv5j43byrHe3f2u6a2r5SiIA/iuBN1VvbkR0plJSfSgqBlh Xu6ol8DY8sIaLVYX8C/ptKWjmAW3b06V+W6maw4cEpyWOcxb/M9F7iw98CO5YNTALD0W RHBCozGcvxlKPGX6uoYJpCQxNytt1WigBKfUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFB+tdyXOtCPNmNlbyeGl25fBeChj1S+VT6tzzLEZ78=; b=UU+Xzfz7GNNMsj5I6YsudPSr3dBY3yWUhJWCOKDbzGTJjf8EkO+qINmE449Y3977dc A+dHhI3aSWFIPlImT92ctgaQYy4vScKq3cEeK3AiNnAmXRaG7UjNNXgFRi7kIozi/2dN rOsEBSAkaT2Y/2NMEYAga+tc/SP/Iv7KCiKWcKTVi/0jL7VW4RszTEftRVfvxWBHUh48 ecPdnddGAUAfFs7ezzgHqeHo91IHeqb4fx/y0cFADNcBrfhazDoaSKjP+XpeSkH8A+6M 1Da1CAHT+KpAuBfRnt5gAr2Gr17tLbD9rAWK0TEXs64UdQ0eetFg91Ic1waXm93v0G4k izhQ== X-Gm-Message-State: AOAM532ObnCvIDpMq7FUCVfIoXvrs1Apwaxnq25Tt5YH6tNCadncKTK3 XeP5S9CyQNESfq0NNxdRijmGjHvuqTZxww== X-Google-Smtp-Source: ABdhPJzErHLRI50ptyglci426i3W0tRuBTWO1R5dT7NqrXVcdV/RaV+EMEUNowVekh9y50iBcIHxWw== X-Received: by 2002:a50:8d48:: with SMTP id t8mr3862551edt.228.1602079934755; Wed, 07 Oct 2020 07:12:14 -0700 (PDT) Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com. [209.85.128.48]) by smtp.gmail.com with ESMTPSA id g18sm1589127eje.12.2020.10.07.07.12.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Oct 2020 07:12:13 -0700 (PDT) Received: by mail-wm1-f48.google.com with SMTP id l11so2492451wmh.2 for ; Wed, 07 Oct 2020 07:12:12 -0700 (PDT) X-Received: by 2002:a1c:8057:: with SMTP id b84mr3494264wmd.116.1602079932144; Wed, 07 Oct 2020 07:12:12 -0700 (PDT) MIME-Version: 1.0 References: <20201002233118.GM9916@ziepe.ca> <725819e9-4f07-3f04-08f8-b6180406b339@samsung.com> <20201007124409.GN5177@ziepe.ca> <20201007130610.GP5177@ziepe.ca> In-Reply-To: From: Tomasz Figa Date: Wed, 7 Oct 2020 16:11:59 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Daniel Vetter X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_101217_327495_ED947EAB X-CRM114-Status: GOOD ( 39.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Oded Gabbay , Inki Dae , linux-samsung-soc , Jan Kara , Joonyoung Shim , Pawel Osciak , Linux MM , John Hubbard , Seung-Woo Kim , LKML , DRI Development , Kyungmin Park , Jason Gunthorpe , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter , Andrew Morton , "open list:DMA BUFFER SHARING FRAMEWORK" , Dan Williams , Linux ARM , Marek Szyprowski Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 7, 2020 at 4:09 PM Daniel Vetter wrote: > > On Wed, Oct 7, 2020 at 3:34 PM Tomasz Figa wrote: > > > > On Wed, Oct 7, 2020 at 3:06 PM Jason Gunthorpe wrote: > > > > > > On Wed, Oct 07, 2020 at 02:58:33PM +0200, Daniel Vetter wrote: > > > > On Wed, Oct 7, 2020 at 2:48 PM Tomasz Figa wrote: > > > > > > > > > > On Wed, Oct 7, 2020 at 2:44 PM Jason Gunthorpe wrote: > > > > > > > > > > > > On Wed, Oct 07, 2020 at 02:33:56PM +0200, Marek Szyprowski wrote: > > > > > > > Well, it was in vb2_get_vma() function, but now I see that it has been > > > > > > > lost in fb639eb39154 and 6690c8c78c74 some time ago... > > > > > > > > > > > > There is no guarentee that holding a get on the file says anthing > > > > > > about the VMA. This needed to check that the file was some special > > > > > > kind of file that promised the VMA layout and file lifetime are > > > > > > connected. > > > > > > > > > > > > Also, cloning a VMA outside the mm world is just really bad. That > > > > > > would screw up many assumptions the drivers make. > > > > > > > > > > > > If it is all obsolete I say we hide it behind a default n config > > > > > > symbol and taint the kernel if anything uses it. > > > > > > > > > > > > Add a big comment above the follow_pfn to warn others away from this > > > > > > code. > > > > > > > > > > Sadly it's just verbally declared as deprecated and not formally noted > > > > > anyway. There are a lot of userspace applications relying on user > > > > > pointer support. > > > > > > > > userptr can stay, it's the userptr abuse for zerocpy buffer sharing > > > > which doesn't work anymore. At least without major surgery (you'd need > > > > an mmu notifier to zap mappings and recreate them, and that pretty > > > > much breaks the v4l model of preallocating all buffers to make sure we > > > > never underflow the buffer queue). And static mappings are not coming > > > > back I think, we'll go ever more into the direction of dynamic > > > > mappings and moving stuff around as needed. > > > > > > Right, and to be clear, the last time I saw a security flaw of this > > > magnitude from a subsystem badly mis-designing itself, Linus's > > > knee-jerk reaction was to propose to remove the whole subsystem. > > > > > > Please don't take status-quo as acceptable, V4L community has to work > > > to resolve this, uABI breakage or not. The follow_pfn related code > > > must be compiled out of normal distro kernel builds. > > > > I think the userptr zero-copy hack should be able to go away indeed, > > given that we now have CMA that allows having carveouts backed by > > struct pages and having the memory represented as DMA-buf normally. > > Not sure whether there's a confusion here: dma-buf supports memory not > backed by struct page. > That's new to me. The whole API relies on sg_tables a lot, which in turn rely on struct page pointers to describe the physical memory. > > How about the regular userptr use case, though? > > > > The existing code resolves the user pointer into pages by following > > the get_vaddr_frames() -> frame_vector_to_pages() -> > > sg_alloc_table_from_pages() / vm_map_ram() approach. > > get_vaddr_frames() seems to use pin_user_pages() behind the scenes if > > the vma is not an IO or a PFNMAP, falling back to follow_pfn() > > otherwise. > > Yeah pin_user_pages is fine, it's just the VM_IO | VM_PFNMAP vma that > don't work. Ack. > > > > Is your intention to drop get_vaddr_frames() or we could still keep > > using it and if vec->is_pfns is true: > > a) if CONFIG_VIDEO_LEGACY_PFN_USERPTR is set, taint the kernel > > b) otherwise just undo and fail? > > I'm typing that patch series (plus a pile more) right now. Cool, thanks! We also need to bring back the vma_open() that somehow disappeared around 4.2, as Marek found. Best regards, Tomasz _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 B86BCC4363D for ; Wed, 7 Oct 2020 14:12:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4048D2076C for ; Wed, 7 Oct 2020 14:12:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="d8LN7dGO" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4048D2076C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 167016E8F5; Wed, 7 Oct 2020 14:12:16 +0000 (UTC) Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by gabe.freedesktop.org (Postfix) with ESMTPS id AE58B6E8F5 for ; Wed, 7 Oct 2020 14:12:14 +0000 (UTC) Received: by mail-ej1-x641.google.com with SMTP id ce10so3173494ejc.5 for ; Wed, 07 Oct 2020 07:12:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=YFB+tdyXOtCPNmNlbyeGl25fBeChj1S+VT6tzzLEZ78=; b=d8LN7dGO3Ag/inP5rvlWv5j43byrHe3f2u6a2r5SiIA/iuBN1VvbkR0plJSfSgqBlh Xu6ol8DY8sIaLVYX8C/ptKWjmAW3b06V+W6maw4cEpyWOcxb/M9F7iw98CO5YNTALD0W RHBCozGcvxlKPGX6uoYJpCQxNytt1WigBKfUE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=YFB+tdyXOtCPNmNlbyeGl25fBeChj1S+VT6tzzLEZ78=; b=QfjYUkjovCsiigWyABsgGpf5/v06DcLmnQbVqTHLVi+ckQomfWrSfPy8wf4NAJV9fU 9ynTHdBDanEKcPXCxpAzbuRzle3W0mv8H9cliXPJsVXQymX2zovyz1Q3VpKOSQQAg6bB UlpELB5Wez+oEdzeiD6bAM5cIiSP/F6LDrsiQf0lJuajwE9Acx1Q3eIxrWs9kk0Qqvez beBCx+1yL72VN88QVa3yHa7M1IhswgtUzb9VeOpJhSu8B+2VwQgLSFgzqtcbQygt66xB CPbNd9IL9isp4nd19YeglBuJ94jL+F624hceX6Svt/80KO1wcPZ3gfxqIhTCp/OshbMU hnjg== X-Gm-Message-State: AOAM530zYhxHujDzchW2hFY23dXcvlXpEk6ubhzFmk7TD/myzRNqZC6e VeaYW5zQMnbQ5hT6dqXumMKdpJkZxcNYiw== X-Google-Smtp-Source: ABdhPJwC6RTDJ7UCWlPVuZqbQnZO87DzoprxOuTlXIPOEshNgw6nSSV8q4mv+3D9zGDVjeJ6B+SLWA== X-Received: by 2002:a17:906:f118:: with SMTP id gv24mr3553522ejb.174.1602079933379; Wed, 07 Oct 2020 07:12:13 -0700 (PDT) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com. [209.85.128.41]) by smtp.gmail.com with ESMTPSA id ba6sm1570825edb.61.2020.10.07.07.12.12 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Oct 2020 07:12:13 -0700 (PDT) Received: by mail-wm1-f41.google.com with SMTP id p15so2477631wmi.4 for ; Wed, 07 Oct 2020 07:12:12 -0700 (PDT) X-Received: by 2002:a1c:8057:: with SMTP id b84mr3494264wmd.116.1602079932144; Wed, 07 Oct 2020 07:12:12 -0700 (PDT) MIME-Version: 1.0 References: <20201002233118.GM9916@ziepe.ca> <725819e9-4f07-3f04-08f8-b6180406b339@samsung.com> <20201007124409.GN5177@ziepe.ca> <20201007130610.GP5177@ziepe.ca> In-Reply-To: From: Tomasz Figa Date: Wed, 7 Oct 2020 16:11:59 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-samsung-soc , Jan Kara , Joonyoung Shim , Pawel Osciak , Linux MM , John Hubbard , Seung-Woo Kim , LKML , DRI Development , Kyungmin Park , Jason Gunthorpe , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Daniel Vetter , Andrew Morton , "open list:DMA BUFFER SHARING FRAMEWORK" , Dan Williams , Linux ARM , Marek Szyprowski Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Wed, Oct 7, 2020 at 4:09 PM Daniel Vetter wrote: > > On Wed, Oct 7, 2020 at 3:34 PM Tomasz Figa wrote: > > > > On Wed, Oct 7, 2020 at 3:06 PM Jason Gunthorpe wrote: > > > > > > On Wed, Oct 07, 2020 at 02:58:33PM +0200, Daniel Vetter wrote: > > > > On Wed, Oct 7, 2020 at 2:48 PM Tomasz Figa wrote: > > > > > > > > > > On Wed, Oct 7, 2020 at 2:44 PM Jason Gunthorpe wrote: > > > > > > > > > > > > On Wed, Oct 07, 2020 at 02:33:56PM +0200, Marek Szyprowski wrote: > > > > > > > Well, it was in vb2_get_vma() function, but now I see that it has been > > > > > > > lost in fb639eb39154 and 6690c8c78c74 some time ago... > > > > > > > > > > > > There is no guarentee that holding a get on the file says anthing > > > > > > about the VMA. This needed to check that the file was some special > > > > > > kind of file that promised the VMA layout and file lifetime are > > > > > > connected. > > > > > > > > > > > > Also, cloning a VMA outside the mm world is just really bad. That > > > > > > would screw up many assumptions the drivers make. > > > > > > > > > > > > If it is all obsolete I say we hide it behind a default n config > > > > > > symbol and taint the kernel if anything uses it. > > > > > > > > > > > > Add a big comment above the follow_pfn to warn others away from this > > > > > > code. > > > > > > > > > > Sadly it's just verbally declared as deprecated and not formally noted > > > > > anyway. There are a lot of userspace applications relying on user > > > > > pointer support. > > > > > > > > userptr can stay, it's the userptr abuse for zerocpy buffer sharing > > > > which doesn't work anymore. At least without major surgery (you'd need > > > > an mmu notifier to zap mappings and recreate them, and that pretty > > > > much breaks the v4l model of preallocating all buffers to make sure we > > > > never underflow the buffer queue). And static mappings are not coming > > > > back I think, we'll go ever more into the direction of dynamic > > > > mappings and moving stuff around as needed. > > > > > > Right, and to be clear, the last time I saw a security flaw of this > > > magnitude from a subsystem badly mis-designing itself, Linus's > > > knee-jerk reaction was to propose to remove the whole subsystem. > > > > > > Please don't take status-quo as acceptable, V4L community has to work > > > to resolve this, uABI breakage or not. The follow_pfn related code > > > must be compiled out of normal distro kernel builds. > > > > I think the userptr zero-copy hack should be able to go away indeed, > > given that we now have CMA that allows having carveouts backed by > > struct pages and having the memory represented as DMA-buf normally. > > Not sure whether there's a confusion here: dma-buf supports memory not > backed by struct page. > That's new to me. The whole API relies on sg_tables a lot, which in turn rely on struct page pointers to describe the physical memory. > > How about the regular userptr use case, though? > > > > The existing code resolves the user pointer into pages by following > > the get_vaddr_frames() -> frame_vector_to_pages() -> > > sg_alloc_table_from_pages() / vm_map_ram() approach. > > get_vaddr_frames() seems to use pin_user_pages() behind the scenes if > > the vma is not an IO or a PFNMAP, falling back to follow_pfn() > > otherwise. > > Yeah pin_user_pages is fine, it's just the VM_IO | VM_PFNMAP vma that > don't work. Ack. > > > > Is your intention to drop get_vaddr_frames() or we could still keep > > using it and if vec->is_pfns is true: > > a) if CONFIG_VIDEO_LEGACY_PFN_USERPTR is set, taint the kernel > > b) otherwise just undo and fail? > > I'm typing that patch series (plus a pile more) right now. Cool, thanks! We also need to bring back the vma_open() that somehow disappeared around 4.2, as Marek found. Best regards, Tomasz _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel