Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Dec 10, 2021
  2. Dec 06, 2021
    • Vladimir Murzin's avatar
      percpu: km: ensure it is used with NOMMU (either UP or SMP) · 3583521a
      Vladimir Murzin authored
      Currently, NOMMU pull km allocator via !SMP dependency because most of
      them are UP, yet for SMP+NOMMU vm allocator gets pulled which:
      
      * may lead to broken build [1]
      * ...or not working runtime due to [2]
      
      It looks like SMP+NOMMU case was overlooked in bbddff05
      
       ("percpu:
      use percpu allocator on UP too") so restore that.
      
      [1]
      For ARM SMP+NOMMU (R-class cores)
      
      arm-none-linux-gnueabihf-ld: mm/percpu.o: in function `pcpu_post_unmap_tlb_flush':
      mm/percpu-vm.c:188: undefined reference to `flush_tlb_kernel_range'
      
      [2]
      static inline
      int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
                      pgprot_t prot, struct page **pages, unsigned int page_shift)
      {
             return -EINVAL;
      }
      
      Signed-off-by: default avatarVladimir Murzin <vladimir.murzin@arm.com>
      Tested-by: default avatarRob Landley <rob@landley.net>
      Tested-by: default avatarRich Felker <dalias@libc.org>
      [Dennis: use depends instead of default for condition]
      Signed-off-by: default avatarDennis Zhou <dennis@kernel.org>
      3583521a
  3. Dec 03, 2021
  4. Nov 22, 2021
    • Nadav Amit's avatar
      hugetlbfs: flush before unlock on move_hugetlb_page_tables() · 13e4ad2c
      Nadav Amit authored
      We must flush the TLB before releasing i_mmap_rwsem to avoid the
      potential reuse of an unshared PMDs page.  This is not true in the case
      of move_hugetlb_page_tables().  The last reference on the page table can
      therefore be dropped before the TLB flush took place.
      
      Prevent it by reordering the operations and flushing the TLB before
      releasing i_mmap_rwsem.
      
      Fixes: 550a7d60
      
       ("mm, hugepages: add mremap() support for hugepage backed vma")
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Cc: Mina Almasry <almasrymina@google.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      13e4ad2c
    • Nadav Amit's avatar
      hugetlbfs: flush TLBs correctly after huge_pmd_unshare · a4a118f2
      Nadav Amit authored
      When __unmap_hugepage_range() calls to huge_pmd_unshare() succeed, a TLB
      flush is missing.  This TLB flush must be performed before releasing the
      i_mmap_rwsem, in order to prevent an unshared PMDs page from being
      released and reused before the TLB flush took place.
      
      Arguably, a comprehensive solution would use mmu_gather interface to
      batch the TLB flushes and the PMDs page release, however it is not an
      easy solution: (1) try_to_unmap_one() and try_to_migrate_one() also call
      huge_pmd_unshare() and they cannot use the mmu_gather interface; and (2)
      deferring the release of the page reference for the PMDs page until
      after i_mmap_rwsem is dropeed can confuse huge_pmd_unshare() into
      thinking PMDs are shared when they are not.
      
      Fix __unmap_hugepage_range() by adding the missing TLB flush, and
      forcing a flush when unshare is successful.
      
      Fixes: 24669e58
      
       ("hugetlb: use mmu_gather instead of a temporary linked list for accumulating pages)" # 3.6
      Signed-off-by: default avatarNadav Amit <namit@vmware.com>
      Reviewed-by: default avatarMike Kravetz <mike.kravetz@oracle.com>
      Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
      Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a4a118f2
  5. Nov 20, 2021
  6. Nov 18, 2021
  7. Nov 17, 2021
  8. Nov 13, 2021
  9. Nov 11, 2021
  10. Nov 10, 2021
  11. Nov 09, 2021
    • David Hildenbrand's avatar
      kernel/resource: disallow access to exclusive system RAM regions · a9e7b8d4
      David Hildenbrand authored
      virtio-mem dynamically exposes memory inside a device memory region as
      system RAM to Linux, coordinating with the hypervisor which parts are
      actually "plugged" and consequently usable/accessible.
      
      On the one hand, the virtio-mem driver adds/removes whole memory blocks,
      creating/removing busy IORESOURCE_SYSTEM_RAM resources, on the other
      hand, it logically (un)plugs memory inside added memory blocks,
      dynamically either exposing them to the buddy or hiding them from the
      buddy and marking them PG_offline.
      
      In contrast to physical devices, like a DIMM, the virtio-mem driver is
      required to actually make use of any of the device-provided memory,
      because it performs the handshake with the hypervisor.  virtio-mem
      memory cannot simply be access via /dev/mem without a driver.
      
      There is no safe way to:
      a) Access plugged memory blocks via /dev/mem, as they might contain
         unplugged holes or might get silently unplugged by the virtio-mem
         driver and consequently turned inaccessible.
      b) Access unplugged memory blocks via /dev/mem because the virtio-mem
         driver is required to make them actually accessible first.
      
      The virtio-spec states that unplugged memory blocks MUST NOT be written,
      and only selected unplugged memory blocks MAY be read.  We want to make
      sure, this is the case in sane environments -- where the virtio-mem driver
      was loaded.
      
      We want to make sure that in a sane environment, nobody "accidentially"
      accesses unplugged memory inside the device managed region.  For example,
      a user might spot a memory region in /proc/iomem and try accessing it via
      /dev/mem via gdb or dumping it via something else.  By the time the mmap()
      happens, the memory might already have been removed by the virtio-mem
      driver silently: the mmap() would succeeed and user space might
      accidentially access unplugged memory.
      
      So once the driver was loaded and detected the device along the
      device-managed region, we just want to disallow any access via /dev/mem to
      it.
      
      In an ideal world, we would mark the whole region as busy ("owned by a
      driver") and exclude it; however, that would be wrong, as we don't really
      have actual system RAM at these ranges added to Linux ("busy system RAM").
      Instead, we want to mark such ranges as "not actual busy system RAM but
      still soft-reserved and prepared by a driver for future use."
      
      Let's teach iomem_is_exclusive() to reject access to any range with
      "IORESOURCE_SYSTEM_RAM | IORESOURCE_EXCLUSIVE", even if not busy and even
      if "iomem=relaxed" is set.  Introduce EXCLUSIVE_SYSTEM_RAM to make it
      easier for applicable drivers to depend on this setting in their Kconfig.
      
      For now, there are no applicable ranges and we'll modify virtio-mem next
      to properly set IORESOURCE_EXCLUSIVE on the parent resource container it
      creates to contain all actual busy system RAM added via
      add_memory_driver_managed().
      
      Link: https://lkml.kernel.org/r/20210920142856.17758-3-david@redhat.com
      
      
      Signed-off-by: default avatarDavid Hildenbrand <david@redhat.com>
      Reviewed-by: default avatarDan Williams <dan.j.williams@intel.com>
      Cc: Andy Shevchenko <andy.shevchenko@gmail.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Hanjun Guo <guohanjun@huawei.com>
      Cc: Jason Wang <jasowang@redhat.com>
      Cc: "Michael S. Tsirkin" <mst@redhat.com>
      Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      a9e7b8d4
    • Kefeng Wang's avatar
      mm: kasan: use is_kernel() helper · 3298cbe8
      Kefeng Wang authored
      Directly use is_kernel() helper in kernel_or_module_addr().
      
      Link: https://lkml.kernel.org/r/20210930071143.63410-8-wangkefeng.wang@huawei.com
      
      
      Signed-off-by: default avatarKefeng Wang <wangkefeng.wang@huawei.com>
      Reviewed-by: default avatarAlexander Potapenko <glider@google.com>
      Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
      Reviewed-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru>
      Cc: Matt Turner <mattst88@gmail.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Michal Simek <monstr@monstr.eu>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Richard Henderson <rth@twiddle.net>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3298cbe8
    • Imran Khan's avatar
      lib, stackdepot: add helper to print stack entries into buffer · 0f68d45e
      Imran Khan authored
      To print stack entries into a buffer, users of stackdepot, first get a
      list of stack entries using stack_depot_fetch and then print this list
      into a buffer using stack_trace_snprint.  Provide a helper in stackdepot
      for this purpose.  Also change above mentioned users to use this helper.
      
      [imran.f.khan@oracle.com: fix build error]
        Link: https://lkml.kernel.org/r/20210915175321.3472770-4-imran.f.khan@oracle.com
      [imran.f.khan@oracle.com: export stack_depot_snprint() to modules]
        Link: https://lkml.kernel.org/r/20210916133535.3592491-4-imran.f.khan@oracle.com
      
      Link: https://lkml.kernel.org/r/20210915014806.3206938-4-imran.f.khan@oracle.com
      
      
      Signed-off-by: default avatarImran Khan <imran.f.khan@oracle.com>
      Suggested-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: Jani Nikula <jani.nikula@intel.com>	[i915]
      Cc: Alexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0f68d45e
    • Imran Khan's avatar
      lib, stackdepot: add helper to print stack entries · 505be481
      Imran Khan authored
      To print a stack entries, users of stackdepot, first use stack_depot_fetch
      to get a list of stack entries and then use stack_trace_print to print
      this list.  Provide a helper in stackdepot to print stack entries based on
      stackdepot handle.  Also change above mentioned users to use this helper.
      
      Link: https://lkml.kernel.org/r/20210915014806.3206938-3-imran.f.khan@oracle.com
      
      
      Signed-off-by: default avatarImran Khan <imran.f.khan@oracle.com>
      Suggested-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Acked-by: default avatarVlastimil Babka <vbabka@suse.cz>
      Reviewed-by: default avatarAlexander Potapenko <glider@google.com>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
      Cc: Daniel Vetter <daniel@ffwll.ch>
      Cc: David Airlie <airlied@linux.ie>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
      Cc: Maxime Ripard <mripard@kernel.org>
      Cc: Thomas Zimmermann <tzimmermann@suse.de>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      505be481