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 12C8DC55179 for ; Sun, 1 Nov 2020 10:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEEDF20709 for ; Sun, 1 Nov 2020 10:31:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="PXdr311j" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726426AbgKAKbE (ORCPT ); Sun, 1 Nov 2020 05:31:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgKAKbC (ORCPT ); Sun, 1 Nov 2020 05:31:02 -0500 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31B9BC0617A6 for ; Sun, 1 Nov 2020 02:31:01 -0800 (PST) Received: by mail-ot1-x343.google.com with SMTP id a6so9835068otp.10 for ; Sun, 01 Nov 2020 02:31:01 -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=cMohUdqA3mHu1aHkJyF+q3c+LPomnH+bJbyOS5Pjj34=; b=PXdr311jw4o1TK1cA/6mrlvkDVtMBlyy1XYbMpIt3vJC7ClXj7DZJYo+vKllfO49H/ YgcjzcGc1VpCnfRMFbloI4quCQ5ndPF+idmxEJoWrUJWkpgS76TUc1DHlMSxRDqofJvd l2sKUL2WW0wKA2NYOf2SZx1Y6sFEl/LXBFDeg= 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=cMohUdqA3mHu1aHkJyF+q3c+LPomnH+bJbyOS5Pjj34=; b=SotKZMwAHHcvdYEom3L2DTeS8cD/PQVzuaJeAQ8Ti2DjVERevDtYddZa6WbipXDvvv RorsAZEKqcF9tlznBIkU93AepfQ7FWLf4fjVXw5IheAF5n/WjN3aFJOWuZU093WxbwAd Ylr6yVdgmDX8Mps/+djjCbDcfJzNlADIofi48M7rVmZgZv8U69a2aT+4nqXkk4Dor8nA fw+UjciYrkqBOA1YptkctmXRTZwefOvxKr8a65HFyn4rWNXnKE4l807BaMYBxRIEYSu6 1uwRla9bTu+P364pGssLW47OxVfHHJmU4ArEDXpNSBhByI9d2yoz3wNNB8WByCz8GPJQ vV7g== X-Gm-Message-State: AOAM532ehBCspBkRRbbu+WKibx/6sFRKs9nAm/J7/Y/vbGqFWiiympYe 4FtvGn759yJ+CWh6ZoWqitnlvna2cfKSnI1lXG54Zw== X-Google-Smtp-Source: ABdhPJxxfl/j7Y56O7SvvjDInbgd1Huz0SnDjNzTDNqX3oHxJ8qJKEvsr7nAV6GfCrUUP0r8bqY++IYBOL0aDpBKvjo= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr8739299otr.281.1604226660644; Sun, 01 Nov 2020 02:31:00 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-6-daniel.vetter@ffwll.ch> <446b2d5b-a1a1-a408-f884-f17a04b72c18@nvidia.com> <1f7cf690-35e2-c56f-6d3f-94400633edd2@nvidia.com> In-Reply-To: <1f7cf690-35e2-c56f-6d3f-94400633edd2@nvidia.com> From: Daniel Vetter Date: Sun, 1 Nov 2020 11:30:49 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard Cc: DRI Development , LKML , KVM list , Linux MM , Linux ARM , linux-samsung-soc , "open list:DMA BUFFER SHARING FRAMEWORK" , Daniel Vetter , Jason Gunthorpe , Pawel Osciak , Marek Szyprowski , Kyungmin Park , Tomasz Figa , Mauro Carvalho Chehab , Andrew Morton , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , Dan Williams Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 1, 2020 at 6:22 AM John Hubbard wrote: > > On 10/31/20 7:45 AM, Daniel Vetter wrote: > > On Sat, Oct 31, 2020 at 3:55 AM John Hubbard wrote: > >> On 10/30/20 3:08 AM, Daniel Vetter wrote: > ... > >> By removing this check from this location, and changing from > >> pin_user_pages_locked() to pin_user_pages_fast(), I *think* we end up > >> losing the check entirely. Is that intended? If so it could use a comment > >> somewhere to explain why. > > > > Yeah this wasn't intentional. I think I needed to drop the _locked > > version to prep for FOLL_LONGTERM, and figured _fast is always better. > > But I didn't realize that _fast doesn't have the vma checks, gup.c got > > me a bit confused. > > Actually, I thought that the change to _fast was a very nice touch, btw. > > > > > I'll remedy this in all the patches where this applies (because a > > VM_IO | VM_PFNMAP can point at struct page backed memory, and that > > exact use-case is what we want to stop with the unsafe_follow_pfn work > > since it wreaks things like cma or security). > > > > Aside: I do wonder whether the lack for that check isn't a problem. > > VM_IO | VM_PFNMAP generally means driver managed, which means the > > driver isn't going to consult the page pin count or anything like that > > (at least not necessarily) when revoking or moving that memory, since > > we're assuming it's totally under driver control. So if pup_fast can > > get into such a mapping, we might have a problem. > > -Daniel > > > > Yes. I don't know why that check is missing from the _fast path. > Probably just an oversight, seeing as how it's in the slow path. Maybe > the appropriate response here is to add a separate patch that adds the > check. > > I wonder if I'm overlooking something, but it certainly seems correct to > do that. You'll need the mmap_sem to get at the vma to be able to do this check. If you add that to _fast, you made it as fast as the slow one. Plus there's _fast_only due to locking recurion issues in fast-paths (I assume, I didn't check all the callers). I'm just wondering whether we have a bug somewhere with device drivers. For CMA regions we always check in try_grab_page, but for dax I'm not seeing where the checks in the _fast fastpaths are, and that all still leaves random device driver mappings behind which aren't backed by CMA but still point to something with a struct page behind it. I'm probably just missing something, but no idea what. -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=-3.8 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 9E6C1C388F9 for ; Sun, 1 Nov 2020 10:33:03 +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 547552071A for ; Sun, 1 Nov 2020 10:33:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="0lmJy/vq"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="PXdr311j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 547552071A 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=zm5ogejzpXsUgpKrU5X2Z0/Uq6D4vs53aTaAw2dlCZY=; b=0lmJy/vqyloSgbUNM7FgXGumB W28m5xBUzMeVxyFMCm0d4PaGqb49p19TmSLb8erxBVa4ZTwxDOCtd/vmVEZaQ3wdnelt/OSoYVrii IspiFNzh3RjEvYyVepP/HC/+r/uxID3i3w9/REQp0S4lIJHdYHzswjuVqk/RirINOCGHKnh4PpN25 ENvD54Sezsg/plBFFrsPfHJ76XrNcGK/vtRD5NItFYyINA3RKi7iKwax2IJNtg5twvSrXWaBd5Hmp XzfDJhG56G4llZmng4b5j2rDtifDVmt5d3Wpte5KVJEztbGhSq1TTKzIbuumR8PW3w/khTDjUIsKS bXT6O4lug==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZAdi-0002sa-2D; Sun, 01 Nov 2020 10:31:10 +0000 Received: from mail-ot1-x344.google.com ([2607:f8b0:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZAda-0002qW-Nh for linux-arm-kernel@lists.infradead.org; Sun, 01 Nov 2020 10:31:08 +0000 Received: by mail-ot1-x344.google.com with SMTP id b2so9840420ots.5 for ; Sun, 01 Nov 2020 02:31:02 -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=cMohUdqA3mHu1aHkJyF+q3c+LPomnH+bJbyOS5Pjj34=; b=PXdr311jw4o1TK1cA/6mrlvkDVtMBlyy1XYbMpIt3vJC7ClXj7DZJYo+vKllfO49H/ YgcjzcGc1VpCnfRMFbloI4quCQ5ndPF+idmxEJoWrUJWkpgS76TUc1DHlMSxRDqofJvd l2sKUL2WW0wKA2NYOf2SZx1Y6sFEl/LXBFDeg= 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=cMohUdqA3mHu1aHkJyF+q3c+LPomnH+bJbyOS5Pjj34=; b=Kem3z1ZSNmR0O1yEDgPsFfHjN5/LgJF/ryTJmSK6pZVAE81N2wapAM5BBwfK7PinmD QEYOI+91GW4PGSW2aOjVs+QEHnRSDOIKCSUDe6SbwP8uXUMIhKg62NbRpv1O8e/kbEEg Jz5WYW3DYpPQqB9pRGGIlhA3HosXAEbixQEBJJTRxXQjQscTUvEx2aUF5yIFAgUpHOb8 LrXBR5eN9pFIgSwG/rysWK/Ye+qlUIa37yRvjEw9ePh5b9ha1cyPH/jzY/0uIbqEUjex LsHACEc/n1O7tbPDVgMHrewfx+FyFKvAvqdgOQdlQLOl+A2OtdP4BjGhZ1h4kdA+/UMC 7wIA== X-Gm-Message-State: AOAM530f61mohzJW/lJcUU2kyNYz8szWLqh+DwCa8vPnJLA7s04WU2TM 2ERFwl5LZQqgIDUZd3Vel9TvClU9KAZzGt5eL3z8LfwwB+yPKw== X-Google-Smtp-Source: ABdhPJxxfl/j7Y56O7SvvjDInbgd1Huz0SnDjNzTDNqX3oHxJ8qJKEvsr7nAV6GfCrUUP0r8bqY++IYBOL0aDpBKvjo= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr8739299otr.281.1604226660644; Sun, 01 Nov 2020 02:31:00 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-6-daniel.vetter@ffwll.ch> <446b2d5b-a1a1-a408-f884-f17a04b72c18@nvidia.com> <1f7cf690-35e2-c56f-6d3f-94400633edd2@nvidia.com> In-Reply-To: <1f7cf690-35e2-c56f-6d3f-94400633edd2@nvidia.com> From: Daniel Vetter Date: Sun, 1 Nov 2020 11:30:49 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201101_053102_786515_8C5B1D9B X-CRM114-Status: GOOD ( 29.82 ) 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: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , linux-samsung-soc , Jan Kara , Pawel Osciak , KVM list , Jason Gunthorpe , Mauro Carvalho Chehab , LKML , DRI Development , Tomasz Figa , Linux MM , Kyungmin Park , Daniel Vetter , Andrew Morton , Marek Szyprowski , Dan Williams , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" 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 Sun, Nov 1, 2020 at 6:22 AM John Hubbard wrote: > > On 10/31/20 7:45 AM, Daniel Vetter wrote: > > On Sat, Oct 31, 2020 at 3:55 AM John Hubbard wrote: > >> On 10/30/20 3:08 AM, Daniel Vetter wrote: > ... > >> By removing this check from this location, and changing from > >> pin_user_pages_locked() to pin_user_pages_fast(), I *think* we end up > >> losing the check entirely. Is that intended? If so it could use a comment > >> somewhere to explain why. > > > > Yeah this wasn't intentional. I think I needed to drop the _locked > > version to prep for FOLL_LONGTERM, and figured _fast is always better. > > But I didn't realize that _fast doesn't have the vma checks, gup.c got > > me a bit confused. > > Actually, I thought that the change to _fast was a very nice touch, btw. > > > > > I'll remedy this in all the patches where this applies (because a > > VM_IO | VM_PFNMAP can point at struct page backed memory, and that > > exact use-case is what we want to stop with the unsafe_follow_pfn work > > since it wreaks things like cma or security). > > > > Aside: I do wonder whether the lack for that check isn't a problem. > > VM_IO | VM_PFNMAP generally means driver managed, which means the > > driver isn't going to consult the page pin count or anything like that > > (at least not necessarily) when revoking or moving that memory, since > > we're assuming it's totally under driver control. So if pup_fast can > > get into such a mapping, we might have a problem. > > -Daniel > > > > Yes. I don't know why that check is missing from the _fast path. > Probably just an oversight, seeing as how it's in the slow path. Maybe > the appropriate response here is to add a separate patch that adds the > check. > > I wonder if I'm overlooking something, but it certainly seems correct to > do that. You'll need the mmap_sem to get at the vma to be able to do this check. If you add that to _fast, you made it as fast as the slow one. Plus there's _fast_only due to locking recurion issues in fast-paths (I assume, I didn't check all the callers). I'm just wondering whether we have a bug somewhere with device drivers. For CMA regions we always check in try_grab_page, but for dax I'm not seeing where the checks in the _fast fastpaths are, and that all still leaves random device driver mappings behind which aren't backed by CMA but still point to something with a struct page behind it. I'm probably just missing something, but no idea what. -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 D4BD6C2D0A3 for ; Sun, 1 Nov 2020 10:31:04 +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 E1F8520709 for ; Sun, 1 Nov 2020 10:31:02 +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="PXdr311j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E1F8520709 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 3017E6E08C; Sun, 1 Nov 2020 10:31:02 +0000 (UTC) Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3F6956E08C for ; Sun, 1 Nov 2020 10:31:01 +0000 (UTC) Received: by mail-ot1-x343.google.com with SMTP id n11so9865640ota.2 for ; Sun, 01 Nov 2020 02:31:01 -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=cMohUdqA3mHu1aHkJyF+q3c+LPomnH+bJbyOS5Pjj34=; b=PXdr311jw4o1TK1cA/6mrlvkDVtMBlyy1XYbMpIt3vJC7ClXj7DZJYo+vKllfO49H/ YgcjzcGc1VpCnfRMFbloI4quCQ5ndPF+idmxEJoWrUJWkpgS76TUc1DHlMSxRDqofJvd l2sKUL2WW0wKA2NYOf2SZx1Y6sFEl/LXBFDeg= 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=cMohUdqA3mHu1aHkJyF+q3c+LPomnH+bJbyOS5Pjj34=; b=YGLVK/ThlRGZb+oChvayh6Yc9orHkv4qFdqIdn3g8/kak+/Wly+eMSQXsf6ko01NQo 0fbBKsFxDJ1AFBWmYZzK7g0tnI+qVZFtLquUeydz1M0/Soo9fRtY6YkAUmAy/Re188pP mEDagnHcyloIcjURt9OBvCIB4LCp5egVnvYkvHYnzTrp3qcVo2vH/P6RRhNPeF5bwY7x 4vzvKTqOcDRqwPiAIwZxAlbJZotNg5QAnIqhC8J3BXfXb5tlDOGjxIF+tkTvUnKsumIS rlaneqzg6LbMF8N6qt6l1Q/+oMsTItn0MFEjLv0JB9JyT+N4OGPp93Q2ZT2NFZhaKHUv 2Myg== X-Gm-Message-State: AOAM532p7aSwvW17XilLZ5R9iAijCf/vxyRdM13DtNYWxm8uoAIplZ05 HF508D26VrGkT6BnzilW8k6cQLxLZwYcQ65lVYuw2A== X-Google-Smtp-Source: ABdhPJxxfl/j7Y56O7SvvjDInbgd1Huz0SnDjNzTDNqX3oHxJ8qJKEvsr7nAV6GfCrUUP0r8bqY++IYBOL0aDpBKvjo= X-Received: by 2002:a05:6830:1647:: with SMTP id h7mr8739299otr.281.1604226660644; Sun, 01 Nov 2020 02:31:00 -0800 (PST) MIME-Version: 1.0 References: <20201030100815.2269-1-daniel.vetter@ffwll.ch> <20201030100815.2269-6-daniel.vetter@ffwll.ch> <446b2d5b-a1a1-a408-f884-f17a04b72c18@nvidia.com> <1f7cf690-35e2-c56f-6d3f-94400633edd2@nvidia.com> In-Reply-To: <1f7cf690-35e2-c56f-6d3f-94400633edd2@nvidia.com> From: Daniel Vetter Date: Sun, 1 Nov 2020 11:30:49 +0100 Message-ID: Subject: Re: [PATCH v5 05/15] mm/frame-vector: Use FOLL_LONGTERM To: John Hubbard 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: =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , linux-samsung-soc , Jan Kara , Pawel Osciak , KVM list , Jason Gunthorpe , Mauro Carvalho Chehab , LKML , DRI Development , Tomasz Figa , Linux MM , Kyungmin Park , Daniel Vetter , Andrew Morton , Marek Szyprowski , Dan Williams , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Sun, Nov 1, 2020 at 6:22 AM John Hubbard wrote: > > On 10/31/20 7:45 AM, Daniel Vetter wrote: > > On Sat, Oct 31, 2020 at 3:55 AM John Hubbard wrote: > >> On 10/30/20 3:08 AM, Daniel Vetter wrote: > ... > >> By removing this check from this location, and changing from > >> pin_user_pages_locked() to pin_user_pages_fast(), I *think* we end up > >> losing the check entirely. Is that intended? If so it could use a comment > >> somewhere to explain why. > > > > Yeah this wasn't intentional. I think I needed to drop the _locked > > version to prep for FOLL_LONGTERM, and figured _fast is always better. > > But I didn't realize that _fast doesn't have the vma checks, gup.c got > > me a bit confused. > > Actually, I thought that the change to _fast was a very nice touch, btw. > > > > > I'll remedy this in all the patches where this applies (because a > > VM_IO | VM_PFNMAP can point at struct page backed memory, and that > > exact use-case is what we want to stop with the unsafe_follow_pfn work > > since it wreaks things like cma or security). > > > > Aside: I do wonder whether the lack for that check isn't a problem. > > VM_IO | VM_PFNMAP generally means driver managed, which means the > > driver isn't going to consult the page pin count or anything like that > > (at least not necessarily) when revoking or moving that memory, since > > we're assuming it's totally under driver control. So if pup_fast can > > get into such a mapping, we might have a problem. > > -Daniel > > > > Yes. I don't know why that check is missing from the _fast path. > Probably just an oversight, seeing as how it's in the slow path. Maybe > the appropriate response here is to add a separate patch that adds the > check. > > I wonder if I'm overlooking something, but it certainly seems correct to > do that. You'll need the mmap_sem to get at the vma to be able to do this check. If you add that to _fast, you made it as fast as the slow one. Plus there's _fast_only due to locking recurion issues in fast-paths (I assume, I didn't check all the callers). I'm just wondering whether we have a bug somewhere with device drivers. For CMA regions we always check in try_grab_page, but for dax I'm not seeing where the checks in the _fast fastpaths are, and that all still leaves random device driver mappings behind which aren't backed by CMA but still point to something with a struct page behind it. I'm probably just missing something, but no idea what. -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