6.12.31-rc1 review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 524/626 btrfs: correct the order of prelim_ref arguments in btrfs__prelim_ref
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Goldwyn Rodrigues <[email protected]>
[ Upstream commit bc7e0975093567f51be8e1bdf4aa5900a3cf0b1e ]
btrfs_prelim_ref() calls the old and new reference variables in the incorrect order. This causes a NULL pointer dereference because oldref is passed as NULL to trace_btrfs_prelim_ref_insert().
Note, trace_btrfs_prelim_ref_insert() is being called with newref as oldref (and oldref as NULL) on purpose in order to print out the values of newref.
To reproduce:
echo 1 > /sys/kernel/debug/tracing/events/btrfs/btrfs_prelim_ref_insert/enable
Perform some writeback operations.
Backtrace: BUG: kernel NULL pointer dereference, address: 0000000000000018 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 115949067 P4D 115949067 PUD 11594a067 PMD 0 Oops: Oops: 0000 [#1] SMP NOPTI CPU: 1 UID: 0 PID: 1188 Comm: fsstress Not tainted 6.15.0-rc2-tester+ #47 PREEMPT(voluntary) 7ca2cef72d5e9c600f0c7718adb6462de8149622 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-2-gc13ff2cd-prebuilt.qemu.org 04/01/2014 RIP: 0010:trace_event_raw_event_btrfs__prelim_ref+0x72/0x130 Code: e8 43 81 9f ff 48 85 c0 74 78 4d 85 e4 0f 84 8f 00 00 00 49 8b 94 24 c0 06 00 00 48 8b 0a 48 89 48 08 48 8b 52 08 48 89 50 10 <49> 8b 55 18 48 89 50 18 49 8b 55 20 48 89 50 20 41 0f b6 55 28 88 RSP: 0018:ffffce44820077a0 EFLAGS: 00010286 RAX: ffff8c6b403f9014 RBX: ffff8c6b55825730 RCX: 304994edf9cf506b RDX: d8b11eb7f0fdb699 RSI: ffff8c6b403f9010 RDI: ffff8c6b403f9010 RBP: 0000000000000001 R08: 0000000000000001 R09: 0000000000000010 R10: 00000000ffffffff R11: 0000000000000000 R12: ffff8c6b4e8fb000 R13: 0000000000000000 R14: ffffce44820077a8 R15: ffff8c6b4abd1540 FS: 00007f4dc6813740(0000) GS:ffff8c6c1d378000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000018 CR3: 000000010eb42000 CR4: 0000000000750ef0 PKRU: 55555554 Call Trace: <TASK> prelim_ref_insert+0x1c1/0x270 find_parent_nodes+0x12a6/0x1ee0 ? __entry_text_end+0x101f06/0x101f09 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 ? srso_alias_return_thunk+0x5/0xfbef5 btrfs_is_data_extent_shared+0x167/0x640 ? fiemap_process_hole+0xd0/0x2c0 extent_fiemap+0xa5c/0xbc0 ? __entry_text_end+0x101f05/0x101f09 btrfs_fiemap+0x7e/0xd0 do_vfs_ioctl+0x425/0x9d0 __x64_sys_ioctl+0x75/0xc0
--- include/trace/events/btrfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/events/btrfs.h +1 -1
@@ -1924,7 +1924,7 @@ DECLARE_EVENT_CLASS(btrfs__prelim_ref, TP_PROTO(const struct btrfs_fs_info *fs_info, const struct prelim_ref *oldref, const struct prelim_ref *newref, u64 tree_size), -TP_ARGS (fs_info, newref, oldref, tree_size), +TP_ARGS (fs_info, oldref, newref, tree_size),TP_STRUCT__entry_btrfs ( __field( u64, root_id )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 525/626 btrfs: handle empty eb->folios in num_extent_folios()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Boris Burkov <[email protected]>
[ Upstream commit d6fe0c69b3aa5c985380b794bdf8e6e9b1811e60 ]
num_extent_folios() unconditionally calls folio_order() on eb->folios[0]. If that is NULL this will be a segfault. It is reasonable for it to return 0 as the number of folios in the eb when the first entry is NULL, so do that instead.
--- fs/btrfs/extent_io.h | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/extent_io.h +2 -0
@@ -293,6 +293,8 @@ static inline int num_extent_pages(const struct extent_buffer *eb)*/ static inline int num_extent_folios (const struct extent_buffer *eb) { +if (!eb->folios[0 ]) +return 0 ;if (folio_order (eb->folios[0 ]))return 1 ;return num_extent_pages (eb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 526/626 btrfs: avoid NULL pointer dereference if no valid csum tree
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit f95d186255b319c48a365d47b69bd997fecb674e ]
[BUG]
When trying read-only scrub on a btrfs with rescue=idatacsums mount option, it will crash with the following call trace:
BUG: kernel NULL pointer dereference, address: 0000000000000208 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page CPU: 1 UID: 0 PID: 835 Comm: btrfs Tainted: G O 6.15.0-rc3-custom+ #236 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS unknown 02/02/2022 RIP: 0010:btrfs_lookup_csums_bitmap+0x49/0x480 [btrfs] Call Trace: <TASK> scrub_find_fill_first_stripe+0x35b/0x3d0 [btrfs] scrub_simple_mirror+0x175/0x290 [btrfs] scrub_stripe+0x5f7/0x6f0 [btrfs] scrub_chunk+0x9a/0x150 [btrfs] scrub_enumerate_chunks+0x333/0x660 [btrfs] btrfs_scrub_dev+0x23e/0x600 [btrfs] btrfs_ioctl+0x1dcf/0x2f80 [btrfs] __x64_sys_ioctl+0x97/0xc0 do_syscall_64+0x4f/0x120 entry_SYSCALL_64_after_hwframe+0x76/0x7e
[CAUSE]
Mount option "rescue=idatacsums" will completely skip loading the csum tree, so that any data read will not find any data csum thus we will ignore data checksum verification.
Normally call sites utilizing csum tree will check the fs state flag NO_DATA_CSUMS bit, but unfortunately scrub does not check that bit at all.
This results in scrub to call btrfs_search_slot() on a NULL pointer and triggered above crash.
[FIX]
Check both extent and csum tree root before doing any tree search.
--- fs/btrfs/scrub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/scrub.c +2 -2
@@ -1541,8 +1541,8 @@ static int scrub_find_fill_first_stripe(struct btrfs_block_group *bg,u64 extent_gen;int ret; -if (unlikely (!extent_root)) { -btrfs_err (fs_info,"no valid extent root for scrub" ); +if (unlikely (!extent_root || !csum_root)) { +btrfs_err (fs_info,"no valid extent or csum root for scrub" );return -EUCLEAN ; } memset(stripe->sectors, 0, sizeof(struct scrub_sector_verification) *
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 527/626 tools: ynl-gen: validate 0 len strings from kernel
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Wei <[email protected]>
[ Upstream commit 4720f9707c783f642332dee3d56dccaefa850e42 ]
Strings from the kernel are guaranteed to be null terminated and ynl_attr_validate() checks for this. But it doesn't check if the string has a len of 0, which would cause problems when trying to access data[len - 1]. Fix this by checking that len is positive.
--- tools/net/ynl/lib/ynl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/net/ynl/lib/ynl.c +1 -1
@@ -364,7 +364,7 @@ int ynl_attr_validate(struct ynl_parse_arg *yarg, const struct nlattr *attr) "Invalid attribute (binary %s)", policy->name);return -1 ;case YNL_PT_NUL_STR : -if ((!policy->len || len <= policy->len) && !data[len -1 ]) +if (len && (!policy->len || len <= policy->len) && !data[len -1 ])break ;yerr (yarg->ys,YNL_ERROR_ATTR_INVALID ,"Invalid attribute (string %s)" , policy->name);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 528/626 block: only update request sector if needed
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit db492e24f9b05547ba12b4783f09c9d943cf42fe ]
In case of a ZONE APPEND write, regardless of native ZONE APPEND or the emulation layer in the zone write plugging code, the sector the data got written to by the device needs to be updated in the bio.
At the moment, this is done for every native ZONE APPEND write and every request that is flagged with 'BIO_ZONE_WRITE_PLUGGING'. But thus superfluously updates the sector for regular writes to a zoned block device.
Check if a bio is a native ZONE APPEND write or if the bio is flagged as 'BIO_EMULATES_ZONE_APPEND', meaning the block layer's zone write plugging code handles the ZONE APPEND and translates it into a regular write and back. Only if one of these two criterion is met, update the sector in the bio upon completion.
--- block/blk.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk.h +2 -1
@@ -482,7 +482,8 @@ static inline void blk_zone_update_request_bio(struct request *rq,* the original BIO sector so that blk_zone_write_plug_bio_endio() can * lookup the zone write plug. */ -if (req_op (rq) ==REQ_OP_ZONE_APPEND ||bio_zone_write_plugging (bio)) +if (req_op (rq) ==REQ_OP_ZONE_APPEND || +bio_flagged (bio,BIO_EMULATES_ZONE_APPEND )) bio->bi_iter.bi_sector = rq->__sector; }void blk_zone_write_plug_bio_endio (struct bio *bio);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 529/626 wifi: iwlwifi: add support for Killer on MTL
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit ebedf8b7f05b9c886d68d63025db8d1b12343157 ]
For now, we need another entry for these devices, this will be changed completely for 6.16.
--- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +2 -0
@@ -587,6 +587,8 @@ VISIBLE_IF_IWLWIFI_KUNIT const struct iwl_dev_info iwl_dev_info_table[] = {IWL_DEV_INFO (0x7A70 ,0x1692 , iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690i_name),IWL_DEV_INFO (0x7AF0 ,0x1691 , iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690s_name),IWL_DEV_INFO (0x7AF0 ,0x1692 , iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690i_name), +IWL_DEV_INFO (0x7F70 ,0x1691 , iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690s_name), +IWL_DEV_INFO (0x7F70 ,0x1692 , iwlax411_2ax_cfg_so_gf4_a0, iwl_ax411_killer_1690i_name),IWL_DEV_INFO (0x271C ,0x0214 , iwl9260_2ac_cfg, iwl9260_1_name), IWL_DEV_INFO(0x7E40, 0x1691, iwl_cfg_ma, iwl_ax411_killer_1690s_name),
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 530/626 x86/Kconfig: make CFI_AUTO_DEFAULT depend on !RUST or Rust >= 1.88
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paweł Anikiel <[email protected]>
[ Upstream commit 5595c31c370957aabe739ac3996aedba8267603f ]
Calling core::fmt::write() from rust code while FineIBT is enabled results in a kernel panic:
[ 4614.199779] kernel BUG at arch/x86/kernel/cet.c:132! [ 4614.205343] Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI [ 4614.211781] CPU: 2 UID: 0 PID: 6057 Comm: dmabuf_dump Tainted: G U O 6.12.17-android16-0-g6ab38c534a43 #1 9da040f27673ec3945e23b998a0f8bd64c846599 [ 4614.227832] Tainted: [U]=USER, [O]=OOT_MODULE [ 4614.241247] RIP: 0010:do_kernel_cp_fault+0xea/0xf0 ... [ 4614.398144] RIP: 0010:_RNvXs5_NtNtNtCs3o2tGsuHyou_4core3fmt3num3impyNtB9_7Display3fmt+0x0/0x20 [ 4614.407792] Code: 48 f7 df 48 0f 48 f9 48 89 f2 89 c6 5d e9 18 fd ff ff 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 41 81 ea 14 61 af 2c 74 03 0f 0b 90 <66> 0f 1f 00 55 48 89 e5 48 89 f2 48 8b 3f be 01 00 00 00 5d e9 e7 [ 4614.428775] RSP: 0018:ffffb95acfa4ba68 EFLAGS: 00010246 [ 4614.434609] RAX: 0000000000000000 RBX: 0000000000000010 RCX: 0000000000000000 [ 4614.442587] RDX: 0000000000000007 RSI: ffffb95acfa4ba70 RDI: ffffb95acfa4bc88 [ 4614.450557] RBP: ffffb95acfa4bae0 R08: ffff0a00ffffff05 R09: 0000000000000070 [ 4614.458527] R10: 0000000000000000 R11: ffffffffab67eaf0 R12: ffffb95acfa4bcc8 [ 4614.466493] R13: ffffffffac5d50f0 R14: 0000000000000000 R15: 0000000000000000 [ 4614.474473] ? __cfi__RNvXs5_NtNtNtCs3o2tGsuHyou_4core3fmt3num3impyNtB9_7Display3fmt+0x10/0x10 [ 4614.484118] ? _RNvNtCs3o2tGsuHyou_4core3fmt5write+0x1d2/0x250
This happens because core::fmt::write() calls core::fmt::rt::Argument::fmt(), which currently has CFI disabled:
library/core/src/fmt/rt.rs:
171 // FIXME: Transmuting formatter in new and indirectly branching to/calling
172 // it here is an explicit CFI violation.
173 #[allow(inline_no_sanitize)]
174 #[no_sanitize(cfi, kcfi)]
175 #[inline]
176 pub(super) unsafe fn fmt(&self, f: &mut Formatter<'_>) -> Result {This causes a Control Protection exception, because FineIBT has sealed off the original function's endbr64.
This makes rust currently incompatible with FineIBT. Add a Kconfig dependency that prevents FineIBT from getting turned on by default if rust is enabled.
[ Rust 1.88.0 (scheduled for 2025-06-26) should have this fixed [1],
and thus we relaxed the condition with Rust >= 1.88.
When objtool lands checking for this with e.g. [2], the plan is to ideally run that in upstream Rust's CI to prevent regressions early [3], since we do not control core's source code.
Alice tested the Rust PR backported to an older compiler.
Peter would like that Rust provides a stable core which can be pulled into the kernel: "Relying on that much out of tree code is 'unfortunate'".
- Miguel ]
--- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/x86/Kconfig +1 -0
@@ -2420,6 +2420,7 @@ config STRICT_SIGALTSTACK_SIZE config CFI_AUTO_DEFAULT bool "Attempt to use FineIBT by default at boot time" depends on FINEIBT + depends on !RUST || RUSTC_VERSION >= 108800 default y help Attempt to use FineIBT by default at boot time. If enabled,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 531/626 xenbus: Allow PVH dom0 a non-local xenstore
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Andryuk <[email protected]>
[ Upstream commit 90989869baae47ee2aa3bcb6f6eb9fbbe4287958 ]
Make xenbus_init() allow a non-local xenstore for a PVH dom0 - it is currently forced to XS_LOCAL. With Hyperlaunch booting dom0 and a xenstore stubdom, dom0 can be handled as a regular XS_HVM following the late init path.
Ideally we'd drop the use of xen_initial_domain() and just check for the event channel instead. However, ARM has a xen,enhanced no-xenstore mode, where the event channel and PFN would both be 0. Retain the xen_initial_domain() check, and use that for an additional check when the event channel is 0.
Check the full 64bit HVM_PARAM_STORE_EVTCHN value to catch the off chance that high bits are set for the 32bit event channel.
Message-ID: <[email protected]>
--- drivers/xen/xenbus/xenbus_probe.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/xen/xenbus/xenbus_probe.c +8 -6
@@ -966,9 +966,15 @@ static int __init xenbus_init(void)if (xen_pv_domain ()) xen_store_domain_type =XS_PV ;if (xen_hvm_domain ()) + { xen_store_domain_type =XS_HVM ; -if (xen_hvm_domain () &&xen_initial_domain ()) - xen_store_domain_type =XS_LOCAL ; + err =hvm_get_parameter (HVM_PARAM_STORE_EVTCHN , &v); +if (err) + goto out_error; + xen_store_evtchn = (int )v; +if (!v &&xen_initial_domain ()) + xen_store_domain_type =XS_LOCAL ; + }if (xen_pv_domain () && !xen_start_info->store_evtchn) xen_store_domain_type =XS_LOCAL ;if (xen_pv_domain () && xen_start_info->store_evtchn)
@@ -987,10 +993,6 @@ static int __init xenbus_init(void) xen_store_interface =gfn_to_virt (xen_store_gfn);break ;case XS_HVM : - err =hvm_get_parameter (HVM_PARAM_STORE_EVTCHN , &v); -if (err) - goto out_error; - xen_store_evtchn = (int )v; err =hvm_get_parameter (HVM_PARAM_STORE_PFN , &v);if (err) goto out_error;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 532/626 drm/amd/display: Call FP Protect Before Mode Programming/Mode Support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Austin Zheng <[email protected]>
[ Upstream commit eba692ca3abca258b3214a6e4126afefad1822f0 ]
[Why]
Memory allocation occurs within dml21_validate() for adding phantom planes. May cause kernel to be tainted due to usage of FP Start.
[How]
Move FP start from dml21_validate to before mode programming/mode support. Calculations requiring floating point are all done within mode programming or mode support.
--- drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/dml2/dml21/dml21_wrapper.c +4 -4
@@ -221,7 +221,9 @@ static bool dml21_mode_check_and_programming(const struct dc *in_dc, struct dc_sif (!result)return false; +DC_FP_START (); result =dml2_build_mode_programming (mode_programming); +DC_FP_END ();if (!result)return false;
@@ -271,7 +273,9 @@ static bool dml21_check_mode_support(const struct dc *in_dc, struct dc_state *co mode_support->dml2_instance = dml_init->dml2_instance;dml21_map_dc_state_into_dml_display_cfg (in_dc, context, dml_ctx); dml_ctx->v21.mode_programming.dml2_instance->scratch.build_mode_programming_locals.mode_programming_params.programming = dml_ctx->v21.mode_programming.programming; +DC_FP_START (); is_supported =dml2_check_mode_supported (mode_support); +DC_FP_END ();if (!is_supported)return false;
@@ -282,16 +286,12 @@ bool dml21_validate(const struct dc *in_dc, struct dc_state *context, struct dml {bool out = false; -DC_FP_START (); -/* Use dml_validate_only for fast_validate path */ if (fast_validate) out =dml21_check_mode_support (in_dc, context, dml_ctx);else out =dml21_mode_check_and_programming (in_dc, context, dml_ctx); -DC_FP_END (); -return out; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 533/626 __legitimize_mnt(): check for MNT_SYNC_UMOUNT should be under mount_lock
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 250cf3693060a5f803c5f1ddc082bb06b16112a9 ]
... or we risk stealing final mntput from sync umount - raising mnt_count after umount(2) has verified that victim is not busy, but before it has set MNT_SYNC_UMOUNT; in that case __legitimize_mnt() doesn't see that it's safe to quietly undo mnt_count increment and leaves dropping the reference to caller, where it'll be a full-blown mntput().
Check under mount_lock is needed; leaving the current one done before taking that makes no sense - it's nowhere near common enough to bother with.
--- fs/namespace.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
fs/namespace.c +1 -5
@@ -750,12 +750,8 @@ int __legitimize_mnt(struct vfsmount *bastard, unsigned seq)smp_mb ();// see mntput_no_expire() and do_umount() if (likely (!read_seqretry (&mount_lock, seq)))return 0 ; -if (bastard->mnt_flags &MNT_SYNC_UMOUNT ) { -mnt_add_count (mnt,-1 ); -return 1 ; - }lock_mount_hash (); -if (unlikely (bastard->mnt_flags &MNT_DOOMED )) { +if (unlikely (bastard->mnt_flags & (MNT_SYNC_UMOUNT |MNT_DOOMED ))) {mnt_add_count (mnt,-1 );unlock_mount_hash ();return 1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 534/626 soundwire: bus: Fix race on the creation of the IRQ domain
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
[ Upstream commit fd15594ba7d559d9da741504c322b9f57c4981e5 ]
The SoundWire IRQ domain needs to be created before any slaves are added to the bus, such that the domain is always available when needed. Move the call to sdw_irq_create() before the calls to sdw_acpi_find_slaves() and sdw_of_find_slaves().
--- drivers/soundwire/bus.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/soundwire/bus.c +5 -4
@@ -121,6 +121,10 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,set_bit (SDW_GROUP13_DEV_NUM , bus->assigned);set_bit (SDW_MASTER_DEV_NUM , bus->assigned); + ret =sdw_irq_create (bus, fwnode); +if (ret) +return ret; +/* * SDW is an enumerable bus, but devices can be powered off. So, * they won't be able to report as present.
@@ -137,6 +141,7 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent,if (ret <0 ) {dev_err (bus->dev,"Finding slaves failed:%d\n" , ret); +sdw_irq_delete (bus);return ret; }
@@ -155,10 +160,6 @@ int sdw_bus_master_add(struct sdw_bus *bus, struct device *parent, bus->params.curr_bank =SDW_BANK0 ; bus->params.next_bank =SDW_BANK1 ; - ret =sdw_irq_create (bus, fwnode); -if (ret) -return ret; -return 0 ; }EXPORT_SYMBOL (sdw_bus_master_add);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 535/626 espintcp: fix skb leaks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 63c1f19a3be3169e51a5812d22a6d0c879414076 ]
A few error paths are missing a kfree_skb.
--- net/ipv4/esp4.c | 4 +++- net/ipv6/esp6.c | 4 +++- net/xfrm/espintcp.c | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-)
net/ipv4/esp4.c +3 -1
@@ -199,8 +199,10 @@ static int esp_output_tcp_finish(struct xfrm_state *x, struct sk_buff *skb) sk =esp_find_tcp_sk (x); err =PTR_ERR_OR_ZERO (sk); -if (err) +if (err) { +kfree_skb (skb); goto out; + }bh_lock_sock (sk);if (sock_owned_by_user (sk))
net/ipv6/esp6.c +3 -1
@@ -216,8 +216,10 @@ static int esp_output_tcp_finish(struct xfrm_state *x, struct sk_buff *skb) sk =esp6_find_tcp_sk (x); err =PTR_ERR_OR_ZERO (sk); -if (err) +if (err) { +kfree_skb (skb); goto out; + }bh_lock_sock (sk);if (sock_owned_by_user (sk))
net/xfrm/espintcp.c +3 -1
@@ -171,8 +171,10 @@ int espintcp_queue_out(struct sock *sk, struct sk_buff *skb)struct espintcp_ctx *ctx =espintcp_getctx (sk);if (skb_queue_len (&ctx->out_queue) >= -READ_ONCE (net_hotdata.max_backlog)) +READ_ONCE (net_hotdata.max_backlog)) { +kfree_skb (skb);return -ENOBUFS ; + }__skb_queue_tail (&ctx->out_queue, skb);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 536/626 espintcp: remove encap socket caching to avoid reference leak
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sabrina Dubroca <[email protected]>
[ Upstream commit 028363685bd0b7a19b4a820f82dd905b1dc83999 ]
The current scheme for caching the encap socket can lead to reference leaks when we try to delete the netns.
The reference chain is: xfrm_state -> enacp_sk -> netns
Since the encap socket is a userspace socket, it holds a reference on the netns. If we delete the espintcp state (through flush or individual delete) before removing the netns, the reference on the socket is dropped and the netns is correctly deleted. Otherwise, the netns may not be reachable anymore (if all processes within the ns have terminated), so we cannot delete the xfrm state to drop its reference on the socket.
This patch results in a small (~2% in my tests) performance regression.
A GC-type mechanism could be added for the socket cache, to clear references if the state hasn't been used "recently", but it's a lot more complex than just not caching the socket.
--- include/net/xfrm.h | 1 - net/ipv4/esp4.c | 49 ++++--------------------------------------- net/ipv6/esp6.c | 49 ++++--------------------------------------- net/xfrm/xfrm_state.c | 3 --- 4 files changed, 8 insertions(+), 94 deletions(-)
include/net/xfrm.h +0 -1
@@ -233,7 +233,6 @@ struct xfrm_state {/* Data for encapsulator */ struct xfrm_encap_tmpl *encap; -struct sock __rcu *encap_sk;/* NAT keepalive */ u32 nat_keepalive_interval;/* seconds */
net/ipv4/esp4.c +4 -45
83 lines not on this page · raw message
net/ipv6/esp6.c +4 -45
83 lines not on this page · raw message
net/xfrm/xfrm_state.c +0 -3
@@ -773,9 +773,6 @@ int __xfrm_state_delete(struct xfrm_state *x)xfrm_nat_keepalive_state_updated (x);spin_unlock (&net->xfrm.xfrm_state_lock); -if (x->encap_sk) -sock_put (rcu_dereference_raw (x->encap_sk)); -xfrm_dev_state_delete (x);/* All xfrm_state objects are created by xfrm_state_alloc.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 537/626 xfrm: Fix UDP GRO handling for some corner cases
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Brunner <[email protected]>
[ Upstream commit e3fd0577768584ece824c8b661c40fb3d912812a ]
This fixes an issue that's caused if there is a mismatch between the data offset in the GRO header and the length fields in the regular sk_buff due to the pskb_pull()/skb_push() calls. That's because the UDP GRO layer stripped off the UDP header via skb_gro_pull() already while the UDP header was explicitly not pulled/pushed in this function.
For example, an IKE packet that triggered this had len=data_len=1268 and the data_offset in the GRO header was 28 (IPv4 + UDP). So pskb_pull() was called with an offset of 28-8=20, which reduced len to 1248 and via pskb_may_pull() and __pskb_pull_tail() it also set data_len to 1248. As the ESP offload module was not loaded, the function bailed out and called skb_push(), which restored len to 1268, however, data_len remained at 1248.
So while skb_headlen() was 0 before, it was now 20. The latter caused a difference of 8 instead of 28 (or 0 if pskb_pull()/skb_push() was called with the complete GRO data_offset) in gro_try_pull_from_frag0() that triggered a call to gro_pull_from_frag0() that corrupted the packet.
This change uses a more GRO-like approach seen in other GRO receivers via skb_gro_header() to just read the actual data we are interested in and does not try to "restore" the UDP header at this point to call the existing function. If the offload module is not loaded, it immediately bails out, otherwise, it only does a quick check to see if the packet is an IKE or keepalive packet instead of calling the existing function.
--- net/ipv4/xfrm4_input.c | 18 ++++++++++-------- net/ipv6/xfrm6_input.c | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-)
net/ipv4/xfrm4_input.c +10 -8
@@ -182,11 +182,15 @@ struct sk_buff *xfrm4_gro_udp_encap_rcv(struct sock *sk, struct list_head *head,int offset =skb_gro_offset (skb);const struct net_offload *ops;struct sk_buff *pp =NULL ; -int ret; - - offset = offset -sizeof (struct udphdr ); +int len, dlen; +__u8 *udpdata; +__be32 *udpdata32; -if (!pskb_pull (skb, offset)) + len = skb->len - offset; + dlen = offset +min (len,8 ); + udpdata =skb_gro_header (skb, dlen, offset); + udpdata32 = (__be32 *)udpdata; +if (unlikely (!udpdata))return NULL ;rcu_read_lock ();
@@ -194,11 +198,10 @@ struct sk_buff *xfrm4_gro_udp_encap_rcv(struct sock *sk, struct list_head *head,if (!ops || !ops->callbacks.gro_receive) goto out; - ret =__xfrm4_udp_encap_rcv (sk, skb, false); -if (ret) +/* check if it is a keepalive or IKE packet */ +if (len <=sizeof (struct ip_esp_hdr ) || udpdata32[0 ] ==0 ) goto out; -skb_push (skb, offset);NAPI_GRO_CB (skb)->proto =IPPROTO_UDP ; pp =call_gro_receive (ops->callbacks.gro_receive, head, skb);
@@ -208,7 +211,6 @@ struct sk_buff *xfrm4_gro_udp_encap_rcv(struct sock *sk, struct list_head *head, out:rcu_read_unlock (); -skb_push (skb, offset);NAPI_GRO_CB (skb)->same_flow =0 ;NAPI_GRO_CB (skb)->flush =1 ;
net/ipv6/xfrm6_input.c +10 -8
@@ -179,14 +179,18 @@ struct sk_buff *xfrm6_gro_udp_encap_rcv(struct sock *sk, struct list_head *head,int offset =skb_gro_offset (skb);const struct net_offload *ops;struct sk_buff *pp =NULL ; -int ret; +int len, dlen; +__u8 *udpdata; +__be32 *udpdata32;if (skb->protocol ==htons (ETH_P_IP ))return xfrm4_gro_udp_encap_rcv (sk, head, skb); - offset = offset -sizeof (struct udphdr ); - -if (!pskb_pull (skb, offset)) + len = skb->len - offset; + dlen = offset +min (len,8 ); + udpdata =skb_gro_header (skb, dlen, offset); + udpdata32 = (__be32 *)udpdata; +if (unlikely (!udpdata))return NULL ;rcu_read_lock ();
@@ -194,11 +198,10 @@ struct sk_buff *xfrm6_gro_udp_encap_rcv(struct sock *sk, struct list_head *head,if (!ops || !ops->callbacks.gro_receive) goto out; - ret =__xfrm6_udp_encap_rcv (sk, skb, false); -if (ret) +/* check if it is a keepalive or IKE packet */ +if (len <=sizeof (struct ip_esp_hdr ) || udpdata32[0 ] ==0 ) goto out; -skb_push (skb, offset);NAPI_GRO_CB (skb)->proto =IPPROTO_UDP ; pp =call_gro_receive (ops->callbacks.gro_receive, head, skb);
@@ -208,7 +211,6 @@ struct sk_buff *xfrm6_gro_udp_encap_rcv(struct sock *sk, struct list_head *head, out:rcu_read_unlock (); -skb_push (skb, offset);NAPI_GRO_CB (skb)->same_flow =0 ;NAPI_GRO_CB (skb)->flush =1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 538/626 dmaengine: idxd: Fix allowing write() from different address spaces
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinicius Costa Gomes <[email protected]>
[ Upstream commit 8dfa57aabff625bf445548257f7711ef294cd30e ]
Check if the process submitting the descriptor belongs to the same address space as the one that opened the file, reject otherwise.
--- drivers/dma/idxd/cdev.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/dma/idxd/cdev.c +9 -0
@@ -412,6 +412,9 @@ static int idxd_cdev_mmap(struct file *filp, struct vm_area_struct *vma)if (!idxd->user_submission_safe && !capable (CAP_SYS_RAWIO ))return -EPERM ; +if (current->mm != ctx->mm) +return -EPERM ; + rc =check_vma (wq, vma, __func__);if (rc <0 )return rc;
@@ -478,6 +481,9 @@ static ssize_t idxd_cdev_write(struct file *filp, const char __user *buf, size_tssize_t written =0 ;int i; +if (current->mm != ctx->mm) +return -EPERM ; +for (i =0 ; i < len/sizeof (struct dsa_hw_desc ); i++) {int rc =idxd_submit_user_descriptor (ctx, udesc + i);
@@ -498,6 +504,9 @@ static __poll_t idxd_cdev_poll(struct file *filp,struct idxd_device *idxd = wq->idxd;__poll_t out =0 ; +if (current->mm != ctx->mm) +return -EPERM ; +poll_wait (filp, &wq->err_queue, wait);spin_lock (&idxd->dev_lock);if (idxd->sw_err.valid)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 539/626 x86/sev: Fix operator precedence in GHCB_MSR_VMPL_REQ_LEVEL macro
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seongman Lee <[email protected]>
[ Upstream commit f7387eff4bad33d12719c66c43541c095556ae4e ]
The GHCB_MSR_VMPL_REQ_LEVEL macro lacked parentheses around the bitmask expression, causing the shift operation to bind too early. As a result, when requesting VMPL1 (e.g., GHCB_MSR_VMPL_REQ_LEVEL(1)), incorrect values such as 0x000000016 were generated instead of the intended 0x100000016 (the requested VMPL level is specified in GHCBData[39:32]).
Fix the precedence issue by grouping the masked value before applying the shift.
[ bp: Massage commit message. ]
--- arch/x86/include/asm/sev-common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/include/asm/sev-common.h +1 -1
@@ -116,7 +116,7 @@ enum psc_op {#define GHCB_MSR_VMPL_REQ 0x016 #define GHCB_MSR_VMPL_REQ_LEVEL(v) \ /* GHCBData[39:32] */ \ - (((u64)(v) & GENMASK_ULL(7, 0) << 32) | \ + ((((u64)(v) & GENMASK_ULL(7, 0)) << 32) | \ /* GHCBDdata[11:0] */ \GHCB_MSR_VMPL_REQ )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 540/626 kernel/fork: only call untrack_pfn_clear() on VMAs duplicated for fork()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
[ Upstream commit e9f180d7cfde23b9f8eebd60272465176373ab2c ]
Not intuitive, but vm_area_dup() located in kernel/fork.c is not only used for duplicating VMAs during fork(), but also for duplicating VMAs when splitting VMAs or when mremap()'ing them.
VM_PFNMAP mappings can at least get ordinarily mremap()'ed (no change in size) and apparently also shrunk during mremap(), which implies duplicating the VMA in __split_vma() first.
In case of ordinary mremap() (no change in size), we first duplicate the VMA in copy_vma_and_data()->copy_vma() to then call untrack_pfn_clear() on the old VMA: we effectively move the VM_PAT reservation. So the untrack_pfn_clear() call on the new VMA duplicating is wrong in that context.
Splitting of VMAs seems problematic, because we don't duplicate/adjust the reservation when splitting the VMA. Instead, in memtype_erase() -- called during zapping/munmap -- we shrink a reservation in case only the end address matches: Assume we split a VMA into A and B, both would share a reservation until B is unmapped.
So when unmapping B, the reservation would be updated to cover only A. When unmapping A, we would properly remove the now-shrunk reservation. That scenario describes the mremap() shrinking (old_size > new_size), where we split + unmap B, and the untrack_pfn_clear() on the new VMA when is wrong.
What if we manage to split a VM_PFNMAP VMA into A and B and unmap A first? It would be broken because we would never free the reservation. Likely, there are ways to trigger such a VMA split outside of mremap().
Affecting other VMA duplication was not intended, vm_area_dup() being used outside of kernel/fork.c was an oversight. So let's fix that for; how to handle VMA splits better should be investigated separately.
With a simple reproducer that uses mprotect() to split such a VMA I can trigger
x86/PAT: pat_mremap:26448 freeing invalid memtype [mem 0x00000000-0x00000fff]
--- kernel/fork.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
kernel/fork.c +5 -4
@@ -505,10 +505,6 @@ struct vm_area_struct *vm_area_dup(struct vm_area_struct *orig)vma_numab_state_init (new);dup_anon_vma_name (orig, new); -/* track_pfn_copy() will later take care of copying internal state. */ -if (unlikely (new->vm_flags &VM_PFNMAP )) -untrack_pfn_clear (new); -return new; }
@@ -699,6 +695,11 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm, tmp =vm_area_dup (mpnt);if (!tmp) goto fail_nomem; + +/* track_pfn_copy() will later take care of copying internal state. */ +if (unlikely (tmp->vm_flags &VM_PFNMAP )) +untrack_pfn_clear (tmp); + retval =vma_dup_policy (mpnt, tmp);if (retval) goto fail_nomem_policy;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 541/626 remoteproc: qcom_wcnss: Fix on platforms without fallback regulators
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Lehtimäki <[email protected]>
[ Upstream commit 4ca45af0a56d00b86285d6fdd720dca3215059a7 ]
Recent change to handle platforms with only single power domain broke pronto-v3 which requires power domains and doesn't have fallback voltage regulators in case power domains are missing. Add a check to verify the number of fallback voltage regulators before using the code which handles single power domain situation.
--- drivers/remoteproc/qcom_wcnss.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/remoteproc/qcom_wcnss.c +2 -1
@@ -456,7 +456,8 @@ static int wcnss_init_regulators(struct qcom_wcnss *wcnss,if (wcnss->num_pds) { info += wcnss->num_pds;/* Handle single power domain case */ - num_vregs += num_pd_vregs - wcnss->num_pds; +if (wcnss->num_pds < num_pd_vregs) + num_vregs += num_pd_vregs - wcnss->num_pds; }else { num_vregs += num_pd_vregs; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 542/626 clk: sunxi-ng: d1: Add missing divider for MMC mod clocks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit 98e6da673cc6dd46ca9a599802bd2c8f83606710 ]
The D1/R528/T113 SoCs have a hidden divider of 2 in the MMC mod clocks, just as other recent SoCs. So far we did not describe that, which led to the resulting MMC clock rate to be only half of its intended value.
Use a macro that allows to describe a fixed post-divider, to compensate for that divisor.
This brings the MMC performance on those SoCs to its expected level, so about 23 MB/s for SD cards, instead of the 11 MB/s measured so far.
--- drivers/clk/sunxi-ng/ccu-sun20i-d1.c | 44 ++++++++++++++++------------ drivers/clk/sunxi-ng/ccu_mp.h | 22 ++++++++++++++ 2 files changed, 47 insertions(+), 19 deletions(-)
drivers/clk/sunxi-ng/ccu-sun20i-d1.c +25 -19
@@ -412,19 +412,23 @@ static const struct clk_parent_data mmc0_mmc1_parents[] = { { .hw = &pll_periph0_2x_clk.common.hw }, { .hw = &pll_audio1_div2_clk.common.hw }, }; -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(mmc0_clk, "mmc0", mmc0_mmc1_parents, 0x830, -0 ,4 ,/* M */ -8 ,2 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); - -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(mmc1_clk, "mmc1", mmc0_mmc1_parents, 0x834, -0 ,4 ,/* M */ -8 ,2 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(mmc0_clk, "mmc0", + mmc0_mmc1_parents,0x830 , +0 ,4 ,/* M */ +8 ,2 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ +2 ,/* post-div */ + 0); + +static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(mmc1_clk, "mmc1", + mmc0_mmc1_parents,0x834 , +0 ,4 ,/* M */ +8 ,2 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ +2 ,/* post-div */ + 0);static const struct clk_parent_data mmc2_parents[] = { { .fw_name = "hosc" },
@@ -433,12 +437,14 @@ static const struct clk_parent_data mmc2_parents[] = { { .hw = &pll_periph0_800M_clk.common.hw }, { .hw = &pll_audio1_div2_clk.common.hw }, }; -static SUNXI_CCU_MP_DATA_WITH_MUX_GATE(mmc2_clk, "mmc2", mmc2_parents, 0x838, -0 ,4 ,/* M */ -8 ,2 ,/* P */ -24 ,3 ,/* mux */ -BIT (31 ),/* gate */ - 0); +static SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV(mmc2_clk, "mmc2", mmc2_parents, +0x838 , +0 ,4 ,/* M */ +8 ,2 ,/* P */ +24 ,3 ,/* mux */ +BIT (31 ),/* gate */ +2 ,/* post-div */ + 0); static SUNXI_CCU_GATE_HWS(bus_mmc0_clk, "bus-mmc0", psi_ahb_hws, 0x84c, BIT(0), 0);
drivers/clk/sunxi-ng/ccu_mp.h +22 -0
@@ -52,6 +52,28 @@ struct ccu_mp { } \ } +#define SUNXI_CCU_MP_DATA_WITH_MUX_GATE_POSTDIV (_struct, _name, _parents, \ + _reg, \ + _mshift, _mwidth, \ + _pshift, _pwidth, \ + _muxshift, _muxwidth, \ + _gate, _postdiv, _flags)\ + struct ccu_mp _struct = { \ + .enable = _gate, \ + .m = _SUNXI_CCU_DIV(_mshift, _mwidth), \ + .p = _SUNXI_CCU_DIV(_pshift, _pwidth), \ + .mux = _SUNXI_CCU_MUX(_muxshift, _muxwidth), \ + .fixed_post_div = _postdiv, \ + .common = { \ + .reg = _reg, \ + .features = CCU_FEATURE_FIXED_POSTDIV, \ + .hw.init = CLK_HW_INIT_PARENTS_DATA(_name, \ + _parents, \ + &ccu_mp_ops, \ + _flags), \ + } \ + } + #define SUNXI_CCU_MP_WITH_MUX_GATE(_struct, _name, _parents, _reg, \ _mshift, _mwidth, \ _pshift, _pwidth, \
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 543/626 xfrm: Sanitize marks before insert
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Chaignon <[email protected]>
[ Upstream commit 0b91fda3a1f044141e1e615456ff62508c32b202 ]
Prior to this patch, the mark is sanitized (applying the state's mask to the state's value) only on inserts when checking if a conflicting XFRM state or policy exists.
We discovered in Cilium that this same sanitization does not occur in the hot-path __xfrm_state_lookup. In the hot-path, the sk_buff's mark is simply compared to the state's value:
if ((mark & x->mark.m) != x->mark.v)
continue;Therefore, users can define unsanitized marks (ex. 0xf42/0xf00) which will never match any packet.
This commit updates __xfrm_state_insert and xfrm_policy_insert to store the sanitized marks, thus removing this footgun.
This has the side effect of changing the ip output, as the returned mark will have the mask applied to it when printed.
--- net/xfrm/xfrm_policy.c | 3 +++ net/xfrm/xfrm_state.c | 3 +++ 2 files changed, 6 insertions(+)
net/xfrm/xfrm_policy.c +3 -0
@@ -1581,6 +1581,9 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)struct xfrm_policy *delpol;struct hlist_head *chain; +/* Sanitize mark before store */ + policy->mark.v &= policy->mark.m; +spin_lock_bh (&net->xfrm.xfrm_policy_lock); chain =policy_hash_bysel (net, &policy->selector, policy->family, dir);if (chain)
net/xfrm/xfrm_state.c +3 -0
@@ -1653,6 +1653,9 @@ static void __xfrm_state_insert(struct xfrm_state *x)list_add (&x->km.all, &net->xfrm.state_all); +/* Sanitize mark before store */ + x->mark.v &= x->mark.m; + h =xfrm_dst_hash (net, &x->id.daddr, &x->props.saddr, x->props.reqid, x->props.family); XFRM_STATE_INSERT(bydst, &x->bydst, net->xfrm.state_bydst + h,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 544/626 dmaengine: idxd: Fix ->poll() return value
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit ae74cd15ade833adc289279b5c6f12e78f64d4d7 ]
The fix to block access from different address space did not return a correct value for ->poll() change. kernel test bot reported that a return value of type __poll_t is expected rather than int. Fix to return POLLNVAL to indicate invalid request.
--- drivers/dma/idxd/cdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/idxd/cdev.c +1 -1
@@ -505,7 +505,7 @@ static __poll_t idxd_cdev_poll(struct file *filp,__poll_t out =0 ;if (current->mm != ctx->mm) -return -EPERM ; +return POLLNVAL ;poll_wait (filp, &wq->err_queue, wait);spin_lock (&idxd->dev_lock);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 545/626 dmaengine: fsl-edma: Fix return code for unhandled interrupts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Wahren <[email protected]>
[ Upstream commit 5e27af0514e2249a9ccc9a762abd3b74e03a1f90 ]
For fsl,imx93-edma4 two DMA channels share the same interrupt. So in case fsl_edma3_tx_handler is called for the "wrong" channel, the return code must be IRQ_NONE. This signalize that the interrupt wasn't handled.
--- drivers/dma/fsl-edma-main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/fsl-edma-main.c +1 -1
@@ -56,7 +56,7 @@ static irqreturn_t fsl_edma3_tx_handler(int irq, void *dev_id) intr =edma_readl_chreg (fsl_chan, ch_int);if (!intr) -return IRQ_HANDLED ; +return IRQ_NONE ;edma_writel_chreg (fsl_chan,1 , ch_int);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 546/626 driver core: Split devres APIs to device/devres.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit a21cad9312767d26b5257ce0662699bb202cdda1 ]
device.h is a huge header which is hard to follow and easy to miss something. Improve that by splitting devres APIs to device/devres.h.
In particular this helps to speedup the build of the code that includes device.h solely for a devres APIs.
While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR() and fix sparse warnings.
Stable-dep-of: 7dd7f39fce00 ("ASoC: SOF: Intel: hda: Fix UAF when reloading module")
--- include/linux/device.h | 119 +------------------------------- include/linux/device/devres.h | 124 ++++++++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+), 118 deletions(-) create mode 100644 include/linux/device/devres.h
include/linux/device.h +1 -118
@@ -26,9 +26,9 @@#include <linux/atomic.h> #include <linux/uidgid.h> #include <linux/gfp.h> -#include <linux/overflow.h> #include <linux/device/bus.h> #include <linux/device/class.h> +#include <linux/device/devres.h> #include <linux/device/driver.h> #include <linux/cleanup.h> #include <asm/device.h>
@@ -281,123 +281,6 @@ int __must_check device_create_bin_file(struct device *dev,void device_remove_bin_file (struct device *dev,const struct bin_attribute *attr); -/* device resource management */ -typedef void (*dr_release_t )(struct device *dev,void *res); -typedef int (*dr_match_t )(struct device *dev,void *res,void *match_data); - -void *__devres_alloc_node (dr_release_t release,size_t size,gfp_t gfp, -int nid,const char *name) __malloc; -#define devres_alloc (release, size, gfp) \ - __devres_alloc_node(release, size, gfp, NUMA_NO_NODE, #release) -#define devres_alloc_node (release, size, gfp, nid) \ - __devres_alloc_node(release, size, gfp, nid, #release) - -void devres_for_each_res (struct device *dev,dr_release_t release, -dr_match_t match,void *match_data, -void (*fn)(struct device *,void *,void *), -void *data); -void devres_free (void *res); -void devres_add (struct device *dev,void *res); -void *devres_find (struct device *dev,dr_release_t release, -dr_match_t match,void *match_data); -void *devres_get (struct device *dev,void *new_res, -dr_match_t match,void *match_data); -void *devres_remove (struct device *dev,dr_release_t release, -dr_match_t match,void *match_data); -int devres_destroy (struct device *dev,dr_release_t release, -dr_match_t match,void *match_data); -int devres_release (struct device *dev,dr_release_t release, -dr_match_t match,void *match_data); - -/* devres group */ -void *__must_check devres_open_group (struct device *dev,void *id,gfp_t gfp); -void devres_close_group (struct device *dev,void *id); -void devres_remove_group (struct device *dev,void *id); -int devres_release_group (struct device *dev,void *id); - -/* managed devm_k.alloc/kfree for device drivers */ -void *devm_kmalloc (struct device *dev,size_t size,gfp_t gfp)__alloc_size(2) ; -void *devm_krealloc (struct device *dev,void *ptr,size_t size, -gfp_t gfp)__must_check __realloc_size (3 ); -__printf(3, 0) char *devm_kvasprintf(struct device *dev, gfp_t gfp, -const char *fmt,va_list ap) __malloc; -__printf(3, 4) char *devm_kasprintf(struct device *dev, gfp_t gfp, -const char *fmt, ...) __malloc; -static inline void *devm_kzalloc (struct device *dev,size_t size,gfp_t gfp) -{ -return devm_kmalloc (dev, size, gfp | __GFP_ZERO); -} -static inline void *devm_kmalloc_array (struct device *dev, -size_t n,size_t size,gfp_t flags) -{ -size_t bytes; - -if (unlikely (check_mul_overflow (n, size, &bytes))) -return NULL ; - -return devm_kmalloc (dev, bytes, flags); -} -static inline void *devm_kcalloc (struct device *dev, -size_t n,size_t size,gfp_t flags) -{ -return devm_kmalloc_array (dev, n, size, flags | __GFP_ZERO); -} -static inline __realloc_size(3, 4) void * __must_check -devm_krealloc_array(struct device *dev, void *p, size_t new_n, size_t new_size, gfp_t flags) -{ - size_t bytes; - -if (unlikely (check_mul_overflow (new_n, new_size, &bytes))) -return NULL ; - -return devm_krealloc (dev, p, bytes, flags); -} - -void devm_kfree (struct device *dev,const void *p); -char *devm_kstrdup (struct device *dev,const char *s,gfp_t gfp) __malloc; -const char *devm_kstrdup_const (struct device *dev,const char *s,gfp_t gfp); -void *devm_kmemdup (struct device *dev,const void *src,size_t len,gfp_t gfp) -__realloc_size (3 ); - -unsigned long devm_get_free_pages (struct device *dev, -gfp_t gfp_mask,unsigned int order); -void devm_free_pages (struct device *dev,unsigned long addr); - -#ifdef CONFIG_HAS_IOMEM -void __iomem *devm_ioremap_resource (struct device *dev, -const struct resource *res); -void __iomem *devm_ioremap_resource_wc (struct device *dev, -const struct resource *res); - -void __iomem *devm_of_iomap (struct device *dev, -struct device_node *node,int index, -resource_size_t *size); -#else - -static inline -void __iomem *devm_ioremap_resource (struct device *dev, -const struct resource *res) -{ -return ERR_PTR (-EINVAL ); -} - -static inline -void __iomem *devm_ioremap_resource_wc (struct device *dev, -const struct resource *res) -{ -return ERR_PTR (-EINVAL ); -} - -static inline -void __iomem *devm_of_iomap (struct device *dev, -struct device_node *node,int index, -resource_size_t *size) -{ -return ERR_PTR (-EINVAL ); -} - -#endif -/* allows to add/remove a custom action to devres stack */ void devm_remove_action (struct device *dev,void (*action)(void *),void *data);void devm_release_action (struct device *dev,void (*action)(void *),void *data);
include/linux/device/devres.h new file +124 -0
124 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 547/626 devres: Introduce devm_kmemdup_array()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raag Jadav <[email protected]>
[ Upstream commit a103b833ac3806b816bc993cba77d0b17cf801f1 ]
Introduce '_array' variant of devm_kmemdup() which is more robust and consistent with alloc family of helpers.
Stable-dep-of: 7dd7f39fce00 ("ASoC: SOF: Intel: hda: Fix UAF when reloading module")
--- include/linux/device/devres.h | 5 +++++ 1 file changed, 5 insertions(+)
include/linux/device/devres.h +5 -0
@@ -79,6 +79,11 @@ void devm_kfree(struct device *dev, const void *p); void * __realloc_size(3) devm_kmemdup(struct device *dev, const void *src, size_t len, gfp_t gfp); +static inline void *devm_kmemdup_array (struct device *dev,const void *src, +size_t n,size_t size,gfp_t flags) +{ +return devm_kmemdup (dev, src,size_mul (size, n), flags); +} char * __mallocdevm_kstrdup (struct device *dev,const char *s,gfp_t gfp);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 548/626 ASoC: SOF: Intel: hda: Fix UAF when reloading module
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tavian Barnes <[email protected]>
[ Upstream commit 7dd7f39fce0022b386ef1ea5ffef92ecc7dfc6af ]
hda_generic_machine_select() appends -idisp to the tplg filename by allocating a new string with devm_kasprintf(), then stores the string right back into the global variable snd_soc_acpi_intel_hda_machines. When the module is unloaded, this memory is freed, resulting in a global variable pointing to freed memory. Reloading the module then triggers a use-after-free:
BUG: KFENCE: use-after-free read in string+0x48/0xe0
Use-after-free read at 0x00000000967e0109 (in kfence-#99):
string+0x48/0xe0 vsnprintf+0x329/0x6e0 devm_kvasprintf+0x54/0xb0 devm_kasprintf+0x58/0x80 hda_machine_select.cold+0x198/0x17a2 [snd_sof_intel_hda_generic] sof_probe_work+0x7f/0x600 [snd_sof] process_one_work+0x17b/0x330 worker_thread+0x2ce/0x3f0 kthread+0xcf/0x100 ret_from_fork+0x31/0x50 ret_from_fork_asm+0x1a/0x30
kfence-#99: 0x00000000198a940f-0x00000000ace47d9d, size=64, cache=kmalloc-64
allocated by task 333 on cpu 8 at 17.798069s (130.453553s ago):
devm_kmalloc+0x52/0x120 devm_kvasprintf+0x66/0xb0 devm_kasprintf+0x58/0x80 hda_machine_select.cold+0x198/0x17a2 [snd_sof_intel_hda_generic] sof_probe_work+0x7f/0x600 [snd_sof] process_one_work+0x17b/0x330 worker_thread+0x2ce/0x3f0 kthread+0xcf/0x100 ret_from_fork+0x31/0x50 ret_from_fork_asm+0x1a/0x30
freed by task 1543 on cpu 4 at 141.586686s (6.665010s ago):
release_nodes+0x43/0xb0 devres_release_all+0x90/0xf0 device_unbind_cleanup+0xe/0x70 device_release_driver_internal+0x1c1/0x200 driver_detach+0x48/0x90 bus_remove_driver+0x6d/0xf0 pci_unregister_driver+0x42/0xb0 __do_sys_delete_module+0x1d1/0x310 do_syscall_64+0x82/0x190 entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fix it by copying the match array with devm_kmemdup_array() before we modify it.
--- sound/soc/sof/intel/hda.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
sound/soc/sof/intel/hda.c +15 -1
@@ -1007,7 +1007,21 @@ static void hda_generic_machine_select(struct snd_sof_dev *sdev,if (!*mach && codec_num <=2 ) {bool tplg_fixup = false; - hda_mach = snd_soc_acpi_intel_hda_machines; +/* +* make a local copy of the match array since we might +* be modifying it +*/ + hda_mach =devm_kmemdup_array (sdev->dev, + snd_soc_acpi_intel_hda_machines, +2 ,/* we have one entry + sentinel in the array */ +sizeof (snd_soc_acpi_intel_hda_machines[0 ]), +GFP_KERNEL ); +if (!hda_mach) { +dev_err (bus->dev, +"%s: failed to duplicate the HDA match table\n" , + __func__); +return ; + }dev_info (bus->dev,"using HDA machine driver %s now\n" , hda_mach->drv_name);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 549/626 irqchip/riscv-imsic: Start local sync timer on correct CPU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrew Bresticker <[email protected]>
[ Upstream commit 08fb624802d8786253994d8ebdbbcdaa186f04f5 ]
When starting the local sync timer to synchronize the state of a remote CPU it should be added on the CPU to be synchronized, not the initiating CPU. This results in interrupt delivery being delayed until the timer eventually runs (due to another mask/unmask/migrate operation) on the target CPU.
--- drivers/irqchip/irq-riscv-imsic-state.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/irqchip/irq-riscv-imsic-state.c +5 -5
@@ -186,17 +186,17 @@ static bool __imsic_local_sync(struct imsic_local_priv *lpriv) }#ifdef CONFIG_SMP -static void __imsic_local_timer_start (struct imsic_local_priv *lpriv) +static void __imsic_local_timer_start (struct imsic_local_priv *lpriv,unsigned int cpu) {lockdep_assert_held (&lpriv->lock);if (!timer_pending (&lpriv->timer)) { lpriv->timer.expires = jiffies +1 ; -add_timer_on (&lpriv->timer,smp_processor_id ()); +add_timer_on (&lpriv->timer, cpu); } }#else -static inline void __imsic_local_timer_start (struct imsic_local_priv *lpriv) +static inline void __imsic_local_timer_start (struct imsic_local_priv *lpriv,unsigned int cpu) { }#endif
@@ -211,7 +211,7 @@ void imsic_local_sync_all(bool force_all)if (force_all)bitmap_fill (lpriv->dirty_bitmap, imsic->global.nr_ids +1 );if (!__imsic_local_sync (lpriv)) -__imsic_local_timer_start (lpriv); +__imsic_local_timer_start (lpriv,smp_processor_id ());raw_spin_unlock_irqrestore (&lpriv->lock, flags); }
@@ -256,7 +256,7 @@ static void __imsic_remote_sync(struct imsic_local_priv *lpriv, unsigned int cpu return; } -__imsic_local_timer_start (lpriv); +__imsic_local_timer_start (lpriv, cpu); } }#else
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 550/626 perf/x86/intel: Fix segfault with PEBS-via-PT with sample_freq
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrian Hunter <[email protected]>
[ Upstream commit 99bcd91fabada0dbb1d5f0de44532d8008db93c6 ]
Currently, using PEBS-via-PT with a sample frequency instead of a sample period, causes a segfault. For example:
BUG: kernel NULL pointer dereference, address: 0000000000000195
<NMI>
? __die_body.cold+0x19/0x27
? page_fault_oops+0xca/0x290
? exc_page_fault+0x7e/0x1b0
? asm_exc_page_fault+0x26/0x30
? intel_pmu_pebs_event_update_no_drain+0x40/0x60
? intel_pmu_pebs_event_update_no_drain+0x32/0x60
intel_pmu_drain_pebs_icl+0x333/0x350
handle_pmi_common+0x272/0x3c0
intel_pmu_handle_irq+0x10a/0x2e0
perf_event_nmi_handler+0x2a/0x50That happens because intel_pmu_pebs_event_update_no_drain() assumes all the pebs_enabled bits represent counter indexes, which is not always the case. In this particular case, bits 60 and 61 are set for PEBS-via-PT purposes.
The behaviour of PEBS-via-PT with sample frequency is questionable because although a PMI is generated (PEBS_PMI_AFTER_EACH_RECORD), the period is not adjusted anyway.
Putting that aside, fix intel_pmu_pebs_event_update_no_drain() by passing the mask of counter bits instead of 'size'. Note, prior to the Fixes commit, 'size' would be limited to the maximum counter index, so the issue was not hit.
--- arch/x86/events/intel/ds.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
arch/x86/events/intel/ds.c +5 -4
@@ -2240,8 +2240,9 @@ static void intel_pmu_drain_pebs_core(struct pt_regs *iregs, struct perf_sample_ setup_pebs_fixed_sample_data); } -static void intel_pmu_pebs_event_update_no_drain (struct cpu_hw_events *cpuc,int size) +static void intel_pmu_pebs_event_update_no_drain (struct cpu_hw_events *cpuc,u64 mask) { +u64 pebs_enabled = cpuc->pebs_enabled & mask;struct perf_event *event;int bit;
@@ -2252,7 +2253,7 @@ static void intel_pmu_pebs_event_update_no_drain(struct cpu_hw_events *cpuc, int* It needs to call intel_pmu_save_and_restart_reload() to * update the event->count for this case. */ -for_each_set_bit (bit, (unsigned long *)&cpuc->pebs_enabled, size) { +for_each_set_bit (bit, (unsigned long *)&pebs_enabled,X86_PMC_IDX_MAX ) { event = cpuc->events[bit];if (event->hw.flags &PERF_X86_EVENT_AUTO_RELOAD )intel_pmu_save_and_restart_reload (event,0 );
@@ -2287,7 +2288,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d }if (unlikely (base >= top)) { -intel_pmu_pebs_event_update_no_drain (cpuc, size); +intel_pmu_pebs_event_update_no_drain (cpuc, mask);return ; }
@@ -2397,7 +2398,7 @@ static void intel_pmu_drain_pebs_icl(struct pt_regs *iregs, struct perf_sample_d (hybrid (cpuc->pmu, fixed_cntr_mask64) <<INTEL_PMC_IDX_FIXED );if (unlikely (base >= top)) { -intel_pmu_pebs_event_update_no_drain (cpuc,X86_PMC_IDX_MAX ); +intel_pmu_pebs_event_update_no_drain (cpuc, mask);return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 551/626 Bluetooth: L2CAP: Fix not checking l2cap_chan security level
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 7af8479d9eb4319b4ba7b47a8c4d2c55af1c31e1 ]
l2cap_check_enc_key_size shall check the security level of the l2cap_chan rather than the hci_conn since for incoming connection request that may be different as hci_conn may already been encrypted using a different security level.
--- net/bluetooth/l2cap_core.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-)
net/bluetooth/l2cap_core.c +8 -7
@@ -1411,7 +1411,8 @@ static void l2cap_request_info(struct l2cap_conn *conn) sizeof(req), &req); } -static bool l2cap_check_enc_key_size (struct hci_conn *hcon) +static bool l2cap_check_enc_key_size (struct hci_conn *hcon, +struct l2cap_chan *chan) {/* The minimum encryption key size needs to be enforced by the * host stack before establishing any L2CAP connections. The
@@ -1425,7 +1426,7 @@ static bool l2cap_check_enc_key_size(struct hci_conn *hcon)int min_key_size = hcon->hdev->min_enc_key_size;/* On FIPS security level, key size must be 16 bytes */ -if (hcon->sec_level ==BT_SECURITY_FIPS ) +if (chan->sec_level ==BT_SECURITY_FIPS ) min_key_size =16 ; return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) ||
@@ -1453,7 +1454,7 @@ static void l2cap_do_start(struct l2cap_chan *chan) !__l2cap_no_conn_pending(chan))return ; -if (l2cap_check_enc_key_size (conn->hcon)) +if (l2cap_check_enc_key_size (conn->hcon, chan))l2cap_start_connection (chan);else __set_chan_timer (chan,L2CAP_DISC_TIMEOUT );
@@ -1528,7 +1529,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)continue ; } -if (l2cap_check_enc_key_size (conn->hcon)) +if (l2cap_check_enc_key_size (conn->hcon, chan))l2cap_start_connection (chan);else l2cap_chan_close (chan,ECONNREFUSED );
@@ -3957,7 +3958,7 @@ static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,/* Check if the ACL is secure enough (if not SDP) */ if (psm !=cpu_to_le16 (L2CAP_PSM_SDP ) && (!hci_conn_check_link_mode (conn->hcon) || - !l2cap_check_enc_key_size (conn->hcon))) { + !l2cap_check_enc_key_size (conn->hcon, pchan))) { conn->disc_reason =HCI_ERROR_AUTH_FAILURE ; result =L2CAP_CR_SEC_BLOCK ; goto response;
@@ -7317,7 +7318,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) }if (chan->state ==BT_CONNECT ) { -if (!status &&l2cap_check_enc_key_size (hcon)) +if (!status &&l2cap_check_enc_key_size (hcon, chan))l2cap_start_connection (chan);else __set_chan_timer (chan,L2CAP_DISC_TIMEOUT );
@@ -7327,7 +7328,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)struct l2cap_conn_rsp rsp;__u16 res, stat; -if (!status &&l2cap_check_enc_key_size (hcon)) { +if (!status &&l2cap_check_enc_key_size (hcon, chan)) {if (test_bit (FLAG_DEFER_SETUP , &chan->flags)) { res =L2CAP_CR_PEND ; stat =L2CAP_CS_AUTHOR_PEND ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 552/626 Bluetooth: btusb: use skb_pull to avoid unsafe access in QCA dump handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: En-Wei Wu <[email protected]>
[ Upstream commit 4bcb0c7dc25446b99fc7a8fa2a143d69f3314162 ]
Use skb_pull() and skb_pull_data() to safely parse QCA dump packets.
This avoids direct pointer math on skb->data, which could lead to invalid access if the packet is shorter than expected.
--- drivers/bluetooth/btusb.c | 98 ++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 58 deletions(-)
drivers/bluetooth/btusb.c +40 -58
@@ -2979,9 +2979,8 @@ static void btusb_coredump_qca(struct hci_dev *hdev)static int handle_dump_pkt_qca (struct hci_dev *hdev,struct sk_buff *skb) {int ret =0 ; +unsigned int skip =0 ;u8 pkt_type; -u8 *sk_ptr; -unsigned int sk_len;u16 seqno;u32 dump_size;
@@ -2990,18 +2989,13 @@ static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)struct usb_device *udev = btdata->udev; pkt_type =hci_skb_pkt_type (skb); - sk_ptr = skb->data; - sk_len = skb->len; + skip =sizeof (struct hci_event_hdr ); +if (pkt_type ==HCI_ACLDATA_PKT ) + skip +=sizeof (struct hci_acl_hdr ); -if (pkt_type ==HCI_ACLDATA_PKT ) { - sk_ptr +=HCI_ACL_HDR_SIZE ; - sk_len -=HCI_ACL_HDR_SIZE ; - } - - sk_ptr +=HCI_EVENT_HDR_SIZE ; - sk_len -=HCI_EVENT_HDR_SIZE ; +skb_pull (skb, skip); + dump_hdr = (struct qca_dump_hdr *)skb->data; - dump_hdr = (struct qca_dump_hdr *)sk_ptr; seqno =le16_to_cpu (dump_hdr->seqno);if (seqno ==0 ) {set_bit (BTUSB_HW_SSR_ACTIVE , &btdata->flags);
@@ -3021,16 +3015,15 @@ static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb) btdata->qca_dump.ram_dump_size = dump_size; btdata->qca_dump.ram_dump_seqno =0 ; - sk_ptr += offsetof(struct qca_dump_hdr , data0); - sk_len -= offsetof(struct qca_dump_hdr , data0); + +skb_pull (skb, offsetof(struct qca_dump_hdr , data0));usb_disable_autosuspend (udev);bt_dev_info (hdev,"%s memdump size(%u)\n" , (pkt_type ==HCI_ACLDATA_PKT ) ?"ACL" :"event" , dump_size); }else { - sk_ptr += offsetof(struct qca_dump_hdr , data); - sk_len -= offsetof(struct qca_dump_hdr , data); +skb_pull (skb, offsetof(struct qca_dump_hdr , data)); }if (!btdata->qca_dump.ram_dump_size) {
@@ -3050,7 +3043,6 @@ static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)return ret; } -skb_pull (skb, skb->len - sk_len);hci_devcd_append (hdev, skb); btdata->qca_dump.ram_dump_seqno++;if (seqno ==QCA_LAST_SEQUENCE_NUM ) {
@@ -3078,68 +3070,58 @@ static int handle_dump_pkt_qca(struct hci_dev *hdev, struct sk_buff *skb)/* Return: true if the ACL packet is a dump packet, false otherwise. */ static bool acl_pkt_is_dump_qca (struct hci_dev *hdev,struct sk_buff *skb) { -u8 *sk_ptr; -unsigned int sk_len; -struct hci_event_hdr *event_hdr;struct hci_acl_hdr *acl_hdr;struct qca_dump_hdr *dump_hdr; +struct sk_buff *clone =skb_clone (skb,GFP_ATOMIC ); +bool is_dump = false; - sk_ptr = skb->data; - sk_len = skb->len; - - acl_hdr =hci_acl_hdr (skb); -if (le16_to_cpu (acl_hdr->handle) !=QCA_MEMDUMP_ACL_HANDLE ) +if (!clone)return false; - sk_ptr +=HCI_ACL_HDR_SIZE ; - sk_len -=HCI_ACL_HDR_SIZE ; - event_hdr = (struct hci_event_hdr *)sk_ptr; - -if ((event_hdr->evt !=HCI_VENDOR_PKT ) || - (event_hdr->plen != (sk_len -HCI_EVENT_HDR_SIZE ))) -return false; + acl_hdr =skb_pull_data (clone,sizeof (*acl_hdr)); +if (!acl_hdr || (le16_to_cpu (acl_hdr->handle) !=QCA_MEMDUMP_ACL_HANDLE )) + goto out; - sk_ptr +=HCI_EVENT_HDR_SIZE ; - sk_len -=HCI_EVENT_HDR_SIZE ; + event_hdr =skb_pull_data (clone,sizeof (*event_hdr)); +if (!event_hdr || (event_hdr->evt !=HCI_VENDOR_PKT )) + goto out; - dump_hdr = (struct qca_dump_hdr *)sk_ptr; -if ((sk_len < offsetof(struct qca_dump_hdr , data)) || - (dump_hdr->vse_class !=QCA_MEMDUMP_VSE_CLASS ) || - (dump_hdr->msg_type !=QCA_MEMDUMP_MSG_TYPE )) -return false; + dump_hdr =skb_pull_data (clone,sizeof (*dump_hdr)); +if (!dump_hdr || (dump_hdr->vse_class !=QCA_MEMDUMP_VSE_CLASS ) || + (dump_hdr->msg_type !=QCA_MEMDUMP_MSG_TYPE )) + goto out; -return true; + is_dump = true; +out: +consume_skb (clone); +return is_dump; }/* Return: true if the event packet is a dump packet, false otherwise. */ static bool evt_pkt_is_dump_qca (struct hci_dev *hdev,struct sk_buff *skb) { -u8 *sk_ptr; -unsigned int sk_len; -struct hci_event_hdr *event_hdr;struct qca_dump_hdr *dump_hdr; +struct sk_buff *clone =skb_clone (skb,GFP_ATOMIC ); +bool is_dump = false; - sk_ptr = skb->data; - sk_len = skb->len; - - event_hdr =hci_event_hdr (skb); - -if ((event_hdr->evt !=HCI_VENDOR_PKT ) - || (event_hdr->plen != (sk_len -HCI_EVENT_HDR_SIZE ))) +if (!clone)return false; - sk_ptr +=HCI_EVENT_HDR_SIZE ; - sk_len -=HCI_EVENT_HDR_SIZE ; + event_hdr =skb_pull_data (clone,sizeof (*event_hdr)); +if (!event_hdr || (event_hdr->evt !=HCI_VENDOR_PKT )) + goto out; - dump_hdr = (struct qca_dump_hdr *)sk_ptr; -if ((sk_len < offsetof(struct qca_dump_hdr , data)) || - (dump_hdr->vse_class !=QCA_MEMDUMP_VSE_CLASS ) || - (dump_hdr->msg_type !=QCA_MEMDUMP_MSG_TYPE )) -return false; + dump_hdr =skb_pull_data (clone,sizeof (*dump_hdr)); +if (!dump_hdr || (dump_hdr->vse_class !=QCA_MEMDUMP_VSE_CLASS ) || + (dump_hdr->msg_type !=QCA_MEMDUMP_MSG_TYPE )) + goto out; -return true; + is_dump = true; +out: +consume_skb (clone); +return is_dump; }static int btusb_recv_acl_qca (struct hci_dev *hdev,struct sk_buff *skb)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 553/626 ptp: ocp: Limit signal/freq counts in summary output functions
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Maimon <[email protected]>
[ Upstream commit c9e455581e2ba87ee38c126e8dc49a424b9df0cf ]
The debugfs summary output could access uninitialized elements in the freq_in[] and signal_out[] arrays, causing NULL pointer dereferences and triggering a kernel Oops (page_fault_oops). This patch adds u8 fields (nr_freq_in, nr_signal_out) to track the number of initialized elements, with a maximum of 4 per array. The summary output functions are updated to respect these limits, preventing out-of-bounds access and ensuring safe array handling.
Widen the label variables because the change confuses GCC about max length of the strings.
--- drivers/ptp/ptp_ocp.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-)
drivers/ptp/ptp_ocp.c +17 -7
@@ -315,6 +315,8 @@ struct ptp_ocp_serial_port {#define OCP_BOARD_ID_LEN 13#define OCP_SERIAL_LEN 6#define OCP_SMA_NUM 4 +#define OCP_SIGNAL_NUM 4 +#define OCP_FREQ_NUM 4enum {PORT_GNSS ,
@@ -342,8 +344,8 @@ struct ptp_ocp {struct dcf_master_reg __iomem *dcf_out;struct dcf_slave_reg __iomem *dcf_in;struct tod_reg __iomem *nmea_out; -struct frequency_reg __iomem *freq_in[4 ]; -struct ptp_ocp_ext_src *signal_out[4 ]; +struct frequency_reg __iomem *freq_in[OCP_FREQ_NUM ]; +struct ptp_ocp_ext_src *signal_out[OCP_SIGNAL_NUM ];struct ptp_ocp_ext_src *pps;struct ptp_ocp_ext_src *ts0;struct ptp_ocp_ext_src *ts1;
@@ -378,10 +380,12 @@ struct ptp_ocp {u32 utc_tai_offset;u32 ts_window_adjust;u64 fw_cap; -struct ptp_ocp_signal signal[4 ]; +struct ptp_ocp_signal signal[OCP_SIGNAL_NUM ];struct ptp_ocp_sma_connector sma[OCP_SMA_NUM ];const struct ocp_sma_op *sma_op;struct dpll_device *dpll; +int signals_nr; +int freq_in_nr; };#define OCP_REQ_TIMESTAMP BIT(0)
@@ -2693,6 +2697,8 @@ ptp_ocp_fb_board_init(struct ptp_ocp *bp, struct ocp_resource *r) bp->eeprom_map = fb_eeprom_map; bp->fw_version =ioread32 (&bp->image->version); bp->sma_op = &ocp_fb_sma_op; + bp->signals_nr =4 ; + bp->freq_in_nr =4 ;ptp_ocp_fb_set_version (bp);
@@ -2858,6 +2864,8 @@ ptp_ocp_art_board_init(struct ptp_ocp *bp, struct ocp_resource *r) bp->fw_version =ioread32 (&bp->reg->version); bp->fw_tag =2 ; bp->sma_op = &ocp_art_sma_op; + bp->signals_nr =4 ; + bp->freq_in_nr =4 ;/* Enable MAC serial port during initialisation */ iowrite32 (1 , &bp->board_config->mro50_serial_activate);
@@ -2884,6 +2892,8 @@ ptp_ocp_adva_board_init(struct ptp_ocp *bp, struct ocp_resource *r) bp->flash_start =0xA00000 ; bp->eeprom_map = fb_eeprom_map; bp->sma_op = &ocp_adva_sma_op; + bp->signals_nr =2 ; + bp->freq_in_nr =2 ; version =ioread32 (&bp->image->version);/* if lower 16 bits are empty, this is the fw loader. */
@@ -4004,7 +4014,7 @@ _signal_summary_show(struct seq_file *s, struct ptp_ocp *bp, int nr) {struct signal_reg __iomem *reg = bp->signal_out[nr]->mem;struct ptp_ocp_signal *signal = &bp->signal[nr]; -char label[8 ]; +char label[16 ];bool on;u32 val;
@@ -4030,7 +4040,7 @@ static void _frequency_summary_show(struct seq_file *s, int nr, struct frequency_reg __iomem *reg) { - char label[8]; + char label[16];bool on;u32 val;
@@ -4174,11 +4184,11 @@ ptp_ocp_summary_show(struct seq_file *s, void *data) }if (bp->fw_cap &OCP_CAP_SIGNAL ) -for (i =0 ; i <4 ; i++) +for (i =0 ; i < bp->signals_nr; i++)_signal_summary_show (s, bp, i);if (bp->fw_cap &OCP_CAP_FREQ ) -for (i =0 ; i <4 ; i++) +for (i =0 ; i < bp->freq_in_nr; i++)_frequency_summary_show (s, i, bp->freq_in[i]);if (bp->irig_out) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 554/626 bridge: netfilter: Fix forwarding of fragmented packets
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit 91b6dbced0ef1d680afdd69b14fc83d50ebafaf3 ]
When netfilter defrag hooks are loaded (due to the presence of conntrack rules, for example), fragmented packets entering the bridge will be defragged by the bridge's pre-routing hook (br_nf_pre_routing() -> ipv4_conntrack_defrag()).
Later on, in the bridge's post-routing hook, the defragged packet will be fragmented again. If the size of the largest fragment is larger than what the kernel has determined as the destination MTU (using ip_skb_dst_mtu()), the defragged packet will be dropped.
Before commit ac6627a28dbf ("net: ipv4: Consolidate ipv4_mtu and ip_dst_mtu_maybe_forward"), ip_skb_dst_mtu() would return dst_mtu() as the destination MTU. Assuming the dst entry attached to the packet is the bridge's fake rtable one, this would simply be the bridge's MTU (see fake_mtu()).
However, after above mentioned commit, ip_skb_dst_mtu() ends up returning the route's MTU stored in the dst entry's metrics. Ideally, in case the dst entry is the bridge's fake rtable one, this should be the bridge's MTU as the bridge takes care of updating this metric when its MTU changes (see br_change_mtu()).
Unfortunately, the last operation is a no-op given the metrics attached to the fake rtable entry are marked as read-only. Therefore, ip_skb_dst_mtu() ends up returning 1500 (the initial MTU value) and defragged packets are dropped during fragmentation when dealing with large fragments and high MTU (e.g., 9k).
Fix by moving the fake rtable entry's metrics to be per-bridge (in a similar fashion to the fake rtable entry itself) and marking them as writable, thereby allowing MTU changes to be reflected.
--- net/bridge/br_nf_core.c | 7 ++----- net/bridge/br_private.h | 1 + 2 files changed, 3 insertions(+), 5 deletions(-)
net/bridge/br_nf_core.c +2 -5
@@ -65,17 +65,14 @@ static struct dst_ops fake_dst_ops = {* ipt_REJECT needs it. Future netfilter modules might * require us to fill additional fields. */ -static const u32 br_dst_default_metrics[RTAX_MAX ] = { - [RTAX_MTU -1 ] =1500 , -}; -void br_netfilter_rtable_init (struct net_bridge *br) {struct rtable *rt = &br->fake_rtable;rcuref_init (&rt->dst.__rcuref,1 ); rt->dst.dev = br->dev; -dst_init_metrics (&rt->dst, br_dst_default_metrics, true); +dst_init_metrics (&rt->dst, br->metrics, false); +dst_metric_set (&rt->dst,RTAX_MTU , br->dev->mtu); rt->dst.flags =DST_NOXFRM |DST_FAKE_RTABLE ; rt->dst.ops = &fake_dst_ops; }
net/bridge/br_private.h +1 -0
@@ -505,6 +505,7 @@ struct net_bridge {struct rtable fake_rtable; struct rt6_info fake_rt6_info; }; +u32 metrics[RTAX_MAX ];#endif u16 group_fwd_mask;u16 group_fwd_mask_required;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 555/626 ice: fix vf->num_mac count with port representors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jacob Keller <[email protected]>
[ Upstream commit bbd95160a03dbfcd01a541f25c27ddb730dfbbd5 ]
The ice_vc_repr_add_mac() function indicates that it does not store the MAC address filters in the firmware. However, it still increments vf->num_mac. This is incorrect, as vf->num_mac should represent the number of MAC filters currently programmed to firmware.
Indeed, we only perform this increment if the requested filter is a unicast address that doesn't match the existing vf->hw_lan_addr. In addition, ice_vc_repr_del_mac() does not decrement the vf->num_mac counter. This results in the counter becoming out of sync with the actual count.
As it turns out, vf->num_mac is currently only used in legacy made without port representors. The single place where the value is checked is for enforcing a filter limit on untrusted VFs.
Upcoming patches to support VF Live Migration will use this value when determining the size of the TLV for MAC address filters. Fix the representor mode function to stop incrementing the counter incorrectly.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +0 -1
@@ -3877,7 +3877,6 @@ static int ice_vc_repr_add_mac(struct ice_vf *vf, u8 *msg) }ice_vfhw_mac_add (vf, &al->list[i]); - vf->num_mac++;break ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 556/626 ice: Fix LACP bonds without SRIOV environment
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Ertman <[email protected]>
[ Upstream commit 6c778f1b839b63525b30046c9d1899424a62be0a ]
If an aggregate has the following conditions:
- The SRIOV LAG DDP package has been enabled
- The bond is in 802.3ad LACP mode
- The bond is disqualified from supporting SRIOV VF LAG
- Both interfaces were added simultaneously to the bond (same command)
Then there is a chance that the two interfaces will be assigned different LACP Aggregator ID's. This will cause a failure of the LACP control over the bond.
To fix this, we can detect if the primary interface for the bond (as defined by the driver) is not in switchdev mode, and exit the setup flow if so.
Reproduction steps:
%> ip link add bond0 type bond mode 802.3ad miimon 100 %> ip link set bond0 up
%> ifenslave bond0 eth0 eth1
%> cat /proc/net/bonding/bond0 | grep Agg
Check for Aggregator IDs that differ.
--- drivers/net/ethernet/intel/ice/ice_lag.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/intel/ice/ice_lag.c +6 -0
@@ -1321,12 +1321,18 @@ static void ice_lag_changeupper_event(struct ice_lag *lag, void *ptr)*/ if (!primary_lag) { lag->primary = true; +if (!ice_is_switchdev_running (lag->pf)) +return ; +/* Configure primary's SWID to be shared */ ice_lag_primary_swid (lag, true); primary_lag = lag; }else {u16 swid; +if (!ice_is_switchdev_running (primary_lag->pf)) +return ; + swid = primary_lag->pf->hw.port_info->sw_id;ice_lag_set_swid (swid, lag, true);ice_lag_add_prune_list (primary_lag, lag->pf);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 557/626 idpf: fix null-ptr-deref in idpf_features_check
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavan Kumar Linga <[email protected]>
[ Upstream commit 2dabe349f7882ff1407a784d54d8541909329088 ]
idpf_features_check is used to validate the TX packet. skb header length is compared with the hardware supported value received from the device control plane. The value is stored in the adapter structure and to access it, vport pointer is used. During reset all the vports are released and the vport pointer that the netdev private structure points to is NULL.
To avoid null-ptr-deref, store the max header length value in netdev private structure. This also helps to cache the value and avoid accessing adapter pointer in hot path.
BUG: kernel NULL pointer dereference, address: 0000000000000068 ... RIP: 0010:idpf_features_check+0x6d/0xe0 [idpf] Call Trace: <TASK> ? __die+0x23/0x70 ? page_fault_oops+0x154/0x520 ? exc_page_fault+0x76/0x190 ? asm_exc_page_fault+0x26/0x30 ? idpf_features_check+0x6d/0xe0 [idpf] netif_skb_features+0x88/0x310 validate_xmit_skb+0x2a/0x2b0 validate_xmit_skb_list+0x4c/0x70 sch_direct_xmit+0x19d/0x3a0 __dev_queue_xmit+0xb74/0xe70 ...
--- drivers/net/ethernet/intel/idpf/idpf.h | 2 ++ drivers/net/ethernet/intel/idpf/idpf_lib.c | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/idpf/idpf.h +2 -0
@@ -143,6 +143,7 @@ enum idpf_vport_state {* @vport_id: Vport identifier * @link_speed_mbps: Link speed in mbps * @vport_idx: Relative vport index +* @max_tx_hdr_size: Max header length hardware can support * @state: See enum idpf_vport_state * @netstats: Packet and byte stats * @stats_lock: Lock to protect stats update
@@ -153,6 +154,7 @@ struct idpf_netdev_priv {u32 vport_id;u32 link_speed_mbps;u16 vport_idx; +u16 max_tx_hdr_size;enum idpf_vport_state state;struct rtnl_link_stats64 netstats;spinlock_t stats_lock;
drivers/net/ethernet/intel/idpf/idpf_lib.c +6 -4
@@ -723,6 +723,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) np->vport = vport; np->vport_idx = vport->idx; np->vport_id = vport->vport_id; + np->max_tx_hdr_size =idpf_get_max_tx_hdr_size (adapter); vport->netdev = netdev;return idpf_init_mac_addr (vport, netdev);
@@ -740,6 +741,7 @@ static int idpf_cfg_netdev(struct idpf_vport *vport) np->adapter = adapter; np->vport_idx = vport->idx; np->vport_id = vport->vport_id; + np->max_tx_hdr_size =idpf_get_max_tx_hdr_size (adapter);spin_lock_init (&np->stats_lock);
@@ -2189,8 +2191,8 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb, struct net_device *netdev, netdev_features_t features) { -struct idpf_vport *vport =idpf_netdev_to_vport (netdev); -struct idpf_adapter *adapter = vport->adapter; +struct idpf_netdev_priv *np =netdev_priv (netdev); +u16 max_tx_hdr_size = np->max_tx_hdr_size;size_t len;/* No point in doing any of this if neither checksum nor GSO are
@@ -2213,7 +2215,7 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb, goto unsupported; len =skb_network_header_len (skb); -if (unlikely (len >idpf_get_max_tx_hdr_size (adapter))) +if (unlikely (len > max_tx_hdr_size)) goto unsupported;if (!skb->encapsulation)
@@ -2226,7 +2228,7 @@ static netdev_features_t idpf_features_check(struct sk_buff *skb,/* IPLEN can support at most 127 dwords */ len =skb_inner_network_header_len (skb); -if (unlikely (len >idpf_get_max_tx_hdr_size (adapter))) +if (unlikely (len > max_tx_hdr_size)) goto unsupported;/* No need to validate L4LEN as TCP is the only protocol with a
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 558/626 loop: dont require ->write_iter for writable files in loop_configure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <[email protected]>
[ Upstream commit 355341e4359b2d5edf0ed5e117f7e9e7a0a5dac0 ]
Block devices can be opened read-write even if they can't be written to for historic reasons. Remove the check requiring file->f_op->write_iter when the block devices was opened in loop_configure. The call to loop_check_backing_file just below ensures the ->write_iter is present for backing files opened for writing, which is the only check that is actually needed.
--- drivers/block/loop.c | 3 --- 1 file changed, 3 deletions(-)
drivers/block/loop.c +0 -3
@@ -969,9 +969,6 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode,if (!file)return -EBADF ; -if ((mode &BLK_OPEN_WRITE ) && !file->f_op->write_iter) -return -EINVAL ; - error =loop_check_backing_file (file);if (error)return error;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 559/626 pinctrl: qcom: switch to devm_register_sys_off_handler()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Baryshkov <[email protected]>
[ Upstream commit 41e452e6933d14146381ea25cff5e4d1ac2abea1 ]
Error-handling paths in msm_pinctrl_probe() don't call
a function required to unroll restart handler registration, unregister_restart_handler(). Instead of adding calls to this function, switch the msm pinctrl code into using devm_register_sys_off_handler().
--- drivers/pinctrl/qcom/pinctrl-msm.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/pinctrl/qcom/pinctrl-msm.c +12 -11
@@ -43,7 +43,6 @@* @pctrl: pinctrl handle. * @chip: gpiochip handle. * @desc: pin controller descriptor -* @restart_nb: restart notifier block. * @irq: parent irq for the TLMM irq_chip. * @intr_target_use_scm: route irq to application cpu using scm calls * @lock: Spinlock to protect register resources as well
@@ -63,7 +62,6 @@ struct msm_pinctrl {struct pinctrl_dev *pctrl;struct gpio_chip chip;struct pinctrl_desc desc; -struct notifier_block restart_nb;int irq;
@@ -1470,10 +1468,9 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)return 0 ; } -static int msm_ps_hold_restart (struct notifier_block *nb,unsigned long action, -void *data) +static int msm_ps_hold_restart (struct sys_off_data *data) { - struct msm_pinctrl *pctrl = container_of(nb, struct msm_pinctrl, restart_nb); +struct msm_pinctrl *pctrl = data->cb_data;writel (0 , pctrl->regs[0 ] +PS_HOLD_OFFSET );mdelay (1000 );
@@ -1484,7 +1481,11 @@ static struct msm_pinctrl *poweroff_pctrl;static void msm_ps_hold_poweroff (void ) { -msm_ps_hold_restart (&poweroff_pctrl->restart_nb,0 ,NULL ); +struct sys_off_data data = { + .cb_data = poweroff_pctrl, + }; + +msm_ps_hold_restart (&data); }static void msm_pinctrl_setup_pm_reset (struct msm_pinctrl *pctrl)
@@ -1494,9 +1495,11 @@ static void msm_pinctrl_setup_pm_reset(struct msm_pinctrl *pctrl)for (i =0 ; i < pctrl->soc->nfunctions; i++)if (!strcmp (func[i].name,"ps_hold" )) { - pctrl->restart_nb.notifier_call = msm_ps_hold_restart; - pctrl->restart_nb.priority =128 ; -if (register_restart_handler (&pctrl->restart_nb)) +if (devm_register_sys_off_handler (pctrl->dev, +SYS_OFF_MODE_RESTART , +128 , + msm_ps_hold_restart, + pctrl))dev_err (pctrl->dev,"failed to setup restart handler.\n" ); poweroff_pctrl = pctrl;
@@ -1598,8 +1601,6 @@ void msm_pinctrl_remove(struct platform_device *pdev)struct msm_pinctrl *pctrl =platform_get_drvdata (pdev);gpiochip_remove (&pctrl->chip); - -unregister_restart_handler (&pctrl->restart_nb); }EXPORT_SYMBOL (msm_pinctrl_remove);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 560/626 net: dwmac-sun8i: Use parsed internal PHY address instead of 1
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Kocialkowski <[email protected]>
[ Upstream commit 47653e4243f2b0a26372e481ca098936b51ec3a8 ]
While the MDIO address of the internal PHY on Allwinner sun8i chips is generally 1, of_mdio_parse_addr is used to cleanly parse the address from the device-tree instead of hardcoding it.
A commit reworking the code ditched the parsed value and hardcoded the value 1 instead, which didn't really break anything but is more fragile and not future-proof.
Restore the initial behavior using the parsed address returned from the helper.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c +1 -1
@@ -964,7 +964,7 @@ static int sun8i_dwmac_set_syscon(struct device *dev,/* of_mdio_parse_addr returns a valid (0 ~ 31) PHY * address. No need to mask it again. */ - reg |=1 <<H3_EPHY_ADDR_SHIFT ; + reg |= ret <<H3_EPHY_ADDR_SHIFT ; }else {/* For SoCs without internal PHY the PHY selection bit should be * set to 0 (external PHY).
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 561/626 net: lan743x: Restore SGMII CTRL register on resume
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thangaraj Samynathan <[email protected]>
[ Upstream commit 293e38ff4e4c2ba53f3fd47d8a4a9f0f0414a7a6 ]
SGMII_CTRL register, which specifies the active interface, was not properly restored when resuming from suspend. This led to incorrect interface selection after resume particularly in scenarios involving the FPGA.
To fix this:
- Move the SGMII_CTRL setup out of the probe function.
- Initialize the register in the hardware initialization helper function, which is called during both device initialization and resume.
This ensures the interface configuration is consistently restored after suspend/resume cycles.
--- drivers/net/ethernet/microchip/lan743x_main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/ethernet/microchip/lan743x_main.c +10 -9
@@ -3466,6 +3466,7 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter, struct pci_dev *pdev) {struct lan743x_tx *tx; +u32 sgmii_ctl;int index;int ret;
@@ -3478,6 +3479,15 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,spin_lock_init (&adapter->eth_syslock_spinlock);mutex_init (&adapter->sgmii_rw_lock);pci11x1x_set_rfe_rd_fifo_threshold (adapter); + sgmii_ctl =lan743x_csr_read (adapter,SGMII_CTL ); +if (adapter->is_sgmii_en) { + sgmii_ctl |=SGMII_CTL_SGMII_ENABLE_ ; + sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_ ; + }else { + sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_ ; + sgmii_ctl |=SGMII_CTL_SGMII_POWER_DN_ ; + } +lan743x_csr_write (adapter,SGMII_CTL , sgmii_ctl); }else { adapter->max_tx_channels =LAN743X_MAX_TX_CHANNELS ; adapter->used_tx_channels =LAN743X_USED_TX_CHANNELS ;
@@ -3526,7 +3536,6 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,static int lan743x_mdiobus_init (struct lan743x_adapter *adapter) { -u32 sgmii_ctl;int ret; adapter->mdiobus =devm_mdiobus_alloc (&adapter->pdev->dev);
@@ -3538,10 +3547,6 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter) adapter->mdiobus->priv = (void *)adapter;if (adapter->is_pci11x1x) {if (adapter->is_sgmii_en) { - sgmii_ctl =lan743x_csr_read (adapter,SGMII_CTL ); - sgmii_ctl |=SGMII_CTL_SGMII_ENABLE_ ; - sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_ ; -lan743x_csr_write (adapter,SGMII_CTL , sgmii_ctl);netif_dbg (adapter, drv, adapter->netdev,"SGMII operation\n" ); adapter->mdiobus->read = lan743x_mdiobus_read_c22;
@@ -3552,10 +3557,6 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)netif_dbg (adapter, drv, adapter->netdev,"lan743x-mdiobus-c45\n" ); }else { - sgmii_ctl =lan743x_csr_read (adapter,SGMII_CTL ); - sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_ ; - sgmii_ctl |=SGMII_CTL_SGMII_POWER_DN_ ; -lan743x_csr_write (adapter,SGMII_CTL , sgmii_ctl);netif_dbg (adapter, drv, adapter->netdev,"RGMII operation\n" );// Only C22 support when RGMII I/F
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 562/626 io_uring: fix overflow resched cqe reordering
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pavel Begunkov <[email protected]>
[ Upstream commit a7d755ed9ce9738af3db602eb29d32774a180bc7 ]
Leaving the CQ critical section in the middle of a overflow flushing can cause cqe reordering since the cache cq pointers are reset and any new cqe emitters that might get called in between are not going to be forced into io_cqe_cache_refill().
--- io_uring/io_uring.c | 1 + 1 file changed, 1 insertion(+)
io_uring/io_uring.c +1 -0
@@ -630,6 +630,7 @@ static void __io_cqring_overflow_flush(struct io_ring_ctx *ctx, bool dying)* to care for a non-real case. */ if (need_resched ()) { + ctx->cqe_sentinel = ctx->cqe_cached;io_cq_unlock_post (ctx);mutex_unlock (&ctx->uring_lock);cond_resched ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 563/626 idpf: fix idpf_vport_splitq_napi_poll()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 407e0efdf8baf1672876d5948b75049860a93e59 ]
idpf_vport_splitq_napi_poll() can incorrectly return @budget after napi_complete_done() has been called.
This violates NAPI rules, because after napi_complete_done(), current thread lost napi ownership.
Move the test against POLL_MODE before the napi_complete_done().
--- drivers/net/ethernet/intel/idpf/idpf_txrx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/idpf/idpf_txrx.c +9 -9
@@ -4022,6 +4022,14 @@ static int idpf_vport_splitq_napi_poll(struct napi_struct *napi, int budget)return budget; } +/* Switch to poll mode in the tear-down path after sending disable +* queues virtchnl message, as the interrupts will be disabled after +* that. +*/ +if (unlikely (q_vector->num_txq &&idpf_queue_has (POLL_MODE , + q_vector->tx[0 ]))) +return budget; + work_done =min_t (int, work_done, budget -1 );/* Exit the polling mode, but don't re-enable interrupts if stack might
@@ -4032,15 +4040,7 @@ static int idpf_vport_splitq_napi_poll(struct napi_struct *napi, int budget)else idpf_vport_intr_set_wb_on_itr (q_vector); -/* Switch to poll mode in the tear-down path after sending disable -* queues virtchnl message, as the interrupts will be disabled after -* that -*/ -if (unlikely (q_vector->num_txq &&idpf_queue_has (POLL_MODE , - q_vector->tx[0 ]))) -return budget; -else -return work_done; +return work_done; }/**
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 564/626 sch_hfsc: Fix qlen accounting bug when using peek in hfsc_enqueue()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
[ Upstream commit 3f981138109f63232a5fb7165938d4c945cc1b9d ]
When enqueuing the first packet to an HFSC class, hfsc_enqueue() calls the child qdisc's peek() operation before incrementing sch->q.qlen and sch->qstats.backlog. If the child qdisc uses qdisc_peek_dequeued(), this may trigger an immediate dequeue and potential packet drop. In such cases, qdisc_tree_reduce_backlog() is called, but the HFSC qdisc's qlen and backlog have not yet been updated, leading to inconsistent queue accounting. This can leave an empty HFSC class in the active list, causing further consequences like use-after-free.
This patch fixes the bug by moving the increment of sch->q.qlen and sch->qstats.backlog before the call to the child qdisc's peek() operation. This ensures that queue length and backlog are always accurate when packet drops or dequeues are triggered during the peek.
--- net/sched/sch_hfsc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/sched/sch_hfsc.c +3 -3
@@ -1569,6 +1569,9 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)return err; } + sch->qstats.backlog += len; + sch->q.qlen++; +if (first && !cl->cl_nactive) {if (cl->cl_flags &HFSC_RSC )init_ed (cl, len);
@@ -1584,9 +1587,6 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) } - sch->qstats.backlog += len; - sch->q.qlen++; -return NET_XMIT_SUCCESS ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 565/626 octeontx2-pf: Add AF_XDP non-zero copy support
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Ghosh <[email protected]>
[ Upstream commit b4164de5041b51cda3438e75bce668e2556057c3 ]
Set xdp rx ring memory type as MEM_TYPE_PAGE_POOL for af-xdp to work. This is needed since xdp_return_frame internally will use page pools.
--- drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +7 -1
@@ -988,6 +988,7 @@ static int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx)int err, pool_id, non_xdp_queues;struct nix_aq_enq_req *aq;struct otx2_cq_queue *cq; +struct otx2_pool *pool; cq = &qset->cq[qidx]; cq->cq_idx = qidx;
@@ -996,8 +997,13 @@ static int otx2_cq_init(struct otx2_nic *pfvf, u16 qidx) cq->cq_type =CQ_RX ; cq->cint_idx = qidx; cq->cqe_cnt = qset->rqe_cnt; -if (pfvf->xdp_prog) +if (pfvf->xdp_prog) { + pool = &qset->pool[qidx];xdp_rxq_info_reg (&cq->xdp_rxq, pfvf->netdev, qidx,0 ); +xdp_rxq_info_reg_mem_model (&cq->xdp_rxq, +MEM_TYPE_PAGE_POOL , + pool->page_pool); + } }else if (qidx < non_xdp_queues) { cq->cq_type =CQ_TX ; cq->cint_idx = qidx - pfvf->hw.rx_queues;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 566/626 net/tipc: fix slab-use-after-free Read in tipc_aead_encrypt_done
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Liang <[email protected]>
[ Upstream commit e279024617134c94fd3e37470156534d5f2b3472 ]
Syzbot reported a slab-use-after-free with the following call trace:
==================================================================
BUG: KASAN: slab-use-after-free in tipc_aead_encrypt_done+0x4bd/0x510 net/tipc/crypto.c:840 Read of size 8 at addr ffff88807a733000 by task kworker/1:0/25 Call Trace: kasan_report+0xd9/0x110 mm/kasan/report.c:601 tipc_aead_encrypt_done+0x4bd/0x510 net/tipc/crypto.c:840 crypto_request_complete include/crypto/algapi.h:266 aead_request_complete include/crypto/internal/aead.h:85 cryptd_aead_crypt+0x3b8/0x750 crypto/cryptd.c:772 crypto_request_complete include/crypto/algapi.h:266 cryptd_queue_worker+0x131/0x200 crypto/cryptd.c:181 process_one_work+0x9fb/0x1b60 kernel/workqueue.c:3231 Allocated by task 8355: kzalloc_noprof include/linux/slab.h:778 tipc_crypto_start+0xcc/0x9e0 net/tipc/crypto.c:1466 tipc_init_net+0x2dd/0x430 net/tipc/core.c:72 ops_init+0xb9/0x650 net/core/net_namespace.c:139 setup_net+0x435/0xb40 net/core/net_namespace.c:343 copy_net_ns+0x2f0/0x670 net/core/net_namespace.c:508 create_new_namespaces+0x3ea/0xb10 kernel/nsproxy.c:110 unshare_nsproxy_namespaces+0xc0/0x1f0 kernel/nsproxy.c:228 ksys_unshare+0x419/0x970 kernel/fork.c:3323 __do_sys_unshare kernel/fork.c:3394 Freed by task 63: kfree+0x12a/0x3b0 mm/slub.c:4557 tipc_crypto_stop+0x23c/0x500 net/tipc/crypto.c:1539 tipc_exit_net+0x8c/0x110 net/tipc/core.c:119 ops_exit_list+0xb0/0x180 net/core/net_namespace.c:173 cleanup_net+0x5b7/0xbf0 net/core/net_namespace.c:640 process_one_work+0x9fb/0x1b60 kernel/workqueue.c:3231
After freed the tipc_crypto tx by delete namespace, tipc_aead_encrypt_done may still visit it in cryptd_queue_worker workqueue.
I reproduce this issue by:
ip netns add ns1
ip link add veth1 type veth peer name veth2
ip link set veth1 netns ns1
ip netns exec ns1 tipc bearer enable media eth dev veth1 ip netns exec ns1 tipc node set key this_is_a_master_key master ip netns exec ns1 tipc bearer disable media eth dev veth1 ip netns del ns1
The key of reproduction is that, simd_aead_encrypt is interrupted, leading to crypto_simd_usable() return false. Thus, the cryptd_queue_worker is triggered, and the tipc_crypto tx will be visited.
tipc_disc_timeout
tipc_bearer_xmit_skb
tipc_crypto_xmit
tipc_aead_encrypt
crypto_aead_encrypt
// encrypt()
simd_aead_encrypt
// crypto_simd_usable() is false
child = &ctx->cryptd_tfm->base; simd_aead_encrypt
crypto_aead_encrypt
// encrypt()
cryptd_aead_encrypt_enqueue
cryptd_aead_enqueue
cryptd_enqueue_request
// trigger cryptd_queue_worker
queue_work_on(smp_processor_id(), cryptd_wq, &cpu_queue->work)Fix this by holding net reference count before encrypt.
--- net/tipc/crypto.c | 5 +++++ 1 file changed, 5 insertions(+)
net/tipc/crypto.c +5 -0
@@ -817,12 +817,16 @@ static int tipc_aead_encrypt(struct tipc_aead *aead, struct sk_buff *skb, goto exit; } +/* Get net to avoid freed tipc_crypto when delete namespace */ +get_net (aead->crypto->net); +/* Now, do encrypt */ rc =crypto_aead_encrypt (req);if (rc == -EINPROGRESS || rc == -EBUSY )return rc;tipc_bearer_put (b); +put_net (aead->crypto->net); exit:kfree (ctx);
@@ -860,6 +864,7 @@ static void tipc_aead_encrypt_done(void *data, int err)kfree (tx_ctx);tipc_bearer_put (b);tipc_aead_put (aead); +put_net (net); }/**
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 567/626 octeontx2-af: Set LMT_ENA bit for APR table entries
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Subbaraya Sundeep <[email protected]>
[ Upstream commit 0eefa27b493306928d88af6368193b134c98fd64 ]
This patch enables the LMT line for a PF/VF by setting the LMT_ENA bit in the APR_LMT_MAP_ENTRY_S structure.
Additionally, it simplifies the logic for calculating the LMTST table index by consistently using the maximum number of hw supported VFs (i.e., 256).
--- .../net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +13 -2
@@ -15,13 +15,17 @@#define LMT_TBL_OP_WRITE 1#define LMT_MAP_TABLE_SIZE (128 * 1024)#define LMT_MAPTBL_ENTRY_SIZE 16 +#define LMT_MAX_VFS 256 + +#define LMT_MAP_ENTRY_ENA BIT_ULL(20) +#define LMT_MAP_ENTRY_LINES GENMASK_ULL(18, 16)/* Function to perform operations (read/write) on lmtst map table */ static int lmtst_map_table_ops (struct rvu *rvu,u32 index,u64 *val,int lmt_tbl_op) {void __iomem *lmt_map_base; -u64 tbl_base; +u64 tbl_base, cfg; tbl_base =rvu_read64 (rvu,BLKADDR_APR ,APR_AF_LMT_MAP_BASE );
@@ -35,6 +39,13 @@ static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val, *val =readq (lmt_map_base + index); }else {writeq ((*val), (lmt_map_base + index)); + + cfg =FIELD_PREP (LMT_MAP_ENTRY_ENA ,0x1 ); +/* 2048 LMTLINES */ + cfg |=FIELD_PREP (LMT_MAP_ENTRY_LINES ,0x6 ); + +writeq (cfg, (lmt_map_base + (index +8 ))); +/* Flushing the AP interceptor cache to make APR_LMT_MAP_ENTRY_S * changes effective. Write 1 for flush and read is being used as a * barrier and sets up a data dependency. Write to 0 after a write
@@ -52,7 +63,7 @@ static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val,#define LMT_MAP_TBL_W1_OFF 8static u32 rvu_get_lmtst_tbl_index (struct rvu *rvu,u16 pcifunc) { -return ((rvu_get_pf (pcifunc) * rvu->hw->total_vfs) + +return ((rvu_get_pf (pcifunc) *LMT_MAX_VFS ) + (pcifunc &RVU_PFVF_FUNC_MASK )) *LMT_MAPTBL_ENTRY_SIZE ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 568/626 octeontx2-af: Fix APR entry mapping based on APR_LMT_CFG
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geetha sowjanya <[email protected]>
[ Upstream commit a6ae7129819ad20788e610261246e71736543b8b ]
The current implementation maps the APR table using a fixed size, which can lead to incorrect mapping when the number of PFs and VFs varies.
This patch corrects the mapping by calculating the APR table size dynamically based on the values configured in the APR_LMT_CFG register, ensuring accurate representation of APR entries in debugfs.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c | 9 ++++++--- .../net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_cn10k.c +6 -3
@@ -13,7 +13,6 @@/* RVU LMTST */ #define LMT_TBL_OP_READ 0#define LMT_TBL_OP_WRITE 1 -#define LMT_MAP_TABLE_SIZE (128 * 1024)#define LMT_MAPTBL_ENTRY_SIZE 16#define LMT_MAX_VFS 256
@@ -26,10 +25,14 @@ static int lmtst_map_table_ops(struct rvu *rvu, u32 index, u64 *val, {void __iomem *lmt_map_base;u64 tbl_base, cfg; +int pfs, vfs; tbl_base =rvu_read64 (rvu,BLKADDR_APR ,APR_AF_LMT_MAP_BASE ); + cfg =rvu_read64 (rvu,BLKADDR_APR ,APR_AF_LMT_CFG ); + vfs =1 << (cfg &0xF ); + pfs =1 << ((cfg >>4 ) &0x7 ); - lmt_map_base =ioremap_wc (tbl_base,LMT_MAP_TABLE_SIZE ); + lmt_map_base =ioremap_wc (tbl_base, pfs * vfs *LMT_MAPTBL_ENTRY_SIZE );if (!lmt_map_base) {dev_err (rvu->dev,"Failed to setup lmt map table mapping!!\n" );return -ENOMEM ;
@@ -80,7 +83,7 @@ static int rvu_get_lmtaddr(struct rvu *rvu, u16 pcifunc,mutex_lock (&rvu->rsrc_lock);rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_SMMU_ADDR_REQ , iova); - pf =rvu_get_pf (pcifunc) &0x1F ; + pf =rvu_get_pf (pcifunc) &RVU_PFVF_PF_MASK ; val =BIT_ULL (63 ) |BIT_ULL (14 ) |BIT_ULL (13 ) | pf <<8 | ((pcifunc &RVU_PFVF_FUNC_MASK ) &0xFF );rvu_write64 (rvu,BLKADDR_RVUM ,RVU_AF_SMMU_TXN_REQ , val);
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +8 -3
@@ -580,6 +580,7 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,u64 lmt_addr, val, tbl_base;int pf, vf, num_vfs, hw_vfs;void __iomem *lmt_map_base; +int apr_pfs, apr_vfs;int buf_size =10240 ;size_t off =0 ;int index =0 ;
@@ -595,8 +596,12 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,return -ENOMEM ; tbl_base =rvu_read64 (rvu,BLKADDR_APR ,APR_AF_LMT_MAP_BASE ); + val =rvu_read64 (rvu,BLKADDR_APR ,APR_AF_LMT_CFG ); + apr_vfs =1 << (val &0xF ); + apr_pfs =1 << ((val >>4 ) &0x7 ); - lmt_map_base =ioremap_wc (tbl_base,128 *1024 ); + lmt_map_base =ioremap_wc (tbl_base, apr_pfs * apr_vfs * +LMT_MAPTBL_ENTRY_SIZE );if (!lmt_map_base) {dev_err (rvu->dev,"Failed to setup lmt map table mapping!!\n" );kfree (buf);
@@ -618,7 +623,7 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp, off +=scnprintf (&buf[off], buf_size -1 - off,"PF%d \t\t\t" , pf); - index = pf * rvu->hw->total_vfs *LMT_MAPTBL_ENTRY_SIZE ; + index = pf * apr_vfs *LMT_MAPTBL_ENTRY_SIZE ; off +=scnprintf (&buf[off], buf_size -1 - off," 0x%llx\t\t" , (tbl_base + index)); lmt_addr =readq (lmt_map_base + index);
@@ -631,7 +636,7 @@ static ssize_t rvu_dbg_lmtst_map_table_display(struct file *filp,/* Reading num of VFs per PF */ rvu_get_pf_numvfs (rvu, pf, &num_vfs, &hw_vfs);for (vf =0 ; vf < num_vfs; vf++) { - index = (pf * rvu->hw->total_vfs *16 ) + + index = (pf * apr_vfs *LMT_MAPTBL_ENTRY_SIZE ) + ((vf +1 ) *LMT_MAPTBL_ENTRY_SIZE ); off +=scnprintf (&buf[off], buf_size -1 - off,"PF%d:VF%d \t\t" , pf, vf);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 569/626 clk: s2mps11: initialise clk_hw_onecell_data::num before accessing ::hws[] in probe()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: André Draszik <[email protected]>
commit 3e14c7207a975eefcda1929b2134a9f4119dde45 upstream.
With UBSAN enabled, we're getting the following trace:
UBSAN: array-index-out-of-bounds in .../drivers/clk/clk-s2mps11.c:186:3
index 0 is out of range for type 'struct clk_hw *[] __counted_by(num)' (aka 'struct clk_hw *[]')This is because commit f316cdff8d67 ("clk: Annotate struct clk_hw_onecell_data with __counted_by") annotated the hws member of that struct with __counted_by, which informs the bounds sanitizer about the number of elements in hws, so that it can warn when hws is accessed out of bounds.
As noted in that change, the __counted_by member must be initialised with the number of elements before the first array access happens, otherwise there will be a warning from each access prior to the initialisation because the number of elements is zero. This occurs in s2mps11_clk_probe() due to ::num being assigned after ::hws access.
Move the assignment to satisfy the requirement of assign-before-access.
--- drivers/clk/clk-s2mps11.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/clk/clk-s2mps11.c +2 -1
@@ -137,6 +137,8 @@ static int s2mps11_clk_probe(struct platif (!clk_data)return -ENOMEM ; + clk_data->num =S2MPS11_CLKS_NUM ; +switch (hwid) {case S2MPS11X : s2mps11_reg =S2MPS11_REG_RTC_CTRL ;
@@ -186,7 +188,6 @@ static int s2mps11_clk_probe(struct plat clk_data->hws[i] = &s2mps11_clks[i].hw; } - clk_data->num =S2MPS11_CLKS_NUM ;of_clk_add_hw_provider (s2mps11_clks->clk_np, of_clk_hw_onecell_get, clk_data);
Greg Kroah-Hartman
maintainerPATCH 570/626 crypto: algif_hash - fix double free in hash_accept
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Pravdin <[email protected]>
commit b2df03ed4052e97126267e8c13ad4204ea6ba9b6 upstream.
If accept(2) is called on socket type algif_hash with MSG_MORE flag set and crypto_ahash_import fails, sk2 is freed. However, it is also freed in af_alg_release, leading to slab-use-after-free error.
--- crypto/algif_hash.c | 4 ---- 1 file changed, 4 deletions(-)
crypto/algif_hash.c +0 -4
@@ -265,10 +265,6 @@ static int hash_accept(struct socket *so goto out_free_state; err =crypto_ahash_import (&ctx2->req, state); -if (err) { -sock_orphan (sk2); -sock_put (sk2); - } out_free_state:kfree_sensitive (state);
Greg Kroah-Hartman
maintainerPATCH 571/626 padata: do not leak refcount in reorder_work
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominik Grzegorzek <[email protected]>
commit d6ebcde6d4ecf34f8495fb30516645db3aea8993 upstream.
A recent patch that addressed a UAF introduced a reference count leak:
the parallel_data refcount is incremented unconditionally, regardless of the return value of queue_work(). If the work item is already queued, the incremented refcount is never decremented.
Fix this by checking the return value of queue_work() and decrementing the refcount when necessary.
Resolves:
Unreferenced object 0xffff9d9f421e3d80 (size 192):
comm "cryptomgr_probe", pid 157, jiffies 4294694003 hex dump (first 32 bytes):
80 8b cf 41 9f 9d ff ff b8 97 e0 89 ff ff ff ff ...A............
d0 97 e0 89 ff ff ff ff 19 00 00 00 1f 88 23 00 ..............#.
backtrace (crc 838fb36):
__kmalloc_cache_noprof+0x284/0x320
padata_alloc_pd+0x20/0x1e0
padata_alloc_shell+0x3b/0xa0
0xffffffffc040a54d
cryptomgr_probe+0x43/0xc0
kthread+0xf6/0x1f0
ret_from_fork+0x2f/0x50
ret_from_fork_asm+0x1a/0x30--- kernel/padata.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/padata.c +2 -1
@@ -358,7 +358,8 @@ static void padata_reorder(struct parall* To avoid UAF issue, add pd ref here, and put pd ref after reorder_work finish. */ padata_get_pd (pd); -queue_work (pinst->serial_wq, &pd->reorder_work); +if (!queue_work (pinst->serial_wq, &pd->reorder_work)) +padata_put_pd (pd); } }
Greg Kroah-Hartman
maintainerPATCH 572/626 can: slcan: allow reception of short error messages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Carlos Sanchez <[email protected]>
commit ef0841e4cb08754be6cb42bf97739fce5d086e5f upstream.
Allows slcan to receive short messages (typically errors) from the serial interface.
When error support was added to slcan protocol in b32ff4668544e1333b694fcc7812b2d7397b4d6a ("can: slcan: extend the protocol with error info") the minimum valid message size changed from 5 (minimum standard can frame tIII0) to 3 ("e1a" is a valid protocol message, it is one of the examples given in the comments for slcan_bump_err() ), but the check for minimum message length prodicating all decoding was not adjusted. This makes short error messages discarded and error frames not being generated.
This patch changes the minimum length to the new minimum (3 characters, excluding terminator, is now a valid message).
--- drivers/net/can/slcan/slcan-core.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-)
drivers/net/can/slcan/slcan-core.c +20 -6
@@ -71,12 +71,21 @@ MODULE_AUTHOR("Dario Binacchi <dario.bin#define SLCAN_CMD_LEN 1#define SLCAN_SFF_ID_LEN 3#define SLCAN_EFF_ID_LEN 8 +#define SLCAN_DATA_LENGTH_LEN 1 +#define SLCAN_ERROR_LEN 1#define SLCAN_STATE_LEN 1#define SLCAN_STATE_BE_RXCNT_LEN 3#define SLCAN_STATE_BE_TXCNT_LEN 3 -#define SLCAN_STATE_FRAME_LEN (1 + SLCAN_CMD_LEN + \ - SLCAN_STATE_BE_RXCNT_LEN + \ - SLCAN_STATE_BE_TXCNT_LEN) +#define SLCAN_STATE_MSG_LEN (SLCAN_CMD_LEN + \ + SLCAN_STATE_LEN + \ + SLCAN_STATE_BE_RXCNT_LEN + \ + SLCAN_STATE_BE_TXCNT_LEN) +#define SLCAN_ERROR_MSG_LEN_MIN (SLCAN_CMD_LEN + \ + SLCAN_ERROR_LEN + \ + SLCAN_DATA_LENGTH_LEN) +#define SLCAN_FRAME_MSG_LEN_MIN (SLCAN_CMD_LEN + \ + SLCAN_SFF_ID_LEN + \ + SLCAN_DATA_LENGTH_LEN)struct slcan {struct can_priv can;
@@ -176,6 +185,9 @@ static void slcan_bump_frame(struct slcau32 tmpid;char *cmd = sl->rbuff; +if (sl->rcount <SLCAN_FRAME_MSG_LEN_MIN ) +return ; + skb =alloc_can_skb (sl->dev, &cf);if (unlikely (!skb)) { sl->dev->stats.rx_dropped++;
@@ -281,7 +293,7 @@ static void slcan_bump_state(struct slcareturn ; } -if (state == sl->can.state || sl->rcount <SLCAN_STATE_FRAME_LEN ) +if (state == sl->can.state || sl->rcount !=SLCAN_STATE_MSG_LEN )return ; cmd +=SLCAN_STATE_BE_RXCNT_LEN +SLCAN_CMD_LEN +1 ;
@@ -328,6 +340,9 @@ static void slcan_bump_err(struct slcanbool rx_errors = false, tx_errors = false, rx_over_errors = false;int i, len; +if (sl->rcount <SLCAN_ERROR_MSG_LEN_MIN ) +return ; +/* get len from sanitized ASCII value */ len = cmd[1 ];if (len >='0' && len <'9' )
@@ -456,8 +471,7 @@ static void slcan_bump(struct slcan *sl)static void slcan_unesc (struct slcan *sl,unsigned char s) {if ((s =='\r' ) || (s =='\a' )) {/* CR or BEL ends the pdu */ -if (!test_and_clear_bit (SLF_ERROR , &sl->flags) && - sl->rcount >4 ) +if (!test_and_clear_bit (SLF_ERROR , &sl->flags))slcan_bump (sl); sl->rcount =0 ;
Greg Kroah-Hartman
maintainerPATCH 573/626 can: bcm: add locking for bcm_op runtime updates
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
commit c2aba69d0c36a496ab4f2e81e9c2b271f2693fd7 upstream.
The CAN broadcast manager (CAN BCM) can send a sequence of CAN frames via hrtimer. The content and also the length of the sequence can be changed resp reduced at runtime where the 'currframe' counter is then set to zero.
Although this appeared to be a safe operation the updates of 'currframe' can be triggered from user space and hrtimer context in bcm_can_tx(). Anderson Nascimento created a proof of concept that triggered a KASAN slab-out-of-bounds read access which can be prevented with a spin_lock_bh.
At the rework of bcm_can_tx() the 'count' variable has been moved into the protected section as this variable can be modified from both contexts too.
--- net/can/bcm.c | 66 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 45 insertions(+), 21 deletions(-)
net/can/bcm.c +45 -21
@@ -58,6 +58,7 @@#include <linux/can/skb.h> #include <linux/can/bcm.h> #include <linux/slab.h> +#include <linux/spinlock.h> #include <net/sock.h> #include <net/net_namespace.h>
@@ -122,6 +123,7 @@ struct bcm_op {struct canfd_frame last_sframe;struct sock *sk;struct net_device *rx_reg_dev; +spinlock_t bcm_tx_lock;/* protect currframe/count in runtime updates */ };struct bcm_sock {
@@ -285,13 +287,18 @@ static void bcm_can_tx(struct bcm_op *op {struct sk_buff *skb;struct net_device *dev; -struct canfd_frame *cf = op->frames + op->cfsiz * op->currframe; +struct canfd_frame *cf;int err;/* no target device? => exit */ if (!op->ifindex)return ; +/* read currframe under lock protection */ +spin_lock_bh (&op->bcm_tx_lock); + cf = op->frames + op->cfsiz * op->currframe; +spin_unlock_bh (&op->bcm_tx_lock); + dev =dev_get_by_index (sock_net (op->sk), op->ifindex);if (!dev) {/* RFC: should this bcm_op remove itself here? */
@@ -312,6 +319,10 @@ static void bcm_can_tx(struct bcm_op *op skb->dev = dev;can_skb_set_owner (skb, op->sk); err =can_send (skb,1 ); + +/* update currframe and count under lock protection */ +spin_lock_bh (&op->bcm_tx_lock); +if (!err) op->frames_abs++;
@@ -320,6 +331,11 @@ static void bcm_can_tx(struct bcm_op *op/* reached last frame? */ if (op->currframe >= op->nframes) op->currframe =0 ; + +if (op->count >0 ) + op->count--; + +spin_unlock_bh (&op->bcm_tx_lock); out:dev_put (dev); }
@@ -430,7 +446,7 @@ static enum hrtimer_restart bcm_tx_timeostruct bcm_msg_head msg_head;if (op->kt_ival1 && (op->count >0 )) { - op->count--; +bcm_can_tx (op);if (!op->count && (op->flags &TX_COUNTEVT )) {/* create notification to user */
@@ -445,7 +461,6 @@ static enum hrtimer_restart bcm_tx_timeobcm_send_to_user (op, &msg_head,NULL ,0 ); } -bcm_can_tx (op); }else if (op->kt_ival2) {bcm_can_tx (op);
@@ -956,6 +971,27 @@ static int bcm_tx_setup(struct bcm_msg_h } op->flags = msg_head->flags; +/* only lock for unlikely count/nframes/currframe changes */ +if (op->nframes != msg_head->nframes || + op->flags &TX_RESET_MULTI_IDX || + op->flags &SETTIMER ) { + +spin_lock_bh (&op->bcm_tx_lock); + +if (op->nframes != msg_head->nframes || + op->flags &TX_RESET_MULTI_IDX ) { +/* potentially update changed nframes */ + op->nframes = msg_head->nframes; +/* restart multiple frame transmission */ + op->currframe =0 ; + } + +if (op->flags &SETTIMER ) + op->count = msg_head->count; + +spin_unlock_bh (&op->bcm_tx_lock); + } + }else {/* insert new BCM operation for the given can_id */
@@ -963,9 +999,14 @@ static int bcm_tx_setup(struct bcm_msg_hif (!op)return -ENOMEM ; +spin_lock_init (&op->bcm_tx_lock); op->can_id = msg_head->can_id; op->cfsiz =CFSIZ (msg_head->flags); op->flags = msg_head->flags; + op->nframes = msg_head->nframes; + +if (op->flags &SETTIMER ) + op->count = msg_head->count;/* create array for CAN frames and copy the data */ if (msg_head->nframes >1 ) {
@@ -1024,22 +1065,8 @@ static int bcm_tx_setup(struct bcm_msg_h }/* if ((op = bcm_find_op(&bo->tx_ops, msg_head->can_id, ifindex))) */ -if (op->nframes != msg_head->nframes) { - op->nframes = msg_head->nframes; -/* start multiple frame transmission with index 0 */ - op->currframe =0 ; - } - -/* check flags */ - -if (op->flags &TX_RESET_MULTI_IDX ) { -/* start multiple frame transmission with index 0 */ - op->currframe =0 ; - } -if (op->flags &SETTIMER ) {/* set timer values */ - op->count = msg_head->count; op->ival1 = msg_head->ival1; op->ival2 = msg_head->ival2; op->kt_ival1 =bcm_timeval_to_ktime (msg_head->ival1);
@@ -1056,11 +1083,8 @@ static int bcm_tx_setup(struct bcm_msg_h op->flags |=TX_ANNOUNCE ; } -if (op->flags &TX_ANNOUNCE ) { +if (op->flags &TX_ANNOUNCE )bcm_can_tx (op); -if (op->count) - op->count--; - }if (op->flags &STARTTIMER )bcm_tx_start_timer (op);
Greg Kroah-Hartman
maintainerPATCH 574/626 can: bcm: add missing rcu read protection for procfs content
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oliver Hartkopp <[email protected]>
commit dac5e6249159ac255dad9781793dbe5908ac9ddb upstream.
When the procfs content is generated for a bcm_op which is in the process to be removed the procfs output might show unreliable data (UAF).
As the removal of bcm_op's is already implemented with rcu handling this patch adds the missing rcu_read_lock() and makes sure the list entries are properly removed under rcu protection.
--- net/can/bcm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
net/can/bcm.c +9 -4
@@ -219,7 +219,9 @@ static int bcm_proc_show(struct seq_fileseq_printf (m," / bound %s" ,bcm_proc_getifname (net, ifname, bo->ifindex));seq_printf (m," <<<\n" ); -list_for_each_entry (op, &bo->rx_ops, list) { +rcu_read_lock (); + +list_for_each_entry_rcu (op, &bo->rx_ops, list) {unsigned long reduction;
@@ -275,6 +277,9 @@ static int bcm_proc_show(struct seq_file seq_printf(m, "# sent %ld\n", op->frames_abs); }seq_putc (m,'\n' ); + +rcu_read_unlock (); +return 0 ; }#endif /* CONFIG_PROC_FS */
@@ -858,7 +863,7 @@ static int bcm_delete_rx_op(struct list_REGMASK (op->can_id), bcm_rx_handler, op); -list_del (&op->list); +list_del_rcu (&op->list);bcm_remove_op (op);return 1 ;/* done */ }
@@ -878,7 +883,7 @@ static int bcm_delete_tx_op(struct list_list_for_each_entry_safe (op, n, ops, list) {if ((op->can_id == mh->can_id) && (op->ifindex == ifindex) && (op->flags &CAN_FD_FRAME ) == (mh->flags &CAN_FD_FRAME )) { -list_del (&op->list); +list_del_rcu (&op->list);bcm_remove_op (op);return 1 ;/* done */ }
@@ -1300,7 +1305,7 @@ static int bcm_rx_setup(struct bcm_msg_h bcm_rx_handler, op, "bcm", sk);if (err) {/* this bcm rx op is broken -> remove it */ -list_del (&op->list); +list_del_rcu (&op->list);bcm_remove_op (op);return err; }
Greg Kroah-Hartman
maintainerPATCH 575/626 ASoC: SOF: ipc4-control: Use SOF_CTRL_CMD_BINARY as numid for bytes_ext
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 4d14b1069e9e672dbe1adab52594076da6f4a62d upstream.
The header.numid is set to scontrol->comp_id in bytes_ext_get and it is ignored during bytes_ext_put.
The use of comp_id is not quite great as it is kernel internal identification number.
Set the header.numid to SOF_CTRL_CMD_BINARY during get and validate the numid during put to provide consistent and compatible identification number as IPC3.
For IPC4 existing tooling also ignored the numid but with the use of SOF_CTRL_CMD_BINARY the different handling of the blobs can be dropped, providing better user experience.
--- sound/soc/sof/ipc4-control.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
sound/soc/sof/ipc4-control.c +10 -1
@@ -531,6 +531,14 @@ static int sof_ipc4_bytes_ext_put(structreturn -EINVAL ; } +/* Check header id */ +if (header.numid !=SOF_CTRL_CMD_BINARY ) { +dev_err_ratelimited (scomp->dev, +"Incorrect numid for bytes put %d\n" , + header.numid); +return -EINVAL ; + } +/* Verify the ABI header first */ if (copy_from_user (&abi_hdr, tlvd->tlv,sizeof (abi_hdr)))return -EFAULT ;
@@ -613,7 +621,8 @@ static int _sof_ipc4_bytes_ext_get(strucif (data_size > size)return -ENOSPC ; - header.numid = scontrol->comp_id; +/* Set header id and length */ + header.numid =SOF_CTRL_CMD_BINARY ; header.length = data_size;if (copy_to_user (tlvd, &header,sizeof (struct snd_ctl_tlv )))
Greg Kroah-Hartman
maintainerPATCH 576/626 ASoC: SOF: Intel: hda-bus: Use PIO mode on ACE2+ platforms
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 4e7010826e96702d7fad13dbe85de4e94052f833 upstream.
Keep using the PIO mode for commands on ACE2+ platforms, similarly how the legacy stack is configured.
--- sound/soc/sof/intel/hda-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/sof/intel/hda-bus.c +1 -1
@@ -76,7 +76,7 @@ void sof_hda_bus_init(struct snd_sof_dev *sdev, struct device *dev)snd_hdac_ext_bus_init (bus, dev, &bus_core_ops, sof_hda_ext_ops); -if (chip && chip->hw_ip_version ==SOF_INTEL_ACE_2_0 ) +if (chip && chip->hw_ip_version >=SOF_INTEL_ACE_2_0 ) bus->use_pio_for_commands = true;#else snd_hdac_ext_bus_init (bus, dev,NULL ,NULL );
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 577/626 ASoc: SOF: topology: connect DAI to a single DAI link
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kai Vehmanen <[email protected]>
commit 6052f05254b4fe7b16bbd8224779af52fba98b71 upstream.
The partial matching of DAI widget to link names, can cause problems if one of the widget names is a substring of another. E.g. with names "Foo1" and Foo10", it's not possible to correctly link up "Foo1".
Modify the logic so that if multiple DAI links match the widget stream name, prioritize a full match if one is found.
--- sound/soc/sof/topology.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-)
sound/soc/sof/topology.c +14 -4
@@ -1059,7 +1059,7 @@ static int sof_connect_dai_widget(struct struct snd_sof_dai *dai) {struct snd_soc_card *card = scomp->card; -struct snd_soc_pcm_runtime *rtd; +struct snd_soc_pcm_runtime *rtd, *full, *partial;struct snd_soc_dai *cpu_dai;int stream;int i;
@@ -1076,12 +1076,22 @@ static int sof_connect_dai_widget(structelse goto end; + full =NULL ; + partial =NULL ;list_for_each_entry (rtd, &card->rtd_list, list) {/* does stream match DAI link ? */ -if (!rtd->dai_link->stream_name || - !strstr (rtd->dai_link->stream_name, w->sname)) -continue ; +if (rtd->dai_link->stream_name) { +if (!strcmp (rtd->dai_link->stream_name, w->sname)) { + full = rtd; +break ; + }else if (strstr (rtd->dai_link->stream_name, w->sname)) { + partial = rtd; + } + } + } + rtd = full ? full : partial; +if (rtd) {for_each_rtd_cpu_dais (rtd, i, cpu_dai) {/* * Please create DAI widget in the right order
Greg Kroah-Hartman
maintainerPATCH 578/626 ASoC: SOF: ipc4-pcm: Delay reporting is only supported for playback direction
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit 98db16f314b3a0d6e5acd94708ea69751436467f upstream.
The firmware does not provide any information for capture streams via the shared pipeline registers.
To avoid reporting invalid delay value for capture streams to user space we need to disable it.
--- sound/soc/sof/ipc4-pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/soc/sof/ipc4-pcm.c +2 -1
@@ -794,7 +794,8 @@ static int sof_ipc4_pcm_setup(struct snd spcm->stream[stream].private = stream_priv; -if (!support_info) +/* Delay reporting is only supported on playback */ +if (!support_info || stream ==SNDRV_PCM_STREAM_CAPTURE )continue ; time_info =kzalloc (sizeof (*time_info),GFP_KERNEL );
Greg Kroah-Hartman
maintainerPATCH 579/626 ALSA: pcm: Fix race of buffer access at PCM OSS layer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 93a81ca0657758b607c3f4ba889ae806be9beb73 upstream.
The PCM OSS layer tries to clear the buffer with the silence data at initialization (or reconfiguration) of a stream with the explicit call of snd_pcm_format_set_silence() with runtime->dma_area. But this may lead to a UAF because the accessed runtime->dma_area might be freed concurrently, as it's performed outside the PCM ops.
For avoiding it, move the code into the PCM core and perform it inside the buffer access lock, so that it won't be changed during the operation.
--- include/sound/pcm.h | 2 ++ sound/core/oss/pcm_oss.c | 3 +-- sound/core/pcm_native.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-)
include/sound/pcm.h +2 -0
@@ -1428,6 +1428,8 @@ int snd_pcm_lib_mmap_iomem(struct snd_pc#define snd_pcm_lib_mmap_iomem NULL#endif +void snd_pcm_runtime_buffer_set_silence (struct snd_pcm_runtime *runtime); +/** * snd_pcm_limit_isa_dma_size - Get the max size fitting with ISA DMA transfer * @dma: DMA number
sound/core/oss/pcm_oss.c +1 -2
@@ -1074,8 +1074,7 @@ static int snd_pcm_oss_change_params_loc runtime->oss.params =0 ; runtime->oss.prepare =1 ; runtime->oss.buffer_used =0 ; -if (runtime->dma_area) -snd_pcm_format_set_silence (runtime->format, runtime->dma_area,bytes_to_samples (runtime, runtime->dma_bytes)); +snd_pcm_runtime_buffer_set_silence (runtime); runtime->oss.period_frames =snd_pcm_alsa_frames (substream, oss_period_size);
sound/core/pcm_native.c +11 -0
@@ -723,6 +723,17 @@ static void snd_pcm_buffer_access_unlockatomic_inc (&runtime->buffer_accessing); } +/* fill the PCM buffer with the current silence format; called from pcm_oss.c */ +void snd_pcm_runtime_buffer_set_silence (struct snd_pcm_runtime *runtime) +{ +snd_pcm_buffer_access_lock (runtime); +if (runtime->dma_area) +snd_pcm_format_set_silence (runtime->format, runtime->dma_area, +bytes_to_samples (runtime, runtime->dma_bytes)); +snd_pcm_buffer_access_unlock (runtime); +} +EXPORT_SYMBOL_GPL (snd_pcm_runtime_buffer_set_silence); +#if IS_ENABLED (CONFIG_SND_PCM_OSS )#define is_oss_stream (substream) ((substream)->oss.oss)#else
Greg Kroah-Hartman
maintainerPATCH 580/626 ALSA: hda/realtek: Add quirk for Lenovo Yoga Pro 7 14ASP10
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ed Burcher <[email protected]>
commit 8d70503068510e6080c2c649cccb154f16de26c9 upstream.
Lenovo Yoga Pro 7 (gen 10) with Realtek ALC3306 and combined CS35L56 amplifiers need quirk ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN to enable bass
--- sound/pci/hda/patch_realtek.c | 1 + 1 file changed, 1 insertion(+)
sound/pci/hda/patch_realtek.c +1 -0
@@ -11182,6 +11182,7 @@ static const struct hda_quirk alc269_fixSND_PCI_QUIRK (0x17aa ,0x38fa ,"Thinkbook 16P Gen5" ,ALC287_FIXUP_MG_RTKC_CSAMP_CS35L41_I2C_THINKPAD ),SND_PCI_QUIRK (0x17aa ,0x38fd ,"ThinkBook plus Gen5 Hybrid" ,ALC287_FIXUP_TAS2781_I2C ),SND_PCI_QUIRK (0x17aa ,0x3902 ,"Lenovo E50-80" ,ALC269_FIXUP_DMIC_THINKPAD_ACPI ), +SND_PCI_QUIRK (0x17aa ,0x390d ,"Lenovo Yoga Pro 7 14ASP10" ,ALC287_FIXUP_YOGA9_14IAP7_BASS_SPK_PIN ),SND_PCI_QUIRK (0x17aa ,0x3913 ,"Lenovo 145" ,ALC236_FIXUP_LENOVO_INV_DMIC ),SND_PCI_QUIRK (0x17aa ,0x391f ,"Yoga S990-16 pro Quad YC Quad" ,ALC287_FIXUP_TAS2781_I2C ), SND_PCI_QUIRK(0x17aa, 0x3920, "Yoga S990-16 pro Quad VECO Quad", ALC287_FIXUP_TAS2781_I2C),
Greg Kroah-Hartman
maintainerPATCH 581/626 llc: fix data loss when reading from a socket in llc_ui_recvmsg()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ilia Gavrilov <[email protected]>
commit 239af1970bcb039a1551d2c438d113df0010c149 upstream.
For SOCK_STREAM sockets, if user buffer size (len) is less than skb size (skb->len), the remaining data from skb will be lost after calling kfree_skb().
To fix this, move the statement for partial reading above skb deletion.
Found by InfoTeCS on behalf of Linux Verification Center (linuxtesting.org)
--- net/llc/af_llc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/llc/af_llc.c +4 -4
@@ -887,15 +887,15 @@ static int llc_ui_recvmsg(struct socketif (sk->sk_type !=SOCK_STREAM ) goto copy_uaddr; +/* Partial read */ +if (used + offset < skb_len) +continue ; +if (!(flags &MSG_PEEK )) {skb_unlink (skb, &sk->sk_receive_queue);kfree_skb (skb); *seq =0 ; } - -/* Partial read */ -if (used + offset < skb_len) -continue ; }while (len >0 ); out:
Greg Kroah-Hartman
maintainerPATCH 582/626 can: kvaser_pciefd: Continue parsing DMA buf after dropped RX
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Forsman <[email protected]>
commit 6d820b81c4dc4a4023e45c3cd6707a07dd838649 upstream.
Going bus-off on a channel doing RX could result in dropped packets.
As netif_running() gets cleared before the channel abort procedure, the handling of any last RDATA packets would see netif_rx() return non-zero to signal a dropped packet. kvaser_pciefd_read_buffer() dealt with this "error" by breaking out of processing the remaining DMA RX buffer.
Only return an error from kvaser_pciefd_read_buffer() due to packet corruption, otherwise handle it internally.
--- drivers/net/can/kvaser_pciefd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/net/can/kvaser_pciefd.c +5 -3
@@ -1200,7 +1200,7 @@ static int kvaser_pciefd_handle_data_pac skb =alloc_canfd_skb (priv->dev, &cf);if (!skb) { priv->dev->stats.rx_dropped++; -return -ENOMEM ; +return 0 ; } cf->len =can_fd_dlc2len (dlc);
@@ -1212,7 +1212,7 @@ static int kvaser_pciefd_handle_data_pac skb =alloc_can_skb (priv->dev, (struct can_frame **)&cf);if (!skb) { priv->dev->stats.rx_dropped++; -return -ENOMEM ; +return 0 ; }can_frame_set_cc_len ((struct can_frame *)cf, dlc, priv->ctrlmode); }
@@ -1230,7 +1230,9 @@ static int kvaser_pciefd_handle_data_pac priv->dev->stats.rx_packets++;kvaser_pciefd_set_skb_timestamp (pcie, skb, p->timestamp); -return netif_rx (skb); +netif_rx (skb); + +return 0 ; } static void kvaser_pciefd_change_state(struct kvaser_pciefd_can *can,
Greg Kroah-Hartman
maintainerPATCH 583/626 can: kvaser_pciefd: Fix echo_skb race
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Forsman <[email protected]>
commit 8256e0ca601051933e9395746817f3801fa9a6bf upstream.
The functions kvaser_pciefd_start_xmit() and kvaser_pciefd_handle_ack_packet() raced to stop/wake TX queues and get/put echo skbs, as kvaser_pciefd_can->echo_lock was only ever taken when transmitting and KCAN_TX_NR_PACKETS_CURRENT gets decremented prior to handling of ACKs. E.g., this caused the following error:
can_put_echo_skb: BUG! echo_skb 5 is occupied!
Instead, use the synchronization helpers in netdev_queues.h. As those piggyback on BQL barriers, start updating in-flight packets and bytes counts as well.
--- drivers/net/can/kvaser_pciefd.c | 93 +++++++++++++++++++++++++--------------- 1 file changed, 59 insertions(+), 34 deletions(-)
drivers/net/can/kvaser_pciefd.c +59 -34
@@ -16,6 +16,7 @@#include <linux/netdevice.h> #include <linux/pci.h> #include <linux/timer.h> +#include <net/netdev_queues.h> MODULE_LICENSE ("Dual BSD/GPL" );MODULE_AUTHOR ("Kvaser AB <[email protected]>" );
@@ -410,10 +411,13 @@ struct kvaser_pciefd_can {void __iomem *reg_base;struct can_berr_counter bec;u8 cmd_seq; +u8 tx_max_count; +u8 tx_idx; +u8 ack_idx;int err_rep_cnt; -int echo_idx; +unsigned int completed_tx_pkts; +unsigned int completed_tx_bytes;spinlock_t lock;/* Locks sensitive registers (e.g. MODE) */ -spinlock_t echo_lock;/* Locks the message echo buffer */ struct timer_list bec_poll_timer;struct completion start_comp, flush_comp; };
@@ -714,6 +718,9 @@ static int kvaser_pciefd_open(struct netint ret;struct kvaser_pciefd_can *can =netdev_priv (netdev); + can->tx_idx =0 ; + can->ack_idx =0 ; + ret =open_candev (netdev);if (ret)return ret;
@@ -745,21 +752,26 @@ static int kvaser_pciefd_stop(struct netdel_timer (&can->bec_poll_timer); } can->can.state =CAN_STATE_STOPPED ; +netdev_reset_queue (netdev);close_candev (netdev);return ret; } +static unsigned int kvaser_pciefd_tx_avail (const struct kvaser_pciefd_can *can) +{ +return can->tx_max_count - (READ_ONCE (can->tx_idx) -READ_ONCE (can->ack_idx)); +} +static int kvaser_pciefd_prepare_tx_packet (struct kvaser_pciefd_tx_packet *p, -struct kvaser_pciefd_can *can, +struct can_priv *can,u8 seq,struct sk_buff *skb) {struct canfd_frame *cf = (struct canfd_frame *)skb->data;int packet_size; -int seq = can->echo_idx;memset (p,0 ,sizeof (*p)); -if (can->can.ctrlmode &CAN_CTRLMODE_ONE_SHOT ) +if (can->ctrlmode &CAN_CTRLMODE_ONE_SHOT ) p->header[1 ] |=KVASER_PCIEFD_TPACKET_SMS ;if (cf->can_id &CAN_RTR_FLAG )
@@ -782,7 +794,7 @@ static int kvaser_pciefd_prepare_tx_pack }else { p->header[1 ] |=FIELD_PREP (KVASER_PCIEFD_RPACKET_DLC_MASK , -can_get_cc_dlc ((struct can_frame *)cf, can->can.ctrlmode)); +can_get_cc_dlc ((struct can_frame *)cf, can->ctrlmode)); } p->header[1 ] |=FIELD_PREP (KVASER_PCIEFD_PACKET_SEQ_MASK , seq);
@@ -797,22 +809,24 @@ static netdev_tx_t kvaser_pciefd_start_x struct net_device *netdev) {struct kvaser_pciefd_can *can =netdev_priv (netdev); -unsigned long irq_flags;struct kvaser_pciefd_tx_packet packet; +unsigned int seq = can->tx_idx & (can->can.echo_skb_max -1 ); +unsigned int frame_len;int nr_words; -u8 count;if (can_dev_dropped_skb (netdev, skb))return NETDEV_TX_OK ; +if (!netif_subqueue_maybe_stop (netdev,0 ,kvaser_pciefd_tx_avail (can),1 ,1 )) +return NETDEV_TX_BUSY ; - nr_words =kvaser_pciefd_prepare_tx_packet (&packet, can, skb); + nr_words =kvaser_pciefd_prepare_tx_packet (&packet, &can->can, seq, skb); -spin_lock_irqsave (&can->echo_lock, irq_flags);/* Prepare and save echo skb in internal slot */ -can_put_echo_skb (skb, netdev, can->echo_idx,0 ); - -/* Move echo index to the next slot */ - can->echo_idx = (can->echo_idx +1 ) % can->can.echo_skb_max; +WRITE_ONCE (can->can.echo_skb[seq],NULL ); + frame_len =can_skb_get_frame_len (skb); +can_put_echo_skb (skb, netdev, seq, frame_len); +netdev_sent_queue (netdev, frame_len); +WRITE_ONCE (can->tx_idx, can->tx_idx +1 );/* Write header to fifo */ iowrite32(packet.header[0],
@@ -836,14 +850,7 @@ static netdev_tx_t kvaser_pciefd_start_x KVASER_PCIEFD_KCAN_FIFO_LAST_REG); } - count =FIELD_GET (KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK , -ioread32 (can->reg_base +KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG )); -/* No room for a new message, stop the queue until at least one -* successful transmit -*/ -if (count >= can->can.echo_skb_max || can->can.echo_skb[can->echo_idx]) -netif_stop_queue (netdev); -spin_unlock_irqrestore (&can->echo_lock, irq_flags); +netif_subqueue_maybe_stop (netdev,0 ,kvaser_pciefd_tx_avail (can),1 ,1 );return NETDEV_TX_OK ; }
@@ -970,6 +977,8 @@ static int kvaser_pciefd_setup_can_ctrls can->kv_pcie = pcie; can->cmd_seq =0 ; can->err_rep_cnt =0 ; + can->completed_tx_pkts =0 ; + can->completed_tx_bytes =0 ; can->bec.txerr =0 ; can->bec.rxerr =0 ;
@@ -983,11 +992,10 @@ static int kvaser_pciefd_setup_can_ctrls tx_nr_packets_max =FIELD_GET (KVASER_PCIEFD_KCAN_TX_NR_PACKETS_MAX_MASK ,ioread32 (can->reg_base +KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG )); + can->tx_max_count =min (KVASER_PCIEFD_CAN_TX_MAX_COUNT , tx_nr_packets_max -1 ); can->can.clock.freq = pcie->freq; - can->can.echo_skb_max =min (KVASER_PCIEFD_CAN_TX_MAX_COUNT , tx_nr_packets_max -1 ); - can->echo_idx =0 ; -spin_lock_init (&can->echo_lock); + can->can.echo_skb_max =roundup_pow_of_two (can->tx_max_count);spin_lock_init (&can->lock); can->can.bittiming_const = &kvaser_pciefd_bittiming_const;
@@ -1509,19 +1517,21 @@ static int kvaser_pciefd_handle_ack_packnetdev_dbg (can->can.dev,"Packet was flushed\n" ); }else {int echo_idx =FIELD_GET (KVASER_PCIEFD_PACKET_SEQ_MASK , p->header[0 ]); -int len; -u8 count; +unsigned int len, frame_len =0 ;struct sk_buff *skb; +if (echo_idx != (can->ack_idx & (can->can.echo_skb_max -1 ))) +return 0 ; skb = can->can.echo_skb[echo_idx]; -if (skb) -kvaser_pciefd_set_skb_timestamp (pcie, skb, p->timestamp); - len =can_get_echo_skb (can->can.dev, echo_idx,NULL ); - count =FIELD_GET (KVASER_PCIEFD_KCAN_TX_NR_PACKETS_CURRENT_MASK , -ioread32 (can->reg_base +KVASER_PCIEFD_KCAN_TX_NR_PACKETS_REG )); +if (!skb) +return 0 ; +kvaser_pciefd_set_skb_timestamp (pcie, skb, p->timestamp); + len =can_get_echo_skb (can->can.dev, echo_idx, &frame_len); -if (count < can->can.echo_skb_max &&netif_queue_stopped (can->can.dev)) -netif_wake_queue (can->can.dev); +/* Pairs with barrier in kvaser_pciefd_start_xmit() */ +smp_store_release (&can->ack_idx, can->ack_idx +1 ); + can->completed_tx_pkts++; + can->completed_tx_bytes += frame_len;if (!one_shot_fail) { can->can.dev->stats.tx_bytes += len;
@@ -1637,11 +1647,26 @@ static int kvaser_pciefd_read_buffer(str {int pos =0 ;int res =0 ; +unsigned int i;do { res =kvaser_pciefd_read_packet (pcie, &pos, dma_buf); }while (!res && pos >0 && pos <KVASER_PCIEFD_DMA_SIZE ); +/* Report ACKs in this buffer to BQL en masse for correct periods */ +for (i =0 ; i < pcie->nr_channels; ++i) { +struct kvaser_pciefd_can *can = pcie->can[i]; + +if (!can->completed_tx_pkts) +continue ; +netif_subqueue_completed_wake (can->can.dev,0 , + can->completed_tx_pkts, + can->completed_tx_bytes, +kvaser_pciefd_tx_avail (can),1 ); + can->completed_tx_pkts =0 ; + can->completed_tx_bytes =0 ; + } +return res; }
Greg Kroah-Hartman
maintainerPATCH 584/626 net: dsa: microchip: linearize skb for tail-tagging switches
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jakob Unterwurzacher <[email protected]>
commit ba54bce747fa9e07896c1abd9b48545f7b4b31d2 upstream.
The pointer arithmentic for accessing the tail tag only works for linear skbs.
For nonlinear skbs, it reads uninitialized memory inside the skb headroom, essentially randomizing the tag. I have observed it gets set to 6 most of the time.
Example where ksz9477_rcv thinks that the packet from port 1 comes from port 6 (which does not exist for the ksz9896 that's in use), dropping the packet. Debug prints added by me (not included in this patch):
[ 256.645337] ksz9477_rcv:323 tag0=6 [ 256.645349] skb len=47 headroom=78 headlen=0 tailroom=0 mac=(64,14) mac_len=14 net=(78,0) trans=78 shinfo(txflags=0 nr_frags=1 gso(size=0 type=0 segs=0)) csum(0x0 start=0 offset=0 ip_summed=0 complete_sw=0 valid=0 level=0) hash(0x0 sw=0 l4=0) proto=0x00f8 pkttype=1 iif=3 priority=0x0 mark=0x0 alloc_cpu=0 vlan_all=0x0 encapsulation=0 inner(proto=0x0000, mac=0, net=0, trans=0) [ 256.645377] dev name=end1 feat=0x0002e10200114bb3 [ 256.645386] skb headroom: 00000000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 256.645395] skb headroom: 00000010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 256.645403] skb headroom: 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 256.645411] skb headroom: 00000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 [ 256.645420] skb headroom: 00000040: ff ff ff ff ff ff 00 1c 19 f2 e2 db 08 06 [ 256.645428] skb frag: 00000000: 00 01 08 00 06 04 00 01 00 1c 19 f2 e2 db 0a 02 [ 256.645436] skb frag: 00000010: 00 83 00 00 00 00 00 00 0a 02 a0 2f 00 00 00 00 [ 256.645444] skb frag: 00000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 [ 256.645452] ksz_common_rcv:92 dsa_conduit_find_user returned NULL
Call skb_linearize before trying to access the tag.
This patch fixes ksz9477_rcv which is used by the ksz9896 I have at hand, and also applies the same fix to ksz8795_rcv which seems to have the same problem.
--- net/dsa/tag_ksz.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
net/dsa/tag_ksz.c +15 -4
@@ -140,7 +140,12 @@ static struct sk_buff *ksz8795_xmit(strustatic struct sk_buff *ksz8795_rcv (struct sk_buff *skb,struct net_device *dev) { -u8 *tag =skb_tail_pointer (skb) -KSZ_EGRESS_TAG_LEN ; +u8 *tag; + +if (skb_linearize (skb)) +return NULL ; + + tag =skb_tail_pointer (skb) -KSZ_EGRESS_TAG_LEN ;return ksz_common_rcv (skb, dev, tag[0 ] &KSZ8795_TAIL_TAG_EG_PORT_M ,KSZ_EGRESS_TAG_LEN );
@@ -311,10 +316,16 @@ static struct sk_buff *ksz9477_xmit(strustatic struct sk_buff *ksz9477_rcv (struct sk_buff *skb,struct net_device *dev) { -/* Tag decoding */ -u8 *tag =skb_tail_pointer (skb) -KSZ_EGRESS_TAG_LEN ; -unsigned int port = tag[0 ] &KSZ9477_TAIL_TAG_EG_PORT_M ;unsigned int len =KSZ_EGRESS_TAG_LEN ; +unsigned int port; +u8 *tag; + +if (skb_linearize (skb)) +return NULL ; + +/* Tag decoding */ + tag =skb_tail_pointer (skb) -KSZ_EGRESS_TAG_LEN ; + port = tag[0 ] &KSZ9477_TAIL_TAG_EG_PORT_M ;/* Extra 4-bytes PTP timestamp */ if (tag[0 ] &KSZ9477_PTP_TAG_INDICATION ) {
Greg Kroah-Hartman
maintainerPATCH 585/626 vmxnet3: update MTU after device quiesce
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ronak Doshi <[email protected]>
commit 43f0999af011fba646e015f0bb08b6c3002a0170 upstream.
Currently, when device mtu is updated, vmxnet3 updates netdev mtu, quiesces the device and then reactivates it for the ESXi to know about the new mtu. So, technically the OS stack can start using the new mtu before ESXi knows about the new mtu.
This can lead to issues for TSO packets which use mss as per the new mtu configured. This patch fixes this issue by moving the mtu write after device quiesce.
Changes v1-> v2:
Moved MTU write after destroy of rx rings
--- drivers/net/vmxnet3/vmxnet3_drv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/vmxnet3/vmxnet3_drv.c +3 -2
@@ -3599,8 +3599,6 @@ vmxnet3_change_mtu(struct net_device *nestruct vmxnet3_adapter *adapter =netdev_priv (netdev);int err =0 ; -WRITE_ONCE (netdev->mtu, new_mtu); -/* * Reset_work may be in the middle of resetting the device, wait for its * completion.
@@ -3614,6 +3612,7 @@ vmxnet3_change_mtu(struct net_device *ne/* we need to re-create the rx queue based on the new mtu */ vmxnet3_rq_destroy_all (adapter); +WRITE_ONCE (netdev->mtu, new_mtu);vmxnet3_adjust_rx_ring_size (adapter); err =vmxnet3_rq_create_all (adapter);if (err) {
@@ -3630,6 +3629,8 @@ vmxnet3_change_mtu(struct net_device *ne "Closing it\n", err); goto out; } + }else { +WRITE_ONCE (netdev->mtu, new_mtu); } out:
Greg Kroah-Hartman
maintainerPATCH 586/626 pmdomain: renesas: rcar: Remove obsolete nullify checks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit 13a6d4265665201a795a2ff5a3e6e4d183fc9c33 upstream.
All nullify users and helpers were removed, but the R-Car SYSC drivers still checked for nullified domains. Remove the obsolete checks.
--- drivers/pmdomain/renesas/rcar-gen4-sysc.c | 5 ----- drivers/pmdomain/renesas/rcar-sysc.c | 5 ----- 2 files changed, 10 deletions(-)
drivers/pmdomain/renesas/rcar-gen4-sysc.c +0 -5
@@ -338,11 +338,6 @@ static int __init rcar_gen4_sysc_pd_init(void)struct rcar_gen4_sysc_pd *pd;size_t n; -if (!area->name) { -/* Skip NULLified area */ -continue ; - } - n =strlen (area->name) +1 ; pd =kzalloc (sizeof (*pd) + n,GFP_KERNEL );if (!pd) {
drivers/pmdomain/renesas/rcar-sysc.c +0 -5
@@ -396,11 +396,6 @@ static int __init rcar_sysc_pd_init(void)struct rcar_sysc_pd *pd;size_t n; -if (!area->name) { -/* Skip NULLified area */ -continue ; - } - n =strlen (area->name) +1 ; pd =kzalloc (sizeof (*pd) + n,GFP_KERNEL );if (!pd) {
Signature · 1 line
2.49.0
Greg Kroah-Hartman
maintainerPATCH 587/626 pmdomain: core: Fix error checking in genpd_dev_pm_attach_by_id()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 0f5757667ec0aaf2456c3b76fcf0c6c3ea3591fe upstream.
The error checking for of_count_phandle_with_args() does not handle negative error codes correctly. The problem is that "index" is a u32 so in the condition "if (index >= num_domains)" negative error codes stored in "num_domains" are type promoted to very high positive values and "index" is always going to be valid.
Test for negative error codes first and then test if "index" is valid.
--- drivers/pmdomain/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pmdomain/core.c +1 -1
@@ -3043,7 +3043,7 @@ struct device *genpd_dev_pm_attach_by_id/* Verify that the index is within a valid range. */ num_domains =of_count_phandle_with_args (dev->of_node,"power-domains" ,"#power-domain-cells" ); -if (index >= num_domains) +if (num_domains <0 || index >= num_domains)return NULL ;/* Allocate and register device on the genpd bus. */
Greg Kroah-Hartman
maintainerPATCH 588/626 platform/x86: dell-wmi-sysman: Avoid buffer overflow in current_password_store()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vladimir Moskovkin <[email protected]>
commit 4e89a4077490f52cde652d17e32519b666abf3a6 upstream.
If the 'buf' array received from the user contains an empty string, the 'length' variable will be zero. Accessing the 'buf' array element with index 'length - 1' will result in a buffer overflow.
Add a check for an empty string.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/dell/dell-wmi-sysman/passobj-attributes.c +1 -1
@@ -45,7 +45,7 @@ static ssize_t current_password_store(stint length; length =strlen (buf); -if (buf[length-1 ] =='\n' ) +if (length && buf[length -1 ] =='\n' ) length--;/* firmware does verifiation of min/max password length,
Greg Kroah-Hartman
maintainerPATCH 589/626 thermal: intel: x86_pkg_temp_thermal: Fix bogus trip temperature
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Rui <[email protected]>
commit cf948c8e274e8b406e846cdf6cc48fe47f98cf57 upstream.
The tj_max value obtained from the Intel TCC library are in Celsius, whereas the thermal subsystem operates in milli-Celsius.
This discrepancy leads to incorrect trip temperature calculations.
Fix bogus trip temperature by converting tj_max to milli-Celsius Unit.
--- drivers/thermal/intel/x86_pkg_temp_thermal.c | 1 + 1 file changed, 1 insertion(+)
drivers/thermal/intel/x86_pkg_temp_thermal.c +1 -0
@@ -329,6 +329,7 @@ static int pkg_temp_thermal_device_add(u tj_max =intel_tcc_get_tjmax (cpu);if (tj_max <0 )return tj_max; + tj_max *=1000 ; zonedev =kzalloc (sizeof (*zonedev),GFP_KERNEL );if (!zonedev)
Greg Kroah-Hartman
maintainerPATCH 590/626 drm/edid: fixed the bug that hdr metadata was not reset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: feijuan.li <[email protected]>
commit 6692dbc15e5ed40a3aa037aced65d7b8826c58cd upstream.
When DP connected to a device with HDR capability, the hdr structure was filled.Then connected to another sink device without hdr capability, but the hdr info still exist.
--- drivers/gpu/drm/drm_edid.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_edid.c +1 -0
@@ -6596,6 +6596,7 @@ static void drm_reset_display_info(struc info->has_hdmi_infoframe = false; info->rgb_quant_range_selectable = false;memset (&info->hdmi,0 ,sizeof (info->hdmi)); +memset (&connector->hdr_sink_metadata,0 ,sizeof (connector->hdr_sink_metadata)); info->edid_hdmi_rgb444_dc_modes =0 ; info->edid_hdmi_ycbcr444_dc_modes =0 ;
Greg Kroah-Hartman
maintainerPATCH 591/626 smb: client: Fix use-after-free in cifs_fill_dirent
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Zhaolong <[email protected]>
commit a7a8fe56e932a36f43e031b398aef92341bf5ea0 upstream.
There is a race condition in the readdir concurrency process, which may access the rsp buffer after it has been released, triggering the following KASAN warning.
==================================================================
BUG: KASAN: slab-use-after-free in cifs_fill_dirent+0xb03/0xb60 [cifs]
Read of size 4 at addr ffff8880099b819c by task a.out/342975
CPU: 2 UID: 0 PID: 342975 Comm: a.out Not tainted 6.15.0-rc6+ #240 PREEMPT(full)
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.1-2.fc37 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x53/0x70
print_report+0xce/0x640
kasan_report+0xb8/0xf0
cifs_fill_dirent+0xb03/0xb60 [cifs]
cifs_readdir+0x12cb/0x3190 [cifs]
iterate_dir+0x1a1/0x520
__x64_sys_getdents+0x134/0x220
do_syscall_64+0x4b/0x110
entry_SYSCALL_64_after_hwframe+0x76/0x7e
RIP: 0033:0x7f996f64b9f9
Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 89 f8 48 89
f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01
f0 ff ff 0d f7 c3 0c 00 f7 d8 64 89 8
RSP: 002b:00007f996f53de78 EFLAGS: 00000207 ORIG_RAX: 000000000000004e
RAX: ffffffffffffffda RBX: 00007f996f53ecdc RCX: 00007f996f64b9f9
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000003
RBP: 00007f996f53dea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000207 R12: ffffffffffffff88
R13: 0000000000000000 R14: 00007ffc8cd9a500 R15: 00007f996f51e000
</TASK>
Allocated by task 408:
kasan_save_stack+0x20/0x40
kasan_save_track+0x14/0x30
__kasan_slab_alloc+0x6e/0x70
kmem_cache_alloc_noprof+0x117/0x3d0
mempool_alloc_noprof+0xf2/0x2c0
cifs_buf_get+0x36/0x80 [cifs]
allocate_buffers+0x1d2/0x330 [cifs]
cifs_demultiplex_thread+0x22b/0x2690 [cifs]
kthread+0x394/0x720
ret_from_fork+0x34/0x70
ret_from_fork_asm+0x1a/0x30
Freed by task 342979:
kasan_save_stack+0x20/0x40
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x37/0x50
kmem_cache_free+0x2b8/0x500
cifs_buf_release+0x3c/0x70 [cifs]
cifs_readdir+0x1c97/0x3190 [cifs]
iterate_dir+0x1a1/0x520
__x64_sys_getdents64+0x134/0x220
do_syscall_64+0x4b/0x110
entry_SYSCALL_64_after_hwframe+0x76/0x7e
The buggy address belongs to the object at ffff8880099b8000
which belongs to the cache cifs_request of size 16588
The buggy address is located 412 bytes inside of
freed 16588-byte region [ffff8880099b8000, ffff8880099bc0cc)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x99b8
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
anon flags: 0x80000000000040(head|node=0|zone=1)
page_type: f5(slab)
raw: 0080000000000040 ffff888001e03400 0000000000000000 dead000000000001
raw: 0000000000000000 0000000000010001 00000000f5000000 0000000000000000
head: 0080000000000040 ffff888001e03400 0000000000000000 dead000000000001
head: 0000000000000000 0000000000010001 00000000f5000000 0000000000000000
head: 0080000000000003 ffffea0000266e01 00000000ffffffff 00000000ffffffff
head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8880099b8080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880099b8100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8880099b8180: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8880099b8200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
ffff8880099b8280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================POC is available in the link [1].
The problem triggering process is as follows:
Process 1 Process 2
-----------------------------------------------------------------cifs_readdir
/* file->private_data == NULL */
initiate_cifs_search
cifsFile = kzalloc(sizeof(struct cifsFileInfo), GFP_KERNEL);
smb2_query_dir_first ->query_dir_first()
SMB2_query_directory
SMB2_query_directory_init
cifs_send_recv
smb2_parse_query_directory
srch_inf->ntwrk_buf_start = (char *)rsp;
srch_inf->srch_entries_start = (char *)rsp + ...
srch_inf->last_entry = (char *)rsp + ...
srch_inf->smallBuf = true;
find_cifs_entry
/* if (cfile->srch_inf.ntwrk_buf_start) */
cifs_small_buf_release(cfile->srch_inf // free
cifs_readdir ->iterate_shared()
/* file->private_data != NULL */
find_cifs_entry
/* in while (...) loop */
smb2_query_dir_next ->query_dir_next()
SMB2_query_directory
SMB2_query_directory_init
cifs_send_recv
compound_send_recv
smb_send_rqst
__smb_send_rqst
rc = -ERESTARTSYS;
/* if (fatal_signal_pending()) */
goto out;
return rc
/* if (cfile->srch_inf.last_entry) */
cifs_save_resume_key()
cifs_fill_dirent // UAF
/* if (rc) */
return -ENOENT;Fix this by ensuring the return code is checked before using pointers from the srch_inf.
--- fs/smb/client/readdir.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/readdir.c +2 -2
@@ -756,11 +756,11 @@ find_cifs_entry(const unsigned int xid, rc = server->ops->query_dir_next (xid, tcon, &cfile->fid, search_flags, &cfile->srch_inf); +if (rc) +return -ENOENT ;/* FindFirst/Next set last_entry to NULL on malformed reply */ if (cfile->srch_inf.last_entry)cifs_save_resume_key (cfile->srch_inf.last_entry, cfile); -if (rc) -return -ENOENT ; }if (index_to_find < cfile->srch_inf.index_of_last_entry) {/* we found the buffer that contains the entry */
Greg Kroah-Hartman
maintainerPATCH 592/626 arm64: dts: marvell: uDPU: define pinctrl state for alarm LEDs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabor Juhos <[email protected]>
commit b04f0d89e880bc2cca6a5c73cf287082c91878da upstream.
The two alarm LEDs of on the uDPU board are stopped working since commit 78efa53e715e ("leds: Init leds class earlier").
The LEDs are driven by the GPIO{15,16} pins of the North Bridge GPIO controller. These pins are part of the 'spi_quad' pin group for which the 'spi' function is selected via the default pinctrl state of the 'spi' node. This is wrong however, since in order to allow controlling the LEDs, the pins should use the 'gpio' function.
Before the commit mentined above, the 'spi' function is selected first by the pinctrl core before probing the spi driver, but then it gets overridden to 'gpio' implicitly via the devm_gpiod_get_index_optional() call from the 'leds-gpio' driver.
After the commit, the LED subsystem gets initialized before the SPI subsystem, so the function of the pin group remains 'spi' which in turn prevents controlling of the LEDs.
Despite the change of the initialization order, the root cause is that the pinctrl state definition is wrong since its initial commit 0d45062cfc89 ("arm64: dts: marvell: Add device tree for uDPU board"),
To fix the problem, override the function in the 'spi_quad_pins' node to 'gpio' and move the pinctrl state definition from the 'spi' node into the 'leds' node.
--- arch/arm64/boot/dts/marvell/armada-3720-uDPU.dtsi | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/marvell/armada-3720-uDPU.dtsi +6 -2
@@ -26,6 +26,8 @@ leds { compatible = "gpio-leds"; + pinctrl-names = "default"; + pinctrl-0 = <&spi_quad_pins>; led-power1 { label = "udpu:green:power";
@@ -82,8 +84,6 @@ &spi0 { status = "okay"; - pinctrl-names = "default"; - pinctrl-0 = <&spi_quad_pins>; flash@0 { compatible = "jedec,spi-nor";
@@ -108,6 +108,10 @@ }; }; +&spi_quad_pins { + function = "gpio"; +}; + &pinctrl_nb { i2c2_recovery_pins: i2c2-recovery-pins { groups = "i2c2";
Greg Kroah-Hartman
maintainerPATCH 593/626 smb: client: Reset all search buffer pointers when releasing buffer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wang Zhaolong <[email protected]>
commit e48f9d849bfdec276eebf782a84fd4dfbe1c14c0 upstream.
Multiple pointers in struct cifs_search_info (ntwrk_buf_start, srch_entries_start, and last_entry) point to the same allocated buffer. However, when freeing this buffer, only ntwrk_buf_start was set to NULL, while the other pointers remained pointing to freed memory.
This is defensive programming to prevent potential issues with stale pointers. While the active UAF vulnerability is fixed by the previous patch, this change ensures consistent pointer state and more robust error handling.
--- fs/smb/client/readdir.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/readdir.c +3 -0
@@ -733,7 +733,10 @@ find_cifs_entry(const unsigned int xid,else cifs_buf_release (cfile->srch_inf. ntwrk_buf_start); +/* Reset all pointers to the network buffer to prevent stale references */ cfile->srch_inf.ntwrk_buf_start =NULL ; + cfile->srch_inf.srch_entries_start =NULL ; + cfile->srch_inf.last_entry =NULL ; } rc =initiate_cifs_search (xid, file, full_path);if (rc) {
Greg Kroah-Hartman
maintainerPATCH 594/626 Revert "drm/amd: Keep display off while going into S4"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
commit 7e7cb7a13c81073d38a10fa7b450d23712281ec4 upstream.
commit 68bfdc8dc0a1a ("drm/amd: Keep display off while going into S4") attempted to keep displays off during the S4 sequence by not resuming display IP. This however leads to hangs because DRM clients such as the console can try to access registers and cause a hang.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -5
@@ -3315,11 +3315,6 @@ static int dm_resume(void *handle)return 0 ; } - -/* leave display off for S4 sequence */ -if (adev->in_s4) -return 0 ; -/* Recreate dc_state - DC invalidates it when setting power state to S3. */ dc_state_release (dm_state->context); dm_state->context =dc_state_create (dm->dc,NULL );
Greg Kroah-Hartman
maintainerPATCH 595/626 Input: xpad - add more controllers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vicki Pfau <[email protected]>
commit f0d17942ea3edec191f1c0fc0d2cd7feca8de2f0 upstream.
Adds support for a revision of the Turtle Beach Recon Wired Controller, the Turtle Beach Stealth Ultra, and the PowerA Wired Controller.
--- drivers/input/joystick/xpad.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/input/joystick/xpad.c +3 -0
@@ -289,6 +289,8 @@ static const struct xpad_device { { 0x1038, 0x1430, "SteelSeries Stratus Duo", 0, XTYPE_XBOX360 }, { 0x1038, 0x1431, "SteelSeries Stratus Duo", 0, XTYPE_XBOX360 }, { 0x10f5, 0x7005, "Turtle Beach Recon Controller", 0, XTYPE_XBOXONE }, + { 0x10f5, 0x7008, "Turtle Beach Recon Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, + { 0x10f5, 0x7073, "Turtle Beach Stealth Ultra Controller", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, { 0x11c9, 0x55f0, "Nacon GC-100XF", 0, XTYPE_XBOX360 }, { 0x11ff, 0x0511, "PXN V900", 0, XTYPE_XBOX360 }, { 0x1209, 0x2882, "Ardwiino Controller", 0, XTYPE_XBOX360 },
@@ -353,6 +355,7 @@ static const struct xpad_device { { 0x1ee9, 0x1590, "ZOTAC Gaming Zone", 0, XTYPE_XBOX360 }, { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE }, { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE }, + { 0x20d6, 0x2064, "PowerA Wired Controller for Xbox", MAP_SHARE_BUTTON, XTYPE_XBOXONE }, { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 }, { 0x2345, 0xe00b, "Machenike G5 Pro Controller", 0, XTYPE_XBOX360 }, { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 },
Greg Kroah-Hartman
maintainerPATCH 596/626 Input: synaptics-rmi - fix crash with unsupported versions of F34
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit ca39500f6af9cfe6823dc5aa8fbaed788d6e35b2 upstream.
Sysfs interface for updating firmware for RMI devices is available even when F34 probe fails. The code checks for presence of F34 "container" pointer and then tries to use the function data attached to the sub-device. F34 assigns the function data early, before it knows if probe will succeed, leaving behind a stale pointer.
Fix this by expanding checks to not only test for presence of F34 "container" but also check if there is driver data assigned to the sub-device, and call dev_set_drvdata() only after we are certain that probe is successful.
This is not a complete fix, since F34 will be freed during firmware update, so there is still a race when fetching and accessing this pointer. This race will be addressed in follow-up changes.
--- drivers/input/rmi4/rmi_f34.c | 133 ++++++++++++++++++++++++------------------- 1 file changed, 75 insertions(+), 58 deletions(-)
drivers/input/rmi4/rmi_f34.c +75 -58
@@ -4,6 +4,7 @@* Copyright (C) 2016 Zodiac Inflight Innovations */ +#include "linux/device.h" #include <linux/kernel.h> #include <linux/rmi.h> #include <linux/firmware.h>
@@ -298,39 +299,30 @@ out:return ret; } -static int rmi_f34_status (struct rmi_function *fn) -{ -struct f34_data *f34 =dev_get_drvdata (&fn->dev); - -/* -* The status is the percentage complete, or once complete, -* zero for success or a negative return code. -*/ -return f34->update_status; -} -static ssize_t rmi_driver_bootloader_id_show (struct device *dev,struct device_attribute *dattr,char *buf) {struct rmi_driver_data *data =dev_get_drvdata (dev); -struct rmi_function *fn = data->f34_container; +struct rmi_function *fn;struct f34_data *f34; -if (fn) { - f34 =dev_get_drvdata (&fn->dev); + fn = data->f34_container; +if (!fn) +return -ENODEV ; -if (f34->bl_version ==5 ) -return sysfs_emit (buf,"%c%c\n" , - f34->bootloader_id[0 ], - f34->bootloader_id[1 ]); -else -return sysfs_emit (buf,"V%d.%d\n" , - f34->bootloader_id[1 ], - f34->bootloader_id[0 ]); - } + f34 =dev_get_drvdata (&fn->dev); +if (!f34) +return -ENODEV ; -return 0 ; +if (f34->bl_version ==5 ) +return sysfs_emit (buf,"%c%c\n" , + f34->bootloader_id[0 ], + f34->bootloader_id[1 ]); +else +return sysfs_emit (buf,"V%d.%d\n" , + f34->bootloader_id[1 ], + f34->bootloader_id[0 ]); } static DEVICE_ATTR(bootloader_id, 0444, rmi_driver_bootloader_id_show, NULL);
@@ -343,13 +335,16 @@ static ssize_t rmi_driver_configuration_struct rmi_function *fn = data->f34_container;struct f34_data *f34; -if (fn) { - f34 =dev_get_drvdata (&fn->dev); + fn = data->f34_container; +if (!fn) +return -ENODEV ; -return sysfs_emit (buf,"%s\n" , f34->configuration_id); - } + f34 =dev_get_drvdata (&fn->dev); +if (!f34) +return -ENODEV ; -return 0 ; + +return sysfs_emit (buf,"%s\n" , f34->configuration_id); } static DEVICE_ATTR(configuration_id, 0444,
@@ -365,10 +360,14 @@ static int rmi_firmware_update(struct rmif (!data->f34_container) {dev_warn (dev,"%s: No F34 present!\n" , __func__); -return -EINVAL ; +return -ENODEV ; } f34 =dev_get_drvdata (&data->f34_container->dev); +if (!f34) { +dev_warn (dev,"%s: No valid F34 present!\n" , __func__); +return -ENODEV ; + }if (f34->bl_version >=7 ) {if (data->pdt_props &HAS_BSR ) {
@@ -494,10 +493,18 @@ static ssize_t rmi_driver_update_fw_stat char *buf) {struct rmi_driver_data *data =dev_get_drvdata (dev); -int update_status =0 ; +struct f34_data *f34; +int update_status = -ENODEV ; -if (data->f34_container) - update_status =rmi_f34_status (data->f34_container); +/* +* The status is the percentage complete, or once complete, +* zero for success or a negative return code. +*/ +if (data->f34_container) { + f34 =dev_get_drvdata (&data->f34_container->dev); +if (f34) + update_status = f34->update_status; + }return sysfs_emit (buf,"%d\n" , update_status); }
@@ -517,33 +524,21 @@ static const struct attribute_group rmi_ .attrs = rmi_firmware_attrs, }; -static int rmi_f34_probe (struct rmi_function *fn) +static int rmi_f34v5_probe (struct f34_data *f34) { -struct f34_data *f34; -unsigned char f34_queries[9 ]; +struct rmi_function *fn = f34->fn; +u8 f34_queries[9 ];bool has_config_id; -u8 version = fn->fd.function_version; -int ret; - - f34 =devm_kzalloc (&fn->dev,sizeof (struct f34_data ),GFP_KERNEL ); -if (!f34) -return -ENOMEM ; - - f34->fn = fn; -dev_set_drvdata (&fn->dev, f34); - -/* v5 code only supported version 0, try V7 probe */ -if (version >0 ) -return rmi_f34v7_probe (f34); +int error; f34->bl_version =5 ; - ret =rmi_read_block (fn->rmi_dev, fn->fd.query_base_addr, - f34_queries,sizeof (f34_queries)); -if (ret) { + error =rmi_read_block (fn->rmi_dev, fn->fd.query_base_addr, + f34_queries,sizeof (f34_queries)); +if (error) {dev_err (&fn->dev,"%s: Failed to query properties\n" , __func__); -return ret; +return error; } snprintf(f34->bootloader_id, sizeof(f34->bootloader_id),
@@ -569,11 +564,11 @@ static int rmi_f34_probe(struct rmi_func f34->v5.config_blocks);if (has_config_id) { - ret =rmi_read_block (fn->rmi_dev, fn->fd.control_base_addr, - f34_queries,sizeof (f34_queries)); -if (ret) { + error =rmi_read_block (fn->rmi_dev, fn->fd.control_base_addr, + f34_queries,sizeof (f34_queries)); +if (error) {dev_err (&fn->dev,"Failed to read F34 config ID\n" ); -return ret; +return error; } snprintf(f34->configuration_id, sizeof(f34->configuration_id),
@@ -582,11 +577,33 @@ static int rmi_f34_probe(struct rmi_func f34_queries[2], f34_queries[3]);rmi_dbg (RMI_DEBUG_FN , &fn->dev,"Configuration ID: %s\n" , - f34->configuration_id); + f34->configuration_id); }return 0 ; } + +static int rmi_f34_probe (struct rmi_function *fn) +{ +struct f34_data *f34; +u8 version = fn->fd.function_version; +int error; + + f34 =devm_kzalloc (&fn->dev,sizeof (struct f34_data ),GFP_KERNEL ); +if (!f34) +return -ENOMEM ; + + f34->fn = fn; + +/* v5 code only supported version 0 */ + error = version ==0 ?rmi_f34v5_probe (f34) :rmi_f34v7_probe (f34); +if (error) +return error; + +dev_set_drvdata (&fn->dev, f34); + +return 0 ; +}int rmi_f34_create_sysfs (struct rmi_device *rmi_dev) {
Greg Kroah-Hartman
maintainerPATCH 597/626 highmem: add folio_test_partial_kmap()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
commit 97dfbbd135cb5e4426f37ca53a8fa87eaaa4e376 upstream.
In commit c749d9b7ebbc ("iov_iter: fix copy_page_from_iter_atomic() if KMAP_LOCAL_FORCE_MAP"), Hugh correctly noted that if KMAP_LOCAL_FORCE_MAP is enabled, we must limit ourselves to PAGE_SIZE bytes per call to kmap_local(). The same problem exists in memcpy_from_folio(), memcpy_to_folio(), folio_zero_tail(), folio_fill_tail() and memcpy_from_file_folio(), so add folio_test_partial_kmap() to do this more succinctly.
--- include/linux/highmem.h | 10 +++++----- include/linux/page-flags.h | 7 +++++++ 2 files changed, 12 insertions(+), 5 deletions(-)
include/linux/highmem.h +5 -5
@@ -461,7 +461,7 @@ static inline void memcpy_from_folio(chaconst char *from =kmap_local_folio (folio, offset);size_t chunk = len; -if (folio_test_highmem (folio) && +if (folio_test_partial_kmap (folio) && chunk >PAGE_SIZE -offset_in_page (offset)) chunk =PAGE_SIZE -offset_in_page (offset);memcpy (to, from, chunk);
@@ -489,7 +489,7 @@ static inline void memcpy_to_folio(strucchar *to =kmap_local_folio (folio, offset);size_t chunk = len; -if (folio_test_highmem (folio) && +if (folio_test_partial_kmap (folio) && chunk >PAGE_SIZE -offset_in_page (offset)) chunk =PAGE_SIZE -offset_in_page (offset);memcpy (to, from, chunk);
@@ -522,7 +522,7 @@ static inline __must_check void *folio_z {size_t len =folio_size (folio) - offset; -if (folio_test_highmem (folio)) { +if (folio_test_partial_kmap (folio)) {size_t max =PAGE_SIZE -offset_in_page (offset);while (len > max) {
@@ -560,7 +560,7 @@ static inline void folio_fill_tail(strucVM_BUG_ON (offset + len >folio_size (folio)); -if (folio_test_highmem (folio)) { +if (folio_test_partial_kmap (folio)) {size_t max =PAGE_SIZE -offset_in_page (offset);while (len > max) {
@@ -597,7 +597,7 @@ static inline size_t memcpy_from_file_fosize_t offset =offset_in_folio (folio, pos);char *from =kmap_local_folio (folio, offset); -if (folio_test_highmem (folio)) { +if (folio_test_partial_kmap (folio)) { offset =offset_in_page (offset); len =min_t (size_t, len,PAGE_SIZE - offset); }else
include/linux/page-flags.h +7 -0
@@ -573,6 +573,13 @@ FOLIO_FLAG(readahead, FOLIO_HEAD_PAGE) PAGEFLAG_FALSE(HighMem, highmem)#endif +/* Does kmap_local_folio() only allow access to one page of the folio? */ +#ifdef CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP +#define folio_test_partial_kmap (f) true +#else +#define folio_test_partial_kmap (f) folio_test_highmem(f) +#endif +#ifdef CONFIG_SWAP static __always_inline bool folio_test_swapcache(const struct folio *folio) {
Greg Kroah-Hartman
maintainerPATCH 598/626 memcg: always call cond_resched() after fn()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
commit 06717a7b6c86514dbd6ab322e8083ffaa4db5712 upstream.
I am seeing soft lockup on certain machine types when a cgroup OOMs. This is happening because killing the process in certain machine might be very slow, which causes the soft lockup and RCU stalls. This happens usually when the cgroup has MANY processes and memory.oom.group is set.
Example I am seeing in real production:
[462012.244552] Memory cgroup out of memory: Killed process 3370438 (crosvm) ....
....
[462037.318059] Memory cgroup out of memory: Killed process 4171372 (adb) ....
[462037.348314] watchdog: BUG: soft lockup - CPU#64 stuck for 26s! [stat_manager-ag:1618982]
....Quick look at why this is so slow, it seems to be related to serial flush for certain machine types. For all the crashes I saw, the target CPU was at console_flush_all().
In the case above, there are thousands of processes in the cgroup, and it is soft locking up before it reaches the 1024 limit in the code (which would call the cond_resched()). So, cond_resched() in 1024 blocks is not sufficient.
Remove the counter-based conditional rescheduling logic and call cond_resched() unconditionally after each task iteration, after fn() is called. This avoids the lockup independently of how slow fn() is.
--- mm/memcontrol.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
mm/memcontrol.c +2 -4
@@ -1139,7 +1139,6 @@ void mem_cgroup_scan_tasks(struct mem_cg {struct mem_cgroup *iter;int ret =0 ; -int i =0 ;BUG_ON (mem_cgroup_is_root (memcg));
@@ -1149,10 +1148,9 @@ void mem_cgroup_scan_tasks(struct mem_cgcss_task_iter_start (&iter->css,CSS_TASK_ITER_PROCS , &it);while (!ret && (task =css_task_iter_next (&it))) { -/* Avoid potential softlockup warning */ -if ((++i &1023 ) ==0 ) -cond_resched (); ret =fn (task, arg); +/* Avoid potential softlockup warning */ +cond_resched (); }css_task_iter_end (&it);if (ret) {
Greg Kroah-Hartman
maintainerPATCH 599/626 mm/page_alloc.c: avoid infinite retries caused by cpuset race
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyang Zhang <[email protected]>
commit e05741fb10c38d70bbd7ec12b23c197b6355d519 upstream.
__alloc_pages_slowpath has no change detection for ac->nodemask in the part of retry path, while cpuset can modify it in parallel. For some processes that set mempolicy as MPOL_BIND, this results ac->nodemask changes, and then the should_reclaim_retry will judge based on the latest nodemask and jump to retry, while the get_page_from_freelist only traverses the zonelist from ac->preferred_zoneref, which selected by a expired nodemask and may cause infinite retries in some cases
cpu 64:
__alloc_pages_slowpath {
/* ..... */
retry:
/* ac->nodemask = 0x1, ac->preferred->zone->nid = 1 */
if (alloc_flags & ALLOC_KSWAPD)
wake_all_kswapds(order, gfp_mask, ac);
/* cpu 1:
cpuset_write_resmask
update_nodemask
update_nodemasks_hier
update_tasks_nodemask
mpol_rebind_task
mpol_rebind_policy
mpol_rebind_nodemask
// mempolicy->nodes has been modified,
// which ac->nodemask point to
*/
/* ac->nodemask = 0x3, ac->preferred->zone->nid = 1 */
if (should_reclaim_retry(gfp_mask, order, ac, alloc_flags,
did_some_progress > 0, &no_progress_loops))
goto retry;
}Simultaneously starting multiple cpuset01 from LTP can quickly reproduce this issue on a multi node server when the maximum memory pressure is reached and the swap is enabled
--- mm/page_alloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/page_alloc.c +8 -0
@@ -4381,6 +4381,14 @@ restart: } retry: +/* +* Deal with possible cpuset update races or zonelist updates to avoid +* infinite retries. +*/ +if (check_retry_cpuset (cpuset_mems_cookie, ac) || +check_retry_zonelist (zonelist_iter_cookie)) + goto restart; +/* Ensure kswapd doesn't accidentally go to sleep as long as we loop */ if (alloc_flags &ALLOC_KSWAPD )wake_all_kswapds (order, gfp_mask, ac);
Greg Kroah-Hartman
maintainerPATCH 600/626 mm: mmap: map MAP_STACK to VM_NOHUGEPAGE only if THP is enabled
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ignacio Moreno Gonzalez <[email protected]>
commit 7190b3c8bd2b0cde483bd440cf91ba1c518b4261 upstream.
commit c4608d1bf7c6 ("mm: mmap: map MAP_STACK to VM_NOHUGEPAGE") maps the mmap option MAP_STACK to VM_NOHUGEPAGE. This is also done if CONFIG_TRANSPARENT_HUGEPAGE is not defined. But in that case, the VM_NOHUGEPAGE does not make sense.
I discovered this issue when trying to use the tool CRIU to checkpoint and restore a container. Our running kernel is compiled without CONFIG_TRANSPARENT_HUGEPAGE. CRIU parses the output of /proc/<pid>/smaps and saves the "nh" flag. When trying to restore the container, CRIU fails to restore the "nh" mappings, since madvise() MADV_NOHUGEPAGE always returns an error because CONFIG_TRANSPARENT_HUGEPAGE is not defined.
--- include/linux/mman.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/mman.h +2 -0
@@ -157,7 +157,9 @@ calc_vm_flag_bits(struct file *file, uns return _calc_vm_trans(flags, MAP_GROWSDOWN, VM_GROWSDOWN ) | _calc_vm_trans(flags, MAP_LOCKED, VM_LOCKED ) | _calc_vm_trans(flags, MAP_SYNC, VM_SYNC ) | +#ifdef CONFIG_TRANSPARENT_HUGEPAGE _calc_vm_trans (flags,MAP_STACK ,VM_NOHUGEPAGE ) | +#endif arch_calc_vm_flag_bits(file, flags); }
Greg Kroah-Hartman
maintainerPATCH 601/626 mm: vmalloc: actually use the in-place vrealloc region
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit f7a35a3c36d1e36059c5654737d9bee3454f01a3 upstream.
Patch series "mm: vmalloc: Actually use the in-place vrealloc region".
This fixes a performance regression[1] with vrealloc()[1].
The refactoring to not build a new vmalloc region only actually worked when shrinking. Actually return the resized area when it grows. Ugh.
--- mm/vmalloc.c | 1 + 1 file changed, 1 insertion(+)
mm/vmalloc.c +1 -0
@@ -4115,6 +4115,7 @@ void *vrealloc_noprof(const void *p, sizif (want_init_on_alloc (flags))memset ((void *)p + old_size,0 , size - old_size); vm->requested_size = size; +return (void *)p; }/* TODO: Grow the vm_area, i.e. allocate and map additional pages. */
Greg Kroah-Hartman
maintainerPATCH 602/626 mm: vmalloc: only zero-init on vrealloc shrink
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 70d1eb031a68cbde4eed8099674be21778441c94 upstream.
The common case is to grow reallocations, and since init_on_alloc will have already zeroed the whole allocation, we only need to zero when shrinking the allocation.
--- mm/vmalloc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
mm/vmalloc.c +7 -5
@@ -4097,8 +4097,8 @@ void *vrealloc_noprof(const void *p, siz* would be a good heuristic for when to shrink the vm_area? */ if (size <= old_size) { -/* Zero out "freed" memory. */ -if (want_init_on_free ()) +/* Zero out "freed" memory, potentially for future realloc. */ +if (want_init_on_free () ||want_init_on_alloc (flags))memset ((void *)p + size,0 , old_size - size); vm->requested_size = size;kasan_poison_vmalloc (p + size, old_size - size);
@@ -4111,9 +4111,11 @@ void *vrealloc_noprof(const void *p, sizif (size <= alloced_size) {kasan_unpoison_vmalloc (p + old_size, size - old_size,KASAN_VMALLOC_PROT_NORMAL ); -/* Zero out "alloced" memory. */ -if (want_init_on_alloc (flags)) -memset ((void *)p + old_size,0 , size - old_size); +/* +* No need to zero memory here, as unused memory will have +* already been zeroed at initial allocation time or during +* realloc shrink time. +*/ vm->requested_size = size;return (void *)p; }
Greg Kroah-Hartman
maintainerPATCH 603/626 nilfs2: fix deadlock warnings caused by lock dependency in init_nilfs()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
commit fb881cd7604536b17a1927fb0533f9a6982ffcc5 upstream.
After commit c0e473a0d226 ("block: fix race between set_blocksize and read paths") was merged, set_blocksize() called by sb_set_blocksize() now locks the inode of the backing device file. As a result of this change, syzbot started reporting deadlock warnings due to a circular dependency involving the semaphore "ns_sem" of the nilfs object, the inode lock of the backing device file, and the locks that this inode lock is transitively dependent on.
This is caused by a new lock dependency added by the above change, since init_nilfs() calls sb_set_blocksize() in the lock section of "ns_sem". However, these warnings are false positives because init_nilfs() is called in the early stage of the mount operation and the filesystem has not yet started.
The reason why "ns_sem" is locked in init_nilfs() was to avoid a race condition in nilfs_fill_super() caused by sharing a nilfs object among multiple filesystem instances (super block structures) in the early implementation. However, nilfs objects and super block structures have long ago become one-to-one, and there is no longer any need to use the semaphore there.
So, fix this issue by removing the use of the semaphore "ns_sem" in init_nilfs().
--- fs/nilfs2/the_nilfs.c | 3 --- 1 file changed, 3 deletions(-)
fs/nilfs2/the_nilfs.c +0 -3
@@ -693,8 +693,6 @@ int init_nilfs(struct the_nilfs *nilfs,int blocksize;int err; -down_write (&nilfs->ns_sem); - blocksize =sb_min_blocksize (sb,NILFS_MIN_BLOCK_SIZE );if (!blocksize) {nilfs_err (sb,"unable to set blocksize" );
@@ -767,7 +765,6 @@ int init_nilfs(struct the_nilfs *nilfs,set_nilfs_init (nilfs); err =0 ; out: -up_write (&nilfs->ns_sem);return err; failed_sbh:
Greg Kroah-Hartman
maintainerPATCH 604/626 Bluetooth: btmtksdio: Check function enabled before doing close
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
commit 07e90048e356a29079fbc011cfc2e1fa1d1c5ac9 upstream.
Check BTMTKSDIO_FUNC_ENABLED flag before doing close to prevent btmtksdio_close been called twice.
--- drivers/bluetooth/btmtksdio.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/bluetooth/btmtksdio.c +4 -0
@@ -723,6 +723,10 @@ static int btmtksdio_close(struct hci_de {struct btmtksdio_dev *bdev =hci_get_drvdata (hdev); +/* Skip btmtksdio_close if BTMTKSDIO_FUNC_ENABLED isn't set */ +if (!test_bit (BTMTKSDIO_FUNC_ENABLED , &bdev->tx_state)) +return 0 ; +sdio_claim_host (bdev->func);/* Disable interrupt */
Greg Kroah-Hartman
maintainerPATCH 605/626 Bluetooth: btmtksdio: Do close if SDIO card removed without close
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Lu <[email protected]>
commit 0b6d58bc6ea85e57de25c828444928e4a0aa79cb upstream.
To prevent Bluetooth SDIO card from be physically removed suddenly, driver needs to ensure btmtksdio_close is called before btmtksdio_remove to disable interrupts and txrx workqueue.
--- drivers/bluetooth/btmtksdio.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/bluetooth/btmtksdio.c +6 -2
@@ -1434,11 +1434,15 @@ static void btmtksdio_remove(struct sdioif (!bdev)return ; + hdev = bdev->hdev; + +/* Make sure to call btmtksdio_close before removing sdio card */ +if (test_bit (BTMTKSDIO_FUNC_ENABLED , &bdev->tx_state)) +btmtksdio_close (hdev); +/* Be consistent the state in btmtksdio_probe */ pm_runtime_get_noresume (bdev->dev); - hdev = bdev->hdev; -sdio_set_drvdata (func,NULL );hci_unregister_dev (hdev);hci_free_dev (hdev);
Greg Kroah-Hartman
maintainerPATCH 606/626 Revert "arm64: dts: allwinner: h6: Use RSB for AXP805 PMIC connection"
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jernej Skrabec <[email protected]>
[ Upstream commit 573f99c7585f597630f14596550c79e73ffaeef4 ]
This reverts commit 531fdbeedeb89bd32018a35c6e137765c9cc9e97.
Hardware that uses I2C wasn't designed with high speeds in mind, so communication with PMIC via RSB can intermittently fail. Go back to I2C as higher speed and efficiency isn't worth the trouble.
--- .../dts/allwinner/sun50i-h6-beelink-gs1.dts | 38 +++++++++---------- .../dts/allwinner/sun50i-h6-orangepi-3.dts | 14 +++---- .../dts/allwinner/sun50i-h6-orangepi.dtsi | 22 +++++------ 3 files changed, 37 insertions(+), 37 deletions(-)
arch/arm64/boot/dts/allwinner/sun50i-h6-beelink-gs1.dts +19 -19
@@ -151,28 +151,12 @@ vcc-pg-supply = <®_aldo1>; }; -&r_ir { - linux,rc-map-name = "rc-beelink-gs1"; - status = "okay"; -}; - -&r_pio { - /* - * FIXME: We can't add that supply for now since it would - * create a circular dependency between pinctrl, the regulator - * and the RSB Bus. - * - * vcc-pl-supply = <®_aldo1>; - */ - vcc-pm-supply = <®_aldo1>; -}; - -&r_rsb { +&r_i2c { status = "okay"; - axp805: pmic@745 { + axp805: pmic@36 { compatible = "x-powers,axp805", "x-powers,axp806"; - reg = <0x745>; + reg = <0x36>; interrupt-parent = <&r_intc>; interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>; interrupt-controller;
@@ -290,6 +274,22 @@ }; }; +&r_ir { + linux,rc-map-name = "rc-beelink-gs1"; + status = "okay"; +}; + +&r_pio { + /* + * PL0 and PL1 are used for PMIC I2C + * don't enable the pl-supply else + * it will fail at boot + * + * vcc-pl-supply = <®_aldo1>; + */ + vcc-pm-supply = <®_aldo1>; +}; + &spdif { pinctrl-names = "default"; pinctrl-0 = <&spdif_tx_pin>;
arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi-3.dts +7 -7
@@ -175,16 +175,12 @@ vcc-pg-supply = <®_vcc_wifi_io>; }; -&r_ir { - status = "okay"; -}; - -&r_rsb { +&r_i2c { status = "okay"; - axp805: pmic@745 { + axp805: pmic@36 { compatible = "x-powers,axp805", "x-powers,axp806"; - reg = <0x745>; + reg = <0x36>; interrupt-parent = <&r_intc>; interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>; interrupt-controller;
@@ -295,6 +291,10 @@ }; }; +&r_ir { + status = "okay"; +}; + &rtc { clocks = <&ext_osc32k>; };
arch/arm64/boot/dts/allwinner/sun50i-h6-orangepi.dtsi +11 -11
@@ -112,20 +112,12 @@ vcc-pg-supply = <®_aldo1>; }; -&r_ir { - status = "okay"; -}; - -&r_pio { - vcc-pm-supply = <®_bldo3>; -}; - -&r_rsb { +&r_i2c { status = "okay"; - axp805: pmic@745 { + axp805: pmic@36 { compatible = "x-powers,axp805", "x-powers,axp806"; - reg = <0x745>; + reg = <0x36>; interrupt-parent = <&r_intc>; interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_LOW>; interrupt-controller;
@@ -240,6 +232,14 @@ }; }; +&r_ir { + status = "okay"; +}; + +&r_pio { + vcc-pm-supply = <®_bldo3>; +}; + &rtc { clocks = <&ext_osc32k>; };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 607/626 ksmbd: fix stream write failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namjae Jeon <[email protected]>
[ Upstream commit 1f4bbedd4e5a69b01cde2cc21d01151ab2d0884f ]
If there is no stream data in file, v_len is zero. So, If position(*pos) is zero, stream write will fail due to stream write position validation check. This patch reorganize stream write position validation.
--- fs/smb/server/vfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
fs/smb/server/vfs.c +6 -8
@@ -426,10 +426,15 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,ksmbd_debug (VFS ,"write stream data pos : %llu, count : %zd\n" , *pos, count); +if (*pos >=XATTR_SIZE_MAX ) { +pr_err ("stream write position %lld is out of bounds\n" , *pos); +return -EINVAL ; + } + size = *pos + count;if (size >XATTR_SIZE_MAX ) { size =XATTR_SIZE_MAX ; - count = (*pos + count) -XATTR_SIZE_MAX ; + count =XATTR_SIZE_MAX - *pos; } v_len = ksmbd_vfs_getcasexattr(idmap,
@@ -443,13 +448,6 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, goto out; } -if (v_len <= *pos) { -pr_err ("stream write position %lld is out of bounds (stream length: %zd)\n" , - *pos, v_len); - err = -EINVAL ; - goto out; - } -if (v_len < size) { wbuf =kvzalloc (size,KSMBD_DEFAULT_GFP );if (!wbuf) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 608/626 platform/x86: think-lmi: Fix attribute name usage for non-compliant items
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Pearson <[email protected]>
[ Upstream commit 8508427a6e21c1ef01ae4c9f4e2675fc99deb949 ]
A few, quite rare, WMI attributes have names that are not compatible with filenames, e.g. "Intel VT for Directed I/O (VT-d)".
For these cases the '/' gets replaced with '\' for display, but doesn't get switched again when doing the WMI access.
Fix this by keeping the original attribute name and using that for sending commands to the BIOS
--- drivers/platform/x86/think-lmi.c | 26 ++++++++++++++------------ drivers/platform/x86/think-lmi.h | 1 + 2 files changed, 15 insertions(+), 12 deletions(-)
drivers/platform/x86/think-lmi.c +14 -12
@@ -995,8 +995,8 @@ static ssize_t current_value_store(struct kobject *kobj, ret = -EINVAL ; goto out; } - set_str =kasprintf (GFP_KERNEL ,"%s,%s,%s" , setting->display_name, - new_setting, tlmi_priv.pwd_admin->signature); + set_str =kasprintf (GFP_KERNEL ,"%s,%s,%s" , setting->name, + new_setting, tlmi_priv.pwd_admin->signature);if (!set_str) { ret = -ENOMEM ; goto out;
@@ -1026,7 +1026,7 @@ static ssize_t current_value_store(struct kobject *kobj, goto out; } - set_str =kasprintf (GFP_KERNEL ,"%s,%s;" , setting->display_name, + set_str =kasprintf (GFP_KERNEL ,"%s,%s;" , setting->name, new_setting);if (!set_str) { ret = -ENOMEM ;
@@ -1054,11 +1054,11 @@ static ssize_t current_value_store(struct kobject *kobj, }if (auth_str) - set_str =kasprintf (GFP_KERNEL ,"%s,%s,%s" , setting->display_name, - new_setting, auth_str); + set_str =kasprintf (GFP_KERNEL ,"%s,%s,%s" , setting->name, + new_setting, auth_str);else - set_str =kasprintf (GFP_KERNEL ,"%s,%s;" , setting->display_name, - new_setting); + set_str =kasprintf (GFP_KERNEL ,"%s,%s;" , setting->name, + new_setting);if (!set_str) { ret = -ENOMEM ; goto out;
@@ -1568,9 +1568,6 @@ static int tlmi_analyze(void)continue ; } -/* It is not allowed to have '/' for file name. Convert it into '\'. */ -strreplace (item,'/' ,'\\' ); -/* Remove the value part */ strreplace (item,',' ,'\0' );
@@ -1582,11 +1579,16 @@ static int tlmi_analyze(void) goto fail_clear_attr; } setting->index = i; + +strscpy (setting->name, item); +/* It is not allowed to have '/' for file name. Convert it into '\'. */ +strreplace (item,'/' ,'\\' );strscpy (setting->display_name, item); +/* If BIOS selections supported, load those */ if (tlmi_priv.can_get_bios_selections) { - ret =tlmi_get_bios_selections (setting->display_name, - &setting->possible_values); + ret =tlmi_get_bios_selections (setting->name, + &setting->possible_values);if (ret || !setting->possible_values)pr_info ("Error retrieving possible values for %d : %s\n" , i, setting->display_name);
drivers/platform/x86/think-lmi.h +1 -0
@@ -84,6 +84,7 @@ struct tlmi_pwd_setting {struct tlmi_attr_setting {struct kobject kobj;int index; +char name[TLMI_SETTINGS_MAXLEN ];char display_name[TLMI_SETTINGS_MAXLEN ];char *possible_values; };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 609/626 spi: use container_of_cont() for to_spi_device()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Greg Kroah-Hartman <[email protected]>
[ Upstream commit 1007ae0d464ceb55a3740634790521d3543aaab9 ]
Some places in the spi core pass in a const pointer to a device and the default container_of() casts that away, which is not a good idea. Preserve the proper const attribute by using container_of_const() for to_spi_device() instead, which is what it was designed for.
Note, this removes the NULL check for a device pointer in the call, but no one was ever checking for that return value, and a device pointer should never be NULL overall anyway, so this should be a safe change.
--- include/linux/spi/spi.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
include/linux/spi/spi.h +1 -4
@@ -247,10 +247,7 @@ struct spi_device {static_assert ((SPI_MODE_KERNEL_MASK &SPI_MODE_USER_MASK ) ==0 ,"SPI_MODE_USER_MASK & SPI_MODE_KERNEL_MASK must not overlap" ); -static inline struct spi_device *to_spi_device (const struct device *dev) -{ - return dev ? container_of(dev, struct spi_device, dev) : NULL; -} +#define to_spi_device (__dev) container_of_const(__dev, struct spi_device, dev)/* Most drivers won't need to care about device refcounting */ static inline struct spi_device *spi_dev_get (struct spi_device *spi)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 610/626 spi: spi-fsl-dspi: restrict register range for regmap access
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larisa Grigore <[email protected]>
[ Upstream commit 283ae0c65e9c592f4a1ba4f31917f5e766da7f31 ]
DSPI registers are NOT continuous, some registers are reserved and accessing them from userspace will trigger external abort, add regmap register access table to avoid below abort.
For example on S32G:
# cat /sys/kernel/debug/regmap/401d8000.spi/registers
Internal error: synchronous external abort: 96000210 1 PREEMPT SMP ... Call trace: regmap_mmio_read32le+0x24/0x48 regmap_mmio_read+0x48/0x70 _regmap_bus_reg_read+0x38/0x48 _regmap_read+0x68/0x1b0 regmap_read+0x50/0x78 regmap_read_debugfs+0x120/0x338
--- drivers/spi/spi-fsl-dspi.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/spi/spi-fsl-dspi.c +19 -1
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0+ // // Copyright 2013 Freescale Semiconductor, Inc. -// Copyright 2020 NXP +// Copyright 2020-2025 NXP // // Freescale DSPI driver // This file contains a driver for the Freescale DSPI
@@ -1167,6 +1167,20 @@ static int dspi_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(dspi_pm, dspi_suspend, dspi_resume); +static const struct regmap_range dspi_yes_ranges[] = { +regmap_reg_range (SPI_MCR ,SPI_MCR ), +regmap_reg_range (SPI_TCR ,SPI_CTAR (3 )), +regmap_reg_range (SPI_SR ,SPI_TXFR3 ), +regmap_reg_range (SPI_RXFR0 ,SPI_RXFR3 ), +regmap_reg_range (SPI_CTARE (0 ),SPI_CTARE (3 )), +regmap_reg_range (SPI_SREX ,SPI_SREX ), +}; + +static const struct regmap_access_table dspi_access_table = { + .yes_ranges = dspi_yes_ranges, + .n_yes_ranges =ARRAY_SIZE (dspi_yes_ranges), +}; +static const struct regmap_range dspi_volatile_ranges[] = {regmap_reg_range (SPI_MCR ,SPI_TCR ),regmap_reg_range (SPI_SR ,SPI_SR ),
@@ -1184,6 +1198,8 @@ static const struct regmap_config dspi_regmap_config = { .reg_stride = 4, .max_register = 0x88, .volatile_table = &dspi_volatile_table, + .rd_table = &dspi_access_table, + .wr_table = &dspi_access_table, };static const struct regmap_range dspi_xspi_volatile_ranges[] = {
@@ -1205,6 +1221,8 @@ static const struct regmap_config dspi_xspi_regmap_config[] = { .reg_stride = 4, .max_register = 0x13c, .volatile_table = &dspi_xspi_volatile_table, + .rd_table = &dspi_access_table, + .wr_table = &dspi_access_table, }, { .name = "pushr",
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 611/626 spi: spi-fsl-dspi: Halt the module after a new message transfer
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bogdan-Gabriel Roman <[email protected]>
[ Upstream commit 8a30a6d35a11ff5ccdede7d6740765685385a917 ]
The XSPI mode implementation in this driver still uses the EOQ flag to signal the last word in a transmission and deassert the PCS signal. However, at speeds lower than ~200kHZ, the PCS signal seems to remain asserted even when SR[EOQF] = 1 indicates the end of a transmission. This is a problem for target devices which require the deassertation of the PCS signal between transfers.
Hence, this commit 'forces' the deassertation of the PCS by stopping the module through MCR[HALT] after completing a new transfer. According to the reference manual, the module stops or transitions from the Running state to the Stopped state after the current frame, when any one of the following conditions exist:
- The value of SR[EOQF] = 1.
- The chip is in Debug mode and the value of MCR[FRZ] = 1.
- The value of MCR[HALT] = 1.
This shouldn't be done if the last transfer in the message has cs_change set.
--- drivers/spi/spi-fsl-dspi.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/spi/spi-fsl-dspi.c +24 -0
@@ -62,6 +62,7 @@#define SPI_SR_TFIWF BIT(18)#define SPI_SR_RFDF BIT(17)#define SPI_SR_CMDFFF BIT(16) +#define SPI_SR_TXRXS BIT(30)#define SPI_SR_CLEAR (SPI_SR_TCFQF | \ SPI_SR_TFUF | SPI_SR_TFFF | \ SPI_SR_CMDTCF | SPI_SR_SPEF | \
@@ -921,9 +922,20 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr,struct spi_transfer *transfer;bool cs = false;int status =0 ; +u32 val =0 ; +bool cs_change = false; message->actual_length =0 ; +/* Put DSPI in running mode if halted. */ +regmap_read (dspi->regmap,SPI_MCR , &val); +if (val &SPI_MCR_HALT ) { +regmap_update_bits (dspi->regmap,SPI_MCR ,SPI_MCR_HALT ,0 ); +while (regmap_read (dspi->regmap,SPI_SR , &val) >=0 && + !(val &SPI_SR_TXRXS )) + ; + } +list_for_each_entry (transfer, &message->transfers, transfer_list) { dspi->cur_transfer = transfer; dspi->cur_msg = message;
@@ -953,6 +965,7 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr, dspi->tx_cmd |=SPI_PUSHR_CMD_CONT ; } + cs_change = transfer->cs_change; dspi->tx = transfer->tx_buf; dspi->rx = transfer->rx_buf; dspi->len = transfer->len;
@@ -988,6 +1001,15 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr,dspi_deassert_cs (spi, &cs); } +if (status || !cs_change) { +/* Put DSPI in stop mode */ +regmap_update_bits (dspi->regmap,SPI_MCR , +SPI_MCR_HALT ,SPI_MCR_HALT ); +while (regmap_read (dspi->regmap,SPI_SR , &val) >=0 && + val &SPI_SR_TXRXS ) + ; + } + message->status = status;spi_finalize_current_message (ctlr);
@@ -1245,6 +1267,8 @@ static int dspi_init(struct fsl_dspi *dspi)if (!spi_controller_is_target (dspi->ctlr)) mcr |=SPI_MCR_HOST ; + mcr |=SPI_MCR_HALT ; +regmap_write (dspi->regmap,SPI_MCR , mcr);regmap_write (dspi->regmap,SPI_SR ,SPI_SR_CLEAR );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 612/626 spi: spi-fsl-dspi: Reset SR flags before sending a new message
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larisa Grigore <[email protected]>
[ Upstream commit 7aba292eb15389073c7f3bd7847e3862dfdf604d ]
If, in a previous transfer, the controller sends more data than expected by the DSPI target, SR.RFDF (RX FIFO is not empty) will remain asserted. When flushing the FIFOs at the beginning of a new transfer (writing 1 into MCR.CLR_TXF and MCR.CLR_RXF), SR.RFDF should also be cleared. Otherwise, when running in target mode with DMA, if SR.RFDF remains asserted, the DMA callback will be fired before the controller sends any data.
Take this opportunity to reset all Status Register fields.
--- drivers/spi/spi-fsl-dspi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-fsl-dspi.c +2 -0
@@ -975,6 +975,8 @@ static int dspi_transfer_one_message(struct spi_controller *ctlr,SPI_MCR_CLR_TXF |SPI_MCR_CLR_RXF , SPI_MCR_CLR_TXF | SPI_MCR_CLR_RXF); +regmap_write (dspi->regmap,SPI_SR ,SPI_SR_CLEAR ); +spi_take_timestamp_pre (dspi->ctlr, dspi->cur_transfer, dspi->progress, !dspi->irq);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 613/626 err.h: move IOMEM_ERR_PTR() to err.h
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Raag Jadav <[email protected]>
commit 18311a766c587fc69b1806f1d5943305903b7e6e upstream.
Since IOMEM_ERR_PTR() macro deals with an error pointer, a better place for it is err.h. This helps avoid dependency on io.h for the users that don't need it.
--- include/linux/err.h | 3 +++ include/linux/io.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
include/linux/err.h +3 -0
@@ -44,6 +44,9 @@ static inline void * __must_check ERR_PT/* Return the pointer in the percpu address space. */ #define ERR_PTR_PCPU (error) ((void __percpu *)(unsigned long)ERR_PTR(error)) +/* Cast an error pointer to __iomem. */ +#define IOMEM_ERR_PTR (error) (__force void __iomem *)ERR_PTR(error) +/** * PTR_ERR - Extract the error code from an error pointer. * @ptr: An error pointer.
include/linux/io.h +0 -2
@@ -65,8 +65,6 @@ static inline void devm_ioport_unmap(str }#endif -#define IOMEM_ERR_PTR (err) (__force void __iomem *)ERR_PTR(err) -void __iomem *devm_ioremap (struct device *dev,resource_size_t offset,resource_size_t size); void __iomem *devm_ioremap_uc(struct device *dev, resource_size_t offset,
Greg Kroah-Hartman
maintainerPATCH 614/626 gcc-15: make unterminated string initialization just a warning
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit d5d45a7f26194460964eb5677a9226697f7b7fdd upstream.
gcc-15 enabling -Wunterminated-string-initialization in -Wextra by default was done with the best intentions, but the warning is still quite broken.
What annoys me about the warning is that this is a very traditional AND CORRECT way to initialize fixed byte arrays in C:
unsigned char hex[16] = "0123456789abcdef";
and we use this all over the kernel. And the warning is fine, but gcc developers apparently never made a reasonable way to disable it. As is (sadly) tradition with these things.
Yes, there's "__attribute__((nonstring))", and we have a macro to make that absolutely disgusting syntax more palatable (ie the kernel syntax for that monstrosity is just "__nonstring").
But that attribute is misdesigned. What you'd typically want to do is tell the compiler that you are using a type that isn't a string but a byte array, but that doesn't work at all:
warning: ‘nonstring’ attribute does not apply to types [-Wattributes]
and because of this fundamental mis-design, you then have to mark each instance of that pattern.
This is particularly noticeable in our ACPI code, because ACPI has this notion of a 4-byte "type name" that gets used all over, and is exactly this kind of byte array.
This is a sad oversight, because the warning is useful, but really would be so much better if gcc had also given a sane way to indicate that we really just want a byte array type at a type level, not the broken "each and every array definition" level.
So now instead of creating a nice "ACPI name" type using something like
typedef char acpi_name_t[4] __nonstring;
we have to do things like
char name[ACPI_NAMESEG_SIZE] __nonstring;
in every place that uses this concept and then happens to have the typical initializers.
This is annoying me mainly because I think the warning _is_ a good warning, which is why I'm not just turning it off in disgust. But it is hampered by this bad implementation detail.
[ And obviously I'm doing this now because system upgrades for me are
something that happen in the middle of the release cycle: don't do it before or during travel, or just before or during the busy merge window period. ]
--- Makefile | 3 +++ 1 file changed, 3 insertions(+)
Makefile +3 -0
@@ -1001,6 +1001,9 @@ KBUILD_CFLAGS += $(call cc-option, -fstr KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) +#Currently, disable -Wunterminated-string-initialization as an error +KBUILD_CFLAGS += $(call cc-option, -Wno-error=unterminated-string-initialization) + # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow
Greg Kroah-Hartman
maintainerPATCH 615/626 gcc-15: disable -Wunterminated-string-initialization entirely for now
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
commit 9d7a0577c9db35c4cc52db90bc415ea248446472 upstream.
From: Linus Torvalds <[email protected]>
I had left the warning around but as a non-fatal error to get my gcc-15 builds going, but fixed up some of the most annoying warning cases so that it wouldn't be *too* verbose.
Because I like the _concept_ of the warning, even if I detested the implementation to shut it up.
It turns out the implementation to shut it up is even more broken than I thought, and my "shut up most of the warnings" patch just caused fatal errors on gcc-14 instead.
I had tested with clang, but when I upgrade my development environment, I try to do it on all machines because I hate having different systems to maintain, and hadn't realized that gcc-14 now had issues.
The ACPI case is literally why I wanted to have a *type* that doesn't trigger the warning (see commit d5d45a7f2619: "gcc-15: make 'unterminated string initialization' just a warning"), instead of marking individual places as "__nonstring".
But gcc-14 doesn't like that __nonstring location that shut gcc-15 up, because it's on an array of char arrays, not on one single array:
drivers/acpi/tables.c:399:1: error: 'nonstring' attribute ignored on objects of type 'const char[][4]' [-Werror=attributes]
399 | static const char table_sigs[][ACPI_NAMESEG_SIZE] __initconst __nonstring = {
| ^~~~~~and my attempts to nest it properly with a type had failed, because of how gcc doesn't like marking the types as having attributes, only symbols.
There may be some trick to it, but I was already annoyed by the bad attribute design, now I'm just entirely fed up with it.
I wish gcc had a proper way to say "this type is a *byte* array, not a string".
The obvious thing would be to distinguish between "char []" and an explicitly signed "unsigned char []" (as opposed to an implicitly unsigned char, which is typically an architecture-specific default, but for the kernel is universal thanks to '-funsigned-char').
But any "we can typedef a 8-bit type to not become a string just because it's an array" model would be fine.
But "__attribute__((nonstring))" is sadly not that sane model.
--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1001,8 +1001,8 @@ KBUILD_CFLAGS += $(call cc-option, -fstr KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) -#Currently, disable -Wunterminated-string-initialization as an error -KBUILD_CFLAGS += $(call cc-option, -Wno-error=unterminated-string-initialization) +#Currently, disable -Wunterminated-string-initialization as broken +KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow
Greg Kroah-Hartman
maintainerPATCH 616/626 Fix mis-uses of cc-option for warning disablement
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Torvalds <[email protected]>
commit a79be02bba5c31f967885c7f3bf3a756d77d11d9 upstream.
This was triggered by one of my mis-uses causing odd build warnings on sparc in linux-next, but while figuring out why the "obviously correct" use of cc-option caused such odd breakage, I found eight other cases of the same thing in the tree.
The root cause is that 'cc-option' doesn't work for checking negative warning options (ie things like '-Wno-stringop-overflow') because gcc will silently accept options it doesn't recognize, and so 'cc-option' ends up thinking they are perfectly fine.
And it all works, until you have a situation where _another_ warning is emitted. At that point the compiler will go "Hmm, maybe the user intended to disable this warning but used that wrong option that I didn't recognize", and generate a warning for the unrecognized negative option.
Which explains why we have several cases of this in the tree: the 'cc-option' test really doesn't work for this situation, but most of the time it simply doesn't matter that ity doesn't work.
The reason my recently added case caused problems on sparc was pointed out by Thomas Weißschuh: the sparc build had a previous explicit warning that then triggered the new one.
I think the best fix for this would be to make 'cc-option' a bit smarter about this sitation, possibly by adding an intentional warning to the test case that then triggers the unrecognized option warning reliably.
But the short-term fix is to replace 'cc-option' with an existing helper designed for this exact case: 'cc-disable-warning', which picks the negative warning but uses the positive form for testing the compiler support.
--- Makefile | 4 ++-- arch/loongarch/kernel/Makefile | 8 ++++---- arch/loongarch/kvm/Makefile | 2 +- arch/riscv/kernel/Makefile | 4 ++-- scripts/Makefile.extrawarn | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-)
Makefile +2 -2
@@ -998,11 +998,11 @@ NOSTDINC_FLAGS += -nostdinc KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) #Currently, disable -Wstringop-overflow for GCC 11, globally. -KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-option, -Wno-stringop-overflow) +KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow) KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) #Currently, disable -Wunterminated-string-initialization as broken -KBUILD_CFLAGS += $(call cc-option, -Wno-unterminated-string-initialization) +KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow
arch/loongarch/kernel/Makefile +4 -4
@@ -21,10 +21,10 @@ obj-$(CONFIG_CPU_HAS_LBT) += lbt.o obj-$(CONFIG_ARCH_STRICT_ALIGN) += unaligned.o -CFLAGS_module.o += $(call cc-option,-Wno-override-init,) -CFLAGS_syscall.o += $(call cc-option,-Wno-override-init,) -CFLAGS_traps.o += $(call cc-option,-Wno-override-init,) -CFLAGS_perf_event.o += $(call cc-option,-Wno-override-init,) +CFLAGS_module.o += $(call cc-disable-warning, override-init) +CFLAGS_syscall.o += $(call cc-disable-warning, override-init) +CFLAGS_traps.o += $(call cc-disable-warning, override-init) +CFLAGS_perf_event.o += $(call cc-disable-warning, override-init) ifdef CONFIG_FUNCTION_TRACER ifndef CONFIG_DYNAMIC_FTRACE
arch/loongarch/kvm/Makefile +1 -1
@@ -19,4 +19,4 @@ kvm-y += tlb.o kvm-y += vcpu.o kvm-y += vm.o -CFLAGS_exit.o += $(call cc-option,-Wno-override-init,) +CFLAGS_exit.o += $(call cc-disable-warning, override-init)
arch/riscv/kernel/Makefile +2 -2
@@ -9,8 +9,8 @@ CFLAGS_REMOVE_patch.o = $(CC_FLAGS_FTRAC CFLAGS_REMOVE_sbi.o = $(CC_FLAGS_FTRACE) CFLAGS_REMOVE_return_address.o = $(CC_FLAGS_FTRACE) endif -CFLAGS_syscall_table.o += $(call cc-option,-Wno-override-init,) -CFLAGS_compat_syscall_table.o += $(call cc-option,-Wno-override-init,) +CFLAGS_syscall_table.o += $(call cc-disable-warning, override-init) +CFLAGS_compat_syscall_table.o += $(call cc-disable-warning, override-init) ifdef CONFIG_KEXEC_CORE AFLAGS_kexec_relocate.o := -mcmodel=medany $(call cc-option,-mno-relax)
scripts/Makefile.extrawarn +1 -1
@@ -15,7 +15,7 @@ KBUILD_CFLAGS += -Werror=return-type KBUILD_CFLAGS += -Werror=strict-prototypes KBUILD_CFLAGS += -Wno-format-security KBUILD_CFLAGS += -Wno-trigraphs -KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) +KBUILD_CFLAGS += $(call cc-disable-warning, frame-address) KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) KBUILD_CFLAGS += -Wmissing-declarations KBUILD_CFLAGS += -Wmissing-prototypes
Greg Kroah-Hartman
maintainerPATCH 617/626 kbuild: Properly disable -Wunterminated-string-initialization for clang
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit 4f79eaa2ceac86a0e0f304b0bab556cca5bf4f30 upstream.
Clang and GCC have different behaviors around disabling warnings included in -Wall and -Wextra and the order in which flags are specified, which is exposed by clang's new support for -Wunterminated-string-initialization.
$ cat test.c const char foo[3] = "FOO"; const char bar[3] __attribute__((__nonstring__)) = "BAR";
$ clang -fsyntax-only -Wextra test.c
test.c:1:21: warning: initializer-string for character array is too long, array size is 3 but initializer has size 4 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
1 | const char foo[3] = "FOO";
| ^~~~~
$ clang -fsyntax-only -Wextra -Wno-unterminated-string-initialization test.c
$ clang -fsyntax-only -Wno-unterminated-string-initialization -Wextra test.c
test.c:1:21: warning: initializer-string for character array is too long, array size is 3 but initializer has size 4 (including the null terminating character); did you mean to use the 'nonstring' attribute? [-Wunterminated-string-initialization]
1 | const char foo[3] = "FOO";
| ^~~~~ $ gcc -fsyntax-only -Wextra test.c
test.c:1:21: warning: initializer-string for array of ‘char’ truncates NUL terminator but destination lacks ‘nonstring’ attribute (4 chars into 3 available) [-Wunterminated-string-initialization]
1 | const char foo[3] = "FOO";
| ^~~~~
$ gcc -fsyntax-only -Wextra -Wno-unterminated-string-initialization test.c
$ gcc -fsyntax-only -Wno-unterminated-string-initialization -Wextra test.cMove -Wextra up right below -Wall in Makefile.extrawarn to ensure these flags are at the beginning of the warning options list. Move the couple of warning options that have been added to the main Makefile since commit e88ca24319e4 ("kbuild: consolidate warning flags in scripts/Makefile.extrawarn") to scripts/Makefile.extrawarn after -Wall / -Wextra to ensure they get properly disabled for all compilers.
--- Makefile | 7 ------- scripts/Makefile.extrawarn | 9 ++++++++- 2 files changed, 8 insertions(+), 8 deletions(-)
Makefile +0 -7
@@ -997,13 +997,6 @@ NOSTDINC_FLAGS += -nostdinc # perform bounds checking. KBUILD_CFLAGS += $(call cc-option, -fstrict-flex-arrays=3) -#Currently, disable -Wstringop-overflow for GCC 11, globally. -KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow) -KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) - -#Currently, disable -Wunterminated-string-initialization as broken -KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization) - # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += -fno-strict-overflow
scripts/Makefile.extrawarn +8 -1
@@ -8,6 +8,7 @@ # Default set of warnings, always enabled KBUILD_CFLAGS += -Wall +KBUILD_CFLAGS += -Wextra KBUILD_CFLAGS += -Wundef KBUILD_CFLAGS += -Werror=implicit-function-declaration KBUILD_CFLAGS += -Werror=implicit-int
@@ -68,6 +69,13 @@ KBUILD_CFLAGS += -Wno-pointer-sign # globally built with -Wcast-function-type. KBUILD_CFLAGS += $(call cc-option, -Wcast-function-type) +# Currently, disable -Wstringop-overflow for GCC 11, globally. +KBUILD_CFLAGS-$(CONFIG_CC_NO_STRINGOP_OVERFLOW) += $(call cc-disable-warning, stringop-overflow) +KBUILD_CFLAGS-$(CONFIG_CC_STRINGOP_OVERFLOW) += $(call cc-option, -Wstringop-overflow) + +# Currently, disable -Wunterminated-string-initialization as broken +KBUILD_CFLAGS += $(call cc-disable-warning, unterminated-string-initialization) + # The allocators already balk at large sizes, so silence the compiler # warnings for bounds checks involving those possible values. While # -Wno-alloc-size-larger-than would normally be used here, earlier versions
@@ -97,7 +105,6 @@ KBUILD_CFLAGS += $(call cc-option,-Wenum # Explicitly clear padding bits during variable initialization KBUILD_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all) -KBUILD_CFLAGS += -Wextra KBUILD_CFLAGS += -Wunused #
Greg Kroah-Hartman
maintainerPATCH 618/626 drm/amd/display: Exit idle optimizations before accessing PHY
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Bunea <[email protected]>
commit c488967488d7eff7b9c527d5469c424c15377502 upstream.
[why & how]
By default, DCN HW is in idle optimized state which does not allow access to PHY registers. If BIOS powers up the DCN, it is fine because they will power up everything. Only exit idle optimized state when not taking control from VBIOS.
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +5 -0
@@ -1888,6 +1888,7 @@ void dce110_enable_accelerated_mode(strubool can_apply_edp_fast_boot = false;bool can_apply_seamless_boot = false;bool keep_edp_vdd_on = false; +struct dc_bios *dcb = dc->ctx->dc_bios;DC_LOGGER_INIT ();
@@ -1964,6 +1965,8 @@ void dce110_enable_accelerated_mode(stru hws->funcs.edp_backlight_control (edp_link_with_sink, false); }/*resume from S3, no vbios posting, no need to power down again*/ +if (dcb && dcb->funcs && !dcb->funcs->is_accelerated_mode (dcb)) +clk_mgr_exit_optimized_pwr_state (dc, dc->clk_mgr);power_down_all_hw_blocks (dc);
@@ -1976,6 +1979,8 @@ void dce110_enable_accelerated_mode(strudisable_vga_and_power_gate_all_controllers (dc);if (edp_link_with_sink && !keep_edp_vdd_on) dc->hwss.edp_power_control (edp_link_with_sink, false); +if (dcb && dcb->funcs && !dcb->funcs->is_accelerated_mode (dcb)) +clk_mgr_optimize_pwr_state (dc, dc->clk_mgr); }bios_set_scratch_acc_mode_change (dc->ctx->dc_bios,1 ); }
Greg Kroah-Hartman
maintainerPATCH 619/626 bpf: abort verification if env->cur_state->loop_entry != NULL
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eduard Zingerman <[email protected]>
commit f3c2d243a36ef23be07bc2bce7c6a5cb6e07d9e3 upstream.
In addition to warning abort verification with -EFAULT. If env->cur_state->loop_entry != NULL something is irrecoverably buggy.
--- kernel/bpf/verifier.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/bpf/verifier.c +4 -2
@@ -18721,8 +18721,10 @@ process_bpf_exit:return err;break ; }else { -if (WARN_ON_ONCE (env->cur_state->loop_entry)) - env->cur_state->loop_entry =NULL ; +if (WARN_ON_ONCE (env->cur_state->loop_entry)) { +verbose (env,"verifier bug: env->cur_state->loop_entry != NULL\n" ); +return -EFAULT ; + } do_print_state = true;continue ; }
Greg Kroah-Hartman
maintainerPATCH 620/626 serial: sh-sci: Save and restore more registers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
commit 81100b9a7b0515132996d62a7a676a77676cb6e3 upstream.
On (H)SCIF with a Baud Rate Generator for External Clock (BRG), there are multiple ways to configure the requested serial speed. If firmware uses a different method than Linux, and if any debug info is printed after the Bit Rate Register (SCBRR) is restored, but before termios is reconfigured (which configures the alternative method), the system may lock-up during resume.
Fix this by saving and restoring the contents of the BRG Frequency Division (SCDL) and Clock Select (SCCKS) registers as well.
Also save and restore the HSCIF's Sampling Rate Register (HSSRR), which configures the sampling point, and the SCIFA/SCIFB's Serial Port Control and Data Registers (SCPCR/SCPDR), which configure the optional control flow signals.
After this, all registers that are not saved/restored are either:
- read-only,
- write-only,
- status registers containing flags with clear-after-set semantics,
- FIFO Data Count Trigger registers, which do not matter much for the serial console.
--- drivers/tty/serial/sh-sci.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/tty/serial/sh-sci.c +25 -0
@@ -105,10 +105,15 @@ struct plat_sci_reg { };struct sci_suspend_regs { +u16 scdl; +u16 sccks;u16 scsmr;u16 scscr;u16 scfcr;u16 scsptr; +u16 hssrr; +u16 scpcr; +u16 scpdr;u8 scbrr;u8 semr; };
@@ -3550,6 +3555,10 @@ static void sci_console_save(struct sci_struct sci_suspend_regs *regs = &s->suspend_regs;struct uart_port *port = &s->port; +if (sci_getreg (port,SCDL )->size) + regs->scdl =sci_serial_in (port,SCDL ); +if (sci_getreg (port,SCCKS )->size) + regs->sccks =sci_serial_in (port,SCCKS );if (sci_getreg (port,SCSMR )->size) regs->scsmr =sci_serial_in (port,SCSMR );if (sci_getreg (port,SCSCR )->size)
@@ -3560,6 +3569,12 @@ static void sci_console_save(struct sci_ regs->scsptr =sci_serial_in (port,SCSPTR );if (sci_getreg (port,SCBRR )->size) regs->scbrr =sci_serial_in (port,SCBRR ); +if (sci_getreg (port,HSSRR )->size) + regs->hssrr =sci_serial_in (port,HSSRR ); +if (sci_getreg (port,SCPCR )->size) + regs->scpcr =sci_serial_in (port,SCPCR ); +if (sci_getreg (port,SCPDR )->size) + regs->scpdr =sci_serial_in (port,SCPDR );if (sci_getreg (port,SEMR )->size) regs->semr =sci_serial_in (port,SEMR ); }
@@ -3569,6 +3584,10 @@ static void sci_console_restore(struct sstruct sci_suspend_regs *regs = &s->suspend_regs;struct uart_port *port = &s->port; +if (sci_getreg (port,SCDL )->size) +sci_serial_out (port,SCDL , regs->scdl); +if (sci_getreg (port,SCCKS )->size) +sci_serial_out (port,SCCKS , regs->sccks);if (sci_getreg (port,SCSMR )->size)sci_serial_out (port,SCSMR , regs->scsmr);if (sci_getreg (port,SCSCR )->size)
@@ -3579,6 +3598,12 @@ static void sci_console_restore(struct ssci_serial_out (port,SCSPTR , regs->scsptr);if (sci_getreg (port,SCBRR )->size)sci_serial_out (port,SCBRR , regs->scbrr); +if (sci_getreg (port,HSSRR )->size) +sci_serial_out (port,HSSRR , regs->hssrr); +if (sci_getreg (port,SCPCR )->size) +sci_serial_out (port,SCPCR , regs->scpcr); +if (sci_getreg (port,SCPDR )->size) +sci_serial_out (port,SCPDR , regs->scpdr);if (sci_getreg (port,SEMR )->size)sci_serial_out (port,SEMR , regs->semr); }
Re: [PATCH 6.12 620/626] serial: sh-sci: Save and restore more registers
Hi!
Quoted 1 line
6.12-stable review patch. If anyone has any objections, please let me know.
Something went wrong with the scripts here:
Quoted 7 lines
Fixes 22a6984c5b5df8ea ("serial: sh-sci: Update the suspend/resume support")Signed-off-by Geert Uytterhoeven <[email protected]>Tested-by Claudiu Beznea <[email protected]>Reviewed-by Claudiu Beznea <[email protected]>Link https://lore.kernel.org/r/11c2eab45d48211e75d8b8202cce60400880fe55.1741114989.git.geert+renesas@glider.be open hereSigned-off-by Greg Kroah-Hartman <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
We should not really have two sign-offs in a row.
BR,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Greg Kroah-Hartman
maintainerPATCH 621/626 drm/amdkfd: Correct F8_MODE for gfx950
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amber Lin <[email protected]>
commit 0c7e053448945e5a4379dc4396c762d7422b11ca upstream.
Correct F8_MODE setting for gfx950 that was removed
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v9.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager_v9.c +1 -2
@@ -69,8 +69,7 @@ static bool set_cache_memory_policy_v9(s qpd->sh_mem_config |=1 <<SH_MEM_CONFIG__RETRY_DISABLE__SHIFT ;if (KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,4 ,3 ) || -KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,4 ,4 ) || -KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,5 ,0 )) +KFD_GC_VERSION (dqm->dev->kfd) ==IP_VERSION (9 ,4 ,4 )) qpd->sh_mem_config |= (1 <<SH_MEM_CONFIG__F8_MODE__SHIFT ); qpd->sh_mem_ape1_limit =0 ;
Greg Kroah-Hartman
maintainerPATCH 622/626 watchdog: aspeed: fix 64-bit division
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 48a136639ec233614a61653e19f559977d5da2b5 upstream.
On 32-bit architectures, the new calculation causes a build failure:
ld.lld-21: error: undefined symbol: __aeabi_uldivmod
Since neither value is ever larger than a register, cast both sides into a uintptr_t.
--- drivers/watchdog/aspeed_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/aspeed_wdt.c +1 -1
@@ -254,7 +254,7 @@ static void aspeed_wdt_update_bootstatusif (!of_device_is_compatible (pdev->dev.of_node,"aspeed,ast2400-wdt" )) { res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - idx = ((intptr_t )wdt->base &0x00000fff ) /resource_size (res); + idx = ((intptr_t )wdt->base &0x00000fff ) / (uintptr_t )resource_size (res); } scu_base =syscon_regmap_lookup_by_compatible (scu.compatible);
Greg Kroah-Hartman
maintainerPATCH 623/626 pinctrl: tegra: Fix off by one in tegra_pinctrl_get_group()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit 5a062c3c3b82004766bc3ece82b594d337076152 upstream.
This should be >= pmx->soc->ngroups instead of > to avoid an out of bounds access. The pmx->soc->groups[] array is allocated in tegra_pinctrl_probe().
--- drivers/pinctrl/tegra/pinctrl-tegra.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/tegra/pinctrl-tegra.c +1 -1
@@ -305,7 +305,7 @@ static const struct tegra_pingroup *tegr {struct tegra_pmx *pmx =pinctrl_dev_get_drvdata (pctldev); -if (group_index <0 || group_index > pmx->soc->ngroups) +if (group_index <0 || group_index >= pmx->soc->ngroups)return NULL ;return &pmx->soc->groups[group_index];
Greg Kroah-Hartman
maintainerPATCH 624/626 i3c: master: svc: Fix implicit fallthrough in svc_i3c_master_ibi_work()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Chancellor <[email protected]>
commit e8d2d287e26d9bd9114cf258a123a6b70812442e upstream.
Clang warns (or errors with CONFIG_WERROR=y):
drivers/i3c/master/svc-i3c-master.c:596:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
596 | default:
| ^
drivers/i3c/master/svc-i3c-master.c:596:2: note: insert 'break;' to avoid fall-through
596 | default:
| ^
| break;1 error generated.
Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return. Add the missing break to silence the warning.
--- drivers/i3c/master/svc-i3c-master.c | 1 + 1 file changed, 1 insertion(+)
drivers/i3c/master/svc-i3c-master.c +1 -0
@@ -512,6 +512,7 @@ static void svc_i3c_master_ibi_work(strubreak ;case SVC_I3C_MSTATUS_IBITYPE_MASTER_REQUEST :svc_i3c_master_emit_stop (master); +break ;default :break ; }
Greg Kroah-Hartman
maintainerPATCH 625/626 x86/mm/init: Handle the special case of device private pages in add_pages(), to not increase max_pfn and trigger dma_addressing_limited() bounce buffers bounce buffers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balbir Singh <[email protected]>
commit 7170130e4c72ce0caa0cb42a1627c635cc262821 upstream.
As Bert Karwatzki reported, the following recent commit causes a performance regression on AMD iGPU and dGPU systems:
7ffb791423c7 ("x86/kaslr: Reduce KASLR entropy on most x86 systems")
It exposed a bug with nokaslr and zone device interaction.
The root cause of the bug is that, the GPU driver registers a zone device private memory region. When KASLR is disabled or the above commit is applied, the direct_map_physmem_end is set to much higher than 10 TiB typically to the 64TiB address. When zone device private memory is added to the system via add_pages(), it bumps up the max_pfn to the same value. This causes dma_addressing_limited() to return true, since the device cannot address memory all the way up to max_pfn.
This caused a regression for games played on the iGPU, as it resulted in the DMA32 zone being used for GPU allocations.
Fix this by not bumping up max_pfn on x86 systems, when pgmap is passed into add_pages(). The presence of pgmap is used to determine if device private memory is being added via add_pages().
More details:
devm_request_mem_region() and request_free_mem_region() request for device private memory. iomem_resource is passed as the base resource with start and end parameters. iomem_resource's end depends on several factors, including the platform and virtualization. On x86 for example on bare metal, this value is set to boot_cpu_data.x86_phys_bits. boot_cpu_data.x86_phys_bits can change depending on support for MKTME. By default it is set to the same as log2(direct_map_physmem_end) which is 46 to 52 bits depending on the number of levels in the page table. The allocation routines used iomem_resource's end and direct_map_physmem_end to figure out where to allocate the region.
[ arch/powerpc is also impacted by this problem, but this patch does not fix
the issue for PowerPC. ]
Testing:
1. Tested on a virtual machine with test_hmm for zone device inseration
2. A previous version of this patch was tested by Bert, please see:
https://lore.kernel.org/lkml/[email protected]/
[ mingo: Clarified the comments and the changelog. ]
--- arch/x86/mm/init_64.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
arch/x86/mm/init_64.c +12 -3
@@ -967,9 +967,18 @@ int add_pages(int nid, unsigned long sta ret =__add_pages (nid, start_pfn, nr_pages, params);WARN_ON_ONCE (ret); -/* update max_pfn, max_low_pfn and high_memory */ -update_end_of_memory_vars (start_pfn <<PAGE_SHIFT , - nr_pages <<PAGE_SHIFT ); +/* +* Special case: add_pages() is called by memremap_pages() for adding device +* private pages. Do not bump up max_pfn in the device private path, +* because max_pfn changes affect dma_addressing_limited(). +* +* dma_addressing_limited() returning true when max_pfn is the device's +* addressable memory can force device drivers to use bounce buffers +* and impact their performance negatively: +*/ +if (!params->pgmap) +/* update max_pfn, max_low_pfn and high_memory */ +update_end_of_memory_vars (start_pfn <<PAGE_SHIFT , nr_pages <<PAGE_SHIFT );return ret; }
Greg Kroah-Hartman
maintainerPATCH 626/626 drm/gem: Internally test import_attach for imported objects
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Zimmermann <[email protected]>
commit 8260731ccad0451207b45844bb66eb161a209218 upstream.
Test struct drm_gem_object.import_attach to detect imported objects.
During object clenanup, the dma_buf field might be NULL. Testing it in an object's free callback then incorrectly does a cleanup as for native objects. Happens for calls to drm_mode_destroy_dumb_ioctl() that clears the dma_buf field in drm_gem_object_exported_dma_buf_free().
v3:
- only test for import_attach (Boris)
v2:
- use import_attach.dmabuf instead of dma_buf (Christian)
--- include/drm/drm_gem.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
include/drm/drm_gem.h +1 -2
@@ -580,8 +580,7 @@ static inline bool drm_gem_object_is_sha*/ static inline bool drm_gem_is_imported (const struct drm_gem_object *obj) { -/* The dma-buf's priv field points to the original GEM object. */ -return obj->dma_buf && (obj->dma_buf->priv != obj); +return !!obj->import_attach; }#ifdef CONFIG_LOCKDEP
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.31-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
On ARCH_BRCMSTB using 32-bit and 64-bit ARM kernels, build tested on BMIPS_GENERIC:
Signature · 1 line
Florian
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 9 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.31-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
thanks,
-- Shuah
Am 27.05.2025 um 18:18 schrieb Greg Kroah-Hartman:
Quoted 4 lines
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Builds, boots and works on my 2-socket Ivy Bridge Xeon E5-2697 v2 server. No dmesg oddities or regressions found.
Beste Grüße,
Peter Schneider
Signature · 8 lines
Climb the mountain not to plant your flag, but to embrace the challenge, enjoy the air and behold the view. Climb it so you can see the world, not so the world can see you. -- David McCullough Jr. OpenPGP: 0xA3828BD796CCE11A8CADE8866E3A92C92C3FF244 Download: https://www.peters-netzplatz.de/download/pschneider1968_pub.asc https://keys.mailvelope.com/pks/lookup?op=get&[email protected] https://keys.mailvelope.com/pks/lookup?op=get&[email protected]
Quoted 8 lines · On Tue, 27 May 2025 18:18:13 +0200 Greg Kroah-Hartman…
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
Boot-tested under QEMU for Rust x86_64, arm64 and riscv64; built-tested for loongarch64:
Thanks!
Cheers,
Miguel
Hi Greg,
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
No problems seen on x86_64 and aarch64 with our testing.
Thanks,
Harshit
Hi!
Quoted 4 lines
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
CIP testing did not find any problems here:
https://gitlab.com/cip-project/cip-testing/linux-stable-rc-ci/-/tree/linux-6.12.y
Best regards,
Pavel
Signature · 2 lines
DENX Software Engineering GmbH, Managing Director: Erika Unter HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.31-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
Built (with both gcc-14 and gcc-15) and booted successfully on RISC-V RV64 (HiFive Unmatched).
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.31-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
Results from Linaro’s test farm.
No regressions on arm64, arm, x86_64, and i386.
## Build
* kernel: 6.12.31-rc1
* git: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git
* git commit: 3fc6e1848884b217db332a5f677a33ad485a128e
* git describe: v6.12.30-627-g3fc6e1848884
* test details:
https://qa-reports.linaro.org/lkft/linux-stable-rc-linux-6.12.y/build/v6.12.30-627-g3fc6e1848884
## Test Regressions (compared to v6.12.29-144-g28ceb2ca3164)
## Metric Regressions (compared to v6.12.29-144-g28ceb2ca3164)
## Test Fixes (compared to v6.12.29-144-g28ceb2ca3164)
## Metric Fixes (compared to v6.12.29-144-g28ceb2ca3164)
## Test result summary
total: 323787, pass: 297841, fail: 5458, skip: 19725, xfail: 763
## Build Summary
* arc: 5 total, 5 passed, 0 failed
* arm: 139 total, 137 passed, 2 failed
* arm64: 57 total, 56 passed, 1 failed
* i386: 18 total, 18 passed, 0 failed
* mips: 34 total, 33 passed, 1 failed
* parisc: 4 total, 4 passed, 0 failed
* powerpc: 40 total, 40 passed, 0 failed
* riscv: 25 total, 23 passed, 2 failed
* s390: 22 total, 21 passed, 1 failed
* sh: 5 total, 5 passed, 0 failed
* sparc: 4 total, 3 passed, 1 failed
* x86_64: 49 total, 48 passed, 1 failed
## Test suites summary
* boot
* commands
* kselftest-arm64
* kselftest-breakpoints
* kselftest-capabilities
* kselftest-cgroup
* kselftest-clone3
* kselftest-core
* kselftest-cpu-hotplug
* kselftest-cpufreq
* kselftest-efivarfs
* kselftest-exec
* kselftest-fpu
* kselftest-ftrace
* kselftest-futex
* kselftest-gpio
* kselftest-intel_pstate
* kselftest-ipc
* kselftest-kcmp
* kselftest-kvm
* kselftest-livepatch
* kselftest-membarrier
* kselftest-memfd
* kselftest-mincore
* kselftest-mm
* kselftest-mqueue
* kselftest-net
* kselftest-net-mptcp
* kselftest-openat2
* kselftest-ptrace
* kselftest-rseq
* kselftest-rtc
* kselftest-seccomp
* kselftest-sigaltstack
* kselftest-size
* kselftest-tc-testing
* kselftest-timers
* kselftest-tmpfs
* kselftest-tpm2
* kselftest-user_events
* kselftest-vDSO
* kselftest-x86
* kunit
* kvm-unit-tests
* lava
* libgpiod
* libhugetlbfs
* log-parser-boot
* log-parser-build-clang
* log-parser-build-gcc
* log-parser-test
* ltp-capability
* ltp-commands
* ltp-containers
* ltp-controllers
* ltp-cpuhotplug
* ltp-crypto
* ltp-cve
* ltp-dio
* ltp-fcntl-locktests
* ltp-fs
* ltp-fs_bind
* ltp-fs_perms_simple
* ltp-hugetlb
* ltp-ipc
* ltp-math
* ltp-mm
* ltp-nptl
* ltp-pty
* ltp-sched
* ltp-smoke
* ltp-syscalls
* ltp-tracing
* modules
* perf
* rcutorture
* rt-tests-cyclicdeadline
* rt-tests-pi-stress
* rt-tests-pmqtest
* rt-tests-rt-migrate-test
* rt-tests-signaltest
--
Linaro LKFT
https://lkft.linaro.org
Quoted 4 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Quoted 10 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.31-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
Builds successfully. Boots and works on qemu and Dell XPS 15 9520 w/ Intel Core i7-12600H
Thanks,
Brett
Quoted 7 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.31 release. There are 626 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Thu, 29 May 2025 16:22:51 +0000. Anything received after that time might be too late.
Hi Greg
6.12.31-rc1 compiles on x86_64 (Xeon E5-1620 v2, Slackware64-15.0), and boots & runs on x86_64 (AMD Ryzen 5 7520U, Slackware64-current), no regressions observed.
The kernel, bpf tool, and perf tool builds fine for v6.12.31-rc1 on x86 and arm64 Azure VM.
Thanks,
Hardik