From: Mateusz Guzik <mjguzik(a)gmail.com>
[ Upstream commit f381640e1bd4f2de7ccafbfe8703d33c3718aad9 ]
... except when the table is known to be only used by one thread.
A file pointer can get installed at any moment despite the ->file_lock
being held since the following:
8a81252b774b53e6 ("fs/file.c: don't acquire files->file_lock in fd_install()")
Accesses subject to such a race can in principle suffer load tearing.
While here redo the comment in dup_fd -- it only covered a race against
files showing up, still assuming fd_install() takes the lock.
Signed-off-by: Mateusz Guzik <mjguzik(a)gmail.com>
Link: https://lore.kernel.org/r/20250313135725.1320914-1-mjguzik@gmail.com
Signed-off-by: Christian Brauner <brauner(a)kernel.org>
Signed-off-by: Sasha Levin <sashal(a)kernel.org>
---
fs/file.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/fs/file.c b/fs/file.c
index d868cdb95d1e7..1ba03662ae66f 100644
--- a/fs/file.c
+++ b/fs/file.c
@@ -418,17 +418,25 @@ struct files_struct *dup_fd(struct files_struct *oldf, struct fd_range *punch_ho
old_fds = old_fdt->fd;
new_fds = new_fdt->fd;
+ /*
+ * We may be racing against fd allocation from other threads using this
+ * files_struct, despite holding ->file_lock.
+ *
+ * alloc_fd() might have already claimed a slot, while fd_install()
+ * did not populate it yet. Note the latter operates locklessly, so
+ * the file can show up as we are walking the array below.
+ *
+ * At the same time we know no files will disappear as all other
+ * operations take the lock.
+ *
+ * Instead of trying to placate userspace racing with itself, we
+ * ref the file if we see it and mark the fd slot as unused otherwise.
+ */
for (i = open_files; i != 0; i--) {
- struct file *f = *old_fds++;
+ struct file *f = rcu_dereference_raw(*old_fds++);
if (f) {
get_file(f);
} else {
- /*
- * The fd may be claimed in the fd bitmap but not yet
- * instantiated in the files array if a sibling thread
- * is partway through open(). So make sure that this
- * fd is available to the new process.
- */
__clear_open_fd(open_files - i, new_fdt);
}
rcu_assign_pointer(*new_fds++, f);
@@ -679,7 +687,7 @@ struct file *file_close_fd_locked(struct files_struct *files, unsigned fd)
return NULL;
fd = array_index_nospec(fd, fdt->max_fds);
- file = fdt->fd[fd];
+ file = rcu_dereference_raw(fdt->fd[fd]);
if (file) {
rcu_assign_pointer(fdt->fd[fd], NULL);
__put_unused_fd(files, fd);
@@ -1237,7 +1245,7 @@ __releases(&files->file_lock)
*/
fdt = files_fdtable(files);
fd = array_index_nospec(fd, fdt->max_fds);
- tofree = fdt->fd[fd];
+ tofree = rcu_dereference_raw(fdt->fd[fd]);
if (!tofree && fd_is_open(fd, fdt))
goto Ebusy;
get_file(file);
--
2.39.5
From: Jacek Lawrynowicz <jacek.lawrynowicz(a)linux.intel.com>
Warn if device is suspended only when runtime PM is enabled.
Runtime PM is disabled during reset/recovery and it is not an error
to use ivpu_ipc_send_receive_internal() in such cases.
Fixes: 5eaa49741119 ("accel/ivpu: Prevent recovery invocation during probe and resume")
Cc: <stable(a)vger.kernel.org> # v6.13+
Signed-off-by: Jacek Lawrynowicz <jacek.lawrynowicz(a)linux.intel.com>
Signed-off-by: Maciej Falkowski <maciej.falkowski(a)linux.intel.com>
---
drivers/accel/ivpu/ivpu_ipc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/accel/ivpu/ivpu_ipc.c b/drivers/accel/ivpu/ivpu_ipc.c
index 0e096fd9b95d..39f83225c181 100644
--- a/drivers/accel/ivpu/ivpu_ipc.c
+++ b/drivers/accel/ivpu/ivpu_ipc.c
@@ -302,7 +302,8 @@ ivpu_ipc_send_receive_internal(struct ivpu_device *vdev, struct vpu_jsm_msg *req
struct ivpu_ipc_consumer cons;
int ret;
- drm_WARN_ON(&vdev->drm, pm_runtime_status_suspended(vdev->drm.dev));
+ drm_WARN_ON(&vdev->drm, pm_runtime_status_suspended(vdev->drm.dev) &&
+ pm_runtime_enabled(vdev->drm.dev));
ivpu_ipc_consumer_add(vdev, &cons, channel, NULL);
--
2.43.0
This is the start of the stable review cycle for the 6.6.85 release.
There are 75 patches in this series, all will be posted as a response
to this one. If anyone has any issues with these being applied, please
let me know.
Responses should be made by Sun, 30 Mar 2025 14:49:59 +0000.
Anything received after that time might be too late.
The whole patch series can be found in one patch at:
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.6.85-rc3…
or in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git linux-6.6.y
and the diffstat can be found below.
thanks,
greg k-h
-------------
Pseudo-Shortlog of commits:
Greg Kroah-Hartman <gregkh(a)linuxfoundation.org>
Linux 6.6.85-rc3
Sebastian Andrzej Siewior <bigeasy(a)linutronix.de>
netfilter: nft_counter: Use u64_stats_t for statistic.
Benjamin Berg <benjamin.berg(a)intel.com>
wifi: iwlwifi: mvm: ensure offloading TID queue exists
Miri Korenblit <miriam.rachel.korenblit(a)intel.com>
wifi: iwlwifi: support BIOS override for 5G9 in CA also in LARI version 8
Shravya KN <shravya.k-n(a)broadcom.com>
bnxt_en: Fix receive ring space parameters when XDP is active
Josef Bacik <josef(a)toxicpanda.com>
btrfs: make sure that WRITTEN is set on all metadata blocks
Dietmar Eggemann <dietmar.eggemann(a)arm.com>
Revert "sched/core: Reduce cost of sched_move_task when config autogroup"
Justin Klaassen <justin(a)tidylabs.net>
arm64: dts: rockchip: fix u2phy1_host status for NanoPi R4S
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Eagerly switch ZCR_EL{1,2}
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Mark some header functions as inline
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Refactor exit handlers
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Remove VHE host restore of CPACR_EL1.SMEN
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Remove VHE host restore of CPACR_EL1.ZEN
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Remove host FPSIMD saving for non-protected KVM
Mark Rutland <mark.rutland(a)arm.com>
KVM: arm64: Unconditionally save+flush host FPSIMD/SVE/SME state
Fuad Tabba <tabba(a)google.com>
KVM: arm64: Calculate cptr_el2 traps on activating traps
Arthur Mongodin <amongodin(a)randorisec.fr>
mptcp: Fix data stream corruption in the address announcement
Namjae Jeon <linkinjeon(a)kernel.org>
ksmbd: fix incorrect validation for num_aces field of smb_acl
Mario Limonciello <mario.limonciello(a)amd.com>
drm/amd/display: Use HW lock mgr for PSR1 when only one eDP
Martin Tsai <martin.tsai(a)amd.com>
drm/amd/display: should support dmub hw lock on Replay
David Rosca <david.rosca(a)amd.com>
drm/amdgpu: Fix JPEG video caps max size for navi1x and raven
David Rosca <david.rosca(a)amd.com>
drm/amdgpu: Fix MPEG2, MPEG4 and VC1 video caps max size
qianyi liu <liuqianyi125(a)gmail.com>
drm/sched: Fix fence reference count leak
Nikita Zhandarovich <n.zhandarovich(a)fintech.ru>
drm/radeon: fix uninitialized size issue in radeon_vce_cs_parse()
Saranya R <quic_sarar(a)quicinc.com>
soc: qcom: pdr: Fix the potential deadlock
Sven Eckelmann <sven(a)narfation.org>
batman-adv: Ignore own maximum aggregation size during RX
Gavrilov Ilia <Ilia.Gavrilov(a)infotecs.ru>
xsk: fix an integer overflow in xp_create_and_assign_umem()
Ard Biesheuvel <ardb(a)kernel.org>
efi/libstub: Avoid physical address 0x0 when doing random allocation
Geert Uytterhoeven <geert+renesas(a)glider.be>
ARM: shmobile: smp: Enforce shmobile_smp_* alignment
Stefan Eichenberger <stefan.eichenberger(a)toradex.com>
ARM: dts: imx6qdl-apalis: Fix poweroff on Apalis iMX6
Ye Bin <yebin10(a)huawei.com>
proc: fix UAF in proc_get_inode()
Zi Yan <ziy(a)nvidia.com>
mm/migrate: fix shmem xarray update during migration
Raphael S. Carvalho <raphaelsc(a)scylladb.com>
mm: fix error handling in __filemap_get_folio() with FGP_NOWAIT
Gu Bowen <gubowen5(a)huawei.com>
mmc: atmel-mci: Add missing clk_disable_unprepare()
Kamal Dasu <kamal.dasu(a)broadcom.com>
mmc: sdhci-brcmstb: add cqhci suspend/resume to PM ops
Quentin Schulz <quentin.schulz(a)cherry.de>
arm64: dts: rockchip: fix pinmux of UART0 for PX30 Ringneck on Haikou
Stefan Eichenberger <stefan.eichenberger(a)toradex.com>
arm64: dts: freescale: imx8mm-verdin-dahlia: add Microphone Jack to sound card
Stefan Eichenberger <stefan.eichenberger(a)toradex.com>
arm64: dts: freescale: imx8mp-verdin-dahlia: add Microphone Jack to sound card
Dan Carpenter <dan.carpenter(a)linaro.org>
accel/qaic: Fix integer overflow in qaic_validate_req()
Christian Eggers <ceggers(a)arri.de>
regulator: check that dummy regulator has been probed before using it
Christian Eggers <ceggers(a)arri.de>
regulator: dummy: force synchronous probing
E Shattow <e(a)freeshell.de>
riscv: dts: starfive: Fix a typo in StarFive JH7110 pin function definitions
Maíra Canal <mcanal(a)igalia.com>
drm/v3d: Don't run jobs that have errors flagged in its fence
Haibo Chen <haibo.chen(a)nxp.com>
can: flexcan: disable transceiver during system PM
Haibo Chen <haibo.chen(a)nxp.com>
can: flexcan: only change CAN state when link up in system PM
Vincent Mailhol <mailhol.vincent(a)wanadoo.fr>
can: ucan: fix out of bound read in strscpy() source
Biju Das <biju.das.jz(a)bp.renesas.com>
can: rcar_canfd: Fix page entries in the AFL list
Andreas Kemnade <andreas(a)kemnade.info>
i2c: omap: fix IRQ storms
Guillaume Nault <gnault(a)redhat.com>
Revert "gre: Fix IPv6 link-local address generation."
Lin Ma <linma(a)zju.edu.cn>
net/neighbor: add missing policy for NDTPA_QUEUE_LENBYTES
Justin Iurman <justin.iurman(a)uliege.be>
net: lwtunnel: fix recursion loops
Dan Carpenter <dan.carpenter(a)linaro.org>
net: atm: fix use after free in lec_send()
Kuniyuki Iwashima <kuniyu(a)amazon.com>
ipv6: Set errno after ip_fib_metrics_init() in ip6_route_info_create().
Kuniyuki Iwashima <kuniyu(a)amazon.com>
ipv6: Fix memleak of nhc_pcpu_rth_output in fib_check_nh_v6_gw().
David Lechner <dlechner(a)baylibre.com>
ARM: davinci: da850: fix selecting ARCH_DAVINCI_DA8XX
Jeffrey Hugo <quic_jhugo(a)quicinc.com>
accel/qaic: Fix possible data corruption in BOs > 2G
Arkadiusz Bokowy <arkadiusz.bokowy(a)gmail.com>
Bluetooth: hci_event: Fix connection regression between LE and non-LE adapters
Dan Carpenter <dan.carpenter(a)linaro.org>
Bluetooth: Fix error code in chan_alloc_skb_cb()
Junxian Huang <huangjunxian6(a)hisilicon.com>
RDMA/hns: Fix wrong value of max_sge_rd
Junxian Huang <huangjunxian6(a)hisilicon.com>
RDMA/hns: Fix a missing rollback in error path of hns_roce_create_qp_common()
Junxian Huang <huangjunxian6(a)hisilicon.com>
RDMA/hns: Fix unmatched condition in error path of alloc_user_qp_db()
Junxian Huang <huangjunxian6(a)hisilicon.com>
RDMA/hns: Fix soft lockup during bt pages loop
Saravanan Vajravel <saravanan.vajravel(a)broadcom.com>
RDMA/bnxt_re: Avoid clearing VLAN_ID mask in modify qp path
Phil Elwell <phil(a)raspberrypi.com>
ARM: dts: bcm2711: Don't mark timer regs unconfigured
Arnd Bergmann <arnd(a)arndb.de>
ARM: OMAP1: select CONFIG_GENERIC_IRQ_CHIP
Qasim Ijaz <qasdev00(a)gmail.com>
RDMA/mlx5: Handle errors returned from mlx5r_ib_rate()
Kashyap Desai <kashyap.desai(a)broadcom.com>
RDMA/bnxt_re: Add missing paranthesis in map_qp_id_to_tbl_indx
Yao Zi <ziyao(a)disroot.org>
arm64: dts: rockchip: Remove undocumented sdmmc property from lubancat-1
Phil Elwell <phil(a)raspberrypi.com>
ARM: dts: bcm2711: PL011 UARTs are actually r1p5
Peng Fan <peng.fan(a)nxp.com>
soc: imx8m: Unregister cpufreq and soc dev in cleanup path
Marek Vasut <marex(a)denx.de>
soc: imx8m: Use devm_* to simplify probe failure handling
Marek Vasut <marex(a)denx.de>
soc: imx8m: Remove global soc_uid
Cosmin Ratiu <cratiu(a)nvidia.com>
xfrm_output: Force software GSO only in tunnel mode
Alexandre Cassen <acassen(a)corp.free.fr>
xfrm: fix tunnel mode TX datapath in packet offload mode
Alexander Stein <alexander.stein(a)ew.tq-group.com>
arm64: dts: freescale: tqma8mpql: Fix vqmmc-supply
Joe Hattori <joe(a)pf.is.s.u-tokyo.ac.jp>
firmware: imx-scu: fix OF node leak in .probe()
-------------
Diffstat:
Makefile | 4 +-
arch/arm/boot/dts/broadcom/bcm2711.dtsi | 11 +-
arch/arm/boot/dts/nxp/imx/imx6qdl-apalis.dtsi | 10 +-
arch/arm/mach-davinci/Kconfig | 1 +
arch/arm/mach-omap1/Kconfig | 1 +
arch/arm/mach-shmobile/headsmp.S | 1 +
.../boot/dts/freescale/imx8mm-verdin-dahlia.dtsi | 6 +-
.../arm64/boot/dts/freescale/imx8mp-tqma8mpql.dtsi | 16 +--
.../boot/dts/freescale/imx8mp-verdin-dahlia.dtsi | 6 +-
.../boot/dts/rockchip/px30-ringneck-haikou.dts | 2 +
arch/arm64/boot/dts/rockchip/rk3399-nanopi-r4s.dts | 2 +-
arch/arm64/boot/dts/rockchip/rk3566-lubancat-1.dts | 1 -
arch/arm64/include/asm/kvm_host.h | 7 +-
arch/arm64/include/asm/kvm_hyp.h | 1 +
arch/arm64/kernel/fpsimd.c | 25 ----
arch/arm64/kvm/arm.c | 1 -
arch/arm64/kvm/fpsimd.c | 89 +++---------
arch/arm64/kvm/hyp/entry.S | 5 +
arch/arm64/kvm/hyp/include/hyp/switch.h | 106 ++++++++++-----
arch/arm64/kvm/hyp/nvhe/hyp-main.c | 15 +-
arch/arm64/kvm/hyp/nvhe/pkvm.c | 29 +---
arch/arm64/kvm/hyp/nvhe/switch.c | 112 ++++++++++-----
arch/arm64/kvm/hyp/vhe/switch.c | 13 +-
arch/arm64/kvm/reset.c | 3 +
arch/riscv/boot/dts/starfive/jh7110-pinfunc.h | 2 +-
drivers/accel/qaic/qaic_data.c | 9 +-
drivers/firmware/efi/libstub/randomalloc.c | 4 +
drivers/firmware/imx/imx-scu.c | 1 +
drivers/gpu/drm/amd/amdgpu/nv.c | 20 +--
drivers/gpu/drm/amd/amdgpu/soc15.c | 20 +--
drivers/gpu/drm/amd/amdgpu/vi.c | 36 ++---
.../gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c | 15 ++
drivers/gpu/drm/radeon/radeon_vce.c | 2 +-
drivers/gpu/drm/scheduler/sched_entity.c | 11 +-
drivers/gpu/drm/v3d/v3d_sched.c | 9 +-
drivers/i2c/busses/i2c-omap.c | 26 +---
drivers/infiniband/hw/bnxt_re/qplib_fp.c | 2 -
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h | 3 +-
drivers/infiniband/hw/hns/hns_roce_hem.c | 16 ++-
drivers/infiniband/hw/hns/hns_roce_main.c | 2 +-
drivers/infiniband/hw/hns/hns_roce_qp.c | 10 +-
drivers/infiniband/hw/mlx5/ah.c | 14 +-
drivers/mmc/host/atmel-mci.c | 4 +-
drivers/mmc/host/sdhci-brcmstb.c | 10 ++
drivers/net/can/flexcan/flexcan-core.c | 18 ++-
drivers/net/can/rcar/rcar_canfd.c | 28 ++--
drivers/net/can/usb/ucan.c | 43 +++---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 +-
drivers/net/wireless/intel/iwlwifi/fw/file.h | 4 +-
drivers/net/wireless/intel/iwlwifi/mvm/d3.c | 9 +-
drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 37 ++++-
drivers/net/wireless/intel/iwlwifi/mvm/sta.c | 28 ++++
drivers/net/wireless/intel/iwlwifi/mvm/sta.h | 3 +-
drivers/regulator/core.c | 12 +-
drivers/regulator/dummy.c | 2 +-
drivers/soc/imx/soc-imx8m.c | 151 ++++++++++-----------
drivers/soc/qcom/pdr_interface.c | 8 +-
fs/btrfs/tree-checker.c | 30 ++--
fs/btrfs/tree-checker.h | 1 +
fs/proc/generic.c | 10 +-
fs/proc/inode.c | 6 +-
fs/proc/internal.h | 14 ++
fs/smb/server/smbacl.c | 5 +-
include/linux/proc_fs.h | 7 +-
include/net/bluetooth/hci.h | 2 +-
kernel/sched/core.c | 22 +--
mm/filemap.c | 13 +-
mm/migrate.c | 10 +-
net/atm/lec.c | 3 +-
net/batman-adv/bat_iv_ogm.c | 3 +-
net/batman-adv/bat_v_ogm.c | 3 +-
net/bluetooth/6lowpan.c | 7 +-
net/core/lwtunnel.c | 65 +++++++--
net/core/neighbour.c | 1 +
net/ipv6/addrconf.c | 15 +-
net/ipv6/route.c | 5 +-
net/mptcp/options.c | 6 +-
net/netfilter/nft_counter.c | 90 ++++++------
net/xdp/xsk_buff_pool.c | 2 +-
net/xfrm/xfrm_output.c | 43 +++++-
80 files changed, 799 insertions(+), 600 deletions(-)
The I3C master driver may receive an IBI from a target device that has not
been probed yet. In such cases, the master calls `i3c_master_queue_ibi()`
to queue an IBI work task, leading to "Unable to handle kernel read from
unreadable memory" and resulting in a kernel panic.
Typical IBI handling flow:
1. The I3C master scans target devices and probes their respective drivers.
2. The target device driver calls `i3c_device_request_ibi()` to enable IBI
and assigns `dev->ibi = ibi`.
3. The I3C master receives an IBI from the target device and calls
`i3c_master_queue_ibi()` to queue the target device driver’s IBI
handler task.
However, since target device events are asynchronous to the I3C probe
sequence, step 3 may occur before step 2, causing `dev->ibi` to be `NULL`,
leading to a kernel panic.
Add a NULL pointer check in `i3c_master_queue_ibi()` to prevent accessing
an uninitialized `dev->ibi`, ensuring stability.
Fixes: 3a379bbcea0af ("i3c: Add core I3C infrastructure")
Cc: stable(a)vger.kernel.org
Link: https://lore.kernel.org/lkml/Z9gjGYudiYyl3bSe@lizhi-Precision-Tower-5810/
Signed-off-by: Manjunatha Venkatesh <manjunatha.venkatesh(a)nxp.com>
---
Changes since v5:
- Updated subject and commit message with some more information.
drivers/i3c/master.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
index d5dc4180afbc..c65006aa0684 100644
--- a/drivers/i3c/master.c
+++ b/drivers/i3c/master.c
@@ -2561,6 +2561,9 @@ static void i3c_master_unregister_i3c_devs(struct i3c_master_controller *master)
*/
void i3c_master_queue_ibi(struct i3c_dev_desc *dev, struct i3c_ibi_slot *slot)
{
+ if (!dev->ibi || !slot)
+ return;
+
atomic_inc(&dev->ibi->pending_ibis);
queue_work(dev->ibi->wq, &slot->work);
}
--
2.46.1
Once cdev_device_add() failed, we should use put_device() to decrement
reference count for cleanup. Or it could cause memory leak. Although
operations in err_free_ida are similar to the operations in callback
function fsi_slave_release(), put_device() is a correct handling
operation as comments require when cdev_device_add() fails.
As comment of device_add() says, 'if device_add() succeeds, you should
call device_del() when you want to get rid of it. If device_add() has
not succeeded, use only put_device() to drop the reference count'.
Found by code review.
Cc: stable(a)vger.kernel.org
Fixes: 371975b0b075 ("fsi/core: Fix error paths on CFAM init")
Signed-off-by: Ma Ke <make24(a)iscas.ac.cn>
---
drivers/fsi/fsi-core.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index e2e1e9df6115..1373e05e3659 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -1084,7 +1084,8 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
rc = cdev_device_add(&slave->cdev, &slave->dev);
if (rc) {
dev_err(&slave->dev, "Error %d creating slave device\n", rc);
- goto err_free_ida;
+ put_device(&slave->dev);
+ return rc;
}
/* Now that we have the cdev registered with the core, any fatal
@@ -1110,8 +1111,6 @@ static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id)
return 0;
-err_free_ida:
- fsi_free_minor(slave->dev.devt);
err_free:
of_node_put(slave->dev.of_node);
kfree(slave);
--
2.25.1
The echo_interval is not limited in any way during mounting,
which makes it possible to write a large number to it. This can
cause an overflow when multiplying ctx->echo_interval by HZ in
match_server().
Add constraints for echo_interval to smb3_fs_context_parse_param().
Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes: adfeb3e00e8e1 ("cifs: Make echo interval tunable")
Cc: stable(a)vger.kernel.org
Signed-off-by: Roman Smirnov <r.smirnov(a)omp.ru>
---
fs/smb/client/fs_context.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/fs/smb/client/fs_context.c b/fs/smb/client/fs_context.c
index 8c73d4d60d1a..e38521a713a6 100644
--- a/fs/smb/client/fs_context.c
+++ b/fs/smb/client/fs_context.c
@@ -1377,6 +1377,11 @@ static int smb3_fs_context_parse_param(struct fs_context *fc,
ctx->closetimeo = HZ * result.uint_32;
break;
case Opt_echo_interval:
+ if (result.uint_32 < SMB_ECHO_INTERVAL_MIN ||
+ result.uint_32 > SMB_ECHO_INTERVAL_MAX) {
+ cifs_errorf(fc, "echo interval is out of bounds\n");
+ goto cifs_parse_mount_err;
+ }
ctx->echo_interval = result.uint_32;
break;
case Opt_snapshot:
--
2.34.1
The call trace shows that the div error occurs on the following line where the code sets
the e_cpos member of the extent record while dividing bg_bits by the bits per
cluster value from the chain list:
rec->e_cpos = cpu_to_le32(le16_to_cpu(bg->bg_bits) /
le16_to_cpu(cl->cl_bpc));
Looking at the code disassembly we see the problem occurred during the divw instruction
which performs a 16-bit unsigned divide operation. The main ways a divide error can occur is
if:
1) the divisor is 0
2) if the quotient is too large for the designated register (overflow).
Normally the divisor being 0 is the most common cause for a division error to occur.
Focusing on the bits per cluster cl->cl_bpc (since it is the divisor) we see that cl is created in
ocfs2_block_group_alloc(), cl is derived from ocfs2_dinode->id2.i_chain. To fix this issue we should
verify the cl_bpc member in the chain list to ensure it is valid and non-zero.
Looking through the rest of the OCFS2 code it seems like there are other places which could benefit
from improved checks of the cl_bpc members of chain lists like the following:
In ocfs2_group_extend():
cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
ret = -EINVAL;
goto out_unlock;
}
Reported-by: syzbot <syzbot+e41e83af7a07a4df8051(a)syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=e41e83af7a07a4df8051
Cc: stable(a)vger.kernel.org
Signed-off-by: Qasim Ijaz <qasdev00(a)gmail.com>
---
fs/ocfs2/resize.c | 4 ++--
fs/ocfs2/suballoc.c | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/fs/ocfs2/resize.c b/fs/ocfs2/resize.c
index b0733c08ed13..22352c027ecd 100644
--- a/fs/ocfs2/resize.c
+++ b/fs/ocfs2/resize.c
@@ -329,8 +329,8 @@ int ocfs2_group_extend(struct inode * inode, int new_clusters)
group = (struct ocfs2_group_desc *)group_bh->b_data;
cl_bpc = le16_to_cpu(fe->id2.i_chain.cl_bpc);
- if (le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
- le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
+ if (!cl_bpc || le16_to_cpu(group->bg_bits) / cl_bpc + new_clusters >
+ le16_to_cpu(fe->id2.i_chain.cl_cpg)) {
ret = -EINVAL;
goto out_unlock;
}
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index f7b483f0de2a..844cb36bd7ab 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -671,6 +671,11 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode));
cl = &fe->id2.i_chain;
+ if (!le16_to_cpu(cl->cl_bpc)) {
+ status = -EINVAL;
+ goto bail;
+ }
+
status = ocfs2_reserve_clusters_with_limit(osb,
le16_to_cpu(cl->cl_cpg),
max_block, flags, &ac);
--
2.39.5
The threaded IRQ function in this driver is reading the flag twice: once to
lock a mutex and once to unlock it. Even though the code setting the flag
is designed to prevent it, there are subtle cases where the flag could be
true at the mutex_lock stage and false at the mutex_unlock stage. This
results in the mutex not being unlocked, resulting in a deadlock.
Fix it by making the opt3001_irq() code generally more robust, reading the
flag into a variable and using the variable value at both stages.
Fixes: 94a9b7b1809f ("iio: light: add support for TI's opt3001 light sensor")
Cc: stable(a)vger.kernel.org
Signed-off-by: Luca Ceresoli <luca.ceresoli(a)bootlin.com>
---
drivers/iio/light/opt3001.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index 65b295877b41588d40234ca7681bfee291e937c2..393a3d2fbe1d7320a243d3b6720e98b90f17baca 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -788,8 +788,9 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)
int ret;
bool wake_result_ready_queue = false;
enum iio_chan_type chan_type = opt->chip_info->chan_type;
+ bool ok_to_ignore_lock = opt->ok_to_ignore_lock;
- if (!opt->ok_to_ignore_lock)
+ if (!ok_to_ignore_lock)
mutex_lock(&opt->lock);
ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_CONFIGURATION);
@@ -826,7 +827,7 @@ static irqreturn_t opt3001_irq(int irq, void *_iio)
}
out:
- if (!opt->ok_to_ignore_lock)
+ if (!ok_to_ignore_lock)
mutex_unlock(&opt->lock);
if (wake_result_ready_queue)
---
base-commit: 250a4b882cf37d9719874253f055aad211f2c317
change-id: 20250321-opt3001-irq-fix-f7eecd4e2e9c
Best regards,
--
Luca Ceresoli <luca.ceresoli(a)bootlin.com>