6.18.3-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 123/430 drm/xe: Increase TDF timeout
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jagmeet Randhawa <[email protected]>
[ Upstream commit eafb6f62093f756535a7be1fc4559374a511e460 ]
There are some corner cases where flushing transient data may take slightly longer than the 150us timeout we currently allow. Update the driver to use a 300us timeout instead based on the latest guidance from the hardware team. An update to the bspec to formally document this is expected to arrive soon.
--- drivers/gpu/drm/xe/xe_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_device.c +1 -1
@@ -1046,7 +1046,7 @@ static void tdf_request_sync(struct xe_device *xe)* transient and need to be flushed.. */ if (xe_mmio_wait32 (>->mmio,XE2_TDF_CTRL ,TRANSIENT_FLUSH_REQUEST ,0 , -150 ,NULL , false)) +300 ,NULL , false))xe_gt_err_once (gt,"TD flush timeout\n" );xe_force_wake_put (gt_to_fw (gt), fw_ref);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 124/430 drm/xe: Restore engine registers before restarting schedulers after GT reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Maslak <[email protected]>
[ Upstream commit eed5b815fa49c17d513202f54e980eb91955d3ed ]
During GT reset recovery in do_gt_restart(), xe_uc_start() was called before xe_reg_sr_apply_mmio() restored engine-specific registers. This created a race window where the scheduler could run jobs before hardware state was fully restored.
This caused failures in eudebug tests (xe_exec_sip_eudebug@breakpoint- waitsip-*) where TD_CTL register (containing TD_CTL_GLOBAL_DEBUG_ENABLE) wasn't restored before jobs started executing. Breakpoints would fail to trigger SIP entry because the debug enable bit wasn't set yet.
Fix by moving xe_uc_start() after all MMIO register restoration, including engine registers and CCS mode configuration, ensuring all hardware state is fully restored before any jobs can be scheduled.
--- drivers/gpu/drm/xe/xe_gt.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_gt.c +4 -3
@@ -784,9 +784,6 @@ static int do_gt_restart(struct xe_gt *gt)xe_gt_sriov_pf_init_hw (gt);xe_mocs_init (gt); - err =xe_uc_start (>->uc); -if (err) -return err;for_each_hw_engine (hwe, gt, id)xe_reg_sr_apply_mmio (&hwe->reg_sr, gt);
@@ -794,6 +791,10 @@ static int do_gt_restart(struct xe_gt *gt)/* Get CCS mode in sync between sw/hw */ xe_gt_apply_ccs_mode (gt); + err =xe_uc_start (>->uc); +if (err) +return err; +/* Restore GT freq to expected values */ xe_gt_sanitize_freq (gt);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 125/430 MIPS: Fix a reference leak bug in ip22_check_gio()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haoxiang Li <[email protected]>
[ Upstream commit 680ad315caaa2860df411cb378bf3614d96c7648 ]
If gio_device_register fails, gio_dev_put() is required to drop the gio_dev device reference.
--- arch/mips/sgi-ip22/ip22-gio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/mips/sgi-ip22/ip22-gio.c +2 -1
@@ -372,7 +372,8 @@ static void ip22_check_gio(int slotno, unsigned long addr, int irq) gio_dev->resource.flags =IORESOURCE_MEM ; gio_dev->irq = irq;dev_set_name (&gio_dev->dev,"%d" , slotno); -gio_device_register (gio_dev); +if (gio_device_register (gio_dev)) +gio_dev_put (gio_dev); }else printk (KERN_INFO "GIO: slot %d : Empty\n" , slotno); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 126/430 drm/panel: sony-td4353-jdi: Enable prepare_prev_first
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marijn Suijten <[email protected]>
[ Upstream commit 2b973ca48ff3ef1952091c8f988d7796781836c8 ]
The DSI host must be enabled before our prepare function can run, which has to send its init sequence over DSI. Without enabling the host first the panel will not probe.
--- drivers/gpu/drm/panel/panel-sony-td4353-jdi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/panel/panel-sony-td4353-jdi.c +2 -0
@@ -212,6 +212,8 @@ static int sony_td4353_jdi_probe(struct mipi_dsi_device *dsi)if (ret)return dev_err_probe (dev, ret,"Failed to get backlight\n" ); + ctx->panel.prepare_prev_first = true; +drm_panel_add (&ctx->panel); ret =mipi_dsi_attach (dsi);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 127/430 x86/xen: Fix sparse warning in enlighten_pv.c
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Juergen Gross <[email protected]>
[ Upstream commit e5aff444e3a7bdeef5ea796a2099fc3c60a070fa ]
The sparse tool issues a warning for arch/x76/xen/enlighten_pv.c:
arch/x86/xen/enlighten_pv.c:120:9: sparse: sparse: incorrect type
in initializer (different address spaces)
expected void const [noderef] __percpu *__vpp_verify got bool *
This is due to the percpu variable xen_in_preemptible_hcall being exported via EXPORT_SYMBOL_GPL() instead of EXPORT_PER_CPU_SYMBOL_GPL().
Message-ID: <[email protected]>
--- arch/x86/xen/enlighten_pv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/enlighten_pv.c +1 -1
@@ -108,7 +108,7 @@ static int xen_cpu_dead_pv(unsigned int cpu);* calls. */ DEFINE_PER_CPU (bool, xen_in_preemptible_hcall); -EXPORT_SYMBOL_GPL (xen_in_preemptible_hcall); +EXPORT_PER_CPU_SYMBOL_GPL (xen_in_preemptible_hcall);/* * In case of scheduling the flag must be cleared and restored after
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 128/430 arm64: kdump: Fix elfcorehdr overlap caused by reserved memory processing reorder
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianpeng Chang <[email protected]>
[ Upstream commit 3e8ade58b71b48913d21b647b2089e03e81f117e ]
Commit 8a6e02d0c00e ("of: reserved_mem: Restructure how the reserved memory regions are processed") changed the processing order of reserved memory regions, causing elfcorehdr to overlap with dynamically allocated reserved memory regions during kdump kernel boot.
The issue occurs because:
1. kexec-tools allocates elfcorehdr in the last crashkernel reserved memory region and passes it to the second kernel
2. The problematic commit moved dynamic reserved memory allocation (like bman-fbpr) to occur during fdt_scan_reserved_mem(), before elfcorehdr reservation in fdt_reserve_elfcorehdr()
3. bman-fbpr with 16MB alignment requirement can get allocated at addresses that overlap with the elfcorehdr location
4. When fdt_reserve_elfcorehdr() tries to reserve elfcorehdr memory, overlap detection identifies the conflict and skips reservation
5. kdump kernel fails with "Unable to handle kernel paging request" because elfcorehdr memory is not properly reserved
The boot log:
Before 8a6e02d0c00e:
OF: fdt: Reserving 1 KiB of memory at 0xf4fff000 for elfcorehdr
OF: reserved mem: 0xf3000000..0xf3ffffff bman-fbpr
After 8a6e02d0c00e:
OF: reserved mem: 0xf4000000..0xf4ffffff bman-fbpr
OF: fdt: elfcorehdr is overlapped
Fix this by ensuring elfcorehdr reservation occurs before dynamic reserved memory allocation.
--- drivers/of/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/fdt.c +1 -1
@@ -503,8 +503,8 @@ void __init early_init_fdt_scan_reserved_mem(void)if (!initial_boot_params)return ; -fdt_scan_reserved_mem ();fdt_reserve_elfcorehdr (); +fdt_scan_reserved_mem ();/* Process header /memreserve/ fields */ for (n =0 ; ; n++) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 129/430 drm/amdgpu: fix a job->pasid access race in gpu recovery
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Deucher <[email protected]>
[ Upstream commit 77f73253015cbc7893fca1821ac3eae9eb4bc943 ]
Avoid a possible UAF in GPU recovery due to a race between the sched timeout callback and the tdr work queue.
The gpu recovery function calls drm_sched_stop() and later drm_sched_start(). drm_sched_start() restarts the tdr queue which will eventually free the job. If the tdr queue frees the job before time out callback completes, the job will be freed and we'll get a UAF when accessing the pasid. Cache it early to avoid the UAF.
Example KASAN trace:
[ 493.058141] BUG: KASAN: slab-use-after-free in amdgpu_device_gpu_recover+0x968/0x990 [amdgpu] [ 493.067530] Read of size 4 at addr ffff88b0ce3f794c by task kworker/u128:1/323 [ 493.074892] [ 493.076485] CPU: 9 UID: 0 PID: 323 Comm: kworker/u128:1 Tainted: G E 6.16.0-1289896.2.zuul.bf4f11df81c1410bbe901c4373305a31 #1 PREEMPT(voluntary) [ 493.076493] Tainted: [E]=UNSIGNED_MODULE [ 493.076495] Hardware name: TYAN B8021G88V2HR-2T/S8021GM2NR-2T, BIOS V1.03.B10 04/01/2019 [ 493.076500] Workqueue: amdgpu-reset-dev drm_sched_job_timedout [gpu_sched] [ 493.076512] Call Trace: [ 493.076515] <TASK> [ 493.076518] dump_stack_lvl+0x64/0x80 [ 493.076529] print_report+0xce/0x630 [ 493.076536] ? _raw_spin_lock_irqsave+0x86/0xd0 [ 493.076541] ? __pfx__raw_spin_lock_irqsave+0x10/0x10 [ 493.076545] ? amdgpu_device_gpu_recover+0x968/0x990 [amdgpu] [ 493.077253] kasan_report+0xb8/0xf0 [ 493.077258] ? amdgpu_device_gpu_recover+0x968/0x990 [amdgpu] [ 493.077965] amdgpu_device_gpu_recover+0x968/0x990 [amdgpu] [ 493.078672] ? __pfx_amdgpu_device_gpu_recover+0x10/0x10 [amdgpu] [ 493.079378] ? amdgpu_coredump+0x1fd/0x4c0 [amdgpu] [ 493.080111] amdgpu_job_timedout+0x642/0x1400 [amdgpu] [ 493.080903] ? pick_task_fair+0x24e/0x330 [ 493.080910] ? __pfx_amdgpu_job_timedout+0x10/0x10 [amdgpu] [ 493.081702] ? _raw_spin_lock+0x75/0xc0 [ 493.081708] ? __pfx__raw_spin_lock+0x10/0x10 [ 493.081712] drm_sched_job_timedout+0x1b0/0x4b0 [gpu_sched] [ 493.081721] ? __pfx__raw_spin_lock_irq+0x10/0x10 [ 493.081725] process_one_work+0x679/0xff0 [ 493.081732] worker_thread+0x6ce/0xfd0 [ 493.081736] ? __pfx_worker_thread+0x10/0x10 [ 493.081739] kthread+0x376/0x730 [ 493.081744] ? __pfx_kthread+0x10/0x10 [ 493.081748] ? __pfx__raw_spin_lock_irq+0x10/0x10 [ 493.081751] ? __pfx_kthread+0x10/0x10 [ 493.081755] ret_from_fork+0x247/0x330 [ 493.081761] ? __pfx_kthread+0x10/0x10 [ 493.081764] ret_from_fork_asm+0x1a/0x30 [ 493.081771] </TASK>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +8 -2
@@ -6476,6 +6476,8 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,struct amdgpu_hive_info *hive =NULL ;int r =0 ;bool need_emergency_restart = false; +/* save the pasid here as the job may be freed before the end of the reset */ +int pasid = job ? job->pasid : -EINVAL ;/* * If it reaches here because of hang/timeout and a RAS error is
@@ -6572,8 +6574,12 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,if (!r) {struct amdgpu_task_info *ti =NULL ; -if (job) - ti =amdgpu_vm_get_task_info_pasid (adev, job->pasid); +/* +* The job may already be freed at this point via the sched tdr workqueue so +* use the cached pasid. +*/ +if (pasid >=0 ) + ti =amdgpu_vm_get_task_info_pasid (adev, pasid);drm_dev_wedged_event (adev_to_drm (adev),DRM_WEDGE_RECOVERY_NONE , ti ? &ti->task :NULL );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 130/430 spi: cadence-quadspi: Fix clock disable on probe failure path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anurag Dutta <[email protected]>
[ Upstream commit 1889dd2081975ce1f6275b06cdebaa8d154847a9 ]
When cqspi_request_mmap_dma() returns -EPROBE_DEFER after runtime PM is enabled, the error path calls clk_disable_unprepare() on an already disabled clock, causing an imbalance.
Use pm_runtime_get_sync() to increment the usage counter and resume the device. This prevents runtime_suspend() from being invoked and causing a double clock disable.
--- drivers/spi/spi-cadence-quadspi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/spi/spi-cadence-quadspi.c +3 -1
@@ -2024,7 +2024,9 @@ static int cqspi_probe(struct platform_device *pdev) probe_reset_failed:if (cqspi->is_jh7110)cqspi_jh7110_disable_clk (pdev, cqspi); -clk_disable_unprepare (cqspi->clk); + +if (pm_runtime_get_sync (&pdev->dev) >=0 ) +clk_disable_unprepare (cqspi->clk); probe_clk_failed:return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 131/430 io_uring: fix nr_segs calculation in io_import_kbuf
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: huang-jl <[email protected]>
[ Upstream commit 114ea9bbaf7681c4d363e13b7916e6fef6a4963a ]
io_import_kbuf() calculates nr_segs incorrectly when iov_offset is non-zero after iov_iter_advance(). It doesn't account for the partial consumption of the first bvec.
The problem comes when meet the following conditions:
1. Use UBLK_F_AUTO_BUF_REG feature of ublk.
2. The kernel will help to register the buffer, into the io uring.
3. Later, the ublk server try to send IO request using the registered buffer in the io uring, to read/write to fuse-based filesystem, withO_DIRECT.
Quoted 1 line
From a userspace perspective, the ublk server thread is blocked in the
kernel, and will see "soft lockup" in the kernel dmesg.
When ublk registers a buffer with mixed-size bvecs like [4K]*6 + [12K] and a request partially consumes a bvec, the next request's nr_segs calculation uses bvec->bv_len instead of (bv_len - iov_offset).
This causes fuse_get_user_pages() to loop forever because nr_segs indicates fewer pages than actually needed.
Specifically, the infinite loop happens at:fuse_get_user_pages()
-> iov_iter_extract_pages()
-> iov_iter_extract_bvec_pages()
Since the nr_segs is miscalculated, the iov_iter_extract_bvec_pages returns when finding that i->nr_segs is zero. Then iov_iter_extract_pages returns zero. However, fuse_get_user_pages does still not get enough data/pages, causing infinite loop.
Example:
- Bvecs: [4K, 4K, 4K, 4K, 4K, 4K, 12K, ...]
- Request 1: 32K at offset 0, uses 6*4K + 8K of the 12K bvec
- Request 2: 32K at offset 32K
- iov_offset = 8K (8K already consumed from 12K bvec)
- Bug: calculates using 12K, not (12K - 8K) = 4K
- Result: nr_segs too small, infinite loop in fuse_get_user_pages.
Fix by accounting for iov_offset when calculating the first segment's available length.
--- io_uring/rsrc.c | 1 + 1 file changed, 1 insertion(+)
io_uring/rsrc.c +1 -0
@@ -1057,6 +1057,7 @@ static int io_import_kbuf(int ddir, struct iov_iter *iter,if (count < imu->len) {const struct bio_vec *bvec = iter->bvec; + len += iter->iov_offset;while (len > bvec->bv_len) { len -= bvec->bv_len; bvec++;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 132/430 ublk: add parameter `struct io_uring_cmd *` to ublk_prep_auto_buf_reg()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 3035b9b46b0611898babc0b96ede65790d3566f7 ]
Add parameter struct io_uring_cmd * to ublk_prep_auto_buf_reg() and prepare for reusing this helper for the coming UBLK_BATCH_IO feature, which can fetch & commit one batch of io commands via single uring_cmd.
Stable-dep-of: c258f5c4502c ("ublk: fix deadlock when reading partition table")
--- drivers/block/ublk_drv.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/block/ublk_drv.c +7 -5
@@ -1242,11 +1242,12 @@ ublk_auto_buf_reg_fallback(const struct ublk_queue *ubq, struct ublk_io *io) }static bool ublk_auto_buf_reg (const struct ublk_queue *ubq,struct request *req, -struct ublk_io *io,unsigned int issue_flags) +struct ublk_io *io,struct io_uring_cmd *cmd, +unsigned int issue_flags) {int ret; - ret =io_buffer_register_bvec (io->cmd, req, ublk_io_release, + ret =io_buffer_register_bvec (cmd, req, ublk_io_release, io->buf.index, issue_flags);if (ret) {if (io->buf.flags &UBLK_AUTO_BUF_REG_FALLBACK ) {
@@ -1258,18 +1259,19 @@ static bool ublk_auto_buf_reg(const struct ublk_queue *ubq, struct request *req, } io->task_registered_buffers =1 ; - io->buf_ctx_handle =io_uring_cmd_ctx_handle (io->cmd); + io->buf_ctx_handle =io_uring_cmd_ctx_handle (cmd); io->flags |=UBLK_IO_FLAG_AUTO_BUF_REG ;return true; }static bool ublk_prep_auto_buf_reg (struct ublk_queue *ubq,struct request *req,struct ublk_io *io, +struct io_uring_cmd *cmd,unsigned int issue_flags) {ublk_init_req_ref (ubq, io);if (ublk_support_auto_buf_reg (ubq) &&ublk_rq_has_data (req)) -return ublk_auto_buf_reg (ubq, req, io, issue_flags); +return ublk_auto_buf_reg (ubq, req, io, cmd, issue_flags);return true; }
@@ -1344,7 +1346,7 @@ static void ublk_dispatch_req(struct ublk_queue *ubq,if (!ublk_start_io (ubq, req, io))return ; -if (ublk_prep_auto_buf_reg (ubq, req, io, issue_flags)) +if (ublk_prep_auto_buf_reg (ubq, req, io, io->cmd, issue_flags))ublk_complete_io_cmd (io, req,UBLK_IO_RES_OK , issue_flags); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 133/430 ublk: add `union ublk_io_buf` with improved naming
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 8d61ece156bd4f2b9e7d3b2a374a26d42c7a4a06 ]
Add union ublk_io_buf for naming the anonymous union of struct ublk_io's addr and buf fields, meantime apply it to struct ublk_io for storing either ublk auto buffer register data or ublk server io buffer address.
The union uses clear field names:
- addr: for regular ublk server io buffer addresses
- auto_reg: for ublk auto buffer registration data
This eliminates confusing access patterns and improves code readability.
Stable-dep-of: c258f5c4502c ("ublk: fix deadlock when reading partition table")
--- drivers/block/ublk_drv.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/block/ublk_drv.c +22 -18
@@ -155,12 +155,13 @@ struct ublk_uring_cmd_pdu {*/ #define UBLK_REFCOUNT_INIT (REFCOUNT_MAX / 2) +union ublk_io_buf { +__u64 addr; +struct ublk_auto_buf_reg auto_reg; +}; +struct ublk_io { -/* userspace buffer address from io cmd */ -union { -__u64 addr; -struct ublk_auto_buf_reg buf; - }; +union ublk_io_buf buf;unsigned int flags;int res;
@@ -499,7 +500,7 @@ static blk_status_t ublk_setup_iod_zoned(struct ublk_queue *ubq, iod->op_flags = ublk_op |ublk_req_build_flags (req); iod->nr_sectors =blk_rq_sectors (req); iod->start_sector =blk_rq_pos (req); - iod->addr = io->addr; + iod->addr = io->buf.addr;return BLK_STS_OK ; }
@@ -1047,7 +1048,7 @@ static int ublk_map_io(const struct ublk_queue *ubq, const struct request *req,struct iov_iter iter;const int dir =ITER_DEST ; -import_ubuf (dir,u64_to_user_ptr (io->addr), rq_bytes, &iter); +import_ubuf (dir,u64_to_user_ptr (io->buf.addr), rq_bytes, &iter);return ublk_copy_user_pages (req,0 , &iter, dir); }return rq_bytes;
@@ -1068,7 +1069,7 @@ static int ublk_unmap_io(bool need_map,WARN_ON_ONCE (io->res > rq_bytes); -import_ubuf (dir,u64_to_user_ptr (io->addr), io->res, &iter); +import_ubuf (dir,u64_to_user_ptr (io->buf.addr), io->res, &iter);return ublk_copy_user_pages (req,0 , &iter, dir); }return rq_bytes;
@@ -1134,7 +1135,7 @@ static blk_status_t ublk_setup_iod(struct ublk_queue *ubq, struct request *req) iod->op_flags = ublk_op |ublk_req_build_flags (req); iod->nr_sectors =blk_rq_sectors (req); iod->start_sector =blk_rq_pos (req); - iod->addr = io->addr; + iod->addr = io->buf.addr;return BLK_STS_OK ; }
@@ -1248,9 +1249,9 @@ static bool ublk_auto_buf_reg(const struct ublk_queue *ubq, struct request *req,int ret; ret =io_buffer_register_bvec (cmd, req, ublk_io_release, - io->buf.index, issue_flags); + io->buf.auto_reg.index, issue_flags);if (ret) { -if (io->buf.flags &UBLK_AUTO_BUF_REG_FALLBACK ) { +if (io->buf.auto_reg.flags &UBLK_AUTO_BUF_REG_FALLBACK ) {ublk_auto_buf_reg_fallback (ubq, io);return true; }
@@ -1539,7 +1540,7 @@ static void ublk_queue_reinit(struct ublk_device *ub, struct ublk_queue *ubq)*/ io->flags &=UBLK_IO_FLAG_CANCELED ; io->cmd =NULL ; - io->addr =0 ; + io->buf.addr =0 ;/* * old task is PF_EXITING, put it now
@@ -2100,13 +2101,16 @@ static inline int ublk_check_cmd_op(u32 cmd_op)static inline int ublk_set_auto_buf_reg (struct ublk_io *io,struct io_uring_cmd *cmd) { - io->buf =ublk_sqe_addr_to_auto_buf_reg (READ_ONCE (cmd->sqe->addr)); +struct ublk_auto_buf_reg buf; + + buf =ublk_sqe_addr_to_auto_buf_reg (READ_ONCE (cmd->sqe->addr)); -if (io->buf.reserved0 || io->buf.reserved1) +if (buf.reserved0 || buf.reserved1)return -EINVAL ; -if (io->buf.flags & ~UBLK_AUTO_BUF_REG_F_MASK ) +if (buf.flags & ~UBLK_AUTO_BUF_REG_F_MASK )return -EINVAL ; + io->buf.auto_reg = buf;return 0 ; }
@@ -2128,7 +2132,7 @@ static int ublk_handle_auto_buf_reg(struct ublk_io *io,* this ublk request gets stuck. */ if (io->buf_ctx_handle ==io_uring_cmd_ctx_handle (cmd)) - *buf_idx = io->buf.index; + *buf_idx = io->buf.auto_reg.index; }return ublk_set_auto_buf_reg (io, cmd);
@@ -2156,7 +2160,7 @@ ublk_config_io_buf(const struct ublk_device *ub, struct ublk_io *io,if (ublk_dev_support_auto_buf_reg (ub))return ublk_handle_auto_buf_reg (io, cmd, buf_idx); - io->addr = buf_addr; + io->buf.addr = buf_addr;return 0 ; }
@@ -2353,7 +2357,7 @@ static bool ublk_get_data(const struct ublk_queue *ubq, struct ublk_io *io,*/ io->flags &= ~UBLK_IO_FLAG_NEED_GET_DATA ;/* update iod->addr because ublksrv may have passed a new io buffer */ -ublk_get_iod (ubq, req->tag)->addr = io->addr; +ublk_get_iod (ubq, req->tag)->addr = io->buf.addr;pr_devel ("%s: update iod->addr: qid %d tag %d io_flags %x addr %llx\n" , __func__, ubq->q_id, req->tag, io->flags,ublk_get_iod (ubq, req->tag)->addr);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 134/430 ublk: refactor auto buffer register in ublk_dispatch_req()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit 0a9beafa7c633e6ff66b05b81eea78231b7e6520 ]
Refactor auto buffer register code and prepare for supporting batch IO feature, and the main motivation is to put 'ublk_io' operation code together, so that per-io lock can be applied for the code block.
The key changes are:
- Rename ublk_auto_buf_reg() as ublk_do_auto_buf_reg()
- Introduce an enum auto_buf_reg_res to represent the result of the buffer registration attempt (FAIL, FALLBACK, OK).
- Split the existing ublk_do_auto_buf_reg function into two:
- __ublk_do_auto_buf_reg: Performs the actual buffer registration and returns the auto_buf_reg_res status.
- ublk_do_auto_buf_reg: A wrapper that calls the internal function and handles the I/O preparation based on the result.
- Introduce ublk_prep_auto_buf_reg_io to encapsulate the logic for preparing the I/O for completion after buffer registration.
- Pass the tag directly to ublk_auto_buf_reg_fallback to avoid recalculating it.
This refactoring makes the control flow clearer and isolates the different stages of the auto buffer registration process.
Stable-dep-of: c258f5c4502c ("ublk: fix deadlock when reading partition table")
--- drivers/block/ublk_drv.c | 64 +++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 21 deletions(-)
drivers/block/ublk_drv.c +43 -21
@@ -1234,17 +1234,37 @@ static inline void __ublk_abort_rq(struct ublk_queue *ubq, }static void -ublk_auto_buf_reg_fallback (const struct ublk_queue *ubq,struct ublk_io *io) +ublk_auto_buf_reg_fallback (const struct ublk_queue *ubq,unsigned tag) { -unsigned tag = io - ubq->ios;struct ublksrv_io_desc *iod =ublk_get_iod (ubq, tag); iod->op_flags |=UBLK_IO_F_NEED_REG_BUF ; } -static bool ublk_auto_buf_reg (const struct ublk_queue *ubq,struct request *req, -struct ublk_io *io,struct io_uring_cmd *cmd, -unsigned int issue_flags) +enum auto_buf_reg_res { +AUTO_BUF_REG_FAIL , +AUTO_BUF_REG_FALLBACK , +AUTO_BUF_REG_OK , +}; + +static void ublk_prep_auto_buf_reg_io (const struct ublk_queue *ubq, +struct request *req,struct ublk_io *io, +struct io_uring_cmd *cmd, +enum auto_buf_reg_res res) +{ +if (res ==AUTO_BUF_REG_OK ) { + io->task_registered_buffers =1 ; + io->buf_ctx_handle =io_uring_cmd_ctx_handle (cmd); + io->flags |=UBLK_IO_FLAG_AUTO_BUF_REG ; + } +ublk_init_req_ref (ubq, io); +__ublk_prep_compl_io_cmd (io, req); +} + +static enum auto_buf_reg_res +__ublk_do_auto_buf_reg (const struct ublk_queue *ubq,struct request *req, +struct ublk_io *io,struct io_uring_cmd *cmd, +unsigned int issue_flags) {int ret;
@@ -1252,29 +1272,27 @@ static bool ublk_auto_buf_reg(const struct ublk_queue *ubq, struct request *req, io->buf.auto_reg.index, issue_flags);if (ret) {if (io->buf.auto_reg.flags &UBLK_AUTO_BUF_REG_FALLBACK ) { -ublk_auto_buf_reg_fallback (ubq, io); -return true; +ublk_auto_buf_reg_fallback (ubq, req->tag); +return AUTO_BUF_REG_FALLBACK ; }blk_mq_end_request (req,BLK_STS_IOERR ); -return false; +return AUTO_BUF_REG_FAIL ; } - io->task_registered_buffers =1 ; - io->buf_ctx_handle =io_uring_cmd_ctx_handle (cmd); - io->flags |=UBLK_IO_FLAG_AUTO_BUF_REG ; -return true; +return AUTO_BUF_REG_OK ; } -static bool ublk_prep_auto_buf_reg (struct ublk_queue *ubq, -struct request *req,struct ublk_io *io, -struct io_uring_cmd *cmd, -unsigned int issue_flags) +static void ublk_do_auto_buf_reg (const struct ublk_queue *ubq,struct request *req, +struct ublk_io *io,struct io_uring_cmd *cmd, +unsigned int issue_flags) { -ublk_init_req_ref (ubq, io); -if (ublk_support_auto_buf_reg (ubq) &&ublk_rq_has_data (req)) -return ublk_auto_buf_reg (ubq, req, io, cmd, issue_flags); +enum auto_buf_reg_res res =__ublk_do_auto_buf_reg (ubq, req, io, cmd, + issue_flags); -return true; +if (res !=AUTO_BUF_REG_FAIL ) { +ublk_prep_auto_buf_reg_io (ubq, req, io, cmd, res); +io_uring_cmd_done (cmd,UBLK_IO_RES_OK , issue_flags); + } } static bool ublk_start_io(const struct ublk_queue *ubq, struct request *req,
@@ -1347,8 +1365,12 @@ static void ublk_dispatch_req(struct ublk_queue *ubq,if (!ublk_start_io (ubq, req, io))return ; -if (ublk_prep_auto_buf_reg (ubq, req, io, io->cmd, issue_flags)) +if (ublk_support_auto_buf_reg (ubq) &&ublk_rq_has_data (req)) { +ublk_do_auto_buf_reg (ubq, req, io, io->cmd, issue_flags); + }else { +ublk_init_req_ref (ubq, io);ublk_complete_io_cmd (io, req,UBLK_IO_RES_OK , issue_flags); + } } static void ublk_cmd_tw_cb(struct io_uring_cmd *cmd,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 135/430 ublk: fix deadlock when reading partition table
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Lei <[email protected]>
[ Upstream commit c258f5c4502c9667bccf5d76fa731ab9c96687c1 ]
When one process(such as udev) opens ublk block device (e.g., to read the partition table via bdev_open()), a deadlock[1] can occur:
1. bdev_open() grabs disk->open_mutex
2. The process issues read I/O to ublk backend to read partition table
3. In __ublk_complete_rq(), blk_update_request() or blk_mq_end_request() runs bio->bi_end_io() callbacks
4. If this triggers fput() on file descriptor of ublk block device, the work may be deferred to current task's task work (see fput() implementation)
5. This eventually calls blkdev_release() from the same context
6. blkdev_release() tries to grab disk->open_mutex again
7. Deadlock: same task waiting for a mutex it already holds
The fix is to run blk_update_request() and blk_mq_end_request() with bottom halves disabled. This forces blkdev_release() to run in kernel work-queue context instead of current task work context, and allows ublk server to make forward progress, and avoids the deadlock.
--- drivers/block/ublk_drv.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-)
drivers/block/ublk_drv.c +28 -4
@@ -1146,12 +1146,20 @@ static inline struct ublk_uring_cmd_pdu *ublk_get_uring_cmd_pdu( return io_uring_cmd_to_pdu(ioucmd, struct ublk_uring_cmd_pdu); } +static void ublk_end_request (struct request *req,blk_status_t error) +{ +local_bh_disable (); +blk_mq_end_request (req, error); +local_bh_enable (); +} +/* todo: handle partial completion */ static inline void __ublk_complete_rq (struct request *req,struct ublk_io *io,bool need_map) {unsigned int unmapped_bytes;blk_status_t res =BLK_STS_OK ; +bool requeue;/* failed read IO if nothing is read */ if (!io->res &&req_op (req) ==REQ_OP_READ )
@@ -1183,14 +1191,30 @@ static inline void __ublk_complete_rq(struct request *req, struct ublk_io *io,if (unlikely (unmapped_bytes < io->res)) io->res = unmapped_bytes; -if (blk_update_request (req,BLK_STS_OK , io->res)) +/* +* Run bio->bi_end_io() with softirqs disabled. If the final fput +* happens off this path, then that will prevent ublk's blkdev_release() +* from being called on current's task work, see fput() implementation. +* +* Otherwise, ublk server may not provide forward progress in case of +* reading the partition table from bdev_open() with disk->open_mutex +* held, and causes dead lock as we could already be holding +* disk->open_mutex here. +* +* Preferably we would not be doing IO with a mutex held that is also +* used for release, but this work-around will suffice for now. +*/ +local_bh_disable (); + requeue =blk_update_request (req,BLK_STS_OK , io->res); +local_bh_enable (); +if (requeue)blk_mq_requeue_request (req, true);else if (likely (!blk_should_fake_timeout (req->q)))__blk_mq_end_request (req,BLK_STS_OK );return ; exit: -blk_mq_end_request (req, res); +ublk_end_request (req, res); } static struct io_uring_cmd *__ublk_prep_compl_io_cmd(struct ublk_io *io,
@@ -1230,7 +1254,7 @@ static inline void __ublk_abort_rq(struct ublk_queue *ubq,if (ublk_nosrv_dev_should_queue_io (ubq->dev))blk_mq_requeue_request (rq, false);else -blk_mq_end_request (rq,BLK_STS_IOERR ); +ublk_end_request (rq,BLK_STS_IOERR ); } static void
@@ -1275,7 +1299,7 @@ __ublk_do_auto_buf_reg(const struct ublk_queue *ubq, struct request *req,ublk_auto_buf_reg_fallback (ubq, req->tag);return AUTO_BUF_REG_FALLBACK ; } -blk_mq_end_request (req,BLK_STS_IOERR ); +ublk_end_request (req,BLK_STS_IOERR );return AUTO_BUF_REG_FAIL ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 136/430 block: rnbd-clt: Fix leaked ID in init_dev()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit c9b5645fd8ca10f310e41b07540f98e6a9720f40 ]
If kstrdup() fails in init_dev(), then the newly allocated ID is lost.
--- drivers/block/rnbd/rnbd-clt.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/block/rnbd/rnbd-clt.c +8 -5
@@ -1423,9 +1423,11 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, goto out_alloc; } - ret =ida_alloc_max (&index_ida, (1 << (MINORBITS -RNBD_PART_BITS )) -1 , -GFP_KERNEL ); -if (ret <0 ) { + dev->clt_device_id =ida_alloc_max (&index_ida, + (1 << (MINORBITS -RNBD_PART_BITS )) -1 , +GFP_KERNEL ); +if (dev->clt_device_id <0 ) { + ret = dev->clt_device_id;pr_err ("Failed to initialize device '%s' from session %s, allocating idr failed, err: %d\n" , pathname, sess->sessname, ret); goto out_queues;
@@ -1434,10 +1436,9 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess, dev->pathname =kstrdup (pathname,GFP_KERNEL );if (!dev->pathname) { ret = -ENOMEM ; - goto out_queues; + goto out_ida; } - dev->clt_device_id = ret; dev->sess = sess; dev->access_mode = access_mode; dev->nr_poll_queues = nr_poll_queues;
@@ -1453,6 +1454,8 @@ static struct rnbd_clt_dev *init_dev(struct rnbd_clt_session *sess,return dev; +out_ida: +ida_free (&index_ida, dev->clt_device_id); out_queues:kfree (dev->hw_queues); out_alloc:
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 137/430 drm/xe: Limit num_syncs to prevent oversized allocations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuicheng Lin <[email protected]>
[ Upstream commit 8e461304009135270e9ccf2d7e2dfe29daec9b60 ]
The exec and vm_bind ioctl allow userspace to specify an arbitrary num_syncs value. Without bounds checking, a very large num_syncs can force an excessively large allocation, leading to kernel warnings from the page allocator as below.
Introduce DRM_XE_MAX_SYNCS (set to 1024) and reject any request exceeding this limit.
"
------------[ cut here ]------------ WARNING: CPU: 0 PID: 1217 at mm/page_alloc.c:5124 __alloc_frozen_pages_noprof+0x2f8/0x2180 mm/page_alloc.c:5124 ... Call Trace: <TASK> alloc_pages_mpol+0xe4/0x330 mm/mempolicy.c:2416 ___kmalloc_large_node+0xd8/0x110 mm/slub.c:4317 __kmalloc_large_node_noprof+0x18/0xe0 mm/slub.c:4348 __do_kmalloc_node mm/slub.c:4364 [inline] __kmalloc_noprof+0x3d4/0x4b0 mm/slub.c:4388 kmalloc_noprof include/linux/slab.h:909 [inline] kmalloc_array_noprof include/linux/slab.h:948 [inline] xe_exec_ioctl+0xa47/0x1e70 drivers/gpu/drm/xe/xe_exec.c:158 drm_ioctl_kernel+0x1f1/0x3e0 drivers/gpu/drm/drm_ioctl.c:797 drm_ioctl+0x5e7/0xc50 drivers/gpu/drm/drm_ioctl.c:894 xe_drm_ioctl+0x10b/0x170 drivers/gpu/drm/xe/xe_device.c:224 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:598 [inline] __se_sys_ioctl fs/ioctl.c:584 [inline] __x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:584 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xbb/0x380 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f
...
"
v2: Add "Reported-by" and Cc stable kernels.
v3: Change XE_MAX_SYNCS from 64 to 1024. (Matt & Ashutosh)
v4: s/XE_MAX_SYNCS/DRM_XE_MAX_SYNCS/ (Matt)
v5: Do the check at the top of the exec func. (Matt)
Stable-dep-of: f8dd66bfb4e1 ("drm/xe/oa: Limit num_syncs to prevent oversized allocations")
--- drivers/gpu/drm/xe/xe_exec.c | 3 ++- drivers/gpu/drm/xe/xe_vm.c | 3 +++ include/uapi/drm/xe_drm.h | 1 + 3 files changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_exec.c +2 -1
@@ -130,7 +130,8 @@ int xe_exec_ioctl(struct drm_device *dev, void *data, struct drm_file *file)if (XE_IOCTL_DBG (xe, args->extensions) ||XE_IOCTL_DBG (xe, args->pad[0 ] || args->pad[1 ] || args->pad[2 ]) || -XE_IOCTL_DBG (xe, args->reserved[0 ] || args->reserved[1 ])) +XE_IOCTL_DBG (xe, args->reserved[0 ] || args->reserved[1 ]) || +XE_IOCTL_DBG (xe, args->num_syncs >DRM_XE_MAX_SYNCS ))return -EINVAL ; q =xe_exec_queue_lookup (xef, args->exec_queue_id);
drivers/gpu/drm/xe/xe_vm.c +3 -0
@@ -3282,6 +3282,9 @@ static int vm_bind_ioctl_check_args(struct xe_device *xe, struct xe_vm *vm,if (XE_IOCTL_DBG (xe, args->extensions))return -EINVAL ; +if (XE_IOCTL_DBG (xe, args->num_syncs >DRM_XE_MAX_SYNCS )) +return -EINVAL ; +if (args->num_binds >1 ) {u64 __user *bind_user =u64_to_user_ptr (args->vector_of_binds);
include/uapi/drm/xe_drm.h +1 -0
@@ -1459,6 +1459,7 @@ struct drm_xe_exec {/** @exec_queue_id: Exec queue ID for the batch buffer */ __u32 exec_queue_id; +#define DRM_XE_MAX_SYNCS 1024/** @num_syncs: Amount of struct drm_xe_sync in array. */ __u32 num_syncs;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 138/430 drm/xe/oa: Limit num_syncs to prevent oversized allocations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuicheng Lin <[email protected]>
[ Upstream commit f8dd66bfb4e184c71bd26418a00546ebe7f5c17a ]
The OA open parameters did not validate num_syncs, allowing userspace to pass arbitrarily large values, potentially leading to excessive allocations.
Add check to ensure that num_syncs does not exceed DRM_XE_MAX_SYNCS, returning -EINVAL when the limit is violated.
v2: use XE_IOCTL_DBG() and drop duplicated check. (Ashutosh)
--- drivers/gpu/drm/xe/xe_oa.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/xe/xe_oa.c +3 -0
@@ -1253,6 +1253,9 @@ static int xe_oa_set_no_preempt(struct xe_oa *oa, u64 value,static int xe_oa_set_prop_num_syncs (struct xe_oa *oa,u64 value,struct xe_oa_open_param *param) { +if (XE_IOCTL_DBG (oa->xe, value >DRM_XE_MAX_SYNCS )) +return -EINVAL ; + param->num_syncs = value;return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 139/430 drm/xe/oa: Always set OAG_OAGLBCTXCTRL_COUNTER_RESUME
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ashutosh Dixit <[email protected]>
[ Upstream commit 256edb267a9d0b5aef70e408e9fba4f930f9926e ]
Reports can be written out to the OA buffer using ways other than periodic sampling. These include mmio trigger and context switches. To support these use cases, when periodic sampling is not enabled, OAG_OAGLBCTXCTRL_COUNTER_RESUME must be set.
--- drivers/gpu/drm/xe/xe_oa.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/drm/xe/xe_oa.c +4 -3
@@ -1104,11 +1104,12 @@ static int xe_oa_enable_metric_set(struct xe_oa_stream *stream)oag_buf_size_select (stream) | oag_configure_mmio_trigger(stream, true)); -xe_mmio_write32 (mmio,__oa_regs (stream)->oa_ctx_ctrl, stream->periodic ? - (OAG_OAGLBCTXCTRL_COUNTER_RESUME | +xe_mmio_write32 (mmio,__oa_regs (stream)->oa_ctx_ctrl, +OAG_OAGLBCTXCTRL_COUNTER_RESUME | + (stream->periodic ?OAG_OAGLBCTXCTRL_TIMER_ENABLE |REG_FIELD_PREP (OAG_OAGLBCTXCTRL_TIMER_PERIOD_MASK , - stream->period_exponent)) :0 ); + stream->period_exponent) :0 ));/* * Initialize Super Queue Internal Cnt Register
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 140/430 amd/iommu: Preserve domain ids inside the kdump kernel
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sairaj Kodilkar <[email protected]>
[ Upstream commit c2e8dc1222c2136e714d5d972dce7e64924e4ed8 ]
Currently AMD IOMMU driver does not reserve domain ids programmed in the DTE while reusing the device table inside kdump kernel. This can cause reallocation of these domain ids for newer domains that are created by the kdump kernel, which can lead to potential IO_PAGE_FAULTs
Hence reserve these ids inside pdom_ids.
--- drivers/iommu/amd/init.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/iommu/amd/init.c +22 -1
@@ -1136,9 +1136,13 @@ static void set_dte_bit(struct dev_table_entry *dte, u8 bit)static bool __reuse_device_table (struct amd_iommu *iommu) {struct amd_iommu_pci_seg *pci_seg = iommu->pci_seg; -u32 lo, hi, old_devtb_size; +struct dev_table_entry *old_dev_tbl_entry; +u32 lo, hi, old_devtb_size, devid;phys_addr_t old_devtb_phys; +u16 dom_id; +bool dte_v;u64 entry; +int ret;/* Each IOMMU use separate device table with the same size */ lo =readl (iommu->mmio_base +MMIO_DEV_TABLE_OFFSET );
@@ -1173,6 +1177,23 @@ static bool __reuse_device_table(struct amd_iommu *iommu)return false; } +for (devid =0 ; devid <= pci_seg->last_bdf; devid++) { + old_dev_tbl_entry = &pci_seg->old_dev_tbl_cpy[devid]; + dte_v =FIELD_GET (DTE_FLAG_V , old_dev_tbl_entry->data[0 ]); + dom_id =FIELD_GET (DEV_DOMID_MASK , old_dev_tbl_entry->data[1 ]); + +if (!dte_v || !dom_id) +continue ; +/* +* ID reservation can fail with -ENOSPC when there +* are multiple devices present in the same domain, +* hence check only for -ENOMEM. +*/ + ret =ida_alloc_range (&pdom_ids, dom_id, dom_id,GFP_KERNEL ); +if (ret == -ENOMEM ) +return false; + } +return true; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 141/430 arm64: dts: mediatek: Apply mt8395-radxa DT overlay at build time
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rob Herring (Arm) <[email protected]>
[ Upstream commit ce7b1d58609abc2941a1f38094147f439fb74233 ]
It's a requirement that DT overlays be applied at build time in order to validate them as overlays are not validated on their own.
Add missing target for mt8395-radxa hd panel overlay.
--- arch/arm64/boot/dts/mediatek/Makefile | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/boot/dts/mediatek/Makefile +2 -0
@@ -104,6 +104,8 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += mt8390-genio-700-evk.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8395-kontron-3-5-sbc-i1200.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8395-radxa-nio-12l.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8395-radxa-nio-12l-8-hd-panel.dtbo +mt8395-radxa-nio-12l-8-hd-panel-dtbs := mt8395-radxa-nio-12l.dtb mt8395-radxa-nio-12l-8-hd-panel.dtbo +dtb-$(CONFIG_ARCH_MEDIATEK) += mt8395-radxa-nio-12l-8-hd-panel.dtb dtb-$(CONFIG_ARCH_MEDIATEK) += mt8516-pumpkin.dtb # Device tree overlays support
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 142/430 hwmon: (ltc4282): Fix reset_history file permissions
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
[ Upstream commit b3db91c3bfea69a6c6258fea508f25a59c0feb1a ]
The reset_history attributes are write only. Hence don't report them as readable just to return -EOPNOTSUPP later on.
--- drivers/hwmon/ltc4282.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/hwmon/ltc4282.c +6 -3
@@ -1018,8 +1018,9 @@ static umode_t ltc4282_in_is_visible(const struct ltc4282_state *st, u32 attr)case hwmon_in_max:case hwmon_in_min:case hwmon_in_enable: -case hwmon_in_reset_history:return 0644 ; +case hwmon_in_reset_history: +return 0200 ;default :return 0 ; }
@@ -1038,8 +1039,9 @@ static umode_t ltc4282_curr_is_visible(u32 attr)return 0444 ;case hwmon_curr_max:case hwmon_curr_min: -case hwmon_curr_reset_history:return 0644 ; +case hwmon_curr_reset_history: +return 0200 ;default :return 0 ; }
@@ -1057,8 +1059,9 @@ static umode_t ltc4282_power_is_visible(u32 attr)return 0444 ;case hwmon_power_max:case hwmon_power_min: -case hwmon_power_reset_history:return 0644 ; +case hwmon_power_reset_history: +return 0200 ;default :return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 143/430 ksmbd: skip lock-range check on equal size to avoid size==0 underflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qianchang Zhao <[email protected]>
commit 5d510ac31626ed157d2182149559430350cf2104 upstream.
When size equals the current i_size (including 0), the code used to call check_lock_range(filp, i_size, size - 1, WRITE), which computes size - 1 and can underflow for size==0. Skip the equal case.
--- fs/smb/server/vfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/smb/server/vfs.c +4 -1
@@ -324,6 +324,9 @@ static int check_lock_range(struct filestruct file_lock_context *ctx =locks_inode_context (file_inode (filp));int error =0 ; +if (start == end) +return 0 ; +if (!ctx ||list_empty_careful (&ctx->flc_posix))return 0 ;
@@ -828,7 +831,7 @@ int ksmbd_vfs_truncate(struct ksmbd_workif (size < inode->i_size) { err =check_lock_range (filp, size, inode->i_size -1 ,WRITE ); - }else { + }else if (size > inode->i_size) { err =check_lock_range (filp, inode->i_size, size -1 ,WRITE ); }
Greg Kroah-Hartman
maintainerPATCH 144/430 ksmbd: Fix refcount leak when invalid session is found on session lookup
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit cafb57f7bdd57abba87725eb4e82bbdca4959644 upstream.
When a session is found but its state is not SMB2_SESSION_VALID, It indicates that no valid session was found, but it is missing to decrement the reference count acquired by the session lookup, which results in a reference count leak. This patch fixes the issue by explicitly calling ksmbd_user_session_put to release the reference to the session.
--- fs/smb/server/mgmt/user_session.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/smb/server/mgmt/user_session.c +3 -1
@@ -325,8 +325,10 @@ struct ksmbd_session *ksmbd_session_look sess =ksmbd_session_lookup (conn, id);if (!sess && conn->binding) sess =ksmbd_session_lookup_slowpath (id); -if (sess && sess->state !=SMB2_SESSION_VALID ) +if (sess && sess->state !=SMB2_SESSION_VALID ) { +ksmbd_user_session_put (sess); sess =NULL ; + }return sess; }
Greg Kroah-Hartman
maintainerPATCH 145/430 ksmbd: fix buffer validation by including null terminator size in EA length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
commit 95d7a890e4b03e198836d49d699408fd1867cb55 upstream.
The smb2_set_ea function, which handles Extended Attributes (EA), was performing buffer validation checks that incorrectly omitted the size of the null terminating character (+1 byte) for EA Name.
This patch fixes the issue by explicitly adding '+ 1' to EaNameLength where the null terminator is expected to be present in the buffer, ensuring the validation accurately reflects the total required buffer size.
--- fs/smb/server/smb2pdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/server/smb2pdu.c +2 -2
@@ -2373,7 +2373,7 @@ static int smb2_set_ea(struct smb2_ea_inint rc =0 ;unsigned int next =0 ; -if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength + +if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength +1 +le16_to_cpu (eabuf->EaValueLength))return -EINVAL ;
@@ -2450,7 +2450,7 @@ next:break ; } -if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength + +if (buf_len <sizeof (struct smb2_ea_info ) + eabuf->EaNameLength +1 +le16_to_cpu (eabuf->EaValueLength)) { rc = -EINVAL ;break ;
Greg Kroah-Hartman
maintainerPATCH 146/430 HID: input: map HID_GD_Z to ABS_DISTANCE for stylus/pen
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ping Cheng <[email protected]>
commit 7953794f741e94d30df9dafaaa4c031c85b891d6 upstream.
HID_GD_Z is mapped to ABS_Z for stylus and pen in hid-input.c. But HID_GD_Z should be used to report ABS_DISTANCE for stylus and pen as described at:
Documentation/input/event-codes.rst#n226
* ABS_DISTANCE:
- Used to describe the distance of a tool from an interaction surface. This event should only be emitted while the tool is hovering, meaning in close proximity of the device and while the value of the BTN_TOUCH code is 0. If the input device may be used freely in three dimensions, consider ABS_Z instead.
- BTN_TOOL_<name> should be set to 1 when the tool comes into detectable proximity and set to 0 when the tool leaves detectable proximity. BTN_TOOL_<name> signals the type of tool that is currently detected by the hardware and is otherwise independent of ABS_DISTANCE and/or BTN_TOUCH.
This patch makes the correct mapping. The ABS_DISTANCE is currently not mapped by any HID usage in hid-generic driver.
--- drivers/hid/hid-input.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-)
drivers/hid/hid-input.c +17 -1
@@ -878,7 +878,7 @@ static void hidinput_configure_usage(strswitch (usage->hid) {/* These usage IDs map directly to the usage codes. */ -case HID_GD_X :case HID_GD_Y :case HID_GD_Z : +case HID_GD_X :case HID_GD_Y :case HID_GD_RX :case HID_GD_RY :case HID_GD_RZ :if (field->flags &HID_MAIN_ITEM_RELATIVE )map_rel (usage->hid &0xf );
@@ -886,6 +886,22 @@ static void hidinput_configure_usage(strmap_abs_clear (usage->hid &0xf );break ; +case HID_GD_Z : +/* HID_GD_Z is mapped to ABS_DISTANCE for stylus/pen */ +if (field->flags &HID_MAIN_ITEM_RELATIVE ) { +map_rel (usage->hid &0xf ); + }else { +if (field->application ==HID_DG_PEN || + field->physical ==HID_DG_PEN || + field->logical ==HID_DG_STYLUS || + field->physical ==HID_DG_STYLUS || + field->application ==HID_DG_DIGITIZER ) +map_abs_clear (ABS_DISTANCE ); +else +map_abs_clear (usage->hid &0xf ); + } +break ; +case HID_GD_WHEEL :if (field->flags &HID_MAIN_ITEM_RELATIVE ) {set_bit (REL_WHEEL , input->relbit);
Greg Kroah-Hartman
maintainerPATCH 147/430 Input: apple_z2 - fix reading incorrect reports after exiting sleep
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sasha Finkelstein <[email protected]>
commit d579478cee228bdc0029a0c12a1f6a63ea9d1c77 upstream.
Under certain conditions (more prevalent after a suspend/resume cycle), the touchscreen controller can send the "boot complete" interrupt before it actually finished booting. In those cases, attempting to read touch data resuls in a stream of "not ready" messages being read and interpreted as a touch report. Check that the response is in fact a touch report and discard it otherwise.
--- drivers/input/touchscreen/apple_z2.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/input/touchscreen/apple_z2.c +4 -0
@@ -21,6 +21,7 @@#define APPLE_Z2_TOUCH_STARTED 3#define APPLE_Z2_TOUCH_MOVED 4#define APPLE_Z2_CMD_READ_INTERRUPT_DATA 0xEB +#define APPLE_Z2_REPLY_INTERRUPT_DATA 0xE1#define APPLE_Z2_HBPP_CMD_BLOB 0x3001#define APPLE_Z2_FW_MAGIC 0x5746325A#define LOAD_COMMAND_INIT_PAYLOAD 0
@@ -142,6 +143,9 @@ static int apple_z2_read_packet(struct aif (error)return error; +if (z2->rx_buf[0 ] !=APPLE_Z2_REPLY_INTERRUPT_DATA ) +return 0 ; + pkt_len = (get_unaligned_le16 (z2->rx_buf +1 ) +8 ) &0xfffffffc ; error =spi_read (z2->spidev, z2->rx_buf, pkt_len);
Greg Kroah-Hartman
maintainerPATCH 148/430 Input: xpad - add support for CRKD Guitars
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sanjay Govind <[email protected]>
commit 806ec7b797adc1cc9b11535307638a55ddfb873c upstream.
Add support for various CRKD Guitar Controllers.
--- drivers/input/joystick/xpad.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/input/joystick/xpad.c +5 -0
@@ -133,6 +133,8 @@ static const struct xpad_device { } xpad_device[] = {/* Please keep this list sorted by vendor and product ID. */ { 0x0079, 0x18d4, "GPD Win 2 X-Box Controller", 0, XTYPE_XBOX360 }, + { 0x0351, 0x1000, "CRKD LP Blueberry Burst Pro Edition (Xbox)", 0, XTYPE_XBOX360 }, + { 0x0351, 0x2000, "CRKD LP Black Tribal Edition (Xbox) ", 0, XTYPE_XBOX360 }, { 0x03eb, 0xff01, "Wooting One (Legacy)", 0, XTYPE_XBOX360 }, { 0x03eb, 0xff02, "Wooting Two (Legacy)", 0, XTYPE_XBOX360 }, { 0x03f0, 0x038D, "HyperX Clutch", 0, XTYPE_XBOX360 }, /* wired */
@@ -420,6 +422,7 @@ static const struct xpad_device { { 0x3285, 0x0663, "Nacon Evol-X", 0, XTYPE_XBOXONE }, { 0x3537, 0x1004, "GameSir T4 Kaleid", 0, XTYPE_XBOX360 }, { 0x3537, 0x1010, "GameSir G7 SE", 0, XTYPE_XBOXONE }, + { 0x3651, 0x1000, "CRKD SG", 0, XTYPE_XBOX360 }, { 0x366c, 0x0005, "ByoWave Proteus Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE, FLAG_DELAY_INIT }, { 0x3767, 0x0101, "Fanatec Speedster 3 Forceshock Wheel", 0, XTYPE_XBOX }, { 0x37d7, 0x2501, "Flydigi Apex 5", 0, XTYPE_XBOX360 },
@@ -518,6 +521,7 @@ static const struct usb_device_id xpad_t*/ { USB_INTERFACE_INFO('X', 'B', 0) }, /* Xbox USB-IF not-approved class */XPAD_XBOX360_VENDOR (0x0079 ),/* GPD Win 2 controller */ +XPAD_XBOX360_VENDOR (0x0351 ),/* CRKD Controllers */ XPAD_XBOX360_VENDOR (0x03eb ),/* Wooting Keyboards (Legacy) */ XPAD_XBOX360_VENDOR (0x03f0 ),/* HP HyperX Xbox 360 controllers */ XPAD_XBOXONE_VENDOR(0x03f0), /* HP HyperX Xbox One controllers */
@@ -578,6 +582,7 @@ static const struct usb_device_id xpad_tXPAD_XBOXONE_VENDOR (0x3285 ),/* Nacon Evol-X */ XPAD_XBOX360_VENDOR (0x3537 ),/* GameSir Controllers */ XPAD_XBOXONE_VENDOR (0x3537 ),/* GameSir Controllers */ +XPAD_XBOX360_VENDOR (0x3651 ),/* CRKD Controllers */ XPAD_XBOXONE_VENDOR (0x366c ),/* ByoWave controllers */ XPAD_XBOX360_VENDOR (0x37d7 ),/* Flydigi Controllers */ XPAD_XBOX360_VENDOR(0x413d), /* Black Shark Green Ghost Controller */
Greg Kroah-Hartman
maintainerPATCH 149/430 Input: ti_am335x_tsc - fix off-by-one error in wire_order validation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junjie Cao <[email protected]>
commit 248d3a73a0167dce15ba100477c3e778c4787178 upstream.
The current validation 'wire_order[i] > ARRAY_SIZE(config_pins)' allows wire_order[i] to equal ARRAY_SIZE(config_pins), which causes out-of-bounds access when used as index in 'config_pins[wire_order[i]]'.
Since config_pins has 4 elements (indices 0-3), the valid range for wire_order should be 0-3. Fix the off-by-one error by using >= instead of > in the validation check.
--- drivers/input/touchscreen/ti_am335x_tsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/touchscreen/ti_am335x_tsc.c +1 -1
@@ -85,7 +85,7 @@ static int titsc_config_wires(struct tit wire_order[i] = ts_dev->config_inp[i] &0x0F ;if (WARN_ON (analog_line[i] >7 ))return -EINVAL ; -if (WARN_ON (wire_order[i] >ARRAY_SIZE (config_pins))) +if (WARN_ON (wire_order[i] >=ARRAY_SIZE (config_pins)))return -EINVAL ; }
Greg Kroah-Hartman
maintainerPATCH 150/430 Input: lkkbd - disable pending work before freeing device
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Minseong Kim <[email protected]>
commit e58c88f0cb2d8ed89de78f6f17409d29cfab6c5c upstream.
lkkbd_interrupt() schedules lk->tq via schedule_work(), and the work handler lkkbd_reinit() dereferences the lkkbd structure and its serio/input_dev fields.
lkkbd_disconnect() and error paths in lkkbd_connect() free the lkkbd structure without preventing the reinit work from being queued again until serio_close() returns. This can allow the work handler to run after the structure has been freed, leading to a potential use-after-free.
Use disable_work_sync() instead of cancel_work_sync() to ensure the reinit work cannot be re-queued, and call it both in lkkbd_disconnect() and in lkkbd_connect() error paths after serio_open().
--- drivers/input/keyboard/lkkbd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/input/keyboard/lkkbd.c +4 -1
@@ -670,7 +670,8 @@ static int lkkbd_connect(struct serio *sreturn 0 ; - fail3:serio_close (serio); + fail3:disable_work_sync (&lk->tq); +serio_close (serio); fail2:serio_set_drvdata (serio,NULL ); fail1:input_free_device (input_dev);kfree (lk);
@@ -684,6 +685,8 @@ static void lkkbd_disconnect(struct seri {struct lkkbd *lk =serio_get_drvdata (serio); +disable_work_sync (&lk->tq); +input_get_device (lk->dev);input_unregister_device (lk->dev);serio_close (serio);
Greg Kroah-Hartman
maintainerPATCH 151/430 Input: alps - fix use-after-free bugs caused by dev3_register_work
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Duoming Zhou <[email protected]>
commit bf40644ef8c8a288742fa45580897ed0e0289474 upstream.
The dev3_register_work delayed work item is initialized within alps_reconnect() and scheduled upon receipt of the first bare PS/2 packet from an external PS/2 device connected to the ALPS touchpad. During device detachment, the original implementation calls flush_workqueue() in psmouse_disconnect() to ensure completion of dev3_register_work. However, the flush_workqueue() in psmouse_disconnect() only blocks and waits for work items that were already queued to the workqueue prior to its invocation. Any work items submitted after flush_workqueue() is called are not included in the set of tasks that the flush operation awaits. This means that after flush_workqueue() has finished executing, the dev3_register_work could still be scheduled. Although the psmouse state is set to PSMOUSE_CMD_MODE in psmouse_disconnect(), the scheduling of dev3_register_work remains unaffected.
The race condition can occur as follows:
CPU 0 (cleanup path) | CPU 1 (delayed work)
psmouse_disconnect() |
psmouse_set_state() |
flush_workqueue() | alps_report_bare_ps2_packet()
alps_disconnect() | psmouse_queue_work()
kfree(priv); // FREE | alps_register_bare_ps2_mouse()
| priv = container_of(work...); // USE
| priv->dev3 // USEAdd disable_delayed_work_sync() in alps_disconnect() to ensure that dev3_register_work is properly canceled and prevented from executing after the alps_data structure has been deallocated.
This bug is identified by static analysis.
--- drivers/input/mouse/alps.c | 1 + 1 file changed, 1 insertion(+)
drivers/input/mouse/alps.c +1 -0
@@ -2975,6 +2975,7 @@ static void alps_disconnect(struct psmoupsmouse_reset (psmouse);timer_shutdown_sync (&priv->timer); +disable_delayed_work_sync (&priv->dev3_register_work);if (priv->dev2)input_unregister_device (priv->dev2);if (!IS_ERR_OR_NULL (priv->dev3))
Greg Kroah-Hartman
maintainerPATCH 152/430 Input: i8042 - add TUXEDO InfinityBook Max Gen10 AMD to i8042 quirk table
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoffer Sandberg <[email protected]>
commit aed3716db7fff74919cc5775ca3a80c8bb246489 upstream.
The device occasionally wakes up from suspend with missing input on the internal keyboard and the following suspend attempt results in an instant wake-up. The quirks fix both issues for this device.
--- drivers/input/serio/i8042-acpipnpio.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-acpipnpio.h +7 -0
@@ -1169,6 +1169,13 @@ static const struct dmi_system_id i8042_ .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) }, + { + .matches = { + DMI_MATCH(DMI_BOARD_NAME, "X5KK45xS_X5SP45xS"), + }, + .driver_data = (void *)(SERIO_QUIRK_NOMUX | SERIO_QUIRK_RESET_ALWAYS | + SERIO_QUIRK_NOLOOP | SERIO_QUIRK_NOPNP) + }, /* * A lot of modern Clevo barebones have touchpad and/or keyboard issues * after suspend fixable with the forcenorestore quirk.
Greg Kroah-Hartman
maintainerPATCH 153/430 xfs: dont leak a locked dquot when xfs_dquot_attach_buf fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
commit 204c8f77e8d4a3006f8abe40331f221a597ce608 upstream.
xfs_qm_quotacheck_dqadjust acquired the dquot through xfs_qm_dqget, which means it owns a reference and holds q_qlock. Both need to be dropped on an error exit.
--- fs/xfs/xfs_qm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/xfs/xfs_qm.c +3 -2
@@ -1318,7 +1318,7 @@ xfs_qm_quotacheck_dqadjust( error =xfs_dquot_attach_buf (NULL , dqp);if (error) -return error; + goto out_unlock;trace_xfs_dqadjust (dqp);
@@ -1348,8 +1348,9 @@ xfs_qm_quotacheck_dqadjust( } dqp->q_flags |=XFS_DQFLAG_DIRTY ; +out_unlock:xfs_qm_dqput (dqp); -return 0 ; +return error; }/*
Greg Kroah-Hartman
maintainerPATCH 154/430 can: gs_usb: gs_can_open(): fix error handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Kleine-Budde <[email protected]>
commit 3e54d3b4a8437b6783d4145c86962a2aa51022f3 upstream.
Commit 2603be9e8167 ("can: gs_usb: gs_can_open(): improve error handling") added missing error handling to the gs_can_open() function.
The driver uses 2 USB anchors to track the allocated URBs: the TX URBs in struct gs_can::tx_submitted for each netdev and the RX URBs in struct gs_usb::rx_submitted for the USB device. gs_can_open() allocates the RX URBs, while TX URBs are allocated during gs_can_start_xmit().
The cleanup in gs_can_open() kills all anchored dev->tx_submitted URBs (which is not necessary since the netdev is not yet registered), but misses the parent->rx_submitted URBs.
Fix the problem by killing the rx_submitted instead of the tx_submitted.
--- drivers/net/can/usb/gs_usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/usb/gs_usb.c +1 -1
@@ -1074,7 +1074,7 @@ out_usb_free_urb:usb_free_urb (urb); out_usb_kill_anchored_urbs:if (!parent->active_channels) { -usb_kill_anchored_urbs (&dev->tx_submitted); +usb_kill_anchored_urbs (&parent->rx_submitted);if (dev->feature &GS_CAN_FEATURE_HW_TIMESTAMP )gs_usb_timestamp_stop (parent);
Greg Kroah-Hartman
maintainerPATCH 155/430 soc/tegra: fuse: Do not register SoC device on ACPI boot
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kartik Rajput <[email protected]>
commit c87f820bc4748fdd4d50969e8930cd88d1b61582 upstream.
On Tegra platforms using ACPI, the SMCCC driver already registers the SoC device. This makes the registration performed by the Tegra fuse driver redundant.
When booted via ACPI, skip registering the SoC device and suppress printing SKU information from the Tegra fuse driver, as this information is already provided by the SMCCC driver.
--- drivers/soc/tegra/fuse/fuse-tegra.c | 2 -- 1 file changed, 2 deletions(-)
drivers/soc/tegra/fuse/fuse-tegra.c +0 -2
@@ -182,8 +182,6 @@ static int tegra_fuse_probe(struct platf } fuse->soc->init (fuse); -tegra_fuse_print_sku_info (&tegra_sku_info); -tegra_soc_device_register (); err =tegra_fuse_add_lookups (fuse);if (err)
Greg Kroah-Hartman
maintainerPATCH 156/430 platform/x86: intel_pmc_ipc: fix ACPI buffer memory leak
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongxin Liu <[email protected]>
commit 611cf41ef6ac8301d23daadd8e78b013db0c5071 upstream.
The intel_pmc_ipc() function uses ACPI_ALLOCATE_BUFFER to allocate memory for the ACPI evaluation result but never frees it, causing a 192-byte memory leak on each call.
This leak is triggered during network interface initialization when the stmmac driver calls intel_mac_finish() -> intel_pmc_ipc().
unreferenced object 0xffff96a848d6ea80 (size 192):
comm "dhcpcd", pid 541, jiffies 4294684345
hex dump (first 32 bytes):
04 00 00 00 05 00 00 00 98 ea d6 48 a8 96 ff ff ...........H....
00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 ................
backtrace (crc b1564374):
kmemleak_alloc+0x2d/0x40
__kmalloc_noprof+0x2fa/0x730
acpi_ut_initialize_buffer+0x83/0xc0
acpi_evaluate_object+0x29a/0x2f0
intel_pmc_ipc+0xfd/0x170
intel_mac_finish+0x168/0x230
stmmac_mac_finish+0x3d/0x50
phylink_major_config+0x22b/0x5b0
phylink_mac_initial_config.constprop.0+0xf1/0x1b0
phylink_start+0x8e/0x210
__stmmac_open+0x12c/0x2b0
stmmac_open+0x23c/0x380
__dev_open+0x11d/0x2c0
__dev_change_flags+0x1d2/0x250
netif_change_flags+0x2b/0x70
dev_change_flags+0x40/0xb0Add __free(kfree) for ACPI object to properly release the allocated buffer.
--- include/linux/platform_data/x86/intel_pmc_ipc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/platform_data/x86/intel_pmc_ipc.h +2 -2
@@ -9,6 +9,7 @@#ifndef INTEL_PMC_IPC_H #define INTEL_PMC_IPC_H #include <linux/acpi.h> +#include <linux/cleanup.h> #define IPC_SOC_REGISTER_ACCESS 0xAA#define IPC_SOC_SUB_CMD_READ 0x00
@@ -48,7 +49,6 @@ static inline int intel_pmc_ipc(struct p {.type = ACPI_TYPE_INTEGER,}, };struct acpi_object_list arg_list = {PMC_IPCS_PARAM_COUNT , params }; -union acpi_object *obj;int status;if (!ipc_cmd || !rbuf)
@@ -72,7 +72,7 @@ static inline int intel_pmc_ipc(struct pif (ACPI_FAILURE (status))return -ENODEV ; - obj = buffer.pointer; + union acpi_object *obj __free(kfree) = buffer.pointer;if (obj && obj->type ==ACPI_TYPE_PACKAGE && obj->package.count ==VALID_IPC_RESPONSE ) {
Greg Kroah-Hartman
maintainerPATCH 157/430 ACPI: PCC: Fix race condition by removing static qualifier
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengjie Zhang <[email protected]>
commit f103fa127c93016bcd89b05d8e11dc1a84f6990d upstream.
Local variable 'ret' in acpi_pcc_address_space_setup() is currently declared as 'static'. This can lead to race conditions in a multithreaded environment.
Remove the 'static' qualifier to ensure that 'ret' will be allocated directly on the stack as a local variable.
--- drivers/acpi/acpi_pcc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_pcc.c +1 -1
@@ -52,7 +52,7 @@ acpi_pcc_address_space_setup(acpi_handlestruct pcc_data *data;struct acpi_pcc_info *ctx = handler_context;struct pcc_mbox_chan *pcc_chan; -static acpi_status ret; +acpi_status ret; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)
Greg Kroah-Hartman
maintainerPATCH 158/430 ACPI: CPPC: Fix missing PCC check for guaranteed_perf
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengjie Zhang <[email protected]>
commit 6ea3a44cef28add2d93b1ef119d84886cb1e3c9b upstream.
The current implementation overlooks the 'guaranteed_perf' register in this check.
If the Guaranteed Performance register is located in the PCC subspace, the function currently attempts to read it without acquiring the lock and without sending the CMD_READ doorbell to the firmware. This can result in reading stale data.
--- drivers/acpi/cppc_acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/cppc_acpi.c +2 -1
@@ -1366,7 +1366,8 @@ int cppc_get_perf_caps(int cpunum, struc/* Are any of the regs PCC ?*/ if (CPC_IN_PCC (highest_reg) ||CPC_IN_PCC (lowest_reg) ||CPC_IN_PCC (lowest_non_linear_reg) ||CPC_IN_PCC (nominal_reg) || -CPC_IN_PCC (low_freq_reg) ||CPC_IN_PCC (nom_freq_reg)) { +CPC_IN_PCC (low_freq_reg) ||CPC_IN_PCC (nom_freq_reg) || +CPC_IN_PCC (guaranteed_reg)) {if (pcc_ss_id <0 ) {pr_debug ("Invalid pcc_ss_id\n" );return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 159/430 spi: fsl-cpm: Check length parity before switching to 16 bit mode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe Leroy <[email protected]>
commit 1417927df8049a0194933861e9b098669a95c762 upstream.
Commit fc96ec826bce ("spi: fsl-cpm: Use 16 bit mode for large transfers with even size") failed to make sure that the size is really even before switching to 16 bit mode. Until recently the problem went unnoticed because kernfs uses a pre-allocated bounce buffer of size PAGE_SIZE for reading EEPROM.
But commit 8ad6249c51d0 ("eeprom: at25: convert to spi-mem API") introduced an additional dynamically allocated bounce buffer whose size is exactly the size of the transfer, leading to a buffer overrun in the fsl-cpm driver when that size is odd.
Add the missing length parity verification and remain in 8 bit mode when the length is not even.
--- drivers/spi/spi-fsl-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi-fsl-spi.c +1 -1
@@ -335,7 +335,7 @@ static int fsl_spi_prepare_message(strucif (t->bits_per_word ==16 || t->bits_per_word ==32 ) t->bits_per_word =8 ;/* pretend its 8 bits */ if (t->bits_per_word ==8 && t->len >=256 && - (mpc8xxx_spi->flags &SPI_CPM1 )) + !(t->len &1 ) && (mpc8xxx_spi->flags &SPI_CPM1 )) t->bits_per_word =16 ; } }
Greg Kroah-Hartman
maintainerPATCH 160/430 mmc: sdhci-esdhc-imx: add alternate ARCH_S32 dependency to Kconfig
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jared Kangas <[email protected]>
commit d3ecb12e2e04ce53c95f933c462f2d8b150b965b upstream.
MMC_SDHCI_ESDHC_IMX requires ARCH_MXC despite also being used on ARCH_S32, which results in unmet dependencies when compiling strictly for ARCH_S32. Resolve this by adding ARCH_S32 as an alternative to ARCH_MXC in the driver's dependencies.
--- drivers/mmc/host/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/host/Kconfig +2 -2
@@ -315,14 +315,14 @@ config MMC_SDHCI_ESDHC_MCF config MMC_SDHCI_ESDHC_IMX tristate "SDHCI support for the Freescale eSDHC/uSDHC i.MX controller" - depends on ARCH_MXC || COMPILE_TEST + depends on ARCH_MXC || ARCH_S32 || COMPILE_TEST depends on MMC_SDHCI_PLTFM depends on OF select MMC_SDHCI_IO_ACCESSORS select MMC_CQHCI help This selects the Freescale eSDHC/uSDHC controller support - found on i.MX25, i.MX35 i.MX5x and i.MX6x. + found on i.MX25, i.MX35, i.MX5x, i.MX6x, and S32G. If you have a controller with this interface, say Y or M here.
Greg Kroah-Hartman
maintainerPATCH 161/430 mmc: sdhci-of-arasan: Increase CD stable timeout to 2 seconds
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sai Krishna Potthuri <[email protected]>
commit a9c4c9085ec8ce3ce01be21b75184789e74f5f19 upstream.
On Xilinx/AMD platforms, the CD stable bit take slightly longer than one second(about an additional 100ms) to assert after a host controller reset. Although no functional failure observed with the existing one second delay but to ensure reliable initialization, increase the CD stable timeout to 2 seconds.
--- drivers/mmc/host/sdhci-of-arasan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-arasan.c +1 -1
@@ -99,7 +99,7 @@#define HIWORD_UPDATE (val, mask, shift) \ ((val) << (shift) | (mask) << ((shift) + 16)) -#define CD_STABLE_TIMEOUT_US 1000000 +#define CD_STABLE_TIMEOUT_US 2000000#define CD_STABLE_MAX_SLEEP_US 10/**
Greg Kroah-Hartman
maintainerPATCH 162/430 dt-bindings: mmc: sdhci-of-aspeed: Switch ref to sdhci-common.yaml
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Jeffery <[email protected]>
commit ed724ea1b82a800af4704311cb89e5ef1b4ea7ac upstream.
Enable use of common SDHCI-related properties such as sdhci-caps-mask as found in the AST2600 EVB DTS.
--- Documentation/devicetree/bindings/mmc/aspeed,sdhci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/devicetree/bindings/mmc/aspeed,sdhci.yaml +1 -1
@@ -41,7 +41,7 @@ properties: patternProperties: "^sdhci@[0-9a-f]+$": type: object - $ref: mmc-controller.yaml + $ref: sdhci-common.yaml unevaluatedProperties: false properties:
Greg Kroah-Hartman
maintainerPATCH 163/430 net/hsr: fix NULL pointer dereference in prp_get_untagged_frame()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shaurya Rane <[email protected]>
commit 188e0fa5a679570ea35474575e724d8211423d17 upstream.
prp_get_untagged_frame() calls __pskb_copy() to create frame->skb_std but doesn't check if the allocation failed. If __pskb_copy() returns NULL, skb_clone() is called with a NULL pointer, causing a crash:
Oops: general protection fault, probably for non-canonical address 0xdffffc000000000f: 0000 [#1] SMP KASAN NOPTI KASAN: null-ptr-deref in range [0x0000000000000078-0x000000000000007f] CPU: 0 UID: 0 PID: 5625 Comm: syz.1.18 Not tainted syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:skb_clone+0xd7/0x3a0 net/core/skbuff.c:2041 Code: 03 42 80 3c 20 00 74 08 4c 89 f7 e8 23 29 05 f9 49 83 3e 00 0f 85 a0 01 00 00 e8 94 dd 9d f8 48 8d 6b 7e 49 89 ee 49 c1 ee 03 <43> 0f b6 04 26 84 c0 0f 85 d1 01 00 00 44 0f b6 7d 00 41 83 e7 0c RSP: 0018:ffffc9000d00f200 EFLAGS: 00010207 RAX: ffffffff892235a1 RBX: 0000000000000000 RCX: ffff88803372a480 RDX: 0000000000000000 RSI: 0000000000000820 RDI: 0000000000000000 RBP: 000000000000007e R08: ffffffff8f7d0f77 R09: 1ffffffff1efa1ee R10: dffffc0000000000 R11: fffffbfff1efa1ef R12: dffffc0000000000 R13: 0000000000000820 R14: 000000000000000f R15: ffff88805144cc00 FS: 0000555557f6d500(0000) GS:ffff88808d72f000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000555581d35808 CR3: 000000005040e000 CR4: 0000000000352ef0 Call Trace: <TASK> hsr_forward_do net/hsr/hsr_forward.c:-1 [inline] hsr_forward_skb+0x1013/0x2860 net/hsr/hsr_forward.c:741 hsr_handle_frame+0x6ce/0xa70 net/hsr/hsr_slave.c:84 __netif_receive_skb_core+0x10b9/0x4380 net/core/dev.c:5966 __netif_receive_skb_one_core net/core/dev.c:6077 [inline] __netif_receive_skb+0x72/0x380 net/core/dev.c:6192 netif_receive_skb_internal net/core/dev.c:6278 [inline] netif_receive_skb+0x1cb/0x790 net/core/dev.c:6337 tun_rx_batched+0x1b9/0x730 drivers/net/tun.c:1485 tun_get_user+0x2b65/0x3e90 drivers/net/tun.c:1953 tun_chr_write_iter+0x113/0x200 drivers/net/tun.c:1999 new_sync_write fs/read_write.c:593 [inline] vfs_write+0x5c9/0xb30 fs/read_write.c:686 ksys_write+0x145/0x250 fs/read_write.c:738 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7f0449f8e1ff Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 f9 92 02 00 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 31 44 89 c7 48 89 44 24 08 e8 4c 93 02 00 48 RSP: 002b:00007ffd7ad94c90 EFLAGS: 00000293 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 00007f044a1e5fa0 RCX: 00007f0449f8e1ff RDX: 000000000000003e RSI: 0000200000000500 RDI: 00000000000000c8 RBP: 00007ffd7ad94d20 R08: 0000000000000000 R09: 0000000000000000 R10: 000000000000003e R11: 0000000000000293 R12: 0000000000000001 R13: 00007f044a1e5fa0 R14: 00007f044a1e5fa0 R15: 0000000000000003 </TASK>
Add a NULL check immediately after __pskb_copy() to handle allocation failures gracefully.
--- net/hsr/hsr_forward.c | 2 ++ 1 file changed, 2 insertions(+)
net/hsr/hsr_forward.c +2 -0
@@ -205,6 +205,8 @@ struct sk_buff *prp_get_untagged_frame(s__pskb_copy (frame->skb_prp,skb_headroom (frame->skb_prp),GFP_ATOMIC ); +if (!frame->skb_std) +return NULL ; }else {/* Unexpected */ WARN_ONCE(1, "%s:%d: Unexpected frame received (port_src %s)\n",
Greg Kroah-Hartman
maintainerPATCH 164/430 x86/bug: Fix old GCC compile fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Zijlstra <[email protected]>
commit c56a12c71ad38f381105f6e5036dede64ad2dfee upstream.
For some mysterious reasons the GCC 8 and 9 preprocessor manages to sporadically fumble _ASM_BYTES(0x0f, 0x0b):
$ grep ".byte[ ]*0x0f" defconfig-build/drivers/net/wireless/realtek/rtlwifi/base.s
1: .byte0x0f,0x0b ;
1: .byte 0x0f,0x0b ;which makes the assembler upset and all that. While there are more _ASM_BYTES() users (notably the NOP instructions), those don't seem affected. Therefore replace the offending ASM_UD2 with one using the ud2 mnemonic.
--- arch/x86/include/asm/bug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/bug.h +1 -1
@@ -10,7 +10,7 @@/* * Despite that some emulators terminate on UD2, we use it for WARN(). */ -#define ASM_UD2 _ASM_BYTES(0x0f, 0x0b) +#define ASM_UD2 __ASM_FORM(ud2)#define INSN_UD2 0x0b0f#define LEN_UD2 2
Greg Kroah-Hartman
maintainerPATCH 165/430 x86/msi: Make irq_retrigger() functional for posted MSI
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 0edc78b82bea85e1b2165d8e870a5c3535919695 upstream.
Luigi reported that retriggering a posted MSI interrupt does not work correctly.
The reason is that the retrigger happens at the vector domain by sending an IPI to the actual vector on the target CPU. That works correctly exactly once because the posted MSI interrupt chip does not issue an EOI as that's only required for the posted MSI notification vector itself.
As a consequence the vector becomes stale in the ISR, which not only affects this vector but also any lower priority vector in the affected APIC because the ISR bit is not cleared.
Luigi proposed to set the vector in the remap PIR bitmap and raise the posted MSI notification vector. That works, but that still does not cure a related problem:
If there is ever a stray interrupt on such a vector, then the related APIC ISR bit becomes stale due to the lack of EOI as described above. Unlikely to happen, but if it happens it's not debuggable at all.
So instead of playing games with the PIR, this can be actually solved for both cases by:
1) Keeping track of the posted interrupt vector handler state
2) Implementing a posted MSI specific irq_ack() callback which checks that state. If the posted vector handler is inactive it issues an EOI, otherwise it delegates that to the posted handler.
This is correct versus affinity changes and concurrent events on the posted vector as the actual handler invocation is serialized through the interrupt descriptor lock.
--- arch/x86/include/asm/irq_remapping.h | 7 +++++++ arch/x86/kernel/irq.c | 23 +++++++++++++++++++++++ drivers/iommu/intel/irq_remapping.c | 8 ++++---- 3 files changed, 34 insertions(+), 4 deletions(-)
arch/x86/include/asm/irq_remapping.h +7 -0
@@ -87,4 +87,11 @@ static inline void panic_if_irq_remap(co }#endif /* CONFIG_IRQ_REMAP */ + +#ifdef CONFIG_X86_POSTED_MSI +void intel_ack_posted_msi_irq (struct irq_data *irqd); +#else +#define intel_ack_posted_msi_irq NULL +#endif +#endif /* __X86_IRQ_REMAPPING_H */
arch/x86/kernel/irq.c +23 -0
@@ -396,6 +396,7 @@ DEFINE_IDTENTRY_SYSVEC_SIMPLE(sysvec_kvm/* Posted Interrupt Descriptors for coalesced MSIs to be posted */ DEFINE_PER_CPU_ALIGNED(struct pi_desc, posted_msi_pi_desc); +static DEFINE_PER_CPU_CACHE_HOT(bool, posted_msi_handler_active);void intel_posted_msi_init (void ) {
@@ -413,6 +414,25 @@ void intel_posted_msi_init(void)this_cpu_write (posted_msi_pi_desc.ndst, destination); } +void intel_ack_posted_msi_irq (struct irq_data *irqd) +{ +irq_move_irq (irqd); + +/* +* Handle the rare case that irq_retrigger() raised the actual +* assigned vector on the target CPU, which means that it was not +* invoked via the posted MSI handler below. In that case APIC EOI +* is required as otherwise the ISR entry becomes stale and lower +* priority interrupts are never going to be delivered after that. +* +* If the posted handler invoked the device interrupt handler then +* the EOI would be premature because it would acknowledge the +* posted vector. +*/ +if (unlikely (!__this_cpu_read (posted_msi_handler_active))) +apic_eoi (); +} + static __always_inline bool handle_pending_pir(unsigned long *pir, struct pt_regs *regs) {unsigned long pir_copy[NR_PIR_WORDS ];
@@ -445,6 +465,8 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_posted_msi pid =this_cpu_ptr (&posted_msi_pi_desc); +/* Mark the handler active for intel_ack_posted_msi_irq() */ +__this_cpu_write (posted_msi_handler_active, true);inc_irq_stat (posted_msi_notification_count);irq_enter ();
@@ -473,6 +495,7 @@ DEFINE_IDTENTRY_SYSVEC(sysvec_posted_msiapic_eoi ();irq_exit (); +__this_cpu_write (posted_msi_handler_active, false); set_irq_regs(old_regs); }#endif /* X86_POSTED_MSI */
drivers/iommu/intel/irq_remapping.c +4 -4
@@ -1303,17 +1303,17 @@ static struct irq_chip intel_ir_chip = {* irq_enter(); * handle_edge_irq() * irq_chip_ack_parent() -* irq_move_irq(); // No EOI +* intel_ack_posted_msi_irq(); // No EOI * handle_irq_event() * driver_handler() * handle_edge_irq() * irq_chip_ack_parent() -* irq_move_irq(); // No EOI +* intel_ack_posted_msi_irq(); // No EOI * handle_irq_event() * driver_handler() * handle_edge_irq() * irq_chip_ack_parent() -* irq_move_irq(); // No EOI +* intel_ack_posted_msi_irq(); // No EOI * handle_irq_event() * driver_handler() * apic_eoi()
@@ -1322,7 +1322,7 @@ static struct irq_chip intel_ir_chip = {*/ static struct irq_chip intel_ir_chip_post_msi = { .name ="INTEL-IR-POST" , - .irq_ack = irq_move_irq, + .irq_ack = intel_ack_posted_msi_irq, .irq_set_affinity = intel_ir_set_affinity, .irq_compose_msi_msg = intel_ir_compose_msi_msg, .irq_set_vcpu_affinity = intel_ir_set_vcpu_affinity,
Greg Kroah-Hartman
maintainerPATCH 166/430 x86/fpu: Fix FPU state core dump truncation on CPUs with no extended xfeatures
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongxin Liu <[email protected]>
[ Upstream commit c8161e5304abb26e6c0bec6efc947992500fa6c5 ]
Zero can be a valid value of num_records. For example, on Intel Atom x6425RE, only x87 and SSE are supported (features 0, 1), and fpu_user_cfg.max_features is 3. The for_each_extended_xfeature() loop only iterates feature 2, which is not enabled, so num_records = 0. This is valid and should not cause core dump failure.
The issue is that dump_xsave_layout_desc() returns 0 for both genuine errors (dump_emit() failure) and valid cases (no extended features). Use negative return values for errors and only abort on genuine failures.
--- arch/x86/kernel/fpu/xstate.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/fpu/xstate.c +2 -2
@@ -1945,7 +1945,7 @@ static int dump_xsave_layout_desc(struct coredump_params *cprm) };if (!dump_emit (cprm, &xc,sizeof (xc))) -return 0 ; +return -1 ; num_records++; }
@@ -1983,7 +1983,7 @@ int elf_coredump_extra_notes_write(struct coredump_params *cprm)return 1 ; num_records =dump_xsave_layout_desc (cprm); -if (!num_records) +if (num_records <0 )return 1 ;/* Total size should be equal to the number of records */
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 167/430 x86/mm/tlb/trace: Export the TLB_REMOTE_WRONG_CPU enum in <trace/events/tlb.h>
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tal Zussman <[email protected]>
[ Upstream commit 8b62e64e6d30fa047b3aefb1a36e1f80c8acb3d2 ]
When the TLB_REMOTE_WRONG_CPU enum was introduced for the tlb_flush tracepoint, the enum was not exported to user-space. Add it to the appropriate macro definition to enable parsing by userspace tools, as per:
[ mingo: Capitalize IPI, etc. ]
--- include/trace/events/tlb.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
include/trace/events/tlb.h +3 -2
@@ -12,8 +12,9 @@ EM( TLB_FLUSH_ON_TASK_SWITCH, "flush on task switch" ) \ EM( TLB_REMOTE_SHOOTDOWN, "remote shootdown" ) \ EM( TLB_LOCAL_SHOOTDOWN, "local shootdown" ) \ - EM( TLB_LOCAL_MM_SHOOTDOWN, "local mm shootdown" ) \ -EMe (TLB_REMOTE_SEND_IPI ,"remote ipi send" ) + EM( TLB_LOCAL_MM_SHOOTDOWN, "local MM shootdown" ) \ + EM( TLB_REMOTE_SEND_IPI, "remote IPI send" ) \ +EMe (TLB_REMOTE_WRONG_CPU ,"remote wrong CPU" )/* * First define the enums in TLB_FLUSH_REASON to be exported to userspace
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 168/430 ASoC: fsl_sai: Constrain sample rates from audio PLLs only in master mode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chancel Liu <[email protected]>
[ Upstream commit 9f4d0899efd9892fc7514c9488270e1bb7dedd2b ]
If SAI works in master mode it will generate clocks for external codec from audio PLLs. Thus sample rates should be constrained according to audio PLL clocks. While SAI works in slave mode which means clocks are generated externally then constraints are independent of audio PLLs.
--- sound/soc/fsl/fsl_sai.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
sound/soc/fsl/fsl_sai.c +8 -2
@@ -917,8 +917,14 @@ static int fsl_sai_startup(struct snd_pcm_substream *substream, tx ? sai->dma_params_tx.maxburst : sai->dma_params_rx.maxburst); - ret =snd_pcm_hw_constraint_list (substream->runtime,0 , -SNDRV_PCM_HW_PARAM_RATE , &sai->constraint_rates); +if (sai->is_consumer_mode[tx]) + ret =snd_pcm_hw_constraint_list (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_RATE , + &fsl_sai_rate_constraints); +else + ret =snd_pcm_hw_constraint_list (substream->runtime,0 , +SNDRV_PCM_HW_PARAM_RATE , + &sai->constraint_rates);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 169/430 ALSA: vxpocket: Fix resource leak in vxpocket_probe error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 2a03b40deacbd293ac9aed0f9b11197dad54fe5f ]
When vxpocket_config() fails, vxpocket_probe() returns the error code directly without freeing the sound card resources allocated by snd_card_new(), which leads to a memory leak.
Add proper error handling to free the sound card and clear the allocation bit when vxpocket_config() fails.
--- sound/pcmcia/vx/vxpocket.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pcmcia/vx/vxpocket.c +7 -1
@@ -284,7 +284,13 @@ static int vxpocket_probe(struct pcmcia_device *p_dev) vxp->p_dev = p_dev; -return vxpocket_config (p_dev); + err =vxpocket_config (p_dev); +if (err <0 ) { + card_alloc &= ~(1 << i); +snd_card_free (card); +return err; + } +return 0 ; }static void vxpocket_detach (struct pcmcia_device *link)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 170/430 ALSA: pcmcia: Fix resource leak in snd_pdacf_probe error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 5032347c04ba7ff9ba878f262e075d745c06a2a8 ]
When pdacf_config() fails, snd_pdacf_probe() returns the error code directly without freeing the sound card resources allocated by snd_card_new(), which leads to a memory leak.
Add proper error handling to free the sound card and clear the card list entry when pdacf_config() fails.
--- sound/pcmcia/pdaudiocf/pdaudiocf.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/pcmcia/pdaudiocf/pdaudiocf.c +7 -1
@@ -131,7 +131,13 @@ static int snd_pdacf_probe(struct pcmcia_device *link) link->config_index =1 ; link->config_regs =PRESENT_OPTION ; -return pdacf_config (link); + err =pdacf_config (link); +if (err <0 ) { + card_list[i] =NULL ; +snd_card_free (card); +return err; + } +return 0 ; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 171/430 ALSA: usb-mixer: us16x08: validate meter packet indices
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shipei Qu <[email protected]>
[ Upstream commit 5526c1c6ba1d0913c7dfcbbd6fe1744ea7c55f1e ]
get_meter_levels_from_urb() parses the 64-byte meter packets sent by the device and fills the per-channel arrays meter_level[], comp_level[] and master_level[] in struct snd_us16x08_meter_store.
Currently the function derives the channel index directly from the meter packet (MUB2(meter_urb, s) - 1) and uses it to index those arrays without validating the range. If the packet contains a negative or out-of-range channel number, the driver may write past the end of these arrays.
Introduce a local channel variable and validate it before updating the arrays. We reject negative indices, limit meter_level[] and comp_level[] to SND_US16X08_MAX_CHANNELS, and guard master_level[] updates with ARRAY_SIZE(master_level).
--- sound/usb/mixer_us16x08.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
sound/usb/mixer_us16x08.c +14 -6
@@ -655,17 +655,25 @@ static void get_meter_levels_from_urb(int s, u8 *meter_urb) {int val =MUC2 (meter_urb, s) + (MUC3 (meter_urb, s) <<8 ); +int ch =MUB2 (meter_urb, s) -1 ; + +if (ch <0 ) +return ;if (MUA0 (meter_urb, s) ==0x61 &&MUA1 (meter_urb, s) ==0x02 &&MUA2 (meter_urb, s) ==0x04 &&MUB0 (meter_urb, s) ==0x62 ) { -if (MUC0 (meter_urb, s) ==0x72 ) - store->meter_level[MUB2 (meter_urb, s) -1 ] = val; -if (MUC0 (meter_urb, s) ==0xb2 ) - store->comp_level[MUB2 (meter_urb, s) -1 ] = val; +if (ch <SND_US16X08_MAX_CHANNELS ) { +if (MUC0 (meter_urb, s) ==0x72 ) + store->meter_level[ch] = val; +if (MUC0 (meter_urb, s) ==0xb2 ) + store->comp_level[ch] = val; + } }if (MUA0 (meter_urb, s) ==0x61 &&MUA1 (meter_urb, s) ==0x02 && -MUA2 (meter_urb, s) ==0x02 &&MUB0 (meter_urb, s) ==0x62 ) - store->master_level[MUB2 (meter_urb, s) -1 ] = val; +MUA2 (meter_urb, s) ==0x02 &&MUB0 (meter_urb, s) ==0x62 ) { +if (ch <ARRAY_SIZE (store->master_level)) + store->master_level[ch] = val; + } }/* Function to retrieve current meter values from the device.
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 172/430 ASoC: ak4458: remove the reset operation in probe and remove
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shengjiu Wang <[email protected]>
[ Upstream commit 00b960a83c764208b0623089eb70af3685e3906f ]
The reset_control handler has the reference count for usage, as there is reset operation in runtime suspend and resume, then reset operation in probe() would cause the reference count of reset not balanced.
Previously add reset operation in probe and remove is to fix the compile issue with !CONFIG_PM, as the driver has been update to use RUNTIME_PM_OPS(), so that change can be reverted.
--- sound/soc/codecs/ak4458.c | 4 ---- 1 file changed, 4 deletions(-)
sound/soc/codecs/ak4458.c +0 -4
@@ -783,16 +783,12 @@ static int ak4458_i2c_probe(struct i2c_client *i2c)pm_runtime_enable (&i2c->dev);regcache_cache_only (ak4458->regmap, true); -ak4458_reset (ak4458, false);return 0 ; }static void ak4458_i2c_remove (struct i2c_client *i2c) { -struct ak4458_priv *ak4458 =i2c_get_clientdata (i2c); - -ak4458_reset (ak4458, true);pm_runtime_disable (&i2c->dev); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 173/430 nfsd: fix memory leak in nfsd_create_serv error paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shardul Bankar <[email protected]>
[ Upstream commit df8d829bba3adcf3cc744c01d933b6fd7cf06e91 ]
When nfsd_create_serv() calls percpu_ref_init() to initialize nn->nfsd_net_ref, it allocates both a percpu reference counter and a percpu_ref_data structure (64 bytes). However, if the function fails later due to svc_create_pooled() returning NULL or svc_bind() returning an error, these allocations are not cleaned up, resulting in a memory leak.
The leak manifests as:
- Unreferenced percpu allocation (8 bytes per CPU)
- Unreferenced percpu_ref_data structure (64 bytes)
Fix this by adding percpu_ref_exit() calls in both error paths to properly clean up the percpu_ref_init() allocations.
This patch fixes the percpu_ref leak in nfsd_create_serv() seen as an auxiliary leak in syzbot report 099461f8558eb0a1f4f3; the prepare_creds() and vsock-related leaks in the same report remain to be addressed separately.
--- fs/nfsd/nfssvc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
fs/nfsd/nfssvc.c +4 -1
@@ -633,12 +633,15 @@ int nfsd_create_serv(struct net *net) serv =svc_create_pooled (nfsd_programs,ARRAY_SIZE (nfsd_programs), &nn->nfsd_svcstats, nfsd_max_blksize, nfsd); -if (serv ==NULL ) +if (serv ==NULL ) { +percpu_ref_exit (&nn->nfsd_net_ref);return -ENOMEM ; + } error =svc_bind (serv, net);if (error <0 ) {svc_destroy (&serv); +percpu_ref_exit (&nn->nfsd_net_ref);return error; }spin_lock (&nfsd_notifier_lock);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 174/430 ASoC: SDCA: support Q7.8 volume format
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuming Fan <[email protected]>
[ Upstream commit 1b0f3f9ee41ee2bdd206667f85ea2aa36dfe6e69 ]
The SDCA specification uses Q7.8 volume format.
This patch adds a field to indicate whether it is SDCA volume control and supports the volume settings.
Stable-dep-of: 095d62114182 ("ASoC: ops: fix snd_soc_get_volsw for sx controls")
--- include/sound/soc.h | 1 + sound/soc/sdca/sdca_asoc.c | 34 ++++++--------------- sound/soc/soc-ops.c | 62 +++++++++++++++++++++++++++++++------- 3 files changed, 61 insertions(+), 36 deletions(-)
include/sound/soc.h +1 -0
@@ -1225,6 +1225,7 @@ struct soc_mixer_control {unsigned int sign_bit; unsigned int invert:1; unsigned int autodisable:1; + unsigned int sdca_q78:1;#ifdef CONFIG_SND_SOC_TOPOLOGY struct snd_soc_dobj dobj;#endif
sound/soc/sdca/sdca_asoc.c +9 -25
@@ -795,7 +795,6 @@ static int control_limit_kctl(struct device *dev,struct sdca_control_range *range;int min, max, step;unsigned int *tlv; -int shift;if (control->type !=SDCA_CTL_DATATYPE_Q7P8DB )return 0 ;
@@ -814,37 +813,22 @@ static int control_limit_kctl(struct device *dev, min =sign_extend32 (min, control->nbits -1 ); max =sign_extend32 (max, control->nbits -1 ); -/* -* FIXME: Only support power of 2 step sizes as this can be supported -* by a simple shift. -*/ -if (hweight32 (step) !=1 ) { -dev_err (dev,"%s: %s: currently unsupported step size\n" , - entity->label, control->label); -return -EINVAL ; - } - -/* -* The SDCA volumes are in steps of 1/256th of a dB, a step down of -* 64 (shift of 6) gives 1/4dB. 1/4dB is the smallest unit that is also -* representable in the ALSA TLVs which are in 1/100ths of a dB. -*/ - shift =max (ffs (step) -1 ,6 ); - tlv =devm_kcalloc (dev,4 ,sizeof (*tlv),GFP_KERNEL );if (!tlv)return -ENOMEM ; - tlv[0 ] =SNDRV_CTL_TLVT_DB_SCALE ; + tlv[0 ] =SNDRV_CTL_TLVT_DB_MINMAX ; tlv[1 ] =2 *sizeof (*tlv); tlv[2 ] = (min *100 ) >>8 ; - tlv[3 ] = ((1 << shift) *100 ) >>8 ; + tlv[3 ] = (max *100 ) >>8 ; + + step = (step *100 ) >>8 ; - mc->min = min >> shift; - mc->max = max >> shift; - mc->shift = shift; - mc->rshift = shift; - mc->sign_bit =15 - shift; + mc->min = ((int )tlv[2 ] / step); + mc->max = ((int )tlv[3 ] / step); + mc->shift = step; + mc->sign_bit =15 ; + mc->sdca_q78 =1 ; kctl->tlv.p = tlv; kctl->access |=SNDRV_CTL_ELEM_ACCESS_TLV_READ ;
sound/soc/soc-ops.c +51 -11
111 lines not on this page · raw message
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 175/430 ASoC: ops: fix snd_soc_get_volsw for sx controls
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Binding <[email protected]>
[ Upstream commit 095d621141826a2841dae85b52c784c147ea99d3 ]
SX controls are currently broken, since the clamp introduced in commit a0ce874cfaaa ("ASoC: ops: improve snd_soc_get_volsw") does not handle SX controls, for example where the min value in the clamp is greater than the max value in the clamp.
Add clamp parameter to prevent clamping in SX controls.
The nature of SX controls mean that it wraps around 0, with a variable number of bits, therefore clamping the value becomes complicated and prone to error.
Fixes 35 kunit tests for soc_ops_test_access.
--- sound/soc/soc-ops.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
sound/soc/soc-ops.c +20 -12
@@ -111,7 +111,8 @@ int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,EXPORT_SYMBOL_GPL (snd_soc_put_enum_double);static int sdca_soc_q78_reg_to_ctl (struct soc_mixer_control *mc,unsigned int reg_val, -unsigned int mask,unsigned int shift,int max) +unsigned int mask,unsigned int shift,int max, +bool sx) {int val = reg_val;
@@ -141,20 +142,26 @@ static unsigned int sdca_soc_q78_ctl_to_reg(struct soc_mixer_control *mc, int va }static int soc_mixer_reg_to_ctl (struct soc_mixer_control *mc,unsigned int reg_val, -unsigned int mask,unsigned int shift,int max) +unsigned int mask,unsigned int shift,int max, +bool sx) {int val = (reg_val >> shift) & mask;if (mc->sign_bit) val =sign_extend32 (val, mc->sign_bit); - val =clamp (val, mc->min, mc->max); - val -= mc->min; +if (sx) { + val -= mc->min;// SX controls intentionally can overflow here + val = min_t(unsigned int, val & mask, max); + }else { + val =clamp (val, mc->min, mc->max); + val -= mc->min; + }if (mc->invert) val = max - val; -return val & mask; +return val; } static unsigned int soc_mixer_ctl_to_reg(struct soc_mixer_control *mc, int val,
@@ -280,9 +287,10 @@ static int soc_put_volsw(struct snd_kcontrol *kcontrol,static int soc_get_volsw (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol, -struct soc_mixer_control *mc,int mask,int max) +struct soc_mixer_control *mc,int mask,int max,bool sx) { -int (*reg_to_ctl)(struct soc_mixer_control *,unsigned int ,unsigned int ,unsigned int ,int ); +int (*reg_to_ctl)(struct soc_mixer_control *,unsigned int ,unsigned int , +unsigned int ,int ,bool );struct snd_soc_component *component =snd_kcontrol_chip (kcontrol);unsigned int reg_val;int val;
@@ -293,16 +301,16 @@ static int soc_get_volsw(struct snd_kcontrol *kcontrol, reg_to_ctl = soc_mixer_reg_to_ctl; reg_val =snd_soc_component_read (component, mc->reg); - val =reg_to_ctl (mc, reg_val, mask, mc->shift, max); + val =reg_to_ctl (mc, reg_val, mask, mc->shift, max, sx); ucontrol->value.integer.value[0 ] = val;if (snd_soc_volsw_is_stereo (mc)) {if (mc->reg == mc->rreg) { - val =reg_to_ctl (mc, reg_val, mask, mc->rshift, max); + val =reg_to_ctl (mc, reg_val, mask, mc->rshift, max, sx); }else { reg_val =snd_soc_component_read (component, mc->rreg); - val =reg_to_ctl (mc, reg_val, mask, mc->shift, max); + val =reg_to_ctl (mc, reg_val, mask, mc->shift, max, sx); } ucontrol->value.integer.value[1 ] = val;
@@ -371,7 +379,7 @@ int snd_soc_get_volsw(struct snd_kcontrol *kcontrol, (struct soc_mixer_control *)kcontrol->private_value;unsigned int mask =soc_mixer_mask (mc); -return soc_get_volsw (kcontrol, ucontrol, mc, mask, mc->max - mc->min); +return soc_get_volsw (kcontrol, ucontrol, mc, mask, mc->max - mc->min, false); }EXPORT_SYMBOL_GPL (snd_soc_get_volsw);
@@ -413,7 +421,7 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, (struct soc_mixer_control *)kcontrol->private_value;unsigned int mask =soc_mixer_sx_mask (mc); -return soc_get_volsw (kcontrol, ucontrol, mc, mask, mc->max); +return soc_get_volsw (kcontrol, ucontrol, mc, mask, mc->max, true); }EXPORT_SYMBOL_GPL (snd_soc_get_volsw_sx);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 176/430 ipmi: Fix the race between __scan_channels() and deliver_response()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinhui Guo <[email protected]>
[ Upstream commit 936750fdba4c45e13bbd17f261bb140dd55f5e93 ]
The race window between __scan_channels() and deliver_response() causes the parameters of some channels to be set to 0.
1.[CPUA] __scan_channels() issues an IPMI request and waits with
wait_event() until all channels have been scanned. wait_event() internally calls might_sleep(), which might yield the CPU. (Moreover, an interrupt can preempt wait_event() and force the task to yield the CPU.)
2.[CPUB] deliver_response() is invoked when the CPU receives the
IPMI response. After processing a IPMI response, deliver_response() directly assigns intf->wchannels to intf->channel_list and sets intf->channels_ready to true. However, not all channels are actually ready for use.
3.[CPUA] Since intf->channels_ready is already true, wait_event()
never enters __wait_event(). __scan_channels() immediately clears intf->null_user_handler and exits.
4.[CPUB] Once intf->null_user_handler is set to NULL, deliver_response()
ignores further IPMI responses, leaving the remaining channels zero-initialized and unusable.
CPUA CPUB
------------------------------- ----------------------------- __scan_channels()
intf->null_user_handler
= channel_handler;
send_channel_info_cmd(intf,
0);
wait_event(intf->waitq,
intf->channels_ready);
do {
might_sleep();
deliver_response()
channel_handler()
intf->channel_list =
intf->wchannels + set;
intf->channels_ready = true;
send_channel_info_cmd(intf,
intf->curr_channel);
if (condition)
break;
__wait_event(wq_head,
condition);
} while(0)
intf->null_user_handler
= NULL;
deliver_response()
if (!msg->user)
if (intf->null_user_handler)
rv = -EINVAL;
return rv;------------------------------- -----------------------------
Fix the race between __scan_channels() and deliver_response() by deferring both the assignment intf->channel_list = intf->wchannels and the flag intf->channels_ready = true until all channels have been successfully scanned or until the IPMI request has failed.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 2 -- 1 file changed, 2 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +0 -2
@@ -3417,8 +3417,6 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg) intf->channels_ready = true;wake_up (&intf->waitq); }else { - intf->channel_list = intf->wchannels + set; - intf->channels_ready = true; rv =send_channel_info_cmd (intf, intf->curr_channel); }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 177/430 ipmi: Fix __scan_channels() failing to rescan channels
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinhui Guo <[email protected]>
[ Upstream commit 6bd30d8fc523fb880b4be548e8501bc0fe8f42d4 ]
channel_handler() sets intf->channels_ready to true but never clears it, so __scan_channels() skips any rescan. When the BMC firmware changes a rescan is required. Allow it by clearing the flag before starting a new scan.
Message-ID: <[email protected]>
--- drivers/char/ipmi/ipmi_msghandler.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/char/ipmi/ipmi_msghandler.c +13 -5
@@ -599,7 +599,8 @@ static void __ipmi_bmc_unregister(struct ipmi_smi *intf);static int __ipmi_bmc_register (struct ipmi_smi *intf,struct ipmi_device_id *id,bool guid_set,guid_t *guid,int intf_num); -static int __scan_channels (struct ipmi_smi *intf,struct ipmi_device_id *id); +static int __scan_channels (struct ipmi_smi *intf, +struct ipmi_device_id *id,bool rescan);static void free_ipmi_user (struct kref *ref) {
@@ -2668,7 +2669,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc,if (__ipmi_bmc_register (intf, &id, guid_set, &guid, intf_num))need_waiter (intf);/* Retry later on an error. */ else -__scan_channels (intf, &id); +__scan_channels (intf, &id, false);if (!intf_set) {
@@ -2688,7 +2689,7 @@ static int __bmc_get_device_id(struct ipmi_smi *intf, struct bmc_device *bmc, goto out_noprocessing; }else if (memcmp (&bmc->fetch_id, &bmc->id,sizeof (bmc->id)))/* Version info changes, scan the channels again. */ -__scan_channels (intf, &bmc->fetch_id); +__scan_channels (intf, &bmc->fetch_id, true); bmc->dyn_id_expiry = jiffies +IPMI_DYN_DEV_ID_EXPIRY ;
@@ -3438,10 +3439,17 @@ channel_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg)/* * Must be holding intf->bmc_reg_mutex to call this. */ -static int __scan_channels (struct ipmi_smi *intf,struct ipmi_device_id *id) +static int __scan_channels (struct ipmi_smi *intf, +struct ipmi_device_id *id, +bool rescan) {int rv; +if (rescan) { +/* Clear channels_ready to force channels rescan. */ + intf->channels_ready = false; + } +if (ipmi_version_major (id) >1 || (ipmi_version_major (id) ==1 &&ipmi_version_minor (id) >=5 )) {
@@ -3656,7 +3664,7 @@ int ipmi_add_smi(struct module *owner, }mutex_lock (&intf->bmc_reg_mutex); - rv =__scan_channels (intf, &id); + rv =__scan_channels (intf, &id, false);mutex_unlock (&intf->bmc_reg_mutex);if (rv) goto out_err_bmc_reg;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 178/430 scsi: ufs: host: mediatek: Fix shutdown/suspend race condition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Wang <[email protected]>
[ Upstream commit 014de20bb36ba03e0e0b0a7e0a1406ab900c9fda ]
Address a race condition between shutdown and suspend operations in the UFS Mediatek driver. Before entering suspend, check if a shutdown is in progress to prevent conflicts and ensure system stability.
--- drivers/ufs/host/ufs-mediatek.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/ufs/host/ufs-mediatek.c +5 -0
@@ -2373,6 +2373,11 @@ static int ufs_mtk_system_suspend(struct device *dev)struct arm_smccc_res res;int ret; +if (hba->shutting_down) { + ret = -EBUSY ; + goto out; + } + ret =ufshcd_system_suspend (dev);if (ret) goto out;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 179/430 firmware: imx: scu-irq: Init workqueue before request mbox channel
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peng Fan <[email protected]>
[ Upstream commit 81fb53feb66a3aefbf6fcab73bb8d06f5b0c54ad ]
With mailbox channel requested, there is possibility that interrupts may come in, so need to make sure the workqueue is initialized before the queue is scheduled by mailbox rx callback.
--- drivers/firmware/imx/imx-scu-irq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/imx/imx-scu-irq.c +2 -2
@@ -214,6 +214,8 @@ int imx_scu_enable_general_irq_channel(struct device *dev) cl->dev = dev; cl->rx_callback = imx_scu_irq_callback; +INIT_WORK (&imx_sc_irq_work, imx_scu_irq_work_handler); +/* SCU general IRQ uses general interrupt channel 3 */ ch =mbox_request_channel_byname (cl,"gip3" );if (IS_ERR (ch)) {
@@ -223,8 +225,6 @@ int imx_scu_enable_general_irq_channel(struct device *dev)return ret; } -INIT_WORK (&imx_sc_irq_work, imx_scu_irq_work_handler); -if (!of_parse_phandle_with_args (dev->of_node,"mboxes" ,"#mbox-cells" ,0 , &spec)) { i =of_alias_get_id (spec.np,"mu" );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 180/430 um: init cpu_tasks[] earlier
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 7b5d4416964c07c902163822a30a622111172b01 ]
This is currently done in uml_finishsetup(), but e.g. with KCOV enabled we'll crash because some init code can call into e.g. memparse(), which has coverage annotations, and then the checks in check_kcov_mode() crash because current is NULL.
Simply initialize the cpu_tasks[] array statically, which fixes the crash. For the later SMP work, it seems to have not really caused any problems yet, but initialize all of the entries anyway.
--- arch/um/kernel/process.c | 4 +++- arch/um/kernel/um_arch.c | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-)
arch/um/kernel/process.c +3 -1
@@ -43,7 +43,9 @@* cares about its entry, so it's OK if another processor is modifying its * entry. */ -struct task_struct *cpu_tasks[NR_CPUS ]; +struct task_struct *cpu_tasks[NR_CPUS ] = { + [0 ...NR_CPUS -1 ] = &init_task, +};EXPORT_SYMBOL (cpu_tasks);void free_stack (unsigned long stack,int order)
arch/um/kernel/um_arch.c +0 -2
@@ -239,8 +239,6 @@ static struct notifier_block panic_exit_notifier = {void uml_finishsetup (void ) { - cpu_tasks[0 ] = &init_task; -atomic_notifier_chain_register (&panic_notifier_list, &panic_exit_notifier);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 181/430 ti-sysc: allow OMAP2 and OMAP4 timers to be reserved on AM33xx
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthias Schiffer <[email protected]>
[ Upstream commit 3f61783920504b2cf99330b372d82914bb004d8e ]
am33xx.dtsi has the same clock setup as am35xx.dtsi, setting ti,no-reset-on-init and ti,no-idle on timer1_target and timer2_target, so AM33 needs the same workaround as AM35 to avoid ti-sysc probe failing on certain target modules.
--- drivers/bus/ti-sysc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/bus/ti-sysc.c +9 -2
@@ -48,6 +48,7 @@ enum sysc_soc {SOC_UNKNOWN ,SOC_2420 ,SOC_2430 , +SOC_AM33 ,SOC_3430 ,SOC_AM35 , SOC_3630,
@@ -2912,6 +2913,7 @@ static void ti_sysc_idle(struct work_struct *work)static const struct soc_device_attribute sysc_soc_match[] = {SOC_FLAG ("OMAP242*" ,SOC_2420 ),SOC_FLAG ("OMAP243*" ,SOC_2430 ), +SOC_FLAG ("AM33*" ,SOC_AM33 ),SOC_FLAG ("AM35*" ,SOC_AM35 ),SOC_FLAG ("OMAP3[45]*" ,SOC_3430 ),SOC_FLAG ("OMAP3[67]*" ,SOC_3630 ),
@@ -3117,10 +3119,15 @@ static int sysc_check_active_timer(struct sysc *ddata)* can be dropped if we stop supporting old beagleboard revisions * A to B4 at some point. */ -if (sysc_soc->soc ==SOC_3430 || sysc_soc->soc ==SOC_AM35 ) +switch (sysc_soc->soc) { +case SOC_AM33 : +case SOC_3430 : +case SOC_AM35 : error = -ENXIO ; -else +break ; +default : error = -EBUSY ; + }if ((ddata->cfg.quirks &SYSC_QUIRK_NO_RESET_ON_INIT ) && (ddata->cfg.quirks &SYSC_QUIRK_NO_IDLE ))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 182/430 scsi: smartpqi: Add support for Hurray Data new controller PCI device
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Strahan <[email protected]>
[ Upstream commit 48e6b7e708029cea451e53a8c16fc8c16039ecdc ]
Add support for new Hurray Data controller.
All entries are in HEX.
Add PCI IDs for Hurray Data controllers:
VID / DID / SVID / SDID
---- ---- ---- ----
9005 028f 207d 4840--- drivers/scsi/smartpqi/smartpqi_init.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/scsi/smartpqi/smartpqi_init.c +4 -0
@@ -10127,6 +10127,10 @@ static const struct pci_device_id pqi_pci_id_table[] = {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,0x207d ,0x4240 ) }, + { +PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f , +0x207d ,0x4840 ) + }, {PCI_DEVICE_SUB (PCI_VENDOR_ID_ADAPTEC2 ,0x028f ,PCI_VENDOR_ID_ADVANTECH ,0x8312 )
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 183/430 scsi: lpfc: Fix reusing an ndlp that is marked NLP_DROPPED during FLOGI
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit 07caedc6a3887938813727beafea40f07c497705 ]
It's possible for an unstable link to repeatedly bounce allowing a FLOGI retry, but then bounce again forcing an abort of the FLOGI. Ensure that the initial reference count on the FLOGI ndlp is restored in this faulty link scenario.
--- drivers/scsi/lpfc/lpfc_els.c | 36 +++++++++++++++++++++++++------- drivers/scsi/lpfc/lpfc_hbadisc.c | 4 +++- 2 files changed, 32 insertions(+), 8 deletions(-)
drivers/scsi/lpfc/lpfc_els.c +29 -7
@@ -934,10 +934,15 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,/* Check to see if link went down during discovery */ if (lpfc_els_chk_latt (vport)) {/* One additional decrement on node reference count to -* trigger the release of the node +* trigger the release of the node. Make sure the ndlp +* is marked NLP_DROPPED. */ -if (!(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) +if (!test_bit (NLP_IN_DEV_LOSS , &ndlp->nlp_flag) && + !test_bit (NLP_DROPPED , &ndlp->nlp_flag) && + !(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) { +set_bit (NLP_DROPPED , &ndlp->nlp_flag);lpfc_nlp_put (ndlp); + } goto out; }
@@ -995,9 +1000,10 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb, IOERR_LOOP_OPEN_FAILURE))) lpfc_vlog_msg(vport, KERN_WARNING, LOG_ELS,"2858 FLOGI Status:x%x/x%x TMO" -":x%x Data x%lx x%x\n" , +":x%x Data x%lx x%x x%lx x%x\n" , ulp_status, ulp_word4, tmo, - phba->hba_flag, phba->fcf.fcf_flag); + phba->hba_flag, phba->fcf.fcf_flag, + ndlp->nlp_flag, ndlp->fc4_xpt_flags);/* Check for retry */ if (lpfc_els_retry (phba, cmdiocb, rspiocb)) {
@@ -1015,14 +1021,17 @@ lpfc_cmpl_els_flogi(struct lpfc_hba *phba, struct lpfc_iocbq *cmdiocb,* reference to trigger node release. */ if (!test_bit (NLP_IN_DEV_LOSS , &ndlp->nlp_flag) && - !(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) + !test_bit (NLP_DROPPED , &ndlp->nlp_flag) && + !(ndlp->fc4_xpt_flags &SCSI_XPT_REGD )) { +set_bit (NLP_DROPPED , &ndlp->nlp_flag);lpfc_nlp_put (ndlp); + }lpfc_printf_vlog (vport,KERN_WARNING ,LOG_ELS ,"0150 FLOGI Status:x%x/x%x " -"xri x%x TMO:x%x refcnt %d\n" , +"xri x%x iotag x%x TMO:x%x refcnt %d\n" , ulp_status, ulp_word4, cmdiocb->sli4_xritag, - tmo,kref_read (&ndlp->kref)); + cmdiocb->iotag, tmo,kref_read (&ndlp->kref));/* If this is not a loop open failure, bail out */ if (!(ulp_status == IOSTAT_LOCAL_REJECT &&
@@ -1279,6 +1288,19 @@ lpfc_issue_els_flogi(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp,uint32_t tmo, did;int rc; +/* It's possible for lpfc to reissue a FLOGI on an ndlp that is marked +* NLP_DROPPED. This happens when the FLOGI completed with the XB bit +* set causing lpfc to reference the ndlp until the XRI_ABORTED CQE is +* issued. The time window for the XRI_ABORTED CQE can be as much as +* 2*2*RA_TOV allowing for ndlp reuse of this type when the link is +* cycling quickly. When true, restore the initial reference and remove +* the NLP_DROPPED flag as lpfc is retrying. +*/ +if (test_and_clear_bit (NLP_DROPPED , &ndlp->nlp_flag)) { +if (!lpfc_nlp_get (ndlp)) +return 1 ; + } + cmdsize = (sizeof (uint32_t ) +sizeof (struct serv_parm )); elsiocb =lpfc_prep_els_iocb (vport,1 , cmdsize, retry, ndlp, ndlp->nlp_DID,ELS_CMD_FLOGI );
drivers/scsi/lpfc/lpfc_hbadisc.c +3 -1
@@ -424,6 +424,7 @@ lpfc_check_nlp_post_devloss(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp) {if (test_and_clear_bit (NLP_IN_RECOV_POST_DEV_LOSS , &ndlp->save_flags)) { +clear_bit (NLP_DROPPED , &ndlp->nlp_flag);lpfc_nlp_get (ndlp);lpfc_printf_vlog (vport,KERN_INFO ,LOG_DISCOVERY |LOG_NODE , "8438 Devloss timeout reversed on DID x%x "
@@ -566,7 +567,8 @@ lpfc_dev_loss_tmo_handler(struct lpfc_nodelist *ndlp)return fcf_inuse; } -lpfc_nlp_put (ndlp); +if (!test_and_set_bit (NLP_DROPPED , &ndlp->nlp_flag)) +lpfc_nlp_put (ndlp);return fcf_inuse; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 184/430 clk: mvebu: cp110 add CLK_IGNORE_UNUSED to pcie_x10, pcie_x11 & pcie_x4
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josua Mayer <[email protected]>
[ Upstream commit f0e6bc0c3ef4b4afb299bd6912586cafd5d864e9 ]
CP110 based platforms rely on the bootloader for pci port initialization.
TF-A actively prevents non-uboot re-configuration of pci lanes, and many boards do not have software control over the pci card reset.
If a pci port had link at boot-time and the clock is stopped at a later point, the link fails and can not be recovered.
PCI controller driver probe - and by extension ownership of a driver for the pci clocks - may be delayed especially on large modular kernels, causing the clock core to start disabling unused clocks.
Add the CLK_IGNORE_UNUSED flag to the three pci port's clocks to ensure they are not stopped before the pci controller driver has taken ownership and tested for an existing link.
This fixes failed pci link detection when controller driver probes late, e.g. with arm64 defconfig and CONFIG_PHY_MVEBU_CP110_COMPHY=m.
--- drivers/clk/mvebu/cp110-system-controller.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
drivers/clk/mvebu/cp110-system-controller.c +20 -0
@@ -110,6 +110,25 @@ static const char * const gate_base_names[] = { [CP110_GATE_EIP197 ] ="eip197" }; +static unsigned long gate_flags (const u8 bit_idx) +{ +switch (bit_idx) { +case CP110_GATE_PCIE_X1_0 : +case CP110_GATE_PCIE_X1_1 : +case CP110_GATE_PCIE_X4 : +/* +* If a port had an active link at boot time, stopping +* the clock creates a failed state from which controller +* driver can not recover. +* Prevent stopping this clock till after a driver has taken +* ownership. +*/ +return CLK_IGNORE_UNUSED ; +default : +return 0 ; + } +}; +struct cp110_gate_clk {struct clk_hw hw;struct regmap *regmap;
@@ -171,6 +190,7 @@ static struct clk_hw *cp110_register_gate(const char *name, init.ops = &cp110_gate_ops; init.parent_names = &parent_name; init.num_parents =1 ; + init.flags =gate_flags (bit_idx); gate->regmap = regmap; gate->bit_idx = bit_idx;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 185/430 powerpc/addnote: Fix overflow on 32-bit builds
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ben Collins <[email protected]>
[ Upstream commit 825ce89a3ef17f84cf2c0eacfa6b8dc9fd11d13f ]
The PUT_64[LB]E() macros need to cast the value to unsigned long long like the GET_64[LB]E() macros. Caused lots of warnings when compiled on 32-bit, and clobbered addresses (36-bit P4080).
--- arch/powerpc/boot/addnote.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/powerpc/boot/addnote.c +4 -3
@@ -68,8 +68,8 @@ static int e_class = ELFCLASS32;#define PUT_16BE (off, v)(buf[off] = ((v) >> 8) & 0xff, \ buf[(off) + 1] = (v) & 0xff)#define PUT_32BE (off, v)(PUT_16BE((off), (v) >> 16L), PUT_16BE((off) + 2, (v))) -#define PUT_64BE (off, v)((PUT_32BE((off), (v) >> 32L), \ - PUT_32BE((off) + 4, (v)))) +#define PUT_64BE (off, v)((PUT_32BE((off), (unsigned long long)(v) >> 32L), \ + PUT_32BE((off) + 4, (unsigned long long)(v))))#define GET_16LE (off) ((buf[off]) + (buf[(off)+1] << 8))#define GET_32LE (off) (GET_16LE(off) + (GET_16LE((off)+2U) << 16U))
@@ -78,7 +78,8 @@ static int e_class = ELFCLASS32;#define PUT_16LE (off, v) (buf[off] = (v) & 0xff, \ buf[(off) + 1] = ((v) >> 8) & 0xff)#define PUT_32LE (off, v) (PUT_16LE((off), (v)), PUT_16LE((off) + 2, (v) >> 16L)) -#define PUT_64LE (off, v) (PUT_32LE((off), (v)), PUT_32LE((off) + 4, (v) >> 32L)) +#define PUT_64LE (off, v) (PUT_32LE((off), (unsigned long long)(v)), \ + PUT_32LE((off) + 4, (unsigned long long)(v) >> 32L))#define GET_16 (off) (e_data == ELFDATA2MSB ? GET_16BE(off) : GET_16LE(off))#define GET_32 (off) (e_data == ELFDATA2MSB ? GET_32BE(off) : GET_32LE(off))
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 186/430 scsi: qla2xxx: Fix lost interrupts with qlini_mode=disabled
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
[ Upstream commit 4f6aaade2a22ac428fa99ed716cf2b87e79c9837 ]
When qla2xxx is loaded with qlini_mode=disabled, ha->flags.disable_msix_handshake is used before it is set, resulting in the wrong interrupt handler being used on certain HBAs (qla2xxx_msix_rsp_q_hs() is used when qla2xxx_msix_rsp_q() should be used). The only difference between these two interrupt handlers is that the _hs() version writes to a register to clear the "RISC" interrupt, whereas the other version does not. So this bug results in the RISC interrupt being cleared when it should not be. This occasionally causes a different interrupt handler qla24xx_msix_default() for a different vector to see ((stat & HSRX_RISC_INT) == 0) and ignore its interrupt, which then causes problems like:
qla2xxx [0000:02:00.0]-d04c:6: MBX Command timeout for cmd 20,
iocontrol=8 jiffies=1090c0300 mb[0-3]=[0x4000 0x0 0x40 0xda] mb7 0x500 host_status 0x40000010 hccr 0x3f00
qla2xxx [0000:02:00.0]-101e:6: Mailbox cmd timeout occurred, cmd=0x20,
mb[0]=0x20. Scheduling ISP abort
(the cmd varies; sometimes it is 0x20, 0x22, 0x54, 0x5a, 0x5d, or 0x6a)
This problem can be reproduced with a 16 or 32 Gbps HBA by loading qla2xxx with qlini_mode=disabled and running a high IOPS test while triggering frequent RSCN database change events.
While analyzing the problem I discovered that even with disable_msix_handshake forced to 0, it is not necessary to clear the RISC interrupt from qla2xxx_msix_rsp_q_hs() (more below). So just completely remove qla2xxx_msix_rsp_q_hs() and the logic for selecting it, which also fixes the bug with qlini_mode=disabled.
The test below describes the justification for not needing qla2xxx_msix_rsp_q_hs():
Force disable_msix_handshake to 0:qla24xx_config_rings():
if (0 && (ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) &&
(ha->flags.msix_enabled)) {In qla24xx_msix_rsp_q() and qla2xxx_msix_rsp_q_hs(), check:
(rd_reg_dword(®->host_status) & HSRX_RISC_INT)
Count the number of calls to each function with HSRX_RISC_INT set and the number with HSRX_RISC_INT not set while performing some I/O.
If qla2xxx_msix_rsp_q_hs() clears the RISC interrupt (original code):
qla24xx_msix_rsp_q: 50% of calls have HSRX_RISC_INT set qla2xxx_msix_rsp_q_hs: 5% of calls have HSRX_RISC_INT set
(# of qla2xxx_msix_rsp_q_hs interrupts) =
(# of qla24xx_msix_rsp_q interrupts) * 3
If qla2xxx_msix_rsp_q_hs() does not clear the RISC interrupt (patched code):
qla24xx_msix_rsp_q: 100% of calls have HSRX_RISC_INT set qla2xxx_msix_rsp_q_hs: 9% of calls have HSRX_RISC_INT set
(# of qla2xxx_msix_rsp_q_hs interrupts) =
(# of qla24xx_msix_rsp_q interrupts) * 3
In the case of the original code, qla24xx_msix_rsp_q() was seeing HSRX_RISC_INT set only 50% of the time because qla2xxx_msix_rsp_q_hs() was clearing it when it shouldn't have been. In the patched code, qla24xx_msix_rsp_q() sees HSRX_RISC_INT set 100% of the time, which makes sense if that interrupt handler needs to clear the RISC interrupt (which it does). qla2xxx_msix_rsp_q_hs() sees HSRX_RISC_INT only 9% of the time, which is just overlap from the other interrupt during the high IOPS test.
Tested with SCST on:
QLE2742 FW:v9.08.02 (32 Gbps 2-port)
QLE2694L FW:v9.10.11 (16 Gbps 4-port)
QLE2694L FW:v9.08.02 (16 Gbps 4-port)
QLE2672 FW:v8.07.12 (16 Gbps 2-port)
both initiator and target mode
--- drivers/scsi/qla2xxx/qla_def.h | 1 - drivers/scsi/qla2xxx/qla_gbl.h | 2 +- drivers/scsi/qla2xxx/qla_isr.c | 32 +++----------------------------- drivers/scsi/qla2xxx/qla_mid.c | 4 +--- 4 files changed, 5 insertions(+), 34 deletions(-)
drivers/scsi/qla2xxx/qla_def.h +0 -1
@@ -3503,7 +3503,6 @@ struct isp_operations {#define QLA_MSIX_RSP_Q 0x01#define QLA_ATIO_VECTOR 0x02#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q 0x03 -#define QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS 0x04#define QLA_MIDX_DEFAULT 0#define QLA_MIDX_RSP_Q 1
drivers/scsi/qla2xxx/qla_gbl.h +1 -1
@@ -766,7 +766,7 @@ extern int qla2x00_dfs_remove(scsi_qla_host_t *);/* Globa function prototypes for multi-q */ extern int qla25xx_request_irq (struct qla_hw_data *,struct qla_qpair *, -struct qla_msix_entry *,int ); +struct qla_msix_entry *);extern int qla25xx_init_req_que (struct scsi_qla_host *,struct req_que *);extern int qla25xx_init_rsp_que (struct scsi_qla_host *,struct rsp_que *); extern int qla25xx_create_req_que(struct qla_hw_data *, uint16_t, uint8_t,
drivers/scsi/qla2xxx/qla_isr.c +3 -29
@@ -4467,32 +4467,6 @@ qla2xxx_msix_rsp_q(int irq, void *dev_id)return IRQ_HANDLED ; } -irqreturn_t -qla2xxx_msix_rsp_q_hs (int irq,void *dev_id) -{ -struct qla_hw_data *ha; -struct qla_qpair *qpair; -struct device_reg_24xx __iomem *reg; -unsigned long flags; - - qpair = dev_id; -if (!qpair) { -ql_log (ql_log_info,NULL ,0x505b , -"%s: NULL response queue pointer.\n" , __func__); -return IRQ_NONE ; - } - ha = qpair->hw; - - reg = &ha->iobase->isp24; -spin_lock_irqsave (&ha->hardware_lock, flags); -wrt_reg_dword (®->hccr,HCCRX_CLR_RISC_INT ); -spin_unlock_irqrestore (&ha->hardware_lock, flags); - -queue_work (ha->wq, &qpair->q_work); - -return IRQ_HANDLED ; -} -/* Interrupt handling helpers. */ struct qla_init_msix_entry {
@@ -4505,7 +4479,6 @@ static const struct qla_init_msix_entry msix_entries[] = { { "rsp_q", qla24xx_msix_rsp_q }, { "atio_q", qla83xx_msix_atio_q }, { "qpair_multiq", qla2xxx_msix_rsp_q }, - { "qpair_multiq_hs", qla2xxx_msix_rsp_q_hs }, }; static const struct qla_init_msix_entry qla82xx_msix_entries[] = {
@@ -4792,9 +4765,10 @@ qla2x00_free_irqs(scsi_qla_host_t *vha) }int qla25xx_request_irq (struct qla_hw_data *ha,struct qla_qpair *qpair, -struct qla_msix_entry *msix,int vector_type) +struct qla_msix_entry *msix) { -const struct qla_init_msix_entry *intr = &msix_entries[vector_type]; +const struct qla_init_msix_entry *intr = + &msix_entries[QLA_MSIX_QPAIR_MULTIQ_RSP_Q ];scsi_qla_host_t *vha =pci_get_drvdata (ha->pdev);int ret;
drivers/scsi/qla2xxx/qla_mid.c +1 -3
@@ -899,9 +899,7 @@ qla25xx_create_rsp_que(struct qla_hw_data *ha, uint16_t options, rsp->options, rsp->id, rsp->rsp_q_in, rsp->rsp_q_out); - ret =qla25xx_request_irq (ha, qpair, qpair->msix, - ha->flags.disable_msix_handshake ? -QLA_MSIX_QPAIR_MULTIQ_RSP_Q :QLA_MSIX_QPAIR_MULTIQ_RSP_Q_HS ); + ret =qla25xx_request_irq (ha, qpair, qpair->msix);if (ret) goto que_failed;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 187/430 scsi: qla2xxx: Fix initiator mode with qlini_mode=exclusive
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
[ Upstream commit 8f58fc64d559b5fda1b0a5e2a71422be61e79ab9 ]
When given the module parameter qlini_mode=exclusive, qla2xxx in initiator mode is initially unable to successfully send SCSI commands to devices it finds while scanning, resulting in an escalating series of resets until an adapter reset clears the issue. Fix by checking the active mode instead of the module parameter.
--- drivers/scsi/qla2xxx/qla_os.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/scsi/qla2xxx/qla_os.c +1 -7
@@ -3460,13 +3460,7 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) ha->mqenable =0 ;if (ha->mqenable) { -bool startit = false; - -if (QLA_TGT_MODE_ENABLED ()) - startit = false; - -if (ql2x_ini_mode ==QLA2XXX_INI_MODE_ENABLED ) - startit = true; +bool startit = !!(host->active_mode &MODE_INITIATOR );/* Create start of day qpairs for Block MQ */ for (i =0 ; i < ha->max_qpairs; i++)
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 188/430 scsi: qla2xxx: Use reinit_completion on mbx_intr_comp
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tony Battersby <[email protected]>
[ Upstream commit 957aa5974989fba4ae4f807ebcb27f12796edd4d ]
If a mailbox command completes immediately after wait_for_completion_timeout() times out, ha->mbx_intr_comp could be left in an inconsistent state, causing the next mailbox command not to wait for the hardware. Fix by reinitializing the completion before use.
--- drivers/scsi/qla2xxx/qla_mbx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/qla2xxx/qla_mbx.c +2 -0
@@ -253,6 +253,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)/* Issue set host interrupt command to send cmd out. */ ha->flags.mbox_int =0 ;clear_bit (MBX_INTERRUPT , &ha->mbx_cmd_flags); +reinit_completion (&ha->mbx_intr_comp);/* Unlock mbx registers and wait for interrupt */ ql_dbg(ql_dbg_mbx, vha, 0x100f,
@@ -279,6 +280,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp) "cmd=%x Timeout.\n", command);spin_lock_irqsave (&ha->hardware_lock, flags);clear_bit (MBX_INTR_WAIT , &ha->mbx_cmd_flags); +reinit_completion (&ha->mbx_intr_comp);spin_unlock_irqrestore (&ha->hardware_lock, flags);if (chip_reset != ha->chip_reset) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 189/430 fuse: Always flush the page cache before FOPEN_DIRECT_IO write
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bernd Schubert <[email protected]>
[ Upstream commit 1ce120dcefc056ce8af2486cebbb77a458aad4c3 ]
This was done as condition on direct_io_allow_mmap, but I believe this is not right, as a file might be open two times - once with write-back enabled another time with FOPEN_DIRECT_IO.
--- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/fuse/file.c +1 -1
@@ -1607,7 +1607,7 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,if (!ia)return -ENOMEM ; -if (fopen_direct_io && fc->direct_io_allow_mmap) { +if (fopen_direct_io) { res =filemap_write_and_wait_range (mapping, pos, pos + count -1 );if (res) {fuse_io_free (ia);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 190/430 fuse: Invalidate the page cache after FOPEN_DIRECT_IO write
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bernd Schubert <[email protected]>
[ Upstream commit b359af8275a982a458e8df6c6beab1415be1f795 ]
generic_file_direct_write() also does this and has a large comment about.
Reproducer here is xfstest's generic/209, which is exactly to have competing DIO write and cached IO read.
--- fs/fuse/file.c | 9 +++++++++ 1 file changed, 9 insertions(+)
fs/fuse/file.c +9 -0
@@ -1681,6 +1681,15 @@ ssize_t fuse_direct_io(struct fuse_io_priv *io, struct iov_iter *iter,if (res >0 ) *ppos = pos; +if (res >0 && write && fopen_direct_io) { +/* +* As in generic_file_direct_write(), invalidate after the +* write, to invalidate read-ahead cache that may have competed +* with the write. +*/ +invalidate_inode_pages2_range (mapping, idx_from, idx_to); + } +return res >0 ? res : err; }EXPORT_SYMBOL_GPL (fuse_direct_io);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 191/430 via_wdt: fix critical boot hang due to unnamed resource allocation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Qiang <[email protected]>
[ Upstream commit 7aa31ee9ec92915926e74731378c009c9cc04928 ]
The VIA watchdog driver uses allocate_resource() to reserve a MMIO region for the watchdog control register. However, the allocated resource was not given a name, which causes the kernel resource tree to contain an entry marked as "<BAD>" under /proc/iomem on x86 platforms.
During boot, this unnamed resource can lead to a critical hang because subsequent resource lookups and conflict checks fail to handle the invalid entry properly.
--- drivers/watchdog/via_wdt.c | 1 + 1 file changed, 1 insertion(+)
drivers/watchdog/via_wdt.c +1 -0
@@ -165,6 +165,7 @@ static int wdt_probe(struct pci_dev *pdev,dev_err (&pdev->dev,"cannot enable PCI device\n" );return -ENODEV ; } + wdt_res.name ="via_wdt" ;/* * Allocate a MMIO region which contains watchdog control register
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 192/430 functionfs: fix the open/removal races
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit e5bf5ee266633cb18fff6f98f0b7d59a62819eee ]
ffs_epfile_open() can race with removal, ending up with file->private_data pointing to freed object.
There is a total count of opened files on functionfs (both ep0 and dynamic ones) and when it hits zero, dynamic files get removed. Unfortunately, that removal can happen while another thread is in ffs_epfile_open(), but has not incremented the count yet. In that case open will succeed, leaving us with UAF on any subsequent read() or write().
The root cause is that ffs->opened is misused; atomic_dec_and_test() vs. atomic_add_return() is not a good idea, when object remains visible all along.
To untangle that
* serialize openers on ffs->mutex (both for ep0 and for dynamic files)
* have dynamic ones use atomic_inc_not_zero() and fail if we had
zero ->opened; in that case the file we are opening is doomed.
* have the inodes of dynamic files marked on removal (from the
callback of simple_recursive_removal()) - clear ->i_private there.
* have open of dynamic ones verify they hadn't been already removed,
along with checking that state is FFS_ACTIVE.
--- drivers/usb/gadget/function/f_fs.c | 53 ++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 10 deletions(-)
drivers/usb/gadget/function/f_fs.c +43 -10
@@ -640,13 +640,22 @@ static ssize_t ffs_ep0_read(struct file *file, char __user *buf,static int ffs_ep0_open (struct inode *inode,struct file *file) { -struct ffs_data *ffs = inode->i_private; +struct ffs_data *ffs = inode->i_sb->s_fs_info; +int ret; -if (ffs->state ==FFS_CLOSING ) -return -EBUSY ; +/* Acquire mutex */ + ret =ffs_mutex_lock (&ffs->mutex, file->f_flags &O_NONBLOCK ); +if (ret <0 ) +return ret; - file->private_data = ffs;ffs_data_opened (ffs); +if (ffs->state ==FFS_CLOSING ) { +ffs_data_closed (ffs); +mutex_unlock (&ffs->mutex); +return -EBUSY ; + } +mutex_unlock (&ffs->mutex); + file->private_data = ffs;return stream_open (inode, file); }
@@ -1193,14 +1202,33 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)static int ffs_epfile_open (struct inode *inode,struct file *file) { -struct ffs_epfile *epfile = inode->i_private; +struct ffs_data *ffs = inode->i_sb->s_fs_info; +struct ffs_epfile *epfile; +int ret; -if (WARN_ON (epfile->ffs->state !=FFS_ACTIVE )) +/* Acquire mutex */ + ret =ffs_mutex_lock (&ffs->mutex, file->f_flags &O_NONBLOCK ); +if (ret <0 ) +return ret; + +if (!atomic_inc_not_zero (&ffs->opened)) { +mutex_unlock (&ffs->mutex); +return -ENODEV ; + } +/* +* we want the state to be FFS_ACTIVE; FFS_ACTIVE alone is +* not enough, though - we might have been through FFS_CLOSING +* and back to FFS_ACTIVE, with our file already removed. +*/ + epfile =smp_load_acquire (&inode->i_private); +if (unlikely (ffs->state !=FFS_ACTIVE || !epfile)) { +mutex_unlock (&ffs->mutex); +ffs_data_closed (ffs);return -ENODEV ; + } +mutex_unlock (&ffs->mutex); file->private_data = epfile; -ffs_data_opened (epfile->ffs); -return stream_open (inode, file); }
@@ -1332,7 +1360,7 @@ static void ffs_dmabuf_put(struct dma_buf_attachment *attach)static int ffs_epfile_release (struct inode *inode,struct file *file) { -struct ffs_epfile *epfile = inode->i_private; +struct ffs_epfile *epfile = file->private_data;struct ffs_dmabuf_priv *priv, *tmp;struct ffs_data *ffs = epfile->ffs;
@@ -2352,6 +2380,11 @@ static int ffs_epfiles_create(struct ffs_data *ffs)return 0 ; } +static void clear_one (struct dentry *dentry) +{ +smp_store_release (&dentry->d_inode->i_private,NULL ); +} +static void ffs_epfiles_destroy (struct ffs_epfile *epfiles,unsigned count) {struct ffs_epfile *epfile = epfiles;
@@ -2359,7 +2392,7 @@ static void ffs_epfiles_destroy(struct ffs_epfile *epfiles, unsigned count)for (; count; --count, ++epfile) {BUG_ON (mutex_is_locked (&epfile->mutex));if (epfile->dentry) { -simple_recursive_removal (epfile->dentry,NULL ); +simple_recursive_removal (epfile->dentry, clear_one); epfile->dentry =NULL ; } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 193/430 reset: fix BIT macro reference
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Encrow Thorne <[email protected]>
[ Upstream commit f3d8b64ee46c9b4b0b82b1a4642027728bac95b8 ]
RESET_CONTROL_FLAGS_BIT_* macros use BIT(), but reset.h does not include bits.h. This causes compilation errors when including reset.h standalone.
Include bits.h to make reset.h self-contained.
--- include/linux/reset.h | 1 + 1 file changed, 1 insertion(+)
include/linux/reset.h +1 -0
@@ -2,6 +2,7 @@#ifndef _LINUX_RESET_H_#define _LINUX_RESET_H_ +#include <linux/bits.h> #include <linux/err.h> #include <linux/errno.h> #include <linux/types.h>
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 194/430 exfat: fix remount failure in different process environments
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuezhang Mo <[email protected]>
[ Upstream commit 51fc7b4ce10ccab8ea5e4876bcdc42cf5202a0ef ]
The kernel test robot reported that the exFAT remount operation failed. The reason for the failure was that the process's umask is different between mount and remount, causing fs_fmask and fs_dmask are changed.
Potentially, both gid and uid may also be changed. Therefore, when initializing fs_context for remount, inherit these mount options from the options used during mount.
--- fs/exfat/super.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
fs/exfat/super.c +15 -4
@@ -813,10 +813,21 @@ static int exfat_init_fs_context(struct fs_context *fc)ratelimit_state_init (&sbi->ratelimit,DEFAULT_RATELIMIT_INTERVAL ,DEFAULT_RATELIMIT_BURST ); - sbi->options.fs_uid =current_uid (); - sbi->options.fs_gid =current_gid (); - sbi->options.fs_fmask = current->fs->umask; - sbi->options.fs_dmask = current->fs->umask; +if (fc->purpose ==FS_CONTEXT_FOR_RECONFIGURE && fc->root) { +struct super_block *sb = fc->root->d_sb; +struct exfat_mount_options *cur_opts = &EXFAT_SB (sb)->options; + + sbi->options.fs_uid = cur_opts->fs_uid; + sbi->options.fs_gid = cur_opts->fs_gid; + sbi->options.fs_fmask = cur_opts->fs_fmask; + sbi->options.fs_dmask = cur_opts->fs_dmask; + }else { + sbi->options.fs_uid =current_uid (); + sbi->options.fs_gid =current_gid (); + sbi->options.fs_fmask = current->fs->umask; + sbi->options.fs_dmask = current->fs->umask; + } + sbi->options.allow_utime =-1 ; sbi->options.errors =EXFAT_ERRORS_RO ;exfat_set_iocharset (&sbi->options, exfat_default_iocharset);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 195/430 exfat: zero out post-EOF page cache on file extension
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuezhang Mo <[email protected]>
[ Upstream commit 4e163c39dd4e70fcdce948b8774d96e0482b4a11 ]
xfstests generic/363 was failing due to unzeroed post-EOF page cache that allowed mmap writes beyond EOF to become visible after file extension.
For example, in following xfs_io sequence, 0x22 should not be written to the file but would become visible after the extension:
xfs_io -f -t -c "pwrite -S 0x11 0 8" \
-c "mmap 0 4096" \
-c "mwrite -S 0x22 32 32" \
-c "munmap" \
-c "pwrite -S 0x33 512 32" \
$testfileThis violates the expected behavior where writes beyond EOF via mmap should not persist after the file is extended. Instead, the extended region should contain zeros.
Fix this by using truncate_pagecache() to truncate the page cache after the current EOF when extending the file.
--- fs/exfat/file.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/exfat/file.c +5 -0
@@ -25,6 +25,8 @@ static int exfat_cont_expand(struct inode *inode, loff_t size)struct exfat_sb_info *sbi =EXFAT_SB (sb);struct exfat_chain clu; +truncate_pagecache (inode,i_size_read (inode)); + ret =inode_newsize_ok (inode, size);if (ret)return ret;
@@ -639,6 +641,9 @@ static ssize_t exfat_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)inode_lock (inode); +if (pos >i_size_read (inode)) +truncate_pagecache (inode,i_size_read (inode)); + valid_size = ei->valid_size; ret =generic_write_checks (iocb, iter);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 196/430 usbip: Fix locking bug in RT-enabled kernels
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lizhi Xu <[email protected]>
[ Upstream commit 09bf21bf5249880f62fe759b53b14b4b52900c6c ]
Interrupts are disabled before entering usb_hcd_giveback_urb(). A spinlock_t becomes a sleeping lock on PREEMPT_RT, so it cannot be acquired with disabled interrupts.
Save the interrupt status and restore it after usb_hcd_giveback_urb().
syz reported:
BUG: sleeping function called from invalid context at kernel/locking/spinlock_rt.c:48 Call Trace: dump_stack_lvl+0x189/0x250 lib/dump_stack.c:120 rt_spin_lock+0xc7/0x2c0 kernel/locking/spinlock_rt.c:57 spin_lock include/linux/spinlock_rt.h:44 [inline] mon_bus_complete drivers/usb/mon/mon_main.c:134 [inline] mon_complete+0x5c/0x200 drivers/usb/mon/mon_main.c:147 usbmon_urb_complete include/linux/usb/hcd.h:738 [inline] __usb_hcd_giveback_urb+0x254/0x5e0 drivers/usb/core/hcd.c:1647 vhci_urb_enqueue+0xb4f/0xe70 drivers/usb/usbip/vhci_hcd.c:818
--- drivers/usb/usbip/vhci_hcd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/usb/usbip/vhci_hcd.c +3 -3
@@ -831,15 +831,15 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag no_need_xmit:usb_hcd_unlink_urb_from_ep (hcd, urb); no_need_unlink: -spin_unlock_irqrestore (&vhci->lock, flags);if (!ret) {/* usb_hcd_giveback_urb() should be called with * irqs disabled */ -local_irq_disable (); +spin_unlock (&vhci->lock);usb_hcd_giveback_urb (hcd, urb, urb->status); -local_irq_enable (); +spin_lock (&vhci->lock); } +spin_unlock_irqrestore (&vhci->lock, flags);return ret; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 197/430 usb: typec: ucsi: Handle incorrect num_connectors capability
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Pearson <[email protected]>
[ Upstream commit 30cd2cb1abf4c4acdb1ddb468c946f68939819fb ]
The UCSI spec states that the num_connectors field is 7 bits, and the 8th bit is reserved and should be set to zero.
Some buggy FW has been known to set this bit, and it can lead to a system not booting.
Flag that the FW is not behaving correctly, and auto-fix the value so that the system boots correctly.
Found on Lenovo P1 G8 during Linux enablement program. The FW will be fixed, but seemed worth addressing in case it hit platforms that aren't officially Linux supported.
--- drivers/usb/typec/ucsi/ucsi.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/usb/typec/ucsi/ucsi.c +6 -0
@@ -1807,6 +1807,12 @@ static int ucsi_init(struct ucsi *ucsi) ret = -ENODEV ; goto err_reset; } +/* Check if reserved bit set. This is out of spec but happens in buggy FW */ +if (ucsi->cap.num_connectors &0x80 ) { +dev_warn (ucsi->dev,"UCSI: Invalid num_connectors %d. Likely buggy FW\n" , + ucsi->cap.num_connectors); + ucsi->cap.num_connectors &=0x7f ;// clear bit and carry on + }/* Allocate the connectors. Released in ucsi_unregister() */ connector =kcalloc (ucsi->cap.num_connectors +1 ,sizeof (*connector),GFP_KERNEL );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 198/430 iio: adc: ti_am335x_adc: Limit step_avg to valid range for gcc complains
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit c9fb952360d0c78bbe98239bd6b702f05c2dbb31 ]
FIELD_PREP() checks that a value fits into the available bitfield, add a check for step_avg to fix gcc complains.
which gcc complains about:
drivers/iio/adc/ti_am335x_adc.c: In function 'tiadc_step_config':
include/linux/compiler_types.h:572:38: error: call to
'__compiletime_assert_491' declared with attribute error: FIELD_PREP: value too large for the field include/linux/mfd/ti_am335x_tscadc.h:58:29: note:
in expansion of macro 'FIELD_PREP'
#define STEPCONFIG_AVG(val) FIELD_PREP(GENMASK(4, 2), (val))
^~~~~~~~~~
drivers/iio/adc/ti_am335x_adc.c:127:17: note: in expansion of macro 'STEPCONFIG_AVG'
stepconfig = STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1)--- drivers/iio/adc/ti_am335x_adc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ti_am335x_adc.c +1 -1
@@ -123,7 +123,7 @@ static void tiadc_step_config(struct iio_dev *indio_dev) chan = adc_dev->channel_line[i]; -if (adc_dev->step_avg[i]) +if (adc_dev->step_avg[i] && adc_dev->step_avg[i] <=STEPCONFIG_AVG_16 ) stepconfig =STEPCONFIG_AVG (ffs (adc_dev->step_avg[i]) -1 ) |STEPCONFIG_FIFO1 ;else
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 199/430 usb: xhci: limit run_graceperiod for only usb 3.0 devices
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyu Xie <[email protected]>
[ Upstream commit 8d34983720155b8f05de765f0183d9b0e1345cc0 ]
run_graceperiod blocks usb 2.0 devices from auto suspending after xhci_start for 500ms.
Log shows:
[ 13.387170] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.387177] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.387182] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.387188] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.387191] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event [ 13.387193] hcd_bus_resume:2303: usb usb7: usb auto-resume [ 13.387296] hub_event:5779: hub 3-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.393343] handle_port_status:2034: xhci-hcd PNP0D10:02: handle_port_status: starting usb5 port polling. [ 13.393353] xhci_hub_control:1271: xhci-hcd PNP0D10:02: Get port status 5-1 read: 0x206e1, return 0x10101 [ 13.400047] hub_suspend:3903: hub 3-0:1.0: hub_suspend [ 13.403077] hub_resume:3948: hub 7-0:1.0: hub_resume [ 13.403080] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.403085] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.403087] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.403090] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.403093] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event [ 13.403095] hcd_bus_resume:2303: usb usb7: usb auto-resume [ 13.405002] handle_port_status:1913: xhci-hcd PNP0D10:04: Port change event, 9-1, id 1, portsc: 0x6e1 [ 13.405016] hub_activate:1169: usb usb5-port1: status 0101 change 0001 [ 13.405026] xhci_clear_port_change_bit:658: xhci-hcd PNP0D10:02: clear port1 connect change, portsc: 0x6e1 [ 13.413275] hcd_bus_suspend:2250: usb usb3: bus auto-suspend, wakeup 1 [ 13.419081] hub_resume:3948: hub 7-0:1.0: hub_resume [ 13.419086] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.419095] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.419100] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.419106] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.419110] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event [ 13.419112] hcd_bus_resume:2303: usb usb7: usb auto-resume [ 13.420455] handle_port_status:2034: xhci-hcd PNP0D10:04: handle_port_status: starting usb9 port polling. [ 13.420493] handle_port_status:1913: xhci-hcd PNP0D10:05: Port change event, 10-1, id 1, portsc: 0x6e1 [ 13.425332] hcd_bus_suspend:2279: usb usb3: suspend raced with wakeup event [ 13.431931] handle_port_status:2034: xhci-hcd PNP0D10:05: handle_port_status: starting usb10 port polling. [ 13.435080] hub_resume:3948: hub 7-0:1.0: hub_resume [ 13.435084] xhci_hub_control:1271: xhci-hcd PNP0D10:03: Get port status 7-1 read: 0x2a0, return 0x100 [ 13.435092] hub_event:5779: hub 7-0:1.0: state 7 ports 1 chg 0000 evt 0000 [ 13.435096] hub_suspend:3903: hub 7-0:1.0: hub_suspend [ 13.435102] hcd_bus_suspend:2250: usb usb7: bus auto-suspend, wakeup 1 [ 13.435106] hcd_bus_suspend:2279: usb usb7: suspend raced with wakeup event
usb7 and other usb 2.0 root hub were rapidly toggling between suspend and resume states. More, "suspend raced with wakeup event" confuses people.
So, limit run_graceperiod for only usb 3.0 devices
--- drivers/usb/host/xhci-hub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/host/xhci-hub.c +1 -1
@@ -1671,7 +1671,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)* SS devices are only visible to roothub after link training completes. * Keep polling roothubs for a grace period after xHC start */ -if (xhci->run_graceperiod) { +if (hcd->speed >=HCD_USB3 && xhci->run_graceperiod) {if (time_before (jiffies, xhci->run_graceperiod)) status =1 ;else
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 200/430 usb: usb-storage: No additional quirks need to be added to the EL-R12 optical drive.
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
[ Upstream commit 955a48a5353f4fe009704a9a4272a3adf627cd35 ]
The optical drive of EL-R12 has the same vid and pid as INIC-3069, as follows:
T: Bus=02 Lev=02 Prnt=02 Port=01 Cnt=01 Dev#= 3 Spd=5000 MxCh= 0 D: Ver= 3.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 9 #Cfgs= 1 P: Vendor=13fd ProdID=3940 Rev= 3.10 S: Manufacturer=HL-DT-ST S: Product= DVD+-RW GT80N S: SerialNumber=423349524E4E38303338323439202020 C:* #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=144mA I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=02 Prot=50 Driver=usb-storage E: Ad=83(I) Atr=02(Bulk) MxPS=1024 Ivl=0ms E: Ad=0a(O) Atr=02(Bulk) MxPS=1024 Ivl=0ms
This will result in the optical drive device also adding the quirks of US_FL_NO_ATA_1X. When performing an erase operation, it will fail, and the reason for the failure is as follows:
[ 388.967742] sr 5:0:0:0: [sr0] tag#0 Send: scmd 0x00000000d20c33a7 [ 388.967742] sr 5:0:0:0: [sr0] tag#0 CDB: ATA command pass through(12)/Blank a1 11 00 00 00 00 00 00 00 00 00 00 [ 388.967773] sr 5:0:0:0: [sr0] tag#0 Done: SUCCESS Result: hostbyte=DID_TARGET_FAILURE driverbyte=DRIVER_OK cmd_age=0s [ 388.967773] sr 5:0:0:0: [sr0] tag#0 CDB: ATA command pass through(12)/Blank a1 11 00 00 00 00 00 00 00 00 00 00 [ 388.967803] sr 5:0:0:0: [sr0] tag#0 Sense Key : Illegal Request [current] [ 388.967803] sr 5:0:0:0: [sr0] tag#0 Add. Sense: Invalid field in cdb [ 388.967803] sr 5:0:0:0: [sr0] tag#0 scsi host busy 1 failed 0 [ 388.967803] sr 5:0:0:0: Notifying upper driver of completion (result 8100002) [ 388.967834] sr 5:0:0:0: [sr0] tag#0 0 sectors total, 0 bytes done.
For the EL-R12 standard optical drive, all operational commands and usage scenarios were tested without adding the IGNORE_RESIDUE quirks, and no issues were encountered. It can be reasonably concluded that removing the IGNORE_RESIDUE quirks has no impact.
--- drivers/usb/storage/unusual_uas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/unusual_uas.h +1 -1
@@ -98,7 +98,7 @@ UNUSUAL_DEV(0x125f, 0xa94a, 0x0160, 0x0160, US_FL_NO_ATA_1X),/* Reported-by: Benjamin Tissoires <[email protected]> */ -UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x9999, +UNUSUAL_DEV(0x13fd, 0x3940, 0x0309, 0x0309, "Initio Corporation", "INIC-3069", USB_SC_DEVICE, USB_PR_DEVICE, NULL,
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 201/430 usb: xhci: Dont unchain link TRBs on quirky HCs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
[ Upstream commit e6aec6d9f5794e85d2312497a5d81296d885090e ]
Some old HCs ignore transfer ring link TRBs whose chain bit is unset. This breaks endpoint operation and sometimes makes it execute other ring's TDs, which may corrupt their buffers or cause unwanted device action. We avoid this by chaining all link TRBs on affected rings.
Fix an omission which allows them to be unchained by cancelling TDs.
The patch was tested by reproducing this condition on an isochronous endpoint (non-power-of-two TDs are sometimes split not to cross 64K) and printing link TRBs in trb_to_noop() on good and buggy HCs.
Actual hardware malfunction is rare since it requires Missed Service Error shortly before the unchained link TRB, at least on NEC and AMD. I have never seen it after commit bb0ba4cb1065 ("usb: xhci: Apply the link chain quirk on NEC isoc endpoints"), but it's Russian roulette and I can't test all affected hosts and workloads. Fairly often MSEs happen after cancellation because the endpoint was stopped.
--- drivers/usb/host/xhci-ring.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
drivers/usb/host/xhci-ring.c +16 -11
@@ -128,11 +128,11 @@ static void inc_td_cnt(struct urb *urb) urb_priv->num_tds_done++; } -static void trb_to_noop (union xhci_trb *trb,u32 noop_type) +static void trb_to_noop (union xhci_trb *trb,u32 noop_type,bool unchain_links) {if (trb_is_link (trb)) { -/* unchain chained link TRBs */ - trb->link.control &=cpu_to_le32 (~TRB_CHAIN ); +if (unchain_links) + trb->link.control &=cpu_to_le32 (~TRB_CHAIN ); }else { trb->generic.field[0 ] =0 ; trb->generic.field[1 ] =0 ;
@@ -465,7 +465,7 @@ static void xhci_handle_stopped_cmd_ring(struct xhci_hcd *xhci,xhci_dbg (xhci,"Turn aborted command %p to no-op\n" , i_cmd->command_trb); -trb_to_noop (i_cmd->command_trb,TRB_CMD_NOOP ); +trb_to_noop (i_cmd->command_trb,TRB_CMD_NOOP , false);/* * caller waiting for completion is called when command
@@ -797,13 +797,18 @@ static int xhci_move_dequeue_past_td(struct xhci_hcd *xhci,* (The last TRB actually points to the ring enqueue pointer, which is not part * of this TD.) This is used to remove partially enqueued isoc TDs from a ring. */ -static void td_to_noop (struct xhci_td *td,bool flip_cycle) +static void td_to_noop (struct xhci_hcd *xhci,struct xhci_virt_ep *ep, +struct xhci_td *td,bool flip_cycle) { +bool unchain_links;struct xhci_segment *seg = td->start_seg;union xhci_trb *trb = td->start_trb; +/* link TRBs should now be unchained, but some old HCs expect otherwise */ + unchain_links = !xhci_link_chain_quirk (xhci, ep->ring ? ep->ring->type :TYPE_STREAM ); +while (1 ) { -trb_to_noop (trb,TRB_TR_NOOP ); +trb_to_noop (trb,TRB_TR_NOOP , unchain_links);/* flip cycle if asked to */ if (flip_cycle && trb != td->start_trb && trb != td->end_trb)
@@ -1091,16 +1096,16 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)"Found multiple active URBs %p and %p in stream %u?\n" , td->urb, cached_td->urb, td->urb->stream_id); -td_to_noop (cached_td, false); +td_to_noop (xhci, ep, cached_td, false); cached_td->cancel_status =TD_CLEARED ; } -td_to_noop (td, false); +td_to_noop (xhci, ep, td, false); td->cancel_status =TD_CLEARING_CACHE ; cached_td = td;break ; } }else { -td_to_noop (td, false); +td_to_noop (xhci, ep, td, false); td->cancel_status =TD_CLEARED ; } }
@@ -1125,7 +1130,7 @@ static int xhci_invalidate_cancelled_tds(struct xhci_virt_ep *ep)continue ;xhci_warn (xhci,"Failed to clear cancelled cached URB %p, mark clear anyway\n" , td->urb); -td_to_noop (td, false); +td_to_noop (xhci, ep, td, false); td->cancel_status =TD_CLEARED ; } }
@@ -4273,7 +4278,7 @@ static int xhci_queue_isoc_tx(struct xhci_hcd *xhci, gfp_t mem_flags,*/ urb_priv->td[0 ].end_trb = ep_ring->enqueue;/* Every TRB except the first & last will have its cycle bit flipped. */ -td_to_noop (&urb_priv->td[0 ], true); +td_to_noop (xhci, xep, &urb_priv->td[0 ], true);/* Reset the ring enqueue back to the first TRB and its cycle bit. */ ep_ring->enqueue = urb_priv->td[0 ].start_trb;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 202/430 serial: sprd: Return -EPROBE_DEFER when uart clock is not ready
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wenhua Lin <[email protected]>
[ Upstream commit 29e8a0c587e328ed458380a45d6028adf64d7487 ]
In sprd_clk_init(), when devm_clk_get() returns -EPROBE_DEFER for either uart or source clock, we should propagate the error instead of just warning and continuing with NULL clocks.
Currently the driver only emits a warning when clock acquisition fails and proceeds with NULL clock pointers. This can lead to issues later when the clocks are actually needed. More importantly, when the clock provider is not ready yet and returns -EPROBE_DEFER, we should return this error to allow deferred probing.
This change adds explicit checks for -EPROBE_DEFER after both:
1. devm_clk_get(uport->dev, uart)
2. devm_clk_get(uport->dev, source)
When -EPROBE_DEFER is encountered, the function now returns -EPROBE_DEFER to let the driver framework retry probing later when the clock dependencies are resolved.
--- drivers/tty/serial/sprd_serial.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/tty/serial/sprd_serial.c +6 -0
@@ -1133,6 +1133,9 @@ static int sprd_clk_init(struct uart_port *uport) clk_uart =devm_clk_get (uport->dev,"uart" );if (IS_ERR (clk_uart)) { +if (PTR_ERR (clk_uart) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +dev_warn (uport->dev,"uart%d can't get uart clock\n" , uport->line); clk_uart =NULL ;
@@ -1140,6 +1143,9 @@ static int sprd_clk_init(struct uart_port *uport) clk_parent =devm_clk_get (uport->dev,"source" );if (IS_ERR (clk_parent)) { +if (PTR_ERR (clk_parent) == -EPROBE_DEFER ) +return -EPROBE_DEFER ; +dev_warn (uport->dev,"uart%d can't get source clock\n" , uport->line); clk_parent =NULL ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 203/430 libperf cpumap: Fix perf_cpu_map__max for an empty/NULL map
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit a0a4173631bfcfd3520192c0a61cf911d6a52c3a ]
Passing an empty map to perf_cpu_map__max triggered a SEGV. Explicitly test for the empty map.
--- tools/lib/perf/cpumap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
tools/lib/perf/cpumap.c +6 -4
@@ -368,10 +368,12 @@ struct perf_cpu perf_cpu_map__max(const struct perf_cpu_map *map) .cpu = -1 }; -// cpu_map__trim_new() qsort()s it, cpu_map__default_new() sorts it as well. -return __perf_cpu_map__nr (map) >0 - ?__perf_cpu_map__cpu (map,__perf_cpu_map__nr (map) -1 ) - : result; +if (!map) +return result; + +// The CPUs are always sorted and nr is always > 0 as 0 length map is +// encoded as NULL. +return __perf_cpu_map__cpu (map,__perf_cpu_map__nr (map) -1 ); }/** Is 'b' a subset of 'a'. */
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 204/430 clk: qcom: dispcc-sm7150: Fix dispcc_mdss_pclk0_clk_src
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Reidel <[email protected]>
[ Upstream commit e3c13e0caa8ceb7dec1a7c4fcfd9dbef56a69fbe ]
Set CLK_OPS_PARENT_ENABLE to ensure the parent gets prepared and enabled when switching to it, fixing an "rcg didn't update its configuration" warning.
--- drivers/clk/qcom/dispcc-sm7150.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/dispcc-sm7150.c +1 -1
@@ -356,7 +356,7 @@ static struct clk_rcg2 dispcc_mdss_pclk0_clk_src = { .name = "dispcc_mdss_pclk0_clk_src", .parent_data = dispcc_parent_data_4, .num_parents = ARRAY_SIZE(dispcc_parent_data_4), - .flags = CLK_SET_RATE_PARENT, + .flags = CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE, .ops = &clk_pixel_ops, }, };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 205/430 i2c: designware: Disable SMBus interrupts to prevent storms from mis-configured firmware
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinhui Guo <[email protected]>
[ Upstream commit d3429178ee51dd7155445d15a5ab87a45fae3c73 ]
When probing the I2C master, disable SMBus interrupts to prevent storms caused by broken firmware mis-configuring IC_SMBUS=1; the handler never services them and a mis-configured SMBUS Master extend-clock timeout or SMBUS Slave extend-clock timeout can flood the CPU.
--- drivers/i2c/busses/i2c-designware-core.h | 1 + drivers/i2c/busses/i2c-designware-master.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/i2c/busses/i2c-designware-core.h +1 -0
@@ -78,6 +78,7 @@#define DW_IC_TX_ABRT_SOURCE 0x80#define DW_IC_ENABLE_STATUS 0x9c#define DW_IC_CLR_RESTART_DET 0xa8 +#define DW_IC_SMBUS_INTR_MASK 0xcc#define DW_IC_COMP_PARAM_1 0xf4#define DW_IC_COMP_VERSION 0xf8#define DW_IC_SDA_HOLD_MIN_VERS 0x3131312A/* "111*" == v1.11* */
drivers/i2c/busses/i2c-designware-master.c +7 -0
@@ -220,6 +220,13 @@ static int i2c_dw_init_master(struct dw_i2c_dev *dev)/* Disable the adapter */ __i2c_dw_disable (dev); +/* +* Mask SMBus interrupts to block storms from broken +* firmware that leaves IC_SMBUS=1; the handler never +* services them. +*/ +regmap_write (dev->map,DW_IC_SMBUS_INTR_MASK ,0 ); +/* Write standard speed timing parameters */ regmap_write (dev->map,DW_IC_SS_SCL_HCNT , dev->ss_hcnt);regmap_write (dev->map,DW_IC_SS_SCL_LCNT , dev->ss_lcnt);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 206/430 platform/x86: wmi-gamezone: Add Legion Go 2 Quirks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Derek J. Clark <[email protected]>
[ Upstream commit 55715d7ad5e772d621c3201da3895f250591bce8 ]
Add Legion Go 2 SKU's to the Extreme Mode quirks table.
--- drivers/platform/x86/lenovo/wmi-gamezone.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/platform/x86/lenovo/wmi-gamezone.c +16 -1
@@ -274,8 +274,23 @@ static const struct dmi_system_id fwbug_list[] = { }, .driver_data = &quirk_no_extreme_bug, }, + { + .ident = "Legion Go 8ASP2", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Legion Go 8ASP2"), + }, + .driver_data = &quirk_no_extreme_bug, + }, + { + .ident = "Legion Go 8AHP2", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "Legion Go 8AHP2"), + }, + .driver_data = &quirk_no_extreme_bug, + }, {}, - }; /**
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 207/430 nvme-fc: dont hold rport lock when putting ctrl
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Wagner <[email protected]>
[ Upstream commit b71cbcf7d170e51148d5467820ae8a72febcb651 ]
nvme_fc_ctrl_put can acquire the rport lock when freeing the ctrl object:
nvme_fc_ctrl_put
nvme_fc_ctrl_free
spin_lock_irqsave(rport->lock)
Thus we can't hold the rport lock when calling nvme_fc_ctrl_put.
Justin suggested use the safe list iterator variant because nvme_fc_ctrl_put will also modify the rport->list.
--- drivers/nvme/host/fc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/nvme/host/fc.c +4 -2
@@ -1468,14 +1468,14 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, {struct fcnvme_ls_disconnect_assoc_rqst *rqst = &lsop->rqstbuf->rq_dis_assoc; -struct nvme_fc_ctrl *ctrl, *ret =NULL ; +struct nvme_fc_ctrl *ctrl, *tmp, *ret =NULL ;struct nvmefc_ls_rcv_op *oldls =NULL ;u64 association_id =be64_to_cpu (rqst->associd.association_id);unsigned long flags;spin_lock_irqsave (&rport->lock, flags); -list_for_each_entry (ctrl, &rport->ctrl_list, ctrl_list) { +list_for_each_entry_safe (ctrl, tmp, &rport->ctrl_list, ctrl_list) {if (!nvme_fc_ctrl_get (ctrl))continue ;spin_lock (&ctrl->lock);
@@ -1488,7 +1488,9 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport,if (ret)/* leave the ctrl get reference */ break ; +spin_unlock_irqrestore (&rport->lock, flags);nvme_fc_ctrl_put (ctrl); +spin_lock_irqsave (&rport->lock, flags); }spin_unlock_irqrestore (&rport->lock, flags);
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 208/430 hwmon: (emc2305) fix device node refcount leak in error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 4910da6b36b122db50a27fabf6ab7f8611b60bf8 ]
The for_each_child_of_node() macro automatically manages device node reference counts during normal iteration. However, when breaking out of the loop early with return, the current iteration's node is not automatically released, leading to a reference count leak.
Fix this by adding of_node_put(child) before returning from the loop when emc2305_set_single_tz() fails.
This issue could lead to memory leaks over multiple probe cycles.
--- drivers/hwmon/emc2305.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/emc2305.c +3 -1
@@ -685,8 +685,10 @@ static int emc2305_probe(struct i2c_client *client) i =0 ;for_each_child_of_node (dev->of_node, child) { ret =emc2305_set_single_tz (dev, child, i); -if (ret !=0 ) +if (ret !=0 ) { +of_node_put (child);return ret; + } i++; } }else {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 209/430 nvme-fabrics: add ENOKEY to no retry criteria for authentication failures
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Tee <[email protected]>
[ Upstream commit 13989207ee29c40501e719512e8dc90768325895 ]
With authentication, in addition to EKEYREJECTED there is also no point in retrying reconnects when status is ENOKEY. Thus, add -ENOKEY as another criteria to determine when to stop retries.
--- drivers/nvme/host/fabrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/fabrics.c +1 -1
@@ -592,7 +592,7 @@ bool nvmf_should_reconnect(struct nvme_ctrl *ctrl, int status)if (status >0 && (status &NVME_STATUS_DNR ))return false; -if (status == -EKEYREJECTED ) +if (status == -EKEYREJECTED || status == -ENOKEY )return false; if (ctrl->opts->max_reconnects == -1 ||
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 210/430 hwmon: (emc2305) fix double put in emc2305_probe_childs_from_dt
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pei Xiao <[email protected]>
[ Upstream commit 541dfb49dcb80c2509e030842de77adfb77820f5 ]
./drivers/hwmon/emc2305.c:597:4-15: ERROR: probable double put
Device node iterators put the previous value of the index variable, so an explicit put causes a double put.
--- drivers/hwmon/emc2305.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hwmon/emc2305.c +1 -3
@@ -593,10 +593,8 @@ static int emc2305_probe_childs_from_dt(struct device *dev)for_each_child_of_node (dev->of_node, child) {if (of_property_present (child,"reg" )) { ret =emc2305_of_parse_pwm_child (dev, child, data); -if (ret) { -of_node_put (child); +if (ret)continue ; - } count++; } }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 211/430 platform/x86/intel/hid: Add Dell Pro Rugged 10/12 tablet to VGBS DMI quirks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chia-Lin Kao (AceLan) <[email protected]>
[ Upstream commit b169e1733cadb614e87f69d7a5ae1b186c50d313 ]
Dell Pro Rugged 10/12 tablets has a reliable VGBS method.
If VGBS is not called on boot, the on-screen keyboard won't appear if the device is booted without a keyboard.
Call VGBS on boot on thess devices to get the initial state of SW_TABLET_MODE in a reliable way.
--- drivers/platform/x86/intel/hid.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/platform/x86/intel/hid.c +12 -0
@@ -177,6 +177,18 @@ static const struct dmi_system_id dmi_vgbs_allow_list[] = { DMI_MATCH(DMI_PRODUCT_NAME, "HP Elite Dragonfly G2 Notebook PC"), }, }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro Rugged 10 Tablet RA00260"), + }, + }, + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Dell Pro Rugged 12 Tablet RA02260"), + }, + }, { } };
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 212/430 MIPS: ftrace: Fix memory corruption when kernel is located beyond 32 bits
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory CLEMENT <[email protected]>
[ Upstream commit 36dac9a3dda1f2bae343191bc16b910c603cac25 ]
Since commit e424054000878 ("MIPS: Tracing: Reduce the overhead of dynamic Function Tracer"), the macro UASM_i_LA_mostly has been used, and this macro can generate more than 2 instructions. At the same time, the code in ftrace assumes that no more than 2 instructions can be generated, which is why it stores them in an int[2] array. However, as previously noted, the macro UASM_i_LA_mostly (and now UASM_i_LA) causes a buffer overflow when _mcount is beyond 32 bits. This leads to corruption of the variables located in the __read_mostly section.
This corruption was observed because the variable __cpu_primary_thread_mask was corrupted, causing a hang very early during boot.
This fix prevents the corruption by avoiding the generation of instructions if they could exceed 2 instructions in
length. Fortunately, insn_la_mcount is only used if the instrumented code is located outside the kernel code section, so dynamic ftrace can still be used, albeit in a more limited scope. This is still preferable to corrupting memory and/or crashing the kernel.
--- arch/mips/kernel/ftrace.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-)
arch/mips/kernel/ftrace.c +21 -4
@@ -54,10 +54,20 @@ static inline void ftrace_dyn_arch_init_insns(void)u32 *buf;unsigned int v1; -/* la v1, _mcount */ - v1 =3 ; - buf = (u32 *)&insn_la_mcount[0 ]; -UASM_i_LA (&buf, v1,MCOUNT_ADDR ); +/* If we are not in compat space, the number of generated +* instructions will exceed the maximum expected limit of 2. +* To prevent buffer overflow, we avoid generating them. +* insn_la_mcount will not be used later in ftrace_make_call. +*/ +if (uasm_in_compat_space_p (MCOUNT_ADDR )) { +/* la v1, _mcount */ + v1 =3 ; + buf = (u32 *)&insn_la_mcount[0 ]; +UASM_i_LA (&buf, v1,MCOUNT_ADDR ); + }else { +pr_warn ("ftrace: mcount address beyond 32 bits is not supported (%lX)\n" , +MCOUNT_ADDR ); + }/* jal (ftrace_caller + 8), jump over the first two instruction */ buf = (u32 *)&insn_jal_ftrace_caller;
@@ -189,6 +199,13 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)unsigned int new;unsigned long ip = rec->ip; +/* When the code to patch does not belong to the kernel code +* space, we must use insn_la_mcount. However, if MCOUNT_ADDR +* is not in compat space, insn_la_mcount is not usable. +*/ +if (!core_kernel_text (ip) && !uasm_in_compat_space_p (MCOUNT_ADDR )) +return -EFAULT ; + new =core_kernel_text (ip) ? insn_jal_ftrace_caller : insn_la_mcount[0 ];#ifdef CONFIG_64BIT
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 213/430 scsi: scsi_debug: Fix atomic write enable module param description
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Garry <[email protected]>
[ Upstream commit 1f7d6e2efeedd8f545d3e0e9bf338023bf4ea584 ]
The atomic write enable module param is "atomic_wr", and not "atomic_write", so fix the module param description.
--- drivers/scsi/scsi_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_debug.c +1 -1
@@ -7410,7 +7410,7 @@ MODULE_PARM_DESC(lbprz,MODULE_PARM_DESC (lbpu,"enable LBP, support UNMAP command (def=0)" );MODULE_PARM_DESC (lbpws,"enable LBP, support WRITE SAME(16) with UNMAP bit (def=0)" );MODULE_PARM_DESC (lbpws10,"enable LBP, support WRITE SAME(10) with UNMAP bit (def=0)" ); -MODULE_PARM_DESC (atomic_write,"enable ATOMIC WRITE support, support WRITE ATOMIC(16) (def=0)" ); +MODULE_PARM_DESC (atomic_wr,"enable ATOMIC WRITE support, support WRITE ATOMIC(16) (def=0)" );MODULE_PARM_DESC (lowest_aligned,"lowest aligned lba (def=0)" );MODULE_PARM_DESC (lun_format,"LUN format: 0->peripheral (def); 1 --> flat address method" );MODULE_PARM_DESC (max_luns,"number of LUNs per target to simulate(def=1)" );
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 214/430 drm/msm: adreno: fix deferencing ifpc_reglist when not declared
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Neil Armstrong <[email protected]>
[ Upstream commit 129049d4fe22c998ae9fd1ec479fbb4ed5338c15 ]
On plaforms with an a7xx GPU not supporting IFPC, the ifpc_reglist if still deferenced in a7xx_patch_pwrup_reglist() which causes a kernel crash:
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 ... pc : a6xx_hw_init+0x155c/0x1e4c [msm] lr : a6xx_hw_init+0x9a8/0x1e4c [msm] ... Call trace: a6xx_hw_init+0x155c/0x1e4c [msm] (P) msm_gpu_hw_init+0x58/0x88 [msm] adreno_load_gpu+0x94/0x1fc [msm] msm_open+0xe4/0xf4 [msm] drm_file_alloc+0x1a0/0x2e4 [drm] drm_client_init+0x7c/0x104 [drm] drm_fbdev_client_setup+0x94/0xcf0 [drm_client_lib] drm_client_setup+0xb4/0xd8 [drm_client_lib] msm_drm_kms_post_init+0x2c/0x3c [msm] msm_drm_init+0x1a4/0x228 [msm] msm_drm_bind+0x30/0x3c [msm]
...
Check the validity of ifpc_reglist before deferencing the table to setup the register values.
Patchwork: https://patchwork.freedesktop.org/patch/688944/
Message-ID: <20251117-topic-sm8x50-fix-a6xx-non-ifpc-v1-1-e4473cbf5903@linaro.org>
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +10 -8
@@ -837,15 +837,17 @@ static void a7xx_patch_pwrup_reglist(struct msm_gpu *gpu) lock->gpu_req = lock->cpu_req = lock->turn =0 ; reglist = adreno_gpu->info->a6xx->ifpc_reglist; - lock->ifpc_list_len = reglist->count; +if (reglist) { + lock->ifpc_list_len = reglist->count; -/* -* For each entry in each of the lists, write the offset and the current -* register value into the GPU buffer -*/ -for (i =0 ; i < reglist->count; i++) { - *dest++ = reglist->regs[i]; - *dest++ =gpu_read (gpu, reglist->regs[i]); +/* +* For each entry in each of the lists, write the offset and the current +* register value into the GPU buffer +*/ +for (i =0 ; i < reglist->count; i++) { + *dest++ = reglist->regs[i]; + *dest++ =gpu_read (gpu, reglist->regs[i]); + } } reglist = adreno_gpu->info->a6xx->pwrup_reglist;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 215/430 drm/msm/a6xx: move preempt_prepare_postamble after error check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alok Tiwari <[email protected]>
[ Upstream commit ef3b04091fd8bc737dc45312375df8625b8318e2 ]
Move the call to preempt_prepare_postamble() after verifying that preempt_postamble_ptr is valid. If preempt_postamble_ptr is NULL, dereferencing it in preempt_prepare_postamble() would lead to a crash.
This change avoids calling the preparation function when the postamble allocation has failed, preventing potential NULL pointer dereference and ensuring proper error handling.
Patchwork: https://patchwork.freedesktop.org/patch/687659/
Message-ID: <[email protected]>
--- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/msm/adreno/a6xx_preempt.c +2 -2
@@ -454,11 +454,11 @@ void a6xx_preempt_init(struct msm_gpu *gpu) gpu->vm, &a6xx_gpu->preempt_postamble_bo, &a6xx_gpu->preempt_postamble_iova); -preempt_prepare_postamble (a6xx_gpu); -if (IS_ERR (a6xx_gpu->preempt_postamble_ptr)) goto fail; +preempt_prepare_postamble (a6xx_gpu); +timer_setup (&a6xx_gpu->preempt_timer, a6xx_preempt_timer,0 );return ;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 216/430 ublk: clean up user copy references on ublk server exit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Caleb Sander Mateos <[email protected]>
[ Upstream commit daa24603d9f0808929514ee62ced30052ca7221c ]
If a ublk server process releases a ublk char device file, any requests dispatched to the ublk server but not yet completed will retain a ref value of UBLK_REFCOUNT_INIT. Before commit e63d2228ef83 ("ublk: simplify aborting ublk request"), __ublk_fail_req() would decrement the reference count before completing the failed request. However, that commit optimized __ublk_fail_req() to call __ublk_complete_rq() directly without decrementing the request reference count.
The leaked reference count incorrectly allows user copy and zero copy operations on the completed ublk request. It also triggers the WARN_ON_ONCE(refcount_read(&io->ref)) warnings in ublk_queue_reinit() and ublk_deinit_queue().
Commit c5c5eb24ed61 ("ublk: avoid ublk_io_release() called after ublk char dev is closed") already fixed the issue for ublk devices using UBLK_F_SUPPORT_ZERO_COPY or UBLK_F_AUTO_BUF_REG. However, the reference count leak also affects UBLK_F_USER_COPY, the other reference-counted data copy mode. Fix the condition in ublk_check_and_reset_active_ref() to include all reference-counted data copy modes. This ensures that any ublk requests still owned by the ublk server when it exits have their reference counts reset to 0.
--- drivers/block/ublk_drv.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/block/ublk_drv.c +1 -2
@@ -1674,8 +1674,7 @@ static bool ublk_check_and_reset_active_ref(struct ublk_device *ub) {int i, j; -if (!(ub->dev_info.flags & (UBLK_F_SUPPORT_ZERO_COPY | -UBLK_F_AUTO_BUF_REG ))) +if (!ublk_dev_need_req_ref (ub))return false;for (i =0 ; i < ub->dev_info.nr_hw_queues; i++) {
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 217/430 block: rnbd-clt: Fix signedness bug in init_dev()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 1ddb815fdfd45613c32e9bd1f7137428f298e541 ]
The "dev->clt_device_id" variable is set using ida_alloc_max() which returns an int and in particular it returns negative error codes. Change the type from u32 to int to fix the error checking.
--- drivers/block/rnbd/rnbd-clt.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/rnbd/rnbd-clt.h +1 -1
@@ -112,7 +112,7 @@ struct rnbd_clt_dev {struct rnbd_queue *hw_queues;u32 device_id;/* local Idr index - used to track minor number allocations. */ -u32 clt_device_id; +int clt_device_id;struct mutex lock;enum rnbd_clt_dev_state dev_state;refcount_t refcount;
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 218/430 vhost/vsock: improve RCU read sections around vhost_vsock_get()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefano Garzarella <[email protected]>
[ Upstream commit d8ee3cfdc89b75dc059dc21c27bef2c1440f67eb ]
vhost_vsock_get() uses hash_for_each_possible_rcu() to find the vhost_vsock associated with the guest_cid. hash_for_each_possible_rcu() should only be called within an RCU read section, as mentioned in the following comment in include/linux/rculist.h:
/**
* hlist_for_each_entry_rcu - iterate over rcu list of given type
* @pos: the type * to use as a loop cursor.
* @head: the head for your list.
* @member: the name of the hlist_node within the struct.
* @cond: optional lockdep expression if called from non-RCU protection.
*
* This list-traversal primitive may safely run concurrently with
* the _rcu list-mutation primitives such as hlist_add_head_rcu()
* as long as the traversal is guarded by rcu_read_lock(). */
Currently, all calls to vhost_vsock_get() are between rcu_read_lock() and rcu_read_unlock() except for calls in vhost_vsock_set_cid() and vhost_vsock_reset_orphans(). In both cases, the current code is safe, but we can make improvements to make it more robust.
About vhost_vsock_set_cid(), when building the kernel with CONFIG_PROVE_RCU_LIST enabled, we get the following RCU warning when the user space issues ioctl(dev, VHOST_VSOCK_SET_GUEST_CID, ...) :
WARNING: suspicious RCU usage
6.18.0-rc7 #62 Not tainted
-----------------------------
drivers/vhost/vsock.c:74 RCU-list traversed in non-reader section!!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by rpc-libvirtd/3443:
#0: ffffffffc05032a8 (vhost_vsock_mutex){+.+.}-{4:4}, at: vhost_vsock_dev_ioctl+0x2ff/0x530 [vhost_vsock]
stack backtrace: CPU: 2 UID: 0 PID: 3443 Comm: rpc-libvirtd Not tainted 6.18.0-rc7 #62 PREEMPT(none) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.17.0-7.fc42 06/10/2025 Call Trace: <TASK> dump_stack_lvl+0x75/0xb0 dump_stack+0x14/0x1a lockdep_rcu_suspicious.cold+0x4e/0x97 vhost_vsock_get+0x8f/0xa0 [vhost_vsock] vhost_vsock_dev_ioctl+0x307/0x530 [vhost_vsock] __x64_sys_ioctl+0x4f2/0xa00 x64_sys_call+0xed0/0x1da0 do_syscall_64+0x73/0xfa0 entry_SYSCALL_64_after_hwframe+0x76/0x7e ... </TASK>
This is not a real problem, because the vhost_vsock_get() caller, i.e. vhost_vsock_set_cid(), holds the vhost_vsock_mutex used by the hash table writers. Anyway, to prevent that warning, add lockdep_is_held() condition to hash_for_each_possible_rcu() to verify that either the caller is in an RCU read section or vhost_vsock_mutex is held when CONFIG_PROVE_RCU_LIST is enabled; and also clarify the comment for vhost_vsock_get() to better describe the locking requirements and the scope of the returned pointer validity.
About vhost_vsock_reset_orphans(), currently this function is only called via vsock_for_each_connected_socket(), which holds the vsock_table_lock spinlock (which is also an RCU read-side critical section). However, add an explicit RCU read lock there to make the code more robust and explicit about the RCU requirements, and to prevent issues if the calling context changes in the future or if vhost_vsock_reset_orphans() is called from other contexts.
Message-Id: <[email protected]>
Message-ID: <20251126210313.GA499503@fedora>
--- drivers/vhost/vsock.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/vsock.c +11 -4
@@ -64,14 +64,15 @@ static u32 vhost_transport_get_local_cid(void)return VHOST_VSOCK_DEFAULT_HOST_CID ; } -/* Callers that dereference the return value must hold vhost_vsock_mutex or the -* RCU read lock. +/* Callers must be in an RCU read section or hold the vhost_vsock_mutex. +* The return value can only be dereferenced while within the section. */ static struct vhost_vsock *vhost_vsock_get (u32 guest_cid) {struct vhost_vsock *vsock; -hash_for_each_possible_rcu (vhost_vsock_hash, vsock, hash, guest_cid) { +hash_for_each_possible_rcu (vhost_vsock_hash, vsock, hash, guest_cid, +lockdep_is_held (&vhost_vsock_mutex)) {u32 other_cid = vsock->guest_cid;/* Skip instances that have no CID yet */
@@ -707,9 +708,15 @@ static void vhost_vsock_reset_orphans(struct sock *sk)* executing. */ +rcu_read_lock (); +/* If the peer is still valid, no need to reset connection */ -if (vhost_vsock_get (vsk->remote_addr.svm_cid)) +if (vhost_vsock_get (vsk->remote_addr.svm_cid)) { +rcu_read_unlock ();return ; + } + +rcu_read_unlock ();/* If the close timeout is pending, let it expire. This avoids races * with the timeout callback.
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 219/430 cifs: Fix memory and information leak in smb3_reconfigure()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zilin Guan <[email protected]>
[ Upstream commit cb6d5aa9c0f10074f1ad056c3e2278ad2cc7ec8d ]
In smb3_reconfigure(), if smb3_sync_session_ctx_passwords() fails, the function returns immediately without freeing and erasing the newly allocated new_password and new_password2. This causes both a memory leak and a potential information leak.
Fix this by calling kfree_sensitive() on both password buffers before returning in this error case.
--- fs/smb/client/fs_context.c | 2 ++ 1 file changed, 2 insertions(+)
fs/smb/client/fs_context.c +2 -0
@@ -1080,6 +1080,8 @@ static int smb3_reconfigure(struct fs_context *fc) rc =smb3_sync_session_ctx_passwords (cifs_sb, ses);if (rc) {mutex_unlock (&ses->session_mutex); +kfree_sensitive (new_password); +kfree_sensitive (new_password2);return rc; }
Signature · 1 line
2.51.0
Greg Kroah-Hartman
maintainerPATCH 220/430 rust/drm/gem: Fix missing header in `Object` rustdoc
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lyude Paul <[email protected]>
commit e54ad0cd3673c93cdafda58505eaa81610fe3aef upstream.
Invariants should be prefixed with a # to turn it into a header.
There are no functional changes in this patch.
--- rust/kernel/drm/gem/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/drm/gem/mod.rs +1 -1
@@ -184,7 +184,7 @@ impl<T: IntoGEMObject> BaseObject for T/// A base GEM object. /// -/// Invariants +/// # Invariants /// /// - `self.obj` is a valid instance of a `struct drm_gem_object`. /// - `self.dev` is always a valid pointer to a `struct drm_device`.
Greg Kroah-Hartman
maintainerPATCH 221/430 rust_binder: avoid mem::take on delivered_deaths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <[email protected]>
commit 6c37bebd8c926ad01ef157c0d123633a203e5c0d upstream.
Similar to the previous commit, List::remove is used on delivered_deaths, so do not use mem::take on it as that may result in violations of the List::remove safety requirements.
I don't think this particular case can be triggered because it requires fd close to run in parallel with an ioctl on the same fd. But let's not tempt fate.
--- drivers/android/binder/process.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/android/binder/process.rs +6 -2
@@ -1362,8 +1362,12 @@ fn deferred_release(self: Arc<Self>) { work.into_arc ().cancel (); } -let delivered_deaths =take (&mut self.inner.lock ().delivered_deaths); -drop (delivered_deaths); +// Clear delivered_deaths list. +// +// Scope ensures that MutexGuard is dropped while executing the body. +while let Some (delivered_death) = { self.inner.lock ().delivered_deaths.pop_front () } { +drop (delivered_death); + }// Free any resources kept alive by allocated buffers. let omapping = self.inner.lock ().mapping.take ();
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 222/430 rust: dma: add helpers for architectures without CONFIG_HAS_DMA
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: FUJITA Tomonori <[email protected]>
commit d8932355f8c5673106eca49abd142f8fe0c1fe8b upstream.
Add dma_set_mask(), dma_set_coherent_mask(), dma_map_sgtable(), and dma_max_mapping_size() helpers to fix a build error when CONFIG_HAS_DMA is not enabled.
Note that when CONFIG_HAS_DMA is enabled, they are included in both bindings_generated.rs and bindings_helpers_generated.rs. The former takes precedence so behavior remains unchanged in that case.
This fixes the following build error on UML:
error[E0425]: cannot find function dma_set_mask in crate bindings
--> rust/kernel/dma.rs:46:38
|
46 | to_result(unsafe { bindings::dma_set_mask(self.as_ref().as_raw(), mask.value()) })
| ^^^^^^^^^^^^ help: a function with a similar name exists: `xa_set_mark`
|
::: rust/bindings/bindings_generated.rs:24690:5
|
24690 | pub fn xa_set_mark(arg1: *mut xarray, index: ffi::c_ulong, arg2: xa_mark_t);
| ---------------------------------------------------------------------------- similarly named function `xa_set_mark` defined hereerror[E0425]: cannot find function dma_set_coherent_mask in crate bindings
--> rust/kernel/dma.rs:63:38
|
63 | to_result(unsafe { bindings::dma_set_coherent_mask(self.as_ref().as_raw(), mask.value()) })
| ^^^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `dma_coherent_ok`
|
::: rust/bindings/bindings_generated.rs:52745:5
|
52745 | pub fn dma_coherent_ok(dev: *mut device, phys: phys_addr_t, size: usize) -> bool_;
| ---------------------------------------------------------------------------------- similarly named function `dma_coherent_ok` defined hereerror[E0425]: cannot find function dma_map_sgtable in crate bindings
--> rust/kernel/scatterlist.rs:212:23
|
212 | bindings::dma_map_sgtable(dev.as_raw(), sgt.as_ptr(), dir.into(), 0)
| ^^^^^^^^^^^^^^^ help: a function with a similar name exists: `dma_unmap_sgtable`
|
::: rust/bindings/bindings_helpers_generated.rs:1351:5
|
1351 | / pub fn dma_unmap_sgtable(
1352 | | dev: *mut device,
1353 | | sgt: *mut sg_table,
1354 | | dir: dma_data_direction,
1355 | | attrs: ffi::c_ulong,
1356 | | );
| |______- similarly named function `dma_unmap_sgtable` defined hereerror[E0425]: cannot find function dma_max_mapping_size in crate bindings
--> rust/kernel/scatterlist.rs:356:52
|
356 | let max_segment = match unsafe { bindings::dma_max_mapping_size(dev.as_raw()) } {
| ^^^^^^^^^^^^^^^^^^^^ not found in `bindings`error: aborting due to 4 previous errors
--- rust/helpers/dma.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
rust/helpers/dma.c +21 -0
@@ -19,3 +19,24 @@ int rust_helper_dma_set_mask_and_coherent(struct device *dev, u64 mask) {return dma_set_mask_and_coherent (dev, mask); } + +int rust_helper_dma_set_mask (struct device *dev,u64 mask) +{ +return dma_set_mask (dev, mask); +} + +int rust_helper_dma_set_coherent_mask (struct device *dev,u64 mask) +{ +return dma_set_coherent_mask (dev, mask); +} + +int rust_helper_dma_map_sgtable (struct device *dev,struct sg_table *sgt, +enum dma_data_direction dir,unsigned long attrs) +{ +return dma_map_sgtable (dev, sgt, dir, attrs); +} + +size_t rust_helper_dma_max_mapping_size (struct device *dev) +{ +return dma_max_mapping_size (dev); +}
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 223/430 samples: rust: fix endianness issue in rust_driver_pci
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marko Turk <[email protected]>
commit e2f1081ca8f18c146e8f928486deac61eca2b517 upstream.
MMIO backend of PCI Bar always assumes little-endian devices and will convert to CPU endianness automatically. Remove the u32::from_le conversion which would cause a bug on big-endian machines.
--- samples/rust/rust_driver_pci.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
samples/rust/rust_driver_pci.rs +1 -1
@@ -48,7 +48,7 @@ fn testdev(index: &TestIndex, bar: &Bar0) -> Result<u32> {// Select the test. bar.write8 (index.0 ,Regs ::TEST ); -let offset = u32::from_le (bar.read32 (Regs ::OFFSET ))as usize ; +let offset = bar.read32 (Regs ::OFFSET )as usize ;let data = bar.read8 (Regs ::DATA );// Write `data` to `offset` to increase `count` by one.
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 224/430 rust: io: define ResourceSize as resource_size_t
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <[email protected]>
commit 919b72922717e396be9435c83916b9969505bd23 upstream.
These typedefs are always equivalent so this should not change anything, but the code makes a lot more sense like this.
--- rust/kernel/io/resource.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
rust/kernel/io/resource.rs +1 -1
@@ -16,7 +16,7 @@ use crate::types::Opaque;/// /// This is a type alias to either `u32` or `u64` depending on the config option /// `CONFIG_PHYS_ADDR_T_64BIT`, and it can be a u64 even on 32-bit architectures. -pub type ResourceSize = bindings::phys_addr_t ; +pub type ResourceSize = bindings::resource_size_t ;/// A region allocated from a parent [`Resource`]. ///
Greg Kroah-Hartman
maintainerPATCH 225/430 rust: io: move ResourceSize to top-level io module
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <[email protected]>
commit dfd67993044f507ba8fd6ee9956f923ba4b7e851 upstream.
Resource sizes are a general concept for dealing with physical addresses, and not specific to the Resource type, which is just one way to access physical addresses. Thus, move the typedef to the io module.
Still keep a re-export under resource. This avoids this commit from being a flag-day, but I also think it's a useful re-export in general so that you can import
use kernel::io::resource::{Resource, ResourceSize};instead of having to write
use kernel::io::{
resource::Resource,
ResourceSize,
};in the specific cases where you need ResourceSize because you are using the Resource type. Therefore I think it makes sense to keep this re-export indefinitely and it is *not* intended as a temporary re-export for migration purposes.
--- rust/kernel/io.rs | 6 ++++++ rust/kernel/io/resource.rs | 6 +----- 2 files changed, 7 insertions(+), 5 deletions(-)
rust/kernel/io.rs +6 -0
@@ -13,6 +13,12 @@ pub mod resource;pub use resource::Resource ; +/// Resource Size type. +/// +/// This is a type alias to either `u32` or `u64` depending on the config option +/// `CONFIG_PHYS_ADDR_T_64BIT`, and it can be a u64 even on 32-bit architectures. +pub type ResourceSize = bindings::resource_size_t ; +/// Raw representation of an MMIO region. /// /// By itself, the existence of an instance of this structure does not provide any guarantees that
rust/kernel/io/resource.rs +1 -5
@@ -12,11 +12,7 @@ use crate::prelude::*;use crate ::str::{CStr ,CString };use crate ::types::Opaque ; -/// Resource Size type. -/// -/// This is a type alias to either `u32` or `u64` depending on the config option -/// `CONFIG_PHYS_ADDR_T_64BIT`, and it can be a u64 even on 32-bit architectures. -pub type ResourceSize = bindings::resource_size_t ; +pub use super ::ResourceSize ;/// A region allocated from a parent [`Resource`]. ///
Greg Kroah-Hartman
maintainerPATCH 226/430 rust: io: add typedef for phys_addr_t
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alice Ryhl <[email protected]>
commit dd6ff5cf56fb183fce605ca6a5bfce228cd8888b upstream.
The C typedef phys_addr_t is missing an analogue in Rust, meaning that we end up using bindings::phys_addr_t or ResourceSize as a replacement in various places throughout the kernel. Fix that by introducing a new typedef on the Rust side. Place it next to the existing ResourceSize typedef since they're quite related to each other.
--- rust/kernel/devres.rs | 18 +++++++++++++++--- rust/kernel/io.rs | 20 +++++++++++++++++--- rust/kernel/io/resource.rs | 9 ++++++--- 3 files changed, 38 insertions(+), 9 deletions(-)
rust/kernel/devres.rs +15 -3
@@ -52,8 +52,20 @@ struct Inner<T: Send> {/// # Examples /// /// ```no_run -/// # use kernel::{bindings, device::{Bound, Device}, devres::Devres, io::{Io, IoRaw}}; -/// # use core::ops::Deref; +/// use kernel::{ +/// bindings, +/// device::{ +/// Bound, +/// Device, +/// }, +/// devres::Devres, +/// io::{ +/// Io, +/// IoRaw, +/// PhysAddr, +/// }, +/// }; +/// use core::ops::Deref; /// /// // See also [`pci::Bar`] for a real example. /// struct IoMem<const SIZE: usize>(IoRaw<SIZE>);
@@ -66,7 +78,7 @@ struct Inner<T: Send> {/// unsafe fn new(paddr: usize) -> Result<Self>{ /// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is /// // valid for `ioremap`. -/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) }; +/// let addr = unsafe { bindings::ioremap(paddr as PhysAddr, SIZE) }; /// if addr.is_null() { /// return Err(ENOMEM); /// }
rust/kernel/io.rs +17 -3
@@ -13,6 +13,12 @@ pub mod resource;pub use resource::Resource ; +/// Physical address type. +/// +/// This is a type alias to either `u32` or `u64` depending on the config option +/// `CONFIG_PHYS_ADDR_T_64BIT`, and it can be a u64 even on 32-bit architectures. +pub type PhysAddr = bindings::phys_addr_t ; +/// Resource Size type. /// /// This is a type alias to either `u32` or `u64` depending on the config option
@@ -68,8 +74,16 @@ impl<const SIZE: usize> IoRaw<SIZE> {/// # Examples /// /// ```no_run -/// # use kernel::{bindings, ffi::c_void, io::{Io, IoRaw}}; -/// # use core::ops::Deref; +/// use kernel::{ +/// bindings, +/// ffi::c_void, +/// io::{ +/// Io, +/// IoRaw, +/// PhysAddr, +/// }, +/// }; +/// use core::ops::Deref; /// /// // See also [`pci::Bar`] for a real example. /// struct IoMem<const SIZE: usize>(IoRaw<SIZE>);
@@ -82,7 +96,7 @@ impl<const SIZE: usize> IoRaw<SIZE> {/// unsafe fn new(paddr: usize) -> Result<Self>{ /// // SAFETY: By the safety requirements of this function [`paddr`, `paddr` + `SIZE`) is /// // valid for `ioremap`. -/// let addr = unsafe { bindings::ioremap(paddr as bindings::phys_addr_t, SIZE) }; +/// let addr = unsafe { bindings::ioremap(paddr as PhysAddr, SIZE) }; /// if addr.is_null() { /// return Err(ENOMEM); /// }
rust/kernel/io/resource.rs +6 -3
@@ -12,7 +12,10 @@ use crate::prelude::*;use crate ::str::{CStr ,CString };use crate ::types::Opaque ; -pub use super ::ResourceSize ; +pub use super ::{ +PhysAddr , +ResourceSize ,// +};/// A region allocated from a parent [`Resource`]. ///
@@ -93,7 +96,7 @@ impl Resource {/// the region, or a part of it, is already in use. pub fn request_region ( &self, - start:ResourceSize , + start:PhysAddr , size:ResourceSize , name:CString , flags: Flags,
@@ -127,7 +130,7 @@ impl Resource { }/// Returns the start address of the resource. -pub fn start (&self) ->ResourceSize { +pub fn start (&self) ->PhysAddr {let inner = self.0 .get ();// SAFETY: Safe as per the invariants of `Resource`. unsafe { (*inner).start }
Greg Kroah-Hartman
maintainerPATCH 227/430 KEYS: trusted: Fix a memory leak in tpm2_load_cmd
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit 62cd5d480b9762ce70d720a81fa5b373052ae05f upstream.
'tpm2_load_cmd' allocates a tempoary blob indirectly via 'tpm2_key_decode' but it is not freed in the failure paths. Address this by wrapping the blob into with a cleanup helper.
--- security/keys/trusted-keys/trusted_tpm2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
security/keys/trusted-keys/trusted_tpm2.c +4 -2
@@ -387,6 +387,7 @@ static int tpm2_load_cmd(struct tpm_chipstruct trusted_key_options *options, u32 *blob_handle) { + u8 *blob_ref __free(kfree) = NULL;struct tpm_buf buf;unsigned int private_len;unsigned int public_len;
@@ -400,6 +401,9 @@ static int tpm2_load_cmd(struct tpm_chip/* old form */ blob = payload->blob; payload->old_format =1 ; + }else { +/* Bind for cleanup: */ + blob_ref = blob; }/* new format carries keyhandle but old format doesn't */
@@ -464,8 +468,6 @@ static int tpm2_load_cmd(struct tpm_chip (__be32 *) &buf.data[TPM_HEADER_SIZE]); out: -if (blob != payload->blob) -kfree (blob);tpm_buf_destroy (&buf);if (rc >0 )
Greg Kroah-Hartman
maintainerPATCH 228/430 clk: keystone: syscon-clk: fix regmap leak on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 9c75986a298f121ed2c6599b05e51d9a34e77068 upstream.
The mmio regmap allocated during probe is never freed.
Switch to using the device managed allocator so that the regmap is released on probe failures (e.g. probe deferral) and on driver unbind.
--- drivers/clk/keystone/syscon-clk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/keystone/syscon-clk.c +1 -1
@@ -129,7 +129,7 @@ static int ti_syscon_gate_clk_probe(struct platform_device *pdev)if (IS_ERR (base))return PTR_ERR (base); - regmap =regmap_init_mmio (dev, base, &ti_syscon_regmap_cfg); + regmap =devm_regmap_init_mmio (dev, base, &ti_syscon_regmap_cfg);if (IS_ERR (regmap))return dev_err_probe (dev,PTR_ERR (regmap),"failed to get regmap\n" );
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 229/430 io_uring/poll: correctly handle io_poll_add() return value on update
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit 84230ad2d2afbf0c44c32967e525c0ad92e26b4e upstream.
When the core of io_uring was updated to handle completions consistently and with fixed return codes, the POLL_REMOVE opcode with updates got slightly broken. If a POLL_ADD is pending and then POLL_REMOVE is used to update the events of that request, if that update causes the POLL_ADD to now trigger, then that completion is lost and a CQE is never posted.
Additionally, ensure that if an update does cause an existing POLL_ADD to complete, that the completion value isn't always overwritten with -ECANCELED. For that case, whatever io_poll_add() set the value to should just be retained.
--- io_uring/poll.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
io_uring/poll.c +7 -2
@@ -936,12 +936,17 @@ int io_poll_remove(struct io_kiocb *req, ret2 =io_poll_add (preq, issue_flags & ~IO_URING_F_UNLOCKED );/* successfully updated, don't complete poll request */ -if (!ret2 || ret2 == -EIOCBQUEUED ) +if (ret2 ==IOU_ISSUE_SKIP_COMPLETE ) goto out; +/* request completed as part of the update, complete it */ +else if (ret2 ==IOU_COMPLETE ) + goto complete; } -req_set_fail (preq);io_req_set_res (preq, -ECANCELED ,0 ); +complete: +if (preq->cqe.res <0 ) +req_set_fail (preq); preq->io_task_work.func = io_req_task_complete;io_req_task_work_add (preq); out:
Greg Kroah-Hartman
maintainerPATCH 230/430 io_uring: fix min_wait wakeups for SQPOLL
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit e15cb2200b934e507273510ba6bc747d5cde24a3 upstream.
Using min_wait, two timeouts are given:
1) The min_wait timeout, within which up to 'wait_nr' events are waited for.
2) The overall long timeout, which is entered if no events are generated in the min_wait window.
If the min_wait has expired, any event being posted must wake the task. For SQPOLL, that isn't the case, as it won't trigger the io_has_work() condition, as it will have already processed the task_work that happened when an event was posted. This causes any event to trigger post the min_wait to not always cause the waiting application to wakeup, and instead it will wait until the overall timeout has expired. This can be shown in a test case that has a 1 second min_wait, with a 5 second overall wait, even if an event triggers after 1.5 seconds:
axboe@m2max-kvm /d/iouring-mre (master)> zig-out/bin/iouring
info: MIN_TIMEOUT supported: true, features: 0x3ffff
info: Testing: min_wait=1000ms, timeout=5s, wait_nr=4
info: 1 cqes in 5000.2ms
where the expected result should be:
axboe@m2max-kvm /d/iouring-mre (master)> zig-out/bin/iouring
info: MIN_TIMEOUT supported: true, features: 0x3ffff
info: Testing: min_wait=1000ms, timeout=5s, wait_nr=4
info: 1 cqes in 1500.3ms
When the min_wait timeout triggers, reset the number of completions needed to wake the task. This should ensure that any future events will wake the task, regardless of how many events it originally wanted to wait for.
--- io_uring/io_uring.c | 3 +++ 1 file changed, 3 insertions(+)
io_uring/io_uring.c +3 -0
@@ -2551,6 +2551,9 @@ static enum hrtimer_restart io_cqring_mi goto out_wake; } +/* any generated CQE posted past this time should wake us up */ + iowq->cq_tail = iowq->cq_min_tail; +hrtimer_update_function (&iowq->t, io_cqring_timer_wakeup);hrtimer_set_expires (timer, iowq->timeout);return HRTIMER_RESTART ;
Greg Kroah-Hartman
maintainerPATCH 231/430 io_uring: fix filename leak in __io_openat_prep()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prithvi Tambewagh <[email protected]>
commit b14fad555302a2104948feaff70503b64c80ac01 upstream.
__io_openat_prep() allocates a struct filename using getname(). However,
for the condition of the file being installed in the fixed file table as well as having O_CLOEXEC flag set, the function returns early. At that point, the request doesn't have REQ_F_NEED_CLEANUP flag set. Due to this, the memory for the newly allocated struct filename is not cleaned up, causing a memory leak.
Fix this by setting the REQ_F_NEED_CLEANUP for the request just after the successful getname() call, so that when the request is torn down, the filename will be cleaned up, along with other resources needing cleanup.
--- io_uring/openclose.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
io_uring/openclose.c +1 -1
@@ -73,13 +73,13 @@ static int __io_openat_prep(struct io_ki open->filename =NULL ;return ret; } + req->flags |=REQ_F_NEED_CLEANUP ; open->file_slot =READ_ONCE (sqe->file_index);if (open->file_slot && (open->how.flags &O_CLOEXEC ))return -EINVAL ; open->nofile =rlimit (RLIMIT_NOFILE ); - req->flags |=REQ_F_NEED_CLEANUP ;if (io_openat_force_async (open)) req->flags |=REQ_F_FORCE_ASYNC ;return 0 ;
Greg Kroah-Hartman
maintainerPATCH 232/430 printk: Avoid scheduling irq_work on suspend
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
commit 26873e3e7f0cb26c45e6ad63656f9fe36b2aa31b upstream.
Allowing irq_work to be scheduled while trying to suspend has shown to cause problems as some architectures interpret the pending interrupts as a reason to not suspend. This became a problem for printk() with the introduction of NBCON consoles. With every printk() call, NBCON console printing kthreads are woken by queueing irq_work. This means that irq_work continues to be queued due to printk() calls late in the suspend procedure.
Avoid this problem by preventing printk() from queueing irq_work once console suspending has begun. This applies to triggering NBCON and legacy deferred printing as well as klogd waiters.
Since triggering of NBCON threaded printing relies on irq_work, the pr_flush() within console_suspend_all() is used to perform the final flushing before suspending consoles and blocking irq_work queueing. NBCON consoles that are not suspended (due to the usage of the "no_console_suspend" boot argument) transition to atomic flushing.
Introduce a new global variable @console_irqwork_blocked to flag when irq_work queueing is to be avoided. The flag is used by printk_get_console_flush_type() to avoid allowing deferred printing and switch NBCON consoles to atomic flushing. It is also used by vprintk_emit() to avoid klogd waking.
Add WARN_ON_ONCE(console_irqwork_blocked) to the irq_work queuing functions to catch any code that attempts to queue printk irq_work during the suspending/resuming procedure.
--- kernel/printk/internal.h | 8 ++++-- kernel/printk/nbcon.c | 7 +++++ kernel/printk/printk.c | 58 ++++++++++++++++++++++++++++++++++------------- 3 files changed, 55 insertions(+), 18 deletions(-)
kernel/printk/internal.h +5 -3
@@ -230,6 +230,8 @@ struct console_flush_type {bool legacy_offload; }; +extern bool console_irqwork_blocked; +/* * Identify which console flushing methods should be used in the context of * the caller.
@@ -241,7 +243,7 @@ static inline void printk_get_console_flswitch (nbcon_get_default_prio ()) {case NBCON_PRIO_NORMAL :if (have_nbcon_console && !have_boot_console) { -if (printk_kthreads_running) +if (printk_kthreads_running && !console_irqwork_blocked) ft->nbcon_offload = true;else ft->nbcon_atomic = true;
@@ -251,7 +253,7 @@ static inline void printk_get_console_flif (have_legacy_console || have_boot_console) {if (!is_printk_legacy_deferred ()) ft->legacy_direct = true; -else +else if (!console_irqwork_blocked) ft->legacy_offload = true; }break ;
@@ -264,7 +266,7 @@ static inline void printk_get_console_flif (have_legacy_console || have_boot_console) {if (!is_printk_legacy_deferred ()) ft->legacy_direct = true; -else +else if (!console_irqwork_blocked) ft->legacy_offload = true; }break ;
kernel/printk/nbcon.c +7 -0
@@ -1276,6 +1276,13 @@ void nbcon_kthreads_wake(void)if (!printk_kthreads_running)return ; +/* +* It is not allowed to call this function when console irq_work +* is blocked. +*/ +if (WARN_ON_ONCE (console_irqwork_blocked)) +return ; + cookie =console_srcu_read_lock ();for_each_console_srcu (con) {if (!(console_srcu_read_flags (con) &CON_NBCON ))
kernel/printk/printk.c +43 -15
98 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 233/430 sched_ext: Factor out local_dsq_post_enq() from dispatch_enqueue()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 530b6637c79e728d58f1d9b66bd4acf4b735b86d upstream.
Factor out local_dsq_post_enq() which performs post-enqueue handling for local DSQs - triggering resched_curr() if SCX_ENQ_PREEMPT is specified or if the current CPU is idle. No functional change.
This will be used by the next patch to fix move_local_task_to_local_dsq().
--- kernel/sched/ext.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
kernel/sched/ext.c +19 -15
@@ -906,6 +906,22 @@ static void refill_task_slice_dfl(struct__scx_add_event (sch,SCX_EV_REFILL_SLICE_DFL ,1 ); } +static void local_dsq_post_enq (struct scx_dispatch_q *dsq,struct task_struct *p, +u64 enq_flags) +{ + struct rq *rq = container_of(dsq, struct rq, scx.local_dsq); +bool preempt = false; + +if ((enq_flags &SCX_ENQ_PREEMPT ) && p != rq->curr && + rq->curr->sched_class == &ext_sched_class) { + rq->curr->scx.slice =0 ; + preempt = true; + } + +if (preempt ||sched_class_above (&ext_sched_class, rq->curr->sched_class)) +resched_curr (rq); +} +static void dispatch_enqueue (struct scx_sched *sch,struct scx_dispatch_q *dsq,struct task_struct *p,u64 enq_flags) {
@@ -1003,22 +1019,10 @@ static void dispatch_enqueue(struct scx_if (enq_flags &SCX_ENQ_CLEAR_OPSS )atomic_long_set_release (&p->scx.ops_state,SCX_OPSS_NONE ); -if (is_local) { - struct rq *rq = container_of(dsq, struct rq, scx.local_dsq); -bool preempt = false; - -if ((enq_flags &SCX_ENQ_PREEMPT ) && p != rq->curr && - rq->curr->sched_class == &ext_sched_class) { - rq->curr->scx.slice =0 ; - preempt = true; - } - -if (preempt ||sched_class_above (&ext_sched_class, - rq->curr->sched_class)) -resched_curr (rq); - }else { +if (is_local) +local_dsq_post_enq (dsq, p, enq_flags); +else raw_spin_unlock (&dsq->lock); - } } static void task_unlink_from_dsq(struct task_struct *p,
Greg Kroah-Hartman
maintainerPATCH 234/430 sched_ext: Fix the memleak for sch->helper objects
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zqiang <[email protected]>
commit 517a44d18537ef8ab888f71197c80116c14cee0a upstream.
This commit use kthread_destroy_worker() to release sch->helper objects to fix the following kmemleak:
unreferenced object 0xffff888121ec7b00 (size 128):
comm "scx_simple", pid 1197, jiffies 4295884415 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 ad 4e ad de .............N..
ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff ................
backtrace (crc 587b3352):
kmemleak_alloc+0x62/0xa0
__kmalloc_cache_noprof+0x28d/0x3e0
kthread_create_worker_on_node+0xd5/0x1f0
scx_enable.isra.210+0x6c2/0x25b0
bpf_scx_reg+0x12/0x20
bpf_struct_ops_link_create+0x2c3/0x3b0
__sys_bpf+0x3102/0x4b00
__x64_sys_bpf+0x79/0xc0
x64_sys_call+0x15d9/0x1dd0
do_syscall_64+0xf0/0x470
entry_SYSCALL_64_after_hwframe+0x77/0x7f--- kernel/sched/ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/sched/ext.c +2 -2
@@ -3512,7 +3512,7 @@ static void scx_sched_free_rcu_work(struint node;irq_work_sync (&sch->error_irq_work); -kthread_stop (sch->helper->task); +kthread_destroy_worker (sch->helper);free_percpu (sch->pcpu);
@@ -4504,7 +4504,7 @@ static struct scx_sched *scx_alloc_and_areturn sch; err_stop_helper: -kthread_stop (sch->helper->task); +kthread_destroy_worker (sch->helper); err_free_pcpu:free_percpu (sch->pcpu); err_free_gdsqs:
Greg Kroah-Hartman
maintainerPATCH 235/430 sched_ext: Fix bypass depth leak on scx_enable() failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 9f769637a93fac81689b80df6855f545839cf999 upstream.
scx_enable() calls scx_bypass(true) to initialize in bypass mode and then scx_bypass(false) on success to exit. If scx_enable() fails during task initialization - e.g. scx_cgroup_init() or scx_init_task() returns an error - it jumps to err_disable while bypass is still active. scx_disable_workfn() then calls scx_bypass(true/false) for its own bypass, leaving the bypass depth at 1 instead of 0. This causes the system to remain permanently in bypass mode after a failed scx_enable().
Failures after task initialization is complete - e.g. scx_tryset_enable_state() at the end - already call scx_bypass(false) before reaching the error path and are not affected. This only affects a subset of failure modes.
Fix it by tracking whether scx_enable() called scx_bypass(true) in a bool and having scx_disable_workfn() call an extra scx_bypass(false) to clear it. This is a temporary measure as the bypass depth will be moved into the sched instance, which will make this tracking unnecessary.
--- kernel/sched/ext.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
kernel/sched/ext.c +14 -0
@@ -40,6 +40,13 @@ static bool scx_init_task_enabled;static bool scx_switching_all;DEFINE_STATIC_KEY_FALSE (__scx_switched_all); +/* +* Tracks whether scx_enable() called scx_bypass(true). Used to balance bypass +* depth on enable failure. Will be removed when bypass depth is moved into the +* sched instance. +*/ +static bool scx_bypassed_for_enable; +static atomic_long_t scx_nr_rejected =ATOMIC_LONG_INIT (0 );static atomic_long_t scx_hotplug_seq =ATOMIC_LONG_INIT (0 );
@@ -4051,6 +4058,11 @@ static void scx_disable_workfn(struct kt scx_dsp_max_batch =0 ;free_kick_pseqs (); +if (scx_bypassed_for_enable) { + scx_bypassed_for_enable = false; +scx_bypass (false); + } +mutex_unlock (&scx_enable_mutex);WARN_ON_ONCE (scx_set_enable_state (SCX_DISABLED ) !=SCX_DISABLING );
@@ -4676,6 +4688,7 @@ static int scx_enable(struct sched_ext_o* Init in bypass mode to guarantee forward progress. */ scx_bypass (true); + scx_bypassed_for_enable = true;for (i =SCX_OPI_NORMAL_BEGIN ; i <SCX_OPI_NORMAL_END ; i++)if (((void (**)(void ))ops)[i])
@@ -4780,6 +4793,7 @@ static int scx_enable(struct sched_ext_oscx_task_iter_stop (&sti);percpu_up_write (&scx_fork_rwsem); + scx_bypassed_for_enable = false;scx_bypass (false);if (!scx_tryset_enable_state (SCX_ENABLED ,SCX_ENABLING )) {
Greg Kroah-Hartman
maintainerPATCH 236/430 sched_ext: Fix missing post-enqueue handling in move_local_task_to_local_dsq()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit f5e1e5ec204da11fa87fdf006d451d80ce06e118 upstream.
move_local_task_to_local_dsq() is used when moving a task from a non-local DSQ to a local DSQ on the same CPU. It directly manipulates the local DSQ without going through dispatch_enqueue() and was missing the post-enqueue handling that triggers preemption when SCX_ENQ_PREEMPT is set or the idle task is running.
The function is used by move_task_between_dsqs() which backs scx_bpf_dsq_move() and may be called while the CPU is busy.
Add local_dsq_post_enq() call to move_local_task_to_local_dsq(). As the dispatch path doesn't need post-enqueue handling, add SCX_RQ_IN_BALANCE early exit to keep consume_dispatch_q() behavior unchanged and avoid triggering unnecessary resched when scx_bpf_dsq_move() is used from the dispatch path.
--- kernel/sched/ext.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/sched/ext.c +10 -0
@@ -919,6 +919,14 @@ static void local_dsq_post_enq(struct sc struct rq *rq = container_of(dsq, struct rq, scx.local_dsq);bool preempt = false; +/* +* If @rq is in balance, the CPU is already vacant and looking for the +* next task to run. No need to preempt or trigger resched after moving +* @p into its local DSQ. +*/ +if (rq->scx.flags &SCX_RQ_IN_BALANCE ) +return ; +if ((enq_flags &SCX_ENQ_PREEMPT ) && p != rq->curr && rq->curr->sched_class == &ext_sched_class) { rq->curr->scx.slice =0 ;
@@ -1524,6 +1532,8 @@ static void move_local_task_to_local_dsqdsq_mod_nr (dst_dsq,1 ); p->scx.dsq = dst_dsq; + +local_dsq_post_enq (dst_dsq, p, enq_flags); }/**
Greg Kroah-Hartman
maintainerPATCH 237/430 x86/mce: Do not clear banks poll bit in mce_poll_banks on AMD SMCA systems
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Avadhut Naik <[email protected]>
commit d7ac083f095d894a0b8ac0573516bfd035e6b25a upstream.
Currently, when a CMCI storm detected on a Machine Check bank, subsides, the bank's corresponding bit in the mce_poll_banks per-CPU variable is cleared unconditionally by cmci_storm_end().
On AMD SMCA systems, this essentially disables polling on that particular bank on that CPU. Consequently, any subsequent correctable errors or storms will not be logged.
Since AMD SMCA systems allow banks to be managed by both polling and interrupts, the polling banks bitmap for a CPU, i.e., mce_poll_banks, should not be modified when a storm subsides.
--- arch/x86/kernel/cpu/mce/threshold.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/cpu/mce/threshold.c +2 -1
@@ -85,7 +85,8 @@ void cmci_storm_end(unsigned int bank) {struct mca_storm_desc *storm =this_cpu_ptr (&storm_desc); -__clear_bit (bank,this_cpu_ptr (mce_poll_banks)); +if (!mce_flags.amd_threshold) +__clear_bit (bank,this_cpu_ptr (mce_poll_banks)); storm->banks[bank].history =0 ; storm->banks[bank].in_storm_mode = false;
Greg Kroah-Hartman
maintainerPATCH 238/430 mmc: sdhci-msm: Avoid early clock doubling during HS400 transition
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarthak Garg <[email protected]>
commit b1f856b1727c2eaa4be2c6d7cd7a8ed052bbeb87 upstream.
According to the hardware programming guide, the clock frequency must remain below 52MHz during the transition to HS400 mode.
However,in the current implementation, the timing is set to HS400 (a DDR mode) before adjusting the clock. This causes the clock to double prematurely to 104MHz during the transition phase, violating the specification and potentially resulting in CRC errors or CMD timeouts.
This change ensures that clock doubling is avoided during intermediate transitions and is applied only when the card requires a 200MHz clock for HS400 operation.
--- drivers/mmc/host/sdhci-msm.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-)
drivers/mmc/host/sdhci-msm.c +15 -12
@@ -344,41 +344,43 @@ static void sdhci_msm_v5_variant_writel_writel_relaxed (val, host->ioaddr + offset); } -static unsigned int msm_get_clock_mult_for_bus_mode (struct sdhci_host *host) +static unsigned int msm_get_clock_mult_for_bus_mode (struct sdhci_host *host, +unsigned int clock, +unsigned int timing) { -struct mmc_ios ios = host->mmc->ios;/* * The SDHC requires internal clock frequency to be double the * actual clock that will be set for DDR mode. The controller * uses the faster clock(100/400MHz) for some of its parts and * send the actual required clock (50/200MHz) to the card. */ -if (ios.timing ==MMC_TIMING_UHS_DDR50 || - ios.timing ==MMC_TIMING_MMC_DDR52 || - ios.timing ==MMC_TIMING_MMC_HS400 || +if (timing ==MMC_TIMING_UHS_DDR50 || + timing ==MMC_TIMING_MMC_DDR52 || + (timing ==MMC_TIMING_MMC_HS400 && + clock ==MMC_HS200_MAX_DTR ) || host->flags &SDHCI_HS400_TUNING )return 2 ;return 1 ; }static void msm_set_clock_rate_for_bus_mode (struct sdhci_host *host, -unsigned int clock) +unsigned int clock, +unsigned int timing) {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host); -struct mmc_ios curr_ios = host->mmc->ios;struct clk *core_clk = msm_host->bulk_clks[0 ].clk;unsigned long achieved_rate;unsigned int desired_rate;unsigned int mult;int rc; - mult =msm_get_clock_mult_for_bus_mode (host); + mult =msm_get_clock_mult_for_bus_mode (host, clock, timing); desired_rate = clock * mult; rc =dev_pm_opp_set_rate (mmc_dev (host->mmc), desired_rate);if (rc) {pr_err ("%s: Failed to set clock at rate %u at timing %d\n" , -mmc_hostname (host->mmc), desired_rate, curr_ios.timing); +mmc_hostname (host->mmc), desired_rate, timing);return ; }
@@ -397,7 +399,7 @@ static void msm_set_clock_rate_for_bus_m msm_host->clk_rate = desired_rate;pr_debug ("%s: Setting clock at rate %lu at timing %d\n" , -mmc_hostname (host->mmc), achieved_rate, curr_ios.timing); +mmc_hostname (host->mmc), achieved_rate, timing); }/* Platform specific tuning */
@@ -1239,7 +1241,7 @@ static int sdhci_msm_execute_tuning(stru*/ if (host->flags &SDHCI_HS400_TUNING ) {sdhci_msm_hc_select_mode (host); -msm_set_clock_rate_for_bus_mode (host, ios.clock); +msm_set_clock_rate_for_bus_mode (host, ios.clock, ios.timing); host->flags &= ~SDHCI_HS400_TUNING ; }
@@ -1864,6 +1866,7 @@ static void sdhci_msm_set_clock(struct s {struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_msm_host *msm_host =sdhci_pltfm_priv (pltfm_host); +struct mmc_ios ios = host->mmc->ios;if (!clock) { host->mmc->actual_clock = msm_host->clk_rate =0 ;
@@ -1872,7 +1875,7 @@ static void sdhci_msm_set_clock(struct ssdhci_msm_hc_select_mode (host); -msm_set_clock_rate_for_bus_mode (host, clock); +msm_set_clock_rate_for_bus_mode (host, ios.clock, ios.timing); out:__sdhci_msm_set_clock (host, clock); }
Greg Kroah-Hartman
maintainerPATCH 239/430 dt-bindings: clock: mmcc-sdm660: Add missing MDSS reset
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Minnekhanov <[email protected]>
commit c57210bc15371caa06a5d4040e7d8aaeed4cb661 upstream.
Add definition for display subsystem reset control, so display driver can reset display controller properly, clearing any configuration left there by bootloader. Since 6.17 after PM domains rework it became necessary for display to function.
--- include/dt-bindings/clock/qcom,mmcc-sdm660.h | 1 + 1 file changed, 1 insertion(+)
include/dt-bindings/clock/qcom,mmcc-sdm660.h +1 -0
@@ -157,6 +157,7 @@#define BIMC_SMMU_GDSC 7#define CAMSS_MICRO_BCR 0 +#define MDSS_BCR 1#endif
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 240/430 phy: exynos5-usbdrd: fix clock prepare imbalance
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
commit 5e428e45bf17a8f3784099ca5ded16e3b5d59766 upstream.
Commit f4fb9c4d7f94 ("phy: exynos5-usbdrd: allow DWC3 runtime suspend with UDC bound (E850+)") incorrectly added clk_bulk_disable() as the inverse of clk_bulk_prepare_enable() while it should have of course used clk_bulk_disable_unprepare(). This means incorrect reference counts to the CMU driver remain.
Update the code accordingly.
--- drivers/phy/samsung/phy-exynos5-usbdrd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/samsung/phy-exynos5-usbdrd.c +1 -1
@@ -1823,7 +1823,7 @@ static int exynos5_usbdrd_orien_sw_set(s phy_drd->orientation = orientation; } -clk_bulk_disable (phy_drd->drv_data->n_clks, phy_drd->clks); +clk_bulk_disable_unprepare (phy_drd->drv_data->n_clks, phy_drd->clks);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 241/430 efi: Add missing static initializer for efi_mm::cpus_allowed_lock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ard Biesheuvel <[email protected]>
commit 40374d308e4e456048d83991e937f13fc8bda8bf upstream.
Initialize the cpus_allowed_lock struct member of efi_mm.
--- drivers/firmware/efi/efi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/firmware/efi/efi.c +3 -0
@@ -74,6 +74,9 @@ struct mm_struct efi_mm = { .page_table_lock = __SPIN_LOCK_UNLOCKED(efi_mm.page_table_lock), .mmlist = LIST_HEAD_INIT(efi_mm.mmlist), .cpu_bitmap = { [BITS_TO_LONGS(NR_CPUS)] = 0}, +#ifdef CONFIG_SCHED_MM_CID + .cpus_allowed_lock = __RAW_SPIN_LOCK_UNLOCKED(efi_mm.cpus_allowed_lock), +#endif };struct workqueue_struct *efi_rts_wq;
Greg Kroah-Hartman
maintainerPATCH 242/430 perf: arm_cspmu: fix error handling in arm_cspmu_impl_unregister()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ma Ke <[email protected]>
commit 970e1e41805f0bd49dc234330a9390f4708d097d upstream.
driver_find_device() calls get_device() to increment the reference count once a matching device is found. device_release_driver() releases the driver, but it does not decrease the reference count that was incremented by driver_find_device(). At the end of the loop, there is no put_device() to balance the reference count. To avoid reference count leakage, add put_device() to decrease the reference count.
Found by code review.
--- drivers/perf/arm_cspmu/arm_cspmu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/perf/arm_cspmu/arm_cspmu.c +3 -1
@@ -1365,8 +1365,10 @@ void arm_cspmu_impl_unregister(const str/* Unbind the driver from all matching backend devices. */ while ((dev =driver_find_device (&arm_cspmu_driver.driver,NULL , - match, arm_cspmu_match_device))) + match, arm_cspmu_match_device))) {device_release_driver (dev); +put_device (dev); + }mutex_lock (&arm_cspmu_lock);
Greg Kroah-Hartman
maintainerPATCH 243/430 lib/crypto: x86/blake2s: Fix 32-bit arg treated as 64-bit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 2f22115709fc7ebcfa40af3367a508fbbd2f71e9 upstream.
In the C code, the 'inc' argument to the assembly functions blake2s_compress_ssse3() and blake2s_compress_avx512() is declared with type u32, matching blake2s_compress(). The assembly code then reads it from the 64-bit %rcx. However, the ABI doesn't guarantee zero-extension to 64 bits, nor do gcc or clang guarantee it. Therefore, fix these functions to read this argument from the 32-bit %ecx.
In theory, this bug could have caused the wrong 'inc' value to be used, causing incorrect BLAKE2s hashes. In practice, probably not: I've fixed essentially this same bug in many other assembly files too, but there's never been a real report of it having caused a problem. In x86_64, all writes to 32-bit registers are zero-extended to 64 bits. That results in zero-extension in nearly all situations. I've only been able to demonstrate a lack of zero-extension with a somewhat contrived example involving truncation, e.g. when the C code has a u64 variable holding 0x1234567800000040 and passes it as a u32 expecting it to be truncated to 0x40 (64). But that's not what the real code does, of course.
--- lib/crypto/x86/blake2s-core.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/crypto/x86/blake2s-core.S +2 -2
@@ -52,7 +52,7 @@ SYM_FUNC_START(blake2s_compress_ssse3) movdqa ROT16(%rip),%xmm12 movdqa ROR328(%rip),%xmm13 movdqu 0x20(%rdi),%xmm14 - movq %rcx,%xmm15 + movd %ecx,%xmm15 leaq SIGMA+0xa0(%rip),%r8 jmp .Lbeginofloop .align 32
@@ -176,7 +176,7 @@ SYM_FUNC_START(blake2s_compress_avx512) vmovdqu (%rdi),%xmm0 vmovdqu 0x10(%rdi),%xmm1 vmovdqu 0x20(%rdi),%xmm4 - vmovq %rcx,%xmm5 + vmovd %ecx,%xmm5 vmovdqa IV(%rip),%xmm14 vmovdqa IV+16(%rip),%xmm15 jmp .Lblake2s_compress_avx512_mainloop
Greg Kroah-Hartman
maintainerPATCH 244/430 s390/dasd: Fix gendisk parent after copy pair swap
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Haberland <[email protected]>
commit c943bfc6afb8d0e781b9b7406f36caa8bbf95cb9 upstream.
After a copy pair swap the block device's "device" symlink points to the secondary CCW device, but the gendisk's parent remained the primary, leaving /sys/block/<dasdx> under the wrong parent.
Move the gendisk to the secondary's device with device_move(), keeping the sysfs topology consistent after the swap.
--- drivers/s390/block/dasd_eckd.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/s390/block/dasd_eckd.c +8 -0
@@ -6150,6 +6150,7 @@ static int dasd_eckd_copy_pair_swap(strustruct dasd_copy_relation *copy;struct dasd_block *block;struct gendisk *gdp; +int rc; copy = device->copy;if (!copy)
@@ -6184,6 +6185,13 @@ static int dasd_eckd_copy_pair_swap(stru/* swap blocklayer device link */ gdp = block->gdp;dasd_add_link_to_gendisk (gdp, secondary); + rc =device_move (disk_to_dev (gdp), &secondary->cdev->dev,DPM_ORDER_NONE ); +if (rc) { +dev_err (&primary->cdev->dev, +"copy_pair_swap: moving blockdevice parent %s->%s failed (%d)\n" , +dev_name (&primary->cdev->dev), +dev_name (&secondary->cdev->dev), rc); + }/* re-enable device */ dasd_device_remove_stop_bits (primary,DASD_STOPPED_PPRC );
Greg Kroah-Hartman
maintainerPATCH 245/430 wifi: mt76: Fix DTS power-limits on little endian systems
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann (Plasma Cloud) <[email protected]>
commit 38b845e1f9e810869b0a0b69f202b877b7b7fb12 upstream.
The power-limits for ru and mcs and stored in the devicetree as bytewise array (often with sizes which are not a multiple of 4). These arrays have a prefix which defines for how many modes a line is applied. This prefix is also only a byte - but the code still tried to fix the endianness of this byte with a be32 operation. As result, loading was mostly failing or was sending completely unexpected values to the firmware.
Since the other rates are also stored in the devicetree as bytewise arrays, just drop the u32 access + be32_to_cpu conversion and directly access them as bytes arrays.
--- drivers/net/wireless/mediatek/mt76/eeprom.c | 37 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/eeprom.c +24 -13
@@ -253,6 +253,19 @@ mt76_get_of_array(struct device_node *npreturn prop->value; } +static const s8 * +mt76_get_of_array_s8 (struct device_node *np,char *name,size_t *len,int min) +{ +struct property *prop =of_find_property (np, name,NULL ); + +if (!prop || !prop->value || prop->length < min) +return NULL ; + + *len = prop->length; + +return prop->value; +} +struct device_node *mt76_find_channel_node (struct device_node *np,struct ieee80211_channel *chan) {
@@ -294,7 +307,7 @@ mt76_get_txs_delta(struct device_node *n }static void -mt76_apply_array_limit (s8 *pwr,size_t pwr_len,const __be32 *data, +mt76_apply_array_limit (s8 *pwr,size_t pwr_len,const s8 *data,s8 target_power,s8 nss_delta,s8 *max_power) {int i;
@@ -303,15 +316,14 @@ mt76_apply_array_limit(s8 *pwr, size_t preturn ;for (i =0 ; i < pwr_len; i++) { - pwr[i] =min_t (s8, target_power, -be32_to_cpu (data[i]) + nss_delta); + pwr[i] =min_t (s8, target_power, data[i] + nss_delta); *max_power =max (*max_power, pwr[i]); } }static void mt76_apply_multi_array_limit (s8 *pwr,size_t pwr_len,s8 pwr_num, -const __be32 *data,size_t len,s8 target_power, +const s8 *data,size_t len,s8 target_power,s8 nss_delta,s8 *max_power) {int i, cur;
@@ -319,8 +331,7 @@ mt76_apply_multi_array_limit(s8 *pwr, siif (!data)return ; - len /=4 ; - cur =be32_to_cpu (data[0 ]); + cur = data[0 ];for (i =0 ; i < pwr_num; i++) {if (len < pwr_len +1 )break ;
@@ -335,7 +346,7 @@ mt76_apply_multi_array_limit(s8 *pwr, siif (!len)break ; - cur =be32_to_cpu (data[0 ]); + cur = data[0 ]; } }
@@ -346,7 +357,7 @@ s8 mt76_get_rate_power_limits(struct mt7 {struct mt76_dev *dev = phy->dev;struct device_node *np; -const __be32 *val; +const s8 *val;char name[16 ];u32 mcs_rates = dev->drv->mcs_rates;u32 ru_rates =ARRAY_SIZE (dest->ru[0 ]);
@@ -392,21 +403,21 @@ s8 mt76_get_rate_power_limits(struct mt7 txs_delta =mt76_get_txs_delta (np,hweight16 (phy->chainmask)); - val =mt76_get_of_array (np,"rates-cck" , &len,ARRAY_SIZE (dest->cck)); + val =mt76_get_of_array_s8 (np,"rates-cck" , &len,ARRAY_SIZE (dest->cck));mt76_apply_array_limit (dest->cck,ARRAY_SIZE (dest->cck), val, target_power, txs_delta, &max_power); - val =mt76_get_of_array (np,"rates-ofdm" , - &len,ARRAY_SIZE (dest->ofdm)); + val =mt76_get_of_array_s8 (np,"rates-ofdm" , + &len,ARRAY_SIZE (dest->ofdm));mt76_apply_array_limit (dest->ofdm,ARRAY_SIZE (dest->ofdm), val, target_power, txs_delta, &max_power); - val =mt76_get_of_array (np,"rates-mcs" , &len, mcs_rates +1 ); + val =mt76_get_of_array_s8 (np,"rates-mcs" , &len, mcs_rates +1 );mt76_apply_multi_array_limit (dest->mcs[0 ],ARRAY_SIZE (dest->mcs[0 ]),ARRAY_SIZE (dest->mcs), val, len, target_power, txs_delta, &max_power); - val =mt76_get_of_array (np,"rates-ru" , &len, ru_rates +1 ); + val =mt76_get_of_array_s8 (np,"rates-ru" , &len, ru_rates +1 );mt76_apply_multi_array_limit (dest->ru[0 ],ARRAY_SIZE (dest->ru[0 ]),ARRAY_SIZE (dest->ru), val, len, target_power, txs_delta, &max_power);
Greg Kroah-Hartman
maintainerPATCH 246/430 btrfs: dont rewrite ret from inode_permission
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
commit 0185c2292c600993199bc6b1f342ad47a9e8c678 upstream.
In our user safe ino resolve ioctl we'll just turn any ret into -EACCES from inode_permission(). This is redundant, and could potentially be wrong if we had an ENOMEM in the security layer or some such other error, so simply return the actual return value.
Note: The patch was taken from v5 of fscrypt patchset
(https://lore.kernel.org/linux-btrfs/[email protected]/)
which was handled over time by various people: Omar Sandoval, Sweet Tea Dorminy, Josef Bacik.
--- fs/btrfs/ioctl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/btrfs/ioctl.c +1 -3
@@ -1913,10 +1913,8 @@ static int btrfs_search_path_in_tree_use ret =inode_permission (idmap, &temp_inode->vfs_inode,MAY_READ |MAY_EXEC );iput (&temp_inode->vfs_inode); -if (ret) { - ret = -EACCES ; +if (ret) goto out_put; - }if (key.offset == upper_limit)break ;
Greg Kroah-Hartman
maintainerPATCH 247/430 gfs2: fix freeze error handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Velichayshiy <[email protected]>
commit 4cfc7d5a4a01d2133b278cdbb1371fba1b419174 upstream.
After commit b77b4a4815a9 ("gfs2: Rework freeze / thaw logic"), the freeze error handling is broken because gfs2_do_thaw() overwrites the 'error' variable, causing incorrect processing of the original freeze error.
Fix this by calling gfs2_do_thaw() when gfs2_lock_fs_check_clean() fails but ignoring its return value to preserve the original freeze error for proper reporting.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- fs/gfs2/super.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/gfs2/super.c +1 -3
@@ -749,9 +749,7 @@ static int gfs2_freeze_super(struct supebreak ; } - error =gfs2_do_thaw (sdp, who, freeze_owner); -if (error) - goto out; + (void )gfs2_do_thaw (sdp, who, freeze_owner);if (error == -EBUSY )fs_err (sdp,"waiting for recovery before freeze\n" );
Greg Kroah-Hartman
maintainerPATCH 248/430 block: rate-limit capacity change info log
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Chen <[email protected]>
commit 3179a5f7f86bcc3acd5d6fb2a29f891ef5615852 upstream.
loop devices under heavy stress-ng loop streessor can trigger many capacity change events in a short time. Each event prints an info message from set_capacity_and_notify(), flooding the console and contributing to soft lockups on slow consoles.
Switch the printk in set_capacity_and_notify() to pr_info_ratelimited() so frequent capacity changes do not spam the log while still reporting occasional changes.
--- block/genhd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/genhd.c +1 -1
@@ -90,7 +90,7 @@ bool set_capacity_and_notify(struct gend (disk->flags & GENHD_FL_HIDDEN))return false; -pr_info ("%s: detected capacity change from %lld to %lld\n" , +pr_info_ratelimited ("%s: detected capacity change from %lld to %lld\n" , disk->disk_name, capacity, size);/*
Greg Kroah-Hartman
maintainerPATCH 249/430 jbd2: fix the inconsistency between checksum and data in memory for journal sb
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ye Bin <[email protected]>
commit 6abfe107894af7e8ce3a2e120c619d81ee764ad5 upstream.
Copying the file system while it is mounted as read-only results in a mount failure:
[~]# mkfs.ext4 -F /dev/sdc
[~]# mount /dev/sdc -o ro /mnt/test
[~]# dd if=/dev/sdc of=/dev/sda bs=1M
[~]# mount /dev/sda /mnt/test1
[ 1094.849826] JBD2: journal checksum error [ 1094.850927] EXT4-fs (sda): Could not load journal inode
mount: mount /dev/sda on /mnt/test1 failed: Bad message
The process described above is just an abstracted way I came up with to reproduce the issue. In the actual scenario, the file system was mounted read-only and then copied while it was still mounted. It was found that the mount operation failed. The user intended to verify the data or use it as a backup, and this action was performed during a version upgrade. Above issue may happen as follows:ext4_fill_super
set_journal_csum_feature_set(sb)
if (ext4_has_metadata_csum(sb))
incompat = JBD2_FEATURE_INCOMPAT_CSUM_V3;
if (test_opt(sb, JOURNAL_CHECKSUM)
jbd2_journal_set_features(sbi->s_journal, compat, 0, incompat);
lock_buffer(journal->j_sb_buffer);
sb->s_feature_incompat |= cpu_to_be32(incompat);
//The data in the journal sb was modified, but the checksum was not
updated, so the data remaining in memory has a mismatch between the
data and the checksum.
unlock_buffer(journal->j_sb_buffer);In this case, the journal sb copied over is in a state where the checksum and data are inconsistent, so mounting fails.
To solve the above issue, update the checksum in memory after modifying the journal sb.
Message-ID: <[email protected]>
--- fs/jbd2/journal.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/jbd2/journal.c +14 -0
@@ -2349,6 +2349,12 @@ int jbd2_journal_set_features(journal_t sb->s_feature_compat |=cpu_to_be32 (compat); sb->s_feature_ro_compat |=cpu_to_be32 (ro); sb->s_feature_incompat |=cpu_to_be32 (incompat); +/* +* Update the checksum now so that it is valid even for read-only +* filesystems where jbd2_write_superblock() doesn't get called. +*/ +if (jbd2_journal_has_csum_v2or3 (journal)) + sb->s_checksum =jbd2_superblock_csum (sb);unlock_buffer (journal->j_sb_buffer);jbd2_journal_init_transaction_limits (journal);
@@ -2378,9 +2384,17 @@ void jbd2_journal_clear_features(journal sb = journal->j_superblock; +lock_buffer (journal->j_sb_buffer); sb->s_feature_compat &= ~cpu_to_be32 (compat); sb->s_feature_ro_compat &= ~cpu_to_be32 (ro); sb->s_feature_incompat &= ~cpu_to_be32 (incompat); +/* +* Update the checksum now so that it is valid even for read-only +* filesystems where jbd2_write_superblock() doesn't get called. +*/ +if (jbd2_journal_has_csum_v2or3 (journal)) + sb->s_checksum =jbd2_superblock_csum (sb); +unlock_buffer (journal->j_sb_buffer);jbd2_journal_init_transaction_limits (journal); }EXPORT_SYMBOL (jbd2_journal_clear_features);
Greg Kroah-Hartman
maintainerPATCH 250/430 floppy: fix for PAGE_SIZE != 4KB
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rene Rebe <[email protected]>
commit 82d20481024cbae2ea87fe8b86d12961bfda7169 upstream.
For years I wondered why the floppy driver does not just work on sparc64, e.g:
root@SUNW_375_0066:# disktype /dev/fd0 disktype: Can't open /dev/fd0: No such device or address
[ 525.341906] disktype: attempt to access beyond end of device fd0: rw=0, sector=0, nr_sectors = 16 limit=8 [ 525.341991] floppy: error 10 while reading block 0
Turns out floppy.c __floppy_read_block_0 tries to read one page for the first test read to determine the disk size and thus fails if that is greater than 4k. Adjust minimum MAX_DISK_SIZE to PAGE_SIZE to fix floppy on sparc64 and likely all other PAGE_SIZE != 4KB configs.
--- drivers/block/floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/floppy.c +1 -1
@@ -329,7 +329,7 @@ static bool initialized;* This default is used whenever the current disk size is unknown. * [Now it is rather a minimum] */ -#define MAX_DISK_SIZE 4/* 3984 */ +#define MAX_DISK_SIZE (PAGE_SIZE / 1024)/* * globals used by 'result()'
Greg Kroah-Hartman
maintainerPATCH 251/430 crypto: scatterwalk - Fix memcpy_sglist() to always succeed
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit 4dffc9bbffb9ccfcda730d899c97c553599e7ca8 upstream.
The original implementation of memcpy_sglist() was broken because it didn't handle scatterlists that describe exactly the same memory, which is a case that many callers rely on. The current implementation is broken too because it calls the skcipher_walk functions which can fail. It ignores any errors from those functions.
Fix it by replacing it with a new implementation written from scratch. It always succeeds. It's also a bit faster, since it avoids the overhead of skcipher_walk. skcipher_walk includes a lot of functionality (such as alignmask handling) that's irrelevant here.
--- crypto/scatterwalk.c | 95 +++++++++++++++++++++++++++++++----- include/crypto/scatterwalk.h | 52 ++++++++++++-------- 2 files changed, 114 insertions(+), 33 deletions(-)
crypto/scatterwalk.c +83 -12
@@ -101,26 +101,97 @@ void memcpy_to_sglist(struct scatterlist *sg, unsigned int start, }EXPORT_SYMBOL_GPL (memcpy_to_sglist); +/** +* memcpy_sglist() - Copy data from one scatterlist to another +* @dst: The destination scatterlist. Can be NULL if @nbytes == 0. +* @src: The source scatterlist. Can be NULL if @nbytes == 0. +* @nbytes: Number of bytes to copy +* +* The scatterlists can describe exactly the same memory, in which case this +* function is a no-op. No other overlaps are supported. +* +* Context: Any context +*/ void memcpy_sglist (struct scatterlist *dst,struct scatterlist *src,unsigned int nbytes) { -struct skcipher_walk walk = {}; +unsigned int src_offset, dst_offset; -if (unlikely (nbytes ==0 ))/* in case sg == NULL */ +if (unlikely (nbytes ==0 ))/* in case src and/or dst is NULL */ return ; - walk.total = nbytes; + src_offset = src->offset; + dst_offset = dst->offset; +for (;;) { +/* Compute the length to copy this step. */ +unsigned int len =min3 (src->offset + src->length - src_offset, + dst->offset + dst->length - dst_offset, + nbytes); +struct page *src_page =sg_page (src); +struct page *dst_page =sg_page (dst); +const void *src_virt; +void *dst_virt; -scatterwalk_start (&walk.in, src); -scatterwalk_start (&walk.out, dst); +if (IS_ENABLED (CONFIG_HIGHMEM )) { +/* HIGHMEM: we may have to actually map the pages. */ +const unsigned int src_oip =offset_in_page (src_offset); +const unsigned int dst_oip =offset_in_page (dst_offset); +const unsigned int limit =PAGE_SIZE ; -skcipher_walk_first (&walk, true); -do { -if (walk.src.virt.addr != walk.dst.virt.addr) -memcpy (walk.dst.virt.addr, walk.src.virt.addr, - walk.nbytes); -skcipher_walk_done (&walk,0 ); - }while (walk.nbytes); +/* Further limit len to not cross a page boundary. */ + len =min3 (len, limit - src_oip, limit - dst_oip); + +/* Compute the source and destination pages. */ + src_page += src_offset /PAGE_SIZE ; + dst_page += dst_offset /PAGE_SIZE ; + +if (src_page != dst_page) { +/* Copy between different pages. */ +memcpy_page (dst_page, dst_oip, + src_page, src_oip, len); +flush_dcache_page (dst_page); + }else if (src_oip != dst_oip) { +/* Copy between different parts of same page. */ + dst_virt =kmap_local_page (dst_page); +memcpy (dst_virt + dst_oip, dst_virt + src_oip, + len); +kunmap_local (dst_virt); +flush_dcache_page (dst_page); + }/* Else, it's the same memory. No action needed. */ + }else { +/* +* !HIGHMEM: no mapping needed. Just work in the linear +* buffer of each sg entry. Note that we can cross page +* boundaries, as they are not significant in this case. +*/ + src_virt =page_address (src_page) + src_offset; + dst_virt =page_address (dst_page) + dst_offset; +if (src_virt != dst_virt) { +memcpy (dst_virt, src_virt, len); +if (ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE ) +__scatterwalk_flush_dcache_pages ( + dst_page, dst_offset, len); + }/* Else, it's the same memory. No action needed. */ + } + nbytes -= len; +if (nbytes ==0 )/* No more to copy? */ +break ; + +/* +* There's more to copy. Advance the offsets by the length +* copied this step, and advance the sg entries as needed. +*/ + src_offset += len; +if (src_offset >= src->offset + src->length) { + src =sg_next (src); + src_offset = src->offset; + } + dst_offset += len; +if (dst_offset >= dst->offset + dst->length) { + dst =sg_next (dst); + dst_offset = dst->offset; + } + } }EXPORT_SYMBOL_GPL (memcpy_sglist);
include/crypto/scatterwalk.h +31 -21
64 lines not on this page · raw message
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 252/430 kallsyms: Fix wrong "big" kernel symbol type read from procfs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zheng Yejian <[email protected]>
commit f3f9f42232dee596d15491ca3f611d02174db49c upstream.
Currently when the length of a symbol is longer than 0x7f characters, its type shown in /proc/kallsyms can be incorrect.
I found this issue when reading the code, but it can be reproduced by following steps:
1. Define a function which symbol length is 130 characters:
#define X13(x) x##x##x##x##x##x##x##x##x##x##x##x##x
static noinline void X13(x123456789)(void)
{
printk("hello world\n");
}2. The type in vmlinux is 't':
$ nm vmlinux | grep x123456
ffffffff816290f0 t x123456789x123456789x123456789x12[...] 3. Then boot the kernel, the type shown in /proc/kallsyms becomes 'g'
instead of the expected 't':
# cat /proc/kallsyms | grep x123456
ffffffff816290f0 g x123456789x123456789x123456789x12[...]The root cause is that, after commit 73bbb94466fd ("kallsyms: support "big" kernel symbols"), ULEB128 was used to encode symbol name length. That is, for "big" kernel symbols of which name length is longer than 0x7f characters, the length info is encoded into 2 bytes.
kallsyms_get_symbol_type() expects to read the first char of the symbol name which indicates the symbol type. However, due to the "big" symbol case not being handled, the symbol type read from /proc/kallsyms may be wrong, so handle it properly.
--- kernel/kallsyms.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
kernel/kallsyms.c +4 -1
@@ -103,8 +103,11 @@ static char kallsyms_get_symbol_type(uns {/* * Get just the first code, look it up in the token table, -* and return the first char from this token. +* and return the first char from this token. If MSB of length +* is 1, it is a "big" symbol, so needs an additional byte. */ +if (kallsyms_names[off] &0x80 ) + off++;return kallsyms_token_table[kallsyms_token_index[kallsyms_names[off +1 ]]]; }
Greg Kroah-Hartman
maintainerPATCH 253/430 fs/ntfs3: fix mount failure for sparse runs in run_unpack()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
commit 801f614ba263cb37624982b27b4c82f3c3c597a9 upstream.
Some NTFS volumes failed to mount because sparse data runs were not handled correctly during runlist unpacking. The code performed arithmetic on the special SPARSE_LCN64 marker, leading to invalid LCN values and mount errors.
Add an explicit check for the case described above, marking the run as sparse without applying arithmetic.
--- fs/ntfs3/run.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ntfs3/run.c +5 -1
@@ -984,8 +984,12 @@ int run_unpack(struct runs_tree *run, stif (!dlcn)return -EINVAL ; -if (check_add_overflow (prev_lcn, dlcn, &lcn)) +/* Check special combination: 0 + SPARSE_LCN64. */ +if (!prev_lcn && dlcn ==SPARSE_LCN64 ) { + lcn =SPARSE_LCN64 ; + }else if (check_add_overflow (prev_lcn, dlcn, &lcn)) {return -EINVAL ; + } prev_lcn = lcn; }else {/* The size of 'dlcn' can't be > 8. */
Greg Kroah-Hartman
maintainerPATCH 254/430 ktest.pl: Fix uninitialized var in config-bisect.pl
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
commit d3042cbe84a060b4df764eb6c5300bbe20d125ca upstream.
The error path of copying the old config used the wrong variable in the error message:
$ mkdir /tmp/build $ ./tools/testing/ktest/config-bisect.pl -b /tmp/build config-good /tmp/config-bad $ chmod 0 /tmp/build $ ./tools/testing/ktest/config-bisect.pl -b /tmp/build config-good /tmp/config-bad good cp /tmp/build//.config config-good.tmp ... [0 seconds] FAILED! Use of uninitialized value $config in concatenation (.) or string at ./tools/testing/ktest/config-bisect.pl line 744. failed to copy to config-good.tmp
When it should have shown:
failed to copy /tmp/build//.config to config-good.tmp
--- tools/testing/ktest/config-bisect.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/ktest/config-bisect.pl +2 -2
@@ -741,9 +741,9 @@ if ($start) { die "Can not find file $bad\n"; } if ($val eq "good") { - run_command "cp $output_config $good" or die "failed to copy $config to $good\n"; + run_command "cp $output_config $good" or die "failed to copy $output_config to $good\n"; } elsif ($val eq "bad") { - run_command "cp $output_config $bad" or die "failed to copy $config to $bad\n"; + run_command "cp $output_config $bad" or die "failed to copy $output_config to $bad\n"; } }
Greg Kroah-Hartman
maintainerPATCH 255/430 tpm: Cap the number of PCR banks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit faf07e611dfa464b201223a7253e9dc5ee0f3c9e upstream.
tpm2_get_pcr_allocation() does not cap any upper limit for the number of banks. Cap the limit to eight banks so that out of bounds values coming from external I/O cause on only limited harm.
--- drivers/char/tpm/tpm-chip.c | 1 - drivers/char/tpm/tpm1-cmd.c | 5 ----- drivers/char/tpm/tpm2-cmd.c | 8 +++----- include/linux/tpm.h | 8 +++++--- 4 files changed, 8 insertions(+), 14 deletions(-)
drivers/char/tpm/tpm-chip.c +0 -1
@@ -282,7 +282,6 @@ static void tpm_dev_release(struct devickfree (chip->work_space.context_buf);kfree (chip->work_space.session_buf); -kfree (chip->allocated_banks);#ifdef CONFIG_TCG_TPM2_HMAC kfree (chip->auth);#endif
drivers/char/tpm/tpm1-cmd.c +0 -5
@@ -799,11 +799,6 @@ int tpm1_pm_suspend(struct tpm_chip *chi*/ int tpm1_get_pcr_allocation (struct tpm_chip *chip) { - chip->allocated_banks =kcalloc (1 ,sizeof (*chip->allocated_banks), -GFP_KERNEL ); -if (!chip->allocated_banks) -return -ENOMEM ; - chip->allocated_banks[0 ].alg_id =TPM_ALG_SHA1 ; chip->allocated_banks[0 ].digest_size = hash_digest_size[HASH_ALGO_SHA1 ]; chip->allocated_banks[0 ].crypto_id =HASH_ALGO_SHA1 ;
drivers/char/tpm/tpm2-cmd.c +3 -5
@@ -538,11 +538,9 @@ ssize_t tpm2_get_pcr_allocation(struct t nr_possible_banks =be32_to_cpup ( (__be32 *)&buf.data[TPM_HEADER_SIZE +5 ]); - - chip->allocated_banks =kcalloc (nr_possible_banks, -sizeof (*chip->allocated_banks), -GFP_KERNEL ); -if (!chip->allocated_banks) { +if (nr_possible_banks >TPM2_MAX_PCR_BANKS ) { +pr_err ("tpm: out of bank capacity: %u > %u\n" , + nr_possible_banks,TPM2_MAX_PCR_BANKS ); rc = -ENOMEM ; goto out; }
include/linux/tpm.h +5 -3
@@ -26,7 +26,9 @@#include <crypto/aes.h> #define TPM_DIGEST_SIZE 20/* Max TPM v1.2 PCR size */ -#define TPM_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE + +#define TPM2_MAX_DIGEST_SIZE SHA512_DIGEST_SIZE +#define TPM2_MAX_PCR_BANKS 8struct tpm_chip ;struct trusted_key_payload ;
@@ -68,7 +70,7 @@ enum tpm2_curves {struct tpm_digest {u16 alg_id; -u8 digest[TPM_MAX_DIGEST_SIZE ]; +u8 digest[TPM2_MAX_DIGEST_SIZE ]; } __packed;struct tpm_bank_info {
@@ -189,7 +191,7 @@ struct tpm_chip {unsigned int groups_cnt;u32 nr_allocated_banks; -struct tpm_bank_info *allocated_banks; +struct tpm_bank_info allocated_banks[TPM2_MAX_PCR_BANKS ];#ifdef CONFIG_ACPI acpi_handle acpi_dev_handle;char ppi_version[TPM_PPI_VERSION_LEN +1 ];
Greg Kroah-Hartman
maintainerPATCH 256/430 fs: PM: Fix reverse check in filesystems_freeze_callback()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
commit 222047f68e8565c558728f792f6fef152a1d4d51 upstream.
The freeze_all_ptr check in filesystems_freeze_callback() introduced by commit a3f8f8662771 ("power: always freeze efivarfs") is reverse which quite confusingly causes all file systems to be frozen when filesystem_freeze_enabled is false.
On my systems it causes the WARN_ON_ONCE() in __set_task_frozen() to trigger, most likely due to an attempt to freeze a file system that is not ready for that.
Add a logical negation to the check in question to reverse it as appropriate.
--- fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/super.c +1 -1
@@ -1188,7 +1188,7 @@ static void filesystems_freeze_callback(if (!sb->s_op->freeze_fs && !sb->s_op->freeze_super)return ; -if (freeze_all_ptr && !(sb->s_type->fs_flags &FS_POWER_FREEZE )) +if (!freeze_all_ptr && !(sb->s_type->fs_flags &FS_POWER_FREEZE ))return ;if (!get_active_super (sb))
Greg Kroah-Hartman
maintainerPATCH 257/430 printk: Allow printk_trigger_flush() to flush all types
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
commit d01ff281bd9b1bfeac9ab98ec8a9ee41da900d5e upstream.
Currently printk_trigger_flush() only triggers legacy offloaded flushing, even if that may not be the appropriate method to flush for currently registered consoles. (The function predates the NBCON consoles.)
Since commit 6690d6b52726 ("printk: Add helper for flush type logic") there is printk_get_console_flush_type(), which also considers NBCON consoles and reports all the methods of flushing appropriate based on the system state and consoles available.
Update printk_trigger_flush() to use printk_get_console_flush_type() to appropriately flush registered consoles.
--- kernel/printk/nbcon.c | 2 +- kernel/printk/printk.c | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-)
kernel/printk/nbcon.c +1 -1
@@ -1856,7 +1856,7 @@ void nbcon_device_release(struct consoleif (console_trylock ())console_unlock (); }else if (ft.legacy_offload) { -printk_trigger_flush (); +defer_console_output (); } }console_srcu_read_unlock (cookie);
kernel/printk/printk.c +22 -1
@@ -4595,9 +4595,30 @@ void defer_console_output(void)__wake_up_klogd (PRINTK_PENDING_WAKEUP |PRINTK_PENDING_OUTPUT ); } +/** +* printk_trigger_flush - Attempt to flush printk buffer to consoles. +* +* If possible, flush the printk buffer to all consoles in the caller's +* context. If offloading is available, trigger deferred printing. +* +* This is best effort. Depending on the system state, console states, +* and caller context, no actual flushing may result from this call. +*/ void printk_trigger_flush (void ) { -defer_console_output (); +struct console_flush_type ft; + +printk_get_console_flush_type (&ft); +if (ft.nbcon_atomic) +nbcon_atomic_flush_pending (); +if (ft.nbcon_offload) +nbcon_kthreads_wake (); +if (ft.legacy_direct) { +if (console_trylock ()) +console_unlock (); + } +if (ft.legacy_offload) +defer_console_output (); }int vprintk_deferred (const char *fmt,va_list args)
Greg Kroah-Hartman
maintainerPATCH 258/430 printk: Avoid irq_work for printk_deferred() on suspend
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Ogness <[email protected]>
commit 66e7c1e0ee08cfb6db64f8f3f6e5a3cc930145c8 upstream.
With commit ("printk: Avoid scheduling irq_work on suspend") the implementation of printk_get_console_flush_type() was modified to avoid offloading when irq_work should be blocked during suspend. Since printk uses the returned flush type to determine what flushing methods are used, this was thought to be sufficient for avoiding irq_work usage during the suspend phase.
However, vprintk_emit() implements a hack to support printk_deferred(). In this hack, the returned flush type is adjusted to make sure no legacy direct printing occurs when printk_deferred() was used.
Because of this hack, the legacy offloading flushing method can still be used, causing irq_work to be queued when it should not be.
Adjust the vprintk_emit() hack to also consider @console_irqwork_blocked so that legacy offloading will not be chosen when irq_work should be blocked.
--- kernel/printk/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/printk/printk.c +1 -1
@@ -2393,7 +2393,7 @@ asmlinkage int vprintk_emit(int facility/* If called from the scheduler, we can not call up(). */ if (level ==LOGLEVEL_SCHED ) { level =LOGLEVEL_DEFAULT ; - ft.legacy_offload |= ft.legacy_direct; + ft.legacy_offload |= ft.legacy_direct && !console_irqwork_blocked; ft.legacy_direct = false; }
Greg Kroah-Hartman
maintainerPATCH 259/430 ext4: fix string copying in parse_apply_sb_mount_options()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit ee5a977b4e771cc181f39d504426dbd31ed701cc upstream.
strscpy_pad() can't be used to copy a non-NUL-term string into a NUL-term string of possibly bigger size. Commit 0efc5990bca5 ("string.h: Introduce memtostr() and memtostr_pad()") provides additional information in that regard. So if this happens, the following warning is observed:
strnlen: detected buffer overflow: 65 byte read of buffer size 64
WARNING: CPU: 0 PID: 28655 at lib/string_helpers.c:1032 __fortify_report+0x96/0xc0 lib/string_helpers.c:1032 Modules linked in: CPU: 0 UID: 0 PID: 28655 Comm: syz-executor.3 Not tainted 6.12.54-syzkaller-00144-g5f0270f1ba00 #0 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:__fortify_report+0x96/0xc0 lib/string_helpers.c:1032 Call Trace: <TASK> __fortify_panic+0x1f/0x30 lib/string_helpers.c:1039 strnlen include/linux/fortify-string.h:235 [inline] sized_strscpy include/linux/fortify-string.h:309 [inline] parse_apply_sb_mount_options fs/ext4/super.c:2504 [inline] __ext4_fill_super fs/ext4/super.c:5261 [inline] ext4_fill_super+0x3c35/0xad00 fs/ext4/super.c:5706 get_tree_bdev_flags+0x387/0x620 fs/super.c:1636 vfs_get_tree+0x93/0x380 fs/super.c:1814 do_new_mount fs/namespace.c:3553 [inline] path_mount+0x6ae/0x1f70 fs/namespace.c:3880 do_mount fs/namespace.c:3893 [inline] __do_sys_mount fs/namespace.c:4103 [inline] __se_sys_mount fs/namespace.c:4080 [inline] __x64_sys_mount+0x280/0x300 fs/namespace.c:4080 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0x64/0x140 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Since userspace is expected to provide s_mount_opts field to be at most 63 characters long with the ending byte being NUL-term, use a 64-byte buffer which matches the size of s_mount_opts, so that strscpy_pad() does its job properly. Return with error if the user still managed to provide a non-NUL-term string here.
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
Message-ID: <[email protected]>
--- fs/ext4/super.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/ext4/super.c +3 -2
@@ -2475,7 +2475,7 @@ static int parse_apply_sb_mount_options( struct ext4_fs_context *m_ctx) {struct ext4_sb_info *sbi =EXT4_SB (sb); -char s_mount_opts[65 ]; +char s_mount_opts[64 ];struct ext4_fs_context *s_ctx =NULL ;struct fs_context *fc =NULL ;int ret = -ENOMEM ;
@@ -2483,7 +2483,8 @@ static int parse_apply_sb_mount_options(if (!sbi->s_es->s_mount_opts[0 ])return 0 ; -strscpy_pad (s_mount_opts, sbi->s_es->s_mount_opts); +if (strscpy_pad (s_mount_opts, sbi->s_es->s_mount_opts) <0 ) +return -E2BIG ; fc =kzalloc (sizeof (struct fs_context ),GFP_KERNEL );if (!fc)
Greg Kroah-Hartman
maintainerPATCH 260/430 ext4: check if mount_opts is NUL-terminated in ext4_ioctl_set_tune_sb()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fedor Pchelkin <[email protected]>
commit 3db63d2c2d1d1e78615dd742568c5a2d55291ad1 upstream.
params.mount_opts may come as potentially non-NUL-term string. Userspace is expected to pass a NUL-term string. Add an extra check to ensure this holds true. Note that further code utilizes strscpy_pad() so this is just for proper informing the user of incorrect data being provided.
Found by Linux Verification Center (linuxtesting.org).
Message-ID: <[email protected]>
--- fs/ext4/ioctl.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ext4/ioctl.c +4 -0
@@ -1394,6 +1394,10 @@ static int ext4_ioctl_set_tune_sb(structif (copy_from_user (¶ms, in,sizeof (params)))return -EFAULT ; +if (strnlen (params.mount_opts,sizeof (params.mount_opts)) == +sizeof (params.mount_opts)) +return -E2BIG ; +if ((params.set_flags & ~TUNE_OPS_SUPPORTED ) !=0 )return -EOPNOTSUPP ;
Greg Kroah-Hartman
maintainerPATCH 261/430 ext4: xattr: fix null pointer deref in ext4_raw_inode()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karina Yankevich <[email protected]>
commit b97cb7d6a051aa6ebd57906df0e26e9e36c26d14 upstream.
If ext4_get_inode_loc() fails (e.g. if it returns -EFSCORRUPTED), iloc.bh will remain set to NULL. Since ext4_xattr_inode_dec_ref_all() lacks error checking, this will lead to a null pointer dereference in ext4_raw_inode(), called right after ext4_get_inode_loc().
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Message-ID: <[email protected]>
--- fs/ext4/xattr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/xattr.c +5 -1
@@ -1174,7 +1174,11 @@ ext4_xattr_inode_dec_ref_all(handle_t *hif (block_csum) end = (void *)bh->b_data + bh->b_size;else { -ext4_get_inode_loc (parent, &iloc); + err =ext4_get_inode_loc (parent, &iloc); +if (err) { +EXT4_ERROR_INODE (parent,"parent inode loc (error %d)" , err); +return ; + } end = (void *)ext4_raw_inode (&iloc) +EXT4_SB (parent->i_sb)->s_inode_size; }
Greg Kroah-Hartman
maintainerPATCH 262/430 ext4: clear i_state_flags when alloc inode
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haibo Chen <[email protected]>
commit 4091c8206cfd2e3bb529ef260887296b90d9b6a2 upstream.
i_state_flags used on 32-bit archs, need to clear this flag when alloc inode.
Find this issue when umount ext4, sometimes track the inode as orphan accidently, cause ext4 mesg dump.
Message-ID: <[email protected]>
--- fs/ext4/ialloc.c | 1 - fs/ext4/inode.c | 1 - fs/ext4/super.c | 1 + 3 files changed, 1 insertion(+), 2 deletions(-)
fs/ext4/ialloc.c +0 -1
@@ -1293,7 +1293,6 @@ got: ei->i_csum_seed =ext4_chksum (csum, (__u8 *)&gen,sizeof (gen)); } -ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */ ext4_set_inode_state (inode,EXT4_STATE_NEW ); ei->i_extra_isize = sbi->s_want_extra_isize;
fs/ext4/inode.c +0 -1
@@ -5288,7 +5288,6 @@ struct inode *__ext4_iget(struct super_b ei->i_projid =make_kprojid (&init_user_ns, i_projid);set_nlink (inode,le16_to_cpu (raw_inode->i_links_count)); -ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */ ei->i_inline_off =0 ; ei->i_dir_start_lookup =0 ; ei->i_dtime =le32_to_cpu (raw_inode->i_dtime);
fs/ext4/super.c +1 -0
@@ -1396,6 +1396,7 @@ static struct inode *ext4_alloc_inode(stinode_set_iversion (&ei->vfs_inode,1 ); ei->i_flags =0 ; +ext4_clear_state_flags (ei);/* Only relevant on 32-bit archs */ spin_lock_init (&ei->i_raw_lock); ei->i_prealloc_node =RB_ROOT ;atomic_set (&ei->i_prealloc_active,0 );
Greg Kroah-Hartman
maintainerPATCH 263/430 ext4: fix incorrect group number assertion in mb_check_buddy
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yongjian Sun <[email protected]>
commit 3f7a79d05c692c7cfec70bf104b1b3c3d0ce6247 upstream.
When the MB_CHECK_ASSERT macro is enabled, an assertion failure can occur in __mb_check_buddy when checking preallocated blocks (pa) in a block group:
Assertion failure in mb_free_blocks() : "groupnr == e4b->bd_group"
This happens when a pa at the very end of a block group (e.g., pa_pstart=32765, pa_len=3 in a group of 32768 blocks) becomes exhausted - its pa_pstart is advanced by pa_len to 32768, which lies in the next block group. If this exhausted pa (with pa_len == 0) is still in the bb_prealloc_list during the buddy check, the assertion incorrectly flags it as belonging to the wrong group. A possible sequence is as follows:
ext4_mb_new_blocks
ext4_mb_release_context
pa->pa_pstart += EXT4_C2B(sbi, ac->ac_b_ex.fe_len)
pa->pa_len -= ac->ac_b_ex.fe_len
__mb_check_buddy
for each pa in group
ext4_get_group_no_and_offset
MB_CHECK_ASSERT(groupnr == e4b->bd_group)To fix this, we modify the check to skip block group validation for exhausted preallocations (where pa_len == 0). Such entries are in a transitional state and will be removed from the list soon, so they should not trigger an assertion. This change prevents the false positive while maintaining the integrity of the checks for active allocations.
Message-ID: <[email protected]>
--- fs/ext4/mballoc.c | 2 ++ 1 file changed, 2 insertions(+)
fs/ext4/mballoc.c +2 -0
@@ -783,6 +783,8 @@ static void __mb_check_buddy(struct ext4ext4_group_t groupnr;struct ext4_prealloc_space *pa; pa = list_entry(cur, struct ext4_prealloc_space, pa_group_list); +if (!pa->pa_len) +continue ;ext4_get_group_no_and_offset (sb, pa->pa_pstart, &groupnr, &k);MB_CHECK_ASSERT (groupnr == e4b->bd_group);for (i =0 ; i < pa->pa_len; i++)
Greg Kroah-Hartman
maintainerPATCH 264/430 ext4: align max orphan file size with e2fsprogs limit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baokun Li <[email protected]>
commit 7c11c56eb32eae96893eebafdbe3decadefe88ad upstream.
Kernel commit 0a6ce20c1564 ("ext4: verify orphan file size is not too big") limits the maximum supported orphan file size to 8 << 20.
However, in e2fsprogs, the orphan file size is set to 32–512 filesystem blocks when creating a filesystem.
With 64k block size, formatting an ext4 fs >32G gives an orphan file bigger than the kernel allows, so mount prints an error and fails:
EXT4-fs (vdb): orphan file too big: 8650752
EXT4-fs (vdb): mount failed
To prevent this issue and allow previously created 64KB filesystems to mount, we updates the maximum allowed orphan file size in the kernel to 512 filesystem blocks.
Message-ID: <[email protected]>
--- fs/ext4/orphan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/ext4/orphan.c +3 -1
@@ -8,6 +8,8 @@#include "ext4.h" #include "ext4_jbd2.h" +#define EXT4_MAX_ORPHAN_FILE_BLOCKS 512 +static int ext4_orphan_file_add (handle_t *handle,struct inode *inode) {int i, j, start;
@@ -588,7 +590,7 @@ int ext4_init_orphan_info(struct super_b* consuming absurd amounts of memory when pinning blocks of orphan * file in memory. */ -if (inode->i_size >8 <<20 ) { +if (inode->i_size > (EXT4_MAX_ORPHAN_FILE_BLOCKS << inode->i_blkbits)) {ext4_msg (sb,KERN_ERR ,"orphan file too big: %llu" , (unsigned long long )inode->i_size); ret = -EFSCORRUPTED ;
Greg Kroah-Hartman
maintainerPATCH 265/430 jbd2: use a per-journal lock_class_key for jbd2_trans_commit_key
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tetsuo Handa <[email protected]>
commit 524c3853831cf4f7e1db579e487c757c3065165c upstream.
syzbot is reporting possibility of deadlock due to sharing lock_class_key for jbd2_handle across ext4 and ocfs2. But this is a false positive, for one disk partition can't have two filesystems at the same time.
Message-ID: <[email protected]>
--- fs/jbd2/journal.c | 6 ++++-- include/linux/jbd2.h | 6 ++++++ 2 files changed, 10 insertions(+), 2 deletions(-)
fs/jbd2/journal.c +4 -2
@@ -1521,7 +1521,6 @@ static journal_t *journal_init_common(ststruct block_device *fs_dev, unsigned long long start, int len, int blocksize) { - static struct lock_class_key jbd2_trans_commit_key; journal_t *journal;int err;int n;
@@ -1530,6 +1529,7 @@ static journal_t *journal_init_common(stif (!journal)return ERR_PTR (-ENOMEM ); +lockdep_register_key (&journal->jbd2_trans_commit_key); journal->j_blocksize = blocksize; journal->j_dev = bdev; journal->j_fs_dev = fs_dev;
@@ -1560,7 +1560,7 @@ static journal_t *journal_init_common(st journal->j_max_batch_time =15000 ;/* 15ms */ atomic_set (&journal->j_reserved_credits,0 );lockdep_init_map (&journal->j_trans_commit_map,"jbd2_handle" , - &jbd2_trans_commit_key,0 ); + &journal->jbd2_trans_commit_key,0 );/* The journal is marked for error until we succeed with recovery! */ journal->j_flags =JBD2_ABORT ;
@@ -1611,6 +1611,7 @@ err_cleanup:kfree (journal->j_wbuf);jbd2_journal_destroy_revoke (journal);journal_fail_superblock (journal); +lockdep_unregister_key (&journal->jbd2_trans_commit_key);kfree (journal);return ERR_PTR (err); }
@@ -2187,6 +2188,7 @@ int jbd2_journal_destroy(journal_t *jourjbd2_journal_destroy_revoke (journal);kfree (journal->j_fc_wbuf);kfree (journal->j_wbuf); +lockdep_unregister_key (&journal->jbd2_trans_commit_key);kfree (journal);return err;
include/linux/jbd2.h +6 -0
@@ -1253,6 +1253,12 @@ struct journal_s*/ struct lockdep_map j_trans_commit_map;#endif +/** +* @jbd2_trans_commit_key: +* +* "struct lock_class_key" for @j_trans_commit_map +*/ +struct lock_class_key jbd2_trans_commit_key;/** * @j_fc_cleanup_callback:
Greg Kroah-Hartman
maintainerPATCH 266/430 jbd2: use a weaker annotation in journal handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Byungchul Park <[email protected]>
commit 40a71b53d5a6d4ea17e4d54b99b2ac03a7f5e783 upstream.
jbd2 journal handling code doesn't want jbd2_might_wait_for_commit() to be placed between start_this_handle() and stop_this_handle(). So it marks the region with rwsem_acquire_read() and rwsem_release().
However, the annotation is too strong for that purpose. We don't have to use more than try lock annotation for that.
rwsem_acquire_read() implies:
1. might be a waiter on contention of the lock.
2. enter to the critical section of the lock.
All we need in here is to act 2, not 1. So trylock version of annotation is sufficient for that purpose. Now that dept partially relies on lockdep annotaions, dept interpets rwsem_acquire_read() as a potential wait and might report a deadlock by the wait.
Replace it with trylock version of annotation.
Message-ID: <[email protected]>
--- fs/jbd2/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jbd2/transaction.c +1 -1
@@ -441,7 +441,7 @@ repeat:read_unlock (&journal->j_state_lock); current->journal_info = handle; -rwsem_acquire_read (&journal->j_trans_commit_map,0 ,0 , _THIS_IP_); +rwsem_acquire_read (&journal->j_trans_commit_map,0 ,1 , _THIS_IP_);jbd2_journal_free_transaction (new_transaction);/* * Ensure that no allocations done while the transaction is open are
Greg Kroah-Hartman
maintainerPATCH 267/430 block: Remove queue freezing from several sysfs store callbacks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bart Van Assche <[email protected]>
commit 935a20d1bebf6236076785fac3ff81e3931834e9 upstream.
Freezing the request queue from inside sysfs store callbacks may cause a deadlock in combination with the dm-multipath driver and the queue_if_no_path option. Additionally, freezing the request queue slows down system boot on systems where sysfs attributes are set synchronously.
Fix this by removing the blk_mq_freeze_queue() / blk_mq_unfreeze_queue() calls from the store callbacks that do not strictly need these callbacks. Add the __data_racy annotation to request_queue.rq_timeout to suppress KCSAN data race reports about the rq_timeout reads.
This patch may cause a small delay in applying the new settings.
For all the attributes affected by this patch, I/O will complete correctly whether the old or the new value of the attribute is used.
This patch affects the following sysfs attributes:
* io_poll_delay
* io_timeout
* nomerges
* read_ahead_kb
* rq_affinity
Here is an example of a deadlock triggered by running test srp/002 if this patch is not applied:
task:multipathd
Call Trace: <TASK> __schedule+0x8c1/0x1bf0 schedule+0xdd/0x270 schedule_preempt_disabled+0x1c/0x30 __mutex_lock+0xb89/0x1650 mutex_lock_nested+0x1f/0x30 dm_table_set_restrictions+0x823/0xdf0 __bind+0x166/0x590 dm_swap_table+0x2a7/0x490 do_resume+0x1b1/0x610 dev_suspend+0x55/0x1a0 ctl_ioctl+0x3a5/0x7e0 dm_ctl_ioctl+0x12/0x20 __x64_sys_ioctl+0x127/0x1a0 x64_sys_call+0xe2b/0x17d0 do_syscall_64+0x96/0x3a0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK> task:(udev-worker) Call Trace: <TASK> __schedule+0x8c1/0x1bf0 schedule+0xdd/0x270 blk_mq_freeze_queue_wait+0xf2/0x140 blk_mq_freeze_queue_nomemsave+0x23/0x30 queue_ra_store+0x14e/0x290 queue_attr_store+0x23e/0x2c0 sysfs_kf_write+0xde/0x140 kernfs_fop_write_iter+0x3b2/0x630 vfs_write+0x4fd/0x1390 ksys_write+0xfd/0x230 __x64_sys_write+0x76/0xc0 x64_sys_call+0x276/0x17d0 do_syscall_64+0x96/0x3a0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 </TASK>
--- block/blk-sysfs.c | 26 ++++++++------------------ include/linux/blkdev.h | 2 +- 2 files changed, 9 insertions(+), 19 deletions(-)
block/blk-sysfs.c +8 -18
@@ -143,21 +143,22 @@ queue_ra_store(struct gendisk *disk, con {unsigned long ra_kb;ssize_t ret; -unsigned int memflags;struct request_queue *q = disk->queue; ret =queue_var_store (&ra_kb, page, count);if (ret <0 )return ret;/* -* ->ra_pages is protected by ->limits_lock because it is usually -* calculated from the queue limits by queue_limits_commit_update. +* The ->ra_pages change below is protected by ->limits_lock because it +* is usually calculated from the queue limits by +* queue_limits_commit_update(). +* +* bdi->ra_pages reads are not serialized against bdi->ra_pages writes. +* Use WRITE_ONCE() to write bdi->ra_pages once. */ mutex_lock (&q->limits_lock); - memflags =blk_mq_freeze_queue (q); - disk->bdi->ra_pages = ra_kb >> (PAGE_SHIFT -10 ); +WRITE_ONCE (disk->bdi->ra_pages, ra_kb >> (PAGE_SHIFT -10 ));mutex_unlock (&q->limits_lock); -blk_mq_unfreeze_queue (q, memflags);return ret; }
@@ -375,21 +376,18 @@ static ssize_t queue_nomerges_store(stru size_t count) {unsigned long nm; -unsigned int memflags;struct request_queue *q = disk->queue;ssize_t ret =queue_var_store (&nm, page, count);if (ret <0 )return ret; - memflags =blk_mq_freeze_queue (q);blk_queue_flag_clear (QUEUE_FLAG_NOMERGES , q);blk_queue_flag_clear (QUEUE_FLAG_NOXMERGES , q);if (nm ==2 )blk_queue_flag_set (QUEUE_FLAG_NOMERGES , q);else if (nm)blk_queue_flag_set (QUEUE_FLAG_NOXMERGES , q); -blk_mq_unfreeze_queue (q, memflags);return ret; }
@@ -409,7 +407,6 @@ queue_rq_affinity_store(struct gendisk *#ifdef CONFIG_SMP struct request_queue *q = disk->queue;unsigned long val; -unsigned int memflags; ret =queue_var_store (&val, page, count);if (ret <0 )
@@ -421,7 +418,6 @@ queue_rq_affinity_store(struct gendisk ** are accessed individually using atomic test_bit operation. So we * don't grab any lock while updating these flags. */ - memflags =blk_mq_freeze_queue (q);if (val ==2 ) {blk_queue_flag_set (QUEUE_FLAG_SAME_COMP , q);blk_queue_flag_set (QUEUE_FLAG_SAME_FORCE , q);
@@ -432,7 +428,6 @@ queue_rq_affinity_store(struct gendisk *blk_queue_flag_clear (QUEUE_FLAG_SAME_COMP , q); blk_queue_flag_clear(QUEUE_FLAG_SAME_FORCE, q); } -blk_mq_unfreeze_queue (q, memflags);#endif return ret; }
@@ -446,11 +441,9 @@ static ssize_t queue_poll_delay_store(ststatic ssize_t queue_poll_store (struct gendisk *disk,const char *page,size_t count) { -unsigned int memflags;ssize_t ret = count;struct request_queue *q = disk->queue; - memflags =blk_mq_freeze_queue (q);if (!(q->limits.features &BLK_FEAT_POLL )) { ret = -EINVAL ; goto out;
@@ -459,7 +452,6 @@ static ssize_t queue_poll_store(struct gpr_info_ratelimited ("writes to the poll attribute are ignored.\n" );pr_info_ratelimited ("please use driver specific parameters instead.\n" ); out: -blk_mq_unfreeze_queue (q, memflags);return ret; }
@@ -472,7 +464,7 @@ static ssize_t queue_io_timeout_show(strstatic ssize_t queue_io_timeout_store (struct gendisk *disk,const char *page,size_t count) { -unsigned int val, memflags; +unsigned int val;int err;struct request_queue *q = disk->queue;
@@ -480,9 +472,7 @@ static ssize_t queue_io_timeout_store(stif (err || val ==0 )return -EINVAL ; - memflags =blk_mq_freeze_queue (q);blk_queue_rq_timeout (q,msecs_to_jiffies (val)); -blk_mq_unfreeze_queue (q, memflags);return count; }
include/linux/blkdev.h +1 -1
@@ -485,7 +485,7 @@ struct request_queue {*/ unsigned long queue_flags; -unsigned int rq_timeout; + unsigned int __data_racy rq_timeout;unsigned int queue_depth;
Greg Kroah-Hartman
maintainerPATCH 268/430 mm/ksm: fix exec/fork inheritance support for prctl
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: xu xin <[email protected]>
commit 590c03ca6a3fbb114396673314e2aa483839608b upstream.
Patch series "ksm: fix exec/fork inheritance", v2.
This series fixes exec/fork inheritance. See the detailed description of the issue below.
This patch (of 2):
Background
==========
commit d7597f59d1d33 ("mm: add new api to enable ksm per process") introduced MMF_VM_MERGE_ANY for mm->flags, and allowed user to set it by prctl() so that the process's VMAs are forcibly scanned by ksmd.
Subsequently, the 3c6f33b7273a ("mm/ksm: support fork/exec for prctl") supported inheriting the MMF_VM_MERGE_ANY flag when a task calls execve().
Finally, commit 3a9e567ca45fb ("mm/ksm: fix ksm exec support for prctl") fixed the issue that ksmd doesn't scan the mm_struct with MMF_VM_MERGE_ANY by adding the mm_slot to ksm_mm_head in __bprm_mm_init().
Problem
=======
In some extreme scenarios, however, this inheritance of MMF_VM_MERGE_ANY during exec/fork can fail. For example, when the scanning frequency of ksmd is tuned extremely high, a process carrying MMF_VM_MERGE_ANY may still fail to pass it to the newly exec'd process. This happens because ksm_execve() is executed too early in the do_execve flow (prematurely adding the new mm_struct to the ksm_mm_slot list).
As a result, before do_execve completes, ksmd may have already performed a scan and found that this new mm_struct has no VM_MERGEABLE VMAs, thus clearing its MMF_VM_MERGE_ANY flag. Consequently, when the new program executes, the flag MMF_VM_MERGE_ANY inheritance missed.
Root reason
===========
commit d7597f59d1d33 ("mm: add new api to enable ksm per process") clear the flag MMF_VM_MERGE_ANY when ksmd found no VM_MERGEABLE VMAs.
Solution
========
Firstly, Don't clear MMF_VM_MERGE_ANY when ksmd found no VM_MERGEABLE VMAs, because perhaps their mm_struct has just been added to ksm_mm_slot list, and its process has not yet officially started running or has not yet performed mmap/brk to allocate anonymous VMAS.
Secondly, recheck MMF_VM_MERGEABLE again if a process takes MMF_VM_MERGE_ANY, and create a mm_slot and join it into ksm_scan_list again.
--- include/linux/ksm.h | 4 ++-- mm/ksm.c | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-)
include/linux/ksm.h +2 -2
@@ -17,7 +17,7 @@#ifdef CONFIG_KSM int ksm_madvise (struct vm_area_struct *vma,unsigned long start,unsigned long end,int advice,vm_flags_t *vm_flags); -vm_flags_t ksm_vma_flags (const struct mm_struct *mm,const struct file *file, +vm_flags_t ksm_vma_flags (struct mm_struct *mm,const struct file *file,vm_flags_t vm_flags);int ksm_enable_merge_any (struct mm_struct *mm);int ksm_disable_merge_any (struct mm_struct *mm);
@@ -103,7 +103,7 @@ bool ksm_process_mergeable(struct mm_str#else /* !CONFIG_KSM */ -static inline vm_flags_t ksm_vma_flags (const struct mm_struct *mm, +static inline vm_flags_t ksm_vma_flags (struct mm_struct *mm,const struct file *file,vm_flags_t vm_flags) {return vm_flags;
mm/ksm.c +17 -3
@@ -2712,8 +2712,14 @@ no_vmas:spin_unlock (&ksm_mmlist_lock);mm_slot_free (mm_slot_cache, mm_slot); +/* +* Only clear MMF_VM_MERGEABLE. We must not clear +* MMF_VM_MERGE_ANY, because for those MMF_VM_MERGE_ANY process, +* perhaps their mm_struct has just been added to ksm_mm_slot +* list, and its process has not yet officially started running +* or has not yet performed mmap/brk to allocate anonymous VMAS. +*/ mm_flags_clear (MMF_VM_MERGEABLE , mm); -mm_flags_clear (MMF_VM_MERGE_ANY , mm);mmap_read_unlock (mm);mmdrop (mm); }else {
@@ -2831,12 +2837,20 @@ static int __ksm_del_vma(struct vm_area_* * Returns: @vm_flags possibly updated to mark mergeable. */ -vm_flags_t ksm_vma_flags (const struct mm_struct *mm,const struct file *file, +vm_flags_t ksm_vma_flags (struct mm_struct *mm,const struct file *file,vm_flags_t vm_flags) {if (mm_flags_test (MMF_VM_MERGE_ANY , mm) && -__ksm_should_add_vma (file, vm_flags)) +__ksm_should_add_vma (file, vm_flags)) { vm_flags |=VM_MERGEABLE ; +/* +* Generally, the flags here always include MMF_VM_MERGEABLE. +* However, in rare cases, this flag may be cleared by ksmd who +* scans a cycle without finding any mergeable vma. +*/ +if (unlikely (!mm_flags_test (MMF_VM_MERGEABLE , mm))) +__ksm_enter (mm); + }return vm_flags; }
Greg Kroah-Hartman
maintainerPATCH 269/430 media: v4l2-mem2mem: Fix outdated documentation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Laurent Pinchart <[email protected]>
commit 082b86919b7a94de01d849021b4da820a6cb89dc upstream.
Commit cbd9463da1b1 ("media: v4l2-mem2mem: Avoid calling .device_run in v4l2_m2m_job_finish") deferred calls to .device_run() to a work queue to avoid recursive calls when a job is finished right away from .device_run(). It failed to update the v4l2_m2m_job_finish() documentation that still states the function must not be called from .device_run(). Fix it.
--- include/media/v4l2-mem2mem.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/media/v4l2-mem2mem.h +1 -2
@@ -192,8 +192,7 @@ void v4l2_m2m_try_schedule(struct v4l2_m* other instances to take control of the device. * * This function has to be called only after &v4l2_m2m_ops->device_run -* callback has been called on the driver. To prevent recursion, it should -* not be called directly from the &v4l2_m2m_ops->device_run callback though. +* callback has been called on the driver. */ void v4l2_m2m_job_finish (struct v4l2_m2m_dev *m2m_dev,struct v4l2_m2m_ctx *m2m_ctx);
Greg Kroah-Hartman
maintainerPATCH 270/430 mm/huge_memory: add pmd folio to ds_queue in do_huge_zero_wp_pmd()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wei Yang <[email protected]>
commit 2a1351cd4176ee1809b0900d386919d03b7652f8 upstream.
We add pmd folio into ds_queue on the first page fault in __do_huge_pmd_anonymous_page(), so that we can split it in case of memory pressure. This should be the same for a pmd folio during wp page fault.
Commit 1ced09e0331f ("mm: allocate THP on hugezeropage wp-fault") miss to add it to ds_queue, which means system may not reclaim enough memory in case of memory pressure even the pmd folio is under used.
Move deferred_split_folio() into map_anon_folio_pmd() to make the pmd folio installation consistent.
--- mm/huge_memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/huge_memory.c +1 -1
@@ -1233,6 +1233,7 @@ static void map_anon_folio_pmd(struct focount_vm_event (THP_FAULT_ALLOC );count_mthp_stat (HPAGE_PMD_ORDER ,MTHP_STAT_ANON_FAULT_ALLOC );count_memcg_event_mm (vma->vm_mm,THP_FAULT_ALLOC ); +deferred_split_folio (folio, false); }static vm_fault_t __do_huge_pmd_anonymous_page (struct vm_fault *vmf)
@@ -1273,7 +1274,6 @@ static vm_fault_t __do_huge_pmd_anonymoupgtable_trans_huge_deposit (vma->vm_mm, vmf->pmd, pgtable);map_anon_folio_pmd (folio, vmf->pmd, vma, haddr);mm_inc_nr_ptes (vma->vm_mm); -deferred_split_folio (folio, false);spin_unlock (vmf->ptl); }
Greg Kroah-Hartman
maintainerPATCH 271/430 tpm2-sessions: Fix out of range indexing in name_size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit 6e9722e9a7bfe1bbad649937c811076acf86e1fd upstream.
'name_size' does not have any range checks, and it just directly indexes with TPM_ALG_ID, which could lead into memory corruption at worst.
Address the issue by only processing known values and returning -EINVAL for unrecognized values.
Make also 'tpm_buf_append_name' and 'tpm_buf_fill_hmac_session' fallible so that errors are detected before causing any spurious TPM traffic.
End also the authorization session on failure in both of the functions, as the session state would be then by definition corrupted.
--- drivers/char/tpm/tpm2-cmd.c | 23 ++++- drivers/char/tpm/tpm2-sessions.c | 132 ++++++++++++++++++++---------- include/linux/tpm.h | 13 +- security/keys/trusted-keys/trusted_tpm2.c | 29 +++++- 4 files changed, 142 insertions(+), 55 deletions(-)
drivers/char/tpm/tpm2-cmd.c +19 -4
@@ -187,7 +187,11 @@ int tpm2_pcr_extend(struct tpm_chip *chi }if (!disable_pcr_integrity) { -tpm_buf_append_name (chip, &buf, pcr_idx,NULL ); + rc =tpm_buf_append_name (chip, &buf, pcr_idx,NULL ); +if (rc) { +tpm_buf_destroy (&buf); +return rc; + }tpm_buf_append_hmac_session (chip, &buf,0 ,NULL ,0 ); }else {tpm_buf_append_handle (chip, &buf, pcr_idx);
@@ -202,8 +206,14 @@ int tpm2_pcr_extend(struct tpm_chip *chi chip->allocated_banks[i].digest_size); } -if (!disable_pcr_integrity) -tpm_buf_fill_hmac_session (chip, &buf); +if (!disable_pcr_integrity) { + rc =tpm_buf_fill_hmac_session (chip, &buf); +if (rc) { +tpm_buf_destroy (&buf); +return rc; + } + } + rc =tpm_transmit_cmd (chip, &buf,0 ,"attempting extend a PCR value" );if (!disable_pcr_integrity) rc =tpm_buf_check_hmac_response (chip, &buf, rc);
@@ -261,7 +271,12 @@ int tpm2_get_random(struct tpm_chip *chi | TPM2_SA_CONTINUE_SESSION, NULL, 0);tpm_buf_append_u16 (&buf, num_bytes); -tpm_buf_fill_hmac_session (chip, &buf); + err =tpm_buf_fill_hmac_session (chip, &buf); +if (err) { +tpm_buf_destroy (&buf); +return err; + } + err = tpm_transmit_cmd(chip, &buf, offsetof(struct tpm2_get_random_out, buffer),
drivers/char/tpm/tpm2-sessions.c +92 -40
232 lines not on this page · raw message
include/linux/tpm.h +8 -5
@@ -526,8 +526,8 @@ static inline struct tpm2_auth *tpm2_chi#endif } -void tpm_buf_append_name (struct tpm_chip *chip,struct tpm_buf *buf, -u32 handle,u8 *name); +int tpm_buf_append_name (struct tpm_chip *chip,struct tpm_buf *buf, +u32 handle,u8 *name);void tpm_buf_append_hmac_session (struct tpm_chip *chip,struct tpm_buf *buf,u8 attributes,u8 *passphrase,int passphraselen);
@@ -560,7 +560,7 @@ static inline void tpm_buf_append_hmac_s#ifdef CONFIG_TCG_TPM2_HMAC int tpm2_start_auth_session (struct tpm_chip *chip); -void tpm_buf_fill_hmac_session (struct tpm_chip *chip,struct tpm_buf *buf); +int tpm_buf_fill_hmac_session (struct tpm_chip *chip,struct tpm_buf *buf);int tpm_buf_check_hmac_response (struct tpm_chip *chip,struct tpm_buf *buf,int rc);void tpm2_end_auth_session (struct tpm_chip *chip);
@@ -574,10 +574,13 @@ static inline int tpm2_start_auth_sessiostatic inline void tpm2_end_auth_session (struct tpm_chip *chip) { } -static inline void tpm_buf_fill_hmac_session (struct tpm_chip *chip, -struct tpm_buf *buf) + +static inline int tpm_buf_fill_hmac_session (struct tpm_chip *chip, +struct tpm_buf *buf) { +return 0 ; } +static inline int tpm_buf_check_hmac_response (struct tpm_chip *chip,struct tpm_buf *buf,int rc)
security/keys/trusted-keys/trusted_tpm2.c +23 -6
@@ -283,7 +283,10 @@ int tpm2_seal_trusted(struct tpm_chip *c goto out_put; } -tpm_buf_append_name (chip, &buf, options->keyhandle,NULL ); + rc =tpm_buf_append_name (chip, &buf, options->keyhandle,NULL ); +if (rc) + goto out; +tpm_buf_append_hmac_session (chip, &buf,TPM2_SA_DECRYPT , options->keyauth,TPM_DIGEST_SIZE );
@@ -331,7 +334,10 @@ int tpm2_seal_trusted(struct tpm_chip *c goto out; } -tpm_buf_fill_hmac_session (chip, &buf); + rc =tpm_buf_fill_hmac_session (chip, &buf); +if (rc) + goto out; + rc =tpm_transmit_cmd (chip, &buf,4 ,"sealing data" ); rc =tpm_buf_check_hmac_response (chip, &buf, rc);if (rc)
@@ -448,7 +454,10 @@ static int tpm2_load_cmd(struct tpm_chipreturn rc; } -tpm_buf_append_name (chip, &buf, options->keyhandle,NULL ); + rc =tpm_buf_append_name (chip, &buf, options->keyhandle,NULL ); +if (rc) + goto out; +tpm_buf_append_hmac_session (chip, &buf,0 , options->keyauth,TPM_DIGEST_SIZE );
@@ -460,7 +469,10 @@ static int tpm2_load_cmd(struct tpm_chip goto out; } -tpm_buf_fill_hmac_session (chip, &buf); + rc =tpm_buf_fill_hmac_session (chip, &buf); +if (rc) + goto out; + rc =tpm_transmit_cmd (chip, &buf,4 ,"loading blob" ); rc =tpm_buf_check_hmac_response (chip, &buf, rc);if (!rc)
@@ -508,7 +520,9 @@ static int tpm2_unseal_cmd(struct tpm_chreturn rc; } -tpm_buf_append_name (chip, &buf, blob_handle,NULL ); + rc =tpm_buf_append_name (chip, &buf, options->keyhandle,NULL ); +if (rc) + goto out;if (!options->policyhandle) { tpm_buf_append_hmac_session(chip, &buf, TPM2_SA_ENCRYPT,
@@ -533,7 +547,10 @@ static int tpm2_unseal_cmd(struct tpm_ch NULL, 0); } -tpm_buf_fill_hmac_session (chip, &buf); + rc =tpm_buf_fill_hmac_session (chip, &buf); +if (rc) + goto out; + rc =tpm_transmit_cmd (chip, &buf,6 ,"unsealing" ); rc =tpm_buf_check_hmac_response (chip, &buf, rc);if (rc >0 )
Greg Kroah-Hartman
maintainerPATCH 272/430 tpm2-sessions: Fix tpm2_read_public range checks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Sakkinen <[email protected]>
commit bda1cbf73c6e241267c286427f2ed52b5735d872 upstream.
tpm2_read_public() has some rudimentary range checks but the function does not ensure that the response buffer has enough bytes for the full TPMT_HA payload.
Re-implement the function with necessary checks and validation, and return name and name size for all handle types back to the caller.
--- drivers/char/tpm/tpm2-cmd.c | 3 + drivers/char/tpm/tpm2-sessions.c | 94 ++++++++++++++++++++------------------- 2 files changed, 53 insertions(+), 44 deletions(-)
drivers/char/tpm/tpm2-cmd.c +3 -0
@@ -11,8 +11,11 @@* used by the kernel internally. */ +#include "linux/dev_printk.h" +#include "linux/tpm.h" #include "tpm.h" #include <crypto/hash_info.h> +#include <linux/unaligned.h> static bool disable_pcr_integrity;module_param (disable_pcr_integrity, bool,0444 );
drivers/char/tpm/tpm2-sessions.c +50 -44
130 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 273/430 crash: let architecture decide crash memory export to iomem_resource
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sourabh Jain <[email protected]>
commit adc15829fb73e402903b7030729263b6ee4a7232 upstream.
With the generic crashkernel reservation, the kernel emits the following warning on powerpc:
WARNING: CPU: 0 PID: 1 at arch/powerpc/mm/mem.c:341 add_system_ram_resources+0xfc/0x180 Modules linked in: CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.17.0-auto-12607-g5472d60c129f #1 VOLUNTARY Hardware name: IBM,9080-HEX Power11 (architected) 0x820200 0xf000007 of:IBM,FW1110.01 (NH1110_069) hv:phyp pSeries NIP: c00000000201de3c LR: c00000000201de34 CTR: 0000000000000000 REGS: c000000127cef8a0 TRAP: 0700 Not tainted (6.17.0-auto-12607-g5472d60c129f) MSR: 8000000002029033 <SF,VEC,EE,ME,IR,DR,RI,LE> CR: 84000840 XER: 20040010
CFAR: c00000000017eed0 IRQMASK: 0
GPR00: c00000000201de34 c000000127cefb40 c0000000016a8100 0000000000000001
GPR04: c00000012005aa00 0000000020000000 c000000002b705c8 0000000000000000
GPR08: 000000007fffffff fffffffffffffff0 c000000002db8100 000000011fffffff
GPR12: c00000000201dd40 c000000002ff0000 c0000000000112bc 0000000000000000
GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
GPR20: 0000000000000000 0000000000000000 0000000000000000 c0000000015a3808
GPR24: c00000000200468c c000000001699888 0000000000000106 c0000000020d1950
GPR28: c0000000014683f8 0000000081000200 c0000000015c1868 c000000002b9f710 NIP [c00000000201de3c] add_system_ram_resources+0xfc/0x180
LR [c00000000201de34] add_system_ram_resources+0xf4/0x180
Call Trace: add_system_ram_resources+0xf4/0x180 (unreliable) do_one_initcall+0x60/0x36c do_initcalls+0x120/0x220 kernel_init_freeable+0x23c/0x390 kernel_init+0x34/0x26c ret_from_kernel_user_thread+0x14/0x1c
This warning occurs due to a conflict between crashkernel and System RAM iomem resources.
The generic crashkernel reservation adds the crashkernel memory range to /proc/iomem during early initialization. Later, all memblock ranges are added to /proc/iomem as System RAM. If the crashkernel region overlaps with any memblock range, it causes a conflict while adding those memblock regions as iomem resources, triggering the above warning. The conflicting memblock regions are then omitted from /proc/iomem.
For example, if the following crashkernel region is added to /proc/iomem:
20000000-11fffffff : Crash kernel
then the following memblock regions System RAM regions fail to be inserted:
00000000-7fffffff : System RAM
80000000-257fffffff : System RAM
Fix this by not adding the crashkernel memory to /proc/iomem on powerpc. Introduce an architecture hook to let each architecture decide whether to export the crashkernel region to /proc/iomem.
For more info checkout commit c40dd2f766440 ("powerpc: Add System RAM to /proc/iomem") and commit bce074bdbc36 ("powerpc: insert System RAM resource to prevent crashkernel conflict")
Note: Before switching to the generic crashkernel reservation, powerpc never exported the crashkernel region to /proc/iomem.
--- arch/powerpc/include/asm/crash_reserve.h | 8 ++++++++ include/linux/crash_reserve.h | 6 ++++++ kernel/crash_reserve.c | 3 +++ 3 files changed, 17 insertions(+)
arch/powerpc/include/asm/crash_reserve.h +8 -0
@@ -5,4 +5,12 @@/* crash kernel regions are Page size agliged */ #define CRASH_ALIGN PAGE_SIZE +#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION +static inline bool arch_add_crash_res_to_iomem (void ) +{ +return false; +} +#define arch_add_crash_res_to_iomem arch_add_crash_res_to_iomem +#endif +#endif /* _ASM_POWERPC_CRASH_RESERVE_H */
include/linux/crash_reserve.h +6 -0
@@ -32,6 +32,12 @@ int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,void __init reserve_crashkernel_cma (unsigned long long cma_size);#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION +#ifndef arch_add_crash_res_to_iomem +static inline bool arch_add_crash_res_to_iomem (void ) +{ +return true; +} +#endif #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20)#endif
kernel/crash_reserve.c +3 -0
@@ -524,6 +524,9 @@ void __init reserve_crashkernel_cma(unsigned long long cma_size)#ifndef HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY static __init int insert_crashkernel_resources (void ) { +if (!arch_add_crash_res_to_iomem ()) +return 0 ; +if (crashk_res.start < crashk_res.end)insert_resource (&iomem_resource, &crashk_res);
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 274/430 dma-mapping: Fix DMA_BIT_MASK() macro being broken
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit 31b931bebd11a0f00967114f62c8c38952f483e5 upstream.
After commit a50f7456f853 ("dma-mapping: Allow use of DMA_BIT_MASK(64) in global scope"), the DMA_BIT_MASK() macro is broken when passed non trivial statements for the value of 'n'. This is caused by the new version missing parenthesis around 'n' when evaluating 'n'.
One example of this breakage is the IPU6 driver now crashing due to it getting DMA-addresses with address bit 32 set even though it has tried to set a 32 bit DMA mask.
The IPU6 CSI2 engine has a DMA mask of either 31 or 32 bits depending on if it is in secure mode or not and it sets this masks like this:
mmu_info->aperture_end =
(dma_addr_t)DMA_BIT_MASK(isp->secure_mode ?
IPU6_MMU_ADDR_BITS :
IPU6_MMU_ADDR_BITS_NON_SECURE);So the 'n' argument here is "isp->secure_mode ? IPU6_MMU_ADDR_BITS :IPU6_MMU_ADDR_BITS_NON_SECURE" which gets expanded into:
isp->secure_mode ? IPU6_MMU_ADDR_BITS : IPU6_MMU_ADDR_BITS_NON_SECURE - 1
With the -1 only being applied in the non secure case, causing the secure mode mask to be one 1 bit too large.
--- include/linux/dma-mapping.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/dma-mapping.h +1 -1
@@ -90,7 +90,7 @@*/ #define DMA_MAPPING_ERROR (~(dma_addr_t)0) -#define DMA_BIT_MASK (n) GENMASK_ULL(n - 1, 0) +#define DMA_BIT_MASK (n) GENMASK_ULL((n) - 1, 0)struct dma_iova_state {dma_addr_t addr;
Signature · 1 line
2.52.0
Greg Kroah-Hartman
maintainerPATCH 275/430 mm/slab: introduce kvfree_rcu_barrier_on_cache() for cache destruction
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Yoo <[email protected]>
commit 0f35040de59371ad542b915d7b91176c9910dadc upstream.
Currently, kvfree_rcu_barrier() flushes RCU sheaves across all slab caches when a cache is destroyed. This is unnecessary; only the RCU sheaves belonging to the cache being destroyed need to be flushed.
As suggested by Vlastimil Babka, introduce a weaker form of kvfree_rcu_barrier() that operates on a specific slab cache.
Factor out flush_rcu_sheaves_on_cache() from flush_all_rcu_sheaves() and call it from flush_all_rcu_sheaves() and kvfree_rcu_barrier_on_cache().
Call kvfree_rcu_barrier_on_cache() instead of kvfree_rcu_barrier() on cache destruction.
The performance benefit is evaluated on a 12 core 24 threads AMD Ryzen 5900X machine (1 socket), by loading slub_kunit module.
Before:
Total calls: 19
Average latency (us): 18127
Total time (us): 344414
After:
Total calls: 19
Average latency (us): 10066
Total time (us): 191264
Two performance regression have been reported:
- stress module loader test's runtime increases by 50-60% (Daniel)
- internal graphics test's runtime on Tegra234 increases by 35% (Jon)
They are fixed by this change.
--- include/linux/slab.h | 7 ++++++ mm/slab.h | 1 mm/slab_common.c | 52 +++++++++++++++++++++++++++++++++------------- mm/slub.c | 57 +++++++++++++++++++++++++++------------------------ 4 files changed, 76 insertions(+), 41 deletions(-)
include/linux/slab.h +7 -0
@@ -1150,10 +1150,17 @@ static inline void kvfree_rcu_barrier(vo rcu_barrier(); } +static inline void kvfree_rcu_barrier_on_cache (struct kmem_cache *s) +{ +rcu_barrier (); +} +static inline void kfree_rcu_scheduler_running (void ) { }#else void kvfree_rcu_barrier (void ); +void kvfree_rcu_barrier_on_cache (struct kmem_cache *s); +void kfree_rcu_scheduler_running (void );#endif
mm/slab.h +1 -0
@@ -442,6 +442,7 @@ static inline bool is_kmalloc_normal(strbool __kfree_rcu_sheaf (struct kmem_cache *s,void *obj);void flush_all_rcu_sheaves (void ); +void flush_rcu_sheaves_on_cache (struct kmem_cache *s);#define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | \ SLAB_CACHE_DMA32 | SLAB_PANIC | \
mm/slab_common.c +37 -15
81 lines not on this page · raw message
mm/slub.c +31 -26
73 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 276/430 mptcp: pm: ignore unknown endpoint flags
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 0ace3297a7301911e52d8195cb1006414897c859 upstream.
Before this patch, the kernel was saving any flags set by the userspace, even unknown ones. This doesn't cause critical issues because the kernel is only looking at specific ones. But on the other hand, endpoints dumps could tell the userspace some recent flags seem to be supported on older kernel versions.
Instead, ignore all unknown flags when parsing them. By doing that, the userspace can continue to set unsupported flags, but it has a way to verify what is supported by the kernel.
Note that it sounds better to continue accepting unsupported flags not to change the behaviour, but also that eases things on the userspace side by adding "optional" endpoint types only supported by newer kernel versions without having to deal with the different kernel versions.
A note for the backports: there will be conflicts in mptcp.h on older versions not having the mentioned flags, the new line should still be added last, and the '5' needs to be adapted to have the same value as the last entry.
--- include/uapi/linux/mptcp.h | 1 + net/mptcp/pm_netlink.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
include/uapi/linux/mptcp.h +1 -0
@@ -40,6 +40,7 @@#define MPTCP_PM_ADDR_FLAG_FULLMESH _BITUL(3)#define MPTCP_PM_ADDR_FLAG_IMPLICIT _BITUL(4)#define MPTCP_PM_ADDR_FLAG_LAMINAR _BITUL(5) +#define MPTCP_PM_ADDR_FLAGS_MASK GENMASK(5, 0)struct mptcp_info {__u8 mptcpi_subflows;
net/mptcp/pm_netlink.c +2 -1
@@ -119,7 +119,8 @@ int mptcp_pm_parse_entry(struct nlattr * }if (tb[MPTCP_PM_ADDR_ATTR_FLAGS ]) - entry->flags =nla_get_u32 (tb[MPTCP_PM_ADDR_ATTR_FLAGS ]); + entry->flags =nla_get_u32 (tb[MPTCP_PM_ADDR_ATTR_FLAGS ]) & +MPTCP_PM_ADDR_FLAGS_MASK ;if (tb[MPTCP_PM_ADDR_ATTR_PORT ]) entry->addr.port =htons (nla_get_u16 (tb[MPTCP_PM_ADDR_ATTR_PORT ]));
Greg Kroah-Hartman
maintainerPATCH 277/430 selftests: mptcp: pm: ensure unknown flags are ignored
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Baerts (NGI0) <[email protected]>
commit 29f4801e9c8dfd12bdcb33b61a6ac479c7162bd7 upstream.
This validates the previous commit: the userspace can set unknown flags -- the 7th bit is currently unused -- without errors, but only the supported ones are printed in the endpoints dumps.
The 'Fixes' tag here below is the same as the one from the previous
commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID.
--- tools/testing/selftests/net/mptcp/pm_netlink.sh | 4 ++++ tools/testing/selftests/net/mptcp/pm_nl_ctl.c | 11 +++++++++++ 2 files changed, 15 insertions(+)
tools/testing/selftests/net/mptcp/pm_netlink.sh +4 -0
@@ -192,6 +192,10 @@ check "show_endpoints" \ flush_endpoint check "show_endpoints" "" "flush addrs" +add_endpoint 10.0.1.1 flags unknown +check "show_endpoints" "$(format_endpoints "1,10.0.1.1")" "ignore unknown flags" +flush_endpoint + set_limits 9 1 2>/dev/null check "get_limits" "${default_limits}" "rcv addrs above hard limit"
tools/testing/selftests/net/mptcp/pm_nl_ctl.c +11 -0
@@ -24,6 +24,8 @@#define IPPROTO_MPTCP 262#endif +#define MPTCP_PM_ADDR_FLAG_UNKNOWN _BITUL(7) +static void syntax (char *argv[]) {fprintf (stderr,"%s add|ann|rem|csf|dsf|get|set|del|flush|dump|events|listen|accept [<args>]\n" , argv[0 ]);
@@ -836,6 +838,8 @@ int add_addr(int fd, int pm_family, int flags |=MPTCP_PM_ADDR_FLAG_BACKUP ; else if (!strcmp(tok, "fullmesh")) flags |=MPTCP_PM_ADDR_FLAG_FULLMESH ; + else if (!strcmp(tok, "unknown")) + flags |=MPTCP_PM_ADDR_FLAG_UNKNOWN ; else error(1, errno, "unknown flag %s", argv[arg]);
@@ -1047,6 +1051,13 @@ static void print_addr(struct rtattr *atif (flags)printf ("," ); } + +if (flags &MPTCP_PM_ADDR_FLAG_UNKNOWN ) { +printf ("unknown" ); + flags &= ~MPTCP_PM_ADDR_FLAG_UNKNOWN ; +if (flags) +printf ("," ); + }/* bump unknown flags, if any */ if (flags)
Greg Kroah-Hartman
maintainerPATCH 278/430 mptcp: schedule rtx timer only after pushing data
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit 2ea6190f42d0416a4310e60a7fcb0b49fcbbd4fb upstream.
The MPTCP protocol usually schedule the retransmission timer only when there is some chances for such retransmissions to happen.
With a notable exception: __mptcp_push_pending() currently schedule such timer unconditionally, potentially leading to unnecessary rtx timer expiration.
The issue is present since the blamed commit below but become easily reproducible after commit 27b0e701d387 ("mptcp: drop bogus optimization in __mptcp_check_push()")
--- net/mptcp/protocol.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
net/mptcp/protocol.c +9 -6
@@ -1597,7 +1597,7 @@ void __mptcp_push_pending(struct sock *sstruct mptcp_sendmsg_info info = { .flags = flags, }; -bool do_check_data_fin = false; +bool copied = false;int push_count =1 ;while (mptcp_send_head (sk) && (push_count >0 )) {
@@ -1639,7 +1639,7 @@ void __mptcp_push_pending(struct sock *s push_count--;continue ; } - do_check_data_fin = true; + copied = true; } } }
@@ -1648,11 +1648,14 @@ void __mptcp_push_pending(struct sock *sif (ssk)mptcp_push_release (ssk, &info); -/* ensure the rtx timer is running */ -if (!mptcp_rtx_timer_pending (sk)) -mptcp_reset_rtx_timer (sk); -if (do_check_data_fin) +/* Avoid scheduling the rtx timer if no data has been pushed; the timer +* will be updated on positive acks by __mptcp_cleanup_una(). +*/ +if (copied) { +if (!mptcp_rtx_timer_pending (sk)) +mptcp_reset_rtx_timer (sk);mptcp_check_send_data_fin (sk); + } }static void __mptcp_subflow_push_pending (struct sock *sk,struct sock *ssk,bool first)
Greg Kroah-Hartman
maintainerPATCH 279/430 mptcp: avoid deadlock on fallback while reinjecting
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
commit ffb8c27b0539dd90262d1021488e7817fae57c42 upstream.
Jakub reported an MPTCP deadlock at fallback time:
WARNING: possible recursive locking detected
6.18.0-rc7-virtme #1 Not tainted
--------------------------------------------
mptcp_connect/20858 is trying to acquire lock:
ff1100001da18b60 (&msk->fallback_lock){+.-.}-{3:3}, at: __mptcp_try_fallback+0xd8/0x280
but task is already holding lock:
ff1100001da18b60 (&msk->fallback_lock){+.-.}-{3:3}, at: __mptcp_retrans+0x352/0xaa0
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
---- lock(&msk->fallback_lock);
lock(&msk->fallback_lock);
*** DEADLOCK ***
May be due to missing lock nesting notation
3 locks held by mptcp_connect/20858:
#0: ff1100001da18290 (sk_lock-AF_INET){+.+.}-{0:0}, at: mptcp_sendmsg+0x114/0x1bc0 #1: ff1100001db40fd0 (k-sk_lock-AF_INET#2){+.+.}-{0:0}, at: __mptcp_retrans+0x2cb/0xaa0 #2: ff1100001da18b60 (&msk->fallback_lock){+.-.}-{3:3}, at: __mptcp_retrans+0x352/0xaa0
stack backtrace: CPU: 0 UID: 0 PID: 20858 Comm: mptcp_connect Not tainted 6.18.0-rc7-virtme #1 PREEMPT(full) Hardware name: Bochs, BIOS Bochs 01/01/2011 Call Trace: <TASK> dump_stack_lvl+0x6f/0xa0 print_deadlock_bug.cold+0xc0/0xcd validate_chain+0x2ff/0x5f0 __lock_acquire+0x34c/0x740 lock_acquire.part.0+0xbc/0x260 _raw_spin_lock_bh+0x38/0x50 __mptcp_try_fallback+0xd8/0x280 mptcp_sendmsg_frag+0x16c2/0x3050 __mptcp_retrans+0x421/0xaa0 mptcp_release_cb+0x5aa/0xa70 release_sock+0xab/0x1d0 mptcp_sendmsg+0xd5b/0x1bc0 sock_write_iter+0x281/0x4d0 new_sync_write+0x3c5/0x6f0 vfs_write+0x65e/0xbb0 ksys_write+0x17e/0x200 do_syscall_64+0xbb/0xfd0 entry_SYSCALL_64_after_hwframe+0x4b/0x53 RIP: 0033:0x7fa5627cbc5e Code: 4d 89 d8 e8 14 bd 00 00 4c 8b 5d f8 41 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 11 c9 c3 0f 1f 80 00 00 00 00 48 8b 45 10 0f 05 <c9> c3 83 e2 39 83 fa 08 75 e7 e8 13 ff ff ff 0f 1f 00 f3 0f 1e fa RSP: 002b:00007fff1fe14700 EFLAGS: 00000202 ORIG_RAX: 0000000000000001 RAX: ffffffffffffffda RBX: 0000000000000005 RCX: 00007fa5627cbc5e RDX: 0000000000001f9c RSI: 00007fff1fe16984 RDI: 0000000000000005 RBP: 00007fff1fe14710 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000202 R12: 00007fff1fe16920 R13: 0000000000002000 R14: 0000000000001f9c R15: 0000000000001f9c
The packet scheduler could attempt a reinjection after receiving an MP_FAIL and before the infinite map has been transmitted, causing a deadlock since MPTCP needs to do the reinjection atomically from WRT fallback.
Address the issue explicitly avoiding the reinjection in the critical scenario. Note that this is the only fallback critical section that could potentially send packets and hit the double-lock.
--- net/mptcp/protocol.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
net/mptcp/protocol.c +5 -2
@@ -2693,10 +2693,13 @@ static void __mptcp_retrans(struct sock/* * make the whole retrans decision, xmit, disallow -* fallback atomic +* fallback atomic, note that we can't retrans even +* when an infinite fallback is in progress, i.e. new +* subflows are disallowed. */ spin_lock_bh (&msk->fallback_lock); -if (__mptcp_check_fallback (msk)) { +if (__mptcp_check_fallback (msk) || + !msk->allow_subflows) {spin_unlock_bh (&msk->fallback_lock);release_sock (ssk); goto clear_scheduled;
Greg Kroah-Hartman
maintainerPATCH 280/430 usb: usb-storage: Maintain minimal modifications to the bcdDevice range.
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen Changcheng <[email protected]>
commit 0831269b5f71594882accfceb02638124f88955d upstream.
We cannot determine which models require the NO_ATA_1X and IGNORE_RESIDUE quirks aside from the EL-R12 optical drive device.
--- drivers/usb/storage/unusual_uas.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/unusual_uas.h +1 -1
@@ -98,7 +98,7 @@ UNUSUAL_DEV(0x125f, 0xa94a, 0x0160, 0x01 US_FL_NO_ATA_1X),/* Reported-by: Benjamin Tissoires <[email protected]> */ -UNUSUAL_DEV(0x13fd, 0x3940, 0x0309, 0x0309, +UNUSUAL_DEV(0x13fd, 0x3940, 0x0000, 0x0309, "Initio Corporation", "INIC-3069", USB_SC_DEVICE, USB_PR_DEVICE, NULL,
Greg Kroah-Hartman
maintainerPATCH 281/430 media: dvb-usb: dtv5100: fix out-of-bounds in dtv5100_i2c_msg()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeongjun Park <[email protected]>
commit b91e6aafe8d356086cc621bc03e35ba2299e4788 upstream.
rlen value is a user-controlled value, but dtv5100_i2c_msg() does not check the size of the rlen value. Therefore, if it is set to a value larger than sizeof(st->data), an out-of-bounds vuln occurs for st->data.
Therefore, we need to add proper range checking to prevent this vuln.
--- drivers/media/usb/dvb-usb/dtv5100.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/media/usb/dvb-usb/dtv5100.c +5 -0
@@ -55,6 +55,11 @@ static int dtv5100_i2c_msg(struct dvb_us } index = (addr <<8 ) + wbuf[0 ]; +if (rlen >sizeof (st->data)) { +warn ("rlen = %x is too big!\n" , rlen); +return -EINVAL ; + } +memcpy (st->data, rbuf, rlen);msleep (1 );/* avoid I2C errors */ return usb_control_msg(d->udev, pipe, request,
Greg Kroah-Hartman
maintainerPATCH 282/430 media: pvrusb2: Fix incorrect variable used in trace message
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <[email protected]>
commit be440980eace19c035a0745fd6b6e42707bc4f49 upstream.
The pvr2_trace message is reporting an error about control read transfers, however it is using the incorrect variable write_len instead of read_lean. Fix this by using the correct variable read_len.
--- drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/pvrusb2/pvrusb2-hdw.c +1 -1
@@ -3622,7 +3622,7 @@ static int pvr2_send_request_ex(struct ppvr2_trace (PVR2_TRACE_ERROR_LEGS ,"Attempted to execute %d byte control-read transfer (limit=%d)" , - write_len,PVR2_CTL_BUFFSIZE ); + read_len,PVR2_CTL_BUFFSIZE );return -EINVAL ; }if ((!write_len) && (!read_len)) {
Greg Kroah-Hartman
maintainerPATCH 283/430 phy: broadcom: bcm63xx-usbh: fix section mismatches
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit 356d1924b9a6bc2164ce2bf1fad147b0c37ae085 upstream.
Platform drivers can be probed after their init sections have been discarded (e.g. on probe deferral or manual rebind through sysfs) so the probe function and match table must not live in init.
--- drivers/phy/broadcom/phy-bcm63xx-usbh.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/phy/broadcom/phy-bcm63xx-usbh.c +3 -3
@@ -375,7 +375,7 @@ static struct phy *bcm63xx_usbh_phy_xlatreturn of_phy_simple_xlate (dev, args); } -static int __init bcm63xx_usbh_phy_probe (struct platform_device *pdev) +static int bcm63xx_usbh_phy_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct bcm63xx_usbh_phy *usbh;
@@ -432,7 +432,7 @@ static int __init bcm63xx_usbh_phy_probereturn 0 ; } -static const struct of_device_id bcm63xx_usbh_phy_ids[]__initconst = { +static const struct of_device_id bcm63xx_usbh_phy_ids[] = { { .compatible ="brcm,bcm6318-usbh-phy" , .data = &usbh_bcm6318 }, { .compatible ="brcm,bcm6328-usbh-phy" , .data = &usbh_bcm6328 }, { .compatible ="brcm,bcm6358-usbh-phy" , .data = &usbh_bcm6358 },
@@ -443,7 +443,7 @@ static const struct of_device_id bcm63xx };MODULE_DEVICE_TABLE (of, bcm63xx_usbh_phy_ids); -static struct platform_driver bcm63xx_usbh_phy_driver__refdata = { +static struct platform_driver bcm63xx_usbh_phy_driver = { .driver = { .name ="bcm63xx-usbh-phy" , .of_match_table = bcm63xx_usbh_phy_ids,
Greg Kroah-Hartman
maintainerPATCH 284/430 usb: ohci-nxp: fix device leak on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johan Hovold <[email protected]>
commit b4c61e542faf8c9131d69ecfc3ad6de96d1b2ab8 upstream.
Make sure to drop the reference taken when looking up the PHY I2C device during probe on probe failure (e.g. probe deferral) and on driver unbind.
--- drivers/usb/host/ohci-nxp.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/ohci-nxp.c +2 -0
@@ -223,6 +223,7 @@ static int ohci_hcd_nxp_probe(struct pla fail_resource:usb_put_hcd (hcd); fail_disable: +put_device (&isp1301_i2c_client->dev); isp1301_i2c_client =NULL ;return ret; }
@@ -234,6 +235,7 @@ static void ohci_hcd_nxp_remove(struct pusb_remove_hcd (hcd);ohci_nxp_stop_hc ();usb_put_hcd (hcd); +put_device (&isp1301_i2c_client->dev); isp1301_i2c_client =NULL ; }
Greg Kroah-Hartman
maintainerPATCH 285/430 usb: typec: ucsi: huawei-gaokin: add DRM dependency
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit d14cd998e67ba8f1cca52a260a1ce1a60954fd8b upstream.
Selecting DRM_AUX_HPD_BRIDGE is not possible from a built-in driver when CONFIG_DRM=m:
WARNING: unmet direct dependencies detected for DRM_AUX_HPD_BRIDGE
Depends on [m]: HAS_IOMEM [=y] && DRM [=m] && DRM_BRIDGE [=y] && OF [=y]
Selected by [y]:
- UCSI_HUAWEI_GAOKUN [=y] && USB_SUPPORT [=y] && TYPEC [=y] && TYPEC_UCSI [=y] && EC_HUAWEI_GAOKUN [=y] && DRM_BRIDGE [=y] && OF [=y]
Add the same dependency we have in similar drivers to work around this.
--- drivers/usb/typec/ucsi/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/usb/typec/ucsi/Kconfig +1 -0
@@ -96,6 +96,7 @@ config UCSI_LENOVO_YOGA_C630 config UCSI_HUAWEI_GAOKUN tristate "UCSI Interface Driver for Huawei Matebook E Go" depends on EC_HUAWEI_GAOKUN + depends on DRM || !DRM select DRM_AUX_HPD_BRIDGE if DRM_BRIDGE && OF help This driver enables UCSI support on the Huawei Matebook E Go tablet,