From: Dan Williams <dan.j.williams@intel.com>
To: Dave Hansen <dave.hansen@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
Kees Cook <kees@kernel.org>
Cc: <dave.hansen@linux.intel.com>,
Nikolay Borisov <nik.borisov@suse.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 2/3] devmem: Block mmap access when read/write access is restricted
Date: Fri, 11 Apr 2025 14:48:23 -0700 [thread overview]
Message-ID: <67f98e27a799e_7205294e3@dwillia2-xfh.jf.intel.com.notmuch> (raw)
In-Reply-To: <bf63b3e3-afdd-424c-87dc-f5488e770315@intel.com>
Dave Hansen wrote:
> On 4/10/25 21:59, Dan Williams wrote:
> >> I don't think we can just fail the mmap. 🙁
> > For the TVM case the havoc of failing mmap for DMI info is smaller and
> > the recommended fallback for /dev/mem being in accessible is
> > /sys/firmware/dmi/tables. So I feel ok making TVMs take the modern
> > replacement path which is what they would need to do anyway in the
> > lockdown_kernel case. Tom, Dave, what do you think?
>
> Yeah, doing the same as lockdown should be fine.
Note that lockdown fails the open() for /dev/mem and fails the mmap()
for PCI sysfs. So the proposal here would arrange for lockdown to not be
required, but fail mmap() in both cases.
> The other alternative to failing all mmap()s is to allow mmap(PROT_READ)
> to succeed and then just map the zero page.
The only goal of mapping zeroes I can see is to attempt to break legacy
userspace less severely, but as the Debian code search shows, legacy
/dev/mem users have already found the mmap() loophole. So, zeroes for
the TVM case does not help satisfy the requirement to use
/sys/firmware/dmi/tables and other modern methods with
private-memory-safe semantics. I.e. the "success but zero" and "mmap()
failed" cases have the same outcome: legacy software falls back to no
DMI info.
For PCI sysfs resource mmap() the semantics are different. mmap() fails
only when devmem_is_allowed() says "no" *and* the kernel has marked the
range as IORESOURCE_BUSY in the iomem resource tree. That should be
sufficient to allow userpsace PCI drivers in TVMs because the goal here
is to avoid simultaneous mappings with mismatched encryption settings or
allowing userspace access to unaccepted private memory.
As long as the upcoming TDISP code is careful to hold a
request_resource() reservation over attempts to convert PCI MMIO from
shared to private, it should close any potential for mismatched
encryption settings, or access to unaccepted private MMIO.
However to get that behavior of not allowing simultaneous
kernel-ioremap() plus userspace mmap() of a PCI resource the kernel
needs to be built with CONFIG_IO_STRICT_DEVMEM=y. I note, for example
that RHEL does not set that, but Fedora does.
next prev parent reply other threads:[~2025-04-11 21:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-11 1:22 [PATCH v2 0/3] Restrict devmem for confidential VMs Dan Williams
2025-04-11 1:22 ` [PATCH v2 1/3] x86/devmem: Remove duplicate range_is_allowed() definition Dan Williams
2025-04-14 18:17 ` Naveen N Rao
2025-04-16 21:25 ` Dan Williams
2025-04-17 7:28 ` Naveen N Rao
2025-04-17 18:27 ` Dan Williams
2025-04-19 9:09 ` Naveen N Rao
2025-04-11 1:22 ` [PATCH v2 2/3] devmem: Block mmap access when read/write access is restricted Dan Williams
2025-04-11 2:32 ` Kees Cook
2025-04-11 4:59 ` Dan Williams
2025-04-11 15:38 ` Dave Hansen
2025-04-11 21:48 ` Dan Williams [this message]
2025-04-11 1:22 ` [PATCH v2 3/3] x86/devmem: Restrict /dev/mem access for potentially unaccepted memory by default Dan Williams
2025-04-14 18:22 ` Naveen N Rao
2025-04-16 21:30 ` Dan Williams
2025-04-14 10:56 ` [PATCH v2 0/3] Restrict devmem for confidential VMs Nikolay Borisov
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=67f98e27a799e_7205294e3@dwillia2-xfh.jf.intel.com.notmuch \
--to=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nik.borisov@suse.com \
/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.