Skip to content
  • Kees Cook's avatar
    usercopy: Avoid HIGHMEM pfn warning · 314eed30
    Kees Cook authored
    When running on a system with >512MB RAM with a 32-bit kernel built with:
    
    	CONFIG_DEBUG_VIRTUAL=y
    	CONFIG_HIGHMEM=y
    	CONFIG_HARDENED_USERCOPY=y
    
    all execve()s will fail due to argv copying into kmap()ed pages, and on
    usercopy checking the calls ultimately of virt_to_page() will be looking
    for "bad" kmap (highmem) pointers due to CONFIG_DEBUG_VIRTUAL=y:
    
     ------------[ cut here ]------------
     kernel BUG at ../arch/x86/mm/physaddr.c:83!
     invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
     CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.3.0-rc8 #6
     Hardware name: Dell Inc. Inspiron 1318/0C236D, BIOS A04 01/15/2009
     EIP: __phys_addr+0xaf/0x100
     ...
     Call Trace:
      __check_object_size+0xaf/0x3c0
      ? __might_sleep+0x80/0xa0
      copy_strings+0x1c2/0x370
      copy_strings_kernel+0x2b/0x40
      __do_execve_file+0x4ca/0x810
      ? kmem_cache_alloc+0x1c7/0x370
      do_execve+0x1b/0x20
      ...
    
    The check is from arch/x86/mm/physaddr.c:
    
    	VIRTUAL_BUG_ON((phys_addr >> PAGE_SHIFT) > max_low_pfn);
    
    Due...
    314eed30