All of lore.kernel.org
 help / color / mirror / Atom feed
From: Naveen N Rao <naveen@kernel.org>
To: Nikolay Borisov <nik.borisov@suse.com>
Cc: x86@kernel.org, mhocko@suse.com, kas@kernel.org, ljs@kernel.org,
	 linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Kees Cook <kees@kernel.org>,  Ingo Molnar <mingo@kernel.org>,
	Vishal Annapurve <vannapurve@google.com>,
	 Kirill Shutemov <kirill.shutemov@linux.intel.com>,
	Arnd Bergmann <arnd@arndb.de>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	 Suzuki K Poulose <suzuki.poulose@arm.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	 Pedro Falcato <pfalcato@suse.de>
Subject: Re: [RESEND PATCH] x86/devmem: Drop /dev/mem access for confidential guests
Date: Fri, 27 Nov 2026 15:17:51 +0530	[thread overview]
Message-ID: <awlDUT0n3Uo4mjld@blrnaveerao1> (raw)
In-Reply-To: <8e8bda1f-dbcc-4f24-bc75-0b68bcc1a40c@suse.com>

On Thu, Nov 26, 2026 at 10:28:02AM +0200, Nikolay Borisov wrote:
> 
> > diff --git a/mm/char-mem.c b/mm/char-mem.c
> > index c5761ddedbd7..5d383befd87d 100644
> > --- a/mm/char-mem.c
> > +++ b/mm/char-mem.c
> > @@ -30,6 +30,7 @@
> >   #include <linux/uio.h>
> >   #include <linux/uaccess.h>
> >   #include <linux/security.h>
> > +#include <linux/cc_platform.h>
> >   #include "internal.h"
> > @@ -609,6 +610,15 @@ static int open_port(struct inode *inode, struct file *filp)
> >   	if (rc)
> >   		return rc;
> > +	/*
> > +	 * Enforce encrypted mapping consistency and avoid unaccepted
> > +	 * memory conflicts, "lockdown" /dev/mem for confidential
> > +	 * guests.
> > +	 */
> > +	if (IS_ENABLED(CONFIG_STRICT_DEVMEM) &&
> > +	    cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT))
> > +		return -EPERM;
> > +
> >   	if (iminor(inode) != DEVMEM_MINOR)
> >   		return 0;
> 
> Having taken a 2nd look I think a consensus solution would be if this check
> is moved inside devmem_is_allowed() for x86. That way /dev/mem could be
> opened but reads will simply return -EPERM. That way x86-specific checks
> don't leak into the generic mm code.

I arrived at the same conclusion. I believe the reason Dan chose to do 
it in open_port() is to mimic lockdown-style semantics so that userspace 
could detect and fall back (to using /sys/firmware/dmi/tables, for 
instance).

But, as far as I can tell:
(a) userspace should be able to deal with -EPERM from read()/mmap() too,
(b) and the tool failing is better than it crashing, or worse crashing 
the guest.

So, I think we can move the check to devmem_is_allowed() and reject all 
accesses for CoCo guests.


- Naveen



      reply	other threads:[~2026-11-27  9:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 16:00 [RESEND PATCH] x86/devmem: Drop /dev/mem access for confidential guests Nikolay Borisov
2026-11-24 16:29 ` Arnd Bergmann
2026-11-24 16:36 ` Dave Hansen
2026-11-24 17:10   ` Pedro Falcato
2026-11-24 17:35     ` Greg Kroah-Hartman
2026-11-24 17:53       ` Nikolay Borisov
2026-11-25  5:06         ` Greg Kroah-Hartman
2026-11-24 17:57     ` Nikolay Borisov
2026-11-25 16:51       ` Naveen N Rao
2026-11-26  7:17         ` Nikolay Borisov
2026-11-27  8:45           ` Naveen N Rao
2026-11-25 16:01 ` sashiko-bot
2026-11-26  8:28 ` Nikolay Borisov
2026-11-27  9:47   ` Naveen N Rao [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=awlDUT0n3Uo4mjld@blrnaveerao1 \
    --to=naveen@kernel.org \
    --cc=arnd@arndb.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kas@kernel.org \
    --cc=kees@kernel.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=mingo@kernel.org \
    --cc=mpe@ellerman.id.au \
    --cc=nik.borisov@suse.com \
    --cc=pfalcato@suse.de \
    --cc=suzuki.poulose@arm.com \
    --cc=vannapurve@google.com \
    --cc=x86@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.