lkml.org 
[lkml]   [2017]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: ce56a86e2a ("x86/mm: Limit mmap() of /dev/mem to valid physical addresses"): kernel BUG at arch/x86/mm/physaddr.c:79!

* Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Thu, Oct 26, 2017 at 9:02 PM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > Well, 'mem=2048M' shouldn't really limit device memory, it's supposed to limit
> > (trim) 'RAM' and not much else.
>
> Agreed. You should very much be able to map in IO memory or whatever
> above the 2G address even if the high_memory itself might be limited
> to 2GB.
>
> So I think that commit ce56a86e2ade ("x86/mm: Limit mmap() of /dev/mem
> to valid physical addresses") is wrong, in that "high_memory" is very
> much the wrong thing to test.
>
> The memory mapping limit might validly be something like
>
> 1ull << boot_cpu_data.x86_phys_bits
>
> or similar, but for now I suspect that the right thing to do is to
> revert. I'm not convinced that our "x86_phys_bits" value is guaranteed
> to be always right, since I think we mainlyjust use it for showing
> things, rather than have lots of code that depends on it.
>
> Ingo?

Yeah, I think a more robust condition would be something like:

int valid_phys_addr_range(phys_addr_t addr, size_t count)
{
return !((addr + count) >> MAX_PHYSMEM_BITS);
}

... as we already rely on MAX_PHYSMEM_BITS in a number of other critical places.

(Totally untested though.)

Thanks,

Ingo

\
 
 \ /
  Last update: 2017-10-28 20:16    [W:0.155 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site