perf test stat: Update test expectations and events
Subsystems (274)
Sasha Levin
maintainerPATCH 612/752 rust/drm: Fix Registration::{new,new_foreign_owned}() docs
In reply to Sasha LevinFrom: Lyude Paul <[email protected]>
[ Upstream commit 638eeda8abaa3e6afe6bd5758ef8045a7f33b9a0 ]
Looks like we've actually had a malformed rustdoc reference in the rustdocs for Registration::new_foreign_owned() for a while that, when fixed, still couldn't resolve properly because it refers to a private item.
This is probably leftover from when Registration::new() was public, so drop the documentation from that function and fixup the documentation for Registration::new_foreign_owned().
--- rust/kernel/drm/driver.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
rust/kernel/drm/driver.rs +3 -3
@@ -121,7 +121,6 @@ pub trait Driver {pub struct Registration <T :Driver >(ARef <drm::Device <T >>);impl <T :Driver >Registration <T > { -/// Creates a new [`Registration`] and registers it. fn new (drm: &drm::Device <T >, flags:usize ) ->Result <Self > {// SAFETY: `drm.as_raw()` is valid by the invariants of `drm::Device`. to_result (unsafe { bindings::drm_dev_register (drm.as_raw (), flags) })?;
@@ -129,8 +128,9 @@ impl<T: Driver> Registration<T> {Ok (Self (drm.into ())) } -/// Same as [`Registration::new`}, but transfers ownership of the [`Registration`] to -/// [`devres::register`]. +/// Registers a new [`Device`](drm::Device) with userspace. +/// +/// Ownership of the [`Registration`] object is passed to [`devres::register`]. pub fn new_foreign_owned ( drm: &drm::Device <T >, dev: &device::Device<device::Bound>,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 613/752 KVM: x86: Add SRCU protection for reading PDPTRs in __get_sregs2()
In reply to Sasha LevinFrom: Vasiliy Kovalev <[email protected]>
[ Upstream commit 95d848dc7e639988dbb385a8cba9b484607cf98c ]
Add SRCU read-side protection when reading PDPTR registers in __get_sregs2().
Reading PDPTRs may trigger access to guest memory:kvm_pdptr_read() -> svm_cache_reg() -> load_pdptrs() -> kvm_vcpu_read_guest_page() -> kvm_vcpu_gfn_to_memslot()
kvm_vcpu_gfn_to_memslot() dereferences memslots via __kvm_memslots(), which uses srcu_dereference_check() and requires either kvm->srcu or kvm->slots_lock to be held. Currently only vcpu->mutex is held, triggering lockdep warning:
=============================
WARNING: suspicious RCU usage in kvm_vcpu_gfn_to_memslot 6.12.59+ #3 Not tainted
include/linux/kvm_host.h:1062 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
1 lock held by syz.5.1717/15100:
#0: ff1100002f4b00b0 (&vcpu->mutex){+.+.}-{3:3}, at: kvm_vcpu_ioctl+0x1d5/0x1590
Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xf0/0x120 lib/dump_stack.c:120 lockdep_rcu_suspicious+0x1e3/0x270 kernel/locking/lockdep.c:6824 __kvm_memslots include/linux/kvm_host.h:1062 [inline] __kvm_memslots include/linux/kvm_host.h:1059 [inline] kvm_vcpu_memslots include/linux/kvm_host.h:1076 [inline] kvm_vcpu_gfn_to_memslot+0x518/0x5e0 virt/kvm/kvm_main.c:2617 kvm_vcpu_read_guest_page+0x27/0x50 virt/kvm/kvm_main.c:3302 load_pdptrs+0xff/0x4b0 arch/x86/kvm/x86.c:1065 svm_cache_reg+0x1c9/0x230 arch/x86/kvm/svm/svm.c:1688 kvm_pdptr_read arch/x86/kvm/kvm_cache_regs.h:141 [inline] __get_sregs2 arch/x86/kvm/x86.c:11784 [inline] kvm_arch_vcpu_ioctl+0x3e20/0x4aa0 arch/x86/kvm/x86.c:6279 kvm_vcpu_ioctl+0x856/0x1590 virt/kvm/kvm_main.c:4663 vfs_ioctl fs/ioctl.c:51 [inline] __do_sys_ioctl fs/ioctl.c:907 [inline] __se_sys_ioctl fs/ioctl.c:893 [inline] __x64_sys_ioctl+0x18b/0x210 fs/ioctl.c:893 do_syscall_x64 arch/x86/entry/common.c:52 [inline] do_syscall_64+0xbd/0x1d0 arch/x86/entry/common.c:83 entry_SYSCALL_64_after_hwframe+0x77/0x7f
Found by Linux Verification Center (linuxtesting.org) with Syzkaller.
--- arch/x86/kvm/x86.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kvm/x86.c +2 -0
@@ -12147,9 +12147,11 @@ static void __get_sregs2(struct kvm_vcpu *vcpu, struct kvm_sregs2 *sregs2)return ;if (is_pae_paging (vcpu)) { +kvm_vcpu_srcu_read_lock (vcpu);for (i =0 ; i <4 ; i++) sregs2->pdptrs[i] =kvm_pdptr_read (vcpu, i); sregs2->flags |=KVM_SREGS2_FLAGS_PDPTRS_VALID ; +kvm_vcpu_srcu_read_unlock (vcpu); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 614/752 PCI: endpoint: Fix swapped parameters in pci_{primary/secondary}_epc_epf_unlink() functions
In reply to Sasha LevinFrom: Manikanta Maddireddy <[email protected]>
[ Upstream commit 8754dd7639ab0fd68c3ab9d91c7bdecc3e5740a8 ]
struct configfs_item_operations callbacks are defined like the following:
int (*allow_link)(struct config_item *src, struct config_item *target); void (*drop_link)(struct config_item *src, struct config_item *target);
While pci_primary_epc_epf_link() and pci_secondary_epc_epf_link() specify the parameters in the correct order, pci_primary_epc_epf_unlink() and pci_secondary_epc_epf_unlink() specify the parameters in the wrong order, leading to the below kernel crash when using the unlink command in configfs:
Unable to handle kernel paging request at virtual address 0000000300000857 Mem abort info: ... pc : string+0x54/0x14c lr : vsnprintf+0x280/0x6e8 ... string+0x54/0x14c vsnprintf+0x280/0x6e8 vprintk_default+0x38/0x4c vprintk+0xc4/0xe0 pci_epf_unbind+0xdc/0x108 configfs_unlink+0xe0/0x208+0x44/0x74 vfs_unlink+0x120/0x29c __arm64_sys_unlinkat+0x3c/0x90 invoke_syscall+0x48/0x134 do_el0_svc+0x1c/0x30prop.0+0xd0/0xf0
--- drivers/pci/endpoint/pci-ep-cfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pci/endpoint/pci-ep-cfs.c +4 -4
@@ -68,8 +68,8 @@ static int pci_secondary_epc_epf_link(struct config_item *epf_item,return 0 ; } -static void pci_secondary_epc_epf_unlink (struct config_item *epc_item, -struct config_item *epf_item) +static void pci_secondary_epc_epf_unlink (struct config_item *epf_item, +struct config_item *epc_item) {struct pci_epf_group *epf_group =to_pci_epf_group (epf_item->ci_parent);struct pci_epc_group *epc_group =to_pci_epc_group (epc_item);
@@ -132,8 +132,8 @@ static int pci_primary_epc_epf_link(struct config_item *epf_item,return 0 ; } -static void pci_primary_epc_epf_unlink (struct config_item *epc_item, -struct config_item *epf_item) +static void pci_primary_epc_epf_unlink (struct config_item *epf_item, +struct config_item *epc_item) {struct pci_epf_group *epf_group =to_pci_epf_group (epf_item->ci_parent);struct pci_epc_group *epc_group =to_pci_epc_group (epc_item);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 615/752 pinctrl: intel: Add code name documentation
In reply to Sasha LevinFrom: Raag Jadav <[email protected]>
[ Upstream commit fc32c5725fbe1164d353400389d3e29d19960a3a ]
Intel pinctrl drivers support large set of platforms and the IPs are often reused by their different variants, but it's currently not possible to figure out the exact driver that supports specific variant. Add user friendly documentation for them.
--- drivers/pinctrl/intel/Kconfig | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/pinctrl/intel/Kconfig +15 -6
@@ -52,7 +52,10 @@ config PINCTRL_ALDERLAKE select PINCTRL_INTEL help This pinctrl driver provides an interface that allows configuring - of Intel Alder Lake PCH pins and using them as GPIOs. + PCH pins of the following platforms and using them as GPIOs: + - Alder Lake HX, N, and S + - Raptor Lake HX, E, and S + - Twin Lake config PINCTRL_BROXTON tristate "Intel Broxton pinctrl and GPIO driver"
@@ -136,15 +139,17 @@ config PINCTRL_METEORLAKE select PINCTRL_INTEL help This pinctrl driver provides an interface that allows configuring - of Intel Meteor Lake pins and using them as GPIOs. + SoC pins of the following platforms and using them as GPIOs: + - Arrow Lake (all variants) + - Meteor Lake (all variants) config PINCTRL_METEORPOINT tristate "Intel Meteor Point pinctrl and GPIO driver" select PINCTRL_INTEL help - Meteor Point is the PCH of Intel Meteor Lake. This pinctrl driver - provides an interface that allows configuring of PCH pins and - using them as GPIOs. + This pinctrl driver provides an interface that allows configuring + PCH pins of the following platforms and using them as GPIOs: + - Arrow Lake HX and S config PINCTRL_SUNRISEPOINT tristate "Intel Sunrisepoint pinctrl and GPIO driver"
@@ -159,7 +164,11 @@ config PINCTRL_TIGERLAKE select PINCTRL_INTEL help This pinctrl driver provides an interface that allows configuring - of Intel Tiger Lake PCH pins and using them as GPIOs. + PCH pins of the following platforms and using them as GPIOs: + - Alder Lake H, P, PS, and U + - Raptor Lake H, P, PS, PX, and U + - Rocket Lake S + - Tiger Lake (all variants) source "drivers/pinctrl/intel/Kconfig.tng" endmenu
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 616/752 xfs: only call xf{array,blob}_destroy if we have a valid pointer
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit ba408d299a3bb3c5309f40c5326e4fb83ead4247 ]
Only call the xfarray and xfblob destructor if we have a valid pointer, and be sure to null out that pointer afterwards. Note that this patch fixes a large number of commits, most of which were merged between 6.9 and 6.10.
--- fs/xfs/scrub/agheader_repair.c | 8 ++++++-- fs/xfs/scrub/attr_repair.c | 6 ++++-- fs/xfs/scrub/dir_repair.c | 8 ++++++-- fs/xfs/scrub/dirtree.c | 8 ++++++-- fs/xfs/scrub/nlinks.c | 3 ++- 5 files changed, 24 insertions(+), 9 deletions(-)
fs/xfs/scrub/agheader_repair.c +6 -2
@@ -837,8 +837,12 @@ xrep_agi_buf_cleanup( {struct xrep_agi *ragi = buf; -xfarray_destroy (ragi->iunlink_prev); -xfarray_destroy (ragi->iunlink_next); +if (ragi->iunlink_prev) +xfarray_destroy (ragi->iunlink_prev); + ragi->iunlink_prev =NULL ; +if (ragi->iunlink_next) +xfarray_destroy (ragi->iunlink_next); + ragi->iunlink_next =NULL ;xagino_bitmap_destroy (&ragi->iunlink_bmp); }
fs/xfs/scrub/attr_repair.c +4 -2
@@ -1516,8 +1516,10 @@ xrep_xattr_teardown(xfblob_destroy (rx->pptr_names);if (rx->pptr_recs)xfarray_destroy (rx->pptr_recs); -xfblob_destroy (rx->xattr_blobs); -xfarray_destroy (rx->xattr_records); +if (rx->xattr_blobs) +xfblob_destroy (rx->xattr_blobs); +if (rx->xattr_records) +xfarray_destroy (rx->xattr_records);mutex_destroy (&rx->lock);kfree (rx); }
fs/xfs/scrub/dir_repair.c +6 -2
@@ -172,8 +172,12 @@ xrep_dir_teardown(struct xrep_dir *rd = sc->buf;xrep_findparent_scan_teardown (&rd->pscan); -xfblob_destroy (rd->dir_names); -xfarray_destroy (rd->dir_entries); +if (rd->dir_names) +xfblob_destroy (rd->dir_names); + rd->dir_names =NULL ; +if (rd->dir_entries) +xfarray_destroy (rd->dir_entries); + rd->dir_names =NULL ; }/* Set up for a directory repair. */
fs/xfs/scrub/dirtree.c +6 -2
@@ -81,8 +81,12 @@ xchk_dirtree_buf_cleanup(kfree (path); } -xfblob_destroy (dl->path_names); -xfarray_destroy (dl->path_steps); +if (dl->path_names) +xfblob_destroy (dl->path_names); + dl->path_names =NULL ; +if (dl->path_steps) +xfarray_destroy (dl->path_steps); + dl->path_steps =NULL ;mutex_destroy (&dl->lock); }
fs/xfs/scrub/nlinks.c +2 -1
@@ -971,7 +971,8 @@ xchk_nlinks_teardown_scan(xfs_dir_hook_del (xnc->sc->mp, &xnc->dhook); -xfarray_destroy (xnc->nlinks); +if (xnc->nlinks) +xfarray_destroy (xnc->nlinks); xnc->nlinks =NULL ;xchk_iscan_teardown (&xnc->collect_iscan);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 617/752 xfs: check return value of xchk_scrub_create_subord
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit ca27313fb3f23e4ac18532ede4ec1c7cc5814c4a ]
Fix this function to return NULL instead of a mangled ENOMEM, then fix the callers to actually check for a null pointer and return ENOMEM. Most of the corrections here are for code merged between 6.2 and 6.10.
--- fs/xfs/scrub/common.c | 3 +++ fs/xfs/scrub/repair.c | 3 +++ fs/xfs/scrub/scrub.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-)
fs/xfs/scrub/common.c +3 -0
@@ -1399,6 +1399,9 @@ xchk_metadata_inode_subtype(int error; sub =xchk_scrub_create_subord (sc, scrub_type); +if (!sub) +return -ENOMEM ; + error = sub->sc.ops->scrub (&sub->sc);xchk_scrub_free_subord (sub);return error;
fs/xfs/scrub/repair.c +3 -0
@@ -1136,6 +1136,9 @@ xrep_metadata_inode_subtype(* setup/teardown routines. */ sub =xchk_scrub_create_subord (sc, scrub_type); +if (!sub) +return -ENOMEM ; + error = sub->sc.ops->scrub (&sub->sc);if (error) goto out;
fs/xfs/scrub/scrub.c +1 -1
@@ -634,7 +634,7 @@ xchk_scrub_create_subord( sub =kzalloc (sizeof (*sub),XCHK_GFP_FLAGS );if (!sub) -return ERR_PTR (-ENOMEM ); +return NULL ; sub->old_smtype = sc->sm->sm_type; sub->old_smflags = sc->sm->sm_flags;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 618/752 xfs: check for deleted cursors when revalidating two btrees
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 55e03b8cbe2783ec9acfb88e8adb946ed504e117 ]
The free space and inode btree repair functions will rebuild both btrees at the same time, after which it needs to evaluate both btrees to confirm that the corruptions are gone.
However, Jiaming Zhang ran syzbot and produced a crash in the second xchk_allocbt call. His root-cause analysis is as follows (with minor corrections):
In xrep_revalidate_allocbt(), xchk_allocbt() is called twice (first for BNOBT, second for CNTBT). The cause of this issue is that the first call nullified the cursor required by the second call.
Let's first enter xrep_revalidate_allocbt() via following call chain:
xfs_file_ioctl() ->
xfs_ioc_scrubv_metadata() ->
xfs_scrub_metadata() ->
sc->ops->repair_eval(sc) ->
xrep_revalidate_allocbt()
xchk_allocbt() is called twice in this function. In the first call:
/* Note that sc->sm->sm_type is XFS_SCRUB_TYPE_BNOPT now */ xchk_allocbt() ->
xchk_btree() ->
bs->scrub_rec(bs, recp) ->
xchk_allocbt_rec() ->
xchk_allocbt_xref() ->
xchk_allocbt_xref_other()
since sm_type is XFS_SCRUB_TYPE_BNOBT, pur is set to &sc->sa.cnt_cur. Kernel called xfs_alloc_get_rec() and returned -EFSCORRUPTED. Call chain:
xfs_alloc_get_rec() ->
xfs_btree_get_rec() ->
xfs_btree_check_block() ->
(XFS_IS_CORRUPT || XFS_TEST_ERROR), the former is false and the latter is true, return -EFSCORRUPTED. This should be caused by ioctl$XFS_IOC_ERROR_INJECTION I guess.
Back to xchk_allocbt_xref_other(), after receiving -EFSCORRUPTED from xfs_alloc_get_rec(), kernel called xchk_should_check_xref(). In this function, *curpp (points to sc->sa.cnt_cur) is nullified.
Back to xrep_revalidate_allocbt(), since sc->sa.cnt_cur has been nullified, it then triggered null-ptr-deref via xchk_allocbt() (second call) -> xchk_btree().
So. The bnobt revalidation failed on a cross-reference attempt, so we deleted the cntbt cursor, and then crashed when we tried to revalidate the cntbt. Therefore, check for a null cntbt cursor before that revalidation, and mark the repair incomplete. Also we can ignore the second tree entirely if the first tree was rebuilt but is already corrupt.
Apply the same fix to xrep_revalidate_iallocbt because it has the same problem.
--- fs/xfs/scrub/alloc_repair.c | 15 +++++++++++++++ fs/xfs/scrub/ialloc_repair.c | 20 +++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-)
fs/xfs/scrub/alloc_repair.c +15 -0
@@ -923,7 +923,22 @@ xrep_revalidate_allocbt(if (error) goto out; +/* +* If the bnobt is still corrupt, we've failed to repair the filesystem +* and should just bail out. +* +* If the bnobt fails cross-examination with the cntbt, the scan will +* free the cntbt cursor, so we need to mark the repair incomplete +* and avoid walking off the end of the NULL cntbt cursor. +*/ +if (sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT ) + goto out; + sc->sm->sm_type =XFS_SCRUB_TYPE_CNTBT ; +if (!sc->sa.cnt_cur) { +xchk_set_incomplete (sc); + goto out; + } error =xchk_allocbt (sc); out: sc->sm->sm_type = old_type;
fs/xfs/scrub/ialloc_repair.c +17 -3
@@ -863,10 +863,24 @@ xrep_revalidate_iallocbt(if (error) goto out; -if (xfs_has_finobt (sc->mp)) { - sc->sm->sm_type =XFS_SCRUB_TYPE_FINOBT ; - error =xchk_iallocbt (sc); +/* +* If the inobt is still corrupt, we've failed to repair the filesystem +* and should just bail out. +* +* If the inobt fails cross-examination with the finobt, the scan will +* free the finobt cursor, so we need to mark the repair incomplete +* and avoid walking off the end of the NULL finobt cursor. +*/ +if (!xfs_has_finobt (sc->mp) || + (sc->sm->sm_flags &XFS_SCRUB_OFLAG_CORRUPT )) + goto out; + + sc->sm->sm_type =XFS_SCRUB_TYPE_FINOBT ; +if (!sc->sa.fino_cur) { +xchk_set_incomplete (sc); + goto out; } + error =xchk_iallocbt (sc); out: sc->sm->sm_type = old_type;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 619/752 md/bitmap: fix GPF in write_page caused by resize race
In reply to Sasha LevinFrom: Jack Wang <[email protected]>
[ Upstream commit 46ef85f854dfa9d5226b3c1c46493d79556c9589 ]
A General Protection Fault occurs in write_page() during array resize:
RIP: 0010:write_page+0x22b/0x3c0 [md_mod]
This is a use-after-free race between bitmap_daemon_work() and __bitmap_resize(). The daemon iterates over bitmap->storage.filemap without locking, while the resize path frees that storage via md_bitmap_file_unmap(). quiesce() does not stop the md thread, allowing concurrent access to freed pages.
Fix by holding mddev->bitmap_info.mutex during the bitmap update.
--- drivers/md/md-bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/md-bitmap.c +2 -1
@@ -2453,6 +2453,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,memcpy (page_address (store.sb_page),page_address (bitmap->storage.sb_page),sizeof (bitmap_super_t)); +mutex_lock (&bitmap->mddev->bitmap_info.mutex);spin_lock_irq (&bitmap->counts.lock);md_bitmap_file_unmap (&bitmap->storage); bitmap->storage = store;
@@ -2560,7 +2561,7 @@ static int __bitmap_resize(struct bitmap *bitmap, sector_t blocks,set_page_attr (bitmap, i,BITMAP_PAGE_DIRTY ); }spin_unlock_irq (&bitmap->counts.lock); - +mutex_unlock (&bitmap->mddev->bitmap_info.mutex);if (!init) {__bitmap_unplug (bitmap); bitmap->mddev->pers->quiesce (bitmap->mddev,0 );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 620/752 NFSD: fix setting FMODE_NOCMTIME in nfs4_open_delegation
In reply to Sasha LevinFrom: Olga Kornievskaia <[email protected]>
[ Upstream commit 41b0a87bc60d5ccfa8575481ddb4d4d8758507fa ]
fstests generic/215 and generic/407 were failing because the server wasn't updating mtime properly. When deleg attribute support is not compiled in and thus no attribute delegation was given, the server was skipping updating mtime and ctime because FMODE_NOCMTIME was uncoditionally set for the write delegation.
--- fs/nfsd/nfs4state.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/nfsd/nfs4state.c +2 -1
@@ -6356,7 +6356,8 @@ nfs4_open_delegation(struct svc_rqst *rqstp, struct nfsd4_open *open, dp->dl_ctime = stat.ctime; dp->dl_mtime = stat.mtime;spin_lock (&f->f_lock); - f->f_mode |=FMODE_NOCMTIME ; +if (deleg_ts) + f->f_mode |=FMODE_NOCMTIME ;spin_unlock (&f->f_lock);trace_nfsd_deleg_write (&dp->dl_stid.sc_stateid); }else {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 621/752 nfsd: fix return error code for nfsd_map_name_to_[ug]id
In reply to Sasha LevinFrom: Anthony Iliopoulos <[email protected]>
[ Upstream commit 404d779466646bf1461f2090ff137e99acaecf42 ]
idmap lookups can time out while the cache is waiting for a userspace upcall reply. In that case cache_check() returns -ETIMEDOUT to callers.
The nfsd_map_name_to_[ug]id functions currently proceed with attempting to map the id to a kuid despite a potentially temporary failure to perform the idmap lookup. This results in the code returning the error NFSERR_BADOWNER which can cause client operations to return to userspace with failure.
Fix this by returning the failure status before attempting kuid mapping.
This will return NFSERR_JUKEBOX on idmap lookup timeout so that clients can retry the operation instead of aborting it.
--- fs/nfsd/nfs4idmap.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/nfsd/nfs4idmap.c +4 -0
@@ -672,6 +672,8 @@ __be32 nfsd_map_name_to_uid(struct svc_rqst *rqstp, const char *name,return nfserr_inval; status =do_name_to_id (rqstp,IDMAP_TYPE_USER , name, namelen, &id); +if (status) +return status; *uid =make_kuid (nfsd_user_namespace (rqstp), id);if (!uid_valid (*uid)) status = nfserr_badowner;
@@ -707,6 +709,8 @@ __be32 nfsd_map_name_to_gid(struct svc_rqst *rqstp, const char *name,return nfserr_inval; status =do_name_to_id (rqstp,IDMAP_TYPE_GROUP , name, namelen, &id); +if (status) +return status; *gid =make_kgid (nfsd_user_namespace (rqstp), id);if (!gid_valid (*gid)) status = nfserr_badowner;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 622/752 nvmem: Drop OF node reference on nvmem_add_one_cell() failure
In reply to Sasha LevinFrom: Krzysztof Kozlowski <[email protected]>
[ Upstream commit f397bc0781553d01b4cdba506c09334a31cb0ec5 ]
If nvmem_add_one_cell() failed, the ownership of "child" (or "info.np"), thus its OF reference, is not passed further and function should clean up by putting the reference it got via earlier of_node_get(). Note that this is independent of references obtained via for_each_child_of_node() loop.
--- drivers/nvmem/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/core.c +1 -0
@@ -831,6 +831,7 @@ static int nvmem_add_cells_from_dt(struct nvmem_device *nvmem, struct device_nodkfree (info.name);if (ret) {of_node_put (child); +of_node_put (info.np);return ret; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 623/752 PCI: Fix bridge window alignment with optional resources
In reply to Sasha LevinFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 7e90360e6d4599795b6f4e094e20d0bdf3b2615f ]
pbus_size_mem() has two alignments, one for required resources in min_align and another in add_align that takes account optional resources.
The add_align is applied to the bridge window through the realloc_head list. It can happen, however, that add_align is larger than min_align but calculated size1 and size0 are equal due to extra tailroom (e.g., hotplug reservation, tail alignment), and therefore no entry is created to the realloc_head list. Without the bridge appearing in the realloc head, add_align is lost when pbus_size_mem() returns.
The problem is visible in this log for 0000:05:00.0 which lacks add_size ... add_align ... line that would indicate it was added into the realloc_head list:
pci 0000:05:00.0: PCI bridge to [bus 06-16]
...
pci 0000:06:00.0: bridge window [mem 0x00100000-0x001fffff] to [bus 07] requires relaxed alignment rules pci 0000:06:06.0: bridge window [mem 0x00100000-0x001fffff] to [bus 0a] requires relaxed alignment rules pci 0000:06:07.0: bridge window [mem 0x00100000-0x003fffff] to [bus 0b] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x00800000-0x00ffffff 64bit pref] to [bus 0c-14] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x01000000-0x057fffff] to [bus 0c-14] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x01000000-0x057fffff] to [bus 0c-14] requires relaxed alignment rules pci 0000:06:08.0: bridge window [mem 0x01000000-0x057fffff] to [bus 0c-14] add_size 100000 add_align 1000000 pci 0000:06:0c.0: bridge window [mem 0x00100000-0x001fffff] to [bus 15] requires relaxed alignment rules pci 0000:06:0d.0: bridge window [mem 0x00100000-0x001fffff] to [bus 16] requires relaxed alignment rules pci 0000:06:0d.0: bridge window [mem 0x00100000-0x001fffff] to [bus 16] requires relaxed alignment rules pci 0000:05:00.0: bridge window [mem 0xd4800000-0xd97fffff]: assigned
pci 0000:05:00.0: bridge window [mem 0x1060000000-0x10607fffff 64bit pref]: assigned
pci 0000:06:08.0: bridge window [mem size 0x04900000]: can't assign; no space
pci 0000:06:08.0: bridge window [mem size 0x04900000]: failed to assign
While this bug itself seems old, it has likely become more visible after the relaxed tail alignment that does not grossly overestimate the size needed for the bridge window.
Make sure add_align > min_align too results in adding an entry into the realloc head list. In addition, add handling to the cases where add_size is zero while only alignment differs.
--- drivers/pci/setup-bus.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pci/setup-bus.c +6 -4
@@ -14,6 +14,7 @@* tighter packing. Prefetchable range support. */ +#include <linux/align.h> #include <linux/bitops.h> #include <linux/init.h> #include <linux/kernel.h>
@@ -459,7 +460,7 @@ static void reassign_resources_sorted(struct list_head *realloc_head,"%s %pR: ignoring failure in optional allocation\n" , res_name, res); } - }else if (add_size >0 ) { + }else if (add_size >0 || !IS_ALIGNED (res->start, align)) { res->flags |= add_res->flags & (IORESOURCE_STARTALIGN |IORESOURCE_SIZEALIGN );if (pci_reassign_resource (dev, idx, add_size, align))
@@ -1388,12 +1389,13 @@ static void pbus_size_mem(struct pci_bus *bus, unsigned long type,resource_set_range (b_res, min_align, size0); b_res->flags |=IORESOURCE_STARTALIGN ; -if (bus->self && size1 > size0 && realloc_head) { +if (bus->self && realloc_head && (size1 > size0 || add_align > min_align)) { b_res->flags &= ~IORESOURCE_DISABLED ; -add_to_list (realloc_head, bus->self, b_res, size1-size0, add_align); + add_size = size1 > size0 ? size1 - size0 :0 ; +add_to_list (realloc_head, bus->self, b_res, add_size, add_align);pci_info (bus->self,"bridge window %pR to %pR add_size %llx add_align %llx\n" , b_res, &bus->busn_res, - (unsigned long long ) (size1 - size0), + (unsigned long long ) add_size, (unsigned long long ) add_align); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 624/752 ima: verify the previous kernel's IMA buffer lies in addressable RAM
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 10d1c75ed4382a8e79874379caa2ead8952734f9 ]
Patch series "Address page fault in ima_restore_measurement_list()", v3.
When the second-stage kernel is booted via kexec with a limiting command line such as "mem=<size>" we observe a pafe fault that happens.
BUG: unable to handle page fault for address: ffff97793ff47000
RIP: ima_restore_measurement_list+0xdc/0x45a
#PF: error_code(0x0000) not-present pageThis happens on x86_64 only, as this is already fixed in aarch64 in
commit: cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer against memory bounds")
This patch (of 3):
When the second-stage kernel is booted with a limiting command line (e.g. "mem=<size>"), the IMA measurement buffer handed over from the previous kernel may fall outside the addressable RAM of the new kernel. Accessing such a buffer can fault during early restore.
Introduce a small generic helper, ima_validate_range(), which verifies that a physical [start, end] range for the previous-kernel IMA buffer lies within addressable memory:
- On x86, use pfn_range_is_mapped().
- On OF based architectures, use page_is_ram().
--- include/linux/ima.h | 1 + security/integrity/ima/ima_kexec.c | 35 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/linux/ima.h +1 -0
@@ -69,6 +69,7 @@ static inline int ima_measure_critical_data(const char *event_label,#ifdef CONFIG_HAVE_IMA_KEXEC int __init ima_free_kexec_buffer (void );int __init ima_get_kexec_buffer (void **addr,size_t *size); +int ima_validate_range (phys_addr_t phys,size_t size);#endif #ifdef CONFIG_IMA_SECURE_AND_OR_TRUSTED_BOOT
security/integrity/ima/ima_kexec.c +35 -0
@@ -12,6 +12,8 @@#include <linux/kexec.h> #include <linux/of.h> #include <linux/ima.h> +#include <linux/mm.h> +#include <linux/overflow.h> #include <linux/reboot.h> #include <asm/page.h> #include "ima.h"
@@ -294,3 +296,36 @@ void __init ima_load_kexec_buffer(void)pr_debug ("Error restoring the measurement list: %d\n" , rc); } } + +/* +* ima_validate_range - verify a physical buffer lies in addressable RAM +* @phys: physical start address of the buffer from previous kernel +* @size: size of the buffer +* +* On success return 0. On failure returns -EINVAL so callers can skip +* restoring. +*/ +int ima_validate_range (phys_addr_t phys,size_t size) +{ +unsigned long start_pfn, end_pfn; +phys_addr_t end_phys; + +if (check_add_overflow (phys, (phys_addr_t )size -1 , &end_phys)) +return -EINVAL ; + + start_pfn =PHYS_PFN (phys); + end_pfn =PHYS_PFN (end_phys); + +#ifdef CONFIG_X86 +if (!pfn_range_is_mapped (start_pfn, end_pfn)) +#else + if (!page_is_ram(start_pfn) || !page_is_ram(end_pfn)) +#endif + { +pr_warn ("IMA: previous kernel measurement buffer %pa (size 0x%zx) lies outside available memory\n" , + &phys, size); +return -EINVAL ; + } + +return 0 ; +}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 625/752 of/kexec: refactor ima_get_kexec_buffer() to use ima_validate_range()
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit 4d02233235ed0450de9c10fcdcf3484e3c9401ce ]
Refactor the OF/DT ima_get_kexec_buffer() to use a generic helper to validate the address range. No functional change intended.
--- drivers/of/kexec.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-)
drivers/of/kexec.c +3 -12
@@ -128,7 +128,6 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size) {int ret, len;unsigned long tmp_addr; -unsigned long start_pfn, end_pfn;size_t tmp_size;const void *prop;
@@ -144,17 +143,9 @@ int __init ima_get_kexec_buffer(void **addr, size_t *size)if (!tmp_size)return -ENOENT ; -/* -* Calculate the PFNs for the buffer and ensure -* they are with in addressable memory. -*/ - start_pfn =PHYS_PFN (tmp_addr); - end_pfn =PHYS_PFN (tmp_addr + tmp_size -1 ); -if (!page_is_ram (start_pfn) || !page_is_ram (end_pfn)) { -pr_warn ("IMA buffer at 0x%lx, size = 0x%zx beyond memory\n" , - tmp_addr, tmp_size); -return -EINVAL ; - } + ret =ima_validate_range (tmp_addr, tmp_size); +if (ret) +return ret; *addr =__va (tmp_addr); *size = tmp_size;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 626/752 x86/kexec: add a sanity check on previous kernel's ima kexec buffer
In reply to Sasha LevinFrom: Harshit Mogalapalli <[email protected]>
[ Upstream commit c5489d04337b47e93c0623e8145fcba3f5739efd ]
When the second-stage kernel is booted via kexec with a limiting command line such as "mem=<size>", the physical range that contains the carried over IMA measurement list may fall outside the truncated RAM leading to a kernel panic.
BUG: unable to handle page fault for address: ffff97793ff47000
RIP: ima_restore_measurement_list+0xdc/0x45a
#PF: error_code(0x0000) – not-present pageOther architectures already validate the range with page_is_ram(), as done in commit cbf9c4b9617b ("of: check previous kernel's ima-kexec-buffer against memory bounds") do a similar check on x86.
Without carrying the measurement list across kexec, the attestation would fail.
--- arch/x86/kernel/setup.c | 6 ++++++ 1 file changed, 6 insertions(+)
arch/x86/kernel/setup.c +6 -0
@@ -439,9 +439,15 @@ int __init ima_free_kexec_buffer(void)int __init ima_get_kexec_buffer (void **addr,size_t *size) { +int ret; +if (!ima_kexec_buffer_size)return -ENOENT ; + ret =ima_validate_range (ima_kexec_buffer_phys, ima_kexec_buffer_size); +if (ret) +return ret; + *addr =__va (ima_kexec_buffer_phys); *size = ima_kexec_buffer_size;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 627/752 mm/vmalloc: prevent RCU stalls in kasan_release_vmalloc_node
In reply to Sasha LevinFrom: Deepanshu Kartikey <[email protected]>
[ Upstream commit 5747435e0fd474c24530ef1a6822f47e7d264b27 ]
When CONFIG_PAGE_OWNER is enabled, freeing KASAN shadow pages during vmalloc cleanup triggers expensive stack unwinding that acquires RCU read locks. Processing a large purge_list without rescheduling can cause the task to hold CPU for extended periods (10+ seconds), leading to RCU stalls and potential OOM conditions.
The issue manifests in purge_vmap_node() -> kasan_release_vmalloc_node() where iterating through hundreds or thousands of vmap_area entries and freeing their associated shadow pages causes:
rcu: INFO: rcu_preempt detected stalls on CPUs/tasks: rcu: Tasks blocked on level-0 rcu_node (CPUs 0-1): P6229/1:b..l ... task:kworker/0:17 state:R running task stack:28840 pid:6229 ... kasan_release_vmalloc_node+0x1ba/0xad0 mm/vmalloc.c:2299 purge_vmap_node+0x1ba/0xad0 mm/vmalloc.c:2299
Each call to kasan_release_vmalloc() can free many pages, and with page_owner tracking, each free triggers save_stack() which performs stack unwinding under RCU read lock. Without yielding, this creates an unbounded RCU critical section.
Add periodic cond_resched() calls within the loop to allow:
- RCU grace periods to complete
- Other tasks to run
- Scheduler to preempt when needed
The fix uses need_resched() for immediate response under load, with a batch count of 32 as a guaranteed upper bound to prevent worst-case stalls even under light load.
--- mm/vmalloc.c | 8 ++++++++ 1 file changed, 8 insertions(+)
mm/vmalloc.c +8 -0
@@ -2241,11 +2241,14 @@ decay_va_pool_node(struct vmap_node *vn, bool full_decay)reclaim_list_global (&decay_list); } +#define KASAN_RELEASE_BATCH_SIZE 32 +static void kasan_release_vmalloc_node (struct vmap_node *vn) {struct vmap_area *va;unsigned long start, end; +unsigned int batch_count =0 ; start = list_first_entry(&vn->purge_list, struct vmap_area, list)->va_start; end = list_last_entry(&vn->purge_list, struct vmap_area, list)->va_end;
@@ -2255,6 +2258,11 @@ kasan_release_vmalloc_node(struct vmap_node *vn)kasan_release_vmalloc (va->va_start, va->va_end, va->va_start, va->va_end,KASAN_VMALLOC_PAGE_RANGE ); + +if (need_resched () || (++batch_count >=KASAN_RELEASE_BATCH_SIZE )) { +cond_resched (); + batch_count =0 ; + } }kasan_release_vmalloc (start, end, start, end,KASAN_VMALLOC_TLB_FLUSH );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 628/752 usb: gadget: tegra-xudc: Add handling for BLCG_COREPLL_PWRDN
In reply to Sasha LevinFrom: Haotien Hsu <[email protected]>
[ Upstream commit 1132e90840abf3e7db11f1d28199e9fbc0b0e69e ]
The COREPLL_PWRDN bit in the BLCG register must be set when the XUSB device controller is powergated and cleared when it is unpowergated. If this bit is not explicitly controlled, the core PLL may remain in an incorrect power state across suspend/resume or ELPG transitions. Therefore, update the driver to explicitly control this bit during powergate transitions.
--- drivers/usb/gadget/udc/tegra-xudc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/tegra-xudc.c +9 -3
@@ -3392,17 +3392,18 @@ static void tegra_xudc_device_params_init(struct tegra_xudc *xudc) {u32 val, imod; + val =xudc_readl (xudc,BLCG );if (xudc->soc->has_ipfs) { - val =xudc_readl (xudc,BLCG ); val |=BLCG_ALL ; val &= ~(BLCG_DFPCI |BLCG_UFPCI |BLCG_FE |BLCG_COREPLL_PWRDN ); val |=BLCG_IOPLL_0_PWRDN ; val |=BLCG_IOPLL_1_PWRDN ; val |=BLCG_IOPLL_2_PWRDN ; - -xudc_writel (xudc, val,BLCG ); + }else { + val &= ~BLCG_COREPLL_PWRDN ; } +xudc_writel (xudc, val,BLCG );if (xudc->soc->port_speed_quirk)tegra_xudc_limit_port_speed (xudc);
@@ -3953,6 +3954,7 @@ static void tegra_xudc_remove(struct platform_device *pdev)static int __maybe_unused tegra_xudc_powergate (struct tegra_xudc *xudc) {unsigned long flags; +u32 val;dev_dbg (xudc->dev,"entering ELPG\n" );
@@ -3965,6 +3967,10 @@ static int __maybe_unused tegra_xudc_powergate(struct tegra_xudc *xudc)spin_unlock_irqrestore (&xudc->lock, flags); + val =xudc_readl (xudc,BLCG ); + val |=BLCG_COREPLL_PWRDN ; +xudc_writel (xudc, val,BLCG ); +clk_bulk_disable_unprepare (xudc->soc->num_clks, xudc->clks);regulator_bulk_disable (xudc->soc->num_supplies, xudc->supplies);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 629/752 mm/slab: add rcu_barrier() to kvfree_rcu_barrier_on_cache()
In reply to Sasha LevinFrom: Vlastimil Babka <[email protected]>
[ Upstream commit b55b423e8518361124ff0a9e15df431b3682ee4f ]
After we submit the rcu_free sheaves to call_rcu() we need to make sure the rcu callbacks complete. kvfree_rcu_barrier() does that via flush_all_rcu_sheaves() but kvfree_rcu_barrier_on_cache() doesn't. Fix that.
This currently causes no issues because the caches with sheaves we have are never destroyed. The problem flagged by kernel test robot was reported for a patch that enables sheaves for (almost) all caches, and occurred only with CONFIG_KASAN. Harry Yoo found the root cause [1]:
It turns out the object freed by sheaf_flush_unused() was in KASAN percpu quarantine list (confirmed by dumping the list) by the time __kmem_cache_shutdown() returns an error.
Quarantined objects are supposed to be flushed by kasan_cache_shutdown(), but things go wrong if the rcu callback (rcu_free_sheaf_nobarn()) is processed after kasan_cache_shutdown() finishes.
That's why rcu_barrier() in __kmem_cache_shutdown() didn't help, because it's called after kasan_cache_shutdown().
Calling rcu_barrier() in kvfree_rcu_barrier_on_cache() guarantees that it'll be added to the quarantine list before kasan_cache_shutdown() is called. So it's a valid fix!
[1] https://lore.kernel.org/all/aWd6f3jERlrB5yeF@hyeyoo/
--- mm/slab_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/slab_common.c +4 -1
@@ -2134,8 +2134,11 @@ EXPORT_SYMBOL_GPL(kvfree_rcu_barrier);*/ void kvfree_rcu_barrier_on_cache (struct kmem_cache *s) { -if (s->cpu_sheaves) +if (s->cpu_sheaves) {flush_rcu_sheaves_on_cache (s); +rcu_barrier (); + } +/* * TODO: Introduce a version of __kvfree_rcu_barrier() that works * on a specific slab cache.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 630/752 io_uring/net: don't continue send bundle if poll was required for retry
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 806ae939c41e5da1d94a1e2b31f5702e96b6c3e3 ]
If a send bundle has picked a bunch of buffers, then it needs to send all of those to be complete. This may require poll arming, if the send buffer ends up being full. Once a send bundle has been poll armed, no further bundles should be attempted.
This allows a current bundle to complete even though it needs to go through polling to do so, but it will not allow another bundle to be started once that has happened. Ideally we would abort a bundle if it was only partially sent, but as some parts of it already went out on the wire, this obviously isn't feasible. Not continuing more bundle attempts post encountering a full socket buffer is the second best thing.
--- io_uring/net.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
io_uring/net.c +5 -1
@@ -516,7 +516,11 @@ static inline bool io_send_finish(struct io_kiocb *req, cflags =io_put_kbufs (req, sel->val, sel->buf_list,io_bundle_nbufs (kmsg, sel->val)); -if (bundle_finished || req->flags &REQ_F_BL_EMPTY ) +/* +* Don't start new bundles if the buffer list is empty, or if the +* current operation needed to go through polling to complete. +*/ +if (bundle_finished || req->flags & (REQ_F_BL_EMPTY |REQ_F_POLLED )) goto finish;/*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 631/752 bus: fsl-mc: fix an error handling in fsl_mc_device_add()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit 52f527d0916bcdd7621a0c9e7e599b133294d495 ]
In fsl_mc_device_add(), device_initialize() is called first. put_device() should be called to drop the reference if error occurs. And other resources would be released via put_device -> fsl_mc_device_release. So remove redundant kfree() in error handling path.
--- drivers/bus/fsl-mc/fsl-mc-bus.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/bus/fsl-mc/fsl-mc-bus.c +1 -5
@@ -909,11 +909,7 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,return 0 ; error_cleanup_dev: -kfree (mc_dev->regions); -if (mc_bus) -kfree (mc_bus); -else -kfree (mc_dev); +put_device (&mc_dev->dev);return error; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 632/752 dm mpath: make pg_init_delay_msecs settable
In reply to Sasha LevinFrom: Benjamin Marzinski <[email protected]>
[ Upstream commit 218b16992a37ea97b9e09b7659a25a864fb9976f ]
"pg_init_delay_msecs X" can be passed as a feature in the multipath table and is used to set m->pg_init_delay_msecs in parse_features(). However, alloc_multipath_stage2(), which is called after parse_features(), resets m->pg_init_delay_msecs to its default value. Instead, set m->pg_init_delay_msecs in alloc_multipath(), which is called before parse_features(), to avoid overwriting a value passed in by the table.
--- drivers/md/dm-mpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +1 -1
@@ -225,6 +225,7 @@ static struct multipath *alloc_multipath(struct dm_target *ti)mutex_init (&m->work_mutex); m->queue_mode =DM_TYPE_NONE ; + m->pg_init_delay_msecs =DM_PG_INIT_DELAY_DEFAULT ; m->ti = ti; ti->private = m;
@@ -257,7 +258,6 @@ static int alloc_multipath_stage2(struct dm_target *ti, struct multipath *m)set_bit (MPATHF_QUEUE_IO , &m->flags);atomic_set (&m->pg_init_in_progress,0 );atomic_set (&m->pg_init_count,0 ); - m->pg_init_delay_msecs =DM_PG_INIT_DELAY_DEFAULT ;init_waitqueue_head (&m->pg_init_wait);init_waitqueue_head (&m->probe_wait);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 633/752 arm64: poe: fix stale POR_EL0 values for ptrace
In reply to Sasha LevinFrom: Joey Gouly <[email protected]>
[ Upstream commit 1f3b950492db411e6c30ee0076b61ef2694c100a ]
If a process wrote to POR_EL0 and then crashed before a context switch happened, the coredump would contain an incorrect value for POR_EL0.
The value read in poe_get() would be a stale value left in thread.por_el0. Fix this by reading the value from the system register, if the target thread is the current thread.
This matches what gcs/fpsimd do.
--- arch/arm64/kernel/ptrace.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm64/kernel/ptrace.c +3 -0
@@ -1458,6 +1458,9 @@ static int poe_get(struct task_struct *target,if (!system_supports_poe ())return -EINVAL ; +if (target == current) + current->thread.por_el0 =read_sysreg_s (SYS_POR_EL0 ); +return membuf_write (&to, &target->thread.por_el0,sizeof (target->thread.por_el0)); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 634/752 tools: Fix bitfield dependency failure
In reply to Sasha LevinFrom: Leo Yan <[email protected]>
[ Upstream commit a537c0da168a08b0b6a7f7bd9e75f4cc8d45ff57 ]
A perf build failure was reported by Thomas Voegtle on stable kernel v6.6.120:
CC tests/sample-parsing.o
CC util/intel-pt-decoder/intel-pt-pkt-decoder.o
CC util/perf-regs-arch/perf_regs_csky.o
CC util/arm-spe-decoder/arm-spe-pkt-decoder.o
CC util/perf-regs-arch/perf_regs_loongarch.o
In file included from util/arm-spe-decoder/arm-spe-pkt-decoder.h:10,
from util/arm-spe-decoder/arm-spe-pkt-decoder.c:14:
/local/git/linux-stable-rc/tools/include/linux/bitfield.h: In function ‘le16_encode_bits’:
/local/git/linux-stable-rc/tools/include/linux/bitfield.h:166:31: error: implicit declaration of
function ‘cpu_to_le16’; did you mean ‘htole16’? [-Werror=implicit-function-declaration]
____MAKE_OP(le##size,u##size,cpu_to_le##size,le##size##_to_cpu) \
^~~~~~~~~
/local/git/linux-stable-rc/tools/include/linux/bitfield.h:149:9: note: in definition of macro
‘____MAKE_OP’
return to((v & field_mask(field)) * field_multiplier(field)); \
^~ /local/git/linux-stable-rc/tools/include/linux/bitfield.h:170:1: note: in expansion of macro ‘__MAKE_OP’
__MAKE_OP(16)
Fix this by including linux/kernel.h, which provides the required definitions.
The issue was not found on the mainline due to the relevant C files have included kernel.h. It'd be good to merge this change on mainline as well for robustness.
To: Sasha Levin <[email protected]>
--- tools/include/linux/bitfield.h | 1 + 1 file changed, 1 insertion(+)
tools/include/linux/bitfield.h +1 -0
@@ -8,6 +8,7 @@#define _LINUX_BITFIELD_H#include <linux/build_bug.h> +#include <linux/kernel.h> #include <asm/byteorder.h> /*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 635/752 vhost: move vdpa group bound check to vhost_vdpa
In reply to Sasha LevinFrom: Eugenio Pérez <[email protected]>
[ Upstream commit cd025c1e876b4e262e71398236a1550486a73ede ]
Remove duplication by consolidating these here. This reduces the posibility of a parent driver missing them.
While we're at it, fix a bug in vdpa_sim where a valid ASID can be assigned to a group equal to ngroups, causing an out of bound write.
Message-Id: <[email protected]>
--- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 6 ------ drivers/vhost/vdpa.c | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-)
drivers/vdpa/mlx5/net/mlx5_vnet.c +0 -3
@@ -3640,9 +3640,6 @@ static int mlx5_set_group_asid(struct vdpa_device *vdev, u32 group,struct mlx5_vdpa_dev *mvdev =to_mvdev (vdev);int err =0 ; -if (group >=MLX5_VDPA_NUMVQ_GROUPS ) -return -EINVAL ; - mvdev->mres.group2asid[group] = asid;mutex_lock (&mvdev->mres.lock);
drivers/vdpa/vdpa_sim/vdpa_sim.c +0 -6
@@ -606,12 +606,6 @@ static int vdpasim_set_group_asid(struct vdpa_device *vdpa, unsigned int group,struct vhost_iotlb *iommu;int i; -if (group > vdpasim->dev_attr.ngroups) -return -EINVAL ; - -if (asid >= vdpasim->dev_attr.nas) -return -EINVAL ; - iommu = &vdpasim->iommu[asid];mutex_lock (&vdpasim->mutex);
drivers/vhost/vdpa.c +1 -1
@@ -680,7 +680,7 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd,case VHOST_VDPA_SET_GROUP_ASID :if (copy_from_user (&s, argp,sizeof (s)))return -EFAULT ; -if (s.num >= vdpa->nas) +if (idx >= vdpa->ngroups || s.num >= vdpa->nas)return -EINVAL ;if (!ops->set_group_asid)return -EOPNOTSUPP ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 636/752 powerpc/smp: Add check for kcalloc() failure in parse_thread_groups()
In reply to Sasha LevinFrom: Guangshuo Li <[email protected]>
[ Upstream commit 33c1c6d8a28a2761ac74b0380b2563cf546c2a3a ]
As kcalloc() may fail, check its return value to avoid a NULL pointer dereference when passing it to of_property_read_u32_array().
--- arch/powerpc/kernel/smp.c | 2 ++ 1 file changed, 2 insertions(+)
arch/powerpc/kernel/smp.c +2 -0
@@ -822,6 +822,8 @@ static int parse_thread_groups(struct device_node *dn, count =of_property_count_u32_elems (dn,"ibm,thread-groups" ); thread_group_array =kcalloc (count,sizeof (u32),GFP_KERNEL ); +if (!thread_group_array) +return -ENOMEM ; ret =of_property_read_u32_array (dn,"ibm,thread-groups" , thread_group_array, count);if (ret)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 637/752 iio: gyro: itg3200: Fix unchecked return value in read_raw
In reply to Sasha LevinFrom: Antoniu Miclaus <[email protected]>
[ Upstream commit b79b24f578cdb2d657db23e5fafe82c7e6a36b72 ]
The return value from itg3200_read_reg_s16() is stored in ret but never checked. The function unconditionally returns IIO_VAL_INT, ignoring potential I2C read failures. This causes garbage data to be returned to userspace when the read fails, with no error reported.
Add proper error checking to propagate the failure to callers.
--- drivers/iio/gyro/itg3200_core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iio/gyro/itg3200_core.c +2 -0
@@ -93,6 +93,8 @@ static int itg3200_read_raw(struct iio_dev *indio_dev,case IIO_CHAN_INFO_RAW : reg = (u8 )chan->address; ret =itg3200_read_reg_s16 (indio_dev, reg, val); +if (ret) +return ret;return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : *val =0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 638/752 mtd: spinand: Disable continuous read during probe
In reply to Sasha LevinFrom: David LaPorte <[email protected]>
[ Upstream commit b4af7d194dc879353829f3c56988a68fbba1fbdd ]
Macronix serial NAND devices with continuous read support do not clear the configuration register on soft reset and lack a hardware reset pin. When continuous read is interrupted (e.g., during reboot), the feature remains enabled at the device level.
With continuous read enabled, the OOB area becomes inaccessible and all reads are instead directed to the main area. As a result, during partition allocation as part of MTD device registration, the first two bytes of the main area for the master block are read and indicate that the block is bad. This process repeats for every subsequent block for the partition.
All reads and writes that reference the BBT find no good blocks and fail.
The only paths for recovery from this state are triggering the continuous read feature by way of raw MTD reads or through a NAND device power drain.
Disable continuous read explicitly during spinand probe to ensure quiescent feature state.
--- drivers/mtd/nand/spi/core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/mtd/nand/spi/core.c +8 -0
@@ -859,6 +859,14 @@ static void spinand_cont_read_init(struct spinand_device *spinand) (engine_type == NAND_ECC_ENGINE_TYPE_ON_DIE || engine_type == NAND_ECC_ENGINE_TYPE_NONE)) { spinand->cont_read_possible = true; + +/* +* Ensure continuous read is disabled on probe. +* Some devices retain this state across soft reset, +* which leaves the OOB area inaccessible and results +* in false positive returns from spinand_isbad(). +*/ +spinand_cont_read_enable (spinand, false); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 639/752 power: reset: tdx-ec-poweroff: fix restart
In reply to Sasha LevinFrom: Emanuele Ghidoli <[email protected]>
[ Upstream commit 562357a6310f79e45844c3e980d410a1e8e02ce6 ]
During testing, restart occasionally failed on Toradex modules.
The issue was traced to an interaction between the EC-based reset/poweroff handler and the PSCI restart handler. While the embedded controller is resetting or powering off the module, the PSCI code may still be invoked, triggering an I2C transaction to the PMIC. This can leave the PMIC I2C in a frozen state.
Add a delay after issuing the EC reset or power-off command to give the controller time to complete the operation and avoid falling back to another restart/poweroff provider.
Also print an error message if sending the command to the embedded controller fails.
--- drivers/power/reset/tdx-ec-poweroff.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/power/reset/tdx-ec-poweroff.c +19 -0
@@ -8,7 +8,10 @@*/ #include <linux/array_size.h> +#include <linux/bug.h> +#include <linux/delay.h> #include <linux/device.h> +#include <linux/dev_printk.h> #include <linux/err.h> #include <linux/i2c.h> #include <linux/mod_devicetable.h>
@@ -31,6 +34,8 @@#define EC_REG_MAX 0xD0 +#define EC_CMD_TIMEOUT_MS 1000 +static const struct regmap_range volatile_ranges[] = {regmap_reg_range (EC_CMD_REG ,EC_CMD_REG ), };
@@ -75,6 +80,13 @@ static int tdx_ec_power_off(struct sys_off_data *data) err =tdx_ec_cmd (regmap,EC_CMD_POWEROFF ); +if (err) { +dev_err (data->dev,"Failed to send power off command\n" ); + }else { +mdelay (EC_CMD_TIMEOUT_MS ); +WARN_ONCE (1 ,"Unable to power off system\n" ); + } +return err ?NOTIFY_BAD :NOTIFY_DONE ; }
@@ -85,6 +97,13 @@ static int tdx_ec_restart(struct sys_off_data *data) err =tdx_ec_cmd (regmap,EC_CMD_RESET ); +if (err) { +dev_err (data->dev,"Failed to send restart command\n" ); + }else { +mdelay (EC_CMD_TIMEOUT_MS ); +WARN_ONCE (1 ,"Unable to restart system\n" ); + } +return err ?NOTIFY_BAD :NOTIFY_DONE ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 640/752 mm/highmem: fix __kmap_to_page() build error
In reply to Sasha LevinFrom: William Tambe <[email protected]>
[ Upstream commit 94350fe6cad77b46c3dcb8c96543bef7647efbc0 ]
This changes fixes following build error which is a miss from ef6e06b2ef87 ("highmem: fix kmap_to_page() for kmap_local_page() addresses").
mm/highmem.c:184:66: error: 'pteval' undeclared (first use in this function); did you mean 'pte_val'?
184 | idx = arch_kmap_local_map_idx(i, pte_pfn(pteval));
In __kmap_to_page(), pteval is used but does not exist in the function.
(akpm: affects xtensa only)
--- mm/highmem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/highmem.c +2 -1
@@ -180,12 +180,13 @@ struct page *__kmap_to_page(void *vaddr)for (i =0 ; i < kctrl->idx; i++) {unsigned long base_addr;int idx; +pte_t pteval = kctrl->pteval[i]; idx =arch_kmap_local_map_idx (i,pte_pfn (pteval)); base_addr =__fix_to_virt (FIX_KMAP_BEGIN + idx);if (base_addr == base) -return pte_page (kctrl->pteval[i]); +return pte_page (pteval); } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 641/752 compiler-clang.h: require LLVM 19.1.0 or higher for __typeof_unqual__
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit e8d899d301346a5591c9d1af06c3c9b3501cf84b ]
When building the kernel using a version of LLVM between llvmorg-19-init (the first commit of the LLVM 19 development cycle) and the change in LLVM that actually added __typeof_unqual__ for all C modes [1], which might happen during a bisect of LLVM, there is a build failure:
In file included from arch/x86/kernel/asm-offsets.c:9:
In file included from include/linux/crypto.h:15:
In file included from include/linux/completion.h:12:
In file included from include/linux/swait.h:7:
In file included from include/linux/spinlock.h:56:
In file included from include/linux/preempt.h:79:
arch/x86/include/asm/preempt.h:61:2: error: call to undeclared function '__typeof_unqual__'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
61 | raw_cpu_and_4(__preempt_count, ~PREEMPT_NEED_RESCHED);
| ^
arch/x86/include/asm/percpu.h:478:36: note: expanded from macro 'raw_cpu_and_4'
478 | #define raw_cpu_and_4(pcp, val) percpu_binary_op(4, , "and", (pcp), val)
| ^
arch/x86/include/asm/percpu.h:210:3: note: expanded from macro 'percpu_binary_op'
210 | TYPEOF_UNQUAL(_var) pto_tmp__; \
| ^
include/linux/compiler.h:248:29: note: expanded from macro 'TYPEOF_UNQUAL'
248 | # define TYPEOF_UNQUAL(exp) __typeof_unqual__(exp)
| ^The current logic of CC_HAS_TYPEOF_UNQUAL just checks for a major version of 19 but half of the 19 development cycle did not have support for __typeof_unqual__.
Harden the logic of CC_HAS_TYPEOF_UNQUAL to avoid this error by only using __typeof_unqual__ with a released version of LLVM 19, which is greater than or equal to 19.1.0 with LLVM's versioning scheme that matches GCC's [2].
--- include/linux/compiler-clang.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/compiler-clang.h +1 -1
@@ -152,4 +152,4 @@* Bindgen uses LLVM even if our C compiler is GCC, so we cannot * rely on the auto-detected CONFIG_CC_HAS_TYPEOF_UNQUAL. */ -#define CC_HAS_TYPEOF_UNQUAL (__clang_major__ >= 19) +#define CC_HAS_TYPEOF_UNQUAL (__clang_major__ > 19 || (__clang_major__ == 19 && __clang_minor__ > 0))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 642/752 rapidio: replace rio_free_net() with kfree() in rio_scan_alloc_net()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit 666183dcdd9ad3b8156a1df7f204f728f720380f ]
When idtab allocation fails, net is not registered with rio_add_net() yet, so kfree(net) is sufficient to release the memory. Set mport->net to NULL to avoid dangling pointer.
--- drivers/rapidio/rio-scan.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rapidio/rio-scan.c +2 -1
@@ -854,7 +854,8 @@ static struct rio_net *rio_scan_alloc_net(struct rio_mport *mport,if (idtab ==NULL ) {pr_err ("RIO: failed to allocate destID table\n" ); -rio_free_net (net); +kfree (net); + mport->net =NULL ; net =NULL ; }else { net->enum_data = idtab;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 643/752 ocfs2: fix reflink preserve cleanup issue
In reply to Sasha LevinFrom: Heming Zhao <[email protected]>
[ Upstream commit 5138c936c2c82c9be8883921854bc6f7e1177d8c ]
commit c06c303832ec ("ocfs2: fix xattr array entry __counted_by error") doesn't handle all cases and the cleanup job for preserved xattr entries still has bug:
- the 'last' pointer should be shifted by one unit after cleanup an array entry.
- current code logic doesn't cleanup the first entry when xh_count is 1.
Note, commit c06c303832ec is also a bug fix for 0fe9b66c65f3.
--- fs/ocfs2/xattr.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/ocfs2/xattr.c +4 -0
@@ -6364,6 +6364,10 @@ static int ocfs2_reflink_xattr_header(handle_t *handle, (void *)last - (void *)xe);memset (last,0 ,sizeof (struct ocfs2_xattr_entry )); + last = &new_xh->xh_entries[le16_to_cpu (new_xh->xh_count)] -1 ; + }else { +memset (xe,0 ,sizeof (struct ocfs2_xattr_entry )); + last =NULL ; }/*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 644/752 kexec: derive purgatory entry from symbol
In reply to Sasha LevinFrom: Li Chen <[email protected]>
[ Upstream commit 480e1d5c64bb14441f79f2eb9421d5e26f91ea3d ]
kexec_load_purgatory() derives image->start by locating e_entry inside an SHF_EXECINSTR section. If the purgatory object contains multiple executable sections with overlapping sh_addr, the entrypoint check can match more than once and trigger a WARN.
Derive the entry section from the purgatory_start symbol when present and compute image->start from its final placement. Keep the existing e_entry fallback for purgatories that do not expose the symbol.
WARNING: kernel/kexec_file.c:1009 at kexec_load_purgatory+0x395/0x3c0, CPU#10: kexec/1784 Call Trace: <TASK> bzImage64_load+0x133/0xa00 __do_sys_kexec_file_load+0x2b3/0x5c0 do_syscall_64+0x81/0x610 entry_SYSCALL_64_after_hwframe+0x76/0x7e
--- kernel/kexec_file.c | 131 +++++++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 57 deletions(-)
kernel/kexec_file.c +74 -57
@@ -882,6 +882,60 @@ static int kexec_calculate_store_digests(struct kimage *image) }#ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY +/* +* kexec_purgatory_find_symbol - find a symbol in the purgatory +* @pi: Purgatory to search in. +* @name: Name of the symbol. +* +* Return: pointer to symbol in read-only symtab on success, NULL on error. +*/ +static const Elf_Sym *kexec_purgatory_find_symbol (struct purgatory_info *pi, +const char *name) +{ +const Elf_Shdr *sechdrs; +const Elf_Ehdr *ehdr; +const Elf_Sym *syms; +const char *strtab; +int i, k; + +if (!pi->ehdr) +return NULL ; + + ehdr = pi->ehdr; + sechdrs = (void *)ehdr + ehdr->e_shoff; + +for (i =0 ; i < ehdr->e_shnum; i++) { +if (sechdrs[i].sh_type !=SHT_SYMTAB ) +continue ; + +if (sechdrs[i].sh_link >= ehdr->e_shnum) +/* Invalid strtab section number */ +continue ; + strtab = (void *)ehdr + sechdrs[sechdrs[i].sh_link].sh_offset; + syms = (void *)ehdr + sechdrs[i].sh_offset; + +/* Go through symbols for a match */ +for (k =0 ; k < sechdrs[i].sh_size/sizeof (Elf_Sym); k++) { +if (ELF_ST_BIND (syms[k].st_info) !=STB_GLOBAL ) +continue ; + +if (strcmp (strtab + syms[k].st_name, name) !=0 ) +continue ; + +if (syms[k].st_shndx ==SHN_UNDEF || + syms[k].st_shndx >= ehdr->e_shnum) { +pr_debug ("Symbol: %s has bad section index %d.\n" , + name, syms[k].st_shndx); +return NULL ; + } + +/* Found the symbol we are looking for */ +return &syms[k]; + } + } + +return NULL ; +}/* * kexec_purgatory_setup_kbuf - prepare buffer to load purgatory. * @pi: Purgatory to be loaded.
@@ -960,6 +1014,10 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi,unsigned long offset;size_t sechdrs_size;Elf_Shdr *sechdrs; +const Elf_Sym *entry_sym; +u16 entry_shndx =0 ; +unsigned long entry_off =0 ; +bool start_fixed = false;int i;/*
@@ -977,6 +1035,12 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi, bss_addr = kbuf->mem + kbuf->bufsz; kbuf->image->start = pi->ehdr->e_entry; + entry_sym =kexec_purgatory_find_symbol (pi,"purgatory_start" ); +if (entry_sym) { + entry_shndx = entry_sym->st_shndx; + entry_off = entry_sym->st_value; + } +for (i =0 ; i < pi->ehdr->e_shnum; i++) {unsigned long align;void *src, *dst;
@@ -994,6 +1058,13 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi, offset =ALIGN (offset, align); +if (!start_fixed && entry_sym && i == entry_shndx && + (sechdrs[i].sh_flags &SHF_EXECINSTR ) && + entry_off < sechdrs[i].sh_size) { + kbuf->image->start = kbuf->mem + offset + entry_off; + start_fixed = true; + } +/* * Check if the segment contains the entry point, if so, * calculate the value of image->start based on it.
@@ -1004,13 +1075,14 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi,* is not set to the initial value, and warn the user so they * have a chance to fix their purgatory's linker script. */ -if (sechdrs[i].sh_flags &SHF_EXECINSTR && +if (!start_fixed && sechdrs[i].sh_flags &SHF_EXECINSTR && pi->ehdr->e_entry >= sechdrs[i].sh_addr && pi->ehdr->e_entry < (sechdrs[i].sh_addr + sechdrs[i].sh_size) && - !WARN_ON (kbuf->image->start != pi->ehdr->e_entry)) { + kbuf->image->start == pi->ehdr->e_entry) { kbuf->image->start -= sechdrs[i].sh_addr; kbuf->image->start += kbuf->mem + offset; + start_fixed = true; } src = (void *)pi->ehdr + sechdrs[i].sh_offset;
@@ -1128,61 +1200,6 @@ int kexec_load_purgatory(struct kimage *image, struct kexec_buf *kbuf)return ret; } -/* -* kexec_purgatory_find_symbol - find a symbol in the purgatory -* @pi: Purgatory to search in. -* @name: Name of the symbol. -* -* Return: pointer to symbol in read-only symtab on success, NULL on error. -*/ -static const Elf_Sym *kexec_purgatory_find_symbol (struct purgatory_info *pi, -const char *name) -{ -const Elf_Shdr *sechdrs; -const Elf_Ehdr *ehdr; -const Elf_Sym *syms; -const char *strtab; -int i, k; - -if (!pi->ehdr) -return NULL ; - - ehdr = pi->ehdr; - sechdrs = (void *)ehdr + ehdr->e_shoff; - -for (i =0 ; i < ehdr->e_shnum; i++) { -if (sechdrs[i].sh_type !=SHT_SYMTAB ) -continue ; - -if (sechdrs[i].sh_link >= ehdr->e_shnum) -/* Invalid strtab section number */ -continue ; - strtab = (void *)ehdr + sechdrs[sechdrs[i].sh_link].sh_offset; - syms = (void *)ehdr + sechdrs[i].sh_offset; - -/* Go through symbols for a match */ -for (k =0 ; k < sechdrs[i].sh_size/sizeof (Elf_Sym); k++) { -if (ELF_ST_BIND (syms[k].st_info) !=STB_GLOBAL ) -continue ; - -if (strcmp (strtab + syms[k].st_name, name) !=0 ) -continue ; - -if (syms[k].st_shndx ==SHN_UNDEF || - syms[k].st_shndx >= ehdr->e_shnum) { -pr_debug ("Symbol: %s has bad section index %d.\n" , - name, syms[k].st_shndx); -return NULL ; - } - -/* Found the symbol we are looking for */ -return &syms[k]; - } - } - -return NULL ; -} -void *kexec_purgatory_get_symbol_addr (struct kimage *image,const char *name) {struct purgatory_info *pi = &image->purgatory_info;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 645/752 crash_dump: fix dm_crypt keys locking and ref leak
In reply to Sasha LevinFrom: Vasily Gorbik <[email protected]>
[ Upstream commit 96a54b8ffc8c4567c32fe0b6996669f1132b026d ]
crash_load_dm_crypt_keys() reads dm-crypt volume keys from the user keyring. It uses user_key_payload_locked() without holding key->sem, which makes lockdep complain when kexec_file_load() assembles the crash image:
=============================
WARNING: suspicious RCU usage
-----------------------------
./include/keys/user-type.h:53 suspicious rcu_dereference_protected() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
no locks held by kexec/4875.
stack backtrace: Call Trace: <TASK> dump_stack_lvl+0x5d/0x80 lockdep_rcu_suspicious.cold+0x4e/0x96 crash_load_dm_crypt_keys+0x314/0x390 bzImage64_load+0x116/0x9a0 ? __lock_acquire+0x464/0x1ba0 __do_sys_kexec_file_load+0x26a/0x4f0 do_syscall_64+0xbd/0x430 entry_SYSCALL_64_after_hwframe+0x77/0x7f
In addition, the key returned by request_key() is never key_put()'d, leaking a key reference on each load attempt.
Take key->sem while copying the payload and drop the key reference afterwards.
--- kernel/crash_dump_dm_crypt.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
kernel/crash_dump_dm_crypt.c +13 -4
@@ -143,6 +143,7 @@ static int read_key_from_user_keying(struct dm_crypt_key *dm_key) {const struct user_key_payload *ukp;struct key *key; +int ret =0 ;kexec_dprintk ("Requesting logon key %s" , dm_key->key_desc); key =request_key (&key_type_logon, dm_key->key_desc,NULL );
@@ -152,20 +153,28 @@ static int read_key_from_user_keying(struct dm_crypt_key *dm_key)return PTR_ERR (key); } +down_read (&key->sem); ukp =user_key_payload_locked (key); -if (!ukp) -return -EKEYREVOKED ; +if (!ukp) { + ret = -EKEYREVOKED ; + goto out; + }if (ukp->datalen >KEY_SIZE_MAX ) {pr_err ("Key size %u exceeds maximum (%u)\n" , ukp->datalen,KEY_SIZE_MAX ); -return -EINVAL ; + ret = -EINVAL ; + goto out; }memcpy (dm_key->data, ukp->data, ukp->datalen); dm_key->key_size = ukp->datalen;kexec_dprintk ("Get dm crypt key (size=%u) %s: %8ph\n" , dm_key->key_size, dm_key->key_desc, dm_key->data); -return 0 ; + +out: +up_read (&key->sem); +key_put (key); +return ret; }struct config_key {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 646/752 kho: skip memoryless NUMA nodes when reserving scratch areas
In reply to Sasha LevinFrom: Evangelos Petrongonas <[email protected]>
[ Upstream commit 427b2535f51342de3156babc6bdc3f3b7dd2c707 ]
kho_reserve_scratch() iterates over all online NUMA nodes to allocate per-node scratch memory. On systems with memoryless NUMA nodes (nodes that have CPUs but no memory), memblock_alloc_range_nid() fails because there is no memory available on that node. This causes KHO initialization to fail and kho_enable to be set to false.
Some ARM64 systems have NUMA topologies where certain nodes contain only CPUs without any associated memory. These configurations are valid and should not prevent KHO from functioning.
Fix this by only counting nodes that have memory (N_MEMORY state) and skip memoryless nodes in the per-node scratch allocation loop.
--- kernel/kexec_handover.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/kexec_handover.c +6 -2
@@ -619,7 +619,7 @@ static void __init kho_reserve_scratch(void)scratch_size_update ();/* FIXME: deal with node hot-plug/remove */ - kho_scratch_cnt =num_online_nodes () +2 ; + kho_scratch_cnt =nodes_weight (node_states[N_MEMORY ]) +2 ; size = kho_scratch_cnt *sizeof (*kho_scratch); kho_scratch =memblock_alloc (size,PAGE_SIZE );if (!kho_scratch)
@@ -649,7 +649,11 @@ static void __init kho_reserve_scratch(void) kho_scratch[i].size = size; i++; -for_each_online_node (nid) { +/* +* Loop over nodes that have both memory and are online. Skip +* memoryless nodes, as we can not allocate scratch areas there. +*/ +for_each_node_state (nid,N_MEMORY ) { size =scratch_size_node (nid); addr = memblock_alloc_range_nid(size, CMA_MIN_ALIGNMENT_BYTES, 0, MEMBLOCK_ALLOC_ACCESSIBLE,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 647/752 Revert "PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV"
In reply to Sasha LevinFrom: Niklas Schnelle <[email protected]>
[ Upstream commit 2fa119c0e5e528453ebae9e70740e8d2d8c0ed5a ]
This reverts commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV"), which causes a deadlock by recursively taking pci_rescan_remove_lock when sriov_del_vfs() is called as part of pci_stop_and_remove_bus_device(). For example with the following sequence of commands:
$ echo <NUM> > /sys/bus/pci/devices/<pf>/sriov_numvfs $ echo 1 > /sys/bus/pci/devices/<pf>/remove
A trimmed trace of the deadlock on a mlx5 device is as below:
zsh/5715 is trying to acquire lock:
000002597926ef50 (pci_rescan_remove_lock){+.+.}-{3:3}, at: sriov_disable+0x34/0x140
but task is already holding lock:
000002597926ef50 (pci_rescan_remove_lock){+.+.}-{3:3}, at: pci_stop_and_remove_bus_device_locked+0x24/0x80
...
Call Trace: [<00000259778c4f90>] dump_stack_lvl+0xc0/0x110 [<00000259779c844e>] print_deadlock_bug+0x31e/0x330 [<00000259779c1908>] __lock_acquire+0x16c8/0x32f0 [<00000259779bffac>] lock_acquire+0x14c/0x350 [<00000259789643a6>] __mutex_lock_common+0xe6/0x1520 [<000002597896413c>] mutex_lock_nested+0x3c/0x50 [<00000259784a07e4>] sriov_disable+0x34/0x140 [<00000258f7d6dd80>] mlx5_sriov_disable+0x50/0x80 [mlx5_core] [<00000258f7d5745e>] remove_one+0x5e/0xf0 [mlx5_core] [<00000259784857fc>] pci_device_remove+0x3c/0xa0 [<000002597851012e>] device_release_driver_internal+0x18e/0x280 [<000002597847ae22>] pci_stop_bus_device+0x82/0xa0 [<000002597847afce>] pci_stop_and_remove_bus_device_locked+0x5e/0x80 [<00000259784972c2>] remove_store+0x72/0x90 [<0000025977e6661a>] kernfs_fop_write_iter+0x15a/0x200 [<0000025977d7241c>] vfs_write+0x24c/0x300 [<0000025977d72696>] ksys_write+0x86/0x110 [<000002597895b61c>] __do_syscall+0x14c/0x400 [<000002597896e0ee>] system_call+0x6e/0x90
This alone is not a complete fix as it restores the issue the cited commit tried to solve. A new fix will be provided as a follow on.
--- drivers/pci/iov.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/pci/iov.c +0 -5
@@ -629,18 +629,15 @@ static int sriov_add_vfs(struct pci_dev *dev, u16 num_vfs)if (dev->no_vf_scan)return 0 ; -pci_lock_rescan_remove ();for (i =0 ; i < num_vfs; i++) { rc =pci_iov_add_virtfn (dev, i);if (rc) goto failed; } -pci_unlock_rescan_remove ();return 0 ; failed:while (i--)pci_iov_remove_virtfn (dev, i); -pci_unlock_rescan_remove ();return rc; }
@@ -765,10 +762,8 @@ static void sriov_del_vfs(struct pci_dev *dev)struct pci_sriov *iov = dev->sriov;int i; -pci_lock_rescan_remove ();for (i =0 ; i < iov->num_VFs; i++)pci_iov_remove_virtfn (dev, i); -pci_unlock_rescan_remove (); }static void sriov_disable (struct pci_dev *dev)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 648/752 PCI/IOV: Fix race between SR-IOV enable/disable and hotplug
In reply to Sasha LevinFrom: Niklas Schnelle <[email protected]>
[ Upstream commit a5338e365c4559d7b4d7356116b0eb95b12e08d5 ]
Commit 05703271c3cd ("PCI/IOV: Add PCI rescan-remove locking when enabling/disabling SR-IOV") tried to fix a race between the VF removal inside sriov_del_vfs() and concurrent hot unplug by taking the PCI rescan/remove lock in sriov_del_vfs(). Similarly the PCI rescan/remove lock was also taken in sriov_add_vfs() to protect addition of VFs.
This approach however causes deadlock on trying to remove PFs with SR-IOV enabled because PFs disable SR-IOV during removal and this removal happens under the PCI rescan/remove lock. So the original fix had to be reverted.
Instead of taking the PCI rescan/remove lock in sriov_add_vfs() and sriov_del_vfs(), fix the race that occurs with SR-IOV enable and disable vs hotplug higher up in the callchain by taking the lock in sriov_numvfs_store() before calling into the driver's sriov_configure() callback.
--- drivers/pci/iov.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/pci/iov.c +4 -0
@@ -495,7 +495,9 @@ static ssize_t sriov_numvfs_store(struct device *dev,if (num_vfs ==0 ) {/* disable VFs */ +pci_lock_rescan_remove (); ret = pdev->driver->sriov_configure (pdev,0 ); +pci_unlock_rescan_remove (); goto exit; }
@@ -507,7 +509,9 @@ static ssize_t sriov_numvfs_store(struct device *dev, goto exit; } +pci_lock_rescan_remove (); ret = pdev->driver->sriov_configure (pdev, num_vfs); +pci_unlock_rescan_remove ();if (ret <0 ) goto exit;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 649/752 arm64: Fix non-atomic __READ_ONCE() with CONFIG_LTO=y
In reply to Sasha LevinFrom: Marco Elver <[email protected]>
[ Upstream commit bb0c99e08ab9aa6d04b40cb63c72db9950d51749 ]
The implementation of __READ_ONCE() under CONFIG_LTO=y incorrectly qualified the fallback "once" access for types larger than 8 bytes, which are not atomic but should still happen "once" and suppress common compiler optimizations.
The cast volatile typeof(__x) applied the volatile qualifier to the pointer type itself rather than the pointee. This created a volatile pointer to a non-volatile type, which violated __READ_ONCE() semantics.
Fix this by casting to volatile typeof(*__x) *.
With a defconfig + LTO + debug options build, we see the following functions to be affected:
xen_manage_runstate_time (884 -> 944 bytes) xen_steal_clock (248 -> 340 bytes) ^-- use __READ_ONCE() to load vcpu_runstate_info structs
--- arch/arm64/include/asm/rwonce.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/rwonce.h +1 -1
@@ -58,7 +58,7 @@default : \ atomic =0 ; \ } \ - atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(__x))__x);\ + atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(*__x) *)__x);\ })#endif /* !BUILD_VDSO */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 650/752 uprobes: Fix incorrect lockdep condition in filter_chain()
In reply to Sasha LevinFrom: Breno Leitao <[email protected]>
[ Upstream commit a56a38fd9196fc89401e498d70b7aa9c9679fa6e ]
The list_for_each_entry_rcu() in filter_chain() uses rcu_read_lock_trace_held() as the lockdep condition, but the function holds consumer_rwsem, not the RCU trace lock.
This gives me the following output when running with some locking debug option enabled:
kernel/events/uprobes.c:1141 RCU-list traversed in non-reader section!!
filter_chain
register_for_each_vma
uprobe_unregister_nosync
__probe_event_disable
Remove the incorrect lockdep condition since the rwsem provides sufficient protection for the list traversal.
--- kernel/events/uprobes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/uprobes.c +1 -1
@@ -1138,7 +1138,7 @@ static bool filter_chain(struct uprobe *uprobe, struct mm_struct *mm)bool ret = false;down_read (&uprobe->consumer_rwsem); -list_for_each_entry_rcu (uc, &uprobe->consumers, cons_node,rcu_read_lock_trace_held ()) { +list_for_each_entry (uc, &uprobe->consumers, cons_node) { ret =consumer_filter (uc, mm);if (ret)break ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 651/752 clk: rs9: Reserve 8 struct clk_hw slots for for 9FGV0841
In reply to Sasha LevinFrom: Marek Vasut <[email protected]>
[ Upstream commit 5ec820fc28d0b8a0f3890d476b1976f20e8343cc ]
The 9FGV0841 has 8 outputs and registers 8 struct clk_hw, make sure there are 8 slots for those newly registered clk_hw pointers, else there is going to be out of bounds write when pointers 4..7 are set into struct rs9_driver_data .clk_dif[4..7] field.
Since there are other structure members past this struct clk_hw pointer array, writing to .clk_dif[4..7] fields corrupts both the struct rs9_driver_data content and data around it, sometimes without crashing the kernel. However, the kernel does surely crash when the driver is unbound or during suspend.
Fix this, increase the struct clk_hw pointer array size to the maximum output count of 9FGV0841, which is the biggest chip that is supported by this driver.
--- drivers/clk/clk-renesas-pcie.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-renesas-pcie.c +1 -1
@@ -64,7 +64,7 @@ struct rs9_driver_data {struct i2c_client *client;struct regmap *regmap;const struct rs9_chip_info *chip_info; -struct clk_hw *clk_dif[4 ]; +struct clk_hw *clk_dif[8 ];u8 pll_amplitude;u8 pll_ssc;u8 clk_dif_sr;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 652/752 btrfs: fix periodic reclaim condition
In reply to Sasha LevinFrom: Sun YangKai <[email protected]>
[ Upstream commit 19eff93dc738e8afaa59cb374b44bb5a162e6c2d ]
Problems with current implementation:
1. reclaimable_bytes is signed while chunk_sz is unsigned, causing negative reclaimable_bytes to trigger reclaim unexpectedly
2. The "space must be freed between scans" assumption breaks the two-scan requirement: first scan marks block groups, second scan reclaims them. Without the second scan, no reclamation occurs.
Instead, track actual reclaim progress: pause reclaim when block groups will be reclaimed, and resume only when progress is made. This ensures reclaim continues until no further progress can be made. And resume periodic reclaim when there's enough free space.
And we take care if reclaim is making any progress now, so it's unnecessary to set periodic_reclaim_ready to false when failed to reclaim a block group.
--- fs/btrfs/block-group.c | 6 ++++-- fs/btrfs/space-info.c | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-)
fs/btrfs/block-group.c +4 -2
@@ -1877,6 +1877,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work)while (!list_empty (&fs_info->reclaim_bgs)) {u64 used;u64 reserved; +u64 old_total;int ret =0 ; bg = list_first_entry(&fs_info->reclaim_bgs,
@@ -1942,6 +1943,7 @@ void btrfs_reclaim_bgs_work(struct work_struct *work) }spin_unlock (&bg->lock); + old_total = space_info->total_bytes;spin_unlock (&space_info->lock);/*
@@ -1994,14 +1996,14 @@ void btrfs_reclaim_bgs_work(struct work_struct *work) reserved =0 ;spin_lock (&space_info->lock); space_info->reclaim_errors++; -if (READ_ONCE (space_info->periodic_reclaim)) - space_info->periodic_reclaim_ready = false;spin_unlock (&space_info->lock); }spin_lock (&space_info->lock); space_info->reclaim_count++; space_info->reclaim_bytes += used; space_info->reclaim_bytes += reserved; +if (space_info->total_bytes < old_total) +btrfs_set_periodic_reclaim_ready (space_info, true);spin_unlock (&space_info->lock); next:
fs/btrfs/space-info.c +12 -9
@@ -2074,11 +2074,11 @@ static bool is_reclaim_urgent(struct btrfs_space_info *space_info)return unalloc < data_chunk_size; } -static void do_reclaim_sweep (struct btrfs_space_info *space_info,int raid) +static bool do_reclaim_sweep (struct btrfs_space_info *space_info,int raid) {struct btrfs_block_group *bg;int thresh_pct; -bool try_again = true; +bool will_reclaim = false;bool urgent;spin_lock (&space_info->lock);
@@ -2096,7 +2096,7 @@ static void do_reclaim_sweep(struct btrfs_space_info *space_info, int raid)spin_lock (&bg->lock); thresh =mult_perc (bg->length, thresh_pct);if (bg->used < thresh && bg->reclaim_mark) { - try_again = false; + will_reclaim = true; reclaim = true; } bg->reclaim_mark++;
@@ -2113,12 +2113,13 @@ static void do_reclaim_sweep(struct btrfs_space_info *space_info, int raid)* If we have any staler groups, we don't touch the fresher ones, but if we * really need a block group, do take a fresh one. */ -if (try_again && urgent) { - try_again = false; +if (!will_reclaim && urgent) { + urgent = false; goto again; }up_read (&space_info->groups_sem); +return will_reclaim; }void btrfs_space_info_update_reclaimable (struct btrfs_space_info *space_info,s64 bytes)
@@ -2128,7 +2129,8 @@ void btrfs_space_info_update_reclaimable(struct btrfs_space_info *space_info, s6lockdep_assert_held (&space_info->lock); space_info->reclaimable_bytes += bytes; -if (space_info->reclaimable_bytes >= chunk_sz) +if (space_info->reclaimable_bytes >0 && + space_info->reclaimable_bytes >= chunk_sz)btrfs_set_periodic_reclaim_ready (space_info, true); }
@@ -2155,7 +2157,6 @@ static bool btrfs_should_periodic_reclaim(struct btrfs_space_info *space_info)spin_lock (&space_info->lock); ret = space_info->periodic_reclaim_ready; -btrfs_set_periodic_reclaim_ready (space_info, false);spin_unlock (&space_info->lock);return ret;
@@ -2169,8 +2170,10 @@ void btrfs_reclaim_sweep(const struct btrfs_fs_info *fs_info)list_for_each_entry (space_info, &fs_info->space_info, list) {if (!btrfs_should_periodic_reclaim (space_info))continue ; -for (raid =0 ; raid <BTRFS_NR_RAID_TYPES ; raid++) -do_reclaim_sweep (space_info, raid); +for (raid =0 ; raid <BTRFS_NR_RAID_TYPES ; raid++) { +if (do_reclaim_sweep (space_info, raid)) +btrfs_set_periodic_reclaim_ready (space_info, false); + } } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 653/752 btrfs: zoned: fixup last alloc pointer after extent removal for RAID1
In reply to Sasha LevinFrom: Naohiro Aota <[email protected]>
[ Upstream commit dda3ec9ee6b3e120603bff1b798f25b51e54ac5d ]
When a block group is composed of a sequential write zone and a conventional zone, we recover the (pseudo) write pointer of the conventional zone using the end of the last allocated position.
However, if the last extent in a block group is removed, the last extent position will be smaller than the other real write pointer position. Then, that will cause an error due to mismatch of the write pointers.
We can fixup this case by moving the alloc_offset to the corresponding write pointer position.
--- fs/btrfs/zoned.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
fs/btrfs/zoned.c +15 -0
@@ -1483,6 +1483,21 @@ static int btrfs_load_block_group_raid1(struct btrfs_block_group *bg,/* In case a device is missing we have a cap of 0, so don't use it. */ bg->zone_capacity =min_not_zero (zone_info[0 ].capacity, zone_info[1 ].capacity); +/* +* When the last extent is removed, last_alloc can be smaller than the other write +* pointer. In that case, last_alloc should be moved to the corresponding write +* pointer position. +*/ +for (i =0 ; i < map->num_stripes; i++) { +if (zone_info[i].alloc_offset ==WP_MISSING_DEV || + zone_info[i].alloc_offset ==WP_CONVENTIONAL ) +continue ; +if (last_alloc <= zone_info[i].alloc_offset) { + last_alloc = zone_info[i].alloc_offset; +break ; + } + } +for (i =0 ; i < map->num_stripes; i++) {if (zone_info[i].alloc_offset ==WP_MISSING_DEV )continue ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 654/752 btrfs: zoned: fixup last alloc pointer after extent removal for DUP
In reply to Sasha LevinFrom: Naohiro Aota <[email protected]>
[ Upstream commit e2d848649e64de39fc1b9c64002629b4daa1105d ]
When a block group is composed of a sequential write zone and a conventional zone, we recover the (pseudo) write pointer of the conventional zone using the end of the last allocated position.
However, if the last extent in a block group is removed, the last extent position will be smaller than the other real write pointer position. Then, that will cause an error due to mismatch of the write pointers.
We can fixup this case by moving the alloc_offset to the corresponding write pointer position.
--- fs/btrfs/zoned.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
fs/btrfs/zoned.c +14 -0
@@ -1442,6 +1442,20 @@ static int btrfs_load_block_group_dup(struct btrfs_block_group *bg,return -EIO ; } +/* +* When the last extent is removed, last_alloc can be smaller than the other write +* pointer. In that case, last_alloc should be moved to the corresponding write +* pointer position. +*/ +for (int i =0 ; i < map->num_stripes; i++) { +if (zone_info[i].alloc_offset ==WP_CONVENTIONAL ) +continue ; +if (last_alloc <= zone_info[i].alloc_offset) { + last_alloc = zone_info[i].alloc_offset; +break ; + } + } +if (zone_info[0 ].alloc_offset ==WP_CONVENTIONAL ) zone_info[0 ].alloc_offset = last_alloc;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 655/752 btrfs: continue trimming remaining devices on failure
In reply to Sasha LevinFrom: jinbaohong <[email protected]>
[ Upstream commit 912d1c6680bdb40b72b1b9204706f32b6eb842c3 ]
Commit 93bba24d4b5a ("btrfs: Enhance btrfs_trim_fs function to handle error better") intended to make device trimming continue even if one device fails, tracking failures and reporting them at the end. However, it used 'break' instead of 'continue', causing the loop to exit on the first device failure.
Fix this by replacing 'break' with 'continue'.
--- fs/btrfs/extent-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/extent-tree.c +1 -1
@@ -6601,7 +6601,7 @@ int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range)if (ret) { dev_failed++; dev_ret = ret; -break ; +continue ; } }mutex_unlock (&fs_devices->device_list_mutex);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 656/752 remoteproc: imx_rproc: Fix invalid loaded resource table detection
In reply to Sasha LevinFrom: Peng Fan <[email protected]>
[ Upstream commit 26aa5295010ffaebcf8f1991c53fa7cf2ee1b20d ]
imx_rproc_elf_find_loaded_rsc_table() may incorrectly report a loaded resource table even when the current firmware does not provide one.
When the device tree contains a "rsc-table" entry, priv->rsc_table is non-NULL and denotes where a resource table would be located if one is present in memory. However, when the current firmware has no resource table, rproc->table_ptr is NULL. The function still returns priv->rsc_table, and the remoteproc core interprets this as a valid loaded resource table.
Fix this by returning NULL from imx_rproc_elf_find_loaded_rsc_table() when there is no resource table for the current firmware (i.e. when rproc->table_ptr is NULL). This aligns the function's semantics with the remoteproc core: a loaded resource table is only reported when a valid table_ptr exists.
With this change, starting firmware without a resource table no longer triggers a crash.
--- drivers/remoteproc/imx_rproc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/remoteproc/imx_rproc.c +4 -0
@@ -608,6 +608,10 @@ imx_rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware * {struct imx_rproc *priv = rproc->priv; +/* No resource table in the firmware */ +if (!rproc->table_ptr) +return NULL ; +if (priv->rsc_table)return (struct resource_table *)priv->rsc_table;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 657/752 perf/arm-cmn: Reject unsupported hardware configurations
In reply to Sasha LevinFrom: Robin Murphy <[email protected]>
[ Upstream commit 36c0de02575ce59dfd879eb4ef63d53a68bbf9ce ]
So far we've been fairly lax about accepting both unknown CMN models (at least with a warning), and unknown revisions of those which we do know, as although things do frequently change between releases, typically enough remains the same to be somewhat useful for at least some basic bringup checks. However, we also make assumptions of the maximum supported sizes and numbers of things in various places, and there's no guarantee that something new might not be bigger and lead to nasty array overflows. Make sure we only try to run on things that actually match our assumptions and so will not risk memory corruption.
We have at least always failed on completely unknown node types, so update that error message for clarity and consistency too.
--- drivers/perf/arm-cmn.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/perf/arm-cmn.c +14 -1
@@ -2422,6 +2422,15 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)arm_cmn_init_node_info (cmn, reg &CMN_CHILD_NODE_ADDR , dn); dn->portid_bits = xp->portid_bits; dn->deviceid_bits = xp->deviceid_bits; +/* +* Logical IDs are assigned from 0 per node type, so as +* soon as we see one bigger than expected, we can assume +* there are more than we can cope with. +*/ +if (dn->logid >CMN_MAX_NODES_PER_EVENT ) { +dev_err (cmn->dev,"Node ID invalid for supported CMN versions: %d\n" , dn->logid); +return -ENODEV ; + }switch (dn->type) {case CMN_TYPE_DTC :
@@ -2471,7 +2480,7 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset)break ;/* Something has gone horribly wrong */ default : -dev_err (cmn->dev,"invalid device node type: 0x%x\n" , dn->type); +dev_err (cmn->dev,"Device node type invalid for supported CMN versions: 0x%x\n" , dn->type);return -ENODEV ; } }
@@ -2499,6 +2508,10 @@ static int arm_cmn_discover(struct arm_cmn *cmn, unsigned int rgn_offset) cmn->mesh_x = cmn->num_xps; cmn->mesh_y = cmn->num_xps / cmn->mesh_x; +if (max (cmn->mesh_x, cmn->mesh_y) >CMN_MAX_DIMENSION ) { +dev_err (cmn->dev,"Mesh size invalid for supported CMN versions: %dx%d\n" , cmn->mesh_x, cmn->mesh_y); +return -ENODEV ; + }/* 1x1 config plays havoc with XP event encodings */ if (cmn->num_xps ==1 )dev_warn (cmn->dev,"1x1 config not fully supported, translate XP events manually\n" );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 658/752 scsi: ufs: core: Flush exception handling work when RPM level is zero
In reply to Sasha LevinFrom: Thomas Yen <[email protected]>
[ Upstream commit f8ef441811ec413717f188f63d99182f30f0f08e ]
Ensure that the exception event handling work is explicitly flushed during suspend when the runtime power management level is set to UFS_PM_LVL_0.
When the RPM level is zero, the device power mode and link state both remain active. Previously, the UFS core driver bypassed flushing exception event handling jobs in this configuration. This created a race condition where the driver could attempt to access the host controller to handle an exception after the system had already entered a deep power-down state, resulting in a system crash.
Explicitly flush this work and disable auto BKOPs before the suspend callback proceeds. This guarantees that pending exception tasks complete and prevents illegal hardware access during the power-down sequence.
--- drivers/ufs/core/ufshcd.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/ufs/core/ufshcd.c +2 -0
@@ -9878,6 +9878,8 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)if (req_dev_pwr_mode ==UFS_ACTIVE_PWR_MODE && req_link_state ==UIC_LINK_ACTIVE_STATE ) { +ufshcd_disable_auto_bkops (hba); +flush_work (&hba->eeh_work); goto vops_suspend; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 659/752 mm/slab: avoid allocating slabobj_ext array from its own slab
In reply to Sasha LevinFrom: Harry Yoo <[email protected]>
[ Upstream commit 280ea9c3154b2af7d841f992c9fc79e9d6534e03 ]
When allocating slabobj_ext array in alloc_slab_obj_exts(), the array can be allocated from the same slab we're allocating the array for. This led to obj_exts_in_slab() incorrectly returning true [1], although the array is not allocated from wasted space of the slab.
Vlastimil Babka observed that this problem should be fixed even when ignoring its incompatibility with obj_exts_in_slab(), because it creates slabs that are never freed as there is always at least one allocated object.
To avoid this, use the next kmalloc size or large kmalloc when the array can be allocated from the same cache we're allocating the array for.
In case of random kmalloc caches, there are multiple kmalloc caches for the same size and the cache is selected based on the caller address. Because it is fragile to ensure the same caller address is passed to kmalloc_slab(), kmalloc_noprof(), and kmalloc_node_noprof(), bump the size to (s->object_size + 1) when the sizes are equal, instead of directly comparing the kmem_cache pointers.
Note that this doesn't happen when memory allocation profiling is disabled, as when the allocation of the array is triggered by memory cgroup (KMALLOC_CGROUP), the array is allocated from KMALLOC_NORMAL.
--- mm/slub.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 7 deletions(-)
mm/slub.c +53 -7
@@ -2099,6 +2099,49 @@ static inline void init_slab_obj_exts(struct slab *slab) slab->obj_exts =0 ; } +/* +* Calculate the allocation size for slabobj_ext array. +* +* When memory allocation profiling is enabled, the obj_exts array +* could be allocated from the same slab cache it's being allocated for. +* This would prevent the slab from ever being freed because it would +* always contain at least one allocated object (its own obj_exts array). +* +* To avoid this, increase the allocation size when we detect the array +* may come from the same cache, forcing it to use a different cache. +*/ +static inline size_t obj_exts_alloc_size (struct kmem_cache *s, +struct slab *slab,gfp_t gfp) +{ +size_t sz =sizeof (struct slabobj_ext ) * slab->objects; +struct kmem_cache *obj_exts_cache; + +/* +* slabobj_ext array for KMALLOC_CGROUP allocations +* are served from KMALLOC_NORMAL caches. +*/ +if (!mem_alloc_profiling_enabled ()) +return sz; + +if (sz >KMALLOC_MAX_CACHE_SIZE ) +return sz; + +if (!is_kmalloc_normal (s)) +return sz; + + obj_exts_cache =kmalloc_slab (sz,NULL , gfp,0 ); +/* +* We can't simply compare s with obj_exts_cache, because random kmalloc +* caches have multiple caches per size, selected by caller address. +* Since caller address may differ between kmalloc_slab() and actual +* allocation, bump size when sizes are equal. +*/ +if (s->object_size == obj_exts_cache->object_size) +return obj_exts_cache->object_size +1 ; + +return sz; +} +int alloc_slab_obj_exts (struct slab *slab,struct kmem_cache *s,gfp_t gfp,bool new_slab) {
@@ -2107,26 +2150,26 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,unsigned long new_exts;unsigned long old_exts;struct slabobj_ext *vec; +size_t sz; gfp &= ~OBJCGS_CLEAR_MASK ;/* Prevent recursive extension vector allocation */ gfp |= __GFP_NO_OBJ_EXT; + sz =obj_exts_alloc_size (s, slab, gfp); +/* * Note that allow_spin may be false during early boot and its * restricted GFP_BOOT_MASK. Due to kmalloc_nolock() only supporting * architectures with cmpxchg16b, early obj_exts will be missing for * very early allocations on those. */ -if (unlikely (!allow_spin)) { -size_t sz = objects *sizeof (struct slabobj_ext ); - +if (unlikely (!allow_spin)) vec =kmalloc_nolock (sz, __GFP_ZERO | __GFP_NO_OBJ_EXT,slab_nid (slab)); - }else { - vec =kcalloc_node (objects,sizeof (struct slabobj_ext ), gfp, -slab_nid (slab)); - } +else + vec =kmalloc_node (sz, gfp | __GFP_ZERO,slab_nid (slab)); +if (!vec) {/* * Try to mark vectors which failed to allocate.
@@ -2140,6 +2183,9 @@ int alloc_slab_obj_exts(struct slab *slab, struct kmem_cache *s,return -ENOMEM ; } +VM_WARN_ON_ONCE (virt_to_slab (vec) !=NULL && +virt_to_slab (vec)->slab_cache == s); + new_exts = (unsigned long )vec;if (unlikely (!allow_spin)) new_exts |=OBJEXTS_NOSPIN_ALLOC ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 660/752 mm/slab: use unsigned long for orig_size to ensure proper metadata align
In reply to Sasha LevinFrom: Harry Yoo <[email protected]>
[ Upstream commit b85f369b81aed457acbea4ad3314218254a72fd2 ]
When both KASAN and SLAB_STORE_USER are enabled, accesses to struct kasan_alloc_meta fields can be misaligned on 64-bit architectures. This occurs because orig_size is currently defined as unsigned int, which only guarantees 4-byte alignment. When struct kasan_alloc_meta is placed after orig_size, it may end up at a 4-byte boundary rather than the required 8-byte boundary on 64-bit systems.
Note that 64-bit architectures without HAVE_EFFICIENT_UNALIGNED_ACCESS are assumed to require 64-bit accesses to be 64-bit aligned. See HAVE_64BIT_ALIGNED_ACCESS and commit adab66b71abf ("Revert:
"ring-buffer: Remove HAVE_64BIT_ALIGNED_ACCESS"") for more details.
Change orig_size from unsigned int to unsigned long to ensure proper alignment for any subsequent metadata. This should not waste additional memory because kmalloc objects are already aligned to at least ARCH_KMALLOC_MINALIGN.
--- mm/slub.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
mm/slub.c +7 -7
@@ -863,7 +863,7 @@ static inline bool slab_update_freelist(struct kmem_cache *s, struct slab *slab,* request size in the meta data area, for better debug and sanity check. */ static inline void set_orig_size (struct kmem_cache *s, -void *object,unsigned int orig_size) +void *object,unsigned long orig_size) {void *p =kasan_reset_tag (object);
@@ -873,10 +873,10 @@ static inline void set_orig_size(struct kmem_cache *s, p +=get_info_end (s); p +=sizeof (struct track ) *2 ; - *(unsigned int *)p = orig_size; + *(unsigned long *)p = orig_size; } -static inline unsigned int get_orig_size (struct kmem_cache *s,void *object) +static inline unsigned long get_orig_size (struct kmem_cache *s,void *object) {void *p =kasan_reset_tag (object);
@@ -889,7 +889,7 @@ static inline unsigned int get_orig_size(struct kmem_cache *s, void *object) p +=get_info_end (s); p +=sizeof (struct track ) *2 ; -return *(unsigned int *)p; +return *(unsigned long *)p; }#ifdef CONFIG_SLUB_DEBUG
@@ -1204,7 +1204,7 @@ static void print_trailer(struct kmem_cache *s, struct slab *slab, u8 *p) off +=2 *sizeof (struct track );if (slub_debug_orig_size (s)) - off +=sizeof (unsigned int ); + off +=sizeof (unsigned long ); off +=kasan_metadata_size (s, false);
@@ -1400,7 +1400,7 @@ static int check_pad_bytes(struct kmem_cache *s, struct slab *slab, u8 *p) off +=2 *sizeof (struct track );if (s->flags &SLAB_KMALLOC ) - off +=sizeof (unsigned int ); + off +=sizeof (unsigned long ); } off +=kasan_metadata_size (s, false);
@@ -8013,7 +8013,7 @@ static int calculate_sizes(struct kmem_cache_args *args, struct kmem_cache *s)/* Save the original kmalloc request size */ if (flags &SLAB_KMALLOC ) - size += sizeof(unsigned int); + size += sizeof(unsigned long); }#endif
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 661/752 MIPS: Loongson2ef: Register PCI controller in early stage
In reply to Sasha LevinFrom: Rong Zhang <[email protected]>
[ Upstream commit 6a00c043af07492502ba7a2263ddc4cdb01b66a7 ]
We are about to set loongson_pci_io_resource.start to 0 and adopt PCIBIOS_MIN_IO. As the first step, PCI controller needs to be registered in early stage to make it the root of other resources (e.g., i8259) and prevent resource conflicts.
Register it in plat_mem_setup() instead of arch_initcall().
--- arch/mips/include/asm/mach-loongson2ef/loongson.h | 6 ++++++ arch/mips/loongson2ef/common/pci.c | 7 +------ arch/mips/loongson2ef/common/setup.c | 1 + 3 files changed, 8 insertions(+), 6 deletions(-)
arch/mips/include/asm/mach-loongson2ef/loongson.h +6 -0
@@ -324,4 +324,10 @@ extern unsigned long _loongson_addrwincfg_base;#endif /* ! CONFIG_CPU_SUPPORTS_ADDRWINCFG */ +#ifdef CONFIG_PCI +void loongson2ef_pcibios_init (void ); +#else +static inline void loongson2ef_pcibios_init (void ) { } +#endif +#endif /* __ASM_MACH_LOONGSON2EF_LOONGSON_H */
arch/mips/loongson2ef/common/pci.c +1 -6
@@ -73,15 +73,10 @@ static void __init setup_pcimap(void)#endif } -static int __init pcibios_init (void ) +void __init loongson2ef_pcibios_init (void ) {setup_pcimap (); loongson_pci_controller.io_map_base = mips_io_port_base;register_pci_controller (&loongson_pci_controller); - - -return 0 ; } - -arch_initcall (pcibios_init);
arch/mips/loongson2ef/common/setup.c +1 -0
@@ -27,4 +27,5 @@ EXPORT_SYMBOL(__wbflush);void __init plat_mem_setup (void ) { +loongson2ef_pcibios_init (); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 662/752 MIPS: Loongson2ef: Use pcibios_align_resource() to block io range
In reply to Sasha LevinFrom: Rong Zhang <[email protected]>
[ Upstream commit 32ec465103527ede09b640cd0ab0636dc58827fb ]
Loongson2ef reserves io range below 0x4000 (LOONGSON_PCI_IO_START) while ISA-mode only IDE controller on the south bridge still has a hard dependency on ISA IO ports.
The reservation was done by lifting loongson_pci_io_resource.start onto 0x4000. Prior to commit ae81aad5c2e1 ("MIPS: PCI: Use pci_enable_resources()"), the arch specific pcibios_enable_resources() did not check if the resources were claimed, which diverges from what PCI core checks, effectively hiding the fact that IDE IO resources were not properly within the resource tree. After starting to use pcibios_enable_resources() from PCI core, enabling IDE controller fails:
pata_cs5536 0000:00:0e.2: BAR 0 [io 0x01f0-0x01f7]: not claimed; can't enable device pata_cs5536 0000:00:0e.2: probe with driver pata_cs5536 failed with error -22
MIPS PCI code already has support for enforcing lower bounds using PCIBIOS_MIN_IO in pcibios_align_resource() without altering the IO window start address itself. Make Loongson2ef PCI code use PCIBIOS_MIN_IO too.
--- arch/mips/loongson2ef/common/pci.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/mips/loongson2ef/common/pci.c +10 -1
@@ -17,7 +17,7 @@ static struct resource loongson_pci_mem_resource = {static struct resource loongson_pci_io_resource = { .name ="pci io space" , - .start =LOONGSON_PCI_IO_START , + .start =0x00000000UL ,/* See loongson2ef_pcibios_init(). */ .end =IO_SPACE_LIMIT , .flags =IORESOURCE_IO , };
@@ -77,6 +77,15 @@ void __init loongson2ef_pcibios_init(void) {setup_pcimap (); +/* +* ISA-mode only IDE controllers have a hard dependency on ISA IO ports. +* +* Claim them by setting PCI IO space to start at 0x00000000, and set +* PCIBIOS_MIN_IO to prevent non-legacy PCI devices from touching +* reserved regions. +*/ +PCIBIOS_MIN_IO =LOONGSON_PCI_IO_START ; + loongson_pci_controller.io_map_base = mips_io_port_base;register_pci_controller (&loongson_pci_controller); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 663/752 PCI: dwc: Fix msg_atu_index assignment
In reply to Sasha LevinFrom: Niklas Cassel <[email protected]>
[ Upstream commit 58fbf08935d9c4396417e5887df89a4e681fa7e3 ]
When dw_pcie_iatu_setup() configures outbound address translation for both type PCIE_ATU_TYPE_MEM and PCIE_ATU_TYPE_IO, the iATU index to use is incremented before calling dw_pcie_prog_outbound_atu().
However for msg_atu_index, the index is not incremented before use, causing the iATU index to be the same as the last configured iATU index, which means that it will incorrectly use the same iATU index that is already in use, breaking outbound address translation.
In total there are three problems with this code:
-It assigns msg_atu_index the same index that was used for the last
outbound address translation window, rather than incrementing the index before assignment.
-The index should only be incremented (and msg_atu_index assigned) if the
use_atu_msg feature is actually requested/in use (pp->use_atu_msg is set).
-If the use_atu_msg feature is requested/in use, and there are no outbound
iATUs available, the code should return an error, as otherwise when this this feature is used, it will use an iATU index that is out of bounds.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-host.c +8 -1
@@ -936,7 +936,14 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp)dev_warn (pci->dev,"Ranges exceed outbound iATU size (%d)\n" , pci->num_ob_windows); - pp->msg_atu_index = i; +if (pp->use_atu_msg) { +if (pci->num_ob_windows > ++i) { + pp->msg_atu_index = i; + }else { +dev_err (pci->dev,"Cannot add outbound window for MSG TLP\n" ); +return -ENOMEM ; + } + } i =0 ;resource_list_for_each_entry (entry, &pp->bridge->dma_ranges) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 664/752 mux: mmio: fix regmap leak on probe failure
In reply to Sasha LevinFrom: Johan Hovold <[email protected]>
[ Upstream commit 3c4ae63073d84abee5d81ce46d86a94e9dae9c89 ]
The mmio regmap that may be allocated during probe is never freed.
Switch to using the device managed allocator so that the regmap is released on probe failures (e.g. probe deferral) and on driver unbind.
--- drivers/mux/mmio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mux/mmio.c +1 -1
@@ -58,7 +58,7 @@ static int mux_mmio_probe(struct platform_device *pdev)if (IS_ERR (base)) regmap =ERR_PTR (-ENODEV );else - regmap =regmap_init_mmio (dev, base, &mux_mmio_regmap_cfg); + regmap =devm_regmap_init_mmio (dev, base, &mux_mmio_regmap_cfg);/* Fallback to checking the parent node on "real" errors. */ if (IS_ERR (regmap) && regmap !=ERR_PTR (-EPROBE_DEFER )) { regmap =dev_get_regmap (dev->parent,NULL );
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 665/752 usb: dwc3: gadget: Move vbus draw to workqueue context
In reply to Sasha LevinFrom: Prashanth K <[email protected]>
[ Upstream commit 54aaa3b387c2f580a99dc86a9cc2eb6dfaf599a7 ]
Currently dwc3_gadget_vbus_draw() can be called from atomic context, which in turn invokes power-supply-core APIs. And some these PMIC APIs have operations that may sleep, leading to kernel panic.
Fix this by moving the vbus_draw into a workqueue context.
--- drivers/usb/dwc3/core.c | 19 ++++++++++++++++++- drivers/usb/dwc3/core.h | 4 ++++ drivers/usb/dwc3/gadget.c | 8 +++----- 3 files changed, 25 insertions(+), 6 deletions(-)
drivers/usb/dwc3/core.c +18 -1
@@ -2149,6 +2149,20 @@ static int dwc3_get_num_ports(struct dwc3 *dwc)return 0 ; } +static void dwc3_vbus_draw_work (struct work_struct *work) +{ + struct dwc3 *dwc = container_of(work, struct dwc3, vbus_draw_work); +union power_supply_propval val = {0 }; +int ret; + + val.intval =1000 * (dwc->current_limit); + ret =power_supply_set_property (dwc->usb_psy,POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT , &val); + +if (ret <0 ) +dev_dbg (dwc->dev,"Error (%d) setting vbus draw (%d mA)\n" , + ret, dwc->current_limit); +} +static struct power_supply *dwc3_get_usb_power_supply (struct dwc3 *dwc) {struct power_supply *usb_psy;
@@ -2163,6 +2177,7 @@ static struct power_supply *dwc3_get_usb_power_supply(struct dwc3 *dwc)if (!usb_psy)return ERR_PTR (-EPROBE_DEFER ); +INIT_WORK (&dwc->vbus_draw_work, dwc3_vbus_draw_work);return usb_psy; }
@@ -2386,8 +2401,10 @@ void dwc3_core_remove(struct dwc3 *dwc)dwc3_free_event_buffers (dwc); -if (dwc->usb_psy) +if (dwc->usb_psy) { +cancel_work_sync (&dwc->vbus_draw_work);power_supply_put (dwc->usb_psy); + } }EXPORT_SYMBOL_GPL (dwc3_core_remove);
drivers/usb/dwc3/core.h +4 -0
@@ -1060,6 +1060,8 @@ struct dwc3_glue_ops {* @role_switch_default_mode: default operation mode of controller while * usb role is USB_ROLE_NONE. * @usb_psy: pointer to power supply interface. +* @vbus_draw_work: Work to set the vbus drawing limit +* @current_limit: How much current to draw from vbus, in milliAmperes. * @usb2_phy: pointer to USB2 PHY * @usb3_phy: pointer to USB3 PHY * @usb2_generic_phy: pointer to array of USB2 PHYs
@@ -1246,6 +1248,8 @@ struct dwc3 {enum usb_dr_mode role_switch_default_mode;struct power_supply *usb_psy; +struct work_struct vbus_draw_work; +unsigned int current_limit;u32 fladj;u32 ref_clk_per;
drivers/usb/dwc3/gadget.c +3 -5
@@ -3123,8 +3123,6 @@ static void dwc3_gadget_set_ssp_rate(struct usb_gadget *g,static int dwc3_gadget_vbus_draw (struct usb_gadget *g,unsigned int mA) {struct dwc3 *dwc =gadget_to_dwc (g); -union power_supply_propval val = {0 }; -int ret;if (dwc->usb2_phy)return usb_phy_set_power (dwc->usb2_phy, mA);
@@ -3132,10 +3130,10 @@ static int dwc3_gadget_vbus_draw(struct usb_gadget *g, unsigned int mA)if (!dwc->usb_psy)return -EOPNOTSUPP ; - val.intval =1000 * mA; - ret =power_supply_set_property (dwc->usb_psy,POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT , &val); + dwc->current_limit = mA; +schedule_work (&dwc->vbus_draw_work); -return ret; +return 0 ; }/**
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 666/752 usb: dwc2: fix resume failure if dr_mode is host
In reply to Sasha LevinFrom: Jisheng Zhang <[email protected]>
[ Upstream commit a52e4f2dff413b58c7200e89bb6540bd995e1269 ]
commit 13b1f8e25bfd1 ("usb: dwc2: Force mode optimizations") removed the dwc2_force_mode(hsotg, true) in dwc2_force_dr_mode() if dr_mode is host.
But this brings a bug: the controller fails to resume back as host, further debugging shows that the controller is resumed as peripheral. The reason is dwc2_force_dr_mode() missed the host mode forcing, and when resuming from s2ram, GINTSTS is 0 by default, dwc2_is_device_mode in dwc2_resume() misreads this as the controller is in peripheral mode.
Fix the resume failure by adding back the dwc2_force_mode(hsotg, true).
Then an obvious question is: why this bug hasn't been observed and fixed for about six years? There are two resons: most dwc2 platforms set the dr_mode as otg; Some platforms don't have suspend & resume support yet.
--- drivers/usb/dwc2/core.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/dwc2/core.c +1 -0
@@ -578,6 +578,7 @@ void dwc2_force_dr_mode(struct dwc2_hsotg *hsotg) {switch (hsotg->dr_mode) {case USB_DR_MODE_HOST : +dwc2_force_mode (hsotg, true);/* * NOTE: This is required for some rockchip soc based * platforms on their host-only dwc2.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 667/752 mtd: rawnand: pl353: Fix software ECC support
In reply to Sasha LevinFrom: Andrea Scian <[email protected]>
[ Upstream commit 89b831ebdaca0df4ca3b226f7e7a1d1db1629060 ]
We need to set also write_page_raw in ecc structure to allow choosing SW ECC instead of HW one, otherwise write operation fail.
--- drivers/mtd/nand/raw/pl35x-nand-controller.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/pl35x-nand-controller.c +1 -0
@@ -976,6 +976,7 @@ static int pl35x_nand_attach_chip(struct nand_chip *chip) fallthrough;case NAND_ECC_ENGINE_TYPE_NONE :case NAND_ECC_ENGINE_TYPE_SOFT : + chip->ecc.write_page_raw = nand_monolithic_write_page_raw;break ;case NAND_ECC_ENGINE_TYPE_ON_HOST : ret =pl35x_nand_init_hw_ecc_controller (nfc, chip);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 668/752 tipc: fix RCU dereference race in tipc_aead_users_dec()
In reply to Sasha LevinFrom: Daniel Hodges <[email protected]>
[ Upstream commit 6a65c0cb0ff20b3cbc5f1c87b37dd22cdde14a1c ]
tipc_aead_users_dec() calls rcu_dereference(aead) twice: once to store in 'tmp' for the NULL check, and again inside the atomic_add_unless() call.
Use the already-dereferenced 'tmp' pointer consistently, matching the correct pattern used in tipc_aead_users_inc() and tipc_aead_users_set().
--- net/tipc/crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/tipc/crypto.c +1 -1
@@ -460,7 +460,7 @@ static void tipc_aead_users_dec(struct tipc_aead __rcu *aead, int lim)rcu_read_lock (); tmp =rcu_dereference (aead);if (tmp) -atomic_add_unless (&rcu_dereference (aead)->users,-1 , lim); +atomic_add_unless (&tmp->users,-1 , lim);rcu_read_unlock (); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 669/752 drm/amdkfd: Fix out-of-bounds write in kfd_event_page_set()
In reply to Sasha LevinFrom: Sunday Clement <[email protected]>
[ Upstream commit 8a70a26c9f34baea6c3199a9862ddaff4554a96d ]
The kfd_event_page_set() function writes KFD_SIGNAL_EVENT_LIMIT * 8 bytes via memset without checking the buffer size parameter. This allows unprivileged userspace to trigger an out-of bounds kernel memory write by passing a small buffer, leading to potential privilege escalation.
--- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +6 -0
@@ -331,6 +331,12 @@ static int kfd_event_page_set(struct kfd_process *p, void *kernel_address,if (p->signal_page)return -EBUSY ; +if (size <KFD_SIGNAL_EVENT_LIMIT *8 ) { +pr_err ("Event page size %llu is too small, need at least %lu bytes\n" , + size, (unsigned long )(KFD_SIGNAL_EVENT_LIMIT *8 )); +return -EINVAL ; + } + page =kzalloc (sizeof (*page),GFP_KERNEL );if (!page)return -ENOMEM ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 670/752 drm/amdgpu: Protect GPU register accesses in powergated state in some paths
In reply to Sasha LevinFrom: Yifan Zhang <[email protected]>
[ Upstream commit 39fc2bc4da0082c226cbee331f0a5d44db3997da ]
Ungate GPU CG/PG in device_fini_hw and device_halt to protect GPU register accesses, e.g. GC registers are accessed in amdgpu_irq_disable_all() and amdgpu_fence_driver_hw_fini().
--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -3
@@ -3630,9 +3630,6 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev) } } -amdgpu_device_set_pg_state (adev,AMD_PG_STATE_UNGATE ); -amdgpu_device_set_cg_state (adev,AMD_CG_STATE_UNGATE ); -amdgpu_amdkfd_suspend (adev, true);amdgpu_userq_suspend (adev);
@@ -4961,6 +4958,9 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)amdgpu_virt_fini_data_exchange (adev); } +amdgpu_device_set_pg_state (adev,AMD_PG_STATE_UNGATE ); +amdgpu_device_set_cg_state (adev,AMD_CG_STATE_UNGATE ); +/* disable all interrupts */ amdgpu_irq_disable_all (adev);if (adev->mode_info.mode_config_initialized) {
@@ -7354,6 +7354,9 @@ void amdgpu_device_halt(struct amdgpu_device *adev)amdgpu_xcp_dev_unplug (adev);drm_dev_unplug (ddev); +amdgpu_device_set_pg_state (adev,AMD_PG_STATE_UNGATE ); +amdgpu_device_set_cg_state (adev,AMD_CG_STATE_UNGATE ); +amdgpu_irq_disable_all (adev);amdgpu_fence_driver_hw_fini (adev);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 671/752 net: cpsw_new: Fix unnecessary netdev unregistration in cpsw_probe() error path
In reply to Sasha LevinFrom: Kevin Hao <[email protected]>
[ Upstream commit 62db84b7efa63b78aed9fdbdae90f198771be94c ]
The current error handling in cpsw_probe() has two issues:
- cpsw_unregister_ports() may be called before cpsw_register_ports() has been executed.
- cpsw_unregister_ports() is already invoked within cpsw_register_ports() in case of a register_netdev() failure, but the error path would call it again.
--- drivers/net/ethernet/ti/cpsw_new.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/net/ethernet/ti/cpsw_new.c +5 -7
@@ -2001,7 +2001,7 @@ static int cpsw_probe(struct platform_device *pdev)/* setup netdevs */ ret =cpsw_create_ports (cpsw);if (ret) - goto clean_unregister_netdev; + goto clean_cpts;/* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and * MISC IRQs which are always kept disabled with this driver so
@@ -2015,14 +2015,14 @@ static int cpsw_probe(struct platform_device *pdev) 0, dev_name(dev), cpsw);if (ret <0 ) {dev_err (dev,"error attaching irq (%d)\n" , ret); - goto clean_unregister_netdev; + goto clean_cpts; } ret =devm_request_irq (dev, cpsw->irqs_table[1 ], cpsw_tx_interrupt,0 ,dev_name (dev), cpsw);if (ret <0 ) {dev_err (dev,"error attaching irq (%d)\n" , ret); - goto clean_unregister_netdev; + goto clean_cpts; }if (!cpsw->cpts)
@@ -2032,7 +2032,7 @@ static int cpsw_probe(struct platform_device *pdev) 0, dev_name(&pdev->dev), cpsw);if (ret <0 ) {dev_err (dev,"error attaching misc irq (%d)\n" , ret); - goto clean_unregister_netdev; + goto clean_cpts; }/* Enable misc CPTS evnt_pend IRQ */
@@ -2041,7 +2041,7 @@ static int cpsw_probe(struct platform_device *pdev) skip_cpts: ret =cpsw_register_notifiers (cpsw);if (ret) - goto clean_unregister_netdev; + goto clean_cpts; ret =cpsw_register_devlink (cpsw);if (ret)
@@ -2063,8 +2063,6 @@ static int cpsw_probe(struct platform_device *pdev) clean_unregister_notifiers:cpsw_unregister_notifiers (cpsw); -clean_unregister_netdev: -cpsw_unregister_ports (cpsw); clean_cpts:cpts_release (cpsw->cpts);cpdma_ctlr_destroy (cpsw->dma);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 672/752 net: cpsw_new: Fix potential unregister of netdev that has not been registered yet
In reply to Sasha LevinFrom: Kevin Hao <[email protected]>
[ Upstream commit 9d724b34fbe13b71865ad0906a4be97571f19cf5 ]
If an error occurs during register_netdev() for the first MAC in cpsw_register_ports(), even though cpsw->slaves[0].ndev is set to NULL, cpsw->slaves[1].ndev would remain unchanged. This could later cause cpsw_unregister_ports() to attempt unregistering the second MAC. To address this, add a check for ndev->reg_state before calling unregister_netdev(). With this change, setting cpsw->slaves[i].ndev to NULL becomes unnecessary and can be removed accordingly.
--- drivers/net/ethernet/ti/cpsw_new.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/ti/cpsw_new.c +1 -2
@@ -1472,7 +1472,7 @@ static void cpsw_unregister_ports(struct cpsw_common *cpsw)for (i =0 ; i < cpsw->data.slaves; i++) { ndev = cpsw->slaves[i].ndev; -if (!ndev) +if (!ndev || ndev->reg_state !=NETREG_REGISTERED )continue ; priv =netdev_priv (ndev);
@@ -1494,7 +1494,6 @@ static int cpsw_register_ports(struct cpsw_common *cpsw)if (ret) {dev_err (cpsw->dev,"cpsw: err registering net device%d\n" , i); - cpsw->slaves[i].ndev =NULL ;break ; } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 673/752 PCI: Don't claim disabled bridge windows
In reply to Sasha LevinFrom: Ilpo Järvinen <[email protected]>
[ Upstream commit 2ecc1bf14e2fdaff78bd1b8e7ed3dba336a3fad5 ]
The commit 8278c6914306 ("PCI: Preserve bridge window resource type flags") changed bridge window resource behavior such that flags are no longer zero if the bridge window is not valid or is disabled (mainly to preserve the type flags for later use). If a bridge window has its limit smaller than base address, pci_read_bridge_*() sets both IORESOURCE_UNSET and IORESOURCE_DISABLED to indicate the bridge window exists but is not valid with the current base and limit configuration.
The code in pci_claim_bridge_resources() still depends on the old behavior of checking validity of the bridge window solely based on !r->flags, whereas after 8278c6914306, also IORESOURCE_DISABLED may indicate bridge window addresses are not valid.
While pci_claim_resource() does check IORESOURCE_UNSET, pci_claim_bridge_resource() attempts to clip the resource if pci_claim_resource() fails, which is not correct for bridge window resources that are not valid. As pci_bus_clip_resource() performs clipping regardless of flags and then clears IORESOURCE_UNSET, it should not be called unless the resource is valid.
The problem is visible in this log:
pci 0000:20:00.0: PCI bridge to [bus 21]
pci 0000:20:00.0: bridge window [io size 0x0000 disabled]: can't claim; no address assigned pci 0000:20:00.0: [io 0x0000-0xffffffffffffffff disabled] clipped to [io 0x0000-0xffff disabled]
Add IORESOURCE_DISABLED check in pci_claim_bridge_resources() to only claim bridge windows that appear to have a valid configuration.
--- drivers/pci/setup-bus.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pci/setup-bus.c +2 -0
@@ -1681,6 +1681,8 @@ static void pci_claim_bridge_resources(struct pci_dev *dev)if (!r->flags || r->parent)continue ; +if (r->flags &IORESOURCE_DISABLED ) +continue ;pci_claim_bridge_resource (dev, i); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 674/752 PCI: Fix pci_slot_trylock() error handling
In reply to Sasha LevinFrom: Jinhui Guo <[email protected]>
[ Upstream commit 9368d1ee62829b08aa31836b3ca003803caf0b72 ]
Commit a4e772898f8b ("PCI: Add missing bridge lock to pci_bus_lock()") delegates the bridge device's pci_dev_trylock() to pci_bus_trylock() in pci_slot_trylock(), but it forgets to remove the corresponding pci_dev_unlock() when pci_bus_trylock() fails.
Before a4e772898f8b, the code did:
if (!pci_dev_trylock(dev)) /* <- lock bridge device */
goto unlock;
if (dev->subordinate) {
if (!pci_bus_trylock(dev->subordinate)) {
pci_dev_unlock(dev); /* <- unlock bridge device */
goto unlock;
}
}After a4e772898f8b the bridge-device lock is no longer taken, but the pci_dev_unlock(dev) on the failure path was left in place, leading to the bug.
This yields one of two errors:
1. A warning that the lock is being unlocked when no one holds it.
2. An incorrect unlock of a lock that belongs to another thread.
Fix it by removing the now-redundant pci_dev_unlock(dev) on the failure path.
[Same patch later posted by Keith at
https://patch.msgid.link/[email protected]]
--- drivers/pci/pci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/pci.c +1 -3
@@ -5500,10 +5500,8 @@ static int pci_slot_trylock(struct pci_slot *slot)if (!dev->slot || dev->slot != slot)continue ;if (dev->subordinate) { -if (!pci_bus_trylock (dev->subordinate)) { -pci_dev_unlock (dev); +if (!pci_bus_trylock (dev->subordinate)) goto unlock; - } }else if (!pci_dev_trylock (dev)) goto unlock; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 675/752 parisc: kernel: replace kfree() with put_device() in create_tree_node()
In reply to Sasha LevinFrom: Haoxiang Li <[email protected]>
[ Upstream commit dcf69599c47f29ce0a99117eb3f9ddcd2c4e78b6 ]
If device_register() fails, put_device() is the correct way to drop the device reference.
Found by code review.
--- arch/parisc/kernel/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/parisc/kernel/drivers.c +1 -1
@@ -435,7 +435,7 @@ static struct parisc_device * __init create_tree_node(char id, dev->dev.dma_mask = &dev->dma_mask; dev->dev.coherent_dma_mask = dev->dma_mask;if (device_register (&dev->dev)) { -kfree (dev); +put_device (&dev->dev);return NULL ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 676/752 mptcp: pm: in-kernel: always set ID as avail when rm endp
In reply to Sasha LevinFrom: "Matthieu Baerts (NGI0)" <[email protected]>
[ Upstream commit d191101dee25567c2af3b28565f45346c33d65f5 ]
Syzkaller managed to find a combination of actions that was generating this warning:
WARNING: net/mptcp/pm_kernel.c:1074 at __mark_subflow_endp_available net/mptcp/pm_kernel.c:1074 [inline], CPU#1: syz.7.48/2535 WARNING: net/mptcp/pm_kernel.c:1074 at mptcp_pm_nl_fullmesh net/mptcp/pm_kernel.c:1446 [inline], CPU#1: syz.7.48/2535 WARNING: net/mptcp/pm_kernel.c:1074 at mptcp_pm_nl_set_flags_all net/mptcp/pm_kernel.c:1474 [inline], CPU#1: syz.7.48/2535 WARNING: net/mptcp/pm_kernel.c:1074 at mptcp_pm_nl_set_flags+0x5de/0x640 net/mptcp/pm_kernel.c:1538, CPU#1: syz.7.48/2535 Modules linked in: CPU: 1 UID: 0 PID: 2535 Comm: syz.7.48 Not tainted 6.18.0-03987-gea5f5e676cf5 #17 PREEMPT(voluntary) Hardware name: QEMU Ubuntu 25.10 PC (i440FX + PIIX, 1996), BIOS 1.17.0-debian-1.17.0-1 04/01/2014 RIP: 0010:__mark_subflow_endp_available net/mptcp/pm_kernel.c:1074 [inline] RIP: 0010:mptcp_pm_nl_fullmesh net/mptcp/pm_kernel.c:1446 [inline] RIP: 0010:mptcp_pm_nl_set_flags_all net/mptcp/pm_kernel.c:1474 [inline] RIP: 0010:mptcp_pm_nl_set_flags+0x5de/0x640 net/mptcp/pm_kernel.c:1538 Code: 89 c7 e8 c5 8c 73 fe e9 f7 fd ff ff 49 83 ef 80 e8 b7 8c 73 fe 4c 89 ff be 03 00 00 00 e8 4a 29 e3 fe eb ac e8 a3 8c 73 fe 90 <0f> 0b 90 e9 3d ff ff ff e8 95 8c 73 fe b8 a1 ff ff ff eb 1a e8 89 RSP: 0018:ffffc9001535b820 EFLAGS: 00010287 netdevsim0: tun_chr_ioctl cmd 1074025677 RAX: ffffffff82da294d RBX: 0000000000000001 RCX: 0000000000080000 RDX: ffffc900096d0000 RSI: 00000000000006d6 RDI: 00000000000006d7 netdevsim0: linktype set to 823 RBP: ffff88802cdb2240 R08: 00000000000104ae R09: ffffffffffffffff R10: ffffffff82da27d4 R11: 0000000000000000 R12: 0000000000000000 R13: ffff88801246d8c0 R14: ffffc9001535b8b8 R15: ffff88802cdb1800 FS: 00007fc6ac5a76c0(0000) GS:ffff8880f90c8000(0000) knlGS:0000000000000000 netlink: 'syz.3.50': attribute type 5 has an invalid length. CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 netlink: 1232 bytes leftover after parsing attributes in process `syz.3.50'. CR2: 0000200000010000 CR3: 0000000025b1a000 CR4: 0000000000350ef0 Call Trace: <TASK> mptcp_pm_set_flags net/mptcp/pm_netlink.c:277 [inline] mptcp_pm_nl_set_flags_doit+0x1d7/0x210 net/mptcp/pm_netlink.c:282 genl_family_rcv_msg_doit+0x117/0x180 net/netlink/genetlink.c:1115 genl_family_rcv_msg net/netlink/genetlink.c:1195 [inline] genl_rcv_msg+0x3a8/0x3f0 net/netlink/genetlink.c:1210 netlink_rcv_skb+0x16d/0x240 net/netlink/af_netlink.c:2550 genl_rcv+0x28/0x40 net/netlink/genetlink.c:1219 netlink_unicast_kernel net/netlink/af_netlink.c:1318 [inline] netlink_unicast+0x3e9/0x4c0 net/netlink/af_netlink.c:1344 netlink_sendmsg+0x4ab/0x5b0 net/netlink/af_netlink.c:1894 sock_sendmsg_nosec net/socket.c:718 [inline] __sock_sendmsg+0xc9/0xf0 net/socket.c:733 ____sys_sendmsg+0x272/0x3b0 net/socket.c:2608 ___sys_sendmsg+0x2de/0x320 net/socket.c:2662 __sys_sendmsg net/socket.c:2694 [inline] __do_sys_sendmsg net/socket.c:2699 [inline] __se_sys_sendmsg net/socket.c:2697 [inline] __x64_sys_sendmsg+0x110/0x1a0 net/socket.c:2697 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xed/0x360 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fc6adb66f6d Code: ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 e8 ff ff ff f7 d8 64 89 01 48 RSP: 002b:00007fc6ac5a6ff8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00007fc6addf5fa0 RCX: 00007fc6adb66f6d RDX: 0000000000048084 RSI: 00002000000002c0 RDI: 000000000000000e RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 netlink: 'syz.5.51': attribute type 2 has an invalid length. R13: 00007fff25e91fe0 R14: 00007fc6ac5a7ce4 R15: 00007fff25e920d7 </TASK>
The actions that caused that seem to be:
- Create an MPTCP endpoint for address A without any flags
- Create a new MPTCP connection from address A
- Remove the MPTCP endpoint: the corresponding subflows will be removed
- Recreate the endpoint with the same ID, but with the subflow flag
- Change the same endpoint to add the fullmesh flag
In this case, msk->pm.local_addr_used has been kept to 0 as expected, but the corresponding bit in msk->pm.id_avail_bitmap was still unset after having removed the endpoint, causing the splat later on.
When removing an endpoint, the corresponding endpoint ID was only marked as available for "signal" types with an announced address, plus all "subflow" types, but not the other types like an endpoint corresponding to the initial subflow. In these cases, re-creating an endpoint with the same ID didn't signal/create anything. Here, adding the fullmesh flag was creating the splat when calling __mark_subflow_endp_available() from mptcp_pm_nl_fullmesh(), because msk->pm.local_addr_used was set to 0 while the ID was marked as used.
To fix this issue, the corresponding bit in msk->pm.id_avail_bitmap can always be set as available when removing an MPTCP in-kernel endpoint. In other words, moving the call to __set_bit() to do it in all cases, except for "subflow" types where this bit is handled in a dedicated helper.
Note: instead of adding a new spin_(un)lock_bh that would be taken in all cases, do all the actions requiring the spin lock under the same block.
This modification potentially fixes another issue reported by syzbot, see [1]. But without a reproducer or more details about what exactly happened before, it is hard to confirm.
--- net/mptcp/pm_kernel.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
net/mptcp/pm_kernel.c +8 -12
@@ -1042,10 +1042,8 @@ static bool mptcp_pm_remove_anno_addr(struct mptcp_sock *msk, ret =mptcp_remove_anno_list_by_saddr (msk, addr);if (ret || force) {spin_lock_bh (&msk->pm.lock); -if (ret) { -__set_bit (addr->id, msk->pm.id_avail_bitmap); +if (ret) msk->pm.add_addr_signaled--; - }mptcp_pm_remove_addr (msk, &list);spin_unlock_bh (&msk->pm.lock); }
@@ -1083,17 +1081,15 @@ static int mptcp_nl_remove_subflow_and_signal_addr(struct net *net, !(entry->flags & MPTCP_PM_ADDR_FLAG_IMPLICIT)); list.ids[0 ] =mptcp_endp_get_local_id (msk, addr); -if (remove_subflow) { -spin_lock_bh (&msk->pm.lock); -mptcp_pm_rm_subflow (msk, &list); -spin_unlock_bh (&msk->pm.lock); - } -if (entry->flags &MPTCP_PM_ADDR_FLAG_SUBFLOW ) { -spin_lock_bh (&msk->pm.lock); +spin_lock_bh (&msk->pm.lock); +if (remove_subflow) +mptcp_pm_rm_subflow (msk, &list); +if (entry->flags &MPTCP_PM_ADDR_FLAG_SUBFLOW )__mark_subflow_endp_available (msk, list.ids[0 ]); -spin_unlock_bh (&msk->pm.lock); - } +else /* mark endp ID as available, e.g. Signal or MPC endp */ +__set_bit (addr->id, msk->pm.id_avail_bitmap); +spin_unlock_bh (&msk->pm.lock);if (msk->mpc_endpoint_id == entry->addr.id) msk->mpc_endpoint_id =0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 677/752 staging: rtl8723bs: fix null dereference in find_network
In reply to Sasha LevinFrom: Ethan Tidmore <[email protected]>
[ Upstream commit 41460a19654c32d39fd0e3a3671cd8d4b7b8479f ]
The variable pwlan has the possibility of being NULL when passed into rtw_free_network_nolock() which would later dereference the variable.
--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +4 -2
@@ -835,8 +835,10 @@ static void find_network(struct adapter *adapter)struct wlan_network *tgt_network = &pmlmepriv->cur_network; pwlan =rtw_find_network (&pmlmepriv->scanned_queue, tgt_network->network.mac_address); -if (pwlan) - pwlan->fixed = false; +if (!pwlan) +return ; + + pwlan->fixed = false;if (check_fwstate (pmlmepriv,WIFI_ADHOC_MASTER_STATE ) && (adapter->stapriv.asoc_sta_count ==1 ))
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 678/752 kcsan, compiler_types: avoid duplicate type issues in BPF Type Format
In reply to Sasha LevinFrom: Alan Maguire <[email protected]>
[ Upstream commit 9dc052234da736f7749f19ab6936342ec7dbe3ac ]
Enabling KCSAN is causing a large number of duplicate types in BTF for core kernel structs like task_struct [1]. This is due to the definition in include/linux/compiler_types.h
`#ifdef __SANITIZE_THREAD__
...
`#define __data_racy volatile
..
`#else
...
`#define __data_racy
...
`#endif
Because some objects in the kernel are compiled without KCSAN flags (KCSAN_SANITIZE) we sometimes get the empty __data_racy annotation for objects; as a result we get multiple conflicting representations of the associated structs in DWARF, and these lead to multiple instances of core kernel types in BTF since they cannot be deduplicated due to the additional modifier in some instances.
Moving the __data_racy definition under CONFIG_KCSAN avoids this problem, since the volatile modifier will be present for both KCSAN and KCSAN_SANITIZE objects in a CONFIG_KCSAN=y kernel.
--- include/linux/compiler_types.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-)
include/linux/compiler_types.h +16 -7
@@ -303,6 +303,22 @@ struct ftrace_likely_data {# define __no_kasan_or_inline __always_inline#endif +#ifdef CONFIG_KCSAN +/* +* Type qualifier to mark variables where all data-racy accesses should be +* ignored by KCSAN. Note, the implementation simply marks these variables as +* volatile, since KCSAN will treat such accesses as "marked". +* +* Defined here because defining __data_racy as volatile for KCSAN objects only +* causes problems in BPF Type Format (BTF) generation since struct members +* of core kernel data structs will be volatile in some objects and not in +* others. Instead define it globally for KCSAN kernels. +*/ +# define __data_racy volatile +#else +# define __data_racy +#endif +#ifdef __SANITIZE_THREAD__/* * Clang still emits instrumentation for __tsan_func_{entry,exit}() and builtin
@@ -314,16 +330,9 @@ struct ftrace_likely_data {* disable all instrumentation. See Kconfig.kcsan where this is mandatory. */ # define __no_kcsan __no_sanitize_thread __disable_sanitizer_instrumentation -/* -* Type qualifier to mark variables where all data-racy accesses should be -* ignored by KCSAN. Note, the implementation simply marks these variables as -* volatile, since KCSAN will treat such accesses as "marked". -*/ -# define __data_racy volatile# define __no_sanitize_or_inline __no_kcsan notrace __maybe_unused#else # define __no_kcsan -# define __data_racy#endif #ifdef __SANITIZE_MEMORY__
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 679/752 watchdog/softlockup: fix sample ring index wrap in need_counting_irqs()
In reply to Sasha LevinFrom: Shengming Hu <[email protected]>
[ Upstream commit cafe4074a7221dca2fa954dd1ab0cf99b6318e23 ]
cpustat_tail indexes cpustat_util[], which is a NUM_SAMPLE_PERIODS-sized ring buffer. need_counting_irqs() currently wraps the index using NUM_HARDIRQ_REPORT, which only happens to match NUM_SAMPLE_PERIODS.
Use NUM_SAMPLE_PERIODS for the wrap to keep the ring math correct even if the NUM_HARDIRQ_REPORT or NUM_SAMPLE_PERIODS changes.
--- kernel/watchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/watchdog.c +1 -1
@@ -521,7 +521,7 @@ static bool need_counting_irqs(void)u8 util;int tail =__this_cpu_read (cpustat_tail); - tail = (tail +NUM_HARDIRQ_REPORT -1 ) %NUM_HARDIRQ_REPORT ; + tail = (tail +NUM_SAMPLE_PERIODS -1 ) %NUM_SAMPLE_PERIODS ; util =__this_cpu_read (cpustat_util[tail][STATS_HARDIRQ ]);return util >HARDIRQ_PERCENT_THRESH ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 680/752 i2c: imx-lpi2c: fix SMBus block read NACK after byte count
In reply to Sasha LevinFrom: Carlos Song <[email protected]>
[ Upstream commit efdc383d1cc28d45cbf5a23b5ffa997010aaacb4 ]
The LPI2C controller sends a NACK at the end of a receive command unless another receive command is already queued in MTDR. During SMBus block reads, this causes the controller to NACK immediately after receiving the block length byte, aborting the transfer before the data bytes are read.
Fix this by queueing a second receive command as soon as the block length byte is received, keeping MTDR non-empty and ensuring continuous ACKs. The initial receive command reads the block length, and the subsequent command reads the remaining data bytes according to the reported length.
--- drivers/i2c/busses/i2c-imx-lpi2c.c | 107 ++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 24 deletions(-)
drivers/i2c/busses/i2c-imx-lpi2c.c +83 -24
@@ -5,6 +5,7 @@* Copyright 2016 Freescale Semiconductor, Inc. */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/completion.h> #include <linux/delay.h>
@@ -90,6 +91,7 @@#define MRDR_RXEMPTY BIT(14)#define MDER_TDDE BIT(0)#define MDER_RDDE BIT(1) +#define MSR_RDF_ASSERTED (x) FIELD_GET(MSR_RDF, (x))#define SCR_SEN BIT(0)#define SCR_RST BIT(1)
@@ -461,7 +463,7 @@ static bool lpi2c_imx_write_txfifo(struct lpi2c_imx_struct *lpi2c_imx, bool atomstatic bool lpi2c_imx_read_rxfifo (struct lpi2c_imx_struct *lpi2c_imx,bool atomic) { -unsigned int blocklen, remaining; +unsigned int remaining;unsigned int temp, data; do {
@@ -472,15 +474,6 @@ static bool lpi2c_imx_read_rxfifo(struct lpi2c_imx_struct *lpi2c_imx, bool atomi lpi2c_imx->rx_buf[lpi2c_imx->delivered++] = data &0xff ; }while (1 ); -/* -* First byte is the length of remaining packet in the SMBus block -* data read. Add it to msgs->len. -*/ -if (lpi2c_imx->block_data) { - blocklen = lpi2c_imx->rx_buf[0 ]; - lpi2c_imx->msglen += blocklen; - } - remaining = lpi2c_imx->msglen - lpi2c_imx->delivered;if (!remaining) {
@@ -493,12 +486,7 @@ static bool lpi2c_imx_read_rxfifo(struct lpi2c_imx_struct *lpi2c_imx, bool atomilpi2c_imx_set_rx_watermark (lpi2c_imx);/* multiple receive commands */ -if (lpi2c_imx->block_data) { - lpi2c_imx->block_data =0 ; - temp = remaining; - temp |= (RECV_DATA <<8 ); -writel (temp, lpi2c_imx->base +LPI2C_MTDR ); - }else if (!(lpi2c_imx->delivered &0xff )) { +if (!(lpi2c_imx->delivered &0xff )) { temp = (remaining >CHUNK_DATA ?CHUNK_DATA : remaining) -1 ; temp |= (RECV_DATA <<8 );writel (temp, lpi2c_imx->base +LPI2C_MTDR );
@@ -536,18 +524,77 @@ static int lpi2c_imx_write_atomic(struct lpi2c_imx_struct *lpi2c_imx,return err; } -static void lpi2c_imx_read_init (struct lpi2c_imx_struct *lpi2c_imx, -struct i2c_msg *msgs) +static unsigned int lpi2c_SMBus_block_read_length_byte (struct lpi2c_imx_struct *lpi2c_imx) { -unsigned int temp; +unsigned int data; + + data =readl (lpi2c_imx->base +LPI2C_MRDR ); + lpi2c_imx->rx_buf[lpi2c_imx->delivered++] = data &0xff ; + +return data; +} + +static int lpi2c_imx_read_init (struct lpi2c_imx_struct *lpi2c_imx, +struct i2c_msg *msgs) +{ +unsigned int temp, val, block_len; +int ret; lpi2c_imx->rx_buf = msgs->buf; lpi2c_imx->block_data = msgs->flags &I2C_M_RECV_LEN ;lpi2c_imx_set_rx_watermark (lpi2c_imx); - temp = msgs->len >CHUNK_DATA ?CHUNK_DATA -1 : msgs->len -1 ; - temp |= (RECV_DATA <<8 ); -writel (temp, lpi2c_imx->base +LPI2C_MTDR ); + +if (!lpi2c_imx->block_data) { + temp = msgs->len >CHUNK_DATA ?CHUNK_DATA -1 : msgs->len -1 ; + temp |= (RECV_DATA <<8 ); +writel (temp, lpi2c_imx->base +LPI2C_MTDR ); + }else { +/* +* The LPI2C controller automatically sends a NACK after the last byte of a +* receive command, unless the next command in MTDR is also a receive command. +* If MTDR is empty when a receive completes, a NACK is sent by default. +* +* To comply with the SMBus block read spec, we start with a 2-byte read: +* The first byte in RXFIFO is the block length. Once this byte arrives, the +* controller immediately updates MTDR with the next read command, ensuring +* continuous ACK instead of NACK. +* +* The second byte is the first block data byte. Therefore, the subsequent +* read command should request (block_len - 1) bytes, since one data byte +* has already been read. +*/ + +writel ((RECV_DATA <<8 ) |0x01 , lpi2c_imx->base +LPI2C_MTDR ); + + ret =readl_poll_timeout (lpi2c_imx->base +LPI2C_MSR , val, +MSR_RDF_ASSERTED (val),1 ,1000 ); +if (ret) { +dev_err (&lpi2c_imx->adapter.dev,"SMBus read count failed %d\n" , ret); +return ret; + } + +/* Read block length byte and confirm this SMBus transfer meets protocol */ + block_len =lpi2c_SMBus_block_read_length_byte (lpi2c_imx); +if (block_len ==0 || block_len >I2C_SMBUS_BLOCK_MAX ) { +dev_err (&lpi2c_imx->adapter.dev,"Invalid SMBus block read length\n" ); +return -EPROTO ; + } + +/* +* When block_len shows more bytes need to be read, update second read command to +* keep MTDR non-empty and ensuring continuous ACKs. Only update command register +* here. All block bytes will be read out at IRQ handler or lpi2c_imx_read_atomic() +* function. +*/ +if (block_len >1 ) +writel ((RECV_DATA <<8 ) | (block_len -2 ), lpi2c_imx->base +LPI2C_MTDR ); + + lpi2c_imx->msglen += block_len; + msgs->len += block_len; + } + +return 0 ; }static bool lpi2c_imx_read_chunk_atomic (struct lpi2c_imx_struct *lpi2c_imx)
@@ -592,6 +639,10 @@ static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg)if (!lpi2c_imx->can_use_dma)return false; +/* DMA is not suitable for SMBus block read */ +if (msg->flags &I2C_M_RECV_LEN ) +return false; +/* * A system-wide suspend or resume transition is in progress. LPI2C should use PIO to * transfer data to avoid issue caused by no ready DMA HW resource.
@@ -609,10 +660,14 @@ static bool is_use_dma(struct lpi2c_imx_struct *lpi2c_imx, struct i2c_msg *msg)static int lpi2c_imx_pio_xfer (struct lpi2c_imx_struct *lpi2c_imx,struct i2c_msg *msg) { +int ret; +reinit_completion (&lpi2c_imx->complete);if (msg->flags &I2C_M_RD ) { -lpi2c_imx_read_init (lpi2c_imx, msg); + ret =lpi2c_imx_read_init (lpi2c_imx, msg); +if (ret) +return ret;lpi2c_imx_intctrl (lpi2c_imx,MIER_RDIE |MIER_NDIE ); }else {lpi2c_imx_write (lpi2c_imx, msg);
@@ -624,8 +679,12 @@ static int lpi2c_imx_pio_xfer(struct lpi2c_imx_struct *lpi2c_imx,static int lpi2c_imx_pio_xfer_atomic (struct lpi2c_imx_struct *lpi2c_imx,struct i2c_msg *msg) { +int ret; +if (msg->flags &I2C_M_RD ) { -lpi2c_imx_read_init (lpi2c_imx, msg); + ret =lpi2c_imx_read_init (lpi2c_imx, msg); +if (ret) +return ret;return lpi2c_imx_read_atomic (lpi2c_imx, msg); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 681/752 cifs: Fix locking usage for tcon fields
In reply to Sasha LevinFrom: Shyam Prasad N <[email protected]>
[ Upstream commit 96c4af418586ee9a6aab61738644366426e05316 ]
We used to use the cifs_tcp_ses_lock to protect a lot of objects that are not just the server, ses or tcon lists. We later introduced srv_lock, ses_lock and tc_lock to protect fields within the corresponding structs. This was done to provide a more granular protection and avoid unnecessary serialization.
There were still a couple of uses of cifs_tcp_ses_lock to provide tcon fields. In this patch, I've replaced them with tc_lock.
--- fs/smb/client/cached_dir.c | 4 ++-- fs/smb/client/smb2misc.c | 6 +++--- fs/smb/client/smb2ops.c | 8 +++----- fs/smb/client/smb2pdu.c | 2 ++ fs/smb/client/trace.h | 1 + 5 files changed, 11 insertions(+), 10 deletions(-)
fs/smb/client/cached_dir.c +2 -2
@@ -788,11 +788,11 @@ static void cfids_laundromat_worker(struct work_struct *work) cfid->dentry =NULL ;if (cfid->is_open) { -spin_lock (&cifs_tcp_ses_lock); +spin_lock (&cfid->tcon->tc_lock); ++cfid->tcon->tc_count;trace_smb3_tcon_ref (cfid->tcon->debug_id, cfid->tcon->tc_count, netfs_trace_tcon_ref_get_cached_laundromat); -spin_unlock (&cifs_tcp_ses_lock); +spin_unlock (&cfid->tcon->tc_lock);queue_work (serverclose_wq, &cfid->close_work); }else /*
fs/smb/client/smb2misc.c +3 -3
@@ -819,14 +819,14 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid,int rc;cifs_dbg (FYI ,"%s: tc_count=%d\n" , __func__, tcon->tc_count); -spin_lock (&cifs_tcp_ses_lock); +spin_lock (&tcon->tc_lock);if (tcon->tc_count <=0 ) {struct TCP_Server_Info *server =NULL ;trace_smb3_tcon_ref (tcon->debug_id, tcon->tc_count, netfs_trace_tcon_ref_see_cancelled_close);WARN_ONCE (tcon->tc_count <0 ,"tcon refcount is negative" ); -spin_unlock (&cifs_tcp_ses_lock); +spin_unlock (&tcon->tc_lock);if (tcon->ses) { server = tcon->ses->server;
@@ -840,7 +840,7 @@ smb2_handle_cancelled_close(struct cifs_tcon *tcon, __u64 persistent_fid, tcon->tc_count++;trace_smb3_tcon_ref (tcon->debug_id, tcon->tc_count, netfs_trace_tcon_ref_get_cancelled_close); -spin_unlock (&cifs_tcp_ses_lock); +spin_unlock (&tcon->tc_lock); rc =__smb2_handle_cancelled_cmd (tcon,SMB2_CLOSE_HE ,0 , persistent_fid, volatile_fid);
fs/smb/client/smb2ops.c +3 -5
@@ -3074,7 +3074,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses, struct cifs_tcon, tcon_list);if (tcon) { +spin_lock (&tcon->tc_lock); tcon->tc_count++; +spin_unlock (&tcon->tc_lock);trace_smb3_tcon_ref (tcon->debug_id, tcon->tc_count, netfs_trace_tcon_ref_get_dfs_refer); }
@@ -3143,13 +3145,9 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses, out:if (tcon && !tcon->ipc) {/* ipc tcons are not refcounted */ -spin_lock (&cifs_tcp_ses_lock); - tcon->tc_count--; +cifs_put_tcon (tcon, netfs_trace_tcon_ref_put_dfs_refer);trace_smb3_tcon_ref (tcon->debug_id, tcon->tc_count, netfs_trace_tcon_ref_dec_dfs_refer); -/* tc_count can never go negative */ -WARN_ON (tcon->tc_count <0 ); -spin_unlock (&cifs_tcp_ses_lock); }kfree (utf16_path);kfree (dfs_req);
fs/smb/client/smb2pdu.c +2 -0
@@ -4174,7 +4174,9 @@ void smb2_reconnect_server(struct work_struct *work)list_for_each_entry (tcon, &ses->tcon_list, tcon_list) {if (tcon->need_reconnect || tcon->need_reopen_files) { +spin_lock (&tcon->tc_lock); tcon->tc_count++; +spin_unlock (&tcon->tc_lock);trace_smb3_tcon_ref (tcon->debug_id, tcon->tc_count, netfs_trace_tcon_ref_get_reconnect_server);list_add_tail (&tcon->rlist, &tmp_list);
fs/smb/client/trace.h +1 -0
@@ -59,6 +59,7 @@ EM(netfs_trace_tcon_ref_put_cancelled_close_fid, "PUT Cn-Fid") \ EM(netfs_trace_tcon_ref_put_cancelled_mid, "PUT Cn-Mid") \ EM(netfs_trace_tcon_ref_put_mnt_ctx, "PUT MntCtx") \ + EM(netfs_trace_tcon_ref_put_dfs_refer, "PUT DfsRfr") \ EM(netfs_trace_tcon_ref_put_reconnect_server, "PUT Reconn") \ EM(netfs_trace_tcon_ref_put_tlink, "PUT Tlink ") \EM (netfs_trace_tcon_ref_see_cancelled_close,"SEE Cn-Cls" ) \
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 682/752 MIPS: rb532: Fix MMIO UART resource registration
In reply to Sasha LevinFrom: Jiaxun Yang <[email protected]>
[ Upstream commit e93bb4b76cfefb302534246e892c7667491cb8cc ]
Since commit 6e690d54cfa8 ("serial: 8250: fix return error code in serial8250_request_std_resource()"), registering an 8250 MMIO port without mapbase no longer works, as the resource range is derived from mapbase/mapsize.
Populate mapbase and mapsize accordingly. Also drop ugly membase KSEG1 pointer and set UPF_IOREMAP instead, letting the 8250 core perform the ioremap.
--- arch/mips/rb532/devices.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/mips/rb532/devices.c +3 -2
@@ -212,11 +212,12 @@ static struct platform_device rb532_wdt = {static struct plat_serial8250_port rb532_uart_res[] = { { .type =PORT_16550A , - .membase = (char *)KSEG1ADDR (REGBASE +UART0BASE ), + .mapbase =REGBASE +UART0BASE , + .mapsize =0x1000 , .irq =UART0_IRQ , .regshift =2 , .iotype =UPIO_MEM , - .flags =UPF_BOOT_AUTOCONF , + .flags =UPF_BOOT_AUTOCONF |UPF_IOREMAP , }, { .flags =0 ,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 683/752 ceph: supply snapshot context in ceph_zero_partial_object()
In reply to Sasha LevinFrom: ethanwu <[email protected]>
[ Upstream commit f16bd3fa74a2084ee7e16a8a2be7e7399b970907 ]
The ceph_zero_partial_object function was missing proper snapshot context for its OSD write operations, which could lead to data inconsistencies in snapshots.
Reproducer:../src/vstart.sh --new -x --localhost --bluestore
./bin/ceph auth caps client.fs_a mds 'allow rwps fsname=a' mon 'allow r fsname=a' osd 'allow rw tag cephfs data=a' mount -t ceph [email protected]=/ /mnt/mycephfs/ -o conf=./ceph.conf
dd if=/dev/urandom of=/mnt/mycephfs/foo bs=64K count=1
mkdir /mnt/mycephfs/.snap/snap1
md5sum /mnt/mycephfs/.snap/snap1/foo
fallocate -p -o 0 -l 4096 /mnt/mycephfs/foo
echo 3 > /proc/sys/vm/drop/caches
md5sum /mnt/mycephfs/.snap/snap1/foo # get different md5sum!!
--- fs/ceph/file.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
fs/ceph/file.c +16 -1
@@ -2568,6 +2568,7 @@ static int ceph_zero_partial_object(struct inode *inode,struct ceph_inode_info *ci =ceph_inode (inode);struct ceph_fs_client *fsc =ceph_inode_to_fs_client (inode);struct ceph_osd_request *req; +struct ceph_snap_context *snapc;int ret =0 ;loff_t zero =0 ;int op;
@@ -2582,12 +2583,25 @@ static int ceph_zero_partial_object(struct inode *inode, op =CEPH_OSD_OP_ZERO ; } +spin_lock (&ci->i_ceph_lock); +if (__ceph_have_pending_cap_snap (ci)) { +struct ceph_cap_snap *capsnap = +list_last_entry (&ci->i_cap_snaps, + struct ceph_cap_snap, + ci_item); + snapc =ceph_get_snap_context (capsnap->context); + }else { +BUG_ON (!ci->i_head_snapc); + snapc =ceph_get_snap_context (ci->i_head_snapc); + } +spin_unlock (&ci->i_ceph_lock); + req =ceph_osdc_new_request (&fsc->client->osdc, &ci->i_layout,ceph_vino (inode), offset, length,0 ,1 , op,CEPH_OSD_FLAG_WRITE , -NULL ,0 ,0 , false); + snapc,0 ,0 , false);if (IS_ERR (req)) { ret =PTR_ERR (req); goto out;
@@ -2601,6 +2615,7 @@ static int ceph_zero_partial_object(struct inode *inode,ceph_osdc_put_request (req); out: +ceph_put_snap_context (snapc);return ret; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 684/752 drm/i915/quirks: Fix device id for QUIRK_EDP_LIMIT_RATE_HBR2 entry
In reply to Sasha LevinFrom: Ankit Nautiyal <[email protected]>
[ Upstream commit 510e7261a7bcd6232e90f0b6b9f93303bdd29f8a ]
Update the device ID for Dell XPS 13 7390 2-in-1 in the quirk QUIRK_EDP_LIMIT_RATE_HBR2 entry. The previous ID (0x8a12) was incorrect; the correct ID is 0x8a52.
--- drivers/gpu/drm/i915/display/intel_quirks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/display/intel_quirks.c +1 -1
@@ -239,7 +239,7 @@ static struct intel_quirk intel_quirks[] = { { 0x0f31, 0x103c, 0x220f, quirk_invert_brightness },/* Dell XPS 13 7390 2-in-1 */ - { 0x8a12, 0x1028, 0x08b0, quirk_edp_limit_rate_hbr2 }, + { 0x8a52, 0x1028, 0x08b0, quirk_edp_limit_rate_hbr2 }, }; static const struct intel_dpcd_quirk intel_dpcd_quirks[] = {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 685/752 rust: kbuild: pass `-Zunstable-options` for Rust 1.95.0
In reply to Sasha LevinFrom: Miguel Ojeda <[email protected]>
[ Upstream commit 0a9be83e57de0d0ca8ca4ec610bc344f17a8e5e7 ]
Custom target specifications are unstable, but starting with Rust 1.95.0, rustc requires to explicitly pass -Zunstable-options to use them [1]:
error: error loading target specification: custom targets are unstable and require `-Zunstable-options`
|
= help: run `rustc --print target-list` for a list of built-in targetsDavid (Rust compiler team lead), writes:
"We're destabilising custom targets to allow us to move forward with
build-std without accidentally exposing functionality that we'd like to revisit prior to committing to. I'll start a thread on Zulip to discuss with the RfL team how we can come up with an alternative for them."
Thus pass it.
--- rust/Makefile | 3 +++ 1 file changed, 3 insertions(+)
rust/Makefile +3 -0
@@ -437,6 +437,8 @@ $(obj)/$(libpin_init_internal_name): private rustc_target_flags = --cfg kernel $(obj)/$(libpin_init_internal_name): $(src)/pin-init/internal/src/lib.rs FORCE +$(call if_changed_dep,rustc_procmacro) +# `rustc` requires `-Zunstable-options` to use custom target specifications +# since Rust 1.95.0 (https://github.com/rust-lang/rust/pull/151534). quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L $@ cmd_rustc_library = \ OBJTREE=$(abspath $(objtree)) \
@@ -447,6 +449,7 @@ quiet_cmd_rustc_library = $(if $(skip_clippy),RUSTC,$(RUSTC_OR_CLIPPY_QUIET)) L --crate-type rlib -L$(objtree)/$(obj) \ --crate-name $(patsubst %.o,%,$(notdir $@)) $< \ --sysroot=/dev/null \ + -Zunstable-options \ $(if $(rustc_objcopy),;$(OBJCOPY) $(rustc_objcopy) $@) \ $(cmd_objtool)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 686/752 mm/slab: do not access current->mems_allowed_seq if !allow_spin
In reply to Sasha LevinFrom: Harry Yoo <[email protected]>
[ Upstream commit 144080a5823b2dbd635acb6decf7ab23182664f3 ]
Lockdep complains when get_from_any_partial() is called in an NMI context, because current->mems_allowed_seq is seqcount_spinlock_t and not NMI-safe:
================================
WARNING: inconsistent lock state
6.19.0-rc5-kfree-rcu+ #315 Tainted: G N
--------------------------------
inconsistent {INITIAL USE} -> {IN-NMI} usage.
kunit_try_catch/9989 [HC1[1]:SC0[0]:HE0:SE1] takes:
ffff889085799820 (&____s->seqcount#3){.-.-}-{0:0}, at: ___slab_alloc+0x58f/0xc00 {INITIAL USE} state was registered at:
lock_acquire+0x185/0x320
kernel_init_freeable+0x391/0x1150
kernel_init+0x1f/0x220
ret_from_fork+0x736/0x8f0
ret_from_fork_asm+0x1a/0x30
irq event stamp: 56
hardirqs last enabled at (55): [<ffffffff850a68d7>] _raw_spin_unlock_irq+0x27/0x70
hardirqs last disabled at (56): [<ffffffff850858ca>] __schedule+0x2a8a/0x6630
softirqs last enabled at (0): [<ffffffff81536711>] copy_process+0x1dc1/0x6a10
softirqs last disabled at (0): [<0000000000000000>] 0x0other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&____s->seqcount#3);
<Interrupt>
lock(&____s->seqcount#3);*** DEADLOCK ***
According to Documentation/locking/seqlock.rst, seqcount_t is not NMI-safe and seqcount_latch_t should be used when read path can interrupt the write-side critical section. In this case, do not access current->mems_allowed_seq and avoid retry.
--- mm/slub.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
mm/slub.c +11 -2
@@ -3594,6 +3594,7 @@ static struct slab *get_any_partial(struct kmem_cache *s,enum zone_type highest_zoneidx =gfp_zone (pc->flags);struct slab *slab;unsigned int cpuset_mems_cookie; +bool allow_spin =gfpflags_allow_spinning (pc->flags);/* * The defrag ratio allows a configuration of the tradeoffs between
@@ -3618,7 +3619,15 @@ static struct slab *get_any_partial(struct kmem_cache *s,return NULL ; do { - cpuset_mems_cookie = read_mems_allowed_begin(); + /* + * read_mems_allowed_begin() accesses current->mems_allowed_seq, + * a seqcount_spinlock_t that is not NMI-safe. Do not access + * current->mems_allowed_seq and avoid retry when GFP flags + * indicate spinning is not allowed. + */ + if (allow_spin) + cpuset_mems_cookie = read_mems_allowed_begin(); + zonelist = node_zonelist(mempolicy_slab_node(), pc->flags); for_each_zone_zonelist(zone, z, zonelist, highest_zoneidx) { struct kmem_cache_node *n;
@@ -3640,7 +3649,7 @@ static struct slab *get_any_partial(struct kmem_cache *s, } } } - }while (read_mems_allowed_retry (cpuset_mems_cookie)); + }while (allow_spin &&read_mems_allowed_retry (cpuset_mems_cookie));#endif /* CONFIG_NUMA */ return NULL ; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 687/752 LoongArch: Make cpumask_of_node() robust against NUMA_NO_NODE
In reply to Sasha LevinFrom: John Garry <[email protected]>
[ Upstream commit 94b0c831eda778ae9e4f2164a8b3de485d8977bb ]
The arch definition of cpumask_of_node() cannot handle NUMA_NO_NODE - which is a valid index - so add a check for this.
--- arch/loongarch/include/asm/topology.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/include/asm/topology.h +1 -1
@@ -12,7 +12,7 @@extern cpumask_t cpus_on_node[]; -#define cpumask_of_node (node) (&cpus_on_node[node]) +#define cpumask_of_node (node) ((node) == NUMA_NO_NODE ? cpu_all_mask : &cpus_on_node[node])struct pci_bus ;extern int pcibus_to_node (struct pci_bus *);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 688/752 LoongArch: Prefer top-down allocation after arch_mem_init()
In reply to Sasha LevinFrom: Huacai Chen <[email protected]>
[ Upstream commit 2172d6ebac9372eb01fe4505a53e18cb061e103b ]
Currently we use bottom-up allocation after sparse_init(), the reason is sparse_init() need a lot of memory, and bottom-up allocation may exhaust precious low memory (below 4GB). On the other hand, SWIOTLB and CMA need low memories for DMA32, so swiotlb_init() and dma_contiguous_reserve() need bottom-up allocation.
Since swiotlb_init() and dma_contiguous_reserve() are both called in arch_mem_init(), we no longer need bottom-up allocation after that. So we set the allocation policy to top-down at the end of arch_mem_init(), in order to avoid later memory allocations (such as KASAN) exhaust low memory.
This solve at least two problems:
1. Some buggy BIOSes use 0xfd000000~0xfe000000 for secondary CPUs, but didn't reserve this range, which causes smpboot failures.
2. Some DMA32 devices, such as Loongson-DRM and OHCI, cannot work with KASAN enabled.
--- arch/loongarch/kernel/setup.c | 1 + 1 file changed, 1 insertion(+)
arch/loongarch/kernel/setup.c +1 -0
@@ -421,6 +421,7 @@ static void __init arch_mem_init(char **cmdline_p) PFN_UP(__pa_symbol(&__nosave_end)));memblock_dump_all (); +memblock_set_bottom_up (false);early_memtest (PFN_PHYS (ARCH_PFN_OFFSET ),PFN_PHYS (max_low_pfn)); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 689/752 LoongArch: Use %px to print unmodified unwinding address
In reply to Sasha LevinFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 77403a06d845db1caf9a6b0867b43e9dd8de8e4a ]
Currently, use %p to prevent leaking information about the kernel memory layout when printing the PC address, but the kernel log messages are not useful to debug problem if bt_address() returns 0. Given that the type of "pc" variable is unsigned long, it should use %px to print the unmodified unwinding address.
--- arch/loongarch/kernel/unwind_orc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/unwind_orc.c +1 -1
@@ -508,7 +508,7 @@ bool unwind_next_frame(struct unwind_state *state) state->pc =bt_address (pc);if (!state->pc) { -pr_err ("cannot find unwind pc at %p\n" , (void *)pc); +pr_err ("cannot find unwind pc at %px\n" , (void *)pc); goto err; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 690/752 LoongArch: Guard percpu handler under !CONFIG_PREEMPT_RT
In reply to Sasha LevinFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 70b0faae3590c628a98a627a10e5d211310169d4 ]
After commit 88fd2b70120d ("LoongArch: Fix sleeping in atomic context for PREEMPT_RT"), it should guard percpu handler under !CONFIG_PREEMPT_RT to avoid redundant operations.
--- arch/loongarch/kernel/unwind_prologue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/kernel/unwind_prologue.c +1 -1
@@ -65,7 +65,7 @@ static inline bool scan_handlers(unsigned long entry_offset)static inline bool fix_exception (unsigned long pc) { -#ifdef CONFIG_NUMA +#if defined(CONFIG_NUMA ) && !defined(CONFIG_PREEMPT_RT )int cpu;for_each_possible_cpu (cpu) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 691/752 LoongArch: Disable instrumentation for setup_ptwalker()
In reply to Sasha LevinFrom: Tiezhu Yang <[email protected]>
[ Upstream commit 7cb37af61f09c9cfd90c43c9275307c16320cbf2 ]
According to Documentation/dev-tools/kasan.rst, software KASAN modes use compiler instrumentation to insert validity checks. Such instrumentation might be incompatible with some parts of the kernel, and therefore needs to be disabled, just use the attribute __no_sanitize_address to disable instrumentation for the low level function setup_ptwalker().
Otherwise bringing up the secondary CPUs failed when CONFIG_KASAN is set (especially when PTW is enabled), here are the call chains:
smpboot_entry()
start_secondary()
cpu_probe()
per_cpu_trap_init()
tlb_init()
setup_tlb_handler()
setup_ptwalker()The reason is the PGD registers are configured in setup_ptwalker(), but KASAN instrumentation may cause TLB exceptions before that.
--- arch/loongarch/mm/tlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/loongarch/mm/tlb.c +1 -1
@@ -202,7 +202,7 @@ void __update_tlb(struct vm_area_struct *vma, unsigned long address, pte_t *pteplocal_irq_restore (flags); } -static void setup_ptwalker (void ) +static void __no_sanitize_address setup_ptwalker(void) {unsigned long pwctl0, pwctl1;unsigned long pgd_i =0 , pgd_w =0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 692/752 net: ethernet: marvell: skge: remove incorrect conflicting PCI ID
In reply to Sasha LevinFrom: Ethan Nelson-Moore <[email protected]>
[ Upstream commit d01103fdcb871fd83fd06ef5803d576507c6a801 ]
The ID 1186:4302 is matched by both r8169 and skge. The same device ID should not be in more than one driver, because in that case, which driver is used is unpredictable. I downloaded the latest drivers for all hardware revisions of the D-Link DGE-530T from D-Link's website, and the only drivers which contain this ID are Realtek drivers. Therefore, remove this device ID from skge.
In the kernel bug report which requested addition of this device ID, someone created a patch to add the ID to skge. Then, it was pointed out that this device is an "r8169 in disguise", and a patch was created to add it to r8169. Somehow, both of these patches got merged. See the link below.
--- drivers/net/ethernet/marvell/skge.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/marvell/skge.c +0 -1
@@ -78,7 +78,6 @@ static const struct pci_device_id skge_id_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x4320) }, /* SK-98xx V2.0 */ { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b01) }, /* D-Link DGE-530T (rev.B) */ { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4c00) }, /* D-Link DGE-530T */ - { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4302) }, /* D-Link DGE-530T Rev C1 */ { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4320) }, /* Marvell Yukon 88E8001/8003/8010 */ { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x5005) }, /* Belkin */ { PCI_DEVICE(PCI_VENDOR_ID_CNET, 0x434E) }, /* CNet PowerG-2000 */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 693/752 net: wan/fsl_ucc_hdlc: Fix dma_free_coherent() in uhdlc_memclean()
In reply to Sasha LevinFrom: Thomas Fourier <[email protected]>
[ Upstream commit 36bd7d5deef936c4e1e3cd341598140e5c14c1d3 ]
The priv->rx_buffer and priv->tx_buffer are alloc'd together as contiguous buffers in uhdlc_init() but freed as two buffers in uhdlc_memclean().
Change the cleanup to only call dma_free_coherent() once on the whole buffer.
--- drivers/net/wan/fsl_ucc_hdlc.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/net/wan/fsl_ucc_hdlc.c +2 -6
@@ -790,18 +790,14 @@ static void uhdlc_memclean(struct ucc_hdlc_private *priv)if (priv->rx_buffer) {dma_free_coherent (priv->dev, -RX_BD_RING_LEN *MAX_RX_BUF_LENGTH , + (RX_BD_RING_LEN +TX_BD_RING_LEN ) *MAX_RX_BUF_LENGTH , priv->rx_buffer, priv->dma_rx_addr); priv->rx_buffer =NULL ; priv->dma_rx_addr =0 ; - } -if (priv->tx_buffer) { -dma_free_coherent (priv->dev, -TX_BD_RING_LEN *MAX_RX_BUF_LENGTH , - priv->tx_buffer, priv->dma_tx_addr); priv->tx_buffer =NULL ; priv->dma_tx_addr =0 ; + } }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 694/752 octeontx2-af: CGX: fix bitmap leaks
In reply to Sasha LevinFrom: Bo Sun <[email protected]>
[ Upstream commit 3def995c4ede842adf509c410e92d09a0cedc965 ]
The RX/TX flow-control bitmaps (rx_fc_pfvf_bmap and tx_fc_pfvf_bmap) are allocated by cgx_lmac_init() but never freed in cgx_lmac_exit(). Unbinding and rebinding the driver therefore triggers kmemleak:
unreferenced object (size 16):
backtrace:
rvu_alloc_bitmap
cgx_probe
Free both bitmaps during teardown.
--- drivers/net/ethernet/marvell/octeontx2/af/cgx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cgx.c +2 -0
@@ -1823,6 +1823,8 @@ static int cgx_lmac_exit(struct cgx *cgx) cgx->mac_ops->mac_pause_frm_config (cgx, lmac->lmac_id, false);cgx_configure_interrupt (cgx, lmac, lmac->lmac_id, true);kfree (lmac->mac_to_index_bmap.bmap); +rvu_free_bitmap (&lmac->rx_fc_pfvf_bmap); +rvu_free_bitmap (&lmac->tx_fc_pfvf_bmap);kfree (lmac->name);kfree (lmac); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 695/752 net: ti: icssg-prueth: Add optional dependency on HSR
In reply to Sasha LevinFrom: Kevin Hao <[email protected]>
[ Upstream commit e3998b6e90f875f19bf758053d79ccfd41880173 ]
Commit 95540ad6747c ("net: ti: icssg-prueth: Add support for HSR frame forward offload") introduced support for offloading HSR frame forwarding, which relies on functions such as is_hsr_master() provided by the HSR module. Although HSR provides stubs for configurations with HSR disabled, this driver still requires an optional dependency on HSR. Otherwise, build failures will occur when icssg-prueth is built-in while HSR is configured as a module.
ld.lld: error: undefined symbol: is_hsr_master
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
referenced by icssg_prueth.c:710 (
drivers/net/ethernet/ti/icssg/icssg_prueth.c:710)
drivers/net/ethernet/ti/icssg/icssg_prueth.o:(icssg_prueth_hsr_del_mcast) in archive vmlinux.a
referenced by icssg_prueth.c:681 (drivers/net/ethernet/ti/icssg/icssg_prueth.c:681)
drivers/net/ethernet/ti/icssg/icssg_prueth.o:(icssg_prueth_hsr_add_mcast) in archive vmlinux.a
referenced by icssg_prueth.c:1812 (drivers/net/ethernet/ti/icssg/icssg_prueth.c:1812)
drivers/net/ethernet/ti/icssg/icssg_prueth.o:(prueth_netdevice_event) in archive vmlinux.a
ld.lld: error: undefined symbol: hsr_get_port_ndev
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
referenced by icssg_prueth.c:712 (
drivers/net/ethernet/ti/icssg/icssg_prueth.c:712)
drivers/net/ethernet/ti/icssg/icssg_prueth.o:(icssg_prueth_hsr_del_mcast) in archive vmlinux.a
referenced by icssg_prueth.c:712 (drivers/net/ethernet/ti/icssg/icssg_prueth.c:712)
drivers/net/etherneteth_hsr_del_mcast) in archive vmlinux.a
referenced by icssg_prueth.c:683 (drivers/net/ethernet/ti/icssg/icssg_prueth.c:683)
drivers/net/ethernet/ti/icssg/icssg_prueth.o:(icssg_prueth_hsr_add_mcast) in archive vmlinux.a
referenced 1 more times
--- drivers/net/ethernet/ti/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/ti/Kconfig +1 -0
@@ -192,6 +192,7 @@ config TI_ICSSG_PRUETH depends on NET_SWITCHDEV depends on ARCH_K3 && OF && TI_K3_UDMA_GLUE_LAYER depends on PTP_1588_CLOCK_OPTIONAL + depends on HSR || !HSR help Support dual Gigabit Ethernet ports over the ICSSG PRU Subsystem. This subsystem is available starting with the AM65 platform.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 696/752 net: macb: Fix tx/rx malfunction after phy link down and up
In reply to Sasha LevinFrom: Kevin Hao <[email protected]>
[ Upstream commit bf9cf80cab81e39701861a42877a28295ade266f ]
In commit 99537d5c476c ("net: macb: Relocate mog_init_rings() callback from macb_mac_link_up() to macb_open()"), the mog_init_rings() callback was moved from macb_mac_link_up() to macb_open() to resolve a deadlock issue. However, this change introduced a tx/rx malfunction following phy link down and up events. The issue arises from a mismatch between the software queue->tx_head, queue->tx_tail, queue->rx_prepared_head, and queue->rx_tail values and the hardware's internal tx/rx queue pointers.
According to the Zynq UltraScale TRM [1], when tx/rx is disabled, the internal tx queue pointer resets to the value in the tx queue base address register, while the internal rx queue pointer remains unchanged. The following is quoted from the Zynq UltraScale TRM:
When transmit is disabled, with bit [3] of the network control register set low, the transmit-buffer queue pointer resets to point to the address indicated by the transmit-buffer queue base address register. Disabling receive does not have the same effect on the receive-buffer queue pointer.
Additionally, there is no need to reset the RBQP and TBQP registers in a phy event callback. Therefore, move macb_init_buffers() to macb_open(). In a phy link up event, the only required action is to reset the tx software head and tail pointers to align with the hardware's behavior.
[1] https://docs.amd.com/v/u/en-US/ug1085-zynq-ultrascale-trm
--- drivers/net/ethernet/cadence/macb_main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +5 -6
@@ -741,14 +741,12 @@ static void macb_mac_link_up(struct phylink_config *config,if (rx_pause) ctrl |=MACB_BIT (PAE ); -/* Initialize rings & buffers as clearing MACB_BIT(TE) in link down -* cleared the pipeline and control registers. -*/ -macb_init_buffers (bp); - -for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) +for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) { + queue->tx_head =0 ; + queue->tx_tail =0 ;queue_writel (queue,IER , bp->rx_intr_mask |MACB_TX_INT_FLAGS |MACB_BIT (HRESP )); + } }macb_or_gem_writel (bp,NCFGR , ctrl);
@@ -2991,6 +2989,7 @@ static int macb_open(struct net_device *dev) } bp->macbgem_ops.mog_init_rings (bp); +macb_init_buffers (bp);for (q =0 , queue = bp->queues; q < bp->num_queues; ++q, ++queue) {napi_enable (&queue->napi_rx);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 697/752 tracing: Fix to set write permission to per-cpu buffer_size_kb
In reply to Sasha LevinFrom: "Masami Hiramatsu (Google)" <[email protected]>
[ Upstream commit f844282deed7481cf2f813933229261e27306551 ]
Since the per-cpu buffer_size_kb file is writable for changing per-cpu ring buffer size, the file should have the write access permission.
--- kernel/trace/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace.c +1 -1
@@ -9183,7 +9183,7 @@ tracing_init_tracefs_percpu(struct trace_array *tr, long cpu)trace_create_cpu_file ("stats" ,TRACE_MODE_READ , d_cpu, tr, cpu, &tracing_stats_fops); -trace_create_cpu_file ("buffer_size_kb" ,TRACE_MODE_READ , d_cpu, +trace_create_cpu_file ("buffer_size_kb" ,TRACE_MODE_WRITE , d_cpu, tr, cpu, &tracing_entries_fops);if (tr->range_addr_start)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 698/752 tracing: Reset last_boot_info if ring buffer is reset
In reply to Sasha LevinFrom: "Masami Hiramatsu (Google)" <[email protected]>
[ Upstream commit 804c4a2209bcf6ed4c45386f033e4d0f7c5bfda5 ]
Commit 32dc0042528d ("tracing: Reset last-boot buffers when reading out all cpu buffers") resets the last_boot_info when user read out all data via trace_pipe* files. But it is not reset when user resets the buffer from other files. (e.g. write trace file)
Reset it when the corresponding ring buffer is reset too.
--- kernel/trace/trace.c | 6 ++++++ 1 file changed, 6 insertions(+)
kernel/trace/trace.c +6 -0
@@ -4852,6 +4852,8 @@ static int tracing_single_release_tr(struct inode *inode, struct file *file)return single_release (inode, file); } +static bool update_last_data_if_empty (struct trace_array *tr); +static int tracing_open (struct inode *inode,struct file *file) {struct trace_array *tr = inode->i_private;
@@ -4876,6 +4878,8 @@ static int tracing_open(struct inode *inode, struct file *file)tracing_reset_online_cpus (trace_buf); elsetracing_reset_cpu (trace_buf ,cpu ); + +update_last_data_if_empty (tr); }if (file->f_mode &FMODE_READ ) {
@@ -5917,6 +5921,7 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,int tracer_init (struct tracer *t,struct trace_array *tr) {tracing_reset_online_cpus (&tr->array_buffer); +update_last_data_if_empty (tr);return t->init (tr); }
@@ -7582,6 +7587,7 @@ int tracing_set_clock(struct trace_array *tr, const char *clockstr)ring_buffer_set_clock (tr->max_buffer.buffer, trace_clocks[i].func);tracing_reset_online_cpus (&tr->max_buffer);#endif +update_last_data_if_empty (tr);if (tr->scratch && !(tr->flags &TRACE_ARRAY_FL_LAST_BOOT )) {struct trace_scratch *tscratch = tr->scratch;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 699/752 ceph: do not propagate page array emplacement errors as batch errors
In reply to Sasha LevinFrom: Sam Edwards <[email protected]>
[ Upstream commit 707104682e3c163f7c14cdd6b07a3e95fb374759 ]
When fscrypt is enabled, move_dirty_folio_in_page_array() may fail because it needs to allocate bounce buffers to store the encrypted versions of each folio. Each folio beyond the first allocates its bounce buffer with GFP_NOWAIT. Failures are common (and expected) under this allocation mode; they should flush (not abort) the batch.
However, ceph_process_folio_batch() uses the same rc variable for its own return code and for capturing the return codes of its routine calls; failing to reset rc back to 0 results in the error being propagated out to the main writeback loop, which cannot actually tolerate any errors here: once ceph_wbc.pages is allocated, it must be passed to ceph_submit_write() to be freed. If it survives until the next iteration (e.g. due to the goto being followed), ceph_allocate_page_array()'s BUG_ON() will oops the worker.
Note that this failure mode is currently masked due to another bug (addressed next in this series) that prevents multiple encrypted folios from being selected for the same write.
For now, just reset rc when redirtying the folio to prevent errors in move_dirty_folio_in_page_array() from propagating. Note that move_dirty_folio_in_page_array() is careful never to return errors on the first folio, so there is no need to check for that. After this change, ceph_process_folio_batch() no longer returns errors; its only remaining failure indicator is locked_pages == 0, which the caller already handles correctly.
--- fs/ceph/addr.c | 1 + 1 file changed, 1 insertion(+)
fs/ceph/addr.c +1 -0
@@ -1373,6 +1373,7 @@ int ceph_process_folio_batch(struct address_space *mapping, rc =move_dirty_folio_in_page_array (mapping, wbc, ceph_wbc, folio);if (rc) { + rc =0 ;folio_redirty_for_writepage (wbc, folio);folio_unlock (folio);break ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 700/752 ceph: fix write storm on fscrypted files
In reply to Sasha LevinFrom: Sam Edwards <[email protected]>
[ Upstream commit cac190c7674fea71620d754ffcdaaeed7c551dbc ]
CephFS stores file data across multiple RADOS objects. An object is the atomic unit of storage, so the writeback code must clean only folios that belong to the same object with each OSD request.
CephFS also supports RAID0-style striping of file contents: if enabled, each object stores multiple unbroken "stripe units" covering different portions of the file; if disabled, a "stripe unit" is simply the whole object. The stripe unit is (usually) reported as the inode's block size.
Though the writeback logic could, in principle, lock all dirty folios belonging to the same object, its current design is to lock only a single stripe unit at a time. Ever since this code was first written, it has determined this size by checking the inode's block size. However, the relatively-new fscrypt support needed to reduce the block size for encrypted inodes to the crypto block size (see 'fixes' commit), which causes an unnecessarily high number of write operations (~1024x as many, with 4MiB objects) and correspondingly degraded performance.
Fix this (and clarify intent) by using i_layout.stripe_unit directly in ceph_define_write_size() so that encrypted inodes are written back with the same number of operations as if they were unencrypted.
This patch depends on the preceding commit ("ceph: do not propagate page array emplacement errors as batch errors") for correctness. While it applies cleanly on its own, applying it alone will introduce a regression. This dependency is only relevant for kernels where ce80b76dd327 ("ceph: introduce ceph_process_folio_batch() method") has been applied; stable kernels without that commit are unaffected.
--- fs/ceph/addr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ceph/addr.c +2 -1
@@ -1000,7 +1000,8 @@ unsigned int ceph_define_write_size(struct address_space *mapping) {struct inode *inode = mapping->host;struct ceph_fs_client *fsc =ceph_inode_to_fs_client (inode); -unsigned int wsize =i_blocksize (inode); +struct ceph_inode_info *ci =ceph_inode (inode); +unsigned int wsize = ci->i_layout.stripe_unit;if (fsc->mount_options->wsize < wsize) wsize = fsc->mount_options->wsize;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 701/752 io_uring/filetable: clamp alloc_hint to the configured alloc range
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit a6bded921ed35f21b3f6bd8e629bf488499ca442 ]
Explicit fixed file install/remove operations on slots outside the configured alloc range can corrupt alloc_hint via io_file_bitmap_set() and io_file_bitmap_clear(), which unconditionally update alloc_hint to the bit position. This causes subsequent auto-allocations to fall outside the configured range.
For example, if the alloc range is [10, 20) and a file is removed at slot 2, alloc_hint gets set to 2. The next auto-alloc then starts searching from slot 2, potentially returning a slot below the range.
Fix this by clamping alloc_hint to [file_alloc_start, file_alloc_end) at the top of io_file_bitmap_get() before starting the search.
--- io_uring/filetable.c | 4 ++++ 1 file changed, 4 insertions(+)
io_uring/filetable.c +4 -0
@@ -22,6 +22,10 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)if (!table->bitmap)return -ENFILE ; +if (table->alloc_hint < ctx->file_alloc_start || + table->alloc_hint >= ctx->file_alloc_end) + table->alloc_hint = ctx->file_alloc_start; + do { ret = find_next_zero_bit(table->bitmap, nr, table->alloc_hint); if (ret != nr)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 702/752 io_uring/openclose: fix io_pipe_fixed() slot tracking for specific slots
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit f4d0668b38d8784f33a9a36c72ed5d0078247538 ]
__io_fixed_fd_install() returns 0 on success for non-alloc mode (specific slot), not the slot index. io_pipe_fixed() used this return value directly as the slot index in fds[], which can cause the reported values returned via copy_to_user() to be incorrect, or the error path operating on the incorrect direct descriptor.
Fix by computing the actual 0-based slot index (slot - 1) for specific slot mode, while preserving the existing behavior for auto-alloc mode where __io_fixed_fd_install() already returns the allocated index.
--- io_uring/openclose.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
io_uring/openclose.c +6 -3
@@ -336,31 +336,34 @@ static int io_pipe_fixed(struct io_kiocb *req, struct file **files, { struct io_pipe *p = io_kiocb_to_cmd(req, struct io_pipe);struct io_ring_ctx *ctx = req->ctx; +bool alloc_slot;int ret, fds[2 ] = {-1 ,-1 };int slot = p->file_slot;if (p->flags &O_CLOEXEC )return -EINVAL ; + alloc_slot = slot ==IORING_FILE_INDEX_ALLOC ; +io_ring_submit_lock (ctx, issue_flags); ret =__io_fixed_fd_install (ctx, files[0 ], slot);if (ret <0 ) goto err; - fds[0 ] = ret; + fds[0 ] = alloc_slot ? ret : slot -1 ; files[0 ] =NULL ;/* * If a specific slot is given, next one will be used for * the write side. */ -if (slot !=IORING_FILE_INDEX_ALLOC ) +if (!alloc_slot) slot++; ret =__io_fixed_fd_install (ctx, files[1 ], slot);if (ret <0 ) goto err; - fds[1 ] = ret; + fds[1 ] = alloc_slot ? ret : slot -1 ; files[1 ] =NULL ;io_ring_submit_unlock (ctx, issue_flags);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 703/752 drm/amd/display: Increase DCN35 SR enter/exit latency
In reply to Sasha LevinFrom: Leo Li <[email protected]>
[ Upstream commit 318917e1d8ecc89f820f4fabf79935f4fed718cd ]
[Why & How]
On Framework laptops with DDR5 modules, underflow can be observed. It's unclear why it only occurs on specific desktop contents. However, increasing enter/exit latencies by 3us seems to resolve it.
--- .../amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c | 16 ++++++++-------- .../gpu/drm/amd/display/dc/dml/dcn35/dcn35_fpu.c | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn35/dcn35_clk_mgr.c +8 -8
@@ -768,32 +768,32 @@ static struct wm_table ddr5_wm_table = { .wm_inst = WM_A, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.72, - .sr_exit_time_us = 28.0, - .sr_enter_plus_exit_time_us = 30.0, + .sr_exit_time_us = 31.0, + .sr_enter_plus_exit_time_us = 33.0, .valid = true, }, { .wm_inst = WM_B, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.72, - .sr_exit_time_us = 28.0, - .sr_enter_plus_exit_time_us = 30.0, + .sr_exit_time_us = 31.0, + .sr_enter_plus_exit_time_us = 33.0, .valid = true, }, { .wm_inst = WM_C, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.72, - .sr_exit_time_us = 28.0, - .sr_enter_plus_exit_time_us = 30.0, + .sr_exit_time_us = 31.0, + .sr_enter_plus_exit_time_us = 33.0, .valid = true, }, { .wm_inst = WM_D, .wm_type = WM_TYPE_PSTATE_CHG, .pstate_latency_us = 11.72, - .sr_exit_time_us = 28.0, - .sr_enter_plus_exit_time_us = 30.0, + .sr_exit_time_us = 31.0, + .sr_enter_plus_exit_time_us = 33.0, .valid = true, }, }
drivers/gpu/drm/amd/display/dc/dml/dcn35/dcn35_fpu.c +2 -2
@@ -164,8 +164,8 @@ struct _vcs_dpi_soc_bounding_box_st dcn3_5_soc = { }, }, .num_states = 5, - .sr_exit_time_us = 28.0, - .sr_enter_plus_exit_time_us = 30.0, + .sr_exit_time_us = 31.0, + .sr_enter_plus_exit_time_us = 33.0, .sr_exit_z8_time_us = 250.0, .sr_enter_plus_exit_z8_time_us = 350.0, .fclk_change_latency_us = 24.0,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 704/752 drm/amdgpu: fix sync handling in amdgpu_dma_buf_move_notify
In reply to Sasha LevinFrom: Pierre-Eric Pelloux-Prayer <[email protected]>
[ Upstream commit b18fc0ab837381c1a6ef28386602cd888f2d9edf ]
Invalidating a dmabuf will impact other users of the shared BO. In the scenario where process A moves the BO, it needs to inform process B about the move and process B will need to update its page table.
The commit fixes a synchronisation bug caused by the use of the
ticket: it made amdgpu_vm_handle_moved behave as if updating the page table immediately was correct but in this case it's not.
An example is the following scenario, with 2 GPUs and glxgears running on GPU0 and Xorg running on GPU1, on a system where P2P PCI isn't supported:
glxgears:
export linear buffer from GPU0 and import using GPU1 submit frame rendering to GPU0
submit tiled->linear blit
Xorg:
copy of linear buffer
The sequence of jobs would be:
drm_sched_job_run # GPU0, frame rendering drm_sched_job_queue # GPU0, blit drm_sched_job_done # GPU0, frame rendering drm_sched_job_run # GPU0, blit move linear buffer for GPU1 access #
amdgpu_dma_buf_move_notify -> update pt # GPU0
It this point the blit job on GPU0 is still running and would likely produce a page fault.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c +8 -1
@@ -489,8 +489,15 @@ amdgpu_dma_buf_move_notify(struct dma_buf_attachment *attach) r =dma_resv_reserve_fences (resv,2 );if (!r) r =amdgpu_vm_clear_freed (adev, vm,NULL ); + +/* Don't pass 'ticket' to amdgpu_vm_handle_moved: we want the clear=true +* path to be used otherwise we might update the PT of another process +* while it's using the BO. +* With clear=true, amdgpu_vm_bo_update will sync to command submission +* from the same VM. +*/ if (!r) - r =amdgpu_vm_handle_moved (adev, vm, ticket); + r =amdgpu_vm_handle_moved (adev, vm,NULL );if (r && r != -EBUSY ) DRM_ERROR("Failed to invalidate VM page tables (%d))\n",
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 705/752 mm/hugetlb: restore failed global reservations to subpool
In reply to Sasha LevinFrom: Joshua Hahn <[email protected]>
[ Upstream commit 1d3f9bb4c8af70304d19c22e30f5d16a2d589bb5 ]
Commit a833a693a490 ("mm: hugetlb: fix incorrect fallback for subpool") fixed an underflow error for hstate->resv_huge_pages caused by incorrectly attributing globally requested pages to the subpool's reservation.
Unfortunately, this fix also introduced the opposite problem, which would leave spool->used_hpages elevated if the globally requested pages could not be acquired. This is because while a subpool's reserve pages only accounts for what is requested and allocated from the subpool, its "used" counter keeps track of what is consumed in total, both from the subpool and globally. Thus, we need to adjust spool->used_hpages in the other direction, and make sure that globally requested pages are uncharged from the subpool's used counter.
Each failed allocation attempt increments the used_hpages counter by how many pages were requested from the global pool. Ultimately, this renders the subpool unusable, as used_hpages approaches the max limit.
The issue can be reproduced as follows:
1. Allocate 4 hugetlb pages
2. Create a hugetlb mount with max=4, min=2
3. Consume 2 pages globally
4. Request 3 pages from the subpool (2 from subpool + 1 from global) 4.1 hugepage_subpool_get_pages(spool, 3) succeeds. used_hpages += 3
4.2 hugetlb_acct_memory(h, 1) fails: no global pages left
used_hpages -= 2
5. Subpool now has used_hpages = 1, despite not being able to successfully allocate any hugepages. It believes it can now only allocate 3 more hugepages, not 4.
With each failed allocation attempt incrementing the used counter, the subpool eventually reaches a point where its used counter equals its max counter. At that point, any future allocations that try to allocate hugeTLB pages from the subpool will fail, despite the subpool not having any of its hugeTLB pages consumed by any user.
Once this happens, there is no way to make the subpool usable again, since there is no way to decrement the used counter as no process is really consuming the hugeTLB pages.
The underflow issue that the original commit fixes still remains fixed as well.
Without this fix, used_hpages would keep on leaking if hugetlb_acct_memory() fails.
--- mm/hugetlb.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/hugetlb.c +9 -0
@@ -7386,6 +7386,15 @@ long hugetlb_reserve_pages(struct inode *inode,*/ hugetlb_acct_memory (h, -gbl_resv); } +/* Restore used_hpages for pages that failed global reservation */ +if (gbl_reserve && spool) { +unsigned long flags; + +spin_lock_irqsave (&spool->lock, flags); +if (spool->max_hpages !=-1 ) + spool->used_hpages -= gbl_reserve; +unlock_or_release_subpool (spool, flags); + } out_uncharge_cgroup:hugetlb_cgroup_uncharge_cgroup_rsvd (hstate_index (h), chg *pages_per_huge_page (h), h_cg);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 706/752 mm/page_alloc: skip debug_check_no_{obj,locks}_freed with FPI_TRYLOCK
In reply to Sasha LevinFrom: Harry Yoo <[email protected]>
[ Upstream commit 338ad1e84d15078a9ae46d7dd7466329ae0bfa61 ]
When CONFIG_DEBUG_OBJECTS_FREE is enabled, debug_check_no_{obj,locks}_freed() functions are called.
Since both of them spin on a lock, they are not safe to be called if the FPI_TRYLOCK flag is specified. This leads to a lockdep splat:
================================
WARNING: inconsistent lock state
6.19.0-rc5-slab-for-next+ #326 Tainted: G N
--------------------------------
inconsistent {INITIAL USE} -> {IN-NMI} usage.
kunit_try_catch/9046 [HC2[2]:SC0[0]:HE0:SE1] takes:
ffffffff84ed6bf8 (&obj_hash[i].lock){-.-.}-{2:2}, at: __debug_check_no_obj_freed+0xe0/0x300 {INITIAL USE} state was registered at:
lock_acquire+0xd9/0x2f0
_raw_spin_lock_irqsave+0x4c/0x80
__debug_object_init+0x9d/0x1f0
debug_object_init+0x34/0x50
__init_work+0x28/0x40
init_cgroup_housekeeping+0x151/0x210
init_cgroup_root+0x3d/0x140
cgroup_init_early+0x30/0x240
start_kernel+0x3e/0xcd0
x86_64_start_reservations+0x18/0x30
x86_64_start_kernel+0xf3/0x140
common_startup_64+0x13e/0x148
irq event stamp: 2998
hardirqs last enabled at (2997): [<ffffffff8298b77a>] exc_nmi+0x11a/0x240
hardirqs last disabled at (2998): [<ffffffff8298b991>] sysvec_irq_work+0x11/0x110
softirqs last enabled at (1416): [<ffffffff813c1f72>] __irq_exit_rcu+0x132/0x1c0
softirqs last disabled at (1303): [<ffffffff813c1f72>] __irq_exit_rcu+0x132/0x1c0other info that might help us debug this:
Possible unsafe locking scenario:
CPU0
----
lock(&obj_hash[i].lock);
<Interrupt>
lock(&obj_hash[i].lock);*** DEADLOCK ***
Rename free_pages_prepare() to __free_pages_prepare(), add an fpi_t parameter, and skip those checks if FPI_TRYLOCK is set. To keep the fpi_t definition in mm/page_alloc.c, add a wrapper function free_pages_prepare() that always passes FPI_NONE and use it in mm/compaction.c.
--- mm/page_alloc.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
mm/page_alloc.c +11 -6
@@ -1339,8 +1339,8 @@ static inline void pgalloc_tag_sub_pages(struct alloc_tag *tag, unsigned int nr)#endif /* CONFIG_MEM_ALLOC_PROFILING */ -__always_inline bool free_pages_prepare(struct page *page, -unsigned int order) +__always_inline bool __free_pages_prepare(struct page *page, +unsigned int order,fpi_t fpi_flags) {int bad =0 ;bool skip_kasan_poison =should_skip_kasan_poison (page);
@@ -1433,7 +1433,7 @@ __always_inline bool free_pages_prepare(struct page *page,page_table_check_free (page, order);pgalloc_tag_sub (page,1 << order); -if (!PageHighMem (page)) { +if (!PageHighMem (page) && !(fpi_flags &FPI_TRYLOCK )) {debug_check_no_locks_freed (page_address (page),PAGE_SIZE << order); debug_check_no_obj_freed(page_address(page),
@@ -1472,6 +1472,11 @@ __always_inline bool free_pages_prepare(struct page *page,return true; } +bool free_pages_prepare (struct page *page,unsigned int order) +{ +return __free_pages_prepare (page, order,FPI_NONE ); +} +/* * Frees a number of pages from the PCP lists * Assumes all pages on list are in same zone.
@@ -1605,7 +1610,7 @@ static void __free_pages_ok(struct page *page, unsigned int order,unsigned long pfn =page_to_pfn (page);struct zone *zone =page_zone (page); -if (free_pages_prepare (page, order)) +if (__free_pages_prepare (page, order, fpi_flags))free_one_page (zone, page, pfn, order, fpi_flags); }
@@ -2931,7 +2936,7 @@ static void __free_frozen_pages(struct page *page, unsigned int order,return ; } -if (!free_pages_prepare (page, order)) +if (!__free_pages_prepare (page, order, fpi_flags))return ;/*
@@ -2988,7 +2993,7 @@ void free_unref_folios(struct folio_batch *folios)unsigned long pfn =folio_pfn (folio);unsigned int order =folio_order (folio); -if (!free_pages_prepare (&folio->page, order)) +if (!__free_pages_prepare (&folio->page, order,FPI_NONE ))continue ;/* * Free orders not handled on the PCP directly to the
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 707/752 procfs: fix possible double mmput() in do_procmap_query()
In reply to Sasha LevinFrom: Andrii Nakryiko <[email protected]>
[ Upstream commit 61dc9f776705d6db6847c101b98fa4f0e9eb6fa3 ]
When user provides incorrectly sized buffer for build ID for PROCMAP_QUERY we return with -ENAMETOOLONG error. After recent changes this condition happens later, after we unlocked mmap_lock/per-VMA lock and did mmput(), so original goto out is now wrong and will double-mmput() mm_struct. Fix by jumping further to clean up only vm_file and name_buf.
--- fs/proc/task_mmu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/proc/task_mmu.c +2 -1
@@ -780,7 +780,7 @@ static int do_procmap_query(struct mm_struct *mm, void __user *uarg) }else {if (karg.build_id_size < build_id_sz) { err = -ENAMETOOLONG ; - goto out; + goto out_file; } karg.build_id_size = build_id_sz; }
@@ -808,6 +808,7 @@ static int do_procmap_query(struct mm_struct *mm, void __user *uarg) out:query_vma_teardown (&lock_ctx);mmput (mm); +out_file:if (vm_file)fput (vm_file);kfree (name_buf);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 708/752 mm/vmscan: fix demotion targets checks in reclaim/demotion
In reply to Sasha LevinFrom: Bing Jiao <[email protected]>
[ Upstream commit 1aceed565ff172fc0331dd1d5e7e65139b711139 ]
Patch series "mm/vmscan: fix demotion targets checks in reclaim/demotion", v9.
This patch series addresses two issues in demote_folio_list(), can_demote(), and next_demotion_node() in reclaim/demotion.
1. demote_folio_list() and can_demote() do not correctly check demotion target against cpuset.mems_effective, which will cause (a) pages to be demoted to not-allowed nodes and (b) pages fail demotion even if the system still has allowed demotion nodes.
Patch 1 fixes this bug by updating cpuset_node_allowed() and mem_cgroup_node_allowed() to return effective_mems, allowing directly logic-and operation against demotion targets.
2. next_demotion_node() returns a preferred demotion target, but it does not check the node against allowed nodes.
Patch 2 ensures that next_demotion_node() filters against the allowed node mask and selects the closest demotion target to the source node.
This patch (of 2):
Fix two bugs in demote_folio_list() and can_demote() due to incorrect demotion target checks against cpuset.mems_effective in reclaim/demotion.
Commit 7d709f49babc ("vmscan,cgroup: apply mems_effective to reclaim") introduces the cpuset.mems_effective check and applies it to can_demote(). However:
1. It does not apply this check in demote_folio_list(), which leads to situations where pages are demoted to nodes that are explicitly excluded from the task's cpuset.mems.
2. It checks only the nodes in the immediate next demotion hierarchy and does not check all allowed demotion targets in can_demote(). This can cause pages to never be demoted if the nodes in the next demotion hierarchy are not set in mems_effective.
These bugs break resource isolation provided by cpuset.mems. This is visible from userspace because pages can either fail to be demoted entirely or are demoted to nodes that are not allowed in multi-tier memory systems.
To address these bugs, update cpuset_node_allowed() and mem_cgroup_node_allowed() to return effective_mems, allowing directly logic-and operation against demotion targets. Also update can_demote() and demote_folio_list() accordingly.
Bug 1 reproduction:
Assume a system with 4 nodes, where nodes 0-1 are top-tier and nodes 2-3 are far-tier memory. All nodes have equal capacity.
Test script:
echo 1 > /sys/kernel/mm/numa/demotion_enabled
mkdir /sys/fs/cgroup/test
echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control
echo "0-2" > /sys/fs/cgroup/test/cpuset.mems
echo $$ > /sys/fs/cgroup/test/cgroup.procs
swapoff -a
# Expectation: Should respect node 0-2 limit.
# Observation: Node 3 shows significant allocation (MemFree drops)
stress-ng --oomable --vm 1 --vm-bytes 150% --mbind 0,1Bug 2 reproduction:
Assume a system with 6 nodes, where nodes 0-2 are top-tier, node 3 is a far-tier node, and nodes 4-5 are the farthest-tier nodes. All nodes have equal capacity.
Test script:
echo 1 > /sys/kernel/mm/numa/demotion_enabled
mkdir /sys/fs/cgroup/test
echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control
echo "0-2,4-5" > /sys/fs/cgroup/test/cpuset.mems
echo $$ > /sys/fs/cgroup/test/cgroup.procs
swapoff -a
# Expectation: Pages are demoted to Nodes 4-5
# Observation: No pages are demoted before oom.
stress-ng --oomable --vm 1 --vm-bytes 150% --mbind 0,1,2--- include/linux/cpuset.h | 6 ++--- include/linux/memcontrol.h | 6 ++--- kernel/cgroup/cpuset.c | 54 +++++++++++++++++++++++++------------- mm/memcontrol.c | 16 +++++++++-- mm/vmscan.c | 34 +++++++++++++++--------- 5 files changed, 78 insertions(+), 38 deletions(-)
include/linux/cpuset.h +3 -3
@@ -173,7 +173,7 @@ static inline void set_mems_allowed(nodemask_t nodemask) task_unlock(current); } -extern bool cpuset_node_allowed (struct cgroup *cgroup,int nid); +extern void cpuset_nodes_allowed (struct cgroup *cgroup,nodemask_t *mask);#else /* !CONFIG_CPUSETS */ static inline bool cpusets_enabled (void ) {return false; }
@@ -294,9 +294,9 @@ static inline bool read_mems_allowed_retry(unsigned int seq) return false; } -static inline bool cpuset_node_allowed (struct cgroup *cgroup,int nid) +static inline void cpuset_nodes_allowed (struct cgroup *cgroup,nodemask_t *mask) { -return true; +nodes_copy (*mask, node_states[N_MEMORY ]); }#endif /* !CONFIG_CPUSETS */
include/linux/memcontrol.h +3 -3
@@ -1789,7 +1789,7 @@ static inline void count_objcg_events(struct obj_cgroup *objcg, rcu_read_unlock(); } -bool mem_cgroup_node_allowed (struct mem_cgroup *memcg,int nid); +void mem_cgroup_node_filter_allowed (struct mem_cgroup *memcg,nodemask_t *mask);#else static inline bool mem_cgroup_kmem_disabled (void )
@@ -1853,9 +1853,9 @@ static inline ino_t page_cgroup_ino(struct page *page) return 0; } -static inline bool mem_cgroup_node_allowed (struct mem_cgroup *memcg,int nid) +static inline void mem_cgroup_node_filter_allowed (struct mem_cgroup *memcg, +nodemask_t *mask) { -return true; }#endif /* CONFIG_MEMCG */
kernel/cgroup/cpuset.c +36 -18
76 lines not on this page · raw message
mm/memcontrol.c +14 -2
@@ -5597,7 +5597,19 @@ subsys_initcall(mem_cgroup_swap_init);#endif /* CONFIG_SWAP */ -bool mem_cgroup_node_allowed (struct mem_cgroup *memcg,int nid) +void mem_cgroup_node_filter_allowed (struct mem_cgroup *memcg,nodemask_t *mask) { -return memcg ?cpuset_node_allowed (memcg->css.cgroup, nid) : true; +nodemask_t allowed; + +if (!memcg) +return ; + +/* +* Since this interface is intended for use by migration paths, and +* reclaim and migration are subject to race conditions such as changes +* in effective_mems and hot-unpluging of nodes, inaccurate allowed +* mask is acceptable. +*/ +cpuset_nodes_allowed (memcg->css.cgroup, &allowed); +nodes_and (*mask, *mask, allowed); }
mm/vmscan.c +22 -12
@@ -344,19 +344,21 @@ static void flush_reclaim_state(struct scan_control *sc)static bool can_demote (int nid,struct scan_control *sc,struct mem_cgroup *memcg) { -int demotion_nid; +struct pglist_data *pgdat =NODE_DATA (nid); +nodemask_t allowed_mask; -if (!numa_demotion_enabled) +if (!pgdat || !numa_demotion_enabled)return false;if (sc && sc->no_demotion)return false; - demotion_nid =next_demotion_node (nid); -if (demotion_nid ==NUMA_NO_NODE ) +node_get_allowed_targets (pgdat, &allowed_mask); +if (nodes_empty (allowed_mask))return false; -/* If demotion node isn't in the cgroup's mems_allowed, fall back */ -return mem_cgroup_node_allowed (memcg, demotion_nid); +/* Filter out nodes that are not in cgroup's mems_allowed. */ +mem_cgroup_node_filter_allowed (memcg, &allowed_mask); +return !nodes_empty (allowed_mask); } static inline bool can_reclaim_anon_pages(struct mem_cgroup *memcg,
@@ -1042,9 +1044,10 @@ static struct folio *alloc_demote_folio(struct folio *src,* Folios which are not demoted are left on @demote_folios. */ static unsigned int demote_folio_list (struct list_head *demote_folios, -struct pglist_data *pgdat) +struct pglist_data *pgdat, +struct mem_cgroup *memcg) { -int target_nid =next_demotion_node (pgdat->node_id); +int target_nid;unsigned int nr_succeeded;nodemask_t allowed_mask;
@@ -1056,7 +1059,6 @@ static unsigned int demote_folio_list(struct list_head *demote_folios,*/ .gfp_mask = (GFP_HIGHUSER_MOVABLE & ~__GFP_RECLAIM) | __GFP_NOWARN | __GFP_NOMEMALLOC | GFP_NOWAIT, - .nid = target_nid, .nmask = &allowed_mask, .reason = MR_DEMOTION, };
@@ -1064,10 +1066,18 @@ static unsigned int demote_folio_list(struct list_head *demote_folios,if (list_empty (demote_folios))return 0 ; -if (target_nid ==NUMA_NO_NODE ) +node_get_allowed_targets (pgdat, &allowed_mask); +mem_cgroup_node_filter_allowed (memcg, &allowed_mask); +if (nodes_empty (allowed_mask))return 0 ; -node_get_allowed_targets (pgdat, &allowed_mask); + target_nid =next_demotion_node (pgdat->node_id); +if (target_nid ==NUMA_NO_NODE ) +/* No lower-tier nodes or nodes were hot-unplugged. */ +return 0 ; +if (!node_isset (target_nid, allowed_mask)) + target_nid =node_random (&allowed_mask); + mtc.nid = target_nid;/* Demotion ignores all cpuset and mempolicy settings */ migrate_pages(demote_folios, alloc_demote_folio, NULL,
@@ -1601,7 +1611,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,/* 'folio_list' is always empty here */ /* Migrate folios selected for demotion */ - nr_demoted =demote_folio_list (&demote_folios, pgdat); + nr_demoted =demote_folio_list (&demote_folios, pgdat, memcg); nr_reclaimed += nr_demoted; stat->nr_demoted += nr_demoted;/* Folios that could not be demoted are still in @demote_folios */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 709/752 mm/page_alloc: clear page->private in free_pages_prepare()
In reply to Sasha LevinFrom: Mikhail Gavrilov <[email protected]>
[ Upstream commit ac1ea219590c09572ed5992dc233bbf7bb70fef9 ]
Several subsystems (slub, shmem, ttm, etc.) use page->private but don't clear it before freeing pages. When these pages are later allocated as high-order pages and split via split_page(), tail pages retain stale page->private values.
This causes a use-after-free in the swap subsystem. The swap code uses page->private to track swap count continuations, assuming freshly allocated pages have page->private == 0. When stale values are present, swap_count_continued() incorrectly assumes the continuation list is valid and iterates over uninitialized page->lru containing LIST_POISON values, causing a crash:
KASAN: maybe wild-memory-access in range [0xdead000000000100-0xdead000000000107] RIP: 0010:__do_sys_swapoff+0x1151/0x1860
Fix this by clearing page->private in free_pages_prepare(), ensuring all freed pages have clean state regardless of previous use.
--- mm/page_alloc.c | 1 + 1 file changed, 1 insertion(+)
mm/page_alloc.c +1 -0
@@ -1429,6 +1429,7 @@ __always_inline bool __free_pages_prepare(struct page *page,page_cpupid_reset_last (page); page->flags.f &= ~PAGE_FLAGS_CHECK_AT_PREP ; + page->private =0 ;reset_page_owner (page, order);page_table_check_free (page, order);pgalloc_tag_sub (page,1 << order);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 710/752 net: intel: fix PCI device ID conflict between i40e and ipw2200
In reply to Sasha LevinFrom: Ethan Nelson-Moore <[email protected]>
[ Upstream commit d03e094473ecdeb68d853752ba467abe13e1de44 ]
The ID 8086:104f is matched by both i40e and ipw2200. The same device ID should not be in more than one driver, because in that case, which driver is used is unpredictable. Fix this by taking advantage of the fact that i40e devices use PCI_CLASS_NETWORK_ETHERNET and ipw2200 devices use PCI_CLASS_NETWORK_OTHER to differentiate the devices.
--- drivers/net/ethernet/intel/i40e/i40e_main.c | 8 +++++++- drivers/net/wireless/intel/ipw2x00/ipw2200.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/i40e/i40e_main.c +7 -1
@@ -75,7 +75,13 @@ static const struct pci_device_id i40e_pci_tbl[] = { {PCI_VDEVICE(INTEL, I40E_DEV_ID_10G_BASE_T4), 0}, {PCI_VDEVICE(INTEL, I40E_DEV_ID_10G_BASE_T_BC), 0}, {PCI_VDEVICE(INTEL, I40E_DEV_ID_10G_SFP), 0}, - {PCI_VDEVICE(INTEL, I40E_DEV_ID_10G_B), 0}, +/* +* This ID conflicts with ipw2200, but the devices can be differentiated +* because i40e devices use PCI_CLASS_NETWORK_ETHERNET and ipw2200 +* devices use PCI_CLASS_NETWORK_OTHER. +*/ + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, I40E_DEV_ID_10G_B), + PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, 0}, {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_X722), 0}, {PCI_VDEVICE(INTEL, I40E_DEV_ID_QSFP_X722), 0}, {PCI_VDEVICE(INTEL, I40E_DEV_ID_SFP_X722), 0},
drivers/net/wireless/intel/ipw2x00/ipw2200.c +7 -1
@@ -11387,7 +11387,13 @@ static const struct pci_device_id card_ids[] = { {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2754, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0}, {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0}, - {PCI_VDEVICE(INTEL, 0x104f), 0}, +/* +* This ID conflicts with i40e, but the devices can be differentiated +* because i40e devices use PCI_CLASS_NETWORK_ETHERNET and ipw2200 +* devices use PCI_CLASS_NETWORK_OTHER. +*/ + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, 0x104f), + PCI_CLASS_NETWORK_OTHER << 8, 0xffff00, 0}, {PCI_VDEVICE(INTEL, 0x4220), 0}, /* BG */ {PCI_VDEVICE(INTEL, 0x4221), 0}, /* BG */ {PCI_VDEVICE(INTEL, 0x4223), 0}, /* ABG */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 711/752 atm: fore200e: fix use-after-free in tasklets during device removal
In reply to Sasha LevinFrom: Duoming Zhou <[email protected]>
[ Upstream commit 8930878101cd40063888a68af73b1b0f8b6c79bc ]
When the PCA-200E or SBA-200E adapter is being detached, the fore200e is deallocated. However, the tx_tasklet or rx_tasklet may still be running or pending, leading to use-after-free bug when the already freed fore200e is accessed again in fore200e_tx_tasklet() or fore200e_rx_tasklet().
One of the race conditions can occur as follows:
CPU 0 (cleanup) | CPU 1 (tasklet)
fore200e_pca_remove_one() | fore200e_interrupt()
fore200e_shutdown() | tasklet_schedule()
kfree(fore200e) | fore200e_tx_tasklet()
| fore200e-> // UAFFix this by ensuring tx_tasklet or rx_tasklet is properly canceled before the fore200e is released. Add tasklet_kill() in fore200e_shutdown() to synchronize with any pending or running tasklets. Moreover, since fore200e_reset() could prevent further interrupts or data transfers, the tasklet_kill() should be placed after fore200e_reset() to prevent the tasklet from being rescheduled in fore200e_interrupt(). Finally, it only needs to do tasklet_kill() when the fore200e state is greater than or equal to FORE200E_STATE_IRQ, since tasklets are uninitialized in earlier states. In a word, the tasklet_kill() should be placed in the FORE200E_STATE_IRQ branch within the switch...case structure.
This bug was identified through static analysis.
--- drivers/atm/fore200e.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/atm/fore200e.c +4 -0
@@ -373,6 +373,10 @@ fore200e_shutdown(struct fore200e* fore200e) fallthrough;case FORE200E_STATE_IRQ :free_irq (fore200e->irq, fore200e->atm_dev); +#ifdef FORE200E_USE_TASKLET +tasklet_kill (&fore200e->tx_tasklet); +tasklet_kill (&fore200e->rx_tasklet); +#endif fallthrough;case FORE200E_STATE_ALLOC_BUF :
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 712/752 function_graph: Restore direct mode when callbacks drop to one
In reply to Sasha LevinFrom: Shengming Hu <[email protected]>
[ Upstream commit 53b2fae90ff01fede6520ca744ed5e8e366497ba ]
When registering a second fgraph callback, direct path is disabled and array loop is used instead. When ftrace_graph_active falls back to one, we try to re-enable direct mode via ftrace_graph_enable_direct(true, ...). But ftrace_graph_enable_direct() incorrectly disables the static key rather than enabling it. This leaves fgraph_do_direct permanently off after first multi-callback transition, so direct fast mode is never restored.
--- kernel/trace/fgraph.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/fgraph.c +1 -1
@@ -1311,7 +1311,7 @@ static void ftrace_graph_enable_direct(bool enable_branch, struct fgraph_ops *gostatic_call_update (fgraph_func, func);static_call_update (fgraph_retfunc, retfunc);if (enable_branch) -static_branch_disable (&fgraph_do_direct); +static_branch_enable (&fgraph_do_direct); }static void ftrace_graph_disable_direct (bool disable_branch)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 713/752 kbuild: Fix CC_CAN_LINK detection
In reply to Sasha LevinFrom: Mickaël Salaün <[email protected]>
[ Upstream commit be55899b71630c79ad01df54c92e467e47644f87 ]
Most samples cannot be build on some environments because they depend on CC_CAN_LINK, which is set according to the result of scripts/cc-can-link.sh called by cc_can_link_user.
Because cc-can-link.sh must now build without warning, it may fail because it is calling printf() with an empty string:
+ cat
+ gcc -m32 -Werror -Wl,--fatal-warnings -x c - -o /dev/null
<stdin>: In function ‘main’:
<stdin>:4:9: error: zero-length gnu_printf format string [-Werror=format-zero-length]
cc1: all warnings being treated as errors
Fix this warning and the samples build by actually printing something.
--- scripts/cc-can-link.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/cc-can-link.sh +1 -1
@@ -5,7 +5,7 @@ cat << "END" | $@ -Werror -Wl,--fatal-warnings -x c - -o /dev/null >/dev/null 2> #include <stdio.h> int main(void) { - printf(""); + printf("\n"); return 0; } END
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 714/752 kbuild: rpm-pkg: Restrict manual debug package creation
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 6d6b8b0e28c468263d7fcb071e5cb284ae343df2 ]
Commit 62089b804895 ("kbuild: rpm-pkg: Generate debuginfo package manually") moved away from the built-in RPM machinery for generating -debuginfo packages to a more manual way to be compatible with module signing, as the built-in machinery strips the modules after the installation process, breaking the signatures.
Unfortunately, prior to rpm 4.20.0, there is a bug where a custom %files directive is ignored for a -debuginfo subpackage [1], meaning builds using older versions of RPM (such as on RHEL9 or RHEL10) fail with:
Checking for unpackaged file(s): /usr/lib/rpm/check-files .../rpmbuild/BUILDROOT/kernel-6.19.0_dirty-1.x86_64
error: Installed (but unpackaged) file(s) found:
/debuginfo.list
/usr/lib/debug/.build-id/09/748c214974bfba1522d434a7e0a02e2fd7f29b.debug
/usr/lib/debug/.build-id/0b/b96dd9c7d3689d82e56d2e73b46f53103cc6c7.debug
/usr/lib/debug/.build-id/0e/979a2f34967c7437fd30aabb41de1f0c8b6a66.debug
...To workaround this, restrict the manual debug info package creation process to when it is necessary (CONFIG_MODULE_SIG=y) and possible (when using RPM >= 4.20.0). A follow up change will restore the RPM debuginfo creation process using a separate internal flag to allow the package to be built in more situations, as RPM 4.20.0 is a fairly recent version and the built-in -debuginfo generation works fine when module signing is disabled.
--- scripts/package/kernel.spec | 9 +++++---- scripts/package/mkspec | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 35 insertions(+), 7 deletions(-)
scripts/package/kernel.spec +5 -4
@@ -47,12 +47,13 @@ This package provides kernel headers and makefiles sufficient to build modules against the %{version} kernel package. %endif -%if %{with_debuginfo} +%if %{with_debuginfo_manual} %package debuginfo Summary: Debug information package for the Linux kernel %description debuginfo This package provides debug information for the kernel image and modules from the %{version} package. +%define install_mod_strip 1 %endif %prep
@@ -67,7 +68,7 @@ patch -p1 < %{SOURCE2} mkdir -p %{buildroot}/lib/modules/%{KERNELRELEASE} cp $(%{make} %{makeflags} -s image_name) %{buildroot}/lib/modules/%{KERNELRELEASE}/vmlinuz # DEPMOD=true makes depmod no-op. We do not package depmod-generated files. -%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} INSTALL_MOD_STRIP=1 DEPMOD=true modules_install +%{make} %{makeflags} INSTALL_MOD_PATH=%{buildroot} %{?install_mod_strip:INSTALL_MOD_STRIP=1} DEPMOD=true modules_install %{make} %{makeflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install cp System.map %{buildroot}/lib/modules/%{KERNELRELEASE} cp .config %{buildroot}/lib/modules/%{KERNELRELEASE}/config
@@ -98,7 +99,7 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA echo "%exclude /lib/modules/%{KERNELRELEASE}/build" } > %{buildroot}/kernel.list -%if %{with_debuginfo} +%if %{with_debuginfo_manual} # copying vmlinux directly to the debug directory means it will not get # stripped (but its source paths will still be collected + fixed up) mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}
@@ -162,7 +163,7 @@ fi /lib/modules/%{KERNELRELEASE}/build %endif -%if %{with_debuginfo} +%if %{with_debuginfo_manual} %files -f %{buildroot}/debuginfo.list debuginfo %defattr (-, root, root) %exclude /debuginfo.list
scripts/package/mkspec +30 -3
@@ -23,15 +23,42 @@ else echo '%define with_devel 0' fi +# manually generate -debuginfo package +with_debuginfo_manual=0 # debuginfo package generation uses find-debuginfo.sh under the hood, # which only works on uncompressed modules that contain debuginfo if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf && (! grep -q CONFIG_MODULE_COMPRESS=y include/config/auto.conf) && (! grep -q CONFIG_DEBUG_INFO_SPLIT=y include/config/auto.conf); then -echo '%define with_debuginfo %{?_without_debuginfo: 0} %{?!_without_debuginfo: 1}' -else -echo '%define with_debuginfo 0' + # If module signing is enabled (which may be required to boot with + # lockdown enabled), the find-debuginfo.sh machinery cannot be used + # because the signatures will be stripped off the modules. However, due + # to an rpm bug in versions prior to 4.20.0 + # + # https://github.com/rpm-software-management/rpm/issues/3057 + # https://github.com/rpm-software-management/rpm/commit/49f906998f3cf1f4152162ca61ac0869251c380f + # + # We cannot provide our own debuginfo package because it does not listen + # to our custom files list, failing the build due to unpackaged files. + # Manually generate the debug info package if using rpm 4.20.0. If not + # using rpm 4.20.0, avoid generating a -debuginfo package altogether, + # as it is not safe. + if grep -q CONFIG_MODULE_SIG=y include/config/auto.conf; then + rpm_ver_str=$(rpm --version 2>/dev/null) + # Split the version on spaces + IFS=' ' + set -- $rpm_ver_str + if [ "${1:-}" = RPM -a "${2:-}" = version ]; then + IFS=. + set -- $3 + rpm_ver=$(( 1000000 * $1 + 10000 * $2 + 100 * $3 + ${4:-0} )) + if [ "$rpm_ver" -ge 4200000 ]; then + with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}' + fi + fi + fi fi +echo "%define with_debuginfo_manual $with_debuginfo_manual" cat<<EOF %define ARCH ${ARCH}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 715/752 kernel: rpm-pkg: Restore find-debuginfo.sh approach to -debuginfo package
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit ffe9ac1ad56df8f915896b97bd7645f522c47ce9 ]
Commit 62089b804895 ("kbuild: rpm-pkg: Generate debuginfo package manually") effectively reverted commit a7c699d090a1 ("kbuild: rpm-pkg:
build a debuginfo RPM") but the approach it took is not safe for older RPM releases. Restore commit a7c699d090a1 ("kbuild: rpm-pkg: build a debuginfo RPM") for the !CONFIG_MODULE_SIG case to allow more environments and configurations to take advantage of the separate debug information package process.
--- scripts/package/kernel.spec | 50 ++++++++++++++++++++++++++++++++++--- scripts/package/mkspec | 5 ++++ 2 files changed, 51 insertions(+), 4 deletions(-)
scripts/package/kernel.spec +46 -4
@@ -2,8 +2,6 @@ %{!?_arch: %define _arch dummy} %{!?make: %define make make} %define makeflags %{?_smp_mflags} ARCH=%{ARCH} -%define __spec_install_post /usr/lib/rpm/brp-compress || : -%define debug_package %{nil} Name: kernel Summary: The Linux Kernel
@@ -56,6 +54,38 @@ This package provides debug information for the kernel image and modules from th %define install_mod_strip 1 %endif +%if %{with_debuginfo_rpm} +# list of debuginfo-related options taken from distribution kernel.spec +# files +%undefine _include_minidebuginfo +%undefine _find_debuginfo_dwz_opts +%undefine _unique_build_ids +%undefine _unique_debug_names +%undefine _unique_debug_srcs +%undefine _debugsource_packages +%undefine _debuginfo_subpackages +%global _find_debuginfo_opts -r +%global _missing_build_ids_terminate_build 1 +%global _no_recompute_build_ids 1 +%{debug_package} + +# later, we make all modules executable so that find-debuginfo.sh strips +# them up. but they don't actually need to be executable, so remove the +# executable bit, taking care to do it _after_ find-debuginfo.sh has run +%define __spec_install_post \ + %{?__debug_package:%{__debug_install_post}} \ + %{__arch_install_post} \ + %{__os_install_post} \ + find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \\\ + | xargs --no-run-if-empty chmod u-x +%else +%define __spec_install_post /usr/lib/rpm/brp-compress || : +%endif +# some (but not all) versions of rpmbuild emit %%debug_package with +# %%install. since we've already emitted it manually, that would cause +# a package redefinition error. ensure that doesn't happen +%define debug_package %{nil} + %prep %setup -q -n linux cp %{SOURCE1} .config
@@ -99,14 +129,22 @@ ln -fns /usr/src/kernels/%{KERNELRELEASE} %{buildroot}/lib/modules/%{KERNELRELEA echo "%exclude /lib/modules/%{KERNELRELEASE}/build" } > %{buildroot}/kernel.list -%if %{with_debuginfo_manual} +%if 0%{with_debuginfo_manual}%{with_debuginfo_rpm} > 0 # copying vmlinux directly to the debug directory means it will not get # stripped (but its source paths will still be collected + fixed up) mkdir -p %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} cp vmlinux %{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE} +%endif -echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list +%if %{with_debuginfo_rpm} +# make modules executable so that find-debuginfo.sh strips them. this +# will be undone later in %%__spec_install_post +find %{buildroot}/lib/modules/%{KERNELRELEASE} -name "*.ko" -type f \ + | xargs --no-run-if-empty chmod u+x +%endif +%if %{with_debuginfo_manual} +echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginfo.list while read -r mod; do mod="${mod%.o}.ko" dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}"
@@ -124,6 +162,10 @@ done < modules.order %clean rm -rf %{buildroot} +%if %{with_debuginfo_rpm} +rm -f debugfiles.list debuglinks.list debugsourcefiles.list debugsources.list \ + elfbins.list +%endif %post if [ -x /usr/bin/kernel-install ]; then
scripts/package/mkspec +5 -0
@@ -23,6 +23,8 @@ else echo '%define with_devel 0' fi +# use %{debug_package} machinery to generate -debuginfo +with_debuginfo_rpm=0 # manually generate -debuginfo package with_debuginfo_manual=0 # debuginfo package generation uses find-debuginfo.sh under the hood,
@@ -56,9 +58,12 @@ if grep -q CONFIG_DEBUG_INFO=y include/config/auto.conf && with_debuginfo_manual='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}' fi fi + else + with_debuginfo_rpm='%{?_without_debuginfo:0}%{?!_without_debuginfo:1}' fi fi echo "%define with_debuginfo_manual $with_debuginfo_manual" +echo "%define with_debuginfo_rpm $with_debuginfo_rpm" cat<<EOF %define ARCH ${ARCH}
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 716/752 kbuild: rpm-pkg: Fix manual debuginfo generation when using .src.rpm
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit afdfb71c018e9a0aa2e51fb8186d3fb1acdd3f0e ]
Commit 62089b804895 ("kbuild: rpm-pkg: Generate debuginfo package manually") added uses of OBJCOPY and READELF, variables from Kbuild. These variables are defined and work properly when using the binrpm-pkg target because rpmbuild is run within Kbuild. However, these variables are not defined when building from a source RPM package generated with the srcrpm-pkg target, breaking the build when generating the debug info subpackage.
Define a default value for these variables so that these commands respect the value from Kbuild but continue to work when built from a source RPM package.
--- scripts/package/kernel.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/package/kernel.spec +2 -2
@@ -148,11 +148,11 @@ echo /usr/lib/debug/lib/modules/%{KERNELRELEASE}/vmlinux > %{buildroot}/debuginf while read -r mod; do mod="${mod%.o}.ko" dbg="%{buildroot}/usr/lib/debug/lib/modules/%{KERNELRELEASE}/kernel/${mod}" - buildid=$("${READELF}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') + buildid=$("${READELF:-readelf}" -n "${mod}" | sed -n 's@^.*Build ID: \(..\)\(.*\)@\1/\2@p') link="%{buildroot}/usr/lib/debug/.build-id/${buildid}.debug" mkdir -p "${dbg%/*}" "${link%/*}" - "${OBJCOPY}" --only-keep-debug "${mod}" "${dbg}" + "${OBJCOPY:-objcopy}" --only-keep-debug "${mod}" "${dbg}" ln -sf --relative "${dbg}" "${link}" echo "${dbg#%{buildroot}}" >> %{buildroot}/debuginfo.list
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 717/752 ipv6: ioam: fix heap buffer overflow in __ioam6_fill_trace_data()
In reply to Sasha LevinFrom: Qanux <[email protected]>
[ Upstream commit 6db8b56eed62baacaf37486e83378a72635c04cc ]
On the receive path, __ioam6_fill_trace_data() uses trace->nodelen to decide how much data to write for each node. It trusts this field as-is from the incoming packet, with no consistency check against trace->type (the 24-bit field that tells which data items are present). A crafted packet can set nodelen=0 while setting type bits 0-21, causing the function to write ~100 bytes past the allocated region (into skb_shared_info), which corrupts adjacent heap memory and leads to a kernel panic.
Add a shared helper ioam6_trace_compute_nodelen() in ioam6.c to derive the expected nodelen from the type field, and use it:
- in ioam6_iptunnel.c (send path, existing validation) to replace
the open-coded computation;
- in exthdrs.c (receive path, ipv6_hop_ioam) to drop packets whose nodelen is inconsistent with the type field, before any data is written.
Per RFC 9197, bits 12-21 are each short (4-octet) fields, so they are included in IOAM6_MASK_SHORT_FIELDS (changed from 0xff100000 to 0xff1ffc00).
--- include/net/ioam6.h | 2 ++ net/ipv6/exthdrs.c | 5 +++++ net/ipv6/ioam6.c | 14 ++++++++++++++ net/ipv6/ioam6_iptunnel.c | 10 +--------- 4 files changed, 22 insertions(+), 9 deletions(-)
include/net/ioam6.h +2 -0
@@ -60,6 +60,8 @@ void ioam6_fill_trace_data(struct sk_buff *skb,struct ioam6_trace_hdr *trace, bool is_input); +u8 ioam6_trace_compute_nodelen (u32 trace_type); +int ioam6_init (void );void ioam6_exit (void );
net/ipv6/exthdrs.c +5 -0
@@ -931,6 +931,11 @@ static bool ipv6_hop_ioam(struct sk_buff *skb, int optoff)if (hdr->opt_len <2 +sizeof (*trace) + trace->remlen *4 ) goto drop; +/* Inconsistent Pre-allocated Trace header */ +if (trace->nodelen != +ioam6_trace_compute_nodelen (be32_to_cpu (trace->type_be32))) + goto drop; +/* Ignore if the IOAM namespace is unknown */ ns =ioam6_namespace (dev_net (skb->dev), trace->namespace_id);if (!ns)
net/ipv6/ioam6.c +14 -0
@@ -690,6 +690,20 @@ struct ioam6_namespace *ioam6_namespace(struct net *net, __be16 id)return rhashtable_lookup_fast (&nsdata->namespaces, &id, rht_ns_params); } +#define IOAM6_MASK_SHORT_FIELDS 0xff1ffc00 +#define IOAM6_MASK_WIDE_FIELDS 0x00e00000 + +u8 ioam6_trace_compute_nodelen (u32 trace_type) +{ +u8 nodelen =hweight32 (trace_type &IOAM6_MASK_SHORT_FIELDS ) + * (sizeof (__be32) /4 ); + + nodelen +=hweight32 (trace_type &IOAM6_MASK_WIDE_FIELDS ) + * (sizeof (__be64) /4 ); + +return nodelen; +} + static void __ioam6_fill_trace_data(struct sk_buff *skb, struct ioam6_namespace *ns, struct ioam6_trace_hdr *trace,
net/ipv6/ioam6_iptunnel.c +1 -9
@@ -22,9 +22,6 @@#include <net/ip6_route.h> #include <net/addrconf.h> -#define IOAM6_MASK_SHORT_FIELDS 0xff100000 -#define IOAM6_MASK_WIDE_FIELDS 0xe00000 -struct ioam6_lwt_encap {struct ipv6_hopopt_hdr eh;u8 pad[2 ];/* 2-octet padding for 4n-alignment */
@@ -93,13 +90,8 @@ static bool ioam6_validate_trace_hdr(struct ioam6_trace_hdr *trace) trace->type.bit21 | trace->type.bit23)return false; - trace->nodelen =0 ; fields =be32_to_cpu (trace->type_be32); - - trace->nodelen +=hweight32 (fields &IOAM6_MASK_SHORT_FIELDS ) - * (sizeof (__be32) /4 ); - trace->nodelen +=hweight32 (fields &IOAM6_MASK_WIDE_FIELDS ) - * (sizeof (__be64) /4 ); + trace->nodelen =ioam6_trace_compute_nodelen (fields);return true; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 718/752 mm: numa_memblks: Identify the accurate NUMA ID of CFMW
In reply to Sasha LevinFrom: Cui Chao <[email protected]>
[ Upstream commit f043a93fff9e3e3e648b6525483f59104b0819fa ]
In some physical memory layout designs, the address space of CFMW (CXL Fixed Memory Window) resides between multiple segments of system memory belonging to the same NUMA node. In numa_cleanup_meminfo, these multiple segments of system memory are merged into a larger numa_memblk. When identifying which NUMA node the CFMW belongs to, it may be incorrectly assigned to the NUMA node of the merged system memory.
When a CXL RAM region is created in userspace, the memory capacity of the newly created region is not added to the CFMW-dedicated NUMA node. Instead, it is accumulated into an existing NUMA node (e.g., NUMA0 containing RAM). This makes it impossible to clearly distinguish between the two types of memory, which may affect memory-tiering applications.
Example memory layout:
Physical address space:
0x00000000 - 0x1FFFFFFF System RAM (node0)
0x20000000 - 0x2FFFFFFF CXL CFMW (node2)
0x40000000 - 0x5FFFFFFF System RAM (node0)
0x60000000 - 0x7FFFFFFF System RAM (node1)After numa_cleanup_meminfo, the two node0 segments are merged into one:
0x00000000 - 0x5FFFFFFF System RAM (node0) // CFMW is inside the range
0x60000000 - 0x7FFFFFFF System RAM (node1)So the CFMW (0x20000000-0x2FFFFFFF) will be incorrectly assigned to node0.
To address this scenario, accurately identifying the correct NUMA node can be achieved by checking whether the region belongs to both numa_meminfo and numa_reserved_meminfo.
While this issue is only observed in a QEMU configuration, and no known end users are impacted by this problem, it is likely that some firmware implementation is leaving memory map holes in a CXL Fixed Memory Window. CXL hotplug depends on mapping free window capacity, and it seems to be only a coincidence to have not hit this problem yet.
--- mm/numa_memblks.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
mm/numa_memblks.c +5 -4
@@ -570,15 +570,16 @@ static int meminfo_to_nid(struct numa_meminfo *mi, u64 start)int phys_to_target_node (u64 start) {int nid =meminfo_to_nid (&numa_meminfo, start); +int reserved_nid =meminfo_to_nid (&numa_reserved_meminfo, start);/* -* Prefer online nodes, but if reserved memory might be -* hot-added continue the search with reserved ranges. +* Prefer online nodes unless the address is also described +* by reserved ranges, in which case use the reserved nid. */ -if (nid !=NUMA_NO_NODE ) +if (nid !=NUMA_NO_NODE && reserved_nid ==NUMA_NO_NODE )return nid; -return meminfo_to_nid (&numa_reserved_meminfo, start); +return reserved_nid; }EXPORT_SYMBOL_GPL (phys_to_target_node);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 719/752 fbdev: Use device_create_with_groups() to fix sysfs groups registration race
In reply to Sasha LevinFrom: Hans de Goede <[email protected]>
[ Upstream commit 68eeb0871e986ae5462439dae881e3a27bcef85f ]
The fbdev sysfs attributes are registered after sending the uevent for the device creation, leaving a race window where e.g. udev rules may not be able to access the sysfs attributes because the registration is not done yet.
Fix this by switching to device_create_with_groups(). This also results in a nice cleanup. After switching to device_create_with_groups() all that is left of fb_init_device() is setting the drvdata and that can be passed to device_create[_with_groups]() too. After which fb_init_device() can be completely removed.
Dropping fb_init_device() + fb_cleanup_device() in turn allows removing fb_info.class_flag as they were the only user of this field.
--- drivers/video/fbdev/core/fbsysfs.c | 36 +++--------------------------- include/linux/fb.h | 1 - 2 files changed, 3 insertions(+), 34 deletions(-)
drivers/video/fbdev/core/fbsysfs.c +3 -33
@@ -12,8 +12,6 @@#include "fb_internal.h" -#define FB_SYSFS_FLAG_ATTR 1 -static int activate (struct fb_info *fb_info,struct fb_var_screeninfo *var) {int err;
@@ -451,33 +449,7 @@ static struct attribute *fb_device_attrs[] = { NULL, }; -static const struct attribute_group fb_device_attr_group = { - .attrs = fb_device_attrs, -}; - -static int fb_init_device (struct fb_info *fb_info) -{ -int ret; - -dev_set_drvdata (fb_info->dev, fb_info); - - fb_info->class_flag |=FB_SYSFS_FLAG_ATTR ; - - ret =device_add_group (fb_info->dev, &fb_device_attr_group); -if (ret) - fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR ; - -return 0 ; -} - -static void fb_cleanup_device (struct fb_info *fb_info) -{ -if (fb_info->class_flag &FB_SYSFS_FLAG_ATTR ) { -device_remove_group (fb_info->dev, &fb_device_attr_group); - - fb_info->class_flag &= ~FB_SYSFS_FLAG_ATTR ; - } -} +ATTRIBUTE_GROUPS (fb_device);int fb_device_create (struct fb_info *fb_info) {
@@ -485,14 +457,13 @@ int fb_device_create(struct fb_info *fb_info)dev_t devt =MKDEV (FB_MAJOR , node);int ret; - fb_info->dev =device_create (fb_class, fb_info->device, devt,NULL ,"fb%d" , node); + fb_info->dev =device_create_with_groups (fb_class, fb_info->device, devt, fb_info, + fb_device_groups,"fb%d" , node);if (IS_ERR (fb_info->dev)) {/* Not fatal */ ret =PTR_ERR (fb_info->dev);pr_warn ("Unable to create device for framebuffer %d; error %d\n" , node, ret); fb_info->dev =NULL ; - }else { -fb_init_device (fb_info); }return 0 ;
@@ -505,7 +476,6 @@ void fb_device_destroy(struct fb_info *fb_info)if (!fb_info->dev)return ; -fb_cleanup_device (fb_info);device_destroy (fb_class, devt); fb_info->dev =NULL ; }
include/linux/fb.h +0 -1
@@ -497,7 +497,6 @@ struct fb_info {#if defined(CONFIG_FB_DEVICE )struct device *dev;/* This is this fb device */ #endif -int class_flag;/* private sysfs flags */ #ifdef CONFIG_FB_TILEBLITTING struct fb_tile_ops *tileops;/* Tile Blitting */ #endif
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 720/752 fbcon: check return value of con2fb_acquire_newinfo()
In reply to Sasha LevinFrom: Andrey Vatoropin <[email protected]>
[ Upstream commit 011a0502801c8536f64141a2b61362c14f456544 ]
If fbcon_open() fails when called from con2fb_acquire_newinfo() then info->fbcon_par pointer remains NULL which is later dereferenced.
Add check for return value of the function con2fb_acquire_newinfo() to avoid it.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/video/fbdev/core/fbcon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon.c +2 -1
@@ -1047,7 +1047,8 @@ static void fbcon_init(struct vc_data *vc, bool init)return ;if (!info->fbcon_par) -con2fb_acquire_newinfo (vc, info, vc->vc_num); +if (con2fb_acquire_newinfo (vc, info, vc->vc_num)) +return ;/* If we are not the first console on this fb, copy the font from that console */
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 721/752 fbdev: vt8500lcdfb: fix missing dma_free_coherent()
In reply to Sasha LevinFrom: Thomas Fourier <[email protected]>
[ Upstream commit 88b3b9924337336a31cefbe99a22ed09401be74a ]
fbi->fb.screen_buffer is allocated with dma_alloc_coherent() but is not freed if the error path is reached.
--- drivers/video/fbdev/vt8500lcdfb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/video/fbdev/vt8500lcdfb.c +4 -1
@@ -369,7 +369,7 @@ static int vt8500lcd_probe(struct platform_device *pdev)if (fbi->palette_cpu ==NULL ) {dev_err (&pdev->dev,"Failed to allocate palette buffer\n" ); ret = -ENOMEM ; - goto failed_free_io; + goto failed_free_mem_virt; } irq =platform_get_irq (pdev,0 );
@@ -432,6 +432,9 @@ static int vt8500lcd_probe(struct platform_device *pdev) failed_free_palette:dma_free_coherent (&pdev->dev, fbi->palette_size, fbi->palette_cpu, fbi->palette_phys); +failed_free_mem_virt: +dma_free_coherent (&pdev->dev, fbi->fb.fix.smem_len, + fbi->fb.screen_buffer, fbi->fb.fix.smem_start); failed_free_io:iounmap (fbi->regbase); failed_free_res:
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 722/752 fbdev: of: display_timing: fix refcount leak in of_get_display_timings()
In reply to Sasha LevinFrom: Weigang He <[email protected]>
[ Upstream commit eacf9840ae1285a1ef47eb0ce16d786e542bd4d7 ]
of_parse_phandle() returns a device_node with refcount incremented, which is stored in 'entry' and then copied to 'native_mode'. When the error paths at lines 184 or 192 jump to 'entryfail', native_mode's refcount is not decremented, causing a refcount leak.
Fix this by changing the goto target from 'entryfail' to 'timingfail', which properly calls of_node_put(native_mode) before cleanup.
--- drivers/video/of_display_timing.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/video/of_display_timing.c +2 -2
@@ -181,7 +181,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np)if (disp->num_timings ==0 ) {/* should never happen, as entry was already found above */ pr_err ("%pOF: no timings specified\n" , np); - goto entryfail; + goto timingfail; } disp->timings = kcalloc(disp->num_timings,
@@ -189,7 +189,7 @@ struct display_timings *of_get_display_timings(const struct device_node *np) GFP_KERNEL);if (!disp->timings) {pr_err ("%pOF: could not allocate timings array\n" , np); - goto entryfail; + goto timingfail; } disp->num_timings =0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 723/752 fbdev: ffb: fix corrupted video output on Sun FFB1
In reply to Sasha LevinFrom: René Rebe <[email protected]>
[ Upstream commit b28da0d092461ac239ff034a8ac3129320177ba3 ]
Fix Sun FFB1 corrupted video out ([1] and [2]) by disabling overlay and initializing window mode to a known state. The issue never appeared on my FFB2+/vertical nor Elite3D/M6. It could also depend on the PROM version.
/SUNW,ffb@1e,0: FFB at 000001fc00000000, type 11, DAC pnum[236c] rev[10] manuf_rev[4] X (II) /dev/fb0: Detected FFB1, Z-buffer, Single-buffered.
X (II) /dev/fb0: BT9068 (PAC1) ramdac detected (with normal cursor control) X (II) /dev/fb0: Detected Creator/Creator3D
[1] https://www.instagram.com/p/DUTcSmSjSem/
[2] https://chaos.social/@ReneRebe/116023241660154102
--- drivers/video/fbdev/ffb.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/video/fbdev/ffb.c +13 -1
@@ -335,6 +335,9 @@ struct ffb_dac { };#define FFB_DAC_UCTRL 0x1001/* User Control */ +#define FFB_DAC_UCTRL_OVENAB 0x00000008/* Overlay Enable */ +#define FFB_DAC_UCTRL_WMODE 0x00000030/* Window Mode */ +#define FFB_DAC_UCTRL_WM_COMB 0x00000000/* Window Mode = Combined */ #define FFB_DAC_UCTRL_MANREV 0x00000f00/* 4-bit Manufacturing Revision */ #define FFB_DAC_UCTRL_MANREV_SHIFT 8#define FFB_DAC_TGEN 0x6000/* Timing Generator */
@@ -425,7 +428,7 @@ static void ffb_switch_from_graph(struct ffb_par *par) {struct ffb_fbc __iomem *fbc = par->fbc;struct ffb_dac __iomem *dac = par->dac; -unsigned long flags; +unsigned long flags, uctrl;spin_lock_irqsave (&par->lock, flags);FFBWait (par);
@@ -450,6 +453,15 @@ static void ffb_switch_from_graph(struct ffb_par *par)upa_writel ((FFB_DAC_CUR_CTRL_P0 |FFB_DAC_CUR_CTRL_P1 ), &dac->value2); +/* Disable overlay and window modes. */ +upa_writel (FFB_DAC_UCTRL , &dac->type); + uctrl =upa_readl (&dac->value); + uctrl &= ~FFB_DAC_UCTRL_WMODE ; + uctrl |=FFB_DAC_UCTRL_WM_COMB ; + uctrl &= ~FFB_DAC_UCTRL_OVENAB ; +upa_writel (FFB_DAC_UCTRL , &dac->type); +upa_writel (uctrl, &dac->value); +spin_unlock_irqrestore (&par->lock, flags); }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 724/752 fbcon: Remove struct fbcon_display.inverse
In reply to Sasha LevinFrom: Thomas Zimmermann <[email protected]>
[ Upstream commit 30baedeeeab524172abc0b58cb101e8df86b5be8 ]
The field inverse in struct fbcon_display is unused. Remove it.
--- drivers/video/fbdev/core/fbcon.h | 1 - 1 file changed, 1 deletion(-)
drivers/video/fbdev/core/fbcon.h +0 -1
@@ -30,7 +30,6 @@ struct fbcon_display {#ifdef CONFIG_FRAMEBUFFER_CONSOLE_LEGACY_ACCELERATION u_short scrollmode;/* Scroll Method, use fb_scrollmode() */ #endif -u_short inverse;/* != 0 text black on white as default */ short yscroll;/* Hardware scrolling */ int vrows;/* number of virtual rows */ int cursor_shape;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 725/752 io_uring/zcrx: fix sgtable leak on mapping failures
In reply to Sasha LevinFrom: Pavel Begunkov <[email protected]>
[ Upstream commit a983aae397767e9da931128ff2b5bf9066513ce3 ]
In an unlikely case when io_populate_area_dma() fails, which could only happen on a PAGE_POOL_32BIT_ARCH_WITH_64BIT_DMA machine, io_zcrx_map_area() will have an initialised and not freed table. It was supposed to be cleaned up in the error path, but !is_mapped prevents that.
--- io_uring/zcrx.c | 3 +++ 1 file changed, 3 insertions(+)
io_uring/zcrx.c +3 -0
@@ -287,6 +287,9 @@ static int io_zcrx_map_area(struct io_zcrx_ifq *ifq, struct io_zcrx_area *area) } ret =io_populate_area_dma (ifq, area); +if (ret && !area->mem.is_dmabuf) +dma_unmap_sgtable (ifq->dev, &area->mem.page_sg_table, +DMA_FROM_DEVICE ,IO_DMA_ATTR );if (ret ==0 ) area->is_mapped = true;return ret;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 726/752 cifs: some missing initializations on replay
In reply to Sasha LevinFrom: Shyam Prasad N <[email protected]>
[ Upstream commit 14f66f44646333d2bfd7ece36585874fd72f8286 ]
In several places in the code, we have a label to signify the start of the code where a request can be replayed if necessary. However, some of these places were missing the necessary reinitializations of certain local variables before replay.
This change makes sure that these variables get initialized after the label.
--- fs/smb/client/smb2ops.c | 2 ++ fs/smb/client/smb2pdu.c | 1 + 2 files changed, 3 insertions(+)
fs/smb/client/smb2ops.c +2 -0
@@ -1184,6 +1184,7 @@ smb2_set_ea(const unsigned int xid, struct cifs_tcon *tcon, replay_again:/* reinitialize for possible replay */ + used_len =0 ; flags =CIFS_CP_CREATE_CLOSE_OP ; oplock =SMB2_OPLOCK_LEVEL_NONE ; server =cifs_pick_channel (ses);
@@ -1582,6 +1583,7 @@ smb2_ioctl_query_info(const unsigned int xid, replay_again:/* reinitialize for possible replay */ + buffer =NULL ; flags =CIFS_CP_CREATE_CLOSE_OP ; oplock =SMB2_OPLOCK_LEVEL_NONE ; server =cifs_pick_channel (ses);
fs/smb/client/smb2pdu.c +1 -0
@@ -2845,6 +2845,7 @@ int smb311_posix_mkdir(const unsigned int xid, struct inode *inode, replay_again:/* reinitialize for possible replay */ + pc_buf =NULL ; flags =0 ; n_iov =2 ; server =cifs_pick_channel (ses);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 727/752 gpio: nomadik: Add missing IS_ERR() check
In reply to Sasha LevinFrom: Ethan Tidmore <[email protected]>
[ Upstream commit 58433885ee99e8c96757e82ccf6d50646c4dfe09 ]
The function gpio_device_get_desc() can return an error pointer and is not checked for one. Add check for error pointer.
--- drivers/gpio/gpio-nomadik.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpio/gpio-nomadik.c +3 -0
@@ -430,6 +430,9 @@ void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,#ifdef CONFIG_PINCTRL_NOMADIK if (mode ==NMK_GPIO_ALT_C && pctldev) { desc =gpio_device_get_desc (chip->gpiodev, offset); +if (IS_ERR (desc)) +return ; + mode =nmk_prcm_gpiocr_get_mode (pctldev,desc_to_gpio (desc)); }#endif
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 728/752 io_uring/cmd_net: fix too strict requirement on ioctl
In reply to Sasha LevinFrom: Asbjørn Sloth Tønnesen <[email protected]>
[ Upstream commit 600b665b903733bd60334e86031b157cc823ee55 ]
Attempting SOCKET_URING_OP_SETSOCKOPT on an AF_NETLINK socket resulted in an -EOPNOTSUPP, as AF_NETLINK doesn't have an ioctl in its struct proto, but only in struct proto_ops.
Prior to the blamed commit, io_uring_cmd_sock() only had two cmd_op operations, both requiring ioctl, thus the check was warranted.
Since then, 4 new cmd_op operations have been added, none of which depend on ioctl. This patch moves the ioctl check, so it only applies to the original operations.
AFAICT, the ioctl requirement was unintentional, and it wasn't visible in the blamed patch within 3 lines of context.
--- io_uring/cmd_net.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
io_uring/cmd_net.c +6 -3
@@ -139,16 +139,19 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)struct proto *prot =READ_ONCE (sk->sk_prot);int ret, arg =0 ; -if (!prot || !prot->ioctl) -return -EOPNOTSUPP ; -switch (cmd->cmd_op) {case SOCKET_URING_OP_SIOCINQ : +if (!prot || !prot->ioctl) +return -EOPNOTSUPP ; + ret = prot->ioctl (sk,SIOCINQ , &arg);if (ret)return ret;return arg;case SOCKET_URING_OP_SIOCOUTQ : +if (!prot || !prot->ioctl) +return -EOPNOTSUPP ; + ret = prot->ioctl (sk,SIOCOUTQ , &arg);if (ret)return ret;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 729/752 ASoC: amd: yc: Add DMI quirk for ASUS Vivobook Pro 15X M6501RR
In reply to Sasha LevinFrom: Gustavo Salvini <[email protected]>
[ Upstream commit ff9cadd1a2c0b2665b7377ac79540d66f212e7e3 ]
The ASUS Vivobook Pro 15X (M6501RR) with AMD Ryzen 9 6900HX has an internal DMIC that is not detected without a DMI quirk entry, as the BIOS does not set the AcpDmicConnected ACPI _DSD property.
Adding the DMI entry enables the ACP6x DMIC machine driver to probe successfully.
--- sound/soc/amd/yc/acp6x-mach.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/soc/amd/yc/acp6x-mach.c +7 -1
@@ -696,7 +696,13 @@ static const struct dmi_system_id yc_acp_quirk_table[] = { DMI_MATCH(DMI_BOARD_NAME, "XyloD5_RBU"), } }, - + { + .driver_data = &acp6x_card, + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "Vivobook_ASUSLaptop M6501RR_M6501RR"), + } + }, {} };
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 730/752 kbuild: rpm-pkg: Disable automatic requires for manual debuginfo package
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit f94711255a73d8938cf3bb405a0af3a4d2700ed1 ]
Stefano reports that after commit 62089b804895 ("kbuild: rpm-pkg:
Generate debuginfo package manually"), building with an rpm package using rpm 4.20.0 fails with:
RPM build errors:
Dependency tokens must begin with alpha-numeric, '_' or '/': #�) = 0x0d000002
Dependency tokens must begin with alpha-numeric, '_' or '/': �) = 0x0d000000
Dependency tokens must begin with alpha-numeric, '_' or '/': ) = 0x7c0e000000
Unknown rich dependency op 'Hat': (Red Hat 15.2.1-7)) = 0x3130363230322000
Unknown rich dependency op 'Hat': (Red Hat 15.2.1-7)) = 0x4728203a43434800
Unknown rich dependency op 'Hat': (Red Hat 15.2.1-7)) = 0x3130363230322000
Unknown rich dependency op 'Hat': (Red Hat 15.2.1-7)) = 0x4728203a43434800This error comes from the automatic requirements feature of rpm. The -debuginfo subpackage has no dependencies, so disable this feature with 'AutoReq: 0' for this subpackage, avoiding the error. This matches the official %_debug_template macro that rpm provides. While automatic provides should be default enabled, be explicit like %_debug_template does.
Additionally, while in the area, add the manual debug information package to the Development/Debug group, further aligning with %_debug_template.
--- scripts/package/kernel.spec | 3 +++ 1 file changed, 3 insertions(+)
scripts/package/kernel.spec +3 -0
@@ -48,6 +48,9 @@ against the %{version} kernel package. %if %{with_debuginfo_manual} %package debuginfo Summary: Debug information package for the Linux kernel +Group: Development/Debug +AutoReq: 0 +AutoProv: 1 %description debuginfo This package provides debug information for the kernel image and modules from the %{version} package.
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 731/752 drm/xe: Add bounds check on pat_index to prevent OOB kernel read in madvise
In reply to Sasha LevinFrom: Jia Yao <[email protected]>
[ Upstream commit fbbe32618e97eff81577a01eb7d9adcd64a216d7 ]
When user provides a bogus pat_index value through the madvise IOCTL, the xe_pat_index_get_coh_mode() function performs an array access without validating bounds. This allows a malicious user to trigger an out-of-bounds kernel read from the xe->pat.table array.
The vulnerability exists because the validation in madvise_args_are_sane() directly calls xe_pat_index_get_coh_mode(xe, args->pat_index.val) without first checking if pat_index is within [0, xe->pat.n_entries).
Although xe_pat_index_get_coh_mode() has a WARN_ON to catch this in debug builds, it still performs the unsafe array access in production kernels.
v2(Matthew Auld)
- Using array_index_nospec() to mitigate spectre attacks when the value is used
v3(Matthew Auld)
- Put the declarations at the start of the block
--- drivers/gpu/drm/xe/xe_vm_madvise.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_vm_madvise.c +6 -1
@@ -268,8 +268,13 @@ static bool madvise_args_are_sane(struct xe_device *xe, const struct drm_xe_madvbreak ;case DRM_XE_MEM_RANGE_ATTR_PAT : { -u16 coh_mode =xe_pat_index_get_coh_mode (xe, args->pat_index.val); +u16 pat_index, coh_mode; +if (XE_IOCTL_DBG (xe, args->pat_index.val >= xe->pat.n_entries)) +return false; + + pat_index =array_index_nospec (args->pat_index.val, xe->pat.n_entries); + coh_mode =xe_pat_index_get_coh_mode (xe, pat_index);if (XE_IOCTL_DBG (xe, !coh_mode))return false;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 732/752 net: ethernet: ec_bhf: Fix dma_free_coherent() dma handle
In reply to Sasha LevinFrom: Thomas Fourier <[email protected]>
[ Upstream commit ffe68c3766997d82e9ccaf1cdbd47eba269c4aa2 ]
dma_free_coherent() in error path takes priv->rx_buf.alloc_len as the dma handle. This would lead to improper unmapping of the buffer.
Change the dma handle to priv->rx_buf.alloc_phys.
--- drivers/net/ethernet/ec_bhf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/ec_bhf.c +1 -1
@@ -423,7 +423,7 @@ static int ec_bhf_open(struct net_device *net_dev) error_rx_free:dma_free_coherent (dev, priv->rx_buf.alloc_len, priv->rx_buf.alloc, - priv->rx_buf.alloc_len); + priv->rx_buf.alloc_phys); out:return err; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 733/752 net/sched: act_skbedit: fix divide-by-zero in tcf_skbedit_hash()
In reply to Sasha LevinFrom: Ruitong Liu <[email protected]>
[ Upstream commit be054cc66f739a9ba615dba9012a07fab8e7dd6f ]
Commit 38a6f0865796 ("net: sched: support hash selecting tx queue") added SKBEDIT_F_TXQ_SKBHASH support. The inclusive range size is computed as:
mapping_mod = queue_mapping_max - queue_mapping + 1;
The range size can be 65536 when the requested range covers all possible u16 queue IDs (e.g. queue_mapping=0 and queue_mapping_max=U16_MAX). That value cannot be represented in a u16 and previously wrapped to 0, so tcf_skbedit_hash() could trigger a divide-by-zero:
queue_mapping += skb_get_hash(skb) % params->mapping_mod;
Compute mapping_mod in a wider type and reject ranges larger than U16_MAX to prevent params->mapping_mod from becoming 0 and avoid the crash.
--- net/sched/act_skbedit.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
net/sched/act_skbedit.c +5 -1
@@ -126,7 +126,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,struct tcf_skbedit *d;u32 flags =0 , *priority =NULL , *mark =NULL , *mask =NULL ;u16 *queue_mapping =NULL , *ptype =NULL ; -u16 mapping_mod =1 ; +u32 mapping_mod =1 ;bool exists = false;int ret =0 , err;u32 index;
@@ -194,6 +194,10 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, } mapping_mod = *queue_mapping_max - *queue_mapping +1 ; +if (mapping_mod >U16_MAX ) { +NL_SET_ERR_MSG_MOD (extack,"The range of queue_mapping is invalid." ); +return -EINVAL ; + } flags |=SKBEDIT_F_TXQ_SKBHASH ; }if (*pure_flags &SKBEDIT_F_INHERITDSFIELD )
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 734/752 gpio: sysfs: fix chip removal with GPIOs exported over sysfs
In reply to Sasha LevinFrom: Bartosz Golaszewski <[email protected]>
[ Upstream commit 6766f59012301f1bf3f46c6e7149caca45d92309 ]
Currently if we export a GPIO over sysfs and unbind the parent GPIO controller, the exported attribute will remain under /sys/class/gpio because once we remove the parent device, we can no longer associate the descriptor with it in gpiod_unexport() and never drop the final reference.
Rework the teardown code: provide an unlocked variant of gpiod_unexport() and remove all exported GPIOs with the sysfs_lock taken before unregistering the parent device itself. This is done to prevent any new exports happening before we unregister the device completely.
--- drivers/gpio/gpiolib-sysfs.c | 106 ++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 51 deletions(-)
drivers/gpio/gpiolib-sysfs.c +55 -51
@@ -919,63 +919,68 @@ int gpiod_export_link(struct device *dev, const char *name, }EXPORT_SYMBOL_GPL (gpiod_export_link); -/** -* gpiod_unexport - reverse effect of gpiod_export() -* @desc: GPIO to make unavailable -* -* This is implicit on gpiod_free(). -*/ -void gpiod_unexport (struct gpio_desc *desc) +static void gpiod_unexport_unlocked (struct gpio_desc *desc) {struct gpiod_data *tmp, *desc_data =NULL ;struct gpiodev_data *gdev_data;struct gpio_device *gdev; -if (!desc) { -pr_warn ("%s: invalid GPIO\n" , __func__); +if (!test_bit (GPIOD_FLAG_EXPORT , &desc->flags))return ; - } - scoped_guard(mutex, &sysfs_lock) { -if (!test_bit (GPIOD_FLAG_EXPORT , &desc->flags)) -return ; - - gdev =gpiod_to_gpio_device (desc); - gdev_data =gdev_get_data (gdev); -if (!gdev_data) -return ; + gdev =gpiod_to_gpio_device (desc); + gdev_data =gdev_get_data (gdev); +if (!gdev_data) +return ; -list_for_each_entry (tmp, &gdev_data->exported_lines, list) { -if (gpiod_is_equal (desc, tmp->desc)) { - desc_data = tmp; -break ; - } +list_for_each_entry (tmp, &gdev_data->exported_lines, list) { +if (gpiod_is_equal (desc, tmp->desc)) { + desc_data = tmp; +break ; } + } -if (!desc_data) -return ; +if (!desc_data) +return ; -list_del (&desc_data->list); -clear_bit (GPIOD_FLAG_EXPORT , &desc->flags); +list_del (&desc_data->list); +clear_bit (GPIOD_FLAG_EXPORT , &desc->flags);#if IS_ENABLED (CONFIG_GPIO_SYSFS_LEGACY ) -sysfs_put (desc_data->value_kn); -device_unregister (desc_data->dev); - -/* -* Release irq after deregistration to prevent race with -* edge_store. -*/ -if (desc_data->irq_flags) -gpio_sysfs_free_irq (desc_data); +sysfs_put (desc_data->value_kn); +device_unregister (desc_data->dev); + +/* +* Release irq after deregistration to prevent race with +* edge_store. +*/ +if (desc_data->irq_flags) +gpio_sysfs_free_irq (desc_data);#endif /* CONFIG_GPIO_SYSFS_LEGACY */ -sysfs_remove_groups (desc_data->parent, - desc_data->chip_attr_groups); - } +sysfs_remove_groups (desc_data->parent, + desc_data->chip_attr_groups);mutex_destroy (&desc_data->mutex);kfree (desc_data); } + +/** +* gpiod_unexport - reverse effect of gpiod_export() +* @desc: GPIO to make unavailable +* +* This is implicit on gpiod_free(). +*/ +void gpiod_unexport (struct gpio_desc *desc) +{ +if (!desc) { +pr_warn ("%s: invalid GPIO\n" , __func__); +return ; + } + +guard (mutex)(&sysfs_lock); + +gpiod_unexport_unlocked (desc); +}EXPORT_SYMBOL_GPL (gpiod_unexport);int gpiochip_sysfs_register (struct gpio_device *gdev)
@@ -1054,29 +1059,28 @@ void gpiochip_sysfs_unregister(struct gpio_device *gdev)struct gpio_desc *desc;struct gpio_chip *chip; - scoped_guard(mutex, &sysfs_lock) { - data =gdev_get_data (gdev); -if (!data) -return ; +guard (mutex)(&sysfs_lock); -#if IS_ENABLED (CONFIG_GPIO_SYSFS_LEGACY ) -device_unregister (data->cdev_base); -#endif /* CONFIG_GPIO_SYSFS_LEGACY */ -device_unregister (data->cdev_id); -kfree (data); - } + data =gdev_get_data (gdev); +if (!data) +return ;guard (srcu)(&gdev->srcu); - chip =srcu_dereference (gdev->chip, &gdev->srcu);if (!chip)return ;/* unregister gpiod class devices owned by sysfs */ for_each_gpio_desc_with_flag (chip, desc,GPIOD_FLAG_SYSFS ) { -gpiod_unexport (desc); +gpiod_unexport_unlocked (desc);gpiod_free (desc); } + +#if IS_ENABLED (CONFIG_GPIO_SYSFS_LEGACY ) +device_unregister (data->cdev_base); +#endif /* CONFIG_GPIO_SYSFS_LEGACY */ +device_unregister (data->cdev_id); +kfree (data); }/*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 735/752 x86/kexec: Copy ACPI root pointer address from config table
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit e00ac9e5afb5d80c0168ec88d8e8662a54af8249 ]
Dave reports that kexec may fail when the first kernel boots via the EFI stub but without EFI runtime services, as in that case, the RSDP address field in struct bootparams is never assigned. Kexec copies this value into the version of struct bootparams that it provides to the incoming kernel, which may have no other means to locate the ACPI root pointer.
So take the value from the EFI config tables if no root pointer has been set in the first kernel's struct bootparams.
--- arch/x86/kernel/kexec-bzimage64.c | 7 +++++++ 1 file changed, 7 insertions(+)
arch/x86/kernel/kexec-bzimage64.c +7 -0
@@ -192,6 +192,13 @@ setup_efi_state(struct boot_params *params, unsigned long params_load_addr,struct efi_info *current_ei = &boot_params.efi_info;struct efi_info *ei = ¶ms->efi_info; +if (!params->acpi_rsdp_addr) { +if (efi.acpi20 !=EFI_INVALID_TABLE_ADDR ) + params->acpi_rsdp_addr = efi.acpi20; +else if (efi.acpi !=EFI_INVALID_TABLE_ADDR ) + params->acpi_rsdp_addr = efi.acpi; + } +if (!efi_enabled (EFI_RUNTIME_SERVICES ))return 0 ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 736/752 io_uring/zcrx: fix user_ref race between scrub and refill paths
In reply to Sasha LevinFrom: Kai Aizen <[email protected]>
[ Upstream commit 003049b1c4fb8aabb93febb7d1e49004f6ad653b ]
The io_zcrx_put_niov_uref() function uses a non-atomic check-then-decrement pattern (atomic_read followed by separate atomic_dec) to manipulate user_refs. This is serialized against other callers by rq_lock, but io_zcrx_scrub() modifies the same counter with atomic_xchg() WITHOUT holding rq_lock.
On SMP systems, the following race exists:
CPU0 (refill, holds rq_lock) CPU1 (scrub, no rq_lock)
put_niov_uref:
atomic_read(uref) - 1
// window opens
atomic_xchg(uref, 0) - 1 return_niov_freelist(niov) [PUSH #1]
// window closes
atomic_dec(uref) - wraps to -1
returns true
return_niov(niov)
return_niov_freelist(niov) [PUSH #2: DOUBLE-FREE]
The same niov is pushed to the freelist twice, causing free_count to exceed nr_iovs. Subsequent freelist pushes then perform an out-of-bounds write (a u32 value) past the kvmalloc'd freelist array into the adjacent slab object.
Fix this by replacing the non-atomic read-then-dec in io_zcrx_put_niov_uref() with an atomic_try_cmpxchg loop that atomically tests and decrements user_refs. This makes the operation safe against concurrent atomic_xchg from scrub without requiring scrub to acquire rq_lock.
--- io_uring/zcrx.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
io_uring/zcrx.c +7 -3
@@ -336,10 +336,14 @@ static inline atomic_t *io_get_user_counter(struct net_iov *niov)static bool io_zcrx_put_niov_uref (struct net_iov *niov) {atomic_t *uref =io_get_user_counter (niov); +int old; + + old =atomic_read (uref); +do { +if (unlikely (old ==0 )) +return false; + }while (!atomic_try_cmpxchg (uref, &old, old -1 )); -if (unlikely (!atomic_read (uref))) -return false; -atomic_dec (uref);return true; }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 737/752 rust: irq: add `'static` bounds to irq callbacks
In reply to Sasha LevinFrom: Benno Lossin <[email protected]>
[ Upstream commit 621609f1e5ca43a75edd497dd1c28bd84aa66433 ]
These callback functions take a generic T that is used in the body as the generic argument in Registration and ThreadedRegistration. Those types require T: 'static, but due to a compiler bug this requirement isn't propagated to the function. Thus add the bound. This was caught in the upstream Rust CI [1].
[ The three errors looked similar and will start appearing with Rust
1.95.0 (expected 2026-04-16). The first one was:
error[E0310]: the parameter type `T` may not live long enough
Error: --> rust/kernel/irq/request.rs:266:43
|
266 | let registration = unsafe { &*(ptr as *const Registration<T>) };
| ^^^^^^^^^^^^^^^^^^^^^^
| |
| the parameter type `T` must be valid for the static lifetime...
| ...so that the type `T` will meet its required lifetime bounds
|
help: consider adding an explicit lifetime bound
|
264 | unsafe extern "C" fn handle_irq_callback<T: Handler + 'static>(_irq: i32, ptr: *mut c_void) -> c_uint {
| +++++++++
- Miguel ]--- rust/kernel/irq/request.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
rust/kernel/irq/request.rs +9 -3
@@ -261,7 +261,10 @@ impl<T: Handler + 'static> Registration<T> {/// # Safety /// /// This function should be only used as the callback in `request_irq`. -unsafe extern "C" fn handle_irq_callback <T :Handler >(_irq:i32 , ptr: *mut c_void ) ->c_uint { +unsafe extern "C" fn handle_irq_callback <T :Handler + 'static>( + _irq:i32 , + ptr: *mut c_void , +) ->c_uint {// SAFETY: `ptr` is a pointer to `Registration<T>` set in `Registration::new` let registration =unsafe { &*(ptras *const Registration <T >) };// SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq
@@ -480,7 +483,7 @@ impl<T: ThreadedHandler + 'static> ThreadedRegistration<T> {/// # Safety /// /// This function should be only used as the callback in `request_threaded_irq`. -unsafe extern "C" fn handle_threaded_irq_callback <T :ThreadedHandler >( +unsafe extern "C" fn handle_threaded_irq_callback <T :ThreadedHandler + 'static>( _irq:i32 , ptr: *mut c_void , ) ->c_uint {
@@ -496,7 +499,10 @@ unsafe extern "C" fn handle_threaded_irq_callback<T: ThreadedHandler>(/// # Safety /// /// This function should be only used as the callback in `request_threaded_irq`. -unsafe extern "C" fn thread_fn_callback <T :ThreadedHandler >(_irq:i32 , ptr: *mut c_void ) ->c_uint { +unsafe extern "C" fn thread_fn_callback <T :ThreadedHandler + 'static>( + _irq:i32 , + ptr: *mut c_void , +) ->c_uint {// SAFETY: `ptr` is a pointer to `ThreadedRegistration<T>` set in `ThreadedRegistration::new` let registration =unsafe { &*(ptras *const ThreadedRegistration <T >) };// SAFETY: The irq callback is removed before the device is unbound, so the fact that the irq
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 738/752 rust: pin-init: replace clippy `expect` with `allow`
In reply to Sasha LevinFrom: Benno Lossin <[email protected]>
[ Upstream commit a58b8764aed9648357b1c5b6368c9943ba33b7f9 ]
clippy has changed behavior in [1] (Rust 1.95) where it no longer warns about the let_and_return lint when a comment is placed between the let binding and the return expression. Nightly thus fails to build, because the expectation is no longer fulfilled.
Thus replace the expectation with an allow.
[ The errors were:
error: this lint expectation is unfulfilled
--> rust/pin-init/src/lib.rs:1279:10
|
1279 | #[expect(clippy::let_and_return)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D unfulfilled-lint-expectations` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]`
error: this lint expectation is unfulfilled
--> rust/pin-init/src/lib.rs:1295:10
|
1295 | #[expect(clippy::let_and_return)]
| ^^^^^^^^^^^^^^^^^^^^^^
- Miguel ]--- rust/pin-init/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
rust/pin-init/src/lib.rs +2 -2
@@ -1276,13 +1276,13 @@ pub const unsafe fn init_from_closure<T: ?Sized, E>(/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_pin_init <T ,U ,E >(init:impl PinInit <T ,E >) ->impl PinInit <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {pin_init_from_closure (|ptr: *mut U | init.__pinned_init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] res }
@@ -1292,13 +1292,13 @@ pub const unsafe fn cast_pin_init<T, U, E>(init: impl PinInit<T, E>) -> impl Pin/// /// - `*mut U` must be castable to `*mut T` and any value of type `T` written through such a /// pointer must result in a valid `U`. -#[expect(clippy::let_and_return)] pub const unsafe fn cast_init <T ,U ,E >(init:impl Init <T ,E >) ->impl Init <U ,E > {// SAFETY: initialization delegated to a valid initializer. Cast is valid by function safety // requirements. let res =unsafe {init_from_closure (|ptr: *mut U | init.__init (ptr.cast ::<T >())) };// FIXME: remove the let statement once the nightly-MSRV allows it (1.78 otherwise encounters a // cycle when computing the type returned by this function) +#[allow(clippy::let_and_return)] res }
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 739/752 arm64: Force the use of CNTVCT_EL0 in __delay()
In reply to Sasha LevinFrom: Marc Zyngier <[email protected]>
[ Upstream commit 29cc0f3aa7c64d3b3cb9d94c0a0984ba6717bf72 ]
Quentin forwards a report from Hyesoo Yu, describing an interesting problem with the use of WFxT in __delay() when a vcpu is loaded and that KVM is *not* in VHE mode (either nVHE or hVHE).
In this case, CNTVOFF_EL2 is set to a non-zero value to reflect the state of the guest virtual counter. At the same time, __delay() is using get_cycles() to read the counter value, which is indirected to reading CNTPCT_EL0.
The core of the issue is that WFxT is using the *virtual* counter, while the kernel is using the physical counter, and that the offset introduces a really bad discrepancy between the two.
Fix this by forcing the use of CNTVCT_EL0, making __delay() consistent irrespective of the value of CNTVOFF_EL2.
--- arch/arm64/lib/delay.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-)
arch/arm64/lib/delay.c +15 -4
@@ -23,9 +23,20 @@ static inline unsigned long xloops_to_cycles(unsigned long xloops)return (xloops * loops_per_jiffy *HZ ) >>32 ; } +/* +* Force the use of CNTVCT_EL0 in order to have the same base as WFxT. +* This avoids some annoying issues when CNTVOFF_EL2 is not reset 0 on a +* KVM host running at EL1 until we do a vcpu_put() on the vcpu. When +* running at EL2, the effective offset is always 0. +* +* Note that userspace cannot change the offset behind our back either, +* as the vcpu mutex is held as long as KVM_RUN is in progress. +*/ +#define __delay_cycles () __arch_counter_get_cntvct_stable() +void __delay (unsigned long cycles) { -cycles_t start =get_cycles (); +cycles_t start =__delay_cycles ();if (alternative_has_cap_unlikely (ARM64_HAS_WFXT )) {u64 end = start + cycles;
@@ -35,17 +46,17 @@ void __delay(unsigned long cycles)* early, use a WFET loop to complete the delay. */ wfit (end); -while ((get_cycles () - start) < cycles) +while ((__delay_cycles () - start) < cycles)wfet (end); }else if (arch_timer_evtstrm_available ()) {const cycles_t timer_evt_period =USECS_TO_CYCLES (ARCH_TIMER_EVT_STREAM_PERIOD_US ); -while ((get_cycles () - start + timer_evt_period) < cycles) +while ((__delay_cycles () - start + timer_evt_period) < cycles)wfe (); } -while ((get_cycles () - start) < cycles) +while ((__delay_cycles () - start) < cycles)cpu_relax (); }EXPORT_SYMBOL (__delay);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 740/752 drm/amd/display: Correct logic check error for fastboot
In reply to Sasha LevinFrom: Charlene Liu <[email protected]>
[ Upstream commit b6a65009e7ce3f0cc72da18f186adb60717b51a0 ]
[Why]
Fix fastboot broken in driver.
This is caused by an open source backport change 7495962c.
from the comment, the intended check is to disable fastboot for pre-DCN10. but the logic check is reversed, and causes fastboot to be disabled on all DCN10 and after.
fastboot is for driver trying to pick up bios used hw setting and bypass reprogramming the hw if dc_validate_boot_timing() condition meets.
--- drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/hwss/dce110/dce110_hwseq.c +2 -2
@@ -1933,8 +1933,8 @@ void dce110_enable_accelerated_mode(struct dc *dc, struct dc_state *context)get_edp_streams (context, edp_streams, &edp_stream_num); -/* Check fastboot support, disable on DCE 6-8 because of blank screens */ -if (edp_num && edp_stream_num && dc->ctx->dce_version <DCE_VERSION_10_0 ) { +/* Check fastboot support, disable on DCE 6-8-10 because of blank screens */ +if (edp_num && edp_stream_num && dc->ctx->dce_version >DCE_VERSION_10_0 ) {for (i =0 ; i < edp_num; i++) { edp_link = edp_links[i];if (edp_link != edp_streams[0 ]->link)
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 741/752 drm/amdgpu: keep vga memory on MacBooks with switchable graphics
In reply to Sasha LevinFrom: Alex Deucher <[email protected]>
[ Upstream commit 096bb75e13cc508d3915b7604e356bcb12b17766 ]
On Intel MacBookPros with switchable graphics, when the iGPU is enabled, the address of VRAM gets put at 0 in the dGPU's virtual address space. This is non-standard and seems to cause issues with the cursor if it ends up at 0. We have the framework to reserve memory at 0 in the address space, so enable it here if the vram start address is 0.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_gmc.c +10 -0
@@ -1013,6 +1013,16 @@ void amdgpu_gmc_get_vbios_allocations(struct amdgpu_device *adev)case CHIP_RENOIR : adev->mman.keep_stolen_vga_memory = true;break ; +case CHIP_POLARIS10 : +case CHIP_POLARIS11 : +case CHIP_POLARIS12 : +/* MacBookPros with switchable graphics put VRAM at 0 when +* the iGPU is enabled which results in cursor issues if +* the cursor ends up at 0. Reserve vram at 0 in that case. +*/ +if (adev->gmc.vram_start ==0 ) + adev->mman.keep_stolen_vga_memory = true; +break ;default : adev->mman.keep_stolen_vga_memory = false;break ;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 742/752 net: nfc: nci: Fix parameter validation for packet data
In reply to Sasha LevinFrom: Michael Thalmeier <[email protected]>
[ Upstream commit 571dcbeb8e635182bb825ae758399831805693c2 ]
Since commit 9c328f54741b ("net: nfc: nci: Add parameter validation for packet data") communication with nci nfc chips is not working any more.
The mentioned commit tries to fix access of uninitialized data, but failed to understand that in some cases the data packet is of variable length and can therefore not be compared to the maximum packet length given by the sizeof(struct).
--- net/nfc/nci/ntf.c | 159 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 141 insertions(+), 18 deletions(-)
net/nfc/nci/ntf.c +141 -18
@@ -58,7 +58,7 @@ static int nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,struct nci_conn_info *conn_info;int i; -if (skb->len <sizeof (struct nci_core_conn_credit_ntf )) + if (skb->len < offsetofend(struct nci_core_conn_credit_ntf, num_entries))return -EINVAL ; ntf = (struct nci_core_conn_credit_ntf *)skb->data;
@@ -68,6 +68,10 @@ static int nci_core_conn_credits_ntf_packet(struct nci_dev *ndev,if (ntf->num_entries >NCI_MAX_NUM_CONN ) ntf->num_entries =NCI_MAX_NUM_CONN ; + if (skb->len < offsetofend(struct nci_core_conn_credit_ntf, num_entries) + + ntf->num_entries *sizeof (struct conn_credit_entry )) +return -EINVAL ; +/* update the credits */ for (i =0 ; i < ntf->num_entries; i++) { ntf->conn_entries[i].conn_id =
@@ -138,23 +142,48 @@ static int nci_core_conn_intf_error_ntf_packet(struct nci_dev *ndev,static const __u8 *nci_extract_rf_params_nfca_passive_poll (struct nci_dev *ndev,struct rf_tech_specific_params_nfca_poll *nfca_poll, -const __u8 *data) +const __u8 *data,ssize_t data_len) { +/* Check if we have enough data for sens_res (2 bytes) */ +if (data_len <2 ) +return ERR_PTR (-EINVAL ); + nfca_poll->sens_res =__le16_to_cpu (*((__le16 *)data)); data +=2 ; + data_len -=2 ; + +/* Check if we have enough data for nfcid1_len (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); nfca_poll->nfcid1_len =min_t (__u8, *data++,NFC_NFCID1_MAXSIZE ); + data_len--;pr_debug ("sens_res 0x%x, nfcid1_len %d\n" , nfca_poll->sens_res, nfca_poll->nfcid1_len); +/* Check if we have enough data for nfcid1 */ +if (data_len < nfca_poll->nfcid1_len) +return ERR_PTR (-EINVAL ); +memcpy (nfca_poll->nfcid1, data, nfca_poll->nfcid1_len); data += nfca_poll->nfcid1_len; + data_len -= nfca_poll->nfcid1_len; + +/* Check if we have enough data for sel_res_len (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); nfca_poll->sel_res_len = *data++; + data_len--; + +if (nfca_poll->sel_res_len !=0 ) { +/* Check if we have enough data for sel_res (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); -if (nfca_poll->sel_res_len !=0 ) nfca_poll->sel_res = *data++; + } pr_debug("sel_res_len %d, sel_res 0x%x\n", nfca_poll->sel_res_len,
@@ -166,12 +195,21 @@ nci_extract_rf_params_nfca_passive_poll(struct nci_dev *ndev,static const __u8 *nci_extract_rf_params_nfcb_passive_poll (struct nci_dev *ndev,struct rf_tech_specific_params_nfcb_poll *nfcb_poll, -const __u8 *data) +const __u8 *data,ssize_t data_len) { +/* Check if we have enough data for sensb_res_len (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); + nfcb_poll->sensb_res_len =min_t (__u8, *data++,NFC_SENSB_RES_MAXSIZE ); + data_len--;pr_debug ("sensb_res_len %d\n" , nfcb_poll->sensb_res_len); +/* Check if we have enough data for sensb_res */ +if (data_len < nfcb_poll->sensb_res_len) +return ERR_PTR (-EINVAL ); +memcpy (nfcb_poll->sensb_res, data, nfcb_poll->sensb_res_len); data += nfcb_poll->sensb_res_len;
@@ -181,14 +219,29 @@ nci_extract_rf_params_nfcb_passive_poll(struct nci_dev *ndev,static const __u8 *nci_extract_rf_params_nfcf_passive_poll (struct nci_dev *ndev,struct rf_tech_specific_params_nfcf_poll *nfcf_poll, -const __u8 *data) +const __u8 *data,ssize_t data_len) { +/* Check if we have enough data for bit_rate (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); + nfcf_poll->bit_rate = *data++; + data_len--; + +/* Check if we have enough data for sensf_res_len (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); + nfcf_poll->sensf_res_len =min_t (__u8, *data++,NFC_SENSF_RES_MAXSIZE ); + data_len--;pr_debug ("bit_rate %d, sensf_res_len %d\n" , nfcf_poll->bit_rate, nfcf_poll->sensf_res_len); +/* Check if we have enough data for sensf_res */ +if (data_len < nfcf_poll->sensf_res_len) +return ERR_PTR (-EINVAL ); +memcpy (nfcf_poll->sensf_res, data, nfcf_poll->sensf_res_len); data += nfcf_poll->sensf_res_len;
@@ -198,22 +251,49 @@ nci_extract_rf_params_nfcf_passive_poll(struct nci_dev *ndev,static const __u8 *nci_extract_rf_params_nfcv_passive_poll (struct nci_dev *ndev,struct rf_tech_specific_params_nfcv_poll *nfcv_poll, -const __u8 *data) +const __u8 *data,ssize_t data_len) { +/* Skip 1 byte (reserved) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); + ++data; + data_len--; + +/* Check if we have enough data for dsfid (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); + nfcv_poll->dsfid = *data++; + data_len--; + +/* Check if we have enough data for uid (8 bytes) */ +if (data_len <NFC_ISO15693_UID_MAXSIZE ) +return ERR_PTR (-EINVAL ); +memcpy (nfcv_poll->uid, data,NFC_ISO15693_UID_MAXSIZE ); data +=NFC_ISO15693_UID_MAXSIZE ; +return data; }static const __u8 *nci_extract_rf_params_nfcf_passive_listen (struct nci_dev *ndev,struct rf_tech_specific_params_nfcf_listen *nfcf_listen, -const __u8 *data) +const __u8 *data,ssize_t data_len) { +/* Check if we have enough data for local_nfcid2_len (1 byte) */ +if (data_len <1 ) +return ERR_PTR (-EINVAL ); + nfcf_listen->local_nfcid2_len =min_t (__u8, *data++,NFC_NFCID2_MAXSIZE ); + data_len--; + +/* Check if we have enough data for local_nfcid2 */ +if (data_len < nfcf_listen->local_nfcid2_len) +return ERR_PTR (-EINVAL ); +memcpy (nfcf_listen->local_nfcid2, data, nfcf_listen->local_nfcid2_len); data += nfcf_listen->local_nfcid2_len;
@@ -364,7 +444,7 @@ static int nci_rf_discover_ntf_packet(struct nci_dev *ndev,const __u8 *data;bool add_target = true; -if (skb->len <sizeof (struct nci_rf_discover_ntf )) + if (skb->len < offsetofend(struct nci_rf_discover_ntf, rf_tech_specific_params_len))return -EINVAL ; data = skb->data;
@@ -380,26 +460,42 @@ static int nci_rf_discover_ntf_packet(struct nci_dev *ndev,pr_debug ("rf_tech_specific_params_len %d\n" , ntf.rf_tech_specific_params_len); +if (skb->len < (data - skb->data) + + ntf.rf_tech_specific_params_len +sizeof (ntf.ntf_type)) +return -EINVAL ; +if (ntf.rf_tech_specific_params_len >0 ) {switch (ntf.rf_tech_and_mode) {case NCI_NFC_A_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfca_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfca_poll), data); + &(ntf.rf_tech_specific_params.nfca_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return PTR_ERR (data);break ;case NCI_NFC_B_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfcb_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfcb_poll), data); + &(ntf.rf_tech_specific_params.nfcb_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return PTR_ERR (data);break ;case NCI_NFC_F_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfcf_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfcf_poll), data); + &(ntf.rf_tech_specific_params.nfcf_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return PTR_ERR (data);break ;case NCI_NFC_V_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfcv_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfcv_poll), data); + &(ntf.rf_tech_specific_params.nfcv_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return PTR_ERR (data);break ;default :
@@ -596,7 +692,7 @@ static int nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,const __u8 *data;int err =NCI_STATUS_OK ; -if (skb->len <sizeof (struct nci_rf_intf_activated_ntf )) + if (skb->len < offsetofend(struct nci_rf_intf_activated_ntf, rf_tech_specific_params_len))return -EINVAL ; data = skb->data;
@@ -628,26 +724,41 @@ static int nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,if (ntf.rf_interface ==NCI_RF_INTERFACE_NFCEE_DIRECT ) goto listen; +if (skb->len < (data - skb->data) + ntf.rf_tech_specific_params_len) +return -EINVAL ; +if (ntf.rf_tech_specific_params_len >0 ) {switch (ntf.activation_rf_tech_and_mode) {case NCI_NFC_A_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfca_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfca_poll), data); + &(ntf.rf_tech_specific_params.nfca_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return -EINVAL ;break ;case NCI_NFC_B_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfcb_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfcb_poll), data); + &(ntf.rf_tech_specific_params.nfcb_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return -EINVAL ;break ;case NCI_NFC_F_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfcf_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfcf_poll), data); + &(ntf.rf_tech_specific_params.nfcf_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return -EINVAL ;break ;case NCI_NFC_V_PASSIVE_POLL_MODE : data =nci_extract_rf_params_nfcv_passive_poll (ndev, - &(ntf.rf_tech_specific_params.nfcv_poll), data); + &(ntf.rf_tech_specific_params.nfcv_poll), data, + ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return -EINVAL ;break ;case NCI_NFC_A_PASSIVE_LISTEN_MODE :
@@ -657,7 +768,9 @@ static int nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,case NCI_NFC_F_PASSIVE_LISTEN_MODE : data =nci_extract_rf_params_nfcf_passive_listen (ndev, &(ntf.rf_tech_specific_params.nfcf_listen), - data); + data, ntf.rf_tech_specific_params_len); +if (IS_ERR (data)) +return -EINVAL ;break ;default :
@@ -668,6 +781,13 @@ static int nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev, } } +if (skb->len < (data - skb->data) + +sizeof (ntf.data_exch_rf_tech_and_mode) + +sizeof (ntf.data_exch_tx_bit_rate) + +sizeof (ntf.data_exch_rx_bit_rate) + +sizeof (ntf.activation_params_len)) +return -EINVAL ; + ntf.data_exch_rf_tech_and_mode = *data++; ntf.data_exch_tx_bit_rate = *data++; ntf.data_exch_rx_bit_rate = *data++;
@@ -679,6 +799,9 @@ static int nci_rf_intf_activated_ntf_packet(struct nci_dev *ndev,pr_debug ("data_exch_rx_bit_rate 0x%x\n" , ntf.data_exch_rx_bit_rate);pr_debug ("activation_params_len %d\n" , ntf.activation_params_len); +if (skb->len < (data - skb->data) + ntf.activation_params_len) +return -EINVAL ; +if (ntf.activation_params_len >0 ) {switch (ntf.rf_interface) {case NCI_RF_INTERFACE_ISO_DEP :
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 743/752 ring-buffer: Fix possible dereference of uninitialized pointer
In reply to Sasha LevinFrom: Daniil Dulov <[email protected]>
[ Upstream commit f1547779402c4cd67755c33616b7203baa88420b ]
There is a pointer head_page in rb_meta_validate_events() which is not initialized at the beginning of a function. This pointer can be dereferenced if there is a failure during reader page validation. In this case the control is passed to "invalid" label where the pointer is dereferenced in a loop.
To fix the issue initialize orig_head and head_page before calling rb_validate_buffer.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- kernel/trace/ring_buffer.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +2 -1
@@ -1883,6 +1883,8 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)if (!meta || !meta->head_buffer)return ; + orig_head = head_page = cpu_buffer->head_page; +/* Do the reader page first */ ret =rb_validate_buffer (cpu_buffer->reader_page->page, cpu_buffer->cpu);if (ret <0 ) {
@@ -1893,7 +1895,6 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer) entry_bytes +=local_read (&cpu_buffer->reader_page->page->commit);local_set (&cpu_buffer->reader_page->entries, ret); - orig_head = head_page = cpu_buffer->head_page; ts = head_page->page->time_stamp;/*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 744/752 tracing: ring-buffer: Fix to check event length before using
In reply to Sasha LevinFrom: "Masami Hiramatsu (Google)" <[email protected]>
[ Upstream commit 912b0ee248c529a4f45d1e7f568dc1adddbf2a4a ]
Check the event length before adding it for accessing next index in rb_read_data_buffer(). Since this function is used for validating possibly broken ring buffers, the length of the event could be broken. In that case, the new event (e + len) can point a wrong address. To avoid invalid memory access at boot, check whether the length of each event is in the possible range before using it.
--- kernel/trace/ring_buffer.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
kernel/trace/ring_buffer.c +5 -1
@@ -1813,6 +1813,7 @@ static int rb_read_data_buffer(struct buffer_data_page *dpage, int tail, int cpustruct ring_buffer_event *event;u64 ts, delta;int events =0 ; +int len;int e; *delta_ptr =0 ;
@@ -1820,9 +1821,12 @@ static int rb_read_data_buffer(struct buffer_data_page *dpage, int tail, int cpu ts = dpage->time_stamp; -for (e =0 ; e < tail; e +=rb_event_length (event)) { +for (e =0 ; e < tail; e += len) { event = (struct ring_buffer_event *)(dpage->data + e); + len =rb_event_length (event); +if (len <=0 || len > tail - e) +return -1 ;switch (event->type_len) {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 745/752 fgraph: Do not call handlers direct when not using ftrace_ops
In reply to Sasha LevinFrom: Steven Rostedt <[email protected]>
[ Upstream commit f4ff9f646a4d373f9e895c2f0073305da288bc0a ]
The function graph tracer was modified to us the ftrace_ops of the function tracer. This simplified the code as well as allowed more features of the function graph tracer.
Not all architectures were converted over as it required the implementation of HAVE_DYNAMIC_FTRACE_WITH_ARGS to implement. For those architectures, it still did it the old way where the function graph tracer handle was called by the function tracer trampoline. The handler then had to check the hash to see if the registered handlers wanted to be called by that function or not.
In order to speed up the function graph tracer that used ftrace_ops, if only one callback was registered with function graph, it would call its function directly via a static call.
Now, if the architecture does not support the use of using ftrace_ops and still has the ftrace function trampoline calling the function graph handler, then by doing a direct call it removes the check against the handler's hash (list of functions it wants callbacks to), and it may call that handler for functions that the handler did not request calls for.
On 32bit x86, which does not support the ftrace_ops use with function graph tracer, it shows the issue:
~# trace-cmd start -p function -l schedule
~# trace-cmd show
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
2) * 11898.94 us | schedule();
3) # 1783.041 us | schedule();
1) | schedule() {
------------------------------------------
1) bash-8369 => kworker-7669
------------------------------------------
1) | schedule() {
------------------------------------------
1) kworker-7669 => bash-8369
------------------------------------------
1) + 97.004 us | }
1) | schedule() {[..]
Now by starting the function tracer is another instance:
~# trace-cmd start -B foo -p function
This causes the function graph tracer to trace all functions (because the function trace calls the function graph tracer for each on, and the function graph trace is doing a direct call):
~# trace-cmd show
# tracer: function_graph
#
# CPU DURATION FUNCTION CALLS
# | | | | | | |
1) 1.669 us | } /* preempt_count_sub */
1) + 10.443 us | } /* _raw_spin_unlock_irqrestore */
1) | tick_program_event() {
1) | clockevents_program_event() {
1) 1.044 us | ktime_get();
1) 6.481 us | lapic_next_event();
1) + 10.114 us | }
1) + 11.790 us | }
1) ! 181.223 us | } /* hrtimer_interrupt */
1) ! 184.624 us | } /* __sysvec_apic_timer_interrupt */
1) | irq_exit_rcu() {
1) 0.678 us | preempt_count_sub();When it should still only be tracing the schedule() function.
To fix this, add a macro FGRAPH_NO_DIRECT to be set to 0 when the architecture does not support function graph use of ftrace_ops, and set to 1 otherwise. Then use this macro to know to allow function graph tracer to call the handlers directly or not.
--- include/linux/ftrace.h | 13 ++++++++++--- kernel/trace/fgraph.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-)
include/linux/ftrace.h +10 -3
@@ -1032,10 +1032,17 @@ static inline bool is_ftrace_trampoline(unsigned long addr)#ifdef CONFIG_FUNCTION_GRAPH_TRACER #ifndef ftrace_graph_func -#define ftrace_graph_func ftrace_stub -#define FTRACE_OPS_GRAPH_STUB FTRACE_OPS_FL_STUB +# define ftrace_graph_func ftrace_stub +# define FTRACE_OPS_GRAPH_STUB FTRACE_OPS_FL_STUB +/* +* The function graph is called every time the function tracer is called. +* It must always test the ops hash and cannot just directly call +* the handler. +*/ +# define FGRAPH_NO_DIRECT 1#else -#define FTRACE_OPS_GRAPH_STUB 0 +# define FTRACE_OPS_GRAPH_STUB 0 +# define FGRAPH_NO_DIRECT 0#endif #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
kernel/trace/fgraph.c +11 -1
@@ -542,7 +542,11 @@ static struct fgraph_ops fgraph_stub = {static struct fgraph_ops *fgraph_direct_gops = &fgraph_stub;DEFINE_STATIC_CALL (fgraph_func, ftrace_graph_entry_stub);DEFINE_STATIC_CALL (fgraph_retfunc, ftrace_graph_ret_stub); +#if FGRAPH_NO_DIRECT +static DEFINE_STATIC_KEY_FALSE (fgraph_do_direct); +#else static DEFINE_STATIC_KEY_TRUE (fgraph_do_direct); +#endif /** * ftrace_graph_stop - set to permanently disable function graph tracing
@@ -846,7 +850,7 @@ __ftrace_return_to_handler(struct ftrace_regs *fregs, unsigned long frame_pointe bitmap =get_bitmap_bits (current, offset);#ifdef CONFIG_HAVE_STATIC_CALL -if (static_branch_likely (&fgraph_do_direct)) { +if (!FGRAPH_NO_DIRECT &&static_branch_likely (&fgraph_do_direct)) {if (test_bit (fgraph_direct_gops->idx, &bitmap))static_call (fgraph_retfunc)(&trace, fgraph_direct_gops, fregs); }else
@@ -1293,6 +1297,9 @@ static void ftrace_graph_enable_direct(bool enable_branch, struct fgraph_ops *gotrace_func_graph_ret_t retfunc =NULL ;int i; +if (FGRAPH_NO_DIRECT ) +return ; +if (gops) { func = gops->entryfunc; retfunc = gops->retfunc;
@@ -1316,6 +1323,9 @@ static void ftrace_graph_enable_direct(bool enable_branch, struct fgraph_ops *gostatic void ftrace_graph_disable_direct (bool disable_branch) { +if (FGRAPH_NO_DIRECT ) +return ; +if (disable_branch)static_branch_disable (&fgraph_do_direct);static_call_update (fgraph_func, ftrace_graph_entry_stub);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 746/752 tracing: Fix checking of freed trace_event_file for hist files
In reply to Sasha LevinFrom: Petr Pavlu <[email protected]>
[ Upstream commit f0a0da1f907e8488826d91c465f7967a56a95aca ]
The event_hist_open() and event_hist_poll() functions currently retrieve a trace_event_file pointer from a file struct by invoking event_file_data(), which simply returns file->f_inode->i_private. The functions then check if the pointer is NULL to determine whether the event is still valid. This approach is flawed because i_private is assigned when an eventfs inode is allocated and remains set throughout its lifetime. Instead, the code should call event_file_file(), which checks for EVENT_FILE_FL_FREED. Using the incorrect access function may result in the code potentially opening a hist file for an event that is being removed or becoming stuck while polling on this file.
Correct the access method to event_file_file() in both functions.
--- kernel/trace/trace_events_hist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/trace/trace_events_hist.c +2 -2
@@ -5778,7 +5778,7 @@ static __poll_t event_hist_poll(struct file *file, struct poll_table_struct *waiguard (mutex)(&event_mutex); - event_file =event_file_data (file); + event_file =event_file_file (file);if (!event_file)return EPOLLERR ;
@@ -5816,7 +5816,7 @@ static int event_hist_open(struct inode *inode, struct file *file)guard (mutex)(&event_mutex); - event_file =event_file_data (file); + event_file =event_file_file (file);if (!event_file) { ret = -ENODEV ; goto err;
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 747/752 tracing: Wake up poll waiters for hist files when removing an event
In reply to Sasha LevinFrom: Petr Pavlu <[email protected]>
[ Upstream commit 9678e53179aa7e907360f5b5b275769008a69b80 ]
The event_hist_poll() function attempts to verify whether an event file is being removed, but this check may not occur or could be unnecessarily delayed. This happens because hist_poll_wakeup() is currently invoked only from event_hist_trigger() when a hist command is triggered. If the event file is being removed, no associated hist command will be triggered and a waiter will be woken up only after an unrelated hist command is triggered.
Fix the issue by adding a call to hist_poll_wakeup() in remove_event_file_dir() after setting the EVENT_FILE_FL_FREED flag. This ensures that a task polling on a hist file is woken up and receives EPOLLERR.
--- include/linux/trace_events.h | 5 +++++ kernel/trace/trace_events.c | 3 +++ 2 files changed, 8 insertions(+)
include/linux/trace_events.h +5 -0
@@ -682,6 +682,11 @@ static inline void hist_poll_wakeup(void)#define hist_poll_wait (file, wait) \ poll_wait(file, &hist_poll_wq, wait) + +#else +static inline void hist_poll_wakeup (void ) +{ +}#endif #define __TRACE_EVENT_FLAGS (name, value) \
kernel/trace/trace_events.c +3 -0
@@ -1296,6 +1296,9 @@ static void remove_event_file_dir(struct trace_event_file *file)free_event_filter (file->filter); file->flags |=EVENT_FILE_FL_FREED ;event_file_put (file); + +/* Wake up hist poll waiters to notice the EVENT_FILE_FL_FREED flag. */ +hist_poll_wakeup (); }/*
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 748/752 rust: list: Add unsafe blocks for container_of and safety comments
In reply to Sasha LevinFrom: Philipp Stanner <[email protected]>
[ Upstream commit 97b281d7edb2ae662365be2809cd728470119720 ]
impl_list_item_mod.rs calls container_of! without unsafe blocks at a couple of places. Since container_of! is unsafe, the blocks are strictly necessary.
The problem was so far not visible because the "unsafe-op-in-unsafe-fn" check is a lint rather than a hard compiler error, and Rust suppresses lints triggered inside of a macro from another crate.
Thus, the error becomes only visible once someone from within the kernel crate tries to use linked lists:
error[E0133]: call to unsafe function `core::ptr::mut_ptr::<impl *mut T>::byte_sub`
is unsafe and requires unsafe block
--> rust/kernel/lib.rs:252:29
|
252 | let container_ptr = field_ptr.byte_sub(offset).cast::<$Container>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function
|
::: rust/kernel/drm/jq.rs:98:1
|
98 | / impl_list_item! {
99 | | impl ListItem<0> for BasicItem { using ListLinks { self.links }; }
100 | | }
| |_- in this macro invocation
|
note: an unsafe function restricts its caller, but its body is safe by default
--> rust/kernel/list/impl_list_item_mod.rs:216:13
|
216 | unsafe fn view_value(me: *mut $crate::list::ListLinks<$num>) -> *const Self {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
::: rust/kernel/drm/jq.rs:98:1
|
98 | / impl_list_item! {
99 | | impl ListItem<0> for BasicItem { using ListLinks { self.links }; }
100 | | }
| |_- in this macro invocation
= note: requested on the command line with `-D unsafe-op-in-unsafe-fn`
= note: this error originates in the macro `$crate::container_of` which comes
from the expansion of the macro `impl_list_item`Therefore, add unsafe blocks to container_of! calls to fix the issue.
[ As discussed, let's fix the build for those that want to use the
macro within the kernel crate now and we can discuss the proper safety comments afterwards. Thus I removed the ones from the patch.
However, we cannot just avoid the comments with CLIPPY=1, so I provided placeholders for now, like we did in the past. They were also needed for an unsafe impl.
While I am not happy about it, it isn't worse than the current status (the comments were meant to be there), and at least this shows what is missing -- our pre-existing "good first issue" [1] may motivate new contributors to complete them properly.
Finally, I moved one of the existing safety comments one line down so that Clippy could locate it.
- Miguel ]
[ Fixed formatting. Reworded to fix the lint suppression
explanation. Indent build error. - Miguel ]
--- rust/kernel/list/impl_list_item_mod.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-)
rust/kernel/list/impl_list_item_mod.rs +16 -9
@@ -84,11 +84,12 @@ macro_rules! impl_has_list_links_self_ptr { // right type. unsafe impl$(<$($generics)*>)? $crate::list::HasSelfPtr<$item_type $(, $id)?> for $self {} + // SAFETY: TODO. unsafe impl$(<$($generics)*>)? $crate::list::HasListLinks$(<$id>)? for $self { #[inline] unsafe fn raw_get_list_links(ptr: *mut Self) -> *mut $crate::list::ListLinks$(<$id>)? { - // SAFETY: The caller promises that the pointer is not dangling. let ptr: *mut $crate::list::ListLinksSelfPtr<$item_type $(, $id)?> = + // SAFETY: The caller promises that the pointer is not dangling. unsafe { ::core::ptr::addr_of_mut!((*ptr)$(.$field)*) }; ptr.cast() }
@@ -217,7 +218,7 @@ macro_rules! impl_list_item {// SAFETY: `me` originates from the most recent call to `prepare_to_insert`, so it // points at the field `$field` in a value of type `Self`. Thus, reversing that // operation is still in-bounds of the allocation. - $crate::container_of!(me,Self , $($field).*) +unsafe { $crate::container_of!(me,Self , $($field).*) } }// GUARANTEES:
@@ -242,7 +243,7 @@ macro_rules! impl_list_item {// SAFETY: `me` originates from the most recent call to `prepare_to_insert`, so it // points at the field `$field` in a value of type `Self`. Thus, reversing that // operation is still in-bounds of the allocation. - $crate::container_of!(me,Self , $($field).*) +unsafe { $crate::container_of!(me,Self , $($field).*) } } } )*};
@@ -270,9 +271,12 @@ macro_rules! impl_list_item {// SAFETY: The caller promises that `me` points at a valid value of type `Self`. let links_field =unsafe { <Self as $crate::list::ListItem <$num>>::view_links (me) }; -let container = $crate::container_of!( - links_field, $crate ::list::ListLinksSelfPtr <Self , $num>, inner - ); +// SAFETY: TODO. +let container =unsafe { + $crate::container_of!( + links_field, $crate ::list::ListLinksSelfPtr <Self , $num>, inner + ) + };// SAFETY: By the same reasoning above, `links_field` is a valid pointer. let self_ptr =unsafe {
@@ -319,9 +323,12 @@ macro_rules! impl_list_item {// `ListArc` containing `Self` until the next call to `post_remove`. The value cannot // be destroyed while a `ListArc` reference exists. unsafe fn view_value (links_field: *mut $crate::list::ListLinks <$num>) -> *const Self { -let container = $crate::container_of!( - links_field, $crate ::list::ListLinksSelfPtr <Self , $num>, inner - ); +// SAFETY: TODO. +let container =unsafe { + $crate::container_of!( + links_field, $crate ::list::ListLinksSelfPtr <Self , $num>, inner + ) + };// SAFETY: By the same reasoning above, `links_field` is a valid pointer. let self_ptr =unsafe {
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 749/752 NTB: ntb_transport: Fix too small buffer for debugfs_name
In reply to Sasha LevinFrom: Koichiro Den <[email protected]>
[ Upstream commit 6a4b50585d74fe45d3ade1e3e86ba8aae79761a5 ]
The buffer used for "qp%d" was only 4 bytes, which truncates names like "qp10" to "qp1" and causes multiple queues to share the same directory.
Enlarge the buffer and use sizeof() to avoid truncation.
--- drivers/ntb/ntb_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ntb/ntb_transport.c +2 -2
@@ -1236,9 +1236,9 @@ static int ntb_transport_init_queue(struct ntb_transport_ctx *nt, qp->tx_max_entry = tx_size / qp->tx_max_frame;if (nt->debugfs_node_dir) { -char debugfs_name[4 ]; +char debugfs_name[8 ]; -snprintf (debugfs_name,4 ,"qp%d" , qp_num); +snprintf (debugfs_name,sizeof (debugfs_name),"qp%d" , qp_num); qp->debugfs_dir =debugfs_create_dir (debugfs_name, nt->debugfs_node_dir);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 750/752 ALSA: pcm: Revert bufs move in snd_pcm_xfern_frames_ioctl()
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit 0585c53b21541cd6b17ad5ab41b371a0d52e358c ]
When building with clang older than 17 targeting architectures that use asm goto for their get_user() and put_user(), such as arm64, after commit f3d233daf011 ("ALSA: pcm: Relax __free() variable declarations"), there are bogus errors around skipping over a variable declared with the cleanup attribute:
sound/core/pcm_native.c:3308:6: error: cannot jump from this asm goto statement to one of its possible targets
if (put_user(result, &_xfern->result))
^
...
arch/arm64/include/asm/uaccess.h:298:2: note: expanded from macro '__put_mem_asm'
asm goto(
^
sound/core/pcm_native.c:3295:6: note: possible target of asm goto statement
if (put_user(0, &_xfern->result))
^ ...
sound/core/pcm_native.c:3300:8: note: jump exits scope of variable with __attribute__((cleanup))
void *bufs __free(kfree) =
^
clang-17 fixed a bug in clang's jump scope checker [1] where all labels in a function were checked as valid targets for all asm goto instances in a function, regardless of whether they were actual targets in a paricular asm goto's provided list of labels.
To workaround this, revert the change done to snd_pcm_xfern_frames_ioctl() by commit f3d233daf011 ("ALSA: pcm: Relax __free() variable declarations") to avoid a variable declared with cleanup from existing between multiple uses of asm goto. There are no other uses of cleanup in this function so there should be low risk from moving this variable back to the top of the function.
--- sound/core/pcm_native.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/core/pcm_native.c +2 -2
@@ -3291,6 +3291,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream, {struct snd_xfern xfern;struct snd_pcm_runtime *runtime = substream->runtime; + void *bufs __free(kfree) = NULL;snd_pcm_sframes_t result;if (runtime->state ==SNDRV_PCM_STATE_OPEN )
@@ -3302,8 +3303,7 @@ static int snd_pcm_xfern_frames_ioctl(struct snd_pcm_substream *substream,if (copy_from_user (&xfern, _xfern,sizeof (xfern)))return -EFAULT ; - void *bufs __free(kfree) = -memdup_array_user (xfern.bufs, runtime->channels,sizeof (void *)); + bufs =memdup_array_user (xfern.bufs, runtime->channels,sizeof (void *));if (IS_ERR (bufs))return PTR_ERR (bufs);if (substream->stream ==SNDRV_PCM_STREAM_PLAYBACK )
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 751/752 Revert "ACPI: processor: Update cpuidle driver check in __acpi_processor_start()"
In reply to Sasha LevinThis reverts commit 0089ce1c056aee547115bdc25c223f8f88c08498 which is upstream commit 6cfed39c2ce64ac024bbde458a9727105e0b8c66.
This commit is causing a suspend regression on systems such as the Asus Zephyrus G14 (GA402RJ) with Ryzen 7 6700H: when suspending, the display turns off but the device fails to fully power down. This is not seen with v7.0-rc1 which indicates that there are changes missing. Therefore, revert this change.
--- drivers/acpi/processor_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/processor_driver.c +1 -1
@@ -166,7 +166,7 @@ static int __acpi_processor_start(struct acpi_device *device)if (result && !IS_ENABLED (CONFIG_ACPI_CPU_FREQ_PSS ))dev_dbg (&device->dev,"CPPC data invalid or not present\n" ); -if (cpuidle_get_driver () == &acpi_idle_driver) +if (!cpuidle_get_driver () ||cpuidle_get_driver () == &acpi_idle_driver)acpi_processor_power_init (pr);acpi_pss_perf_init (pr);
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 752/752 Linux 6.18.16-rc1
In reply to Sasha Levin--- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Makefile +2 -2
@@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 6 PATCHLEVEL = 18 -SUBLEVEL = 15 -EXTRAVERSION = +SUBLEVEL = 16 +EXTRAVERSION = -rc1 NAME = Baby Opossum Posse # *DOCUMENTATION*
Signature · 1 line
2.51.0