Skip to content
Snippets Groups Projects
  1. Sep 02, 2023
    • Greg Kroah-Hartman's avatar
    • Yonghong Song's avatar
      kallsyms: Fix kallsyms_selftest failure · 7ed58960
      Yonghong Song authored
      
      commit 33f0467f upstream.
      
      Kernel test robot reported a kallsyms_test failure when clang lto is
      enabled (thin or full) and CONFIG_KALLSYMS_SELFTEST is also enabled.
      I can reproduce in my local environment with the following error message
      with thin lto:
        [    1.877897] kallsyms_selftest: Test for 1750th symbol failed: (tsc_cs_mark_unstable) addr=ffffffff81038090
        [    1.877901] kallsyms_selftest: abort
      
      It appears that commit 8cc32a9b ("kallsyms: strip LTO-only suffixes
      from promoted global functions") caused the failure. Commit 8cc32a9b
      changed cleanup_symbol_name() based on ".llvm." instead of '.' where
      ".llvm." is appended to a before-lto-optimization local symbol name.
      We need to propagate such knowledge in kallsyms_selftest.c as well.
      
      Further more, compare_symbol_name() in kallsyms.c needs change as well.
      In scripts/kallsyms.c, kallsyms_names and kallsyms_seqs_of_names are used
      to record symbol names themselves and index to symbol names respectively.
      For example:
        kallsyms_names:
          ...
          __amd_smn_rw._entry       <== seq 1000
          __amd_smn_rw._entry.5     <== seq 1001
          __amd_smn_rw.llvm.<hash>  <== seq 1002
          ...
      
      kallsyms_seqs_of_names are sorted based on cleanup_symbol_name() through, so
      the order in kallsyms_seqs_of_names actually has
      
        index 1000:   seq 1002   <== __amd_smn_rw.llvm.<hash> (actual symbol comparison using '__amd_smn_rw')
        index 1001:   seq 1000   <== __amd_smn_rw._entry
        index 1002:   seq 1001   <== __amd_smn_rw._entry.5
      
      Let us say at a particular point, at index 1000, symbol '__amd_smn_rw.llvm.<hash>'
      is comparing to '__amd_smn_rw._entry' where '__amd_smn_rw._entry' is the one to
      search e.g., with function kallsyms_on_each_match_symbol(). The current implementation
      will find out '__amd_smn_rw._entry' is less than '__amd_smn_rw.llvm.<hash>' and
      then continue to search e.g., index 999 and never found a match although the actual
      index 1001 is a match.
      
      To fix this issue, let us do cleanup_symbol_name() first and then do comparison.
      In the above case, comparing '__amd_smn_rw' vs '__amd_smn_rw._entry' and
      '__amd_smn_rw._entry' being greater than '__amd_smn_rw', the next comparison will
      be > index 1000 and eventually index 1001 will be hit an a match is found.
      
      For any symbols not having '.llvm.' substr, there is no functionality change
      for compare_symbol_name().
      
      Fixes: 8cc32a9b ("kallsyms: strip LTO-only suffixes from promoted global functions")
      Reported-by: default avatarkernel test robot <oliver.sang@intel.com>
      Closes: https://lore.kernel.org/oe-lkp/202308232200.1c932a90-oliver.sang@intel.com
      
      
      Signed-off-by: default avatarYonghong Song <yonghong.song@linux.dev>
      Reviewed-by: default avatarSong Liu <song@kernel.org>
      Reviewed-by: default avatarZhen Lei <thunder.leizhen@huawei.com>
      Link: https://lore.kernel.org/r/20230825034659.1037627-1-yonghong.song@linux.dev
      
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ed58960
    • Helge Deller's avatar
      lockdep: fix static memory detection even more · 23520b44
      Helge Deller authored
      commit 0a6b58c5 upstream.
      
      On the parisc architecture, lockdep reports for all static objects which
      are in the __initdata section (e.g. "setup_done" in devtmpfs,
      "kthreadd_done" in init/main.c) this warning:
      
      	INFO: trying to register non-static key.
      
      The warning itself is wrong, because those objects are in the __initdata
      section, but the section itself is on parisc outside of range from
      _stext to _end, which is why the static_obj() functions returns a wrong
      answer.
      
      While fixing this issue, I noticed that the whole existing check can
      be simplified a lot.
      Instead of checking against the _stext and _end symbols (which include
      code areas too) just check for the .data and .bss segments (since we check a
      data object). This can be done with the existing is_kernel_core_data()
      macro.
      
      In addition objects in the __initdata section can be checked with
      init_section_contains(), and is_kernel_rodata() allows keys to be in the
      _ro_after_init section.
      
      This partly reverts and simplifies commit bac59d18 ("x86/setup: Fix static
      memory detection").
      
      Link: https://lkml.kernel.org/r/ZNqrLRaOi/3wPAdp@p100
      
      
      Fixes: bac59d18 ("x86/setup: Fix static memory detection")
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: "Rafael J. Wysocki" <rafael@kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      23520b44
    • Eric Dumazet's avatar
      ipv6: remove hard coded limitation on ipv6_pinfo · c8df2560
      Eric Dumazet authored
      
      commit f5f80e32 upstream.
      
      IPv6 inet sockets are supposed to have a "struct ipv6_pinfo"
      field at the end of their definition, so that inet6_sk_generic()
      can derive from socket size the offset of the "struct ipv6_pinfo".
      
      This is very fragile, and prevents adding bigger alignment
      in sockets, because inet6_sk_generic() does not work
      if the compiler adds padding after the ipv6_pinfo component.
      
      We are currently working on a patch series to reorganize
      TCP structures for better data locality and found issues
      similar to the one fixed in commit f5d54767
      ("tcp: fix tcp_inet6_sk() for 32bit kernels")
      
      Alternative would be to force an alignment on "struct ipv6_pinfo",
      greater or equal to __alignof__(any ipv6 sock) to ensure there is
      no padding. This does not look great.
      
      v2: fix typo in mptcp_proto_v6_init() (Paolo)
      
      Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
      Cc: Chao Wu <wwchao@google.com>
      Cc: Wei Wang <weiwan@google.com>
      Cc: Coco Li <lixiaoyan@google.com>
      Cc: YiFei Zhu <zhuyifei@google.com>
      Reviewed-by: default avatarSimon Horman <simon.horman@corigine.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      Cc: Jakub Kicinski <kuba@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c8df2560
    • Andrea Righi's avatar
      module/decompress: use vmalloc() for zstd decompression workspace · c1b8d8c1
      Andrea Righi authored
      
      commit a419beac upstream.
      
      Using kmalloc() to allocate the decompression workspace for zstd may
      trigger the following warning when large modules are loaded (i.e., xfs):
      
      [    2.961884] WARNING: CPU: 1 PID: 254 at mm/page_alloc.c:4453 __alloc_pages+0x2c3/0x350
      ...
      [    2.989033] Call Trace:
      [    2.989841]  <TASK>
      [    2.990614]  ? show_regs+0x6d/0x80
      [    2.991573]  ? __warn+0x89/0x160
      [    2.992485]  ? __alloc_pages+0x2c3/0x350
      [    2.993520]  ? report_bug+0x17e/0x1b0
      [    2.994506]  ? handle_bug+0x51/0xa0
      [    2.995474]  ? exc_invalid_op+0x18/0x80
      [    2.996469]  ? asm_exc_invalid_op+0x1b/0x20
      [    2.997530]  ? module_zstd_decompress+0xdc/0x2a0
      [    2.998665]  ? __alloc_pages+0x2c3/0x350
      [    2.999695]  ? module_zstd_decompress+0xdc/0x2a0
      [    3.000821]  __kmalloc_large_node+0x7a/0x150
      [    3.001920]  __kmalloc+0xdb/0x170
      [    3.002824]  module_zstd_decompress+0xdc/0x2a0
      [    3.003857]  module_decompress+0x37/0xc0
      [    3.004688]  init_module_from_file+0xd0/0x100
      [    3.005668]  idempotent_init_module+0x11c/0x2b0
      [    3.006632]  __x64_sys_finit_module+0x64/0xd0
      [    3.007568]  do_syscall_64+0x59/0x90
      [    3.008373]  ? ksys_read+0x73/0x100
      [    3.009395]  ? exit_to_user_mode_prepare+0x30/0xb0
      [    3.010531]  ? syscall_exit_to_user_mode+0x37/0x60
      [    3.011662]  ? do_syscall_64+0x68/0x90
      [    3.012511]  ? do_syscall_64+0x68/0x90
      [    3.013364]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
      
      However, continuous physical memory does not seem to be required in
      module_zstd_decompress(), so use vmalloc() instead, to prevent the
      warning and avoid potential failures at loading compressed modules.
      
      Fixes: 169a58ad ("module/decompress: Support zstd in-kernel decompression")
      Signed-off-by: default avatarAndrea Righi <andrea.righi@canonical.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c1b8d8c1
    • James Morse's avatar
      ARM: module: Use module_init_layout_section() to spot init sections · 7e339e06
      James Morse authored
      
      commit a6846234 upstream.
      
      Today module_frob_arch_sections() spots init sections from their
      'init' prefix, and uses this to keep the init PLTs separate from the rest.
      
      get_module_plt() uses within_module_init() to determine if a
      location is in the init text or not, but this depends on whether
      core code thought this was an init section.
      
      Naturally the logic is different.
      
      module_init_layout_section() groups the init and exit text together if
      module unloading is disabled, as the exit code will never run. The result
      is kernels with this configuration can't load all their modules because
      there are not enough PLTs for the combined init+exit section.
      
      A previous patch exposed module_init_layout_section(), use that so the
      logic is the same.
      
      Fixes: 055f23b7 ("module: check for exit sections in layout_sections() instead of module_init_section()")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e339e06
    • James Morse's avatar
      arm64: module: Use module_init_layout_section() to spot init sections · a67496bf
      James Morse authored
      
      commit f928f8b1 upstream.
      
      Today module_frob_arch_sections() spots init sections from their
      'init' prefix, and uses this to keep the init PLTs separate from the rest.
      
      module_emit_plt_entry() uses within_module_init() to determine if a
      location is in the init text or not, but this depends on whether
      core code thought this was an init section.
      
      Naturally the logic is different.
      
      module_init_layout_section() groups the init and exit text together if
      module unloading is disabled, as the exit code will never run. The result
      is kernels with this configuration can't load all their modules because
      there are not enough PLTs for the combined init+exit section.
      
      This results in the following:
      | WARNING: CPU: 2 PID: 51 at arch/arm64/kernel/module-plts.c:99 module_emit_plt_entry+0x184/0x1cc
      | Modules linked in: crct10dif_common
      | CPU: 2 PID: 51 Comm: modprobe Not tainted 6.5.0-rc4-yocto-standard-dirty #15208
      | Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
      | pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      | pc : module_emit_plt_entry+0x184/0x1cc
      | lr : module_emit_plt_entry+0x94/0x1cc
      | sp : ffffffc0803bba60
      [...]
      | Call trace:
      |  module_emit_plt_entry+0x184/0x1cc
      |  apply_relocate_add+0x2bc/0x8e4
      |  load_module+0xe34/0x1bd4
      |  init_module_from_file+0x84/0xc0
      |  __arm64_sys_finit_module+0x1b8/0x27c
      |  invoke_syscall.constprop.0+0x5c/0x104
      |  do_el0_svc+0x58/0x160
      |  el0_svc+0x38/0x110
      |  el0t_64_sync_handler+0xc0/0xc4
      |  el0t_64_sync+0x190/0x194
      
      A previous patch exposed module_init_layout_section(), use that so the
      logic is the same.
      
      Reported-by: default avatarAdam Johnston <adam.johnston@arm.com>
      Tested-by: default avatarAdam Johnston <adam.johnston@arm.com>
      Fixes: 055f23b7 ("module: check for exit sections in layout_sections() instead of module_init_section()")
      Cc: <stable@vger.kernel.org> # 5.15.x: 60a0aab7 arm64: module-plts: inline linux/moduleloader.h
      Cc: <stable@vger.kernel.org> # 5.15.x
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Acked-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a67496bf
    • James Morse's avatar
      module: Expose module_init_layout_section() · 3f359197
      James Morse authored
      
      commit 2abcc4b5 upstream.
      
      module_init_layout_section() choses whether the core module loader
      considers a section as init or not. This affects the placement of the
      exit section when module unloading is disabled. This code will never run,
      so it can be free()d once the module has been initialised.
      
      arm and arm64 need to count the number of PLTs they need before applying
      relocations based on the section name. The init PLTs are stored separately
      so they can be free()d. arm and arm64 both use within_module_init() to
      decide which list of PLTs to use when applying the relocation.
      
      Because within_module_init()'s behaviour changes when module unloading
      is disabled, both architecture would need to take this into account when
      counting the PLTs.
      
      Today neither architecture does this, meaning when module unloading is
      disabled there are insufficient PLTs in the init section to load some
      modules, resulting in warnings:
      | WARNING: CPU: 2 PID: 51 at arch/arm64/kernel/module-plts.c:99 module_emit_plt_entry+0x184/0x1cc
      | Modules linked in: crct10dif_common
      | CPU: 2 PID: 51 Comm: modprobe Not tainted 6.5.0-rc4-yocto-standard-dirty #15208
      | Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015
      | pstate: 20400005 (nzCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      | pc : module_emit_plt_entry+0x184/0x1cc
      | lr : module_emit_plt_entry+0x94/0x1cc
      | sp : ffffffc0803bba60
      [...]
      | Call trace:
      |  module_emit_plt_entry+0x184/0x1cc
      |  apply_relocate_add+0x2bc/0x8e4
      |  load_module+0xe34/0x1bd4
      |  init_module_from_file+0x84/0xc0
      |  __arm64_sys_finit_module+0x1b8/0x27c
      |  invoke_syscall.constprop.0+0x5c/0x104
      |  do_el0_svc+0x58/0x160
      |  el0_svc+0x38/0x110
      |  el0t_64_sync_handler+0xc0/0xc4
      |  el0t_64_sync+0x190/0x194
      
      Instead of duplicating module_init_layout_section()s logic, expose it.
      
      Reported-by: default avatarAdam Johnston <adam.johnston@arm.com>
      Fixes: 055f23b7 ("module: check for exit sections in layout_sections() instead of module_init_section()")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarJames Morse <james.morse@arm.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3f359197
    • Mario Limonciello's avatar
      ACPI: thermal: Drop nocrt parameter · 4e726924
      Mario Limonciello authored
      
      commit 5f641174 upstream.
      
      The `nocrt` module parameter has no code associated with it and does
      nothing.  As `crt=-1` has same functionality as what nocrt should be
      doing drop `nocrt` and associated documentation.
      
      This should fix a quirk for Gigabyte GA-7ZX that used `nocrt` and
      thus didn't function properly.
      
      Fixes: 8c99fdce ("ACPI: thermal: set "thermal.nocrt" via DMI on Gigabyte GA-7ZX")
      Signed-off-by: default avatarMario Limonciello <mario.limonciello@amd.com>
      Cc: All applicable <stable@vger.kernel.org>
      Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e726924
  2. Aug 27, 2023
  3. Aug 26, 2023
    • Linus Torvalds's avatar
      Merge tag 'x86-urgent-2023-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 28f20a19
      Linus Torvalds authored
      Pull x86 fixes from Ingo Molnar:
       "Fix an FPU invalidation bug on exec(), and fix a performance
        regression due to a missing setting of X86_FEATURE_OSXSAVE"
      
      * tag 'x86-urgent-2023-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/fpu: Set X86_FEATURE_OSXSAVE feature after enabling OSXSAVE in CR4
        x86/fpu: Invalidate FPU state correctly on exec()
      28f20a19
    • Linus Torvalds's avatar
      Merge tag 'irq-urgent-2023-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 3b35375f
      Linus Torvalds authored
      Pull irq fix from Thomas Gleixner:
       "A last minute fix for a regression introduced in the v6.5 merge
        window.
      
        The conversion of the software based interrupt resend mechanism to
        hlist missed to add a check whether the descriptor is already enqueued
        and dropped the interrupt descriptor lookup for nested interrupts.
      
        The missing check whether the descriptor is already queued causes
        hlist corruption and can be observed in the wild. The dropped parent
        descriptor lookup has not yet caused problems, but it would result in
        stale interrupt line in the worst case.
      
        Add the missing enqueued check and bring the descriptor lookup back to
        cure this"
      
      * tag 'irq-urgent-2023-08-26' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        genirq: Fix software resend lockup and nested resend
      3b35375f
    • Linus Torvalds's avatar
      Merge tag 'loongarch-fixes-6.5-2' of... · c3137613
      Linus Torvalds authored
      Merge tag 'loongarch-fixes-6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
      
      Pull LoongArch fixes from Huacai Chen:
       "Fix a ptrace bug, a hw_breakpoint bug, some build errors/warnings and
        some trivial cleanups"
      
      * tag 'loongarch-fixes-6.5-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
        LoongArch: Fix hw_breakpoint_control() for watchpoints
        LoongArch: Ensure FP/SIMD registers in the core dump file is up to date
        LoongArch: Put the body of play_dead() into arch_cpu_idle_dead()
        LoongArch: Add identifier names to arguments of die() declaration
        LoongArch: Return earlier in die() if notify_die() returns NOTIFY_STOP
        LoongArch: Do not kill the task in die() if notify_die() returns NOTIFY_STOP
        LoongArch: Remove <asm/export.h>
        LoongArch: Replace #include <asm/export.h> with #include <linux/export.h>
        LoongArch: Remove unneeded #include <asm/export.h>
        LoongArch: Replace -ffreestanding with finer-grained -fno-builtin's
        LoongArch: Remove redundant "source drivers/firmware/Kconfig"
      c3137613
    • Johan Hovold's avatar
      genirq: Fix software resend lockup and nested resend · 9f5deb55
      Johan Hovold authored
      
      The switch to using hlist for managing software resend of interrupts
      broke resend in at least two ways:
      
      First, unconditionally adding interrupt descriptors to the resend list can
      corrupt the list when the descriptor in question has already been
      added. This causes the resend tasklet to loop indefinitely with interrupts
      disabled as was recently reported with the Lenovo ThinkPad X13s after
      threaded NAPI was disabled in the ath11k WiFi driver.
      
      This bug is easily fixed by restoring the old semantics of irq_sw_resend()
      so that it can be called also for descriptors that have already been marked
      for resend.
      
      Second, the offending commit also broke software resend of nested
      interrupts by simply discarding the code that made sure that such
      interrupts are retriggered using the parent interrupt.
      
      Add back the corresponding code that adds the parent descriptor to the
      resend list.
      
      Fixes: bc06a9e0 ("genirq: Use hlist for managing resend handlers")
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: default avatarMarc Zyngier <maz@kernel.org>
      Link: https://lore.kernel.org/lkml/20230809073432.4193-1-johan+linaro@kernel.org/
      Link: https://lore.kernel.org/r/20230826154004.1417-1-johan+linaro@kernel.org
      9f5deb55
    • Huacai Chen's avatar
      LoongArch: Fix hw_breakpoint_control() for watchpoints · 9730870b
      Huacai Chen authored
      
      In hw_breakpoint_control(), encode_ctrl_reg() has already encoded the
      MWPnCFG3_LoadEn/MWPnCFG3_StoreEn bits in info->ctrl. We don't need to
      add (1 << MWPnCFG3_LoadEn | 1 << MWPnCFG3_StoreEn) unconditionally.
      
      Otherwise we can't set read watchpoint and write watchpoint separately.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      9730870b
    • Huacai Chen's avatar
      LoongArch: Ensure FP/SIMD registers in the core dump file is up to date · 656f9aec
      Huacai Chen authored
      
      This is a port of commit 379eb01c ("riscv: Ensure the value
      of FP registers in the core dump file is up to date").
      
      The values of FP/SIMD registers in the core dump file come from the
      thread.fpu. However, kernel saves the FP/SIMD registers only before
      scheduling out the process. If no process switch happens during the
      exception handling, kernel will not have a chance to save the latest
      values of FP/SIMD registers. So it may cause their values in the core
      dump file incorrect. To solve this problem, force fpr_get()/simd_get()
      to save the FP/SIMD registers into the thread.fpu if the target task
      equals the current task.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      656f9aec
    • Linus Torvalds's avatar
      Merge tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux · 7d2f353b
      Linus Torvalds authored
      Pull clk fixes from Stephen Boyd:
       "One clk driver fix and two clk framework fixes:
      
         - Fix an OOB access when devm_get_clk_from_child() is used and
           devm_clk_release() casts the void pointer to the wrong type
      
         - Move clk_rate_exclusive_{get,put}() within the correct ifdefs in
           clk.h so that the stubs are used when CONFIG_COMMON_CLK=n
      
         - Register the proper clk provider function depending on the value of
           #clock-cells in the TI keystone driver"
      
      * tag 'clk-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/clk/linux:
        clk: Fix slab-out-of-bounds error in devm_clk_release()
        clk: Fix undefined reference to `clk_rate_exclusive_{get,put}'
        clk: keystone: syscon-clk: Fix audio refclk
      7d2f353b
  4. Aug 25, 2023
    • Helge Deller's avatar
      lib/clz_ctz.c: Fix __clzdi2() and __ctzdi2() for 32-bit kernels · 382d4cd1
      Helge Deller authored
      
      The gcc compiler translates on some architectures the 64-bit
      __builtin_clzll() function to a call to the libgcc function __clzdi2(),
      which should take a 64-bit parameter on 32- and 64-bit platforms.
      
      But in the current kernel code, the built-in __clzdi2() function is
      defined to operate (wrongly) on 32-bit parameters if BITS_PER_LONG ==
      32, thus the return values on 32-bit kernels are in the range from
      [0..31] instead of the expected [0..63] range.
      
      This patch fixes the in-kernel functions __clzdi2() and __ctzdi2() to
      take a 64-bit parameter on 32-bit kernels as well, thus it makes the
      functions identical for 32- and 64-bit kernels.
      
      This bug went unnoticed since kernel 3.11 for over 10 years, and here
      are some possible reasons for that:
      
       a) Some architectures have assembly instructions to count the bits and
          which are used instead of calling __clzdi2(), e.g. on x86 the bsr
          instruction and on ppc cntlz is used. On such architectures the
          wrong __clzdi2() implementation isn't used and as such the bug has
          no effect and won't be noticed.
      
       b) Some architectures link to libgcc.a, and the in-kernel weak
          functions get replaced by the correct 64-bit variants from libgcc.a.
      
       c) __builtin_clzll() and __clzdi2() doesn't seem to be used in many
          places in the kernel, and most likely only in uncritical functions,
          e.g. when printing hex values via seq_put_hex_ll(). The wrong return
          value will still print the correct number, but just in a wrong
          formatting (e.g. with too many leading zeroes).
      
       d) 32-bit kernels aren't used that much any longer, so they are less
          tested.
      
      A trivial testcase to verify if the currently running 32-bit kernel is
      affected by the bug is to look at the output of /proc/self/maps:
      
      Here the kernel uses a correct implementation of __clzdi2():
      
        root@debian:~# cat /proc/self/maps
        00010000-00019000 r-xp 00000000 08:05 787324     /usr/bin/cat
        00019000-0001a000 rwxp 00009000 08:05 787324     /usr/bin/cat
        0001a000-0003b000 rwxp 00000000 00:00 0          [heap]
        f7551000-f770d000 r-xp 00000000 08:05 794765     /usr/lib/hppa-linux-gnu/libc.so.6
        ...
      
      and this kernel uses the broken implementation of __clzdi2():
      
        root@debian:~# cat /proc/self/maps
        0000000010000-0000000019000 r-xp 00000000 000000008:000000005 787324  /usr/bin/cat
        0000000019000-000000001a000 rwxp 000000009000 000000008:000000005 787324  /usr/bin/cat
        000000001a000-000000003b000 rwxp 00000000 00:00 0  [heap]
        00000000f73d1000-00000000f758d000 r-xp 00000000 000000008:000000005 794765  /usr/lib/hppa-linux-gnu/libc.so.6
        ...
      
      Signed-off-by: default avatarHelge Deller <deller@gmx.de>
      Fixes: 4df87bb7 ("lib: add weak clz/ctz functions")
      Cc: Chanho Min <chanho.min@lge.com>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: stable@vger.kernel.org # v3.11+
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      382d4cd1
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2023-08-25-11-07' of... · 6f0edbb8
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2023-08-25-11-07' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull misc fixes from Andrew Morton:
       "18 hotfixes. 13 are cc:stable and the remainder pertain to post-6.4
        issues or aren't considered suitable for a -stable backport"
      
      * tag 'mm-hotfixes-stable-2023-08-25-11-07' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        shmem: fix smaps BUG sleeping while atomic
        selftests: cachestat: catch failing fsync test on tmpfs
        selftests: cachestat: test for cachestat availability
        maple_tree: disable mas_wr_append() when other readers are possible
        madvise:madvise_free_pte_range(): don't use mapcount() against large folio for sharing check
        madvise:madvise_free_huge_pmd(): don't use mapcount() against large folio for sharing check
        madvise:madvise_cold_or_pageout_pte_range(): don't use mapcount() against large folio for sharing check
        mm: multi-gen LRU: don't spin during memcg release
        mm: memory-failure: fix unexpected return value in soft_offline_page()
        radix tree: remove unused variable
        mm: add a call to flush_cache_vmap() in vmap_pfn()
        selftests/mm: FOLL_LONGTERM need to be updated to 0x100
        nilfs2: fix general protection fault in nilfs_lookup_dirty_data_buffers()
        mm/gup: handle cont-PTE hugetlb pages correctly in gup_must_unshare() via GUP-fast
        selftests: cgroup: fix test_kmem_basic less than error
        mm: enable page walking API to lock vmas during the walk
        smaps: use vm_normal_page_pmd() instead of follow_trans_huge_pmd()
        mm/gup: reintroduce FOLL_NUMA as FOLL_HONOR_NUMA_FAULT
      6f0edbb8
    • Linus Torvalds's avatar
      Merge tag 'riscv-for-linus-6.5-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux · 4942fed8
      Linus Torvalds authored
      Pull RISC-V fixes from Palmer Dabbelt:
       "This is obviously not ideal, particularly for something this late in
        the cycle.
      
        Unfortunately we found some uABI issues in the vector support while
        reviewing the GDB port, which has triggered a revert -- probably a
        good sign we should have reviewed GDB before merging this, I guess I
        just dropped the ball because I was so worried about the context
        extension and libc suff I forgot. Hence the late revert.
      
        There's some risk here as we're still exposing the vector context for
        signal handlers, but changing that would have meant reverting all of
        the vector support. The issues we've found so far have been fixed
        already and they weren't absolute showstoppers, so we're essentially
        just playing it safe by holding ptrace support for another release (or
        until we get through a proper userspace code review).
      
        Summary:
      
         - The vector ucontext extension has been extended with vlenb
      
         - The vector registers ELF core dump note type has been changed to
           avoid aliasing with the CSR type used in embedded systems
      
         - Support for accessing vector registers via ptrace() has been
           reverted
      
         - Another build fix for the ISA spec changes around Zifencei/Zicsr
           that manifests on some systems built with binutils-2.37 and
           gcc-11.2"
      
      * tag 'riscv-for-linus-6.5-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
        riscv: Fix build errors using binutils2.37 toolchains
        RISC-V: vector: export VLENB csr in __sc_riscv_v_state
        RISC-V: Remove ptrace support for vectors
      4942fed8
    • Linus Torvalds's avatar
      Merge tag 'gpio-fixes-for-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux · 98c6b8a5
      Linus Torvalds authored
      Pull gpio fixes from Bartosz Golaszewski:
      
       - fix an irq mapping leak in gpio-sim
      
       - associate the GPIO device's software node with the irq domain in
         gpio-sim
      
      * tag 'gpio-fixes-for-v6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
        gpio: sim: pass the GPIO device's software node to irq domain
        gpio: sim: dispose of irq mappings before destroying the irq_sim domain
      98c6b8a5
    • Linus Torvalds's avatar
      Merge tag 'pinctrl-v6.5-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl · a87eaffb
      Linus Torvalds authored
      Pull pin control fixes from Linus Walleij:
       "Here are some Renesas and AMD driver fixes, the AMD fix affects
        important laptops in the wild so this one is pretty important. It
        seems a bit tough to get this right.
      
         - Fix DT parsing and related locking in the Renesas driver.
      
         - Fix wakeup IRQs in the AMD driver once again. Really tricky this
           one"
      
      * tag 'pinctrl-v6.5-4' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
        pinctrl: amd: Mask wake bits on probe again
        pinctrl: renesas: rza2: Add lock around pinctrl_generic{{add,remove}_group,{add,remove}_function}
        pinctrl: renesas: rzv2m: Fix NULL pointer dereference in rzv2m_dt_subnode_to_map()
        pinctrl: renesas: rzg2l: Fix NULL pointer dereference in rzg2l_dt_subnode_to_map()
      a87eaffb
    • Linus Torvalds's avatar
      Merge tag 'sound-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · ced5bf24
      Linus Torvalds authored
      Pull sound fixes from Takashi Iwai:
       "Hopefully the last bits for 6.5. It's slightly higher LOCs than
        wished, but it doesn't look scary.
      
        The biggest change is MAINTAINERS update for TI; it's good to have the
        update before the final release, so that people can contact to the
        right persons for bug reports (which shouldn't happen of course!)
      
        The rest are all device-specific fixes and quirks, most for various
        ASoC platforms"
      
      * tag 'sound-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound:
        ASoC: amd: yc: Fix a non-functional mic on Lenovo 82SJ
        ALSA: ymfpci: Fix the missing snd_card_free() call at probe error
        ASoC: cs35l41: Correct amp_gain_tlv values
        ASoC: amd: yc: Add VivoBook Pro 15 to quirks list for acp6x
        ASoC: tas2781: fixed register access error when switching to other chips
        ASoC: cs35l56: Add an ACPI match table
        ASoC: cs35l56: Read firmware uuid from a device property instead of _SUB
        ASoC: SOF: ipc4-pcm: fix possible null pointer deference
        MAINTAINERS: Add entries for TEXAS INSTRUMENTS ASoC DRIVERS
      ced5bf24
    • Tiezhu Yang's avatar
      LoongArch: Put the body of play_dead() into arch_cpu_idle_dead() · c337c849
      Tiezhu Yang authored
      
      The initial aim is to silence the following objtool warning:
      
      arch/loongarch/kernel/process.o: warning: objtool: arch_cpu_idle_dead() falls through to next function start_thread()
      
      According to tools/objtool/Documentation/objtool.txt, this is because
      the last instruction of arch_cpu_idle_dead() is a call to a noreturn
      function play_dead(). In order to silence the warning, one simple way
      is to add the noreturn function play_dead() to objtool's hard-coded
      global_noreturns array, that is to say, just put "NORETURN(play_dead)"
      into tools/objtool/noreturns.h, it works well.
      
      But I noticed that play_dead() is only defined once and only called by
      arch_cpu_idle_dead(), so put the body of play_dead() into the caller
      arch_cpu_idle_dead(), then remove the noreturn function play_dead() is
      an alternative way which can reduce the overhead of the function call
      at the same time.
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      c337c849
    • Tiezhu Yang's avatar
      LoongArch: Add identifier names to arguments of die() declaration · 8879515e
      Tiezhu Yang authored
      
      Add identifier names to arguments of die() declaration in ptrace.h
      to fix the following checkpatch warnings:
      
        WARNING: function definition argument 'const char *' should also have an identifier name
        WARNING: function definition argument 'struct pt_regs *' should also have an identifier name
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      8879515e
    • Tiezhu Yang's avatar
      LoongArch: Return earlier in die() if notify_die() returns NOTIFY_STOP · a038ae71
      Tiezhu Yang authored
      
      After the call to oops_exit(), it should not panic or execute
      the crash kernel if the oops is to be suppressed.
      
      Suggested-by: default avatarMaciej W. Rozycki <macro@orcam.me.uk>
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      a038ae71
    • Tiezhu Yang's avatar
      LoongArch: Do not kill the task in die() if notify_die() returns NOTIFY_STOP · 6933c11f
      Tiezhu Yang authored
      If notify_die() returns NOTIFY_STOP, honor the return value from the
      handler chain invocation in die() and return without killing the task
      as, through a debugger, the fault may have been fixed. It makes sense
      even if ignoring the event will make the system unstable: by allowing
      access through a debugger it has been compromised already anyway. It
      makes our port consistent with x86, arm64, riscv and csky.
      
      Commit 20c0d2d4 ("[PATCH] i386: pass proper trap numbers to die
      chain handlers") may be the earliest of similar changes.
      
      Link: https://lore.kernel.org/r/43DDF02E.76F0.0078.0@novell.com/
      
      
      Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      6933c11f
    • Masahiro Yamada's avatar
      LoongArch: Remove <asm/export.h> · a746ceb1
      Masahiro Yamada authored
      
      All *.S files under arch/loongarch/ have been converted to include
      <linux/export.h> instead of <asm/export.h>.
      
      Remove <asm/export.h>.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      a746ceb1
    • Masahiro Yamada's avatar
      LoongArch: Replace #include <asm/export.h> with #include <linux/export.h> · 55b46ff9
      Masahiro Yamada authored
      
      Commit ddb5cdba ("kbuild: generate KSYMTAB entries by modpost")
      deprecated <asm/export.h>, which is now a wrapper of <linux/export.h>.
      
      Replace #include <asm/export.h> with #include <linux/export.h>.
      
      After all the <asm/export.h> lines are converted, <asm/export.h> and
      <asm-generic/export.h> will be removed.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      55b46ff9
    • Masahiro Yamada's avatar
      LoongArch: Remove unneeded #include <asm/export.h> · 347aa8de
      Masahiro Yamada authored
      
      There is no EXPORT_SYMBOL() line there, hence #include <asm/export.h>
      is unneeded.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      347aa8de
    • WANG Xuerui's avatar
      LoongArch: Replace -ffreestanding with finer-grained -fno-builtin's · 3f301dc2
      WANG Xuerui authored
      As explained by Nick in the original issue: the kernel usually does a
      good job of providing library helpers that have similar semantics as
      their ordinary userspace libc equivalents, but -ffreestanding disables
      such libcall optimization and other related features in the compiler,
      which can lead to unexpected things such as CONFIG_FORTIFY_SOURCE not
      working (!).
      
      However, due to the desire for better control over unaligned accesses
      with respect to CONFIG_ARCH_STRICT_ALIGN, and also for avoiding the
      GCC bug https://gcc.gnu.org/PR109465, we do want to still disable
      optimizations for the memory libcalls (memcpy, memmove and memset for
      now). Use finer-grained -fno-builtin-* toggles to achieve this without
      losing source fortification and other libcall optimizations.
      
      Closes: https://github.com/ClangBuiltLinux/linux/issues/1897
      
      
      Reported-by: default avatarNathan Chancellor <nathan@kernel.org>
      Suggested-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarWANG Xuerui <git@xen0n.name>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      3f301dc2
    • Xi Ruoyao's avatar
      LoongArch: Remove redundant "source drivers/firmware/Kconfig" · b8e2771b
      Xi Ruoyao authored
      
      In drivers/Kconfig, drivers/firmware/Kconfig is sourced for all ports so
      there is no need to source it in the port-specific Kconfig file.  And
      sourcing it here also caused the "Firmware Drivers" menu appeared two
      times: one in the "Device Drivers" menu, another in the toplevel menu.
      This is really puzzling so remove it.
      
      Reviewed-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarXi Ruoyao <xry111@xry111.site>
      Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
      b8e2771b
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2023-08-25' of git://anongit.freedesktop.org/drm/drm · beaa71d6
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "A bit bigger than I'd care for, but it's mostly a single vmwgfx fix
        and a fix for an i915 hotplug probing. Otherwise misc i915, bridge,
        panfrost and dma-buf fixes.
      
        core:
         - add a HPD poll helper
      
        i915:
         - fix regression in i915 polling
         - fix docs build warning
         - fix DG2 idle power consumption
      
        bridge:
         - samsung-dsim: init fix
      
        panfrost:
         - fix speed binning issue
      
        dma-buf:
         - fix recursive lock in fence signal
      
        vmwgfx:
         - fix shader stage validation
         - fix NULL ptr derefs in gem put"
      
      * tag 'drm-fixes-2023-08-25' of git://anongit.freedesktop.org/drm/drm:
        drm/i915: Fix HPD polling, reenabling the output poll work as needed
        drm: Add an HPD poll helper to reschedule the poll work
        drm/vmwgfx: Fix possible invalid drm gem put calls
        drm/vmwgfx: Fix shader stage validation
        dma-buf/sw_sync: Avoid recursive lock during fence signal
        drm/i915: fix Sphinx indentation warning
        drm/i915/dgfx: Enable d3cold at s2idle
        drm/display/dp: Fix the DP DSC Receiver cap size
        drm/panfrost: Skip speed binning on EOPNOTSUPP
        drm: bridge: samsung-dsim: Fix init during host transfer
      beaa71d6
    • Takashi Iwai's avatar
      Merge tag 'asoc-fix-v6.5-rc7-2' of... · 37e44d60
      Takashi Iwai authored
      Merge tag 'asoc-fix-v6.5-rc7-2' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus
      
      ASoC: Quirk for v6.5
      
      One additional fix for v6.5, an additional quirk.  As with the other
      fixes this could wait for the merge window.
      37e44d60
    • Linus Torvalds's avatar
      Merge tag 'trace-v6.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace · 4f9e7fab
      Linus Torvalds authored
      Pull tracing fixes from Steven Rostedt:
      
       - Fix ring buffer being permanently disabled due to missed
         record_disabled()
      
         Changing the trace cpu mask will disable the ring buffers for the
         CPUs no longer in the mask. But it fails to update the snapshot
         buffer. If a snapshot takes place, the accounting for the ring buffer
         being disabled is corrupted and this can lead to the ring buffer
         being permanently disabled.
      
       - Add test case for snapshot and cpu mask working together
      
       - Fix memleak by the function graph tracer not getting closed properly.
      
         The iterator is used to read the ring buffer. When it opens, it calls
         the open function of a tracer, and when it is closed, it calls the
         close iteration. While a trace is being read, it is still possible to
         change the tracer.
      
         If this happens between the function graph tracer and the wakeup
         tracer (which uses function graph tracing), the tracers are not
         closed properly during when the iterator sees the switch, and the
         wakeup function did not initialize its private pointer to NULL, which
         is used to know if the function graph tracer was the last tracer. It
         could be fooled in thinking it is, but then on exit it does not call
         the close function of the function graph tracer to clean up its data.
      
       - Fix synthetic events on big endian machines, by introducing a union
         that does the conversions properly.
      
       - Fix synthetic events from printing out the number of elements in the
         stacktrace when it shouldn't.
      
       - Fix synthetic events stacktrace to not print a bogus value at the
         end.
      
       - Introduce a pipe_cpumask that prevents the trace_pipe files from
         being opened by more than one task (file descriptor).
      
         There was a race found where if splice is called, the iter->ent could
         become stale and events could be missed. There's no point reading a
         producer/consumer file by more than one task as they will corrupt
         each other anyway. Add a cpumask that keeps track of the per_cpu
         trace_pipe files as well as the global trace_pipe file that prevents
         more than one open of a trace_pipe file that represents the same ring
         buffer. This prevents the race from happening.
      
       - Fix ftrace samples for arm64 to work with older compilers.
      
      * tag 'trace-v6.5-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
        samples: ftrace: Replace bti assembly with hint for older compiler
        tracing: Introduce pipe_cpumask to avoid race on trace_pipes
        tracing: Fix memleak due to race between current_tracer and trace
        tracing/synthetic: Allocate one additional element for size
        tracing/synthetic: Skip first entry for stack traces
        tracing/synthetic: Use union instead of casts
        selftests/ftrace: Add a basic testcase for snapshot
        tracing: Fix cpu buffers unavailable due to 'record_disabled' missed
      4f9e7fab
    • Zhu Wang's avatar
      scsi: snic: Fix double free in snic_tgt_create() · 1bd3a768
      Zhu Wang authored
      
      Commit 41320b18 ("scsi: snic: Fix possible memory leak if device_add()
      fails") fixed the memory leak caused by dev_set_name() when device_add()
      failed. However, it did not consider that 'tgt' has already been released
      when put_device(&tgt->dev) is called. Remove kfree(tgt) in the error path
      to avoid double free of 'tgt' and move put_device(&tgt->dev) after the
      removed kfree(tgt) to avoid a use-after-free.
      
      Fixes: 41320b18 ("scsi: snic: Fix possible memory leak if device_add() fails")
      Signed-off-by: default avatarZhu Wang <wangzhu9@huawei.com>
      Link: https://lore.kernel.org/r/20230819083941.164365-1-wangzhu9@huawei.com
      
      
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      1bd3a768
    • Linus Torvalds's avatar
      Merge tag 'media/v6.5-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media · 14ddccc8
      Linus Torvalds authored
      Pull media fix from Mauro Carvalho Chehab:
       "Fix a potential array out-of-bounds in the mediatek vcodec driver"
      
      * tag 'media/v6.5-4' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media:
        media: vcodec: Fix potential array out-of-bounds in encoder queue_setup
      14ddccc8
    • Zhu Wang's avatar
      scsi: core: raid_class: Remove raid_component_add() · 60c5fd2e
      Zhu Wang authored
      
      The raid_component_add() function was added to the kernel tree via patch
      "[SCSI] embryonic RAID class" (2005). Remove this function since it never
      has had any callers in the Linux kernel. And also raid_component_release()
      is only used in raid_component_add(), so it is also removed.
      
      Signed-off-by: default avatarZhu Wang <wangzhu9@huawei.com>
      Link: https://lore.kernel.org/r/20230822015254.184270-1-wangzhu9@huawei.com
      
      
      Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
      Fixes: 04b5b5cb ("scsi: core: Fix possible memory leak if device_add() fails")
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      60c5fd2e
  5. Aug 24, 2023
Loading