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,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 20E2CC41604 for ; Wed, 7 Oct 2020 14:09:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86DBB206BE for ; Wed, 7 Oct 2020 14:09:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="B4PLpbur" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728562AbgJGOJH (ORCPT ); Wed, 7 Oct 2020 10:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728469AbgJGOJH (ORCPT ); Wed, 7 Oct 2020 10:09:07 -0400 Received: from mail-oo1-xc44.google.com (mail-oo1-xc44.google.com [IPv6:2607:f8b0:4864:20::c44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBC1AC0613D2 for ; Wed, 7 Oct 2020 07:09:06 -0700 (PDT) Received: by mail-oo1-xc44.google.com with SMTP id w7so645567oow.7 for ; Wed, 07 Oct 2020 07:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F5NtGNV4UXqtob/Dy8Wfu3ZnV2YG7ZTF8Dz7SU/MRuA=; b=B4PLpburyCDHIfOP25bhhP5r9tO+rxb3oufGcc1bi7vBgcrdV+TGTIhDv3iLTdW/e3 oIr3r8n5BHeowIpG4G2PtYVK0pjnuwRKRa5QxkdhF8GSBqXvOSF2jkGXbTBeRECcAImq DchpU/Y/YQ235XjHuiSdLX0FDwNJ1FnUf5B4s= 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=F5NtGNV4UXqtob/Dy8Wfu3ZnV2YG7ZTF8Dz7SU/MRuA=; b=ToEU9Oo9CMGReAy1CV4nsmCT4yLj0bPSUpnmRdnHth02XISEqSTetSCmD8VmmLN5e7 JSOW6g3U4KAyFYAuc5x1qHsrCnqb9t3SnnJGnNmKULdO7eINf038ZPJK+bVQjShZnhyF 22J8c0Htdjftys6FMG3QX/gRhvL/6vEiwGSezVy8H2aIorNxPjMMUO1FsEprCFcp5lX3 xAY0pFHizMWTF4coVPS67wTZVVc8Uel4sy77BYcIAICVJNudKEVzPyMCJTcbjxZCHcnR W8ZJM3xwvF+tSDg7S8eSq2gv6qHe92EWkSqfYUAFU0JDiG/EUhP66wpSbXzPyT4B8XNa kFYg== X-Gm-Message-State: AOAM532IgAX/RMlx6BTh2Kldg09Cgus/kq8xNgon2hJvkQx8a1KybxSG 6V3yd7m1N+YP/wYzpFcDcB+uZQjoovZ5hGiq5gLcNw== X-Google-Smtp-Source: ABdhPJw2MxOMsCCHLuA0B2aXMY51PcMyywibrKXkCKUzUw6tJNpIcvbizXHrg3fACcDmzezaL+tQ7uy44dIyRAnAIS8= X-Received: by 2002:a4a:e592:: with SMTP id o18mr2184941oov.28.1602079746086; Wed, 07 Oct 2020 07:09:06 -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: Daniel Vetter Date: Wed, 7 Oct 2020 16:08:54 +0200 Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Tomasz Figa 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 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. > 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. > > 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. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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 BD61DC4363D for ; Wed, 7 Oct 2020 14:10:37 +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 2D3C9206BE for ; Wed, 7 Oct 2020 14:10:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="p/FMkzz6"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="B4PLpbur" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2D3C9206BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch 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=L3tdiRyHo2exFqI96xoV7VVEBvkg/zJi617Dj/Zzqpg=; b=p/FMkzz6B6p19CLgH1x2tWHU/ KgcTC1yU0C5/NL97h1Y9xGGlusogA5R5TST51wyvlx0ohTyO2uP9NUl90NofZEOq4DiBxXinJQMmE ku5P9vto+bx8Dus8/cXHNdf/X6y8OJfpvx7vDzu9UQRX6nUD74/e2CTb69hQauquwAAbky/Ju/dXT Io5HRw9m7UxfTOrq/nViTt3efi2v1bykH+gXFyBCc2SLXgvMiEoCRGaJrOe/AoOMgnGYMIYRiahLL NKHB8PGGZnHWwV/M1FLC8XuylcUIufoYi+62TFMq/FCNkmquXT14zmLGu5QDGcHhsbFqfARKoj6Gv PsLYEeriQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQA7z-0001fH-Sz; Wed, 07 Oct 2020 14:09:11 +0000 Received: from mail-oo1-xc42.google.com ([2607:f8b0:4864:20::c42]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kQA7w-0001dy-FP for linux-arm-kernel@lists.infradead.org; Wed, 07 Oct 2020 14:09:09 +0000 Received: by mail-oo1-xc42.google.com with SMTP id y127so645350ooa.5 for ; Wed, 07 Oct 2020 07:09:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F5NtGNV4UXqtob/Dy8Wfu3ZnV2YG7ZTF8Dz7SU/MRuA=; b=B4PLpburyCDHIfOP25bhhP5r9tO+rxb3oufGcc1bi7vBgcrdV+TGTIhDv3iLTdW/e3 oIr3r8n5BHeowIpG4G2PtYVK0pjnuwRKRa5QxkdhF8GSBqXvOSF2jkGXbTBeRECcAImq DchpU/Y/YQ235XjHuiSdLX0FDwNJ1FnUf5B4s= 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=F5NtGNV4UXqtob/Dy8Wfu3ZnV2YG7ZTF8Dz7SU/MRuA=; b=ZQ0cRpERdDyvcyWq9cmoyvoZEIrEHqFjy2F7sQnzJADlzu6tYif5eRIg90b0SKI+gG VJZvrNNF+VMqVDFZDJjbNehPXhV6gqAq+/CcBM9eue4JDebIDL3+vN24PRDCW+I/+wJJ U9llkHJBftE9CMy1GO4XjJd0fMjTRNDDQ0ebG/pyGoI/QNXKERsfwdmIuXA6CCjTJ8/1 aQ7c9qwLvZvVeNVTt6IbGaqJHcBYlQSx+FJfQdPlGj9ymPNpaxv7h3HCCfb72YnBYjRu vpTmdJYooH5RyAtwC/KqwTlKvKDKmqxedqNZ2APBkWtuvbBYY9sRPF/wtw8+OTmfH44N dcKg== X-Gm-Message-State: AOAM531tEGfuxfp7YFVGwpCFfdEnBoVsLz2hg6aIvR2KO4m9jIt0r3QR S7ru/Wpls0QeNHTjYJNaYuhMfj69pfS3rzsBPWxXZQ== X-Google-Smtp-Source: ABdhPJw2MxOMsCCHLuA0B2aXMY51PcMyywibrKXkCKUzUw6tJNpIcvbizXHrg3fACcDmzezaL+tQ7uy44dIyRAnAIS8= X-Received: by 2002:a4a:e592:: with SMTP id o18mr2184941oov.28.1602079746086; Wed, 07 Oct 2020 07:09:06 -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: Daniel Vetter Date: Wed, 7 Oct 2020 16:08:54 +0200 Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Tomasz Figa X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201007_100908_697102_0C7213A4 X-CRM114-Status: GOOD ( 35.65 ) 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 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. > 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. > > 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. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ 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 39122C4727E for ; Wed, 7 Oct 2020 14:09:10 +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 49FEB206BE for ; Wed, 7 Oct 2020 14:09:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="B4PLpbur" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49FEB206BE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch 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 4ECDE6E8F2; Wed, 7 Oct 2020 14:09:08 +0000 (UTC) Received: from mail-oo1-xc43.google.com (mail-oo1-xc43.google.com [IPv6:2607:f8b0:4864:20::c43]) by gabe.freedesktop.org (Postfix) with ESMTPS id F1B0A6E8F2 for ; Wed, 7 Oct 2020 14:09:06 +0000 (UTC) Received: by mail-oo1-xc43.google.com with SMTP id w7so645569oow.7 for ; Wed, 07 Oct 2020 07:09:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=F5NtGNV4UXqtob/Dy8Wfu3ZnV2YG7ZTF8Dz7SU/MRuA=; b=B4PLpburyCDHIfOP25bhhP5r9tO+rxb3oufGcc1bi7vBgcrdV+TGTIhDv3iLTdW/e3 oIr3r8n5BHeowIpG4G2PtYVK0pjnuwRKRa5QxkdhF8GSBqXvOSF2jkGXbTBeRECcAImq DchpU/Y/YQ235XjHuiSdLX0FDwNJ1FnUf5B4s= 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=F5NtGNV4UXqtob/Dy8Wfu3ZnV2YG7ZTF8Dz7SU/MRuA=; b=CW8iki0uGEhCJc+ZUeVzSJZh9r17IsiyKpzFMXzLJf6qDxS0WZOFplfjeo84WlnmfF Ls7xV9RE1OOAiPHpWj5F4u1PDjothB0hD7VLiqQUL2K/bV0iMbSNoGTfGaPDv5u+RFhC fKVIrpFgd/OCPxC4up7M4J8+H2baoyi/QKou+OM5aoV41MXEYz5GQDJFOtS/p6KCUZI3 N1/fTuvBQZNCfzZoeIBZUqlzLSC7WwA/UCtNzmkOEken1p4ra3TNA/bjjEG/Q294yP24 C4FG5Plc70hD35QpJxaXu4ExlmZ4iSowz+r/f6dnqI4O8bbjOxIQLSlGNwJnyXJSug7M XALA== X-Gm-Message-State: AOAM5321wxpXFlxDPYqGCkuISV8B2tbFYg+b88eXhIHRdTi208wOH6SX 5wp+nlSku4b5+RVdcvLNkF/tWhcbAR7bSJsqYPqCSw== X-Google-Smtp-Source: ABdhPJw2MxOMsCCHLuA0B2aXMY51PcMyywibrKXkCKUzUw6tJNpIcvbizXHrg3fACcDmzezaL+tQ7uy44dIyRAnAIS8= X-Received: by 2002:a4a:e592:: with SMTP id o18mr2184941oov.28.1602079746086; Wed, 07 Oct 2020 07:09:06 -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: Daniel Vetter Date: Wed, 7 Oct 2020 16:08:54 +0200 Message-ID: Subject: Re: [PATCH 2/2] mm/frame-vec: use FOLL_LONGTERM To: Tomasz Figa 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 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. > 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. > > 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. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel