All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ravi Kumar Bandi <ravib@amazon.com>
To: <djbw@kernel.org>
Cc: <akpm@linux-foundation.org>, <bhelgaas@google.com>,
	<david@kernel.org>, <hch@infradead.org>,
	<ilpo.jarvinen@linux.intel.com>, <linux-kernel@vger.kernel.org>,
	<ravib@amazon.com>
Subject: Re: [PATCH] resource: export iomem_get_mapping() for loadable modules
Date: Thu, 14 May 2026 15:54:05 +0000	[thread overview]
Message-ID: <20260514155405.7998-1-ravib@amazon.com> (raw)
In-Reply-To: <6a04c6ba958b2_107b100f9@djbw-dev.notmuch>

On 5/13/26, Dan Williams (nvidia) wrote:
> I took a look and there are some problems here.
>
> My first thought was, "why does the endpoint driver need to do this? The
> PCI core device removal should be responsible for zapping mappings."
>
> 2 things defeat this:
>
> 1/ for sysfs bar mappings, the unmap_mapping_range() in
> kernfs_drain_open_files() misses mappings established against
> the shared iomem_get_mapping().
>
> 2/ procfs access to BAR space has never unmapped on device removal
>
> The practical implication of this is that userspace mappings of BARs can
> survive past device removal. As for mitigations, with IO_STRICT_DEVMEM
> the kernel will zap them before use, with LOCKDOWN the mappings can not
> be established, and CAP_SYS_RAWIO is required (for procfs) to create
> these mappings.

Hello Dan, thank you for the review and guidance.

>
> I recall that Sima added support for ioport mmap revoke support in:
>
> 636b21b50152 PCI: Revoke mappings like devmem
>
> ...but given revoke_iomem() only evacuates at request_mem_region() time,
> I do not see how that ever worked.
>
> We could do something like the following for kernfs regression in the
> near term, or just proceed with making revoke_iomem() something that the
> PCI core does unconditionally by physical address on device removal.
> That would also fix the procfs gap.
>
> Ravi, I think your time is best spent getting the PCI core to handle the
> unmap on device removal.

Agree. Thank you for the pointers, I will work on it and get back here.

>
> -- >8 --
> Subject: resource: Fix PCI/sysfs mmap revocation vs CONFIG_IO_STRICT_DEVMEM=n
>
> From: Dan Williams <djbw@kernel.org>

      reply	other threads:[~2026-05-14 15:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  6:56 [PATCH] resource: export iomem_get_mapping() for loadable modules Ravi Kumar Bandi
2026-05-11  7:14 ` David Hildenbrand (Arm)
2026-05-11  7:17   ` Christoph Hellwig
2026-05-11 16:16     ` Ravi Kumar Bandi
2026-05-12  7:10       ` David Hildenbrand (Arm)
2026-05-12  7:31         ` Ravi Kumar Bandi
2026-05-12  7:22       ` Christoph Hellwig
2026-05-12  7:50         ` Ravi Kumar Bandi
2026-05-13 18:45           ` Dan Williams (nvidia)
2026-05-14 15:54             ` Ravi Kumar Bandi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260514155405.7998-1-ravib@amazon.com \
    --to=ravib@amazon.com \
    --cc=akpm@linux-foundation.org \
    --cc=bhelgaas@google.com \
    --cc=david@kernel.org \
    --cc=djbw@kernel.org \
    --cc=hch@infradead.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.