Skip to content
  1. May 17, 2023
    • Johan Hovold's avatar
      drm/msm/adreno: fix runtime PM imbalance at gpu load · 47bfe128
      Johan Hovold authored
      commit 0d997f95 upstream.
      
      A recent commit moved enabling of runtime PM to GPU load time (first
      open()) but failed to update the error paths so that runtime PM is
      disabled if initialisation of the GPU fails. This would trigger a
      warning about the unbalanced disable count on the next open() attempt.
      
      Note that pm_runtime_put_noidle() is sufficient to balance the usage
      count when pm_runtime_put_sync() fails (and is chosen over
      pm_runtime_resume_and_get() for consistency reasons).
      
      Fixes: 4b18299b
      
       ("drm/msm/adreno: Defer enabling runpm until hw_init()")
      Cc: stable@vger.kernel.org      # 6.0
      Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
      Patchwork: https://patchwork.freedesktop.org/patch/524971/
      Link: https://lore.kernel.org/r/20230303164807.13124-3-johan+linaro@kernel.org
      Signed-off-by: default avatarRob Clark <robdclark@chromium.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      47bfe128
    • Zev Weiss's avatar
      ARM: dts: aspeed: romed8hm3: Fix GPIO polarity of system-fault LED · 3d0fdfef
      Zev Weiss authored
      commit a3fd1073
      
       upstream.
      
      Turns out it's in fact not the same as the heartbeat LED.
      
      Signed-off-by: default avatarZev Weiss <zev@bewilderbeest.net>
      Cc: stable@vger.kernel.org # v5.18+
      Fixes: a9a3d60b
      
       ("ARM: dts: aspeed: Add ASRock ROMED8HM3 BMC")
      Link: https://lore.kernel.org/r/20230224000400.12226-2-zev@bewilderbeest.net
      Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3d0fdfef
    • Krzysztof Kozlowski's avatar
      ARM: dts: s5pv210: correct MIPI CSIS clock name · f327c744
      Krzysztof Kozlowski authored
      commit 665b9459 upstream.
      
      The Samsung S5P/Exynos MIPI CSIS bindings and Linux driver expect first
      clock name to be "csis".  Otherwise the driver fails to probe.
      
      Fixes: 94ad0f6d
      
       ("ARM: dts: Add Device tree for s5pv210 SoC")
      Cc: <stable@vger.kernel.org>
      Link: https://lore.kernel.org/r/20230212185818.43503-2-krzysztof.kozlowski@linaro.org
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f327c744
    • Krzysztof Kozlowski's avatar
      ARM: dts: exynos: fix WM8960 clock name in Itop Elite · 5503ea70
      Krzysztof Kozlowski authored
      commit 6c950c20 upstream.
      
      The WM8960 Linux driver expects the clock to be named "mclk".  Otherwise
      the clock will be ignored and not prepared/enabled by the driver.
      
      Cc: <stable@vger.kernel.org>
      Fixes: 339b2fb3
      
       ("ARM: dts: exynos: Add TOPEET itop elite based board")
      Link: https://lore.kernel.org/r/20230217150627.779764-3-krzysztof.kozlowski@linaro.org
      Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5503ea70
    • Zev Weiss's avatar
      ARM: dts: aspeed: asrock: Correct firmware flash SPI clocks · 6efe88c3
      Zev Weiss authored
      commit 9dedb724
      
       upstream.
      
      While I'm not aware of any problems that have occurred running these
      at 100 MHz, the official word from ASRock is that 50 MHz is the
      correct speed to use, so let's be safe and use that instead.
      
      Signed-off-by: default avatarZev Weiss <zev@bewilderbeest.net>
      Cc: stable@vger.kernel.org
      Fixes: 2b81613c ("ARM: dts: aspeed: Add ASRock E3C246D4I BMC")
      Fixes: a9a3d60b
      
       ("ARM: dts: aspeed: Add ASRock ROMED8HM3 BMC")
      Link: https://lore.kernel.org/r/20230224000400.12226-4-zev@bewilderbeest.net
      Signed-off-by: default avatarJoel Stanley <joel@jms.id.au>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6efe88c3
    • Luis Chamberlain's avatar
      sysctl: clarify register_sysctl_init() base directory order · a64910ba
      Luis Chamberlain authored
      commit 228b09de
      
       upstream.
      
      Relatively new docs which I added which hinted the base directories needed
      to be created before is wrong, remove that incorrect comment. This has been
      hinted before by Eric twice already [0] [1], I had just not verified that
      until now. Now that I've verified that updates the docs to relax the context
      described.
      
      [0] https://lkml.kernel.org/r/875ys0azt8.fsf@email.froward.int.ebiederm.org
      [1] https://lkml.kernel.org/r/87ftbiud6s.fsf@x220.int.ebiederm.org
      
      Cc: stable@vger.kernel.org # v5.17
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Suggested-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a64910ba
    • Mathieu Poirier's avatar
      remoteproc: rcar_rproc: Call of_node_put() on iteration error · c3c70209
      Mathieu Poirier authored
      commit f8bae637 upstream.
      
      Function of_phandle_iterator_next() calls of_node_put() on the last
      device_node it iterated over, but when the loop exits prematurely it has
      to be called explicitly.
      
      Fixes: 285892a7
      
       ("remoteproc: Add Renesas rcar driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Link: https://lore.kernel.org/r/20230320221826.2728078-4-mathieu.poirier@linaro.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c3c70209
    • Mathieu Poirier's avatar
      remoteproc: imx_rproc: Call of_node_put() on iteration error · 948f81da
      Mathieu Poirier authored
      commit 5ef074e8 upstream.
      
      Function of_phandle_iterator_next() calls of_node_put() on the last
      device_node it iterated over, but when the loop exits prematurely it has
      to be called explicitly.
      
      Fixes: b29b4249
      
       ("remoteproc: imx_rproc: add i.MX specific parse fw hook")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarPeng Fan <peng.fan@nxp.com>
      Link: https://lore.kernel.org/r/20230320221826.2728078-5-mathieu.poirier@linaro.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      948f81da
    • Mathieu Poirier's avatar
      remoteproc: imx_dsp_rproc: Call of_node_put() on iteration error · fe3497c3
      Mathieu Poirier authored
      commit e0e01de8 upstream.
      
      Function of_phandle_iterator_next() calls of_node_put() on the last
      device_node it iterated over, but when the loop exits prematurely it has
      to be called explicitly.
      
      Fixes: ec0e5549
      
       ("remoteproc: imx_dsp_rproc: Add remoteproc driver for DSP on i.MX")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Acked-by: default avatarShengjiu Wang <shengjiu.wang@gmail.com>
      Link: https://lore.kernel.org/r/20230320221826.2728078-6-mathieu.poirier@linaro.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fe3497c3
    • Mathieu Poirier's avatar
      remoteproc: st: Call of_node_put() on iteration error · 8a0fc842
      Mathieu Poirier authored
      commit 8a749189 upstream.
      
      Function of_phandle_iterator_next() calls of_node_put() on the last
      device_node it iterated over, but when the loop exits prematurely it has
      to be called explicitly.
      
      Fixes: 3df52ed7
      
       ("remoteproc: st: add reserved memory support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarArnaud Pouliquen <arnaud.pouliquen@foss.st.com>
      Link: https://lore.kernel.org/r/20230320221826.2728078-3-mathieu.poirier@linaro.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8a0fc842
    • Mathieu Poirier's avatar
      remoteproc: stm32: Call of_node_put() on iteration error · 0d6b6665
      Mathieu Poirier authored
      commit ccadca5b upstream.
      
      Function of_phandle_iterator_next() calls of_node_put() on the last
      device_node it iterated over, but when the loop exits prematurely it has
      to be called explicitly.
      
      Fixes: 13140de0
      
       ("remoteproc: stm32: add an ST stm32_rproc driver")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Reviewed-by: default avatarArnaud Pouliquen <arnaud.pouliquen@foss.st.com>
      Link: https://lore.kernel.org/r/20230320221826.2728078-2-mathieu.poirier@linaro.org
      Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0d6b6665
    • Luis Chamberlain's avatar
      proc_sysctl: enhance documentation · fde64a40
      Luis Chamberlain authored
      commit 1dc8689e
      
       upstream.
      
      Expand documentation to clarify:
      
        o that paths don't need to exist for the new API callers
        o clarify that we *require* callers to keep the memory of
          the table around during the lifetime of the sysctls
        o annotate routines we are trying to deprecate and later remove
      
      Cc: stable@vger.kernel.org # v5.17
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fde64a40
    • Luis Chamberlain's avatar
      proc_sysctl: update docs for __register_sysctl_table() · f4708645
      Luis Chamberlain authored
      commit 67ff3228
      
       upstream.
      
      Update the docs for __register_sysctl_table() to make it clear no child
      entries can be passed. When the child is true these are non-leaf entries
      on the ctl table and sysctl treats these as directories. The point to
      __register_sysctl_table() is to deal only with directories not part of
      the ctl table where thay may riside, to be simple and avoid recursion.
      
      While at it, hint towards using long on extra1 and extra2 later.
      
      Cc: stable@vger.kernel.org # v5.17
      Cc: Christian Brauner <brauner@kernel.org>
      Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
      Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f4708645
    • Randy Dunlap's avatar
      sh: nmi_debug: fix return value of __setup handler · c93185ff
      Randy Dunlap authored
      commit d1155e41 upstream.
      
      __setup() handlers should return 1 to obsolete_checksetup() in
      init/main.c to indicate that the boot option has been handled.
      A return of 0 causes the boot option/value to be listed as an Unknown
      kernel parameter and added to init's (limited) argument or environment
      strings. Also, error return codes don't mean anything to
      obsolete_checksetup() -- only non-zero (usually 1) or zero.
      So return 1 from nmi_debug_setup().
      
      Fixes: 1e1030dc
      
       ("sh: nmi_debug support.")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarIgor Zhbanov <izh1979@gmail.com>
      Link: lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: linux-sh@vger.kernel.org
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/20230306040037.20350-3-rdunlap@infradead.org
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c93185ff
    • Randy Dunlap's avatar
      sh: init: use OF_EARLY_FLATTREE for early init · 2ebd0064
      Randy Dunlap authored
      commit 6cba6555 upstream.
      
      When CONFIG_OF_EARLY_FLATTREE and CONFIG_SH_DEVICE_TREE are not set,
      SH3 build fails with a call to early_init_dt_scan(), so in
      arch/sh/kernel/setup.c and arch/sh/kernel/head_32.S, use
      CONFIG_OF_EARLY_FLATTREE instead of CONFIG_OF_FLATTREE.
      
      Fixes this build error:
      ../arch/sh/kernel/setup.c: In function 'sh_fdt_init':
      ../arch/sh/kernel/setup.c:262:26: error: implicit declaration of function 'early_init_dt_scan' [-Werror=implicit-function-declaration]
        262 |         if (!dt_virt || !early_init_dt_scan(dt_virt)) {
      
      Fixes: 03767daa ("sh: fix build regression with CONFIG_OF && !CONFIG_OF_FLATTREE")
      Fixes: eb6b6930
      
       ("sh: fix memory corruption of unflattened device tree")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Suggested-by: default avatarRob Herring <robh+dt@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: devicetree@vger.kernel.org
      Cc: Rich Felker <dalias@libc.org>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Geert Uytterhoeven <geert+renesas@glider.be>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: linux-sh@vger.kernel.org
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/20230306040037.20350-4-rdunlap@infradead.org
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      2ebd0064
    • Randy Dunlap's avatar
      sh: mcount.S: fix build error when PRINTK is not enabled · ab2221dc
      Randy Dunlap authored
      commit c2bd1e18 upstream.
      
      Fix a build error in mcount.S when CONFIG_PRINTK is not enabled.
      Fixes this build error:
      
      sh2-linux-ld: arch/sh/lib/mcount.o: in function `stack_panic':
      (.text+0xec): undefined reference to `dump_stack'
      
      Fixes: e460ab27
      
       ("sh: Fix up stack overflow check with ftrace disabled.")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Suggested-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/20230306040037.20350-8-rdunlap@infradead.org
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      ab2221dc
    • Randy Dunlap's avatar
      sh: math-emu: fix macro redefined warning · fdac282b
      Randy Dunlap authored
      commit 58a49ad9 upstream.
      
      Fix a warning that was reported by the kernel test robot:
      
      In file included from ../include/math-emu/soft-fp.h:27,
                       from ../arch/sh/math-emu/math.c:22:
      ../arch/sh/include/asm/sfp-machine.h:17: warning: "__BYTE_ORDER" redefined
         17 | #define __BYTE_ORDER __BIG_ENDIAN
      In file included from ../arch/sh/math-emu/math.c:21:
      ../arch/sh/math-emu/sfp-util.h:71: note: this is the location of the previous definition
         71 | #define __BYTE_ORDER __LITTLE_ENDIAN
      
      Fixes: b929926f
      
       ("sh: define __BIG_ENDIAN for math-emu")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Link: lore.kernel.org/r/202111121827.6v6SXtVv-lkp@intel.com
      Cc: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
      Cc: Rich Felker <dalias@libc.org>
      Cc: linux-sh@vger.kernel.org
      Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Link: https://lore.kernel.org/r/20230306040037.20350-5-rdunlap@infradead.org
      Signed-off-by: default avatarJohn Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      fdac282b
    • Steve French's avatar
      SMB3: force unmount was failing to close deferred close files · 6d103a57
      Steve French authored
      commit 2cb6f968
      
       upstream.
      
      In investigating a failure with xfstest generic/392 it
      was noticed that mounts were reusing a superblock that should
      already have been freed. This turned out to be related to
      deferred close files keeping a reference count until the
      closetimeo expired.
      
      Currently the only way an fs knows that mount is beginning is
      when force unmount is called, but when this, ie umount_begin(),
      is called all deferred close files on the share (tree
      connection) should be closed immediately (unless shared by
      another mount) to avoid using excess resources on the server
      and to avoid reusing a superblock which should already be freed.
      
      In umount_begin, close all deferred close handles for that
      share if this is the last mount using that share on this
      client (ie send the SMB3 close request over the wire for those
      that have been already closed by the app but that we have
      kept a handle lease open for and have not sent closes to the
      server for yet).
      
      Reported-by: default avatarDavid Howells <dhowells@redhat.com>
      Acked-by: default avatarBharath SM <bharathsm@microsoft.com>
      Cc: <stable@vger.kernel.org>
      Fixes: 78c09634
      
       ("Cifs: Fix kernel oops caused by deferred close for files.")
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6d103a57
    • Steve French's avatar
      smb3: fix problem remounting a share after shutdown · bb0091a5
      Steve French authored
      commit 716a3cf3
      
       upstream.
      
      xfstests generic/392 showed a problem where even after a
      shutdown call was made on a mount, we would still attempt
      to use the (now inaccessible) superblock if another mount
      was attempted for the same share.
      
      Reported-by: default avatarDavid Howells <dhowells@redhat.com>
      Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: <stable@vger.kernel.org>
      Fixes: 087f757b
      
       ("cifs: add shutdown support")
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bb0091a5
    • Jan Kara's avatar
      inotify: Avoid reporting event with invalid wd · 145f54ea
      Jan Kara authored
      commit c915d8f5 upstream.
      
      When inotify_freeing_mark() races with inotify_handle_inode_event() it
      can happen that inotify_handle_inode_event() sees that i_mark->wd got
      already reset to -1 and reports this value to userspace which can
      confuse the inotify listener. Avoid the problem by validating that wd is
      sensible (and pretend the mark got removed before the event got
      generated otherwise).
      
      CC: stable@vger.kernel.org
      Fixes: 7e790dd5
      
       ("inotify: fix error paths in inotify_update_watch")
      Message-Id: <20230424163219.9250-1-jack@suse.cz>
      Reported-by: default avatar <syzbot+4a06d4373fd52f0b2f9c@syzkaller.appspotmail.com>
      Reviewed-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      145f54ea
    • Mark Pearson's avatar
      platform/x86: thinkpad_acpi: Add profile force ability · d759abeb
      Mark Pearson authored
      commit 16848789
      
       upstream.
      
      There has been a lot of confusion around which platform profiles are
      supported on various platforms and it would be useful to have a debug
      method to be able to override the profile mode that is selected.
      
      I don't expect this to be used in anything other than debugging in
      conjunction with Lenovo engineers - but it does give a way to get a
      system working whilst we wait for either FW fixes, or a driver fix
      to land upstream, if something is wonky in the mode detection logic
      
      Signed-off-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
      Link: https://lore.kernel.org/r/20230505132523.214338-2-mpearson-lenovo@squebb.ca
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d759abeb
    • Andrey Avdeev's avatar
      platform/x86: touchscreen_dmi: Add info for the Dexp Ursus KX210i · 66d4f7f3
      Andrey Avdeev authored
      commit 4b65f95c
      
       upstream.
      
      Add touchscreen info for the Dexp Ursus KX210i
      
      Signed-off-by: default avatarAndrey Avdeev <jamesstoun@gmail.com>
      Link: https://lore.kernel.org/r/ZE4gRgzRQCjXFYD0@avdeevavpc
      Cc: stable@vger.kernel.org
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      66d4f7f3
    • Mark Pearson's avatar
      platform/x86: thinkpad_acpi: Fix platform profiles on T490 · e614c1de
      Mark Pearson authored
      commit 0c0cd3e2 upstream.
      
      I had incorrectly thought that PSC profiles were not usable on Intel
      platforms so had blocked them in the driver initialistion. This broke
      platform profiles on the T490.
      
      After discussion with the FW team PSC does work on Intel platforms and
      should be allowed.
      
      Note - it's possible this may impact other platforms where it is advertised
      but special driver support that only Windows has is needed. But if it does
      then they will need fixing via quirks. Please report any issues to me so I
      can get them addressed - but I haven't found any problems in testing...yet
      
      Fixes: bce6243f
      
       ("platform/x86: thinkpad_acpi: do not use PSC mode on Intel platforms")
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=2177962
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarMark Pearson <mpearson-lenovo@squebb.ca>
      Link: https://lore.kernel.org/r/20230505132523.214338-1-mpearson-lenovo@squebb.ca
      Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e614c1de
    • Hans de Goede's avatar
      platform/x86: touchscreen_dmi: Add upside-down quirk for GDIX1002 ts on the Juno Tablet · a02d29de
      Hans de Goede authored
      commit 6abfa99c
      
       upstream.
      
      The Juno Computers Juno Tablet has an upside-down mounted Goodix
      touchscreen. Add a quirk to invert both axis to correct for this.
      
      Link: https://junocomputers.com/us/product/juno-tablet/
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Link: https://lore.kernel.org/r/20230505210323.43177-1-hdegoede@redhat.com
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a02d29de
    • Srinivas Pandruvada's avatar
      platform/x86/intel-uncore-freq: Return error on write frequency · 61549b74
      Srinivas Pandruvada authored
      commit 75e406b5 upstream.
      
      Currently when the uncore_write() returns error, it is silently
      ignored. Return error to user space when uncore_write() fails.
      
      Fixes: 49a474c7
      
       ("platform/x86: Add support for Uncore frequency control")
      Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
      Reviewed-by: default avatarZhang Rui <rui.zhang@intel.com>
      Tested-by: default avatarWendy Wang <wendy.wang@intel.com>
      Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
      Link: https://lore.kernel.org/r/20230418153230.679094-1-srinivas.pandruvada@linux.intel.com
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      61549b74
    • Steve French's avatar
      cifs: release leases for deferred close handles when freezing · b886ad6b
      Steve French authored
      commit d39fc592
      
       upstream.
      
      We should not be caching closed files when freeze is invoked on an fs
      (so we can release resources more gracefully).
      
      Fixes xfstests generic/068 generic/390 generic/491
      
      Reviewed-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b886ad6b
    • Pawel Witek's avatar
      cifs: fix pcchunk length type in smb2_copychunk_range · 187f89cf
      Pawel Witek authored
      commit d66cde50 upstream.
      
      Change type of pcchunk->Length from u32 to u64 to match
      smb2_copychunk_range arguments type. Fixes the problem where performing
      server-side copy with CIFS_IOC_COPYCHUNK_FILE ioctl resulted in incomplete
      copy of large files while returning -EINVAL.
      
      Fixes: 9bf0c9cd
      
       ("CIFS: Fix SMB2/SMB3 Copy offload support (refcopy) for large files")
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarPawel Witek <pawel.ireneusz.witek@gmail.com>
      Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      187f89cf
    • Naohiro Aota's avatar
      btrfs: zoned: fix full zone super block reading on ZNS · c5544c95
      Naohiro Aota authored
      commit 02ca9e6f upstream.
      
      When both of the superblock zones are full, we need to check which
      superblock is newer. The calculation of last superblock position is wrong
      as it does not consider zone_capacity and uses the length.
      
      Fixes: 9658b72e
      
       ("btrfs: zoned: locate superblock position using zone capacity")
      CC: stable@vger.kernel.org # 6.1+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      c5544c95
    • Naohiro Aota's avatar
      btrfs: zoned: zone finish data relocation BG with last IO · 4def3a0a
      Naohiro Aota authored
      commit f84353c7 upstream.
      
      For data block groups, we zone finish a zone (or, just deactivate it) when
      seeing the last IO in btrfs_finish_ordered_io(). That is only called for
      IOs using ZONE_APPEND, but we use a regular WRITE command for data
      relocation IOs. Detect it and call btrfs_zone_finish_endio() properly.
      
      Fixes: be1a1d7a
      
       ("btrfs: zoned: finish fully written block group")
      CC: stable@vger.kernel.org # 6.1+
      Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      4def3a0a
    • Filipe Manana's avatar
      btrfs: fix space cache inconsistency after error loading it from disk · 1e8de322
      Filipe Manana authored
      commit 0004ff15 upstream.
      
      When loading a free space cache from disk, at __load_free_space_cache(),
      if we fail to insert a bitmap entry, we still increment the number of
      total bitmaps in the btrfs_free_space_ctl structure, which is incorrect
      since we failed to add the bitmap entry. On error we then empty the
      cache by calling __btrfs_remove_free_space_cache(), which will result
      in getting the total bitmaps counter set to 1.
      
      A failure to load a free space cache is not critical, so if a failure
      happens we just rebuild the cache by scanning the extent tree, which
      happens at block-group.c:caching_thread(). Yet the failure will result
      in having the total bitmaps of the btrfs_free_space_ctl always bigger
      by 1 then the number of bitmap entries we have. So fix this by having
      the total bitmaps counter be incremented only if we successfully added
      the bitmap entry.
      
      Fixes: a67509c3
      
       ("Btrfs: add a io_ctl struct and helpers for dealing with the space cache")
      Reviewed-by: default avatarAnand Jain <anand.jain@oracle.com>
      CC: stable@vger.kernel.org # 4.4+
      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>
      1e8de322
    • Anastasia Belova's avatar
      btrfs: print-tree: parent bytenr must be aligned to sector size · 1689eabb
      Anastasia Belova authored
      commit c87f318e upstream.
      
      Check nodesize to sectorsize in alignment check in print_extent_item.
      The comment states that and this is correct, similar check is done
      elsewhere in the functions.
      
      Found by Linux Verification Center (linuxtesting.org) with SVACE.
      
      Fixes: ea57788e
      
       ("btrfs: require only sector size alignment for parent eb bytenr")
      CC: stable@vger.kernel.org # 4.14+
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarAnastasia Belova <abelova@astralinux.ru>
      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>
      1689eabb
    • Qu Wenruo's avatar
      btrfs: make clear_cache mount option to rebuild FST without disabling it · 83ae0282
      Qu Wenruo authored
      commit 1d6a4fc8
      
       upstream.
      
      Previously clear_cache mount option would simply disable free-space-tree
      feature temporarily then re-enable it to rebuild the whole free space
      tree.
      
      But this is problematic for block-group-tree feature, as we have an
      artificial dependency on free-space-tree feature.
      
      If we go the existing method, after clearing the free-space-tree
      feature, we would flip the filesystem to read-only mode, as we detect a
      super block write with block-group-tree but no free-space-tree feature.
      
      This patch would change the behavior by properly rebuilding the free
      space tree without disabling this feature, thus allowing clear_cache
      mount option to work with block group tree.
      
      Now we can mount a filesystem with block-group-tree feature and
      clear_mount option:
      
        $ mkfs.btrfs  -O block-group-tree /dev/test/scratch1  -f
        $ sudo mount /dev/test/scratch1 /mnt/btrfs -o clear_cache
        $ sudo dmesg -t | head -n 5
        BTRFS info (device dm-1): force clearing of disk cache
        BTRFS info (device dm-1): using free space tree
        BTRFS info (device dm-1): auto enabling async discard
        BTRFS info (device dm-1): rebuilding free space tree
        BTRFS info (device dm-1): checking UUID tree
      
      CC: stable@vger.kernel.org # 6.1+
      Signed-off-by: default avatarQu Wenruo <wqu@suse.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      83ae0282
    • Christoph Hellwig's avatar
      btrfs: zero the buffer before marking it dirty in btrfs_redirty_list_add · dd5a2194
      Christoph Hellwig authored
      commit c83b56d1 upstream.
      
      btrfs_redirty_list_add zeroes the buffer data and sets the
      EXTENT_BUFFER_NO_CHECK to make sure writeback is fine with a bogus
      header.  But it does that after already marking the buffer dirty, which
      means that writeback could already be looking at the buffer.
      
      Switch the order of operations around so that the buffer is only marked
      dirty when we're ready to write it.
      
      Fixes: d3575156
      
       ("btrfs: zoned: redirty released extent buffers")
      CC: stable@vger.kernel.org # 5.15+
      Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
      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>
      dd5a2194
    • Josef Bacik's avatar
      btrfs: don't free qgroup space unless specified · 15e877e5
      Josef Bacik authored
      commit d246331b
      
       upstream.
      
      Boris noticed in his simple quotas testing that he was getting a leak
      with Sweet Tea's change to subvol create that stopped doing a
      transaction commit.  This was just a side effect of that change.
      
      In the delayed inode code we have an optimization that will free extra
      reservations if we think we can pack a dir item into an already modified
      leaf.  Previously this wouldn't be triggered in the subvolume create
      case because we'd commit the transaction, it was still possible but
      much harder to trigger.  It could actually be triggered if we did a
      mkdir && subvol create with qgroups enabled.
      
      This occurs because in btrfs_insert_delayed_dir_index(), which gets
      called when we're adding the dir item, we do the following:
      
        btrfs_block_rsv_release(fs_info, trans->block_rsv, bytes, NULL);
      
      if we're able to skip reserving space.
      
      The problem here is that trans->block_rsv points at the temporary block
      rsv for the subvolume create, which has qgroup reservations in the block
      rsv.
      
      This is a problem because btrfs_block_rsv_release() will do the
      following:
      
        if (block_rsv->qgroup_rsv_reserved >= block_rsv->qgroup_rsv_size) {
      	  qgroup_to_release = block_rsv->qgroup_rsv_reserved -
      		  block_rsv->qgroup_rsv_size;
      	  block_rsv->qgroup_rsv_reserved = block_rsv->qgroup_rsv_size;
        }
      
      The temporary block rsv just has ->qgroup_rsv_reserved set,
      ->qgroup_rsv_size == 0.  The optimization in
      btrfs_insert_delayed_dir_index() sets ->qgroup_rsv_reserved = 0.  Then
      later on when we call btrfs_subvolume_release_metadata() which has
      
        btrfs_block_rsv_release(fs_info, rsv, (u64)-1, &qgroup_to_release);
        btrfs_qgroup_convert_reserved_meta(root, qgroup_to_release);
      
      qgroup_to_release is set to 0, and we do not convert the reserved
      metadata space.
      
      The problem here is that the block rsv code has been unconditionally
      messing with ->qgroup_rsv_reserved, because the main place this is used
      is delalloc, and any time we call btrfs_block_rsv_release() we do it
      with qgroup_to_release set, and thus do the proper accounting.
      
      The subvolume code is the only other code that uses the qgroup
      reservation stuff, but it's intermingled with the above optimization,
      and thus was getting its reservation freed out from underneath it and
      thus leaking the reserved space.
      
      The solution is to simply not mess with the qgroup reservations if we
      don't have qgroup_to_release set.  This works with the existing code as
      anything that messes with the delalloc reservations always have
      qgroup_to_release set.  This fixes the leak that Boris was observing.
      
      Reviewed-by: default avatarQu Wenruo <wqu@suse.com>
      CC: stable@vger.kernel.org # 5.4+
      Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      15e877e5
    • Boris Burkov's avatar
      btrfs: fix encoded write i_size corruption with no-holes · 44c52544
      Boris Burkov authored
      commit e7db9e5c upstream.
      
      We have observed a btrfs filesystem corruption on workloads using
      no-holes and encoded writes via send stream v2. The symptom is that a
      file appears to be truncated to the end of its last aligned extent, even
      though the final unaligned extent and even the file extent and otherwise
      correctly updated inode item have been written.
      
      So if we were writing out a 1MiB+X file via 8 128K extents and one
      extent of length X, i_size would be set to 1MiB, but the ninth extent,
      nbyte, etc. would all appear correct otherwise.
      
      The source of the race is a narrow (one line of code) window in which a
      no-holes fs has read in an updated i_size, but has not yet set a shared
      disk_i_size variable to write. Therefore, if two ordered extents run in
      parallel (par for the course for receive workloads), the following
      sequence can play out: (following "threads" a bit loosely, since there
      are callbacks involved for endio but extra threads aren't needed to
      cause the issue)
      
        ENC-WR1 (second to last)                                         ENC-WR2 (last)
        -------                                                          -------
        btrfs_do_encoded_write
          set i_size = 1M
          submit bio B1 ending at 1M
        endio B1
        btrfs_inode_safe_disk_i_size_write
          local i_size = 1M
          falls off a cliff for some reason
      							      btrfs_do_encoded_write
      								set i_size = 1M+X
      								submit bio B2 ending at 1M+X
      							      endio B2
      							      btrfs_inode_safe_disk_i_size_write
      								local i_size = 1M+X
      								disk_i_size = 1M+X
          disk_i_size = 1M
      							      btrfs_delayed_update_inode
          btrfs_delayed_update_inode
      
      And the delayed inode ends up filled with nbytes=1M+X and isize=1M, and
      writes respect i_size and present a corrupted file missing its last
      extents.
      
      Fix this by holding the inode lock in the no-holes case so that a thread
      can't sneak in a write to disk_i_size that gets overwritten with an out
      of date i_size.
      
      Fixes: 41a2ee75
      
       ("btrfs: introduce per-inode file extent tree")
      CC: stable@vger.kernel.org # 5.10+
      Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
      Signed-off-by: default avatarBoris Burkov <boris@bur.io>
      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>
      44c52544
    • xiaoshoukui's avatar
      btrfs: fix assertion of exclop condition when starting balance · 17eaeee4
      xiaoshoukui authored
      commit ac868bc9
      
       upstream.
      
      Balance as exclusive state is compatible with paused balance and device
      add, which makes some things more complicated. The assertion of valid
      states when starting from paused balance needs to take into account two
      more states, the combinations can be hit when there are several threads
      racing to start balance and device add. This won't typically happen when
      the commands are started from command line.
      
      Scenario 1: With exclusive_operation state == BTRFS_EXCLOP_NONE.
      
      Concurrently adding multiple devices to the same mount point and
      btrfs_exclop_finish executed finishes before assertion in
      btrfs_exclop_balance, exclusive_operation will changed to
      BTRFS_EXCLOP_NONE state which lead to assertion failed:
      
        fs_info->exclusive_operation == BTRFS_EXCLOP_BALANCE ||
        fs_info->exclusive_operation == BTRFS_EXCLOP_DEV_ADD,
        in fs/btrfs/ioctl.c:456
        Call Trace:
         <TASK>
         btrfs_exclop_balance+0x13c/0x310
         ? memdup_user+0xab/0xc0
         ? PTR_ERR+0x17/0x20
         btrfs_ioctl_add_dev+0x2ee/0x320
         btrfs_ioctl+0x9d5/0x10d0
         ? btrfs_ioctl_encoded_write+0xb80/0xb80
         __x64_sys_ioctl+0x197/0x210
         do_syscall_64+0x3c/0xb0
         entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Scenario 2: With exclusive_operation state == BTRFS_EXCLOP_BALANCE_PAUSED.
      
      Concurrently adding multiple devices to the same mount point and
      btrfs_exclop_balance executed finish before the latter thread execute
      assertion in btrfs_exclop_balance, exclusive_operation will changed to
      BTRFS_EXCLOP_BALANCE_PAUSED state which lead to assertion failed:
      
        fs_info->exclusive_operation == BTRFS_EXCLOP_BALANCE ||
        fs_info->exclusive_operation == BTRFS_EXCLOP_DEV_ADD ||
        fs_info->exclusive_operation == BTRFS_EXCLOP_NONE,
        fs/btrfs/ioctl.c:458
        Call Trace:
         <TASK>
         btrfs_exclop_balance+0x240/0x410
         ? memdup_user+0xab/0xc0
         ? PTR_ERR+0x17/0x20
         btrfs_ioctl_add_dev+0x2ee/0x320
         btrfs_ioctl+0x9d5/0x10d0
         ? btrfs_ioctl_encoded_write+0xb80/0xb80
         __x64_sys_ioctl+0x197/0x210
         do_syscall_64+0x3c/0xb0
         entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      An example of the failed assertion is below, which shows that the
      paused balance is also needed to be checked.
      
        root@syzkaller:/home/xsk# ./repro
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        [  416.611428][ T7970] BTRFS info (device loop0): fs_info exclusive_operation: 0
        Failed to add device /dev/vda, errno 14
        [  416.613973][ T7971] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.615456][ T7972] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.617528][ T7973] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.618359][ T7974] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.622589][ T7975] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.624034][ T7976] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.626420][ T7977] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.627643][ T7978] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.629006][ T7979] BTRFS info (device loop0): fs_info exclusive_operation: 3
        [  416.630298][ T7980] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        Failed to add device /dev/vda, errno 14
        [  416.632787][ T7981] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.634282][ T7982] BTRFS info (device loop0): fs_info exclusive_operation: 3
        Failed to add device /dev/vda, errno 14
        [  416.636202][ T7983] BTRFS info (device loop0): fs_info exclusive_operation: 3
        [  416.637012][ T7984] BTRFS info (device loop0): fs_info exclusive_operation: 1
        Failed to add device /dev/vda, errno 14
        [  416.637759][ T7984] assertion failed: fs_info->exclusive_operation ==
        BTRFS_EXCLOP_BALANCE || fs_info->exclusive_operation ==
        BTRFS_EXCLOP_DEV_ADD || fs_info->exclusive_operation ==
        BTRFS_EXCLOP_NONE, in fs/btrfs/ioctl.c:458
        [  416.639845][ T7984] invalid opcode: 0000 [#1] PREEMPT SMP KASAN
        [  416.640485][ T7984] CPU: 0 PID: 7984 Comm: repro Not tainted 6.2.0 #7
        [  416.641172][ T7984] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014
        [  416.642090][ T7984] RIP: 0010:btrfs_assertfail+0x2c/0x2e
        [  416.644423][ T7984] RSP: 0018:ffffc90003ea7e28 EFLAGS: 00010282
        [  416.645018][ T7984] RAX: 00000000000000cc RBX: 0000000000000000 RCX: 0000000000000000
        [  416.645763][ T7984] RDX: ffff88801d030000 RSI: ffffffff81637e7c RDI: fffff520007d4fb7
        [  416.646554][ T7984] RBP: ffffffff8a533de0 R08: 00000000000000cc R09: 0000000000000000
        [  416.647299][ T7984] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff8a533da0
        [  416.648041][ T7984] R13: 00000000000001ca R14: 000000005000940a R15: 0000000000000000
        [  416.648785][ T7984] FS:  00007fa2985d4640(0000) GS:ffff88802cc00000(0000) knlGS:0000000000000000
        [  416.649616][ T7984] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [  416.650238][ T7984] CR2: 0000000000000000 CR3: 0000000018e5e000 CR4: 0000000000750ef0
        [  416.650980][ T7984] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [  416.651725][ T7984] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
        [  416.652502][ T7984] PKRU: 55555554
        [  416.652888][ T7984] Call Trace:
        [  416.653241][ T7984]  <TASK>
        [  416.653527][ T7984]  btrfs_exclop_balance+0x240/0x410
        [  416.654036][ T7984]  ? memdup_user+0xab/0xc0
        [  416.654465][ T7984]  ? PTR_ERR+0x17/0x20
        [  416.654874][ T7984]  btrfs_ioctl_add_dev+0x2ee/0x320
        [  416.655380][ T7984]  btrfs_ioctl+0x9d5/0x10d0
        [  416.655822][ T7984]  ? btrfs_ioctl_encoded_write+0xb80/0xb80
        [  416.656400][ T7984]  __x64_sys_ioctl+0x197/0x210
        [  416.656874][ T7984]  do_syscall_64+0x3c/0xb0
        [  416.657346][ T7984]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
        [  416.657922][ T7984] RIP: 0033:0x4546af
        [  416.660170][ T7984] RSP: 002b:00007fa2985d4150 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
        [  416.660972][ T7984] RAX: ffffffffffffffda RBX: 00007fa2985d4640 RCX: 00000000004546af
        [  416.661714][ T7984] RDX: 0000000000000000 RSI: 000000005000940a RDI: 0000000000000003
        [  416.662449][ T7984] RBP: 00007fa2985d41d0 R08: 0000000000000000 R09: 00007ffee37a4c4f
        [  416.663195][ T7984] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fa2985d4640
        [  416.663951][ T7984] R13: 0000000000000009 R14: 000000000041b320 R15: 00007fa297dd4000
        [  416.664703][ T7984]  </TASK>
        [  416.665040][ T7984] Modules linked in:
        [  416.665590][ T7984] ---[ end trace 0000000000000000 ]---
        [  416.666176][ T7984] RIP: 0010:btrfs_assertfail+0x2c/0x2e
        [  416.668775][ T7984] RSP: 0018:ffffc90003ea7e28 EFLAGS: 00010282
        [  416.669425][ T7984] RAX: 00000000000000cc RBX: 0000000000000000 RCX: 0000000000000000
        [  416.670235][ T7984] RDX: ffff88801d030000 RSI: ffffffff81637e7c RDI: fffff520007d4fb7
        [  416.671050][ T7984] RBP: ffffffff8a533de0 R08: 00000000000000cc R09: 0000000000000000
        [  416.671867][ T7984] R10: 0000000000000001 R11: 0000000000000001 R12: ffffffff8a533da0
        [  416.672685][ T7984] R13: 00000000000001ca R14: 000000005000940a R15: 0000000000000000
        [  416.673501][ T7984] FS:  00007fa2985d4640(0000) GS:ffff88802cc00000(0000) knlGS:0000000000000000
        [  416.674425][ T7984] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        [  416.675114][ T7984] CR2: 0000000000000000 CR3: 0000000018e5e000 CR4: 0000000000750ef0
        [  416.675933][ T7984] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        [  416.676760][ T7984] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      
      Link: https://lore.kernel.org/linux-btrfs/20230324031611.98986-1-xiaoshoukui@gmail.com/
      CC: stable@vger.kernel.org # 6.1+
      Signed-off-by: default avatarxiaoshoukui <xiaoshoukui@ruijie.com.cn>
      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>
      17eaeee4
    • Qu Wenruo's avatar
      btrfs: properly reject clear_cache and v1 cache for block-group-tree · 0a99cd08
      Qu Wenruo authored
      commit 64b5d5b2
      
       upstream.
      
      [BUG]
      With block-group-tree feature enabled, mounting it with clear_cache
      would cause the following transaction abort at mount or remount:
      
        BTRFS info (device dm-4): force clearing of disk cache
        BTRFS info (device dm-4): using free space tree
        BTRFS info (device dm-4): auto enabling async discard
        BTRFS info (device dm-4): clearing free space tree
        BTRFS info (device dm-4): clearing compat-ro feature flag for FREE_SPACE_TREE (0x1)
        BTRFS info (device dm-4): clearing compat-ro feature flag for FREE_SPACE_TREE_VALID (0x2)
        BTRFS error (device dm-4): block-group-tree feature requires fres-space-tree and no-holes
        BTRFS error (device dm-4): super block corruption detected before writing it to disk
        BTRFS: error (device dm-4) in write_all_supers:4288: errno=-117 Filesystem corrupted (unexpected superblock corruption detected)
        BTRFS warning (device dm-4: state E): Skipping commit of aborted transaction.
      
      [CAUSE]
      For block-group-tree feature, we have an artificial dependency on
      free-space-tree.
      
      This means if we detect block-group-tree without v2 cache, we consider
      it a corruption and cause the problem.
      
      For clear_cache mount option, it would temporary disable v2 cache, then
      re-enable it.
      
      But unfortunately for that temporary v2 cache disabled status, we refuse
      to write a superblock with bg tree only flag, thus leads to the above
      transaction abortion.
      
      [FIX]
      For now, just reject clear_cache and v1 cache mount option for block
      group tree.  So now we got a graceful rejection other than a transaction
      abort:
      
        BTRFS info (device dm-4): force clearing of disk cache
        BTRFS error (device dm-4): cannot disable free space tree with block-group-tree feature
        BTRFS error (device dm-4): open_ctree failed
      
      CC: stable@vger.kernel.org # 6.1+
      Signed-off-by: default avatarQu Wenruo <wqu@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>
      0a99cd08
    • Naohiro Aota's avatar
      btrfs: zoned: fix wrong use of bitops API in btrfs_ensure_empty_zones · 8583cc10
      Naohiro Aota authored
      commit 631003e2 upstream.
      
      find_next_bit and find_next_zero_bit take @size as the second parameter and
      @offset as the third parameter. They are specified opposite in
      btrfs_ensure_empty_zones(). Thanks to the later loop, it never failed to
      detect the empty zones. Fix them and (maybe) return the result a bit
      faster.
      
      Note: the naming is a bit confusing, size has two meanings here, bitmap
      and our range size.
      
      Fixes: 1cd6121f
      
       ("btrfs: zoned: implement zoned chunk allocator")
      CC: stable@vger.kernel.org # 5.15+
      Signed-off-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
      Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8583cc10
    • Filipe Manana's avatar
      btrfs: fix btrfs_prev_leaf() to not return the same key twice · bcd7aa29
      Filipe Manana authored
      commit 6f932d4e
      
       upstream.
      
      A call to btrfs_prev_leaf() may end up returning a path that points to the
      same item (key) again. This happens if while btrfs_prev_leaf(), after we
      release the path, a concurrent insertion happens, which moves items off
      from a sibling into the front of the previous leaf, and an item with the
      computed previous key does not exists.
      
      For example, suppose we have the two following leaves:
      
        Leaf A
      
        -------------------------------------------------------------
        | ...   key (300 96 10)   key (300 96 15)   key (300 96 16) |
        -------------------------------------------------------------
                    slot 20             slot 21             slot 22
      
        Leaf B
      
        -------------------------------------------------------------
        | key (300 96 20)   key (300 96 21)   key (300 96 22)   ... |
        -------------------------------------------------------------
            slot 0             slot 1             slot 2
      
      If we call btrfs_prev_leaf(), from btrfs_previous_item() for example, with
      a path pointing to leaf B and slot 0 and the following happens:
      
      1) At btrfs_prev_leaf() we compute the previous key to search as:
         (300 96 19), which is a key that does not exists in the tree;
      
      2) Then we call btrfs_release_path() at btrfs_prev_leaf();
      
      3) Some other task inserts a key at leaf A, that sorts before the key at
         slot 20, for example it has an objectid of 299. In order to make room
         for the new key, the key at slot 22 is moved to the front of leaf B.
         This happens at push_leaf_right(), called from split_leaf().
      
         After this leaf B now looks like:
      
        --------------------------------------------------------------------------------
        | key (300 96 16)    key (300 96 20)   key (300 96 21)   key (300 96 22)   ... |
        --------------------------------------------------------------------------------
             slot 0              slot 1             slot 2             slot 3
      
      4) At btrfs_prev_leaf() we call btrfs_search_slot() for the computed
         previous key: (300 96 19). Since the key does not exists,
         btrfs_search_slot() returns 1 and with a path pointing to leaf B
         and slot 1, the item with key (300 96 20);
      
      5) This makes btrfs_prev_leaf() return a path that points to slot 1 of
         leaf B, the same key as before it was called, since the key at slot 0
         of leaf B (300 96 16) is less than the computed previous key, which is
         (300 96 19);
      
      6) As a consequence btrfs_previous_item() returns a path that points again
         to the item with key (300 96 20).
      
      For some users of btrfs_prev_leaf() or btrfs_previous_item() this may not
      be functional a problem, despite not making sense to return a new path
      pointing again to the same item/key. However for a caller such as
      tree-log.c:log_dir_items(), this has a bad consequence, as it can result
      in not logging some dir index deletions in case the directory is being
      logged without holding the inode's VFS lock (logging triggered while
      logging a child inode for example) - for the example scenario above, in
      case the dir index keys 17, 18 and 19 were deleted in the current
      transaction.
      
      CC: stable@vger.kernel.org # 4.14+
      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 avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      bcd7aa29
    • Borislav Petkov (AMD)'s avatar
      x86/retbleed: Fix return thunk alignment · 000322b2
      Borislav Petkov (AMD) authored
      commit 9a48d604
      
       upstream.
      
      SYM_FUNC_START_LOCAL_NOALIGN() adds an endbr leading to this layout
      (leaving only the last 2 bytes of the address):
      
        3bff <zen_untrain_ret>:
        3bff:       f3 0f 1e fa             endbr64
        3c03:       f6                      test   $0xcc,%bl
      
        3c04 <__x86_return_thunk>:
        3c04:       c3                      ret
        3c05:       cc                      int3
        3c06:       0f ae e8                lfence
      
      However, "the RET at __x86_return_thunk must be on a 64 byte boundary,
      for alignment within the BTB."
      
      Use SYM_START instead.
      
      Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
      Reviewed-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: <stable@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      000322b2