lkml.org 
[lkml]   [2022]   [Apr]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4] /dev/mem: Revoke mappings when a driver claims the region
On Thu, Apr 7, 2022 at 11:47 AM Dan Williams <dan.j.williams@intel.com> wrote:
>
> On Wed, Apr 6, 2022 at 12:46 PM Kees Cook <keescook@chromium.org> wrote:
> >
> > *thread necromancy*
>
> It's alive!
>
> >
> > Hi Dan,
> >
> > I'm doing a KSPP bug scrub and am reviewing
> > https://github.com/KSPP/linux/issues/74 again.
> >
> > Do you have a chance to look at this? I'd love a way to make mmap()
> > behave the same way as read() for the first meg of /dev/mem.
>
> You want 0-reads or SIGBUS when attempting to access the first 1MB?
>
> Because it sounds like what you want is instead of loudly failing with
> -EPERM in drivers/char/mem.c::mmap_mem() you want it to silently
> succeed but swap in the zero page, right? Otherwise if it's SIGBUS
> then IO_STRICT_DEVMEM=y + marking that span as IORESOURCE_BUSY will
> "Do the Right Thing (TM).".

In other words, if IO_STRICT_DEVMEM is enabled then the enforcement is
already there at least for anything marked IORESOURCE_BUSY. So if
tools are ok with that protection today, maybe there is no need to do
the zero page dance. I.e. legacy tools the read(2) /dev/mem below 1MB
get zeroes, and apparently no tools were mmap'ing below 1MB otherwise
they would have complained by now? At least Fedora is shipping
IO_STRICT_DEVMEM these days:

https://src.fedoraproject.org/rpms/kernel/blob/rawhide/f/kernel-x86_64-fedora.config#_2799

\
 
 \ /
  Last update: 2022-04-08 01:46    [W:0.086 / U:0.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site