Skip to content
  1. Sep 04, 2020
    • Catalin Marinas's avatar
      arm64: mte: Allow user control of the generated random tags via prctl() · af5ce952
      Catalin Marinas authored
      
      
      The IRG, ADDG and SUBG instructions insert a random tag in the resulting
      address. Certain tags can be excluded via the GCR_EL1.Exclude bitmap
      when, for example, the user wants a certain colour for freed buffers.
      Since the GCR_EL1 register is not accessible at EL0, extend the
      prctl(PR_SET_TAGGED_ADDR_CTRL) interface to include a 16-bit field in
      the first argument for controlling which tags can be generated by the
      above instruction (an include rather than exclude mask). Note that by
      default all non-zero tags are excluded. This setting is per-thread.
      
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      af5ce952
    • Catalin Marinas's avatar
      arm64: mte: Allow user control of the tag check mode via prctl() · 1c101da8
      Catalin Marinas authored
      
      
      By default, even if PROT_MTE is set on a memory range, there is no tag
      check fault reporting (SIGSEGV). Introduce a set of option to the
      exiting prctl(PR_SET_TAGGED_ADDR_CTRL) to allow user control of the tag
      check fault mode:
      
        PR_MTE_TCF_NONE  - no reporting (default)
        PR_MTE_TCF_SYNC  - synchronous tag check fault reporting
        PR_MTE_TCF_ASYNC - asynchronous tag check fault reporting
      
      These options translate into the corresponding SCTLR_EL1.TCF0 bitfield,
      context-switched by the kernel. Note that the kernel accesses to the
      user address space (e.g. read() system call) are not checked if the user
      thread tag checking mode is PR_MTE_TCF_NONE or PR_MTE_TCF_ASYNC. If the
      tag checking mode is PR_MTE_TCF_SYNC, the kernel makes a best effort to
      check its user address accesses, however it cannot always guarantee it.
      
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      1c101da8
    • Catalin Marinas's avatar
      arm64: mte: Tags-aware aware memcmp_pages() implementation · 4d1a8a2d
      Catalin Marinas authored
      
      
      When the Memory Tagging Extension is enabled, two pages are identical
      only if both their data and tags are identical.
      
      Make the generic memcmp_pages() a __weak function and add an
      arm64-specific implementation which returns non-zero if any of the two
      pages contain valid MTE tags (PG_mte_tagged set). There isn't much
      benefit in comparing the tags of two pages since these are normally used
      for heap allocations and likely to differ anyway.
      
      Co-developed-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      4d1a8a2d
    • Catalin Marinas's avatar
      arm64: mte: Clear the tags when a page is mapped in user-space with PROT_MTE · 34bfeea4
      Catalin Marinas authored
      
      
      Pages allocated by the kernel are not guaranteed to have the tags
      zeroed, especially as the kernel does not (yet) use MTE itself. To
      ensure the user can still access such pages when mapped into its address
      space, clear the tags via set_pte_at(). A new page flag - PG_mte_tagged
      (PG_arch_2) - is used to track pages with valid allocation tags.
      
      Since the zero page is mapped as pte_special(), it won't be covered by
      the above set_pte_at() mechanism. Clear its tags during early MTE
      initialisation.
      
      Co-developed-by: default avatarSteven Price <steven.price@arm.com>
      Signed-off-by: default avatarSteven Price <steven.price@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      34bfeea4
    • Vincenzo Frascino's avatar
      arm64: mte: Handle synchronous and asynchronous tag check faults · 637ec831
      Vincenzo Frascino authored
      
      
      The Memory Tagging Extension has two modes of notifying a tag check
      fault at EL0, configurable through the SCTLR_EL1.TCF0 field:
      
      1. Synchronous raising of a Data Abort exception with DFSC 17.
      2. Asynchronous setting of a cumulative bit in TFSRE0_EL1.
      
      Add the exception handler for the synchronous exception and handling of
      the asynchronous TFSRE0_EL1.TF0 bit setting via a new TIF flag in
      do_notify_resume().
      
      On a tag check failure in user-space, whether synchronous or
      asynchronous, a SIGSEGV will be raised on the faulting thread.
      
      Signed-off-by: default avatarVincenzo Frascino <vincenzo.frascino@arm.com>
      Co-developed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Cc: Will Deacon <will@kernel.org>
      637ec831
  2. Sep 03, 2020
  3. Aug 28, 2020
    • James Morse's avatar
      KVM: arm64: Add kvm_extable for vaxorcism code · e9ee186b
      James Morse authored
      
      
      KVM has a one instruction window where it will allow an SError exception
      to be consumed by the hypervisor without treating it as a hypervisor bug.
      This is used to consume asynchronous external abort that were caused by
      the guest.
      
      As we are about to add another location that survives unexpected exceptions,
      generalise this code to make it behave like the host's extable.
      
      KVM's version has to be mapped to EL2 to be accessible on nVHE systems.
      
      The SError vaxorcism code is a one instruction window, so has two entries
      in the extable. Because the KVM code is copied for VHE and nVHE, we end up
      with four entries, half of which correspond with code that isn't mapped.
      
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      e9ee186b
  4. Aug 27, 2020
  5. Aug 26, 2020
  6. Aug 23, 2020
  7. Aug 21, 2020
  8. Aug 12, 2020
  9. Aug 08, 2020
  10. Aug 07, 2020
    • Andrey Konovalov's avatar
      kasan, arm64: don't instrument functions that enable kasan · f9409d58
      Andrey Konovalov authored
      This patch prepares Software Tag-Based KASAN for stack tagging support.
      
      With stack tagging enabled, KASAN tags stack variable in each function in
      its prologue.  In start_kernel() stack variables get tagged before KASAN
      is enabled via setup_arch()->kasan_init().  As the result the tags for
      start_kernel()'s stack variables end up in the temporary shadow memory.
      Later when KASAN gets enabled, switched to normal shadow, and starts
      checking tags, this leads to false-positive reports, as proper tags are
      missing in normal shadow.
      
      Disable KASAN instrumentation for start_kernel().  Also disable it for
      arm64's setup_arch() as a precaution (it doesn't have any stack variables
      right now).
      
      [andreyknvl@google.com: reorder attributes for start_kernel()]
        Link: http://lkml.kernel.org/r/26fb6165a17abcf61222eda5184c030fb6b133d1.1596544734.git.andreyknvl@google.com
      
      
      
      Signed-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Acked-by: Catalin Marinas <catalin.marinas@arm.com>	[arm64]
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Elena Petrova <lenaptr@google.com>
      Cc: Marco Elver <elver@google.com>
      Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
      Cc: Walter Wu <walter-zh.wu@mediatek.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Link: http://lkml.kernel.org/r/55d432671a92e931ab8234b03dc36b14d4c21bfb.1596199677.git.andreyknvl@google.com
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f9409d58
    • Mike Rapoport's avatar
      mm: remove unneeded includes of <asm/pgalloc.h> · ca15ca40
      Mike Rapoport authored
      
      
      Patch series "mm: cleanup usage of <asm/pgalloc.h>"
      
      Most architectures have very similar versions of pXd_alloc_one() and
      pXd_free_one() for intermediate levels of page table.  These patches add
      generic versions of these functions in <asm-generic/pgalloc.h> and enable
      use of the generic functions where appropriate.
      
      In addition, functions declared and defined in <asm/pgalloc.h> headers are
      used mostly by core mm and early mm initialization in arch and there is no
      actual reason to have the <asm/pgalloc.h> included all over the place.
      The first patch in this series removes unneeded includes of
      <asm/pgalloc.h>
      
      In the end it didn't work out as neatly as I hoped and moving
      pXd_alloc_track() definitions to <asm-generic/pgalloc.h> would require
      unnecessary changes to arches that have custom page table allocations, so
      I've decided to move lib/ioremap.c to mm/ and make pgalloc-track.h local
      to mm/.
      
      This patch (of 8):
      
      In most cases <asm/pgalloc.h> header is required only for allocations of
      page table memory.  Most of the .c files that include that header do not
      use symbols declared in <asm/pgalloc.h> and do not require that header.
      
      As for the other header files that used to include <asm/pgalloc.h>, it is
      possible to move that include into the .c file that actually uses symbols
      from <asm/pgalloc.h> and drop the include from the header file.
      
      The process was somewhat automated using
      
      	sed -i -E '/[<"]asm\/pgalloc\.h/d' \
                      $(grep -L -w -f /tmp/xx \
                              $(git grep -E -l '[<"]asm/pgalloc\.h'))
      
      where /tmp/xx contains all the symbols defined in
      arch/*/include/asm/pgalloc.h.
      
      [rppt@linux.ibm.com: fix powerpc warning]
      
      Signed-off-by: default avatarMike Rapoport <rppt@linux.ibm.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Reviewed-by: default avatarPekka Enberg <penberg@kernel.org>
      Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>	[m68k]
      Cc: Abdul Haleem <abdhalee@linux.vnet.ibm.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: Joerg Roedel <joro@8bytes.org>
      Cc: Max Filippov <jcmvbkbc@gmail.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Satheesh Rajendran <sathnaga@linux.vnet.ibm.com>
      Cc: Stafford Horne <shorne@gmail.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Joerg Roedel <jroedel@suse.de>
      Cc: Matthew Wilcox <willy@infradead.org>
      Link: http://lkml.kernel.org/r/20200627143453.31835-1-rppt@kernel.org
      Link: http://lkml.kernel.org/r/20200627143453.31835-2-rppt@kernel.org
      
      
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      ca15ca40
    • Guenter Roeck's avatar
      arm64: kaslr: Use standard early random function · 9bceb80b
      Guenter Roeck authored
      
      
      Commit 58552408 ("random: random.h should include archrandom.h, not
      the other way around") tries to fix a problem with recursive inclusion
      of linux/random.h and arch/archrandom.h for arm64.  Unfortunately, this
      results in the following compile error if ARCH_RANDOM is disabled.
      
        arch/arm64/kernel/kaslr.c: In function 'kaslr_early_init':
        arch/arm64/kernel/kaslr.c:128:6: error: implicit declaration of function '__early_cpu_has_rndr'; did you mean '__early_pfn_to_nid'? [-Werror=implicit-function-declaration]
          if (__early_cpu_has_rndr()) {
              ^~~~~~~~~~~~~~~~~~~~
              __early_pfn_to_nid
        arch/arm64/kernel/kaslr.c:131:7: error: implicit declaration of function '__arm64_rndr' [-Werror=implicit-function-declaration]
           if (__arm64_rndr(&raw))
               ^~~~~~~~~~~~
      
      The problem is that arch/archrandom.h is only included from
      linux/random.h if ARCH_RANDOM is enabled.  If not, __arm64_rndr() and
      __early_cpu_has_rndr() are undeclared, causing the problem.
      
      Use arch_get_random_seed_long_early() instead of arm64 specific
      functions to solve the problem.
      
      Reported-by: default avatarQian Cai <cai@lca.pw>
      Fixes: 58552408 ("random: random.h should include archrandom.h, not the other way around")
      Cc: Qian Cai <cai@lca.pw>
      Cc: Mark Brown <broonie@kernel.org>
      Reviewed-by: default avatarMark Rutland <mark.rutland@arm.com>
      Reviewed-by: default avatarMark Brown <broonie@kernel.org>
      Tested-by: default avatarMark Brown <broonie@kernel.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      9bceb80b
  11. Aug 05, 2020
  12. Jul 31, 2020
  13. Jul 28, 2020
  14. Jul 27, 2020
  15. Jul 24, 2020
  16. Jul 23, 2020
  17. Jul 21, 2020
  18. Jul 20, 2020
  19. Jul 16, 2020
Loading