Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1459637pxb; Mon, 22 Feb 2021 02:27:37 -0800 (PST) X-Google-Smtp-Source: ABdhPJwKHi31mHWKqawlFmc4XrD6qM39tbtbr7zRo17ltURZGihEV2lkoDQ4jmf+5zzyMFhXq/kH X-Received: by 2002:aa7:ca08:: with SMTP id y8mr8591151eds.256.1613989657714; Mon, 22 Feb 2021 02:27:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613989657; cv=none; d=google.com; s=arc-20160816; b=KAXJwPMhNS8pMPGo/DCKW3sf/HJOUla4Oji1pCYciHApo9KLOHAxNNi6MM/9KBahkI Cc8VyjKJ6jT/poKBdvsyhSPIxYegrTrIzIw+TmoJBFlsg+NoExcLzTUMLtEp/S4Em6/c GMlti7j0WGs5ve5OVXUpV0GfFTd2diXFyr/PzPo82FgMKCt9YtiODCcj8nqu82QYOdsq xkVB8pUfQAhDhJ6HjVfYFvvWuvpoZ/xS4kEomW4B8UmFDrzKdP0swp1E7VCh+TaE3Wr4 Ri5+WtzbHcDg9lobQ7BPlGBBh3NcJgVC3uyTilCnaXX60Zq8GvDz1OJ7cnA58RrbrZwf ZVew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8PN9lZns7J1+4nVNdLUsP5pZfABQHuCQh40cXC4mRVU=; b=UIGrlJrTFDOY1qASGWcdSN3EX1INNn+P3SSOeGXwXeMnyVgj0XT0tRv1zLn2ZViWij Zx5BtSBOozGLq8oSxdpLu6tHqZcv8RYW4J2sh2vOu//l2u+imSZLCmECJWSktylgNPAm wPi5yHRYrpmRcmP5fi6SkleF1C+/tXcms9XPprustcTG8CSG2mNwxQ1Qq1F/e7vugoY0 NmQyX1U2CM46UbktD09ZwqpUMc113YIn8HfFBRvCNIRvIoM5v6K+37kvHZpZr8FwaGr0 cwA0bt6pdvIxbPpb/fdEm6PvhN+aNrWxQoIQyEjKebUnfPYpRkM5QcNpV8fw0tJfEoBT uLHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=JjNqFK4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o15si13172235edc.151.2021.02.22.02.27.15; Mon, 22 Feb 2021 02:27:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=JjNqFK4g; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229934AbhBVK0Z (ORCPT + 99 others); Mon, 22 Feb 2021 05:26:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbhBVKZs (ORCPT ); Mon, 22 Feb 2021 05:25:48 -0500 Received: from mail-ot1-x336.google.com (mail-ot1-x336.google.com [IPv6:2607:f8b0:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E18A1C06178C for ; Mon, 22 Feb 2021 02:25:07 -0800 (PST) Received: by mail-ot1-x336.google.com with SMTP id 105so5059721otd.3 for ; Mon, 22 Feb 2021 02:25:07 -0800 (PST) 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=8PN9lZns7J1+4nVNdLUsP5pZfABQHuCQh40cXC4mRVU=; b=JjNqFK4gSzIei693IqlhBwRtfqfVLnXSE7H+WylDNcJ9iWnvn2v5HZQmr66dRaYaR2 1qy0ofXUQ9Sazr3OTMvKwxsLcc+bhw7lERWk030gGX0TSIV/TOasbs9/DKvt7XoHW5NV X+rSaxHg9heK4QU/oT4mD4B0YbNGVJzrPs9c4= 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=8PN9lZns7J1+4nVNdLUsP5pZfABQHuCQh40cXC4mRVU=; b=IHHjlGu8/juZl30LvAM6w8F5739i1DRGi0lZOyiB+fSqQLV8gPuiHU0NXUMRwCTGnk uE7yQzCubrj+Fzmyc7OapYMJrivTXn4Ky4hJjGs2xvwJPiBKwbnkd3qYfgy2NTQX46WA 4nGEYuRN1XZLHksJv63H5IBWXz5ZdqodAUS+84bs5HFy4/fdmimXiVygHxtSZmLLH6WL diOvy9OfWfIQQ1iJ7qKVkxAx9vjnKSMdLh3BHMfe6KU/B6vPQr6UP05qvPdx4iGcRFVB 6Iqz3iJsVHWAZaIWyukcDya2FKoAEv0vUIImJJ8/iJQU2qjs6aGt4gR94tNqyDfWUNGm ZbVw== X-Gm-Message-State: AOAM5321M+phGNR3AjZhJyWJUKLayNqlTLvndLbujbDeZgAK2xsOMaxb YAwlk4tPNxDeWmohplrWltJ7FwGlGoi5lMY5CkOusQ== X-Received: by 2002:a9d:2265:: with SMTP id o92mr16080713ota.188.1613989507244; Mon, 22 Feb 2021 02:25:07 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Daniel Vetter Date: Mon, 22 Feb 2021 11:24:56 +0100 Message-ID: Subject: Re: [PULL] fixes around VM_PFNMAP and follow_pfn for 5.12 merge window To: Linus Torvalds Cc: Linux Kernel Mailing List , dri-devel , Linux MM , "open list:DMA BUFFER SHARING FRAMEWORK" , Linux PCI Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc all the mailing lists ... my usual script crashed and I had to hand-roll the email and screwed it up ofc :-/ -Daniel On Mon, Feb 22, 2021 at 11:23 AM Daniel Vetter wrote: > > Hi Linus, > > Another small pull from you to ponder. > > This is the first part of a patch series I've been working on for a while: > > https://lore.kernel.org/dri-devel/20201127164131.2244124-1-daniel.vetter@ffwll.ch/ > > I've stumbled over this for my own learning and then realized there's a > bunch of races around VM_PFNMAP mappings vs follow pfn. > > If you're happy with this then I'll follow up with the media patches to > mark their leftover use of follow_pfn as unsafe (it's uapi, so unfixable > issue, all we can do is a config option to harden the kernel). Plus > hopefully kvm and vfio are then fixed too (you've been on the recent kvm > thread where this popped up again) so that we can sunset follow_pfn usage > completely. > > The last two patches have only been in linux-next in their current form > for a week, there was some issue for platforms with HAVE_PCI_LEGACY (not > that many) which took some sorting out. But looks all good now. > > Cheers, Daniel > > The following changes since commit 7c53f6b671f4aba70ff15e1b05148b10d58c2837: > > Linux 5.11-rc3 (2021-01-10 14:34:50 -0800) > > are available in the Git repository at: > > git://anongit.freedesktop.org/drm/drm tags/topic/iomem-mmap-vs-gup-2021-02-22 > > for you to fetch changes up to 636b21b50152d4e203223ee337aca1cb3c1bfe53: > > PCI: Revoke mappings like devmem (2021-02-11 15:59:19 +0100) > > ---------------------------------------------------------------- > Fixes around VM_FPNMAP and follow_pfn > > - replace mm/frame_vector.c by get_user_pages in misc/habana and > drm/exynos drivers, then move that into media as it's sole user > - close race in generic_access_phys > - s390 pci ioctl fix of this series landed in 5.11 already > - properly revoke iomem mappings (/dev/mem, pci files) > > ---------------------------------------------------------------- > Daniel Vetter (13): > drm/exynos: Stop using frame_vector helpers > drm/exynos: Use FOLL_LONGTERM for g2d cmdlists > misc/habana: Stop using frame_vector helpers > misc/habana: Use FOLL_LONGTERM for userptr > mm/frame-vector: Use FOLL_LONGTERM > media: videobuf2: Move frame_vector into media subsystem > mm: Close race in generic_access_phys > PCI: Obey iomem restrictions for procfs mmap > /dev/mem: Only set filp->f_mapping > resource: Move devmem revoke code to resource framework > sysfs: Support zapping of binary attr mmaps > PCI: Also set up legacy files only after sysfs init > PCI: Revoke mappings like devmem > > drivers/char/mem.c | 86 +---------------------------------------------------------------- > drivers/gpu/drm/exynos/Kconfig | 1 - > drivers/gpu/drm/exynos/exynos_drm_g2d.c | 48 ++++++++++++++++--------------------- > drivers/media/common/videobuf2/Kconfig | 1 - > drivers/media/common/videobuf2/Makefile | 1 + > {mm => drivers/media/common/videobuf2}/frame_vector.c | 55 +++++++++++++++--------------------------- > drivers/media/common/videobuf2/videobuf2-memops.c | 3 +-- > drivers/media/platform/omap/Kconfig | 1 - > drivers/misc/habanalabs/Kconfig | 1 - > drivers/misc/habanalabs/common/habanalabs.h | 6 +++-- > drivers/misc/habanalabs/common/memory.c | 52 +++++++++++++++------------------------- > drivers/pci/pci-sysfs.c | 11 +++++++++ > drivers/pci/proc.c | 6 +++++ > fs/sysfs/file.c | 11 +++++++++ > include/linux/ioport.h | 6 +---- > include/linux/mm.h | 45 ++-------------------------------- > include/linux/sysfs.h | 2 ++ > include/media/frame_vector.h | 47 ++++++++++++++++++++++++++++++++++++ > include/media/videobuf2-core.h | 1 + > kernel/resource.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- > mm/Kconfig | 3 --- > mm/Makefile | 1 - > mm/memory.c | 46 ++++++++++++++++++++++++++++++++--- > 23 files changed, 287 insertions(+), 245 deletions(-) > rename {mm => drivers/media/common/videobuf2}/frame_vector.c (85%) > create mode 100644 include/media/frame_vector.h > -- > Daniel Vetter > Software Engineer, Intel Corporation > http://blog.ffwll.ch -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch