Skip to content
  1. Mar 06, 2024
    • Aneesh Kumar K.V (IBM)'s avatar
      mm/debug_vm_pgtable: fix BUG_ON with pud advanced test · d2a9510c
      Aneesh Kumar K.V (IBM) authored
      commit 720da1e5 upstream.
      
      Architectures like powerpc add debug checks to ensure we find only devmap
      PUD pte entries.  These debug checks are only done with CONFIG_DEBUG_VM.
      This patch marks the ptes used for PUD advanced test devmap pte entries so
      that we don't hit on debug checks on architecture like ppc64 as below.
      
      WARNING: CPU: 2 PID: 1 at arch/powerpc/mm/book3s64/radix_pgtable.c:1382 radix__pud_hugepage_update+0x38/0x138
      ....
      NIP [c0000000000a7004] radix__pud_hugepage_update+0x38/0x138
      LR [c0000000000a77a8] radix__pudp_huge_get_and_clear+0x28/0x60
      Call Trace:
      [c000000004a2f950] [c000000004a2f9a0] 0xc000000004a2f9a0 (unreliable)
      [c000000004a2f980] [000d34c100000000] 0xd34c100000000
      [c000000004a2f9a0] [c00000000206ba98] pud_advanced_tests+0x118/0x334
      [c000000004a2fa40] [c00000000206db34] debug_vm_pgtable+0xcbc/0x1c48
      [c000000004a2fc10] [c00000000000fd28] do_one_initcall+0x60/0x388
      
      Also
      
       kernel BUG at arch/powerpc/mm/book3s64/pgtable.c:202!
       ....
      
       NIP [c000000000096510] pudp_huge_get_and_clear_full+0x98/0x174
       LR [c00000000206bb34] pud_advanced_tests+0x1b4/0x334
       Call Trace:
       [c000000004a2f950] [000d34c100000000] 0xd34c100000000 (unreliable)
       [c000000004a2f9a0] [c00000000206bb34] pud_advanced_tests+0x1b4/0x334
       [c000000004a2fa40] [c00000000206db34] debug_vm_pgtable+0xcbc/0x1c48
       [c000000004a2fc10] [c00000000000fd28] do_one_initcall+0x60/0x388
      
      Link: https://lkml.kernel.org/r/20240129060022.68044-1-aneesh.kumar@kernel.org
      Fixes: 27af67f3
      
       ("powerpc/book3s64/mm: enable transparent pud hugepage")
      Signed-off-by: default avatarAneesh Kumar K.V (IBM) <aneesh.kumar@kernel.org>
      Cc: Anshuman Khandual <anshuman.khandual@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d2a9510c
    • Bjorn Andersson's avatar
      pmdomain: qcom: rpmhpd: Fix enabled_corner aggregation · e9eeb0dd
      Bjorn Andersson authored
      commit 2a93c6cb upstream.
      
      Commit 'e3e56c05 ("soc: qcom: rpmhpd: Make power_on actually enable
      the domain")' aimed to make sure that a power-domain that is being
      enabled without any particular performance-state requested will at least
      turn the rail on, to avoid filling DeviceTree with otherwise unnecessary
      required-opps properties.
      
      But in the event that aggregation happens on a disabled power-domain, with
      an enabled peer without performance-state, both the local and peer
      corner are 0. The peer's enabled_corner is not considered, with the
      result that the underlying (shared) resource is disabled.
      
      One case where this can be observed is when the display stack keeps mmcx
      enabled (but without a particular performance-state vote) in order to
      access registers and sync_state happens in the rpmhpd driver. As mmcx_ao
      is flushed the state of the peer (mmcx) is not considered and mmcx_ao
      ends up turning off "mmcx.lvl" underneath mmcx. This has been observed
      several times, but has been painted over in DeviceTree by adding an
      explicit vote for the lowest non-disabled performance-state.
      
      Fixes: e3e56c05
      
       ("soc: qcom: rpmhpd: Make power_on actually enable the domain")
      Reported-by: default avatarJohan Hovold <johan@kernel.org>
      Closes: https://lore.kernel.org/linux-arm-msm/ZdMwZa98L23mu3u6@hovoldconsulting.com/
      Cc:  <stable@vger.kernel.org>
      Signed-off-by: default avatarBjorn Andersson <quic_bjorande@quicinc.com>
      Reviewed-by: default avatarKonrad Dybcio <konrad.dybcio@linaro.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Tested-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarAbhinav Kumar <quic_abhinavk@quicinc.com>
      Reviewed-by: default avatarStephen Boyd <swboyd@chromium.org>
      Tested-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Link: https://lore.kernel.org/r/20240226-rpmhpd-enable-corner-fix-v1-1-68c004cec48c@quicinc.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e9eeb0dd
    • Tim Schumacher's avatar
      efivarfs: Request at most 512 bytes for variable names · 71da10e6
      Tim Schumacher authored
      commit f45812cc
      
       upstream.
      
      Work around a quirk in a few old (2011-ish) UEFI implementations, where
      a call to `GetNextVariableName` with a buffer size larger than 512 bytes
      will always return EFI_INVALID_PARAMETER.
      
      There is some lore around EFI variable names being up to 1024 bytes in
      size, but this has no basis in the UEFI specification, and the upper
      bounds are typically platform specific, and apply to the entire variable
      (name plus payload).
      
      Given that Linux does not permit creating files with names longer than
      NAME_MAX (255) bytes, 512 bytes (== 256 UTF-16 characters) is a
      reasonable limit.
      
      Cc: <stable@vger.kernel.org> # 6.1+
      Signed-off-by: default avatarTim Schumacher <timschumi@gmx.de>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      71da10e6
    • Nicolin Chen's avatar
      iommufd: Fix iopt_access_list_id overwrite bug · f1fb745e
      Nicolin Chen authored
      commit aeb004c0 upstream.
      
      Syzkaller reported the following WARN_ON:
        WARNING: CPU: 1 PID: 4738 at drivers/iommu/iommufd/io_pagetable.c:1360
      
        Call Trace:
         iommufd_access_change_ioas+0x2fe/0x4e0
         iommufd_access_destroy_object+0x50/0xb0
         iommufd_object_remove+0x2a3/0x490
         iommufd_object_destroy_user
         iommufd_access_destroy+0x71/0xb0
         iommufd_test_staccess_release+0x89/0xd0
         __fput+0x272/0xb50
         __fput_sync+0x4b/0x60
         __do_sys_close
         __se_sys_close
         __x64_sys_close+0x8b/0x110
         do_syscall_x64
      
      The mismatch between the access pointer in the list and the passed-in
      pointer is resulting from an overwrite of access->iopt_access_list_id, in
      iopt_add_access(). Called from iommufd_access_change_ioas() when
      xa_alloc() succeeds but iopt_calculate_iova_alignment() fails.
      
      Add a new_id in iopt_add_access() and only update iopt_access_list_id when
      returning successfully.
      
      Cc: stable@vger.kernel.org
      Fixes: 9227da78
      
       ("iommufd: Add iommufd_access_change_ioas(_id) helpers")
      Link: https://lore.kernel.org/r/2dda7acb25b8562ec5f1310de828ef5da9ef509c.1708636627.git.nicolinc@nvidia.com
      Reported-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Suggested-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarNicolin Chen <nicolinc@nvidia.com>
      Reviewed-by: default avatarKevin Tian <kevin.tian@intel.com>
      Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f1fb745e
    • Nathan Chancellor's avatar
      kbuild: Add -Wa,--fatal-warnings to as-instr invocation · 8db4f87f
      Nathan Chancellor authored
      commit 0ee695a4
      
       upstream.
      
      Certain assembler instruction tests may only induce warnings from the
      assembler on an unsupported instruction or option, which causes as-instr
      to succeed when it was expected to fail. Some tests workaround this
      limitation by additionally testing that invalid input fails as expected.
      However, this is fragile if the assembler is changed to accept the
      invalid input, as it will cause the instruction/option to be unavailable
      like it was unsupported even when it is.
      
      Use '-Wa,--fatal-warnings' in the as-instr macro to turn these warnings
      into hard errors, which avoids this fragility and makes tests more
      robust and well formed.
      
      Cc: stable@vger.kernel.org
      Suggested-by: default avatarEric Biggers <ebiggers@kernel.org>
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarEric Biggers <ebiggers@google.com>
      Tested-by: default avatarAndy Chiu <andybnac@gmail.com>
      Reviewed-by: default avatarAndy Chiu <andybnac@gmail.com>
      Tested-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Acked-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://lore.kernel.org/r/20240125-fix-riscv-option-arch-llvm-18-v1-1-390ac9cc3cd0@kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8db4f87f
    • Zong Li's avatar
      riscv: add CALLER_ADDRx support · 9537603a
      Zong Li authored
      commit 68034138 upstream.
      
      CALLER_ADDRx returns caller's address at specified level, they are used
      for several tracers. These macros eventually use
      __builtin_return_address(n) to get the caller's address if arch doesn't
      define their own implementation.
      
      In RISC-V, __builtin_return_address(n) only works when n == 0, we need
      to walk the stack frame to get the caller's address at specified level.
      
      data.level started from 'level + 3' due to the call flow of getting
      caller's address in RISC-V implementation. If we don't have additional
      three iteration, the level is corresponding to follows:
      
      callsite -> return_address -> arch_stack_walk -> walk_stackframe
      |           |                 |                  |
      level 3     level 2           level 1            level 0
      
      Fixes: 10626c32
      
       ("riscv/ftrace: Add basic support")
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Signed-off-by: default avatarZong Li <zong.li@sifive.com>
      Link: https://lore.kernel.org/r/20240202015102.26251-1-zong.li@sifive.com
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9537603a
    • Nathan Chancellor's avatar
      RISC-V: Drop invalid test from CONFIG_AS_HAS_OPTION_ARCH · 0c8a3d33
      Nathan Chancellor authored
      commit 3aff0c45 upstream.
      
      Commit e4bb020f ("riscv: detect assembler support for .option arch")
      added two tests, one for a valid value to '.option arch' that should
      succeed and one for an invalid value that is expected to fail to make
      sure that support for '.option arch' is properly detected because Clang
      does not error when '.option arch' is not supported:
      
        $ clang --target=riscv64-linux-gnu -Werror -x assembler -c -o /dev/null <(echo '.option arch, +m')
        /dev/fd/63:1:9: warning: unknown option, expected 'push', 'pop', 'rvc', 'norvc', 'relax' or 'norelax'
        .option arch, +m
                ^
        $ echo $?
        0
      
      Unfortunately, the invalid test started being accepted by Clang after
      the linked llvm-project change, which causes CONFIG_AS_HAS_OPTION_ARCH
      and configurations that depend on it to be silently disabled, even
      though those versions do support '.option arch'.
      
      The invalid test can be avoided altogether by using
      '-Wa,--fatal-warnings', which will turn all assembler warnings into
      errors, like '-Werror' does for the compiler:
      
        $ clang --target=riscv64-linux-gnu -Werror -Wa,--fatal-warnings -x assembler -c -o /dev/null <(echo '.option arch, +m')
        /dev/fd/63:1:9: error: unknown option, expected 'push', 'pop', 'rvc', 'norvc', 'relax' or 'norelax'
        .option arch, +m
                ^
        $ echo $?
        1
      
      The as-instr macros have been updated to make use of this flag, so
      remove the invalid test, which allows CONFIG_AS_HAS_OPTION_ARCH to work
      for all compiler versions.
      
      Cc: stable@vger.kernel.org
      Fixes: e4bb020f
      
       ("riscv: detect assembler support for .option arch")
      Link: https://github.com/llvm/llvm-project/commit/3ac9fe69f70a2b3541266daedbaaa7dc9c007a2a
      Reported-by: default avatarEric Biggers <ebiggers@kernel.org>
      Closes: https://lore.kernel.org/r/20240121011341.GA97368@sol.localdomain/
      Signed-off-by: default avatarNathan Chancellor <nathan@kernel.org>
      Tested-by: default avatarEric Biggers <ebiggers@google.com>
      Tested-by: default avatarAndy Chiu <andybnac@gmail.com>
      Reviewed-by: default avatarAndy Chiu <andybnac@gmail.com>
      Tested-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
      Acked-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Link: https://lore.kernel.org/r/20240125-fix-riscv-option-arch-llvm-18-v1-2-390ac9cc3cd0@kernel.org
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0c8a3d33
    • Elad Nachman's avatar
      mmc: sdhci-xenon: fix PHY init clock stability · aebd67a5
      Elad Nachman authored
      commit 8e9f25a2 upstream.
      
      Each time SD/mmc phy is initialized, at times, in some of
      the attempts, phy fails to completes its initialization
      which results into timeout error. Per the HW spec, it is
      a pre-requisite to ensure a stable SD clock before a phy
      initialization is attempted.
      
      Fixes: 06c8b667
      
       ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC")
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarElad Nachman <enachman@marvell.com>
      Link: https://lore.kernel.org/r/20240222200930.1277665-1-enachman@marvell.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      aebd67a5
    • Elad Nachman's avatar
      mmc: sdhci-xenon: add timeout for PHY init complete · b4eacb32
      Elad Nachman authored
      commit 09e23823 upstream.
      
      AC5X spec says PHY init complete bit must be polled until zero.
      We see cases in which timeout can take longer than the standard
      calculation on AC5X, which is expected following the spec comment above.
      According to the spec, we must wait as long as it takes for that bit to
      toggle on AC5X.
      Cap that with 100 delay loops so we won't get stuck forever.
      
      Fixes: 06c8b667
      
       ("mmc: sdhci-xenon: Add support to PHYs of Marvell Xenon SDHC")
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarElad Nachman <enachman@marvell.com>
      Link: https://lore.kernel.org/r/20240222191714.1216470-3-enachman@marvell.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b4eacb32
    • Ivan Semenov's avatar
      mmc: core: Fix eMMC initialization with 1-bit bus connection · 43444442
      Ivan Semenov authored
      commit ff3206d2 upstream.
      
      Initializing an eMMC that's connected via a 1-bit bus is current failing,
      if the HW (DT) informs that 4-bit bus is supported. In fact this is a
      regression, as we were earlier capable of falling back to 1-bit mode, when
      switching to 4/8-bit bus failed. Therefore, let's restore the behaviour.
      
      Log for Samsung eMMC 5.1 chip connected via 1bit bus (only D0 pin)
      Before patch:
      [134509.044225] mmc0: switch to bus width 4 failed
      [134509.044509] mmc0: new high speed MMC card at address 0001
      [134509.054594] mmcblk0: mmc0:0001 BGUF4R 29.1 GiB
      [134509.281602] mmc0: switch to bus width 4 failed
      [134509.282638] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.282657] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.284598] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.284602] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.284609] ldm_validate_partition_table(): Disk read failed.
      [134509.286495] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.286500] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.288303] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.288308] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.289540] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.289544] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      [134509.289553]  mmcblk0: unable to read partition table
      [134509.289728] mmcblk0boot0: mmc0:0001 BGUF4R 31.9 MiB
      [134509.290283] mmcblk0boot1: mmc0:0001 BGUF4R 31.9 MiB
      [134509.294577] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x80700 phys_seg 1 prio class 2
      [134509.295835] I/O error, dev mmcblk0, sector 0 op 0x0:(READ) flags 0x0 phys_seg 1 prio class 2
      [134509.295841] Buffer I/O error on dev mmcblk0, logical block 0, async page read
      
      After patch:
      
      [134551.089613] mmc0: switch to bus width 4 failed
      [134551.090377] mmc0: new high speed MMC card at address 0001
      [134551.102271] mmcblk0: mmc0:0001 BGUF4R 29.1 GiB
      [134551.113365]  mmcblk0: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10 p11 p12 p13 p14 p15 p16 p17 p18 p19 p20 p21
      [134551.114262] mmcblk0boot0: mmc0:0001 BGUF4R 31.9 MiB
      [134551.114925] mmcblk0boot1: mmc0:0001 BGUF4R 31.9 MiB
      
      Fixes: 577fb131
      
       ("mmc: rework selection of bus speed mode")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarIvan Semenov <ivan@semenov.dev>
      Link: https://lore.kernel.org/r/20240206172845.34316-1-ivan@semenov.dev
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43444442
    • Christophe Kerello's avatar
      mmc: mmci: stm32: fix DMA API overlapping mappings warning · 176e6626
      Christophe Kerello authored
      commit 6b1ba3f9
      
       upstream.
      
      Turning on CONFIG_DMA_API_DEBUG_SG results in the following warning:
      
      DMA-API: mmci-pl18x 48220000.mmc: cacheline tracking EEXIST,
      overlapping mappings aren't supported
      WARNING: CPU: 1 PID: 51 at kernel/dma/debug.c:568
      add_dma_entry+0x234/0x2f4
      Modules linked in:
      CPU: 1 PID: 51 Comm: kworker/1:2 Not tainted 6.1.28 #1
      Hardware name: STMicroelectronics STM32MP257F-EV1 Evaluation Board (DT)
      Workqueue: events_freezable mmc_rescan
      Call trace:
      add_dma_entry+0x234/0x2f4
      debug_dma_map_sg+0x198/0x350
      __dma_map_sg_attrs+0xa0/0x110
      dma_map_sg_attrs+0x10/0x2c
      sdmmc_idma_prep_data+0x80/0xc0
      mmci_prep_data+0x38/0x84
      mmci_start_data+0x108/0x2dc
      mmci_request+0xe4/0x190
      __mmc_start_request+0x68/0x140
      mmc_start_request+0x94/0xc0
      mmc_wait_for_req+0x70/0x100
      mmc_send_tuning+0x108/0x1ac
      sdmmc_execute_tuning+0x14c/0x210
      mmc_execute_tuning+0x48/0xec
      mmc_sd_init_uhs_card.part.0+0x208/0x464
      mmc_sd_init_card+0x318/0x89c
      mmc_attach_sd+0xe4/0x180
      mmc_rescan+0x244/0x320
      
      DMA API debug brings to light leaking dma-mappings as dma_map_sg and
      dma_unmap_sg are not correctly balanced.
      
      If an error occurs in mmci_cmd_irq function, only mmci_dma_error
      function is called and as this API is not managed on stm32 variant,
      dma_unmap_sg is never called in this error path.
      
      Signed-off-by: default avatarChristophe Kerello <christophe.kerello@foss.st.com>
      Fixes: 46b723dd
      
       ("mmc: mmci: add stm32 sdmmc variant")
      Cc: stable@vger.kernel.org
      Link: https://lore.kernel.org/r/20240207143951.938144-1-christophe.kerello@foss.st.com
      Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      176e6626
    • Curtis Klein's avatar
      dmaengine: fsl-qdma: init irq after reg initialization · a69c8bbb
      Curtis Klein authored
      commit 87a39071 upstream.
      
      Initialize the qDMA irqs after the registers are configured so that
      interrupts that may have been pending from a primary kernel don't get
      processed by the irq handler before it is ready to and cause panic with
      the following trace:
      
        Call trace:
         fsl_qdma_queue_handler+0xf8/0x3e8
         __handle_irq_event_percpu+0x78/0x2b0
         handle_irq_event_percpu+0x1c/0x68
         handle_irq_event+0x44/0x78
         handle_fasteoi_irq+0xc8/0x178
         generic_handle_irq+0x24/0x38
         __handle_domain_irq+0x90/0x100
         gic_handle_irq+0x5c/0xb8
         el1_irq+0xb8/0x180
         _raw_spin_unlock_irqrestore+0x14/0x40
         __setup_irq+0x4bc/0x798
         request_threaded_irq+0xd8/0x190
         devm_request_threaded_irq+0x74/0xe8
         fsl_qdma_probe+0x4d4/0xca8
         platform_drv_probe+0x50/0xa0
         really_probe+0xe0/0x3f8
         driver_probe_device+0x64/0x130
         device_driver_attach+0x6c/0x78
         __driver_attach+0xbc/0x158
         bus_for_each_dev+0x5c/0x98
         driver_attach+0x20/0x28
         bus_add_driver+0x158/0x220
         driver_register+0x60/0x110
         __platform_driver_register+0x44/0x50
         fsl_qdma_driver_init+0x18/0x20
         do_one_initcall+0x48/0x258
         kernel_init_freeable+0x1a4/0x23c
         kernel_init+0x10/0xf8
         ret_from_fork+0x10/0x18
      
      Cc: stable@vger.kernel.org
      Fixes: b092529e
      
       ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
      Signed-off-by: default avatarCurtis Klein <curtis.klein@hpe.com>
      Signed-off-by: default avatarYi Zhao <yi.zhao@nxp.com>
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Link: https://lore.kernel.org/r/20240201220406.440145-1-Frank.Li@nxp.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a69c8bbb
    • Joy Zou's avatar
      dmaengine: fsl-edma: correct calculation of 'nbytes' in multi-fifo scenario · 91b001fb
      Joy Zou authored
      commit 9ba17def upstream.
      
      The 'nbytes' should be equivalent to burst * width in audio multi-fifo
      setups. Given that the FIFO width is fixed at 32 bits, adjusts the burst
      size for multi-fifo configurations to match the slave maxburst in the
      configuration.
      
      Cc: stable@vger.kernel.org
      Fixes: 72f5801a
      
       ("dmaengine: fsl-edma: integrate v3 support")
      Signed-off-by: default avatarJoy Zou <joy.zou@nxp.com>
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Link: https://lore.kernel.org/r/20240131163318.360315-1-Frank.Li@nxp.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      91b001fb
    • Tadeusz Struk's avatar
      dmaengine: ptdma: use consistent DMA masks · 4e0fe154
      Tadeusz Struk authored
      commit df2515a1 upstream.
      
      The PTDMA driver sets DMA masks in two different places for the same
      device inconsistently. First call is in pt_pci_probe(), where it uses
      48bit mask. The second call is in pt_dmaengine_register(), where it
      uses a 64bit mask. Using 64bit dma mask causes IO_PAGE_FAULT errors
      on DMA transfers between main memory and other devices.
      Without the extra call it works fine. Additionally the second call
      doesn't check the return value so it can silently fail.
      Remove the superfluous dma_set_mask() call and only use 48bit mask.
      
      Cc: stable@vger.kernel.org
      Fixes: b0b4a6b1
      
       ("dmaengine: ptdma: register PTDMA controller as a DMA resource")
      Reviewed-by: default avatarBasavaraj Natikar <Basavaraj.Natikar@amd.com>
      Signed-off-by: default avatarTadeusz Struk <tstruk@gigaio.com>
      Link: https://lore.kernel.org/r/20240222163053.13842-1-tstruk@gigaio.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4e0fe154
    • Ard Biesheuvel's avatar
      crypto: arm64/neonbs - fix out-of-bounds access on short input · 1291d278
      Ard Biesheuvel authored
      commit 1c0cf6d1 upstream.
      
      The bit-sliced implementation of AES-CTR operates on blocks of 128
      bytes, and will fall back to the plain NEON version for tail blocks or
      inputs that are shorter than 128 bytes to begin with.
      
      It will call straight into the plain NEON asm helper, which performs all
      memory accesses in granules of 16 bytes (the size of a NEON register).
      For this reason, the associated plain NEON glue code will copy inputs
      shorter than 16 bytes into a temporary buffer, given that this is a rare
      occurrence and it is not worth the effort to work around this in the asm
      code.
      
      The fallback from the bit-sliced NEON version fails to take this into
      account, potentially resulting in out-of-bounds accesses. So clone the
      same workaround, and use a temp buffer for short in/outputs.
      
      Fixes: fc074e13
      
       ("crypto: arm64/aes-neonbs-ctr - fallback to plain NEON for final chunk")
      Cc: <stable@vger.kernel.org>
      Reported-by: default avatar <syzbot+f1ceaa1a09ab891e1934@syzkaller.appspotmail.com>
      Reviewed-by: default avatarEric Biggers <ebiggers@google.com>
      Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      1291d278
    • Peng Ma's avatar
      dmaengine: fsl-qdma: fix SoC may hang on 16 byte unaligned read · 5b696e9c
      Peng Ma authored
      commit 9d739bcc upstream.
      
      There is chip (ls1028a) errata:
      
      The SoC may hang on 16 byte unaligned read transactions by QDMA.
      
      Unaligned read transactions initiated by QDMA may stall in the NOC
      (Network On-Chip), causing a deadlock condition. Stalled transactions will
      trigger completion timeouts in PCIe controller.
      
      Workaround:
      Enable prefetch by setting the source descriptor prefetchable bit
      ( SD[PF] = 1 ).
      
      Implement this workaround.
      
      Cc: stable@vger.kernel.org
      Fixes: b092529e
      
       ("dmaengine: fsl-qdma: Add qDMA controller driver for Layerscape SoCs")
      Signed-off-by: default avatarPeng Ma <peng.ma@nxp.com>
      Signed-off-by: default avatarFrank Li <Frank.Li@nxp.com>
      Link: https://lore.kernel.org/r/20240201215007.439503-1-Frank.Li@nxp.com
      Signed-off-by: default avatarVinod Koul <vkoul@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5b696e9c
    • Rob Clark's avatar
      soc: qcom: pmic_glink: Fix boot when QRTR=m · 737d2e93
      Rob Clark authored
      commit f79ee787 upstream.
      
      We need to bail out before adding/removing devices if we are going to
      -EPROBE_DEFER. Otherwise boot can get stuck in a probe deferral loop due
      to a long-standing issue in driver core (see commit fbc35b45
      
       ("Add
      documentation on meaning of -EPROBE_DEFER")).
      
      Deregistering the altmode child device can potentially also trigger bugs
      in the DRM bridge implementation, which does not expect bridges to go
      away.
      
      [DB: slightly fixed commit message by adding the word 'commit']
      Suggested-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Link: https://lore.kernel.org/r/20231213210644.8702-1-robdclark@gmail.com
      [ johan: rebase on 6.8-rc4, amend commit message and mention DRM ]
      Fixes: 58ef4ece
      
       ("soc: qcom: pmic_glink: Introduce base PMIC GLINK driver")
      Cc: <stable@vger.kernel.org>      # 6.3
      Cc: Bjorn Andersson <andersson@kernel.org>
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reviewed-by: default avatarBjorn Andersson <andersson@kernel.org>
      Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Reviewed-by: default avatarNeil Armstrong <neil.armstrong@linaro.org>
      Signed-off-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240217150228.5788-5-johan+linaro@kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      737d2e93
    • Ryan Lin's avatar
      drm/amd/display: Add monitor patch for specific eDP · 82dacc26
      Ryan Lin authored
      commit b7cdccc6
      
       upstream.
      
      [WHY]
      Some eDP panels' ext caps don't write initial values. The value of
      dpcd_addr (0x317) can be random and the backlight control interface
      will be incorrect.
      
      [HOW]
      Add new panel patches to remove sink ext caps.
      
      Cc: Mario Limonciello <mario.limonciello@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.5.x
      Cc: Tsung-hua Lin <tsung-hua.lin@amd.com>
      Cc: Chris Chi <moukong.chi@amd.com>
      Reviewed-by: default avatarWayne Lin <wayne.lin@amd.com>
      Acked-by: default avatarAlex Hung <alex.hung@amd.com>
      Signed-off-by: default avatarRyan Lin <tsung-hua.lin@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      82dacc26
    • Matthew Auld's avatar
      drm/buddy: fix range bias · 5e476625
      Matthew Auld authored
      commit f41900e4 upstream.
      
      There is a corner case here where start/end is after/before the block
      range we are currently checking. If so we need to be sure that splitting
      the block will eventually give use the block size we need. To do that we
      should adjust the block range to account for the start/end, and only
      continue with the split if the size/alignment will fit the requested
      size. Not doing so can result in leaving split blocks unmerged when it
      eventually fails.
      
      Fixes: afea229f
      
       ("drm: improve drm_buddy_alloc function")
      Signed-off-by: default avatarMatthew Auld <matthew.auld@intel.com>
      Cc: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: <stable@vger.kernel.org> # v5.18+
      Reviewed-by: default avatarArunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
      Link: https://patchwork.freedesktop.org/patch/msgid/20240219121851.25774-4-matthew.auld@intel.com
      Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5e476625
    • Alex Deucher's avatar
      Revert "drm/amd/pm: resolve reboot exception for si oland" · baac2928
      Alex Deucher authored
      commit 95555803 upstream.
      
      This reverts commit e490d60a
      
      .
      
      This causes hangs on SI when DC is enabled and errors on driver
      reboot and power off cycles.
      
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3216
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/2755
      Reviewed-by: default avatarYang Wang <kevinyang.wang@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      baac2928
    • Filipe Manana's avatar
      btrfs: send: don't issue unnecessary zero writes for trailing hole · 202e4f4b
      Filipe Manana authored
      commit 5897710b
      
       upstream.
      
      If we have a sparse file with a trailing hole (from the last extent's end
      to i_size) and then create an extent in the file that ends before the
      file's i_size, then when doing an incremental send we will issue a write
      full of zeroes for the range that starts immediately after the new extent
      ends up to i_size. While this isn't incorrect because the file ends up
      with exactly the same data, it unnecessarily results in using extra space
      at the destination with one or more extents full of zeroes instead of
      having a hole. In same cases this results in using megabytes or even
      gigabytes of unnecessary space.
      
      Example, reproducer:
      
         $ cat test.sh
         #!/bin/bash
      
         DEV=/dev/sdh
         MNT=/mnt/sdh
      
         mkfs.btrfs -f $DEV
         mount $DEV $MNT
      
         # Create 1G sparse file.
         xfs_io -f -c "truncate 1G" $MNT/foobar
      
         # Create base snapshot.
         btrfs subvolume snapshot -r $MNT $MNT/mysnap1
      
         # Create send stream (full send) for the base snapshot.
         btrfs send -f /tmp/1.snap $MNT/mysnap1
      
         # Now write one extent at the beginning of the file and one somewhere
         # in the middle, leaving a gap between the end of this second extent
         # and the file's size.
         xfs_io -c "pwrite -S 0xab 0 128K" \
                -c "pwrite -S 0xcd 512M 128K" \
                $MNT/foobar
      
         # Now create a second snapshot which is going to be used for an
         # incremental send operation.
         btrfs subvolume snapshot -r $MNT $MNT/mysnap2
      
         # Create send stream (incremental send) for the second snapshot.
         btrfs send -p $MNT/mysnap1 -f /tmp/2.snap $MNT/mysnap2
      
         # Now recreate the filesystem by receiving both send streams and
         # verify we get the same content that the original filesystem had
         # and file foobar has only two extents with a size of 128K each.
         umount $MNT
         mkfs.btrfs -f $DEV
         mount $DEV $MNT
      
         btrfs receive -f /tmp/1.snap $MNT
         btrfs receive -f /tmp/2.snap $MNT
      
         echo -e "\nFile fiemap in the second snapshot:"
         # Should have:
         #
         # 128K extent at file range [0, 128K[
         # hole at file range [128K, 512M[
         # 128K extent file range [512M, 512M + 128K[
         # hole at file range [512M + 128K, 1G[
         xfs_io -r -c "fiemap -v" $MNT/mysnap2/foobar
      
         # File should be using 256K of data (two 128K extents).
         echo -e "\nSpace used by the file: $(du -h $MNT/mysnap2/foobar | cut -f 1)"
      
         umount $MNT
      
      Running the test, we can see with fiemap that we get an extent for the
      range [512M, 1G[, while in the source filesystem we have an extent for
      the range [512M, 512M + 128K[ and a hole for the rest of the file (the
      range [512M + 128K, 1G[):
      
         $ ./test.sh
         (...)
         File fiemap in the second snapshot:
         /mnt/sdh/mysnap2/foobar:
          EXT: FILE-OFFSET        BLOCK-RANGE        TOTAL FLAGS
            0: [0..255]:          26624..26879         256   0x0
            1: [256..1048575]:    hole             1048320
            2: [1048576..2097151]: 2156544..3205119 1048576   0x1
      
         Space used by the file: 513M
      
      This happens because once we finish processing an inode, at
      finish_inode_if_needed(), we always issue a hole (write operations full
      of zeros) if there's a gap between the end of the last processed extent
      and the file's size, even if that range is already a hole in the parent
      snapshot. Fix this by issuing the hole only if the range is not already
      a hole.
      
      After this change, running the test above, we get the expected layout:
      
         $ ./test.sh
         (...)
         File fiemap in the second snapshot:
         /mnt/sdh/mysnap2/foobar:
          EXT: FILE-OFFSET        BLOCK-RANGE      TOTAL FLAGS
            0: [0..255]:          26624..26879       256   0x0
            1: [256..1048575]:    hole             1048320
            2: [1048576..1048831]: 26880..27135       256   0x1
            3: [1048832..2097151]: hole             1048320
      
         Space used by the file: 256K
      
      A test case for fstests will follow soon.
      
      CC: stable@vger.kernel.org # 6.1+
      Reported-by: default avatarDorai Ashok S A <dash.btrfs@inix.me>
      Link: https://lore.kernel.org/linux-btrfs/c0bf7818-9c45-46a8-b3d3-513230d0c86e@inix.me/
      Reviewed-by: default avatarSweet Tea Dorminy <sweettea-kernel@dorminy.me>
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      202e4f4b
    • David Sterba's avatar
      btrfs: dev-replace: properly validate device names · b1690ced
      David Sterba authored
      commit 9845664b
      
       upstream.
      
      There's a syzbot report that device name buffers passed to device
      replace are not properly checked for string termination which could lead
      to a read out of bounds in getname_kernel().
      
      Add a helper that validates both source and target device name buffers.
      For devid as the source initialize the buffer to empty string in case
      something tries to read it later.
      
      This was originally analyzed and fixed in a different way by Edward Adam
      Davis (see links).
      
      Link: https://lore.kernel.org/linux-btrfs/000000000000d1a1d1060cc9c5e7@google.com/
      Link: https://lore.kernel.org/linux-btrfs/tencent_44CA0665C9836EF9EEC80CB9E7E206DF5206@qq.com/
      CC: stable@vger.kernel.org # 4.19+
      CC: Edward Adam Davis <eadavis@qq.com>
      Reported-and-tested-by: default avatar <syzbot+33f23b49ac24f986c9e8@syzkaller.appspotmail.com>
      Reviewed-by: default avatarBoris Burkov <boris@bur.io>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b1690ced
    • Filipe Manana's avatar
      btrfs: fix double free of anonymous device after snapshot creation failure · eb344109
      Filipe Manana authored
      commit e2b54eaf upstream.
      
      When creating a snapshot we may do a double free of an anonymous device
      in case there's an error committing the transaction. The second free may
      result in freeing an anonymous device number that was allocated by some
      other subsystem in the kernel or another btrfs filesystem.
      
      The steps that lead to this:
      
      1) At ioctl.c:create_snapshot() we allocate an anonymous device number
         and assign it to pending_snapshot->anon_dev;
      
      2) Then we call btrfs_commit_transaction() and end up at
         transaction.c:create_pending_snapshot();
      
      3) There we call btrfs_get_new_fs_root() and pass it the anonymous device
         number stored in pending_snapshot->anon_dev;
      
      4) btrfs_get_new_fs_root() frees that anonymous device number because
         btrfs_lookup_fs_root() returned a root - someone else did a lookup
         of the new root already, which could some task doing backref walking;
      
      5) After that some error happens in the transaction commit path, and at
         ioctl.c:create_snapshot() we jump to the 'fail' label, and after
         that we free again the same anonymous device number, which in the
         meanwhile may have been reallocated somewhere else, because
         pending_snapshot->anon_dev still has the same value as in step 1.
      
      Recently syzbot ran into this and reported the following trace:
      
        ------------[ cut here ]------------
        ida_free called for id=51 which is not allocated.
        WARNING: CPU: 1 PID: 31038 at lib/idr.c:525 ida_free+0x370/0x420 lib/idr.c:525
        Modules linked in:
        CPU: 1 PID: 31038 Comm: syz-executor.2 Not tainted 6.8.0-rc4-syzkaller-00410-gc02197fc9076 #0
        Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
        RIP: 0010:ida_free+0x370/0x420 lib/idr.c:525
        Code: 10 42 80 3c 28 (...)
        RSP: 0018:ffffc90015a67300 EFLAGS: 00010246
        RAX: be5130472f5dd000 RBX: 0000000000000033 RCX: 0000000000040000
        RDX: ffffc90009a7a000 RSI: 000000000003ffff RDI: 0000000000040000
        RBP: ffffc90015a673f0 R08: ffffffff81577992 R09: 1ffff92002b4cdb4
        R10: dffffc0000000000 R11: fffff52002b4cdb5 R12: 0000000000000246
        R13: dffffc0000000000 R14: ffffffff8e256b80 R15: 0000000000000246
        FS:  00007fca3f4b46c0(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 00007f167a17b978 CR3: 000000001ed26000 CR4: 0000000000350ef0
        Call Trace:
         <TASK>
         btrfs_get_root_ref+0xa48/0xaf0 fs/btrfs/disk-io.c:1346
         create_pending_snapshot+0xff2/0x2bc0 fs/btrfs/transaction.c:1837
         create_pending_snapshots+0x195/0x1d0 fs/btrfs/transaction.c:1931
         btrfs_commit_transaction+0xf1c/0x3740 fs/btrfs/transaction.c:2404
         create_snapshot+0x507/0x880 fs/btrfs/ioctl.c:848
         btrfs_mksubvol+0x5d0/0x750 fs/btrfs/ioctl.c:998
         btrfs_mksnapshot+0xb5/0xf0 fs/btrfs/ioctl.c:1044
         __btrfs_ioctl_snap_create+0x387/0x4b0 fs/btrfs/ioctl.c:1306
         btrfs_ioctl_snap_create_v2+0x1ca/0x400 fs/btrfs/ioctl.c:1393
         btrfs_ioctl+0xa74/0xd40
         vfs_ioctl fs/ioctl.c:51 [inline]
         __do_sys_ioctl fs/ioctl.c:871 [inline]
         __se_sys_ioctl+0xfe/0x170 fs/ioctl.c:857
         do_syscall_64+0xfb/0x240
         entry_SYSCALL_64_after_hwframe+0x6f/0x77
        RIP: 0033:0x7fca3e67dda9
        Code: 28 00 00 00 (...)
        RSP: 002b:00007fca3f4b40c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
        RAX: ffffffffffffffda RBX: 00007fca3e7abf80 RCX: 00007fca3e67dda9
        RDX: 00000000200005c0 RSI: 0000000050009417 RDI: 0000000000000003
        RBP: 00007fca3e6ca47a R08: 0000000000000000 R09: 0000000000000000
        R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
        R13: 000000000000000b R14: 00007fca3e7abf80 R15: 00007fff6bf95658
         </TASK>
      
      Where we get an explicit message where we attempt to free an anonymous
      device number that is not currently allocated. It happens in a different
      code path from the example below, at btrfs_get_root_ref(), so this change
      may not fix the case triggered by syzbot.
      
      To fix at least the code path from the example above, change
      btrfs_get_root_ref() and its callers to receive a dev_t pointer argument
      for the anonymous device number, so that in case it frees the number, it
      also resets it to 0, so that up in the call chain we don't attempt to do
      the double free.
      
      CC: stable@vger.kernel.org # 5.10+
      Link: https://lore.kernel.org/linux-btrfs/000000000000f673a1061202f630@google.com/
      Fixes: e03ee2fe
      
       ("btrfs: do not ASSERT() if the newly created subvolume already got read")
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      eb344109
    • Johannes Berg's avatar
      wifi: nl80211: reject iftype change with mesh ID change · 177d574b
      Johannes Berg authored
      commit f78c1375 upstream.
      
      It's currently possible to change the mesh ID when the
      interface isn't yet in mesh mode, at the same time as
      changing it into mesh mode. This leads to an overwrite
      of data in the wdev->u union for the interface type it
      currently has, causing cfg80211_change_iface() to do
      wrong things when switching.
      
      We could probably allow setting an interface to mesh
      while setting the mesh ID at the same time by doing a
      different order of operations here, but realistically
      there's no userspace that's going to do this, so just
      disallow changes in iftype when setting mesh ID.
      
      Cc: stable@vger.kernel.org
      Fixes: 29cbe68c
      
       ("cfg80211/mac80211: add mesh join/leave commands")
      Reported-by: default avatar <syzbot+dd4779978217b1973180@syzkaller.appspotmail.com>
      Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      177d574b
    • Elad Nachman's avatar
      mtd: rawnand: marvell: fix layouts · ad8ff8cf
      Elad Nachman authored
      commit e6a30d0c upstream.
      
      The check in nand_base.c, nand_scan_tail() : has the following code:
      (ecc->steps * ecc->size != mtd->writesize) which fails for some NAND chips.
      Remove ECC entries in this driver which are not integral multiplications,
      and adjust the number of chunks for entries which fails the above
      calculation so it will calculate correctly (this was previously done
      automatically before the check and was removed in a later commit).
      
      Fixes: 68c18dae
      
       ("mtd: rawnand: marvell: add missing layouts")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarElad Nachman <enachman@marvell.com>
      Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ad8ff8cf
    • Nhat Pham's avatar
      mm: cachestat: fix folio read-after-free in cache walk · ba60fdf7
      Nhat Pham authored
      commit 3a75cb05 upstream.
      
      In cachestat, we access the folio from the page cache's xarray to compute
      its page offset, and check for its dirty and writeback flags.  However, we
      do not hold a reference to the folio before performing these actions,
      which means the folio can concurrently be released and reused as another
      folio/page/slab.
      
      Get around this altogether by just using xarray's existing machinery for
      the folio page offsets and dirty/writeback states.
      
      This changes behavior for tmpfs files to now always report zeroes in their
      dirty and writeback counters.  This is okay as tmpfs doesn't follow
      conventional writeback cache behavior: its pages get "cleaned" during
      swapout, after which they're no longer resident etc.
      
      Link: https://lkml.kernel.org/r/20240220153409.GA216065@cmpxchg.org
      Fixes: cf264e13
      
       ("cachestat: implement cachestat syscall")
      Reported-by: default avatarJann Horn <jannh@google.com>
      Suggested-by: default avatarMatthew Wilcox <willy@infradead.org>
      Signed-off-by: default avatarNhat Pham <nphamcs@gmail.com>
      Signed-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
      Tested-by: default avatarJann Horn <jannh@google.com>
      Cc: <stable@vger.kernel.org>	[6.4+]
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ba60fdf7
    • Alexander Ofitserov's avatar
      gtp: fix use-after-free and null-ptr-deref in gtp_newlink() · 93dd420b
      Alexander Ofitserov authored
      commit 616d82c3
      
       upstream.
      
      The gtp_link_ops operations structure for the subsystem must be
      registered after registering the gtp_net_ops pernet operations structure.
      
      Syzkaller hit 'general protection fault in gtp_genl_dump_pdp' bug:
      
      [ 1010.702740] gtp: GTP module unloaded
      [ 1010.715877] general protection fault, probably for non-canonical address 0xdffffc0000000001: 0000 [#1] SMP KASAN NOPTI
      [ 1010.715888] KASAN: null-ptr-deref in range [0x0000000000000008-0x000000000000000f]
      [ 1010.715895] CPU: 1 PID: 128616 Comm: a.out Not tainted 6.8.0-rc6-std-def-alt1 #1
      [ 1010.715899] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.0-alt1 04/01/2014
      [ 1010.715908] RIP: 0010:gtp_newlink+0x4d7/0x9c0 [gtp]
      [ 1010.715915] Code: 80 3c 02 00 0f 85 41 04 00 00 48 8b bb d8 05 00 00 e8 ed f6 ff ff 48 89 c2 48 89 c5 48 b8 00 00 00 00 00 fc ff df 48 c1 ea 03 <80> 3c 02 00 0f 85 4f 04 00 00 4c 89 e2 4c 8b 6d 00 48 b8 00 00 00
      [ 1010.715920] RSP: 0018:ffff888020fbf180 EFLAGS: 00010203
      [ 1010.715929] RAX: dffffc0000000000 RBX: ffff88800399c000 RCX: 0000000000000000
      [ 1010.715933] RDX: 0000000000000001 RSI: ffffffff84805280 RDI: 0000000000000282
      [ 1010.715938] RBP: 000000000000000d R08: 0000000000000001 R09: 0000000000000000
      [ 1010.715942] R10: 0000000000000001 R11: 0000000000000001 R12: ffff88800399cc80
      [ 1010.715947] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000400
      [ 1010.715953] FS:  00007fd1509ab5c0(0000) GS:ffff88805b300000(0000) knlGS:0000000000000000
      [ 1010.715958] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 1010.715962] CR2: 0000000000000000 CR3: 000000001c07a000 CR4: 0000000000750ee0
      [ 1010.715968] PKRU: 55555554
      [ 1010.715972] Call Trace:
      [ 1010.715985]  ? __die_body.cold+0x1a/0x1f
      [ 1010.715995]  ? die_addr+0x43/0x70
      [ 1010.716002]  ? exc_general_protection+0x199/0x2f0
      [ 1010.716016]  ? asm_exc_general_protection+0x1e/0x30
      [ 1010.716026]  ? gtp_newlink+0x4d7/0x9c0 [gtp]
      [ 1010.716034]  ? gtp_net_exit+0x150/0x150 [gtp]
      [ 1010.716042]  __rtnl_newlink+0x1063/0x1700
      [ 1010.716051]  ? rtnl_setlink+0x3c0/0x3c0
      [ 1010.716063]  ? is_bpf_text_address+0xc0/0x1f0
      [ 1010.716070]  ? kernel_text_address.part.0+0xbb/0xd0
      [ 1010.716076]  ? __kernel_text_address+0x56/0xa0
      [ 1010.716084]  ? unwind_get_return_address+0x5a/0xa0
      [ 1010.716091]  ? create_prof_cpu_mask+0x30/0x30
      [ 1010.716098]  ? arch_stack_walk+0x9e/0xf0
      [ 1010.716106]  ? stack_trace_save+0x91/0xd0
      [ 1010.716113]  ? stack_trace_consume_entry+0x170/0x170
      [ 1010.716121]  ? __lock_acquire+0x15c5/0x5380
      [ 1010.716139]  ? mark_held_locks+0x9e/0xe0
      [ 1010.716148]  ? kmem_cache_alloc_trace+0x35f/0x3c0
      [ 1010.716155]  ? __rtnl_newlink+0x1700/0x1700
      [ 1010.716160]  rtnl_newlink+0x69/0xa0
      [ 1010.716166]  rtnetlink_rcv_msg+0x43b/0xc50
      [ 1010.716172]  ? rtnl_fdb_dump+0x9f0/0x9f0
      [ 1010.716179]  ? lock_acquire+0x1fe/0x560
      [ 1010.716188]  ? netlink_deliver_tap+0x12f/0xd50
      [ 1010.716196]  netlink_rcv_skb+0x14d/0x440
      [ 1010.716202]  ? rtnl_fdb_dump+0x9f0/0x9f0
      [ 1010.716208]  ? netlink_ack+0xab0/0xab0
      [ 1010.716213]  ? netlink_deliver_tap+0x202/0xd50
      [ 1010.716220]  ? netlink_deliver_tap+0x218/0xd50
      [ 1010.716226]  ? __virt_addr_valid+0x30b/0x590
      [ 1010.716233]  netlink_unicast+0x54b/0x800
      [ 1010.716240]  ? netlink_attachskb+0x870/0x870
      [ 1010.716248]  ? __check_object_size+0x2de/0x3b0
      [ 1010.716254]  netlink_sendmsg+0x938/0xe40
      [ 1010.716261]  ? netlink_unicast+0x800/0x800
      [ 1010.716269]  ? __import_iovec+0x292/0x510
      [ 1010.716276]  ? netlink_unicast+0x800/0x800
      [ 1010.716284]  __sock_sendmsg+0x159/0x190
      [ 1010.716290]  ____sys_sendmsg+0x712/0x880
      [ 1010.716297]  ? sock_write_iter+0x3d0/0x3d0
      [ 1010.716304]  ? __ia32_sys_recvmmsg+0x270/0x270
      [ 1010.716309]  ? lock_acquire+0x1fe/0x560
      [ 1010.716315]  ? drain_array_locked+0x90/0x90
      [ 1010.716324]  ___sys_sendmsg+0xf8/0x170
      [ 1010.716331]  ? sendmsg_copy_msghdr+0x170/0x170
      [ 1010.716337]  ? lockdep_init_map_type+0x2c7/0x860
      [ 1010.716343]  ? lockdep_hardirqs_on_prepare+0x430/0x430
      [ 1010.716350]  ? debug_mutex_init+0x33/0x70
      [ 1010.716360]  ? percpu_counter_add_batch+0x8b/0x140
      [ 1010.716367]  ? lock_acquire+0x1fe/0x560
      [ 1010.716373]  ? find_held_lock+0x2c/0x110
      [ 1010.716384]  ? __fd_install+0x1b6/0x6f0
      [ 1010.716389]  ? lock_downgrade+0x810/0x810
      [ 1010.716396]  ? __fget_light+0x222/0x290
      [ 1010.716403]  __sys_sendmsg+0xea/0x1b0
      [ 1010.716409]  ? __sys_sendmsg_sock+0x40/0x40
      [ 1010.716419]  ? lockdep_hardirqs_on_prepare+0x2b3/0x430
      [ 1010.716425]  ? syscall_enter_from_user_mode+0x1d/0x60
      [ 1010.716432]  do_syscall_64+0x30/0x40
      [ 1010.716438]  entry_SYSCALL_64_after_hwframe+0x62/0xc7
      [ 1010.716444] RIP: 0033:0x7fd1508cbd49
      [ 1010.716452] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ef 70 0d 00 f7 d8 64 89 01 48
      [ 1010.716456] RSP: 002b:00007fff18872348 EFLAGS: 00000202 ORIG_RAX: 000000000000002e
      [ 1010.716463] RAX: ffffffffffffffda RBX: 000055f72bf0eac0 RCX: 00007fd1508cbd49
      [ 1010.716468] RDX: 0000000000000000 RSI: 0000000020000280 RDI: 0000000000000006
      [ 1010.716473] RBP: 00007fff18872360 R08: 00007fff18872360 R09: 00007fff18872360
      [ 1010.716478] R10: 00007fff18872360 R11: 0000000000000202 R12: 000055f72bf0e1b0
      [ 1010.716482] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
      [ 1010.716491] Modules linked in: gtp(+) udp_tunnel ib_core uinput af_packet rfkill qrtr joydev hid_generic usbhid hid kvm_intel iTCO_wdt intel_pmc_bxt iTCO_vendor_support kvm snd_hda_codec_generic ledtrig_audio irqbypass crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel snd_hda_intel nls_utf8 snd_intel_dspcfg nls_cp866 psmouse aesni_intel vfat crypto_simd fat cryptd glue_helper snd_hda_codec pcspkr snd_hda_core i2c_i801 snd_hwdep i2c_smbus xhci_pci snd_pcm lpc_ich xhci_pci_renesas xhci_hcd qemu_fw_cfg tiny_power_button button sch_fq_codel vboxvideo drm_vram_helper drm_ttm_helper ttm vboxsf vboxguest snd_seq_midi snd_seq_midi_event snd_seq snd_rawmidi snd_seq_device snd_timer snd soundcore msr fuse efi_pstore dm_mod ip_tables x_tables autofs4 virtio_gpu virtio_dma_buf drm_kms_helper cec rc_core drm virtio_rng virtio_scsi rng_core virtio_balloon virtio_blk virtio_net virtio_console net_failover failover ahci libahci libata evdev scsi_mod input_leds serio_raw virtio_pci intel_agp
      [ 1010.716674]  virtio_ring intel_gtt virtio [last unloaded: gtp]
      [ 1010.716693] ---[ end trace 04990a4ce61e174b ]---
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAlexander Ofitserov <oficerovas@altlinux.org>
      Fixes: 459aa660
      
       ("gtp: add initial driver for datapath of GPRS Tunneling Protocol (GTP-U)")
      Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
      Link: https://lore.kernel.org/r/20240228114703.465107-1-oficerovas@altlinux.org
      Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      93dd420b
    • Mickaël Salaün's avatar
      landlock: Fix asymmetric private inodes referring · f4906938
      Mickaël Salaün authored
      commit d9818b3e upstream.
      
      When linking or renaming a file, if only one of the source or
      destination directory is backed by an S_PRIVATE inode, then the related
      set of layer masks would be used as uninitialized by
      is_access_to_paths_allowed().  This would result to indeterministic
      access for one side instead of always being allowed.
      
      This bug could only be triggered with a mounted filesystem containing
      both S_PRIVATE and !S_PRIVATE inodes, which doesn't seem possible.
      
      The collect_domain_accesses() calls return early if
      is_nouser_or_private() returns false, which means that the directory's
      superblock has SB_NOUSER or its inode has S_PRIVATE.  Because rename or
      link actions are only allowed on the same mounted filesystem, the
      superblock is always the same for both source and destination
      directories.  However, it might be possible in theory to have an
      S_PRIVATE parent source inode with an !S_PRIVATE parent destination
      inode, or vice versa.
      
      To make sure this case is not an issue, explicitly initialized both set
      of layer masks to 0, which means to allow all actions on the related
      side.  If at least on side has !S_PRIVATE, then
      collect_domain_accesses() and is_access_to_paths_allowed() check for the
      required access rights.
      
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Günther Noack <gnoack@google.com>
      Cc: Jann Horn <jannh@google.com>
      Cc: Shervin Oloumi <enlightened@chromium.org>
      Cc: stable@vger.kernel.org
      Fixes: b91c3e4e
      
       ("landlock: Add support for file reparenting with LANDLOCK_ACCESS_FS_REFER")
      Link: https://lore.kernel.org/r/20240219190345.2928627-1-mic@digikod.net
      Signed-off-by: default avatarMickaël Salaün <mic@digikod.net>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4906938
    • Johan Hovold's avatar
      Bluetooth: hci_bcm4377: do not mark valid bd_addr as invalid · 0be289ba
      Johan Hovold authored
      commit c17d2a7b upstream.
      
      A recent commit restored the original (and still documented) semantics
      for the HCI_QUIRK_USE_BDADDR_PROPERTY quirk so that the device address
      is considered invalid unless an address is provided by firmware.
      
      This specifically means that this flag must only be set for devices with
      invalid addresses, but the Broadcom BCM4377 driver has so far been
      setting this flag unconditionally.
      
      Fortunately the driver already checks for invalid addresses during setup
      and sets the HCI_QUIRK_INVALID_BDADDR flag, which can simply be replaced
      with HCI_QUIRK_USE_BDADDR_PROPERTY to indicate that the default address
      is invalid but can be overridden by firmware (long term, this should
      probably just always be allowed).
      
      Fixes: 6945795b
      
       ("Bluetooth: fix use-bdaddr-property quirk")
      Cc: stable@vger.kernel.org      # 6.5
      Reported-by: default avatarFelix Zhang <mrman@mrman314.tech>
      Link: https://lore.kernel.org/r/77419ffacc5b4875e920e038332575a2a5bff29f.camel@mrman314.tech/
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Reported-by: default avatarFelix Zhang <mrman@mrman314.tech>
      Reviewed-by: default avatarNeal Gompa <neal@gompa.dev>
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0be289ba
    • Willian Wang's avatar
      ALSA: hda/realtek: Add special fixup for Lenovo 14IRP8 · a4904b3a
      Willian Wang authored
      commit 0ac32a39 upstream.
      
      Lenovo Slim/Yoga Pro 9 14IRP8 requires a special fixup because there is
      a collision of its PCI SSID (17aa:3802) with Lenovo Yoga DuetITL 2021
      codec SSID.
      
      Fixes: 3babae91
      
       ("ALSA: hda/tas2781: Add tas2781 HDA driver")
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=208555
      Link: https://lore.kernel.org/all/d5b42e483566a3815d229270abd668131a0d9f3a.camel@irl.hu
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWillian Wang <git@willian.wang>
      Reviewed-by: default avatarGergo Koteles <soyer@irl.hu>
      Link: https://lore.kernel.org/r/170879111795.8.6687687359006700715.273812184@willian.wang
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4904b3a
    • Eniac Zhang's avatar
      ALSA: hda/realtek: fix mute/micmute LED For HP mt440 · 5cdf76fb
      Eniac Zhang authored
      commit 67c3d771
      
       upstream.
      
      The HP mt440 Thin Client uses an ALC236 codec and needs the
      ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF quirk to make the mute and
      micmute LEDs work.
      
      There are two variants of the USB-C PD chip on this device. Each uses
      a different BIOS and board ID, hence the two entries.
      
      Signed-off-by: default avatarEniac Zhang <eniac-xw.zhang@hp.com>
      Signed-off-by: default avatarAlexandru Gagniuc <alexandru.gagniuc@hp.com>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20240220175812.782687-1-alexandru.gagniuc@hp.com
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5cdf76fb
    • Hans Peter's avatar
      ALSA: hda/realtek: Enable Mute LED on HP 840 G8 (MB 8AB8) · 46fb5e7e
      Hans Peter authored
      commit 1fdf4e8b
      
       upstream.
      
      On my EliteBook 840 G8 Notebook PC (ProdId 5S7R6EC#ABD; built 2022 for
      german market) the Mute LED is always on. The mute button itself works
      as expected. alsa-info.sh shows a different subsystem-id 0x8ab9 for
      Realtek ALC285 Codec, thus the existing quirks for HP 840 G8 don't work.
      Therefore, add a new quirk for this type of EliteBook.
      
      Signed-off-by: default avatarHans Peter <flurry123@gmx.ch>
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20240219164518.4099-1-flurry123@gmx.ch
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      46fb5e7e
    • Gergo Koteles's avatar
      ALSA: hda/realtek: tas2781: enable subwoofer volume control · d6ac6ffb
      Gergo Koteles authored
      commit c1947ce6 upstream.
      
      The volume of subwoofer channels is always at maximum with the
      ALC269_FIXUP_THINKPAD_ACPI chain.
      
      Use ALC285_FIXUP_THINKPAD_HEADSET_JACK to align it to the master volume.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=208555#c827
      
      Fixes: 3babae91
      
       ("ALSA: hda/tas2781: Add tas2781 HDA driver")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarGergo Koteles <soyer@irl.hu>
      Link: https://lore.kernel.org/r/7ffae10ebba58601d25fe2ff8381a6ae3a926e62.1708687813.git.soyer@irl.hu
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d6ac6ffb
    • Takashi Iwai's avatar
      ALSA: ump: Fix the discard error code from snd_ump_legacy_open() · bb06ffbf
      Takashi Iwai authored
      commit 49cbb7b7 upstream.
      
      snd_ump_legacy_open() didn't return the error code properly even if it
      couldn't open.  Fix it.
      
      Fixes: 0b5288f5
      
       ("ALSA: ump: Add legacy raw MIDI support")
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20240220150843.28630-1-tiwai@suse.de
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb06ffbf
    • Takashi Sakamoto's avatar
      ALSA: firewire-lib: fix to check cycle continuity · 22df6ff5
      Takashi Sakamoto authored
      commit 77ce9654 upstream.
      
      The local helper function to compare the given pair of cycle count
      evaluates them. If the left value is less than the right value, the
      function returns negative value.
      
      If the safe cycle is less than the current cycle, it is the case of
      cycle lost. However, it is not currently handled properly.
      
      This commit fixes the bug.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 705794c5
      
       ("ALSA: firewire-lib: check cycle continuity")
      Signed-off-by: default avatarTakashi Sakamoto <o-takashi@sakamocchi.jp>
      Link: https://lore.kernel.org/r/20240218033026.72577-1-o-takashi@sakamocchi.jp
      Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      22df6ff5
    • Tetsuo Handa's avatar
      tomoyo: fix UAF write bug in tomoyo_write_control() · 2caa6050
      Tetsuo Handa authored
      commit 2f03fc34
      
       upstream.
      
      Since tomoyo_write_control() updates head->write_buf when write()
      of long lines is requested, we need to fetch head->write_buf after
      head->io_sem is held.  Otherwise, concurrent write() requests can
      cause use-after-free-write and double-free problems.
      
      Reported-by: default avatarSam Sun <samsun1006219@gmail.com>
      Closes: https://lkml.kernel.org/r/CAEkJfYNDspuGxYx5kym8Lvp--D36CMDUErg4rxfWFJuPbbji8g@mail.gmail.com
      Fixes: bd03a3e4
      
       ("TOMOYO: Add policy namespace support.")
      Cc:  <stable@vger.kernel.org> # Linux 3.1+
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2caa6050
    • Saravana Kannan's avatar
      of: property: fw_devlink: Fix stupid bug in remote-endpoint parsing · 6f72b445
      Saravana Kannan authored
      [ Upstream commit 7cb50f6c ]
      
      Introduced a stupid bug in commit 782bfd03
      
       ("of: property: Improve
      finding the supplier of a remote-endpoint property") due to a last minute
      incorrect edit of "index !=0" into "!index". This patch fixes it to be
      "index > 0" to match the comment right next to it.
      
      Reported-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Link: https://lore.kernel.org/lkml/20240223171849.10f9901d@booty/
      Fixes: 782bfd03
      
       ("of: property: Improve finding the supplier of a remote-endpoint property")
      Signed-off-by: default avatarSaravana Kannan <saravanak@google.com>
      Reviewed-by: default avatarHerve Codina <herve.codina@bootlin.com>
      Reviewed-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Tested-by: default avatarLuca Ceresoli <luca.ceresoli@bootlin.com>
      Link: https://lore.kernel.org/r/20240224052436.3552333-1-saravanak@google.com
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      6f72b445
    • Filipe Manana's avatar
      btrfs: fix race between ordered extent completion and fiemap · d43f8e58
      Filipe Manana authored
      [ Upstream commit a1a4a9ca
      
       ]
      
      For fiemap we recently stopped locking the target extent range for the
      whole duration of the fiemap call, in order to avoid a deadlock in a
      scenario where the fiemap buffer happens to be a memory mapped range of
      the same file. This use case is very unlikely to be useful in practice but
      it may be triggered by fuzz testing (syzbot, etc).
      
      However by not locking the target extent range for the whole duration of
      the fiemap call we can race with an ordered extent. This happens like
      this:
      
      1) The fiemap task finishes processing a file extent item that covers
         the file range [512K, 1M[, and that file extent item is the last item
         in the leaf currently being processed;
      
      2) And ordered extent for the file range [768K, 2M[, in COW mode,
         completes (btrfs_finish_one_ordered()) and the file extent item
         covering the range [512K, 1M[ is trimmed to cover the range
         [512K, 768K[ and then a new file extent item for the range [768K, 2M[
         is inserted in the inode's subvolume tree;
      
      3) The fiemap task calls fiemap_next_leaf_item(), which then calls
         btrfs_next_leaf() to find the next leaf / item. This finds that the
         the next key following the one we previously processed (its type is
         BTRFS_EXTENT_DATA_KEY and its offset is 512K), is the key corresponding
         to the new file extent item inserted by the ordered extent, which has
         a type of BTRFS_EXTENT_DATA_KEY and an offset of 768K;
      
      4) Later the fiemap code ends up at emit_fiemap_extent() and triggers
         the warning:
      
            if (cache->offset + cache->len > offset) {
                     WARN_ON(1);
                     return -EINVAL;
            }
      
         Since we get 1M > 768K, because the previously emitted entry for the
         old extent covering the file range [512K, 1M[ ends at an offset that
         is greater than the new extent's start offset (768K). This makes fiemap
         fail with -EINVAL besides triggering the warning that produces a stack
         trace like the following:
      
           [1621.677651] ------------[ cut here ]------------
           [1621.677656] WARNING: CPU: 1 PID: 204366 at fs/btrfs/extent_io.c:2492 emit_fiemap_extent+0x84/0x90 [btrfs]
           [1621.677899] Modules linked in: btrfs blake2b_generic (...)
           [1621.677951] CPU: 1 PID: 204366 Comm: pool Not tainted 6.8.0-rc5-btrfs-next-151+ #1
           [1621.677954] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.2-0-gea1b7a073390-prebuilt.qemu.org 04/01/2014
           [1621.677956] RIP: 0010:emit_fiemap_extent+0x84/0x90 [btrfs]
           [1621.678033] Code: 2b 4c 89 63 (...)
           [1621.678035] RSP: 0018:ffffab16089ffd20 EFLAGS: 00010206
           [1621.678037] RAX: 00000000004fa000 RBX: ffffab16089ffe08 RCX: 0000000000009000
           [1621.678039] RDX: 00000000004f9000 RSI: 00000000004f1000 RDI: ffffab16089ffe90
           [1621.678040] RBP: 00000000004f9000 R08: 0000000000001000 R09: 0000000000000000
           [1621.678041] R10: 0000000000000000 R11: 0000000000001000 R12: 0000000041d78000
           [1621.678043] R13: 0000000000001000 R14: 0000000000000000 R15: ffff9434f0b17850
           [1621.678044] FS:  00007fa6e20006c0(0000) GS:ffff943bdfa40000(0000) knlGS:0000000000000000
           [1621.678046] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
           [1621.678048] CR2: 00007fa6b0801000 CR3: 000000012d404002 CR4: 0000000000370ef0
           [1621.678053] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
           [1621.678055] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
           [1621.678056] Call Trace:
           [1621.678074]  <TASK>
           [1621.678076]  ? __warn+0x80/0x130
           [1621.678082]  ? emit_fiemap_extent+0x84/0x90 [btrfs]
           [1621.678159]  ? report_bug+0x1f4/0x200
           [1621.678164]  ? handle_bug+0x42/0x70
           [1621.678167]  ? exc_invalid_op+0x14/0x70
           [1621.678170]  ? asm_exc_invalid_op+0x16/0x20
           [1621.678178]  ? emit_fiemap_extent+0x84/0x90 [btrfs]
           [1621.678253]  extent_fiemap+0x766/0xa30 [btrfs]
           [1621.678339]  btrfs_fiemap+0x45/0x80 [btrfs]
           [1621.678420]  do_vfs_ioctl+0x1e4/0x870
           [1621.678431]  __x64_sys_ioctl+0x6a/0xc0
           [1621.678434]  do_syscall_64+0x52/0x120
           [1621.678445]  entry_SYSCALL_64_after_hwframe+0x6e/0x76
      
      There's also another case where before calling btrfs_next_leaf() we are
      processing a hole or a prealloc extent and we had several delalloc ranges
      within that hole or prealloc extent. In that case if the ordered extents
      complete before we find the next key, we may end up finding an extent item
      with an offset smaller than (or equals to) the offset in cache->offset.
      
      So fix this by changing emit_fiemap_extent() to address these three
      scenarios like this:
      
      1) For the first case, steps listed above, adjust the length of the
         previously cached extent so that it does not overlap with the current
         extent, emit the previous one and cache the current file extent item;
      
      2) For the second case where he had a hole or prealloc extent with
         multiple delalloc ranges inside the hole or prealloc extent's range,
         and the current file extent item has an offset that matches the offset
         in the fiemap cache, just discard what we have in the fiemap cache and
         assign the current file extent item to the cache, since it's more up
         to date;
      
      3) For the third case where he had a hole or prealloc extent with
         multiple delalloc ranges inside the hole or prealloc extent's range
         and the offset of the file extent item we just found is smaller than
         what we have in the cache, just skip the current file extent item
         if its range end at or behind the cached extent's end, because we may
         have emitted (to the fiemap user space buffer) delalloc ranges that
         overlap with the current file extent item's range. If the file extent
         item's range goes beyond the end offset of the cached extent, just
         emit the cached extent and cache a subrange of the file extent item,
         that goes from the end offset of the cached extent to the end offset
         of the file extent item.
      
      Dealing with those cases in those ways makes everything consistent by
      reflecting the current state of file extent items in the btree and
      without emitting extents that have overlapping ranges (which would be
      confusing and violating expectations).
      
      This issue could be triggered often with test case generic/561, and was
      also hit and reported by Wang Yugui.
      
      Reported-by: default avatarWang Yugui <wangyugui@e16-tech.com>
      Link: https://lore.kernel.org/linux-btrfs/20240223104619.701F.409509F4@e16-tech.com/
      Fixes: b0ad381f
      
       ("btrfs: fix deadlock with fiemap and extent locking")
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      d43f8e58
    • Dimitris Vlachos's avatar
      riscv: Sparse-Memory/vmemmap out-of-bounds fix · a278d5c6
      Dimitris Vlachos authored
      [ Upstream commit a11dd49d
      
       ]
      
      Offset vmemmap so that the first page of vmemmap will be mapped
      to the first page of physical memory in order to ensure that
      vmemmap’s bounds will be respected during
      pfn_to_page()/page_to_pfn() operations.
      The conversion macros will produce correct SV39/48/57 addresses
      for every possible/valid DRAM_BASE inside the physical memory limits.
      
      v2:Address Alex's comments
      
      Suggested-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Signed-off-by: default avatarDimitris Vlachos <dvlachos@ics.forth.gr>
      Reported-by: default avatarDimitris Vlachos <dvlachos@ics.forth.gr>
      Closes: https://lore.kernel.org/linux-riscv/20240202135030.42265-1-csd4492@csd.uoc.gr
      Fixes: d95f1a54
      
       ("RISC-V: Implement sparsemem")
      Reviewed-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Link: https://lore.kernel.org/r/20240229191723.32779-1-dvlachos@ics.forth.gr
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      a278d5c6
    • Alexandre Ghiti's avatar
      riscv: Fix pte_leaf_size() for NAPOT · eb257167
      Alexandre Ghiti authored
      [ Upstream commit e0fe5ab4 ]
      
      pte_leaf_size() must be reimplemented to add support for NAPOT mappings.
      
      Fixes: 82a1a1f3
      
       ("riscv: mm: support Svnapot in hugetlb page")
      Signed-off-by: default avatarAlexandre Ghiti <alexghiti@rivosinc.com>
      Link: https://lore.kernel.org/r/20240227205016.121901-3-alexghiti@rivosinc.com
      Signed-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
      Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
      eb257167