Skip to content
  • Kees Cook's avatar
    /dev/mem: Add bounce buffer for copy-out · 22ec1a2a
    Kees Cook authored
    As done for /proc/kcore in
    
      commit df04abfd
    
     ("fs/proc/kcore.c: Add bounce buffer for ktext data")
    
    this adds a bounce buffer when reading memory via /dev/mem. This
    is needed to allow kernel text memory to be read out when built with
    CONFIG_HARDENED_USERCOPY (which refuses to read out kernel text) and
    without CONFIG_STRICT_DEVMEM (which would have refused to read any RAM
    contents at all).
    
    Since this build configuration isn't common (most systems with
    CONFIG_HARDENED_USERCOPY also have CONFIG_STRICT_DEVMEM), this also tries
    to inform Kconfig about the recommended settings.
    
    This patch is modified from Brad Spengler/PaX Team's changes to /dev/mem
    code in the last public patch of grsecurity/PaX based on my understanding
    of the code. Changes or omissions from the original code are mine and
    don't reflect the original grsecurity/PaX code.
    
    Reported-by: default avatarMichael Holzheu <holzheu@linux.vnet.ibm.com>
    Fixes: f5509cc1
    
     ("mm: Hardened usercopy")
    Signed-off-by: default avatarKees Cook <keescook@chromium.org>
    Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    22ec1a2a