1. 01 12月, 2022 1 次提交
  2. 01 11月, 2022 1 次提交
  3. 20 10月, 2022 1 次提交
  4. 04 10月, 2022 1 次提交
    • A
      asm-generic: instrument usercopy in cacheflush.h · 2b420aaf
      Alexander Potapenko 提交于
      Notify memory tools about usercopy events in copy_to_user_page() and
      copy_from_user_page().
      
      Link: https://lkml.kernel.org/r/20220915150417.722975-6-glider@google.comSigned-off-by: NAlexander Potapenko <glider@google.com>
      Reviewed-by: NMarco Elver <elver@google.com>
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Andrey Konovalov <andreyknvl@gmail.com>
      Cc: Andrey Konovalov <andreyknvl@google.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Cc: Eric Biggers <ebiggers@google.com>
      Cc: Eric Biggers <ebiggers@kernel.org>
      Cc: Eric Dumazet <edumazet@google.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Herbert Xu <herbert@gondor.apana.org.au>
      Cc: Ilya Leoshkevich <iii@linux.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Matthew Wilcox <willy@infradead.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Petr Mladek <pmladek@suse.com>
      Cc: Stephen Rothwell <sfr@canb.auug.org.au>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vasily Gorbik <gor@linux.ibm.com>
      Cc: Vegard Nossum <vegard.nossum@oracle.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      2b420aaf
  5. 28 9月, 2022 1 次提交
  6. 27 9月, 2022 2 次提交
  7. 26 9月, 2022 1 次提交
  8. 23 9月, 2022 1 次提交
  9. 17 9月, 2022 1 次提交
  10. 12 9月, 2022 1 次提交
  11. 10 9月, 2022 1 次提交
  12. 09 9月, 2022 3 次提交
  13. 07 9月, 2022 1 次提交
    • J
      kernel/module: add __dyndbg_classes section · 66f4006b
      Jim Cromie 提交于
      Add __dyndbg_classes section, using __dyndbg as a model. Use it:
      
      vmlinux.lds.h:
      
      KEEP the new section, which also silences orphan section warning on
      loadable modules.  Add (__start_/__stop_)__dyndbg_classes linker
      symbols for the c externs (below).
      
      kernel/module/main.c:
      - fill new fields in find_module_sections(), using section_objs()
      - extend callchain prototypes
        to pass classes, length
        load_module(): pass new info to dynamic_debug_setup()
        dynamic_debug_setup(): new params, pass through to ddebug_add_module()
      
      dynamic_debug.c:
      - add externs to the linker symbols.
      
      ddebug_add_module():
      - It currently builds a debug_table, and *will* find and attach classes.
      
      dynamic_debug_init():
      - add class fields to the _ddebug_info cursor var: di.
      Signed-off-by: NJim Cromie <jim.cromie@gmail.com>
      Link: https://lore.kernel.org/r/20220904214134.408619-16-jim.cromie@gmail.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66f4006b
  14. 05 9月, 2022 1 次提交
  15. 29 8月, 2022 1 次提交
    • Q
      asm-generic: sections: refactor memory_intersects · 0c7d7cc2
      Quanyang Wang 提交于
      There are two problems with the current code of memory_intersects:
      
      First, it doesn't check whether the region (begin, end) falls inside the
      region (virt, vend), that is (virt < begin && vend > end).
      
      The second problem is if vend is equal to begin, it will return true but
      this is wrong since vend (virt + size) is not the last address of the
      memory region but (virt + size -1) is.  The wrong determination will
      trigger the misreporting when the function check_for_illegal_area calls
      memory_intersects to check if the dma region intersects with stext region.
      
      The misreporting is as below (stext is at 0x80100000):
       WARNING: CPU: 0 PID: 77 at kernel/dma/debug.c:1073 check_for_illegal_area+0x130/0x168
       DMA-API: chipidea-usb2 e0002000.usb: device driver maps memory from kernel text or rodata [addr=800f0000] [len=65536]
       Modules linked in:
       CPU: 1 PID: 77 Comm: usb-storage Not tainted 5.19.0-yocto-standard #5
       Hardware name: Xilinx Zynq Platform
        unwind_backtrace from show_stack+0x18/0x1c
        show_stack from dump_stack_lvl+0x58/0x70
        dump_stack_lvl from __warn+0xb0/0x198
        __warn from warn_slowpath_fmt+0x80/0xb4
        warn_slowpath_fmt from check_for_illegal_area+0x130/0x168
        check_for_illegal_area from debug_dma_map_sg+0x94/0x368
        debug_dma_map_sg from __dma_map_sg_attrs+0x114/0x128
        __dma_map_sg_attrs from dma_map_sg_attrs+0x18/0x24
        dma_map_sg_attrs from usb_hcd_map_urb_for_dma+0x250/0x3b4
        usb_hcd_map_urb_for_dma from usb_hcd_submit_urb+0x194/0x214
        usb_hcd_submit_urb from usb_sg_wait+0xa4/0x118
        usb_sg_wait from usb_stor_bulk_transfer_sglist+0xa0/0xec
        usb_stor_bulk_transfer_sglist from usb_stor_bulk_srb+0x38/0x70
        usb_stor_bulk_srb from usb_stor_Bulk_transport+0x150/0x360
        usb_stor_Bulk_transport from usb_stor_invoke_transport+0x38/0x440
        usb_stor_invoke_transport from usb_stor_control_thread+0x1e0/0x238
        usb_stor_control_thread from kthread+0xf8/0x104
        kthread from ret_from_fork+0x14/0x2c
      
      Refactor memory_intersects to fix the two problems above.
      
      Before the 1d7db834 ("dma-debug: use memory_intersects()
      directly"), memory_intersects is called only by printk_late_init:
      
      printk_late_init -> init_section_intersects ->memory_intersects.
      
      There were few places where memory_intersects was called.
      
      When commit 1d7db834 ("dma-debug: use memory_intersects()
      directly") was merged and CONFIG_DMA_API_DEBUG is enabled, the DMA
      subsystem uses it to check for an illegal area and the calltrace above
      is triggered.
      
      [akpm@linux-foundation.org: fix nearby comment typo]
      Link: https://lkml.kernel.org/r/20220819081145.948016-1-quanyang.wang@windriver.com
      Fixes: 97955936 ("asm/sections: add helpers to check for section data")
      Signed-off-by: NQuanyang Wang <quanyang.wang@windriver.com>
      Cc: Ard Biesheuvel <ardb@kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      0c7d7cc2
  16. 27 8月, 2022 1 次提交
  17. 17 8月, 2022 1 次提交
    • H
      locking/atomic: Make test_and_*_bit() ordered on failure · 415d8324
      Hector Martin 提交于
      These operations are documented as always ordered in
      include/asm-generic/bitops/instrumented-atomic.h, and producer-consumer
      type use cases where one side needs to ensure a flag is left pending
      after some shared data was updated rely on this ordering, even in the
      failure case.
      
      This is the case with the workqueue code, which currently suffers from a
      reproducible ordering violation on Apple M1 platforms (which are
      notoriously out-of-order) that ends up causing the TTY layer to fail to
      deliver data to userspace properly under the right conditions.  This
      change fixes that bug.
      
      Change the documentation to restrict the "no order on failure" story to
      the _lock() variant (for which it makes sense), and remove the
      early-exit from the generic implementation, which is what causes the
      missing barrier semantics in that case.  Without this, the remaining
      atomic op is fully ordered (including on ARM64 LSE, as of recent
      versions of the architecture spec).
      Suggested-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Cc: stable@vger.kernel.org
      Fixes: e986a0d6 ("locking/atomics, asm-generic/bitops/atomic.h: Rewrite using atomic_*() APIs")
      Fixes: 61e02392 ("locking/atomic/bitops: Document and clarify ordering semantics for failed test_and_{}_bit()")
      Signed-off-by: NHector Martin <marcan@marcan.st>
      Acked-by: NWill Deacon <will@kernel.org>
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      415d8324
  18. 01 8月, 2022 1 次提交
  19. 30 7月, 2022 1 次提交
  20. 25 7月, 2022 1 次提交
    • J
      random: handle archrandom with multiple longs · d349ab99
      Jason A. Donenfeld 提交于
      The archrandom interface was originally designed for x86, which supplies
      RDRAND/RDSEED for receiving random words into registers, resulting in
      one function to generate an int and another to generate a long. However,
      other architectures don't follow this.
      
      On arm64, the SMCCC TRNG interface can return between one and three
      longs. On s390, the CPACF TRNG interface can return arbitrary amounts,
      with four longs having the same cost as one. On UML, the os_getrandom()
      interface can return arbitrary amounts.
      
      So change the api signature to take a "max_longs" parameter designating
      the maximum number of longs requested, and then return the number of
      longs generated.
      
      Since callers need to check this return value and loop anyway, each arch
      implementation does not bother implementing its own loop to try again to
      fill the maximum number of longs. Additionally, all existing callers
      pass in a constant max_longs parameter. Taken together, these two things
      mean that the codegen doesn't really change much for one-word-at-a-time
      platforms, while performance is greatly improved on platforms such as
      s390.
      Acked-by: NHeiko Carstens <hca@linux.ibm.com>
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Acked-by: NMichael Ellerman <mpe@ellerman.id.au>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
      d349ab99
  21. 23 7月, 2022 3 次提交
  22. 22 7月, 2022 4 次提交
    • L
      asm-generic: remove a broken and needless ifdef conditional · e2a619ca
      Lukas Bulwahn 提交于
      Commit 527701ed ("lib: Add a generic version of devmem_is_allowed()")
      introduces the config symbol GENERIC_LIB_DEVMEM_IS_ALLOWED, but then
      falsely refers to CONFIG_GENERIC_DEVMEM_IS_ALLOWED (note the missing LIB
      in the reference) in ./include/asm-generic/io.h.
      
      Luckily, ./scripts/checkkconfigsymbols.py warns on non-existing configs:
      
      GENERIC_DEVMEM_IS_ALLOWED
      Referencing files: include/asm-generic/io.h
      
      The actual fix, though, is simply to not to make this function declaration
      dependent on any kernel config. For architectures that intend to use
      the generic version, the arch's 'select GENERIC_LIB_DEVMEM_IS_ALLOWED' will
      lead to picking the function definition, and for other architectures, this
      function is simply defined elsewhere.
      
      The wrong '#ifndef' on a non-existing config symbol also always had the
      same effect (although more by mistake than by intent). So, there is no
      functional change.
      
      Remove this broken and needless ifdef conditional.
      
      Fixes: 527701ed ("lib: Add a generic version of devmem_is_allowed()")
      Signed-off-by: NLukas Bulwahn <lukas.bulwahn@gmail.com>
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      e2a619ca
    • P
      mmu_gather: Force tlb-flush VM_PFNMAP vmas · b67fbebd
      Peter Zijlstra 提交于
      Jann reported a race between munmap() and unmap_mapping_range(), where
      unmap_mapping_range() will no-op once unmap_vmas() has unlinked the
      VMA; however munmap() will not yet have invalidated the TLBs.
      
      Therefore unmap_mapping_range() will complete while there are still
      (stale) TLB entries for the specified range.
      
      Mitigate this by force flushing TLBs for VM_PFNMAP ranges.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NWill Deacon <will@kernel.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      b67fbebd
    • P
      mmu_gather: Let there be one tlb_{start,end}_vma() implementation · 18ba064e
      Peter Zijlstra 提交于
      Now that architectures are no longer allowed to override
      tlb_{start,end}_vma() re-arrange code so that there is only one
      implementation for each of these functions.
      
      This much simplifies trying to figure out what they actually do.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NWill Deacon <will@kernel.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      18ba064e
    • P
      mmu_gather: Remove per arch tlb_{start,end}_vma() · 1e9fdf21
      Peter Zijlstra 提交于
      Scattered across the archs are 3 basic forms of tlb_{start,end}_vma().
      Provide two new MMU_GATHER_knobs to enumerate them and remove the per
      arch tlb_{start,end}_vma() implementations.
      
       - MMU_GATHER_NO_FLUSH_CACHE indicates the arch has flush_cache_range()
         but does *NOT* want to call it for each VMA.
      
       - MMU_GATHER_MERGE_VMAS indicates the arch wants to merge the
         invalidate across multiple VMAs if possible.
      
      With these it is possible to capture the three forms:
      
        1) empty stubs;
           select MMU_GATHER_NO_FLUSH_CACHE and MMU_GATHER_MERGE_VMAS
      
        2) start: flush_cache_range(), end: empty;
           select MMU_GATHER_MERGE_VMAS
      
        3) start: flush_cache_range(), end: flush_tlb_range();
           default
      
      Obviously, if the architecture does not have flush_cache_range() then
      it also doesn't need to select MMU_GATHER_NO_FLUSH_CACHE.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NWill Deacon <will@kernel.org>
      Cc: David Miller <davem@davemloft.net>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1e9fdf21
  23. 18 7月, 2022 1 次提交
    • J
      random: remove CONFIG_ARCH_RANDOM · 9592eef7
      Jason A. Donenfeld 提交于
      When RDRAND was introduced, there was much discussion on whether it
      should be trusted and how the kernel should handle that. Initially, two
      mechanisms cropped up, CONFIG_ARCH_RANDOM, a compile time switch, and
      "nordrand", a boot-time switch.
      
      Later the thinking evolved. With a properly designed RNG, using RDRAND
      values alone won't harm anything, even if the outputs are malicious.
      Rather, the issue is whether those values are being *trusted* to be good
      or not. And so a new set of options were introduced as the real
      ones that people use -- CONFIG_RANDOM_TRUST_CPU and "random.trust_cpu".
      With these options, RDRAND is used, but it's not always credited. So in
      the worst case, it does nothing, and in the best case, maybe it helps.
      
      Along the way, CONFIG_ARCH_RANDOM's meaning got sort of pulled into the
      center and became something certain platforms force-select.
      
      The old options don't really help with much, and it's a bit odd to have
      special handling for these instructions when the kernel can deal fine
      with the existence or untrusted existence or broken existence or
      non-existence of that CPU capability.
      
      Simplify the situation by removing CONFIG_ARCH_RANDOM and using the
      ordinary asm-generic fallback pattern instead, keeping the two options
      that are actually used. For now it leaves "nordrand" for now, as the
      removal of that will take a different route.
      Acked-by: NMichael Ellerman <mpe@ellerman.id.au>
      Acked-by: NCatalin Marinas <catalin.marinas@arm.com>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NHeiko Carstens <hca@linux.ibm.com>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: NJason A. Donenfeld <Jason@zx2c4.com>
      9592eef7
  24. 01 7月, 2022 4 次提交
  25. 28 6月, 2022 1 次提交
    • A
      arch/*/: remove CONFIG_VIRT_TO_BUS · 4313a249
      Arnd Bergmann 提交于
      All architecture-independent users of virt_to_bus() and bus_to_virt()
      have been fixed to use the dma mapping interfaces or have been
      removed now.  This means the definitions on most architectures, and the
      CONFIG_VIRT_TO_BUS symbol are now obsolete and can be removed.
      
      The only exceptions to this are a few network and scsi drivers for m68k
      Amiga and VME machines and ppc32 Macintosh. These drivers work correctly
      with the old interfaces and are probably not worth changing.
      
      On alpha and parisc, virt_to_bus() were still used in asm/floppy.h.
      alpha can use isa_virt_to_bus() like x86 does, and parisc can just
      open-code the virt_to_phys() here, as this is architecture specific
      code.
      
      I tried updating the bus-virt-phys-mapping.rst documentation, which
      started as an email from Linus to explain some details of the Linux-2.0
      driver interfaces. The bits about virt_to_bus() were declared obsolete
      backin 2000, and the rest is not all that relevant any more, so in the
      end I just decided to remove the file completely.
      Reviewed-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Acked-by: Helge Deller <deller@gmx.de> # parisc
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      4313a249
  26. 27 6月, 2022 2 次提交
  27. 24 6月, 2022 1 次提交
  28. 15 6月, 2022 1 次提交