Message ID | 20221116102659.70287-16-david@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp68689wru; Wed, 16 Nov 2022 02:41:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DLdNUdaJmoO4CyrTv5nEEhLg1vfZfEKj5YFEu6EKftw2Y6aIzNaraGUYxN2b9taYttGF8 X-Received: by 2002:a17:906:4e88:b0:7a7:1d4f:c7dc with SMTP id v8-20020a1709064e8800b007a71d4fc7dcmr16893725eju.252.1668595269454; Wed, 16 Nov 2022 02:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668595269; cv=none; d=google.com; s=arc-20160816; b=qjHhMil2OKJoIVWPhabjC9W9NbO2U8gKz50USXkVKp7T4x0Q6VBIZepz0tdp39YppQ 6eT1wVJCno7RzyaLad+1qV/PUX0gjCDgQbuxkaOAlDYU0P5N1qGf398sjPtd13S0DnkA icN43YPKmjzgSXLAoNl6nvo434s0zD86bKlFiyxFoPjS7DEddR1HJ7gTV53Px9irJSD0 szcMxqOt60idwQ/kJjwOaVABSe2w86qsCh8/9PsTnZLwWKHpKR3DZ7KU6qAghHW1ZFEy ZnXsO4A/qbT7QIZZv8h0z1lP7eIGJ3nhb8zJe7/3GdLDCUESJy+CG5yjjxLBJPFTYFAw 87/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1lgRYK0+yPuNJDFPZ9ndbDbQCvjtc3Xp7NDAue46xBY=; b=wpvhRO5CGCpFy5jWnoEW8cUEoy7smeTWYQwQlxfN9HsUh4+tJwCqZl0FksjzcueuEU 3Ji2VmQugsws+LUS5cgi+S5nG/S1r52FA9KXUmNbu+ZYsj5bRFjKUncy8P9r4CZ/JKws 8FNBBLC7k4ihAnXZ5yzdGU/kRDRLkMD9rw4fQZvNKnAmCMQGr3KZCkE75BZ1F14+XBBK nnmy8w0RAeruINowac/CdeiJNdZ+i6/vDJfokWz2sX0DKSvTlGetTLtgEiIj6FEHGHwt M3GSK2ANyDiMbertBug1uhxxEaCOzx7BkwPd47ft/biYBx7W7vP9GlkBuX3RAlhRggmq 08jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iR9z+DqT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a50c242000000b00456d901922bsi12916631edf.510.2022.11.16.02.40.42; Wed, 16 Nov 2022 02:41:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=iR9z+DqT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238341AbiKPKkD (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 05:40:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233808AbiKPKi0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 05:38:26 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F250C2E9F1 for <linux-kernel@vger.kernel.org>; Wed, 16 Nov 2022 02:29:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668594562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1lgRYK0+yPuNJDFPZ9ndbDbQCvjtc3Xp7NDAue46xBY=; b=iR9z+DqTp/cgIbZeMtOXPAGbCIRAeQrT3dFeoEtJ92ejk/KBLFq+Awtp0CBd0BLP1lAt2Z sWPKOH3dtOgdzXh2dSa/BfIDKaEWy/PjsESnCSGbFtWa1SmpPzlcFFjZMoPdMjBLwKycYz miC7h/g0eyYhjB3O2WUFrUwJTmG+9Bc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-14-svSpfQNhOguMSNDl-MdQSA-1; Wed, 16 Nov 2022 05:29:18 -0500 X-MC-Unique: svSpfQNhOguMSNDl-MdQSA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 724BE86F147; Wed, 16 Nov 2022 10:29:15 +0000 (UTC) Received: from t480s.fritz.box (unknown [10.39.193.216]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3626A2028E8F; Wed, 16 Nov 2022 10:29:08 +0000 (UTC) From: David Hildenbrand <david@redhat.com> To: linux-kernel@vger.kernel.org Cc: x86@kernel.org, linux-alpha@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-ia64@vger.kernel.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, etnaviv@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-perf-users@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kselftest@vger.kernel.org, Linus Torvalds <torvalds@linux-foundation.org>, Andrew Morton <akpm@linux-foundation.org>, Jason Gunthorpe <jgg@ziepe.ca>, John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Andrea Arcangeli <aarcange@redhat.com>, Hugh Dickins <hughd@google.com>, Nadav Amit <namit@vmware.com>, Vlastimil Babka <vbabka@suse.cz>, Matthew Wilcox <willy@infradead.org>, Mike Kravetz <mike.kravetz@oracle.com>, Muchun Song <songmuchun@bytedance.com>, Shuah Khan <shuah@kernel.org>, Lucas Stach <l.stach@pengutronix.de>, David Airlie <airlied@gmail.com>, Oded Gabbay <ogabbay@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Christoph Hellwig <hch@infradead.org>, Alex Williamson <alex.williamson@redhat.com>, David Hildenbrand <david@redhat.com>, Andy Walls <awalls@md.metrocast.net>, Mauro Carvalho Chehab <mchehab@kernel.org> Subject: [PATCH mm-unstable v1 15/20] media: pci/ivtv: remove FOLL_FORCE usage Date: Wed, 16 Nov 2022 11:26:54 +0100 Message-Id: <20221116102659.70287-16-david@redhat.com> In-Reply-To: <20221116102659.70287-1-david@redhat.com> References: <20221116102659.70287-1-david@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749648953349463993?= X-GMAIL-MSGID: =?utf-8?q?1749648953349463993?= |
Series |
mm/gup: remove FOLL_FORCE usage from drivers (reliable R/O long-term pinning)
|
|
Commit Message
David Hildenbrand
Nov. 16, 2022, 10:26 a.m. UTC
FOLL_FORCE is really only for ptrace access. R/O pinning a page is
supposed to fail if the VMA misses proper access permissions (no VM_READ).
Let's just remove FOLL_FORCE usage here; there would have to be a pretty
good reason to allow arbitrary drivers to R/O pin pages in a PROT_NONE
VMA. Most probably, FOLL_FORCE usage is just some legacy leftover.
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: David Hildenbrand <david@redhat.com>
---
drivers/media/pci/ivtv/ivtv-udma.c | 2 +-
drivers/media/pci/ivtv/ivtv-yuv.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
Comments
On 16/11/2022 11:26, David Hildenbrand wrote: > FOLL_FORCE is really only for ptrace access. R/O pinning a page is > supposed to fail if the VMA misses proper access permissions (no VM_READ). > > Let's just remove FOLL_FORCE usage here; there would have to be a pretty > good reason to allow arbitrary drivers to R/O pin pages in a PROT_NONE > VMA. Most probably, FOLL_FORCE usage is just some legacy leftover. I'm pretty sure about that as well, so: Acked-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Regards, Hans > > Cc: Andy Walls <awalls@md.metrocast.net> > Cc: Mauro Carvalho Chehab <mchehab@kernel.org> > Signed-off-by: David Hildenbrand <david@redhat.com> > --- > drivers/media/pci/ivtv/ivtv-udma.c | 2 +- > drivers/media/pci/ivtv/ivtv-yuv.c | 5 ++--- > 2 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/pci/ivtv/ivtv-udma.c b/drivers/media/pci/ivtv/ivtv-udma.c > index 210be8290f24..99b9f55ca829 100644 > --- a/drivers/media/pci/ivtv/ivtv-udma.c > +++ b/drivers/media/pci/ivtv/ivtv-udma.c > @@ -115,7 +115,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr, > > /* Pin user pages for DMA Xfer */ > err = pin_user_pages_unlocked(user_dma.uaddr, user_dma.page_count, > - dma->map, FOLL_FORCE); > + dma->map, 0); > > if (user_dma.page_count != err) { > IVTV_DEBUG_WARN("failed to map user pages, returned %d instead of %d\n", > diff --git a/drivers/media/pci/ivtv/ivtv-yuv.c b/drivers/media/pci/ivtv/ivtv-yuv.c > index 4ba10c34a16a..582146f8d70d 100644 > --- a/drivers/media/pci/ivtv/ivtv-yuv.c > +++ b/drivers/media/pci/ivtv/ivtv-yuv.c > @@ -63,12 +63,11 @@ static int ivtv_yuv_prep_user_dma(struct ivtv *itv, struct ivtv_user_dma *dma, > > /* Pin user pages for DMA Xfer */ > y_pages = pin_user_pages_unlocked(y_dma.uaddr, > - y_dma.page_count, &dma->map[0], FOLL_FORCE); > + y_dma.page_count, &dma->map[0], 0); > uv_pages = 0; /* silence gcc. value is set and consumed only if: */ > if (y_pages == y_dma.page_count) { > uv_pages = pin_user_pages_unlocked(uv_dma.uaddr, > - uv_dma.page_count, &dma->map[y_pages], > - FOLL_FORCE); > + uv_dma.page_count, &dma->map[y_pages], 0); > } > > if (y_pages != y_dma.page_count || uv_pages != uv_dma.page_count) {
diff --git a/drivers/media/pci/ivtv/ivtv-udma.c b/drivers/media/pci/ivtv/ivtv-udma.c index 210be8290f24..99b9f55ca829 100644 --- a/drivers/media/pci/ivtv/ivtv-udma.c +++ b/drivers/media/pci/ivtv/ivtv-udma.c @@ -115,7 +115,7 @@ int ivtv_udma_setup(struct ivtv *itv, unsigned long ivtv_dest_addr, /* Pin user pages for DMA Xfer */ err = pin_user_pages_unlocked(user_dma.uaddr, user_dma.page_count, - dma->map, FOLL_FORCE); + dma->map, 0); if (user_dma.page_count != err) { IVTV_DEBUG_WARN("failed to map user pages, returned %d instead of %d\n", diff --git a/drivers/media/pci/ivtv/ivtv-yuv.c b/drivers/media/pci/ivtv/ivtv-yuv.c index 4ba10c34a16a..582146f8d70d 100644 --- a/drivers/media/pci/ivtv/ivtv-yuv.c +++ b/drivers/media/pci/ivtv/ivtv-yuv.c @@ -63,12 +63,11 @@ static int ivtv_yuv_prep_user_dma(struct ivtv *itv, struct ivtv_user_dma *dma, /* Pin user pages for DMA Xfer */ y_pages = pin_user_pages_unlocked(y_dma.uaddr, - y_dma.page_count, &dma->map[0], FOLL_FORCE); + y_dma.page_count, &dma->map[0], 0); uv_pages = 0; /* silence gcc. value is set and consumed only if: */ if (y_pages == y_dma.page_count) { uv_pages = pin_user_pages_unlocked(uv_dma.uaddr, - uv_dma.page_count, &dma->map[y_pages], - FOLL_FORCE); + uv_dma.page_count, &dma->map[y_pages], 0); } if (y_pages != y_dma.page_count || uv_pages != uv_dma.page_count) {