6.1.193-rc1 review
Subsystems (6)
Greg Kroah-Hartman
maintainerPATCH 1362/2857 seccomp: restore knotif->state when SECCOMP_ADDFD_FLAG_SEND is interrupted
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hui Peng <[email protected]>
[ Upstream commit 832b9b176be06a20747a267db6bc0010a24b74f4 ]
In seccomp_notify_addfd(), when SECCOMP_ADDFD_FLAG_SEND is set in addfd.flags, knotif->state is optimistically transitioned from SECCOMP_NOTIFY_SENT to SECCOMP_NOTIFY_REPLIED before waking the tracee and waiting on kaddfd.completion:
if (addfd.flags & SECCOMP_ADDFD_FLAG_SEND) {
knotif->state = SECCOMP_NOTIFY_REPLIED;
...
}If wait_for_completion_interruptible(&kaddfd.completion) is interrupted by a signal before the tracee dequeues the kaddfd request (!list_empty(&kaddfd.list)), seccomp_notify_addfd() removes kaddfd from knotif->addfd and returns -EINTR to the supervisor without having installed the file descriptor.
However, knotif->state is left as SECCOMP_NOTIFY_REPLIED (with knotif->error == 0 and knotif->val == 0). This causes two problems:
1. When the tracee runs in do_user_notif(), it checks
if (knotif.state != SECCOMP_NOTIFY_REPLIED) after calling seccomp_handle_addfd(). Because knotif->state is already SECCOMP_NOTIFY_REPLIED, the tracee exits the notification wait loop prematurely and returns 0 from the trapped syscall without the file descriptor ever having been installed.
2. If the supervisor retries SECCOMP_IOCTL_NOTIF_ADDFD or SECCOMP_IOCTL_NOTIF_SEND before the tracee runs, it fails with -EINPROGRESS because knotif->state is no longer SECCOMP_NOTIFY_SENT.
Fix this by restoring knotif->state back to SECCOMP_NOTIFY_SENT if SECCOMP_ADDFD_FLAG_SEND was set and kaddfd was not consumed before the interrupted wait. Also add a seccomp_bpf selftest (user_notification_addfd_send_interrupted) covering this race.
Tested in QEMU against Linux 7.3.0-rc3 using the user_notification_addfd_send_interrupted selftest added in this patch (./seccomp_bpf -t user_notification_addfd_send_interrupted): on the unfixed kernel the test fails because the retry ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd) returns -EINPROGRESS (-1) and the tracee prematurely exits do_user_notif() with return value 0 instead of FD 42, whereas with this patch applied the test passes.
--- kernel/seccomp.c | 7 +- tools/testing/selftests/seccomp/seccomp_bpf.c | 179 ++++++++++++++++++ 2 files changed, 184 insertions(+), 2 deletions(-)
kernel/seccomp.c +5 -2
@@ -1690,10 +1690,13 @@ static long seccomp_notify_addfd(struct seccomp_filter *filter,* We need to check again if the addfd request has been handled, * and if not, we will remove it from the queue. */ -if (list_empty (&kaddfd.list)) +if (list_empty (&kaddfd.list)) { ret = kaddfd.ret; -else + }else {list_del (&kaddfd.list); +if (addfd.flags &SECCOMP_ADDFD_FLAG_SEND ) + knotif->state =SECCOMP_NOTIFY_SENT ; + } out_unlock:mutex_unlock (&filter->notify_lock);
tools/testing/selftests/seccomp/seccomp_bpf.c +179 -0
185 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1363/2857 media: microchip-isc: dont sleep in the clk .is_enabled callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 61490ff518c7b3ea3ff1cd16bbc012e9e4f1ab74 ]
isc_clk_is_enabled() calls pm_runtime_resume_and_get() and pm_runtime_put_sync(), which can sleep and are not safe here, as .is_enabled must run in atomic context. clk_disable_unused() calls it so at boot, and CONFIG_DEBUG_ATOMIC_SLEEP reports a "sleeping function called from invalid context" BUG.
Use the atomic-safe pm_runtime_get_if_active() and pm_runtime_put() instead. A suspended ISC has its clocks gated, so report the clock disabled when the device is not already active.
--- drivers/media/platform/atmel/atmel-isc-clk.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/media/platform/atmel/atmel-isc-clk.c +3 -4
@@ -98,15 +98,14 @@ static int isc_clk_is_enabled(struct clk_hw *hw) {struct isc_clk *isc_clk =to_isc_clk (hw);u32 status; -int ret; - ret =pm_runtime_resume_and_get (isc_clk->dev); -if (ret <0 ) +/* Runs in atomic context, so must not sleep to resume the ISC. */ +if (pm_runtime_get_if_active (isc_clk->dev, true) <=0 )return 0 ;regmap_read (isc_clk->regmap,ISC_CLKSR , &status); -pm_runtime_put_sync (isc_clk->dev); +pm_runtime_put (isc_clk->dev);return status &ISC_CLK (isc_clk->id) ?1 :0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1364/2857 arm64: dts: ti: k3-am625-sk-common: Set eMMC clock pin as OUTPUT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 8ef8a0e38d1377c6d51c06f95c64d87641b2c717 ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
[0] https://www.ti.com/lit/pdf/spruiv7 Rev. C: Table 12-246. MMCSDi I/O Signals
--- arch/arm64/boot/dts/ti/k3-am625-sk.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am625-sk.dts +1 -1
@@ -177,7 +177,7 @@ AM62X_IOPAD(0x0b4, PIN_INPUT_PULLUP, 1) /* (K24) GPMC0_CSn3.I2C2_SDA */ main_mmc0_pins_default: main-mmc0-pins-default { pinctrl-single,pins = < AM62X_IOPAD(0x220, PIN_INPUT, 0) /* (Y3) MMC0_CMD */ - AM62X_IOPAD(0x218, PIN_INPUT, 0) /* (AB1) MMC0_CLK */ + AM62X_IOPAD(0x218, PIN_OUTPUT, 0) /* (AB1) MMC0_CLK */ AM62X_IOPAD(0x214, PIN_INPUT, 0) /* (AA2) MMC0_DAT0 */ AM62X_IOPAD(0x210, PIN_INPUT, 0) /* (AA1) MMC0_DAT1 */ AM62X_IOPAD(0x20c, PIN_INPUT, 0) /* (AA3) MMC0_DAT2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1365/2857 KVM: nSVM: Ignore EFER.LMA if EFER.LME=0 when preparing L2 state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 1c4c84a643b704e473cb171f7b61359ff29b12a4 ]
Force EFER.LMA=0 if EFER.LME=0 when preparing L2 state for VMRUN, i.e. mimic real hardware's behavior of ignoring EFER.LMA if EFER.LME=0. VMRUN unfortunately allows the nonsensical combination, i.e. doesn't fail, but KVM itself has an invariant EFER.LMA can be set et if and only if EFER.LME
is set. Breaking that invariant can lead to a variety of issue,
particularly in MMU code that keys off EFER.LMA when determining whether to emulate/virtualization 4/5-level paging versus PAE paging.
--- arch/x86/kvm/svm/nested.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/x86/kvm/svm/nested.c +4 -0
@@ -559,6 +559,10 @@ static void nested_vmcb02_prepare_save(struct vcpu_svm *svm, struct vmcb *vmcb12kvm_set_rflags (&svm->vcpu, vmcb12->save.rflags |X86_EFLAGS_FIXED ); +/* SVM ignores EFER.LMA if EFER.LME=0 (instead of failing VMRUN). */ +if (!(svm->nested.save.efer &EFER_LME )) + svm->nested.save.efer &= ~EFER_LMA ; +svm_set_efer (&svm->vcpu, svm->nested.save.efer);svm_set_cr0 (&svm->vcpu, svm->nested.save.cr0);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1366/2857 KVM: x86/mmu: Bug the VM if a vCPU ends up in long mode without PAE enabled
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 72e2fb24a0b0528bcc16a8f6ad2cf336ac361525 ]
Promote the ASSERT(), which is quite dead code in KVM, into a KVM_BUG_ON() for KVM's sanity check that CR4.PAE=1 if the vCPU is in long mode when performing a walk of guest page tables. The sanity is quite cheap since neither EFER nor CR4.PAE requires a VMREAD, especially relative to the cost of walking the guest page tables.
More importantly, the sanity check would have prevented the true badness fixed by commit 112e66017bff ("KVM: nVMX: add missing consistency checks for CR0 and CR4"). The missed consistency check resulted in some versions of KVM corrupting the on-stack guest_walker structure due to KVM thinking there are 4/5 levels of page tables, but wiring up the MMU hooks to point at the paging32 implementation, which only allocates space for two levels of page tables in "struct guest_walker32".
Queue a page fault for injection if the assertion fails, as both callers, FNAME(gva_to_gpa) and FNAME(walk_addr_generic), assume that walker.fault contains sane info on a walk failure. E.g. not populating the fault info could result in KVM consuming and/or exposing uninitialized stack data before the vCPU is kicked out to userspace, which doesn't happen until KVM checks for KVM_REQ_VM_DEAD on the next enter.
Move the check below the initialization of "pte_access" so that the aforementioned to-be-injected page fault doesn't consume uninitialized stack data. The information _shouldn't_ reach the guest or userspace, but there's zero downside to being paranoid in this case.
Stable-dep-of: 115f9405a2ed ("KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has")
--- arch/x86/kvm/mmu/paging_tmpl.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu/paging_tmpl.h +11 -1
@@ -345,7 +345,6 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, }#endif walker->max_level = walker->level; -ASSERT (!(is_long_mode (vcpu) && !is_pae (vcpu)));/* * FIXME: on Intel processors, loads of the PDPTE registers for PAE paging
@@ -355,6 +354,17 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, nested_access = (have_ad ?PFERR_WRITE_MASK :0 ) |PFERR_USER_MASK ; pte_access = ~0 ; + +/* +* Queue a page fault for injection if this assertion fails, as callers +* assume that walker.fault contains sane info on a walk failure. I.e. +* avoid making the situation worse by inducing even worse badness +* between when the assertion fails and when KVM kicks the vCPU out to +* userspace (because the VM is bugged). +*/ +if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm)) + goto error; + ++walker->level; do {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1367/2857 KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 115f9405a2ed6d78ee7ad8436bdd638743f6d1d4 ]
Extend the "EFER.LMA && !CR4.PAE" check, which exists largely to guard against KVM configuring a paging32 MMU with more than 2 levels of paging, with a very explicit check for exactly that: that KVM isn't trying to walk more levels of paging than the MMU template provides. I.e. harden KVM against all bugs that would cause KVM to generates accesses beyond the bounds of guest_walker's arrays, regardless of how KVM ended up with the misconfigured MMU.
Note, don't use w->cpu_role.base.level directly as the paging64 template only provides two levels of page tables for PAE paging on 32-bit hosts, and handles the third level by manually emulating the PDPTR access.
--- arch/x86/kvm/mmu/paging_tmpl.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/x86/kvm/mmu/paging_tmpl.h +7 -6
@@ -356,13 +356,14 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, pte_access = ~0 ;/* -* Queue a page fault for injection if this assertion fails, as callers -* assume that walker.fault contains sane info on a walk failure. I.e. -* avoid making the situation worse by inducing even worse badness -* between when the assertion fails and when KVM kicks the vCPU out to -* userspace (because the VM is bugged). +* Queue a page fault for injection if any of the below assertions fail, +* as callers assume that walker.fault contains sane info on a walk +* failure. I.e. avoid making the situation worse by inducing even +* worse badness between when the assertion fails and when KVM kicks +* the vCPU out to userspace (because the VM is bugged). */ -if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm)) +if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm) || +KVM_BUG_ON (walker->max_level >PT_MAX_FULL_LEVELS , vcpu->kvm)) goto error; ++walker->level;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1368/2857 iio: light: isl29028: fix runtime PM reference leak on error paths
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Cesari <[email protected]>
[ Upstream commit 0e30d15b15647df786e60022650613e16dd70645 ]
isl29028_read_raw() and isl29028_write_raw() take a runtime PM reference with pm_runtime_resume_and_get() but return directly on their error paths without dropping it. The usage count never balances again and the device stops entering autosuspend for good. In isl29028_read_raw() this needs a regmap access to fail; in isl29028_write_raw() one rejected sysfs write is enough, for example
echo 200 > in_proximity_sampling_frequency
which is outside the [1:100] range and returns -EINVAL with the reference still held.
Take the reference with PM_RUNTIME_ACQUIRE_AUTOSUSPEND() instead, so it is released on every return path.
This also stops the return value of pm_runtime_put_autosuspend() from reaching userspace. That value only says whether the device could be suspended right away, so -EAGAIN or -EPERM turns a successful access into a failure, and with CONFIG_PM=n the stub returns -ENOSYS on every access.
--- drivers/iio/light/isl29028.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/iio/light/isl29028.c +4 -19
@@ -407,14 +407,9 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,mutex_unlock (&chip->lock); -if (ret <0 ) -return ret; +isl29028_set_pm_runtime_busy (chip, false); - ret =isl29028_set_pm_runtime_busy (chip, false); -if (ret <0 ) -return ret; - -return 0 ; +return ret; } static int isl29028_read_raw(struct iio_dev *indio_dev,
@@ -423,7 +418,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev, {struct isl29028_chip *chip =iio_priv (indio_dev);struct device *dev =regmap_get_device (chip->regmap); -int ret, pm_ret; +int ret; ret =isl29028_set_pm_runtime_busy (chip, true);if (ret <0 )
@@ -476,17 +471,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,mutex_unlock (&chip->lock); -if (ret <0 ) -return ret; - -/** -* Preserve the ret variable if the call to -* isl29028_set_pm_runtime_busy() is successful so the reading -* (if applicable) is returned to user space. -*/ - pm_ret =isl29028_set_pm_runtime_busy (chip, false); -if (pm_ret <0 ) -return pm_ret; +isl29028_set_pm_runtime_busy (chip, false);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1369/2857 mtd: mtdsuper: Fix MTD device reference leak in mtd_get_sb()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 62ee3da38f41bef83c1cf250f6816a0ee187674b ]
mtd_get_sb() is called with a reference to the MTD device already taken by the caller. When sget_dev() fails, the function returns the error without dropping that reference, so the device is never released and its refcount never reaches zero. Every mount attempt on an MTD device whose superblock cannot be set up leaks a reference.
Restore the put_mtd_device() that the fs_context conversion dropped on this path.
--- drivers/mtd/mtdsuper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/mtdsuper.c +3 -1
@@ -64,8 +64,10 @@ static int mtd_get_sb(struct fs_context *fc, fc->sget_key = mtd; sb =sget_fc (fc, mtd_test_super, mtd_set_super); -if (IS_ERR (sb)) +if (IS_ERR (sb)) { +put_mtd_device (mtd);return PTR_ERR (sb); + }if (sb->s_root) {/* new mountpoint for an already mounted superblock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1370/2857 ALSA: usb-audio: Protect Roland control activation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 19b42c1fff7f220a6346c614d79ce1bda6d95b40 ]
The USB MIDI driver changes the Roland MIDI Input Mode control's access flags directly from the rawmidi open and close paths. These changes are not protected by the ALSA control core and the corresponding notifications can race with control access.
Use snd_ctl_activate_id() so that the control core updates the access flags and sends the notification under its lock. Release the USB MIDI mutex before calling it because the control write path holds controls_rwsem while roland_load_put() takes the USB MIDI mutex.
Keep the state transition and alternate-setting change under the USB MIDI mutex; rawmidi's open mutex serializes the enclosing open and close paths.
--- sound/usb/midi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
sound/usb/midi.c +11 -11
@@ -1152,7 +1152,9 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, int open) {struct snd_usb_midi *umidi = substream->rmidi->private_data; -struct snd_kcontrol *ctl; +struct snd_ctl_elem_id ctl_id; +bool activate_ctl = false; +bool active;down_read (&umidi->disc_rwsem);if (umidi->disconnected) {
@@ -1164,11 +1166,9 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,if (open) {if (!umidi->opened[0 ] && !umidi->opened[1 ]) {if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0 ].access |= -SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (umidi->card, -SNDRV_CTL_EVENT_MASK_INFO , &ctl->id); + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = false;update_roland_altsetting (umidi); } }
@@ -1181,15 +1181,15 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,snd_usbmidi_input_stop (&umidi->list);if (!umidi->opened[0 ] && !umidi->opened[1 ]) {if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0 ].access &= - ~SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (umidi->card, -SNDRV_CTL_EVENT_MASK_INFO , &ctl->id); + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = true; } } }mutex_unlock (&umidi->mutex); +if (activate_ctl) +snd_ctl_activate_id (umidi->card, &ctl_id, active);up_read (&umidi->disc_rwsem);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1371/2857 ocfs2: restrict OCFS2_INVALID_SLOT suballoc slot to system inodes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
[ Upstream commit 25bf9e549360b656a6763232e0e9e58a00c3aff7 ]
Patch series "ocfs2: validate suballoc slot and bit of metadata blocks", v3.
The ocfs2 metadata validators trust the on-disk suballoc slot and bit without checking them against the slot range of the mounted filesystem and the capacity of the block group bitmap. A corrupted image can carry OCFS2_INVALID_SLOT or another out-of-range slot, or a suballoc bit beyond the bitmap, and once the corresponding inode, extent block, xattr block, dir index root or refcount block gets freed, the bad value goes straight into ocfs2_get_system_file_inode() or _ocfs2_free_suballoc_bits() and hits a BUG_ON() or runs off the end of local_system_inodes[].
This series rejects such values at read time, in the existing validators, so corrupted objects fail with -EROFS (and a read-only remount) instead of crashing:
patch 1 restricts OCFS2_INVALID_SLOT dinodes to system inodes,
completing fe7a283b3916 ("ocfs2: add suballoc slot check in ocfs2_validate_inode_block()"), and turns the "system file state is ambiguous" BUG_ON() in ocfs2_read_locked_inode() into an ocfs2_error();
patch 2 rejects oversized dinode suballoc bits;
patch 3 validates the suballoc slot and bit of xattr and dir index
blocks;
patch 4 validates the suballoc slot and bit of extent and refcount
blocks.
The checks only enforce what the kernel and mkfs.ocfs2 already write: a valid slot from meta_ac->ac_alloc_slot and a bit within the block group bitmap, with system inodes carrying OCFS2_INVALID_SLOT plus OCFS2_SYSTEM_FL and extent blocks using slot 0. Nothing changes for healthy filesystems.
Each new check was exercised under QEMU by corrupting the field in question with an out-of-range value; with the series applied the access fails with -EROFS and the filesystem remounts read-only instead of hitting the BUG_ON().
This patch (of 4):
ocfs2_validate_inode_block() currently permits i_suballoc_slot to be OCFS2_INVALID_SLOT for any dinode. Only system inodes created by mkfs.ocfs2 are allocated from the global allocator and thus legitimately carry this value; regular inodes are always allocated from a per-slot suballocator and hence must have a valid slot.
If a corrupted regular inode with OCFS2_INVALID_SLOT is accepted, ocfs2_remove_inode() will pass the slot to ocfs2_get_system_file_inode() and get_local_system_inode() will hit BUG_ON(slot == OCFS2_INVALID_SLOT) when the inode is deleted. This can be triggered by an unprivileged user unlinking such a corrupted file.
Reject OCFS2_INVALID_SLOT for non-system dinodes during validation, while still accepting it for system inodes. Note that a crafted dinode carrying OCFS2_SYSTEM_FL passes the check above, yet a plain lookup of it still used to BUG() in ocfs2_read_locked_inode() ("system file state is ambiguous"). Since i_flags comes from disk, handle that mismatch with ocfs2_error() instead of BUG_ON() as well.
--- fs/ocfs2/inode.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
fs/ocfs2/inode.c +28 -9
@@ -575,14 +575,18 @@ static int ocfs2_read_locked_inode(struct inode *inode, fe = (struct ocfs2_dinode *) bh->b_data;/* -* This is a code bug. Right now the caller needs to -* understand whether it is asking for a system file inode or -* not so the proper lock names can be built. +* The caller must know whether it is asking for a system file inode +* or not so the proper lock names can be built. Since i_flags comes +* from disk, a mismatch is filesystem corruption instead of a code +* bug, so handle it with ocfs2_error() rather than BUG_ON(). */ -mlog_bug_on_msg (!!(fe->i_flags &cpu_to_le32 (OCFS2_SYSTEM_FL )) != - !!(args->fi_flags &OCFS2_FI_FLAG_SYSFILE ), -"Inode %llu: system file state is ambiguous\n" , - (unsigned long long )args->fi_blkno); +if (!!(fe->i_flags &cpu_to_le32 (OCFS2_SYSTEM_FL )) != + !!(args->fi_flags &OCFS2_FI_FLAG_SYSFILE )) { + status =ocfs2_error (osb->sb, +"Inode %llu: system file state is ambiguous\n" , + (unsigned long long )args->fi_blkno); + goto bail; + }if (S_ISCHR (le16_to_cpu (fe->i_mode)) ||S_ISBLK (le16_to_cpu (fe->i_mode)))
@@ -1579,8 +1583,23 @@ int ocfs2_validate_inode_block(struct super_block *sb, } } -if (le16_to_cpu (di->i_suballoc_slot) != (u16 )OCFS2_INVALID_SLOT && - (u32 )le16_to_cpu (di->i_suballoc_slot) >OCFS2_SB (sb)->max_slots -1 ) { +/* +* Only system inodes created by mkfs.ocfs2 are allocated from the +* global allocator and thus legitimately carry OCFS2_INVALID_SLOT. +* Regular inodes are always allocated from a per-slot suballocator. +* If a regular inode with OCFS2_INVALID_SLOT was accepted here, +* deleting it would pass the slot to get_local_system_inode() via +* ocfs2_remove_inode() and trigger BUG_ON(slot == OCFS2_INVALID_SLOT). +*/ +if (le16_to_cpu (di->i_suballoc_slot) == (u16 )OCFS2_INVALID_SLOT ) { +if (!(le32_to_cpu (di->i_flags) &OCFS2_SYSTEM_FL )) { + rc =ocfs2_error (sb, +"Invalid dinode %llu: suballoc slot %u for non-system inode\n" , + (unsigned long long )bh->b_blocknr, +le16_to_cpu (di->i_suballoc_slot)); + goto bail; + } + }else if ((u32 )le16_to_cpu (di->i_suballoc_slot) >OCFS2_SB (sb)->max_slots -1 ) { rc =ocfs2_error (sb,"Invalid dinode %llu: suballoc slot %u\n" , (unsigned long long )bh->b_blocknr,le16_to_cpu (di->i_suballoc_slot));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1372/2857 usb: core: Add quirk for 255-bytes initial config read
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikhil Solanke <[email protected]>
[ Upstream commit 152f174a13618bec1f842d2deb69245cb2ace51f ]
Certain third-party USB game controllers exposing (or spoofing) an Xbox 360-compatible interface (VID:PID 045e:028e) fail to enumerate under Linux. The device disconnects from the bus without responding to the initial GET_DESCRIPTOR(CONFIGURATION) request, and the kernel logs 'unable to read config index 0 descriptor/start: -71'.
The device then falls back to a secondary Android HID mode (with a different VID:PID), losing XInput functionality including rumble support. The failure reproduces across multiple machines, host controller types, and kernel versions including current mainline and LTS. The device enumerates correctly and remains in XInput mode under Windows. Notably, the device enumerates correctly in Android mode when the same 9-byte request is issued for that mode's configuration descriptor, confirming the firmware bug is specific to the XInput mode.
usbmon traces from Linux and Wireshark/USBPcap traces from Windows are identical up to the point of failure, with no visible protocol-level difference explaining the divergence. The root cause was identified when Michal Pecio discovered via a QEMU bus-level capture that Windows does not use wLength=9 for the initial config descriptor request; it uses wLength=255. Alan Stern subsequently confirmed this with a bus analyzer on a different USB 2.0 device, and Michal verified the behavior goes back to Windows 95 OSR2.1.
So, add a new quirk flag USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE which causes usb_get_configuration() to issue a 255 byte sized configuration request instead of USB_DT_CONFIG_SIZE (9) for the initial GET_DESCRIPTOR(CONFIGURATION) request, mimicking long-standing Windows behavior.
This patch intentionally does not add any new VID:PID entries using this quirk. Some affected Xbox 360-compatible controllers spoof Microsoft's VID:PID, while genuine Microsoft controllers already enumerate correctly and do not require this quirk. Other affected clone devices use their own VID:PID pairs and can be added individually as they are identified.
Stable-dep-of: 40224df29729 ("USB: quirks: add USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE for GameSir G7 SE")
--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/usb/core/config.c | 32 ++++++++++++++----- drivers/usb/core/quirks.c | 4 +++ include/linux/usb/quirks.h | 3 ++ 4 files changed, 36 insertions(+), 8 deletions(-)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -6646,6 +6646,11 @@ q = USB_QUIRK_FORCE_ONE_CONFIG (Device claims zero configurations, forcing to 1); + r = USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE (Device + fails during initialization when asked for + 9-bytes configuration descriptor request. + Ask for 255-bytes request instead to mirror + Windows' behavior); Example: quirks=0781:5580:bk,0a5c:5834:gij usbhid.mousepoll=
drivers/usb/core/config.c +24 -8
@@ -891,6 +891,18 @@ int usb_get_configuration(struct usb_device *dev)unsigned char *bigbuffer;struct usb_config_descriptor *desc;int result; +size_t usb_config_req_size; + +/* +* We usually start by grabbing the first 9-bytes descriptor so we know +* how long the whole configuration is. Some devices with quirky +* firmware will fail enumeration, so if the quirk is set, use 255 instead, +* mirroring the behavior of Windows. +*/ +if (dev->quirks &USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE ) + usb_config_req_size =255 ; +else + usb_config_req_size =USB_DT_CONFIG_SIZE ;if (ncfg >USB_MAXCONFIG ) { dev_notice(ddev, "too many configurations: %d, "
@@ -917,15 +929,13 @@ int usb_get_configuration(struct usb_device *dev)if (!dev->rawdescriptors)return -ENOMEM ; - desc =kmalloc (USB_DT_CONFIG_SIZE ,GFP_KERNEL ); + desc =kmalloc (usb_config_req_size,GFP_KERNEL );if (!desc)return -ENOMEM ;for (cfgno =0 ; cfgno < ncfg; cfgno++) { -/* We grab just the first descriptor so we know how long -* the whole configuration is */ result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, - desc,USB_DT_CONFIG_SIZE ); + desc, usb_config_req_size);if (result <0 ) {dev_err (ddev,"unable to read config index %d " "descriptor/%s: %d\n" , cfgno,"start" , result);
@@ -935,16 +945,14 @@ int usb_get_configuration(struct usb_device *dev) dev->descriptor.bNumConfigurations = cfgno;break ; }else if (result <4 ) { -dev_err (ddev,"config index %d descriptor too short " -"(expected %i, got %i)\n" , cfgno, -USB_DT_CONFIG_SIZE , result); +dev_err (ddev,"config index %d descriptor too short (asked for %zu, got %i)\n" , + cfgno, usb_config_req_size, result); result = -EINVAL ; goto err; } length =max ((int )le16_to_cpu (desc->wTotalLength),USB_DT_CONFIG_SIZE ); -/* Now that we know the length, get the whole thing */ bigbuffer =kmalloc (length,GFP_KERNEL );if (!bigbuffer) { result = -ENOMEM ;
@@ -954,6 +962,13 @@ int usb_get_configuration(struct usb_device *dev)if (dev->quirks &USB_QUIRK_DELAY_INIT )msleep (200 ); +/* Skip the second read if we already got everything */ +if (result >= length) { +memcpy (bigbuffer, desc, length); + goto store_and_parse; + } + +/* Get the whole thing */ result =usb_get_descriptor (dev,USB_DT_CONFIG , cfgno, bigbuffer, length);if (result <0 ) {
@@ -968,6 +983,7 @@ int usb_get_configuration(struct usb_device *dev) length = result; } +store_and_parse: dev->rawdescriptors[cfgno] = bigbuffer; result = usb_parse_configuration(dev, cfgno,
drivers/usb/core/quirks.c +4 -0
@@ -143,6 +143,10 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)break ;case 'q' : flags |=USB_QUIRK_FORCE_ONE_CONFIG ; +break ; +case 'r' : + flags |=USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE ; +break ;/* Ignore unrecognized flag characters */ } }
include/linux/usb/quirks.h +3 -0
@@ -81,4 +81,7 @@/* Device claims zero configurations, forcing to 1 */ #define USB_QUIRK_FORCE_ONE_CONFIG BIT(18) +/* Use a 255 bytes config descriptor request mirroring windows behavior */ +#define USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE BIT(19) +#endif /* __LINUX_USB_QUIRKS_H */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1373/2857 USB: quirks: add USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE for GameSir G7 SE
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Resool Tuama <[email protected]>
[ Upstream commit 40224df29729618ecd88c5c0077e71b1e82c7a3a ]
The GameSir G7 SE wired controller first enumerates as 3537:10a0 and then re-enumerates in a mode it picks from how the host enumerated it.
When the configuration descriptor is fetched the Linux way, 9 bytes followed by the full 80, the controller disconnects about 1 ms after its string descriptors have been read, before SET_CONFIGURATION, and comes back as 3537:1082, a generic HID gamepad without force feedback.
When the configuration descriptor is fetched in one 255-byte request, as Windows does, it comes back as 3537:1010 in Xbox One (GIP) mode, which xpad already supports, including rumble.
Skipping the device qualifier requests (USB_QUIRK_DEVICE_QUALIFIER) makes no difference; the configuration descriptor request size alone decides the mode. Add USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE for the 10a0 identity, as is already done for the ShanWan Wireless Gamepad.
--- drivers/usb/core/quirks.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/core/quirks.c +3 -0
@@ -607,6 +607,9 @@ static const struct usb_device_id usb_quirk_list[] = {/* ezcap401 - BOS descriptor fetch hangs at SuperSpeed Plus */ { USB_DEVICE(0x32ed, 0x0401), .driver_info = USB_QUIRK_NO_BOS }, + /* GameSir G7 SE */ + { USB_DEVICE(0x3537, 0x10a0), .driver_info = USB_QUIRK_WINDOWS_CONFIG_REQ_SIZE }, + /* DELL USB GEN2 */ { USB_DEVICE(0x413c, 0xb062), .driver_info = USB_QUIRK_NO_LPM | USB_QUIRK_RESET_RESUME },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1374/2857 media: v4l2-common: Fix P010 format info
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nas Chung <[email protected]>
[ Upstream commit 8761a87aff8259eab0add8a9428cee2c280fb6eb ]
V4L2_PIX_FMT_P010 is a 10-bit 4:2:0 semi-planar format, but its v4l2_format_info() entry described a 4:2:2 layout with a half-width chroma plane. Correct bpp and vdiv to match P010's real layout, consistent with the other semi-planar formats.
--- drivers/media/v4l2-core/v4l2-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/v4l2-common.c +1 -1
@@ -266,7 +266,7 @@ const struct v4l2_format_info *v4l2_format_info(u32 format) { .format = V4L2_PIX_FMT_NV61, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, { .format = V4L2_PIX_FMT_NV24, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, { .format = V4L2_PIX_FMT_NV42, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 1, 2, 0, 0 }, .hdiv = 1, .vdiv = 1 }, - { .format = V4L2_PIX_FMT_P010, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 2, 0, 0 }, .hdiv = 2, .vdiv = 1 }, + { .format = V4L2_PIX_FMT_P010, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 2, .bpp = { 2, 4, 0, 0 }, .hdiv = 2, .vdiv = 2 }, { .format = V4L2_PIX_FMT_YUV410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 }, { .format = V4L2_PIX_FMT_YVU410, .pixel_enc = V4L2_PIXEL_ENC_YUV, .mem_planes = 1, .comp_planes = 3, .bpp = { 1, 1, 1, 0 }, .hdiv = 4, .vdiv = 4 },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1375/2857 media: hantro_drv: Convert to platform remove callback returning void
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit b9294ba9285e555e0e6daafac95704be4a9125c2 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 8e26d4c20ed2 ("media: hantro: disable runtime PM before hardware teardown")
--- drivers/media/platform/verisilicon/hantro_drv.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/media/platform/verisilicon/hantro_drv.c +2 -3
@@ -1183,7 +1183,7 @@ static int hantro_probe(struct platform_device *pdev)return ret; } -static int hantro_remove (struct platform_device *pdev) +static void hantro_remove (struct platform_device *pdev) {struct hantro_dev *vpu =platform_get_drvdata (pdev);
@@ -1199,7 +1199,6 @@ static int hantro_remove(struct platform_device *pdev)reset_control_assert (vpu->resets);pm_runtime_dont_use_autosuspend (vpu->dev);pm_runtime_disable (vpu->dev); -return 0 ; }#ifdef CONFIG_PM
@@ -1222,7 +1221,7 @@ static const struct dev_pm_ops hantro_pm_ops = {static struct platform_driver hantro_driver = { .probe = hantro_probe, - .remove = hantro_remove, + .remove_new = hantro_remove, .driver = { .name =DRIVER_NAME , .of_match_table =of_match_ptr (of_hantro_match),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1376/2857 media: hantro: disable runtime PM before hardware teardown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tharit Tangkijwanichakul <[email protected]>
[ Upstream commit 8e26d4c20ed218db6c3123480a4a4e2545680566 ]
Removing the Hantro driver may trigger an SError on RK3588:
SError Interrupt on CPU6, code 0x00000000be000011 -- SError ... do_serror+0x5c/0x74 el1h_64_error_handler+0x34/0x50 el1h_64_error+0x6c/0x70 regmap_mmio_read32le+0x10/0x20 (P) _regmap_bus_reg_read+0x6c/0xb4 _regmap_read+0x60/0xdc regmap_read+0x4c/0x80 rockchip_pd_power+0xe4/0x600 rockchip_pd_power_off+0x1c/0x60 _genpd_power_off+0x98/0x198 genpd_power_off.part.0+0x178/0x288 genpd_runtime_suspend+0x210/0x300 __rpm_callback+0x48/0x1e0 rpm_callback+0x74/0x80 rpm_suspend+0x10c/0x580 rpm_idle+0x134/0x1b8 update_autosuspend+0x30/0xc4 __pm_runtime_use_autosuspend+0x48/0x64 hantro_remove+0x8c/0xa8 [hantro_vpu] ...
hantro_remove() currently asserts the device resets before disabling runtime PM.
Calling pm_runtime_dont_use_autosuspend() causes an idle device to be runtime-suspended immediately. At that point the Hantro hardware has already been torn down, while the generic power-domain genpd code still performs the power-off sequence. genpd regmap_mmio_read causes panic subsequently because the reset lines were asserted.
Disable runtime PM before asserting the reset lines so that no runtime-PM transition can race with hardware teardown.
Apply the same ordering to the probe error paths as well.
--- drivers/media/platform/verisilicon/hantro_drv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/media/platform/verisilicon/hantro_drv.c +6 -3
@@ -1119,7 +1119,7 @@ static int hantro_probe(struct platform_device *pdev) ret =clk_bulk_prepare (vpu->variant->num_clocks, vpu->clocks);if (ret) {dev_err (&pdev->dev,"Failed to prepare clocks\n" ); - goto err_rst_assert; + goto err_pm_disable_assert_reset; } ret =v4l2_device_register (&pdev->dev, &vpu->v4l2_dev);
@@ -1175,8 +1175,11 @@ static int hantro_probe(struct platform_device *pdev)v4l2_device_unregister (&vpu->v4l2_dev); err_clk_unprepare:clk_bulk_unprepare (vpu->variant->num_clocks, vpu->clocks); -err_rst_assert: +err_pm_disable_assert_reset: +pm_runtime_dont_use_autosuspend (vpu->dev); +pm_runtime_disable (vpu->dev);reset_control_assert (vpu->resets); +return ret; err_pm_disable:pm_runtime_dont_use_autosuspend (vpu->dev);pm_runtime_disable (vpu->dev);
@@ -1196,9 +1199,9 @@ static void hantro_remove(struct platform_device *pdev)v4l2_m2m_put (vpu->m2m_dev);v4l2_device_unregister (&vpu->v4l2_dev);clk_bulk_unprepare (vpu->variant->num_clocks, vpu->clocks); -reset_control_assert (vpu->resets);pm_runtime_dont_use_autosuspend (vpu->dev);pm_runtime_disable (vpu->dev); +reset_control_assert (vpu->resets); }#ifdef CONFIG_PM
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1377/2857 hwmon: (tmp102) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 56c1d32323e773b8b927316f8beeae9238576335 ]
tmp102 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the first ~35 ms conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp102.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp102.c +4 -4
@@ -54,7 +54,7 @@struct tmp102 {struct regmap *regmap;u16 config_orig; -unsigned long ready_time; +u64 ready_time; };/* convert left adjusted 13-bit TMP102 register value to milliCelsius */
@@ -79,7 +79,7 @@ static int tmp102_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp102->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp102->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ; }
@@ -245,7 +245,7 @@ static int tmp102_probe(struct i2c_client *client)* Mark that we are not ready with data until the first * conversion is complete */ - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS ); hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, tmp102,
@@ -278,7 +278,7 @@ static int tmp102_resume(struct device *dev) err =regmap_update_bits (tmp102->regmap,TMP102_CONF_REG ,TMP102_CONF_SD ,0 ); - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1378/2857 gfs2: reject invalid inode sizes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit 33ed0a0567e0abe66ea65e89dad2e35082890fbe ]
A corrupted GFS2 image can store a dinode size that is larger than what VFS i_size can represent. gfs2_dinode_in() reads the on-disk di_size as a u64 and writes it directly into inode->i_size. If the value is larger than S64_MAX, the incore i_size becomes negative. That negative value can bypass the existing stuffed inode size check:
inode->i_size > gfs2_max_stuffed_size(ip)
Later, gfs2_quotad may try to sync the quota file and unstuff the quota inode. gfs2_unstuffer_folio() reads the negative i_size into an unsigned length and passes it to memcpy(), turning it into a huge copy size and triggering a out-of-bound issue.
Reject dinodes whose size exceeds sb->s_maxbytes before storing the value in inode->i_size. Also make the stuffed inode check use the raw on-disk size while it is still unsigned.
--- fs/gfs2/glops.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
fs/gfs2/glops.c +8 -2
@@ -404,6 +404,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)umode_t mode =be32_to_cpu (str->di_mode);struct inode *inode = &ip->i_inode;bool is_new = inode->i_state &I_NEW ; +u64 size;if (unlikely (ip->i_no_addr !=be64_to_cpu (str->di_num.no_addr))) {gfs2_consist_inode (ip);
@@ -429,7 +430,12 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)i_uid_write (inode,be32_to_cpu (str->di_uid));i_gid_write (inode,be32_to_cpu (str->di_gid));set_nlink (inode,be32_to_cpu (str->di_nlink)); -i_size_write (inode,be64_to_cpu (str->di_size)); + size =be64_to_cpu (str->di_size); +if (unlikely (size > inode->i_sb->s_maxbytes)) { +gfs2_consist_inode (ip); +return -EIO ; + } +i_size_write (inode, size);gfs2_set_inode_blocks (inode,be64_to_cpu (str->di_blocks)); atime.tv_sec =be64_to_cpu (str->di_atime); atime.tv_nsec =be32_to_cpu (str->di_atime_nsec);
@@ -467,7 +473,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) ip->i_depth = (u8 )depth; ip->i_entries =be32_to_cpu (str->di_entries); -if (gfs2_is_stuffed (ip) && inode->i_size >gfs2_max_stuffed_size (ip)) { +if (gfs2_is_stuffed (ip) && size >gfs2_max_stuffed_size (ip)) {gfs2_consist_inode (ip);return -EIO ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1379/2857 iio: light: ltr501: Power down chip if request irq fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esben Haabendal <[email protected]>
[ Upstream commit 8a9bcd587d7d768e6c8e9fff88bb89645e412731 ]
In case devm_request_threaded_irq() failed, we were leaving the chip powered instead of powering it down again. Power down the chip switching ALS and PS modes to standby.
--- drivers/iio/light/ltr501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/ltr501.c +1 -1
@@ -1576,7 +1576,7 @@ static int ltr501_probe(struct i2c_client *client,if (ret) {dev_err (&client->dev,"request irq (%d) failed\n" , client->irq); -return ret; + goto powerdown_on_error; } }else { indio_dev->info = data->chip_info->info_no_irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1380/2857 media: redrat3: Error path leaves device in transmitting state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 8024d5e84531d828535365718278f1cf0ce67db0 ]
In the allocation failure error path, the transmitting boolean is not cleared. If this error path is followed the transmitter cannot be used again until the device is replugged or the module reloaded.
Fix the error path by moving the assignment statement.
Remove the check for the transmitting state in transmit, since rc-core ensures there is never a reentrant call to the driver transmit function; the transmit function is always called with dev->lock held.
The transmitting boolean is only used for interpretting firmware errors.
--- drivers/media/rc/redrat3.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/media/rc/redrat3.c +3 -8
@@ -773,17 +773,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,u8 curlencheck =0 ;unsigned i, sendbuf_len; -if (rr3->transmitting) { -dev_warn (dev,"%s: transmitter already in use\n" , __func__); -return -EAGAIN ; - } -if (count >RR3_MAX_SIG_SIZE -RR3_TX_TRAILER_LEN )return -EINVAL ; -/* rr3 will disable rc detector on transmit */ - rr3->transmitting = true; - sample_lens =kcalloc (RR3_DRIVER_MAXLENS ,sizeof (*sample_lens),GFP_KERNEL );
@@ -796,6 +788,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, goto out; } +/* rr3 will disable rc detector on transmit */ + rr3->transmitting = true; +for (i =0 ; i < count; i++) { cur_sample_len =redrat3_us_to_len (txbuf[i]);if (cur_sample_len >0xffff ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1381/2857 platform/x86: int3472: Fix uninitialised variable warning
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit 70e6384fe0f4cf9768944f81924f6c1478b0ce43 ]
Fix a compiler warning about an uninitialised err_msg variable by printing the error where it is handled:
drivers/platform/x86/intel/int3472/discrete.c:440:24: warning: ‘err_msg’ may be used uninitialized [-Wmaybe-uninitialized]
440 | return dev_err_probe(int3472->dev, ret, err_msg);
--- drivers/platform/x86/intel/int3472/discrete.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/platform/x86/intel/int3472/discrete.c +8 -8
@@ -226,7 +226,6 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares,struct int3472_discrete_device *int3472 = data;struct acpi_resource_gpio *agpio;union acpi_object *obj; -const char *err_msg;int ret;u8 type;
@@ -255,27 +254,31 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, ret =skl_int3472_map_gpio_to_sensor (int3472, agpio,"reset" ,GPIO_ACTIVE_LOW );if (ret) - err_msg ="Failed to map reset pin to sensor\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map reset pin to sensor\n" );break ;case INT3472_GPIO_TYPE_POWERDOWN : ret =skl_int3472_map_gpio_to_sensor (int3472, agpio,"powerdown" ,GPIO_ACTIVE_LOW );if (ret) - err_msg ="Failed to map powerdown pin to sensor\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map powerdown pin to sensor\n" );break ;case INT3472_GPIO_TYPE_CLK_ENABLE :case INT3472_GPIO_TYPE_PRIVACY_LED : ret =skl_int3472_map_gpio_to_clk (int3472, agpio, type);if (ret) - err_msg ="Failed to map GPIO to clock\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map GPIO to clock\n" );break ;case INT3472_GPIO_TYPE_POWER_ENABLE : ret =skl_int3472_register_regulator (int3472, agpio);if (ret) - err_msg ="Failed to map regulator to sensor\n" ; +dev_err_probe (int3472->dev, ret, +"Failed to map regulator to sensor\n" );break ;default :
@@ -289,9 +292,6 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, int3472->ngpios++;ACPI_FREE (obj); -if (ret <0 ) -return dev_err_probe (int3472->dev, ret, err_msg); -return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1382/2857 media: i2c: ov5647: fix power cleanup on remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 6e81cfc38548109021ab761b94ecdd01f8753154 ]
ov5647_remove() disables runtime PM without powering off the sensor if it is still runtime active. pm_runtime_disable() does not invoke the runtime suspend callback, so the sensor can remain powered on.
If the device is not already runtime suspended, call ov5647_power_off() and mark the runtime PM state as suspended.
This issue was found by manual code inspection.
--- drivers/media/i2c/ov5647.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/i2c/ov5647.c +4 -0
@@ -1460,6 +1460,10 @@ static void ov5647_remove(struct i2c_client *client)v4l2_ctrl_handler_free (&sensor->ctrls);v4l2_device_unregister_subdev (sd);pm_runtime_disable (&client->dev); +if (!pm_runtime_status_suspended (&client->dev)) { +ov5647_power_off (&client->dev); +pm_runtime_set_suspended (&client->dev); + }mutex_destroy (&sensor->lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1383/2857 staging: media: av7110: fix sp8870 initialization failure state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punnay Sharma <[email protected]>
[ Upstream commit 30684fa98394bc0eb4362282908612aab7d4dad9 ]
The SP8870 DVB frontend driver prematurely flags the device as initialized at the very beginning of the sp8870_init() routine, prior to requesting the firmware (dvb-fe-sp8870.fw) and executing the I2C upload sequence.
If request_firmware() times out or sp8870_firmware_upload() encounters an I2C bus error, the function aborts and returns -EIO. However, because state->initialised is already set to 1, all subsequent invocations of fe->ops.init() by the DVB core will immediately return 0 (success) without attempting to load the firmware again. This leaves the demodulator microcontroller halted and the frontend permanently dead until the module is forcibly reloaded.
Relocate the state->initialised = 1 assignment to the end of sp8870_init(), ensuring the flag is only set after the firmware is successfully uploaded and the system controller is actually restarted.
--- drivers/staging/media/deprecated/saa7146/av7110/sp8870.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/media/deprecated/saa7146/av7110/sp8870.c +2 -1
@@ -297,7 +297,6 @@ static int sp8870_init (struct dvb_frontend* fe)sp8870_wake_up (state);if (state->initialised)return 0 ; - state->initialised =1 ;dprintk ("%s\n" , __func__);
@@ -336,6 +335,8 @@ static int sp8870_init (struct dvb_frontend* fe)sp8870_writereg (state,0x0D00 ,0x010 );sp8870_writereg (state,0x0D01 ,0x000 ); + state->initialised =1 ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1384/2857 arm64: dts: ti: k3-am62x-sk-common: Set SD clock pin as OUTPUT
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Judith Mendez <[email protected]>
[ Upstream commit 1e2e5016bda94b2bcd86258b5eb77fe3006639a0 ]
MMC clock pins must be configured as OUTPUT-only per TRM [0] with receiver disabled (RXACTIVE bit = 0). Change MMC CLK pins from PIN_INPUT to PIN_OUTPUT to match documentation.
[0] https://www.ti.com/lit/pdf/spruiv7 Rev. C: Table 12-246. MMCSDi I/O Signals
--- arch/arm64/boot/dts/ti/k3-am625-sk.dts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/ti/k3-am625-sk.dts +1 -1
@@ -192,7 +192,7 @@ AM62X_IOPAD(0x1f8, PIN_INPUT, 0) /* (AC2) MMC0_DAT7 */ main_mmc1_pins_default: main-mmc1-pins-default { pinctrl-single,pins = < AM62X_IOPAD(0x23c, PIN_INPUT, 0) /* (A21) MMC1_CMD */ - AM62X_IOPAD(0x234, PIN_INPUT, 0) /* (B22) MMC1_CLK */ + AM62X_IOPAD(0x234, PIN_OUTPUT, 0) /* (B22) MMC1_CLK */ AM62X_IOPAD(0x230, PIN_INPUT, 0) /* (A22) MMC1_DAT0 */ AM62X_IOPAD(0x22c, PIN_INPUT, 0) /* (B21) MMC1_DAT1 */ AM62X_IOPAD(0x228, PIN_INPUT, 0) /* (C21) MMC1_DAT2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1385/2857 hte: tegra194-test: shut down timer before GPIO release
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 30167fadbf87fa901a2fee49c30a5c5a506a43e8 ]
tegra_hte_test_remove() releases GPIO descriptors before stopping hte.timer. gpio_timer_cb() accesses hte.gpio_out and rearms the timer, so a callback concurrent with remove can use a released descriptor and rearm after teardown.
Shut down the timer before releasing the GPIO descriptors. timer_shutdown_sync() waits for a running callback and prevents it from being rearmed.
--- drivers/hte/hte-tegra194-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hte/hte-tegra194-test.c +1 -1
@@ -219,10 +219,10 @@ static int tegra_hte_test_remove(struct platform_device *pdev) { (void )pdev; +timer_shutdown_sync (&hte.timer);free_irq (hte.gpio_in_irq, &hte);gpiod_put (hte.gpio_in);gpiod_put (hte.gpio_out); -del_timer_sync (&hte.timer);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1386/2857 xen/gntdev: prevent private mappings from becoming writable
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdifatah Suruur <[email protected]>
[ Upstream commit 2176dea8d8c19cb43a9b3651bfa1cb21eab1b31a ]
gntdev_mmap() rejects writable private (non-shared) mappings of foreign grant pages, because a private writable mapping takes the COW path on pages that have no proper struct-page backing. However, VM_MAYWRITE is left set, so userspace can map the grant read-only and then upgrade the mapping to writable with mprotect(), hitting the same COW path the check was written to prevent.
Clear VM_MAYWRITE for private mappings, as i915 does for its read-only objects and as fixed in drm/vc4 (CVE-2026-68445) and drm/panthor (CVE-2024-53071) and ptp: vmclock (commit a5edadbae57e2298a56cf7a4e774a027905a331f).
Message-ID: <[email protected]>
--- drivers/xen/gntdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/xen/gntdev.c +7 -0
@@ -1074,6 +1074,13 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)if ((vma->vm_flags &VM_WRITE ) && !(vma->vm_flags &VM_SHARED ))return -EINVAL ; +/* +* Private mappings of foreign grant pages must never become +* writable: they would take the COW path on granted pages. +*/ +if (!(vma->vm_flags &VM_SHARED )) + vma->vm_flags &= ~VM_MAYWRITE ; +pr_debug ("map %d+%d at %lx (pgoff %lx)\n" , index, count, vma->vm_start, vma->vm_pgoff);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1387/2857 ext4: Move CONFIG_UNICODE defguards into the code flow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriel Krisman Bertazi <[email protected]>
[ Upstream commit d98c822232f8642960a69caedeb7909471127939 ]
Instead of a bunch of ifdefs, make the unicode built checks part of the code flow where possible, as requested by Torvalds.
Stable-dep-of: 19e16597f9ba ("ext4: fix ABBA deadlock in ext4_rmdir()")
--- fs/ext4/crypto.c | 10 ++-------- fs/ext4/ext4.h | 33 +++++++++++++++++++++------------ fs/ext4/namei.c | 14 +++++--------- fs/ext4/super.c | 4 +--- 4 files changed, 29 insertions(+), 32 deletions(-)
fs/ext4/crypto.c +2 -8
@@ -31,11 +31,10 @@ int ext4_fname_setup_filename(struct inode *dir, const struct qstr *iname,ext4_fname_from_fscrypt_name (fname, &name); -#if IS_ENABLED (CONFIG_UNICODE ) err =ext4_fname_setup_ci_filename (dir, iname, fname);if (err)ext4_fname_free_filename (fname); -#endif +return err; }
@@ -51,11 +50,9 @@ int ext4_fname_prepare_lookup(struct inode *dir, struct dentry *dentry,ext4_fname_from_fscrypt_name (fname, &name); -#if IS_ENABLED (CONFIG_UNICODE ) err =ext4_fname_setup_ci_filename (dir, &dentry->d_name, fname);if (err)ext4_fname_free_filename (fname); -#endif return err; }
@@ -70,10 +67,7 @@ void ext4_fname_free_filename(struct ext4_filename *fname) fname->usr_fname =NULL ; fname->disk_name.name =NULL ; -#if IS_ENABLED (CONFIG_UNICODE ) -kfree (fname->cf_name.name); - fname->cf_name.name =NULL ; -#endif +ext4_fname_free_ci_filename (fname); }static bool uuid_is_zero (__u8 u[16 ])
fs/ext4/ext4.h +21 -12
@@ -2776,8 +2776,25 @@ ext4_fsblk_t ext4_inode_to_goal_block(struct inode *);#if IS_ENABLED (CONFIG_UNICODE )extern int ext4_fname_setup_ci_filename (struct inode *dir, -const struct qstr *iname, -struct ext4_filename *fname); +const struct qstr *iname, +struct ext4_filename *fname); + +static inline void ext4_fname_free_ci_filename (struct ext4_filename *fname) +{ +kfree (fname->cf_name.name); + fname->cf_name.name =NULL ; +} +#else +static inline int ext4_fname_setup_ci_filename (struct inode *dir, +const struct qstr *iname, +struct ext4_filename *fname) +{ +return 0 ; +} + +static inline void ext4_fname_free_ci_filename (struct ext4_filename *fname) +{ +}#endif /* ext4 encryption related stuff goes here crypto.c */
@@ -2800,16 +2817,11 @@ static inline int ext4_fname_setup_filename(struct inode *dir,int lookup, struct ext4_filename *fname) { - int err = 0; fname->usr_fname = iname; fname->disk_name.name = (unsigned char *) iname->name; fname->disk_name.len = iname->len; -#if IS_ENABLED (CONFIG_UNICODE ) - err =ext4_fname_setup_ci_filename (dir, iname, fname); -#endif - -return err; +return ext4_fname_setup_ci_filename (dir, iname, fname); } static inline int ext4_fname_prepare_lookup(struct inode *dir,
@@ -2821,10 +2833,7 @@ static inline int ext4_fname_prepare_lookup(struct inode *dir,static inline void ext4_fname_free_filename (struct ext4_filename *fname) { -#if IS_ENABLED (CONFIG_UNICODE ) -kfree (fname->cf_name.name); - fname->cf_name.name =NULL ; -#endif +ext4_fname_free_ci_filename (fname); } static inline int ext4_ioctl_get_encryption_pwsalt(struct file *filp,
fs/ext4/namei.c +5 -9
@@ -1875,8 +1875,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi } } -#if IS_ENABLED (CONFIG_UNICODE ) -if (!inode &&IS_CASEFOLDED (dir)) { +if (IS_ENABLED (CONFIG_UNICODE ) && !inode &&IS_CASEFOLDED (dir)) {/* Eventually we want to call d_add_ci(dentry, NULL) * for negative dentries in the encoding case as * well. For now, prevent the negative dentry
@@ -1884,7 +1883,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, unsi*/ return NULL ; } -#endif +return d_splice_alias (inode, dentry); }
@@ -3259,16 +3258,14 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_fc_track_unlink (handle, dentry); retval =ext4_mark_inode_dirty (handle, dir); -#if IS_ENABLED (CONFIG_UNICODE )/* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ -if (IS_CASEFOLDED (dir)) +if (IS_ENABLED (CONFIG_UNICODE ) &&IS_CASEFOLDED (dir))d_invalidate (dentry); -#endif end_rmdir:brelse (bh);
@@ -3370,16 +3367,15 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) goto out_trace; retval =__ext4_unlink (dir, &dentry->d_name,d_inode (dentry), dentry); -#if IS_ENABLED (CONFIG_UNICODE ) +/* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ -if (IS_CASEFOLDED (dir)) +if (IS_ENABLED (CONFIG_UNICODE ) &&IS_CASEFOLDED (dir))d_invalidate (dentry); -#endif out_trace:trace_ext4_unlink_exit (dentry, retval);
fs/ext4/super.c +1 -3
@@ -3601,14 +3601,12 @@ int ext4_feature_set_ok(struct super_block *sb, int readonly)return 0 ; } -#if !IS_ENABLED (CONFIG_UNICODE ) -if (ext4_has_feature_casefold (sb)) { +if (!IS_ENABLED (CONFIG_UNICODE ) &&ext4_has_feature_casefold (sb)) {ext4_msg (sb,KERN_ERR ,"Filesystem with casefold feature cannot be " "mounted without CONFIG_UNICODE" );return 0 ; } -#endif if (readonly)return 1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1388/2857 ext4: fix ABBA deadlock in ext4_rmdir()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Senozhatsky <[email protected]>
[ Upstream commit 19e16597f9baf1b5719a3a6c710486446f6808fd ]
We observe the following ABBA deadlock (casefolding enabled):
INFO: task jbd2/dm-13-8:447 blocked for more than 720 seconds. task:jbd2/dm-13-8 state:D stack:0 pid:447 tgid:447 ppid:2 Call Trace: <TASK> __schedule+0xc2c/0xe60 schedule+0x40/0xe0 jbd2_journal_wait_updates+0x8f/0xf0 jbd2_journal_commit_transaction+0x321/0x1850 kjournald2+0xa9/0x230 kthread+0x226/0x2a0 ret_from_fork+0x101/0x1e0 ret_from_fork_asm+0x1a/0x30 INFO: task Thread-10:4161 blocked for more than 720 seconds. task:Thread-10 state:D stack:0 pid:4161 tgid:3848 ppid:540 Call Trace: <TASK> __schedule+0xc2c/0xe60 schedule+0x40/0xe0 wait_transaction_locked+0x8c/0xd0 start_this_handle+0x252/0x870 jbd2__journal_start+0x120/0x280 __ext4_journal_start_sb+0x11a/0x250 ext4_evict_inode+0x208/0x760 iput+0x222/0x5c0 dput+0x293/0x690 ____fput+0x145/0x2b0 task_work_run+0x7a/0xb0 exit_to_user_mode_loop+0xc0/0xd0 do_syscall_64+0x14b/0xf10 entry_SYSCALL_64_after_hwframe+0x76/0x7e
NMI backtrace for cpu 0
CPU: 0 UID: 1010216 PID: 4160 Comm: Thread-7 RIP: 0010:d_walk+0x0/0x290 [..] Call Trace: <TASK> shrink_dcache_parent+0xb2/0x100 d_invalidate+0x50/0x110 ext4_rmdir+0x3a2/0x3d0 vfs_rmdir+0x9d/0x1d0 do_rmdir+0xf0/0x330 __x64_sys_unlinkat+0x34/0x50 do_syscall_64+0x61/0xf10
The problem is that ext4_rmdir() calls d_invalidate() before stopping the jbd2 transaction handle. Because d_invalidate() traverses child dentries it can encounter dying or in-use dentries. If a concurrent thread executing __dentry_kill() on a child dentry invokes ext4_evict_inode(), it requests a new transaction handle via ext4_journal_start(), which waits for all running handles to close. However, the thread executing ext4_rmdir() still holds its active transaction handle while looping in shrink_dcache_parent() waiting for the dying child dentry to complete eviction.
Stop transaction handle in ext4_rmdir() before calling d_invalidate().
--- fs/ext4/namei.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/namei.c +6 -5
@@ -3258,19 +3258,20 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_fc_track_unlink (handle, dentry); retval =ext4_mark_inode_dirty (handle, dir); +end_rmdir: +brelse (bh); +if (handle) +ext4_journal_stop (handle); +/* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid * invalidating the dentries here, alongside with returning the * negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ -if (IS_ENABLED (CONFIG_UNICODE ) &&IS_CASEFOLDED (dir)) +if (!retval &&IS_ENABLED (CONFIG_UNICODE ) &&IS_CASEFOLDED (dir))d_invalidate (dentry); -end_rmdir: -brelse (bh); -if (handle) -ext4_journal_stop (handle);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1389/2857 crypto: ecc - Handle exceptional points in Shamir multiplication
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 6fd70bc8bc01a578c7728b7bd1cb5689c62cc5b7 ]
Shamir multiplication mishandles equal points, opposite points and the point at infinity. This rejects valid ECDSA signatures and can accept invalid digest/signature tuples when the public key is G or -G. The kernel incorrectly rejects 16 valid signatures from Wycheproof.
Handle doubling, cancellation and the point at infinity in precomputation and accumulation. Add regression tests for P-256 ECDSA and 256/512-bit EC-RDSA. The valid vectors are Wycheproof P1363 secp256r1/SHA-256 cases 60 and 210 converted to X9.62, two constructed ECDSA signatures for Q = +/-G with k = 2, and six constructed EC-RDSA signatures for Q = G, -G and -2G. Also add two invalid P-256 digest/signature tuples for Q = +/-G that must return -EKEYREJECTED.
--- crypto/ecc.c | 33 ++++- crypto/testmgr.c | 10 +- crypto/testmgr.h | 339 ++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 375 insertions(+), 7 deletions(-)
crypto/ecc.c +31 -2
@@ -1358,9 +1358,22 @@ static void ecc_point_add(const struct ecc_point *result,vli_set (result->x, q->x, ndigits);vli_set (result->y, q->y, ndigits);vli_mod_sub (z, result->x, p->x, curve->p, ndigits); +if (vli_is_zero (z, ndigits)) { +if (vli_cmp (p->y, q->y, ndigits)) { +/* P + (-P) is the point at infinity. */ +vli_clear (result->x, ndigits); +vli_clear (result->y, ndigits); +return ; + } +/* The co-Z addition formula does not handle P == Q. */ + z[0 ] =1 ; +ecc_point_double_jacobian (result->x, result->y, z, curve); + goto out; + }vli_set (px, p->x, ndigits);vli_set (py, p->y, ndigits);xycz_add (px, py, result->x, result->y, curve); +out:vli_mod_inv (z, z, curve->p, ndigits);apply_z (result->x, result->y, z, curve); }
@@ -1399,21 +1412,37 @@ void ecc_point_mult_shamir(const struct ecc_point *result,vli_set (rx, point->x, ndigits);vli_set (ry, point->y, ndigits);vli_clear (z +1 , ndigits -1 ); - z[0 ] =1 ; + z[0 ] = !ecc_point_is_zero (point);for (--i; i >=0 ; i--) {ecc_point_double_jacobian (rx, ry, z, curve); idx = (!!vli_test_bit (u1, i)) | ((!!vli_test_bit (u2, i)) <<1 ); point = points[idx]; -if (point) { +if (point && !ecc_point_is_zero (point)) {u64 tx[ECC_MAX_DIGITS ];u64 ty[ECC_MAX_DIGITS ];u64 tz[ECC_MAX_DIGITS ]; +if (vli_is_zero (z, ndigits)) { +/* Adding to infinity starts a new accumulator. */ +vli_set (rx, point->x, ndigits); +vli_set (ry, point->y, ndigits); + z[0 ] =1 ; +continue ; + }vli_set (tx, point->x, ndigits);vli_set (ty, point->y, ndigits);apply_z (tx, ty, z, curve);vli_mod_sub (tz, rx, tx, curve->p, ndigits); +if (vli_is_zero (tz, ndigits)) { +if (!vli_cmp (ry, ty, ndigits)) +ecc_point_double_jacobian (rx, ry, z, + curve); +else +/* Adding opposite points yields infinity. */ +vli_clear (z, ndigits); +continue ; + }xycz_add (tx, ty, rx, ry, curve);vli_mod_mult_fast (z, z, tz, curve); }
crypto/testmgr.c +6 -4
@@ -4160,8 +4160,10 @@ static int test_akcipher_one(struct crypto_akcipher *tfm, crypto_akcipher_verify(req) :/* Run asymmetric encrypt */ crypto_akcipher_encrypt(req), &wait); -if (err) { -pr_err ("alg: akcipher: %s test failed. err %d\n" , op, err); +if (err != vecs->verify_error) { +pr_err ("alg: akcipher: %s test failed: expected %d, got %d\n" , + op, vecs->verify_error, err); + err = err ?: -EINVAL ; goto free_all; }if (!vecs->siggen_sigver_test && c) {
@@ -4183,9 +4185,9 @@ static int test_akcipher_one(struct crypto_akcipher *tfm,/* * Don't invoke (decrypt or sign) test which require a private key -* for vectors with only a public key. +* for vectors with only a public key or an invalid signature. */ -if (vecs->public_key_vec) { +if (vecs->public_key_vec || vecs->verify_error) { err =0 ; goto free_all; }
crypto/testmgr.h +338 -1
363 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1390/2857 usb: typec: ucsi: ccg: Validate altmode index in GET_CURRENT_CAM response
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungjin Bae <[email protected]>
[ Upstream commit 02ee864e8d2142c5648998944c3306ea6a763c26 ]
When the PPM reports more than one DisplayPort alternate mode for a connector, ucsi_ccg_update_altmodes() merges them into a single entry in uc->updated[] and sets uc->has_multiple_dp. In that case, ucsi_ccg_update_get_current_cam_cmd() rewrites the response of the GET_CURRENT_CAM command. The response is a single byte holding the index of the currently active alternate mode, and it is provided by the PPM firmware.
The function uses this byte directly as an index into uc->orig[], and then uses the linked_idx read from that entry as the translated index into uc->updated[]. Both arrays have UCSI_MAX_ALTMODES entries, but neither index is checked against that size.
If a malicious or buggy PPM reports a value of UCSI_MAX_ALTMODES or larger, e.g. 0xFF, uc->orig[cam].linked_idx reads over the end of uc->orig[]. The byte read from there is then used as the index for writing cam into uc->updated[new_cam].active_idx, so the out-of-bounds read is followed by an out-of-bounds write. This happens without any userspace action, since the UCSI core issues GET_CURRENT_CAM on its own when handling connector changes.
Fix this by rejecting responses whose index is out of range, printing an error and returning -EPROTO, so that the caller cannot accept this. Also check linked_idx before using it as an index, so that the write into uc->updated[] is always within bounds.
The response is now only processed when the command completed without an error. ucsi_sync_control_common() only reads the response when the CCI reports command completion, so otherwise the buffer is not filled and must not be mistaken for an invalid index.
This bug was found with a Python script that traces where firmware input is used.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +16 -2
@@ -356,14 +356,28 @@ static int ucsi_ccg_init(struct ucsi_ccg *uc)return -ETIMEDOUT ; } -static void ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) +static int ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) {u8 cam, new_cam; cam = data[0 ]; +if (cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"PPM returned invalid alternate mode index %u\n" , + cam); +return -EPROTO ; + } + new_cam = uc->orig[cam].linked_idx; +if (new_cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"invalid linked alternate mode index %u for %u\n" , + new_cam, cam); +return -EPROTO ; + } + uc->updated[new_cam].active_idx = cam; data[0 ] = new_cam; + +return 0 ; } static bool ucsi_ccg_update_altmodes(struct ucsi *ucsi,
@@ -547,7 +561,7 @@ static int ucsi_ccg_read(struct ucsi *ucsi, unsigned int offset,switch (UCSI_COMMAND (uc->last_cmd_sent)) {case UCSI_GET_CURRENT_CAM :if (uc->has_multiple_dp) -ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val); + ret =ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val);break ;case UCSI_GET_ALTERNATE_MODES : if (UCSI_ALTMODE_RECIPIENT(uc->last_cmd_sent) ==
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1391/2857 sctp: hold shkey across socket migration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit ad1320865b1826ffa2e81e37c49535751e81335c ]
sctp_sock_migrate() transfers queued DATA skbs from the old socket to the new one. skb_orphan() invokes sctp_wfree() during that transfer and drops the skb-owned shared-key reference.
If userspace has removed that key from the association, this can be the final reference. The following sctp_set_owner_w() then dereferences the freed chunk->shkey while trying to take the new owner reference.
Take a temporary shared-key reference before orphaning the skb and release it after the new owner has taken its reference. This preserves the selected authentication key throughout the ownership transfer.
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.
Stable-dep-of: 52ffeaa358d1 ("sctp: re-point retained control chunks on association migration")
--- net/sctp/socket.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/sctp/socket.c +11 -1
@@ -147,9 +147,19 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)static void sctp_clear_owner_w (struct sctp_chunk *chunk) { +/* Keep the shkey alive until the new owner takes its reference. */ +if (chunk->shkey) +sctp_auth_shkey_hold (chunk->shkey);skb_orphan (chunk->skb); } +static void sctp_set_owner_w_migrate (struct sctp_chunk *chunk) +{ +sctp_set_owner_w (chunk); +if (chunk->shkey) +sctp_auth_shkey_release (chunk->shkey); +} +#define traverse_and_process () \ do { \ msg = chunk->msg; \
@@ -9692,7 +9702,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,lock_sock_nested (newsk,SINGLE_DEPTH_NESTING );sctp_for_each_tx_datachunk (assoc, true, sctp_clear_owner_w);sctp_assoc_migrate (assoc, newsk); -sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w); +sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w_migrate);/* If the association on the newsk is already closed before accept() * is called, set RCV_SHUTDOWN flag.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1392/2857 sctp: re-point retained control chunks on association migration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
[ Upstream commit 52ffeaa358d1f3d91aa87a26ad90d77769cff74b ]
sctp_sock_migrate() transfers DATA chunk ownership but leaves retained control chunks pointing at the old socket. A later retransmission can therefore access the socket after it has been freed.
Extend the migration walk to cover retained control chunks and use sctp_control_set_owner_w() to assign their new owner. Reuse the DATA ownership check so each chunk is processed once per pass, even when it is reachable through multiple lists or retained pointers.
Preserve a control chunk's existing authentication key across migration so its final release can still generate SCTP_AUTH_FREE_KEY when needed.
--- include/net/sctp/sm.h | 1 + net/sctp/sm_make_chunk.c | 5 ++-- net/sctp/socket.c | 53 ++++++++++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 15 deletions(-)
include/net/sctp/sm.h +1 -0
@@ -256,6 +256,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, struct sctp_fwdtsn_skip *skiplist);struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc,__u16 key_id); +void sctp_control_set_owner_w (struct sctp_chunk *chunk);struct sctp_chunk *sctp_make_strreset_req (const struct sctp_association *asoc,__u16 stream_num,__be16 *stream_list,bool out,bool in);
net/sctp/sm_make_chunk.c +3 -2
@@ -95,7 +95,7 @@ static void sctp_control_release_owner(struct sk_buff *skb) } } -static void sctp_control_set_owner_w (struct sctp_chunk *chunk) +void sctp_control_set_owner_w (struct sctp_chunk *chunk) {struct sctp_association *asoc = chunk->asoc;struct sk_buff *skb = chunk->skb;
@@ -108,7 +108,8 @@ static void sctp_control_set_owner_w(struct sctp_chunk *chunk)* For now don't do anything for now. */ if (chunk->auth) { - chunk->shkey = asoc->shkey; +if (!chunk->shkey) + chunk->shkey = asoc->shkey;sctp_auth_shkey_hold (chunk->shkey); } skb->sk = asoc ? asoc->base.sk :NULL ;
net/sctp/socket.c +40 -13
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1393/2857 nvme: make the DH-HMAC-CHAP secret attributes readable by root only
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Belanger <[email protected]>
[ Upstream commit bbca7c312ab25efd0024eb87545c51a76ab2ea39 ]
The dhchap_secret and dhchap_ctrl_secret sysfs attributes have mode 0644. Their show functions return the secret, so any local user can read the DH-HMAC-CHAP secrets of a connected controller.
Define them with DEVICE_ATTR_ADMIN_RW(), which sets mode 0600. The macro takes the show and store functions from the attribute name, so rename them. Writing the attributes was already limited to root and is not changed.
--- drivers/nvme/host/core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/nvme/host/core.c +6 -8
@@ -3847,7 +3847,7 @@ static ssize_t dctype_show(struct device *dev,static DEVICE_ATTR_RO (dctype);#ifdef CONFIG_NVME_AUTH -static ssize_t nvme_ctrl_dhchap_secret_show (struct device *dev, +static ssize_t dhchap_secret_show (struct device *dev,struct device_attribute *attr,char *buf) {struct nvme_ctrl *ctrl =dev_get_drvdata (dev);
@@ -3858,7 +3858,7 @@ static ssize_t nvme_ctrl_dhchap_secret_show(struct device *dev,return sysfs_emit (buf,"%s\n" , opts->dhchap_secret); } -static ssize_t nvme_ctrl_dhchap_secret_store (struct device *dev, +static ssize_t dhchap_secret_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct nvme_ctrl *ctrl =dev_get_drvdata (dev);
@@ -3899,10 +3899,9 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,return count; } -static DEVICE_ATTR(dhchap_secret, S_IRUGO | S_IWUSR, - nvme_ctrl_dhchap_secret_show, nvme_ctrl_dhchap_secret_store); +static DEVICE_ATTR_ADMIN_RW (dhchap_secret); -static ssize_t nvme_ctrl_dhchap_ctrl_secret_show (struct device *dev, +static ssize_t dhchap_ctrl_secret_show (struct device *dev,struct device_attribute *attr,char *buf) {struct nvme_ctrl *ctrl =dev_get_drvdata (dev);
@@ -3913,7 +3912,7 @@ static ssize_t nvme_ctrl_dhchap_ctrl_secret_show(struct device *dev,return sysfs_emit (buf,"%s\n" , opts->dhchap_ctrl_secret); } -static ssize_t nvme_ctrl_dhchap_ctrl_secret_store (struct device *dev, +static ssize_t dhchap_ctrl_secret_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct nvme_ctrl *ctrl =dev_get_drvdata (dev);
@@ -3954,8 +3953,7 @@ static ssize_t nvme_ctrl_dhchap_ctrl_secret_store(struct device *dev,return count; } -static DEVICE_ATTR(dhchap_ctrl_secret, S_IRUGO | S_IWUSR, - nvme_ctrl_dhchap_ctrl_secret_show, nvme_ctrl_dhchap_ctrl_secret_store); +static DEVICE_ATTR_ADMIN_RW (dhchap_ctrl_secret);#endif static struct attribute *nvme_dev_attrs[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1394/2857 bnxt_en: dont leave an XDP program installed when the open fails
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vaibhav Nagare <[email protected]>
[ Upstream commit 78731b46967e3e7102b5cd5062bef185f3404b5c ]
bnxt_xdp_set() stores the new program and drops the reference on the old one before reopening the NIC. If bnxt_open_nic() then fails, ndo_bpf() returns an error with the new program still in bp->xdp_prog. The caller treats the error as "nothing was installed" and drops its own reference, so bp->xdp_prog is left pointing at a freed program and the next XDP update dereferences it:
BUG: unable to handle page fault for address: ff78ecc80ddd1038 RIP: 0010:__bpf_prog_put+0x5/0x80 Call Trace: bnxt_xdp_set+0xad/0x1b0 [bnxt_en] dev_xdp_propagate+0x36/0xa0 bond_xdp_set+0xeb/0x2d0 [bonding] dev_xdp_install+0x1b1/0x350 bpf_xdp_link_update+0xc5/0x1b0 link_update+0x104/0x1e0 __sys_bpf+0x662/0xcf0
Seen on a 6.12 based kernel after bnxt_alloc_mem() failed an order-4 allocation on a fragmented host:
bnxt_en 0000:a0:00.1 ens4f1np1: nic open fail (rc: fffffff4)
bond1: (slave ens4f1np1): Error -12 calling ndo_bpf
Bonding is not required to hit this; a plain XDP attach on a bnxt interface takes the same path.
Restore the previous program when an attach or a replace fails, and recompute the page-mode and XDP TX ring configuration from it. The configuration matters because bnxt_init_one_rx_ring() only assigns rxr->xdp_prog in page mode, and __bnxt_set_rx_skb_mode() derives dev->max_mtu from the installed program. Release the old program only once the change has been committed.
A detach is not undone. dev_xdp_detach_link() clears the core's record of the program even when the driver returns an error, so putting the program back would leave the driver running a program the core has already dropped. If the reopen fails during a detach, bnxt_xdp_set() therefore returns 0 with the device closed; bnxt_open_nic() has already logged the failure.
Found in a crash dump; the change was not tested on hardware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +20 -5
@@ -390,6 +390,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)struct net_device *dev = bp->dev;int tx_xdp =0 , rc, tc;struct bpf_prog *old; +int old_tx_xdp;if (prog && !prog->aux->xdp_has_frags && bp->dev->mtu >BNXT_MAX_PAGE_MODE_MTU ) {
@@ -416,11 +417,12 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)if (netif_running (dev))bnxt_close_nic (bp, true, false); + old_tx_xdp = bp->tx_nr_rings_xdp; old =xchg (&bp->xdp_prog, prog); -if (old) -bpf_prog_put (old); -if (prog) { +apply_cfg: + tc =netdev_get_num_tc (dev) ? :1 ; +if (bp->xdp_prog) {bnxt_set_rx_skb_mode (bp, true); }else {bnxt_set_rx_skb_mode (bp, false);
@@ -431,8 +433,21 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)bnxt_set_tpa_flags (bp);bnxt_set_ring_params (bp); -if (netif_running (dev)) -return bnxt_open_nic (bp, true, false); +if (rc) +return rc; + +if (netif_running (dev)) { + rc =bnxt_open_nic (bp, true, false); +/* a detach cannot be undone, only an attach */ +if (rc && prog) { +WRITE_ONCE (bp->xdp_prog, old); + tx_xdp = old_tx_xdp; + goto apply_cfg; + } + } + +if (old) +bpf_prog_put (old);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1395/2857 mm/madvise: atomically clear the young bit on THP MADV_COLD
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pedro Falcato <[email protected]>
[ Upstream commit 246c8cc33438a71c28f9b86baa492d9a0a130316 ]
As-is, madvise_cold_or_pageout_pte_range() discards the hardware young bit by invalidating the PMD, doing pmd_mkold() and subsequently writing to the pmd again. However, it does so in a racy manner, looking at a possibly-stale snapshot. It's entirely possible that a write elsewhere set the hardware D bit, which this logic now loses.
Fix it by using pmdp_test_and_clear_young(). This is an atomic modification of the PMD entry, and thus safe against any possible racing writes. As a (nice) side-effect, this elides one non-required TLB flush in pmdp_invalidate().
This bug can interact with the swapping system in complicated ways, leading to data loss. For instance, if a folio is marked lazyfree, but was later read from, and then MADV_COLD'd while racing a write to that same THP, dropping the dirty bit may lead to data loss as reclaim/MADV_PAGEOUT drops the "clean" anon folio:
T0 T1
================================================================MADV_FREE(thp) |
folio marked lazyfree |
read(thp) |
PMD marked young by hardware |
| MADV_COLD(thp)
write(thp) | if (pmd_young(pmd)) {
PMD marked dirty by hardware | set(pmdp, pmd_mkold(pmd));
MADV_PAGEOUT/reclaim |
dirty bit may or may not be |
set |
reclaim/pageout may drop |
the folio |
--- mm/madvise.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/madvise.c +1 -4
@@ -379,10 +379,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, }if (pmd_young (orig_pmd)) { -pmdp_invalidate (vma, addr, pmd); - orig_pmd =pmd_mkold (orig_pmd); - -set_pmd_at (mm, addr, pmd, orig_pmd); +pmdp_test_and_clear_young (vma, addr, pmd);tlb_remove_pmd_tlb_entry (tlb, pmd, addr); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1396/2857 fs/ntfs3: validate the EA value length in ntfs_read_ea()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuejie Shi <[email protected]>
[ Upstream commit 351817226fbf0031c4c63d1f5d7f15c3172312eb ]
ntfs_read_ea() checks the $EA list for consistency, but it only recomputes the packed size of an entry when the entry's own size field is zero:
for (off = 0; off < size; off += ea_size) {
const struct EA_FULL *ef = Add2Ptr(ea_p, off);
u32 bytes = size - off;
...
if (ef->size) {
ea_size = le32_to_cpu(ef->size);
if (ea_size > bytes)
goto out1;
continue; /* <- elength never checked */
}
...
ea_size = ALIGN(struct_size(ef, name,
1 + ef->name_len +
le16_to_cpu(ef->elength)),
4);
if (ea_size > bytes)
goto out1;
}ef->size is non-zero for every entry except the last one, and it is what ntfs3 itself writes (ntfs_set_ea() stores exactly that aligned packed size), so in practice elength is not validated at all. find_ea() then uses unpacked_ea_size(), which also prefers ea->size when it is set, so it agrees and hands the entry back.
ntfs_get_ea() copies elength bytes with no further bound of its own:
len = le16_to_cpu(ea->elength);
...
if (len > size) { /* size is the *caller's* buffer */
err = -ERANGE;
...
}
memcpy(buffer, ea->name + ea->name_len + 1, len);so a caller that supplies a large enough buffer receives up to 64 KiB of whatever follows the small $EA allocation -- straight to userspace via getxattr(2).
Compute the packed size unconditionally and require it to fit in the entry. Hoist the "bytes < offsetof(struct EA_FULL, name)" test above the ef->size branch as well: name_len and elength were being read there without it, which is itself a small over-read of the kmalloc'd buffer when fewer than 8 bytes are left. The old "bytes < sizeof(ef->size)" test is subsumed by it.
# mkntfs image; create /mnt/ntfs/poc with user.ntfs6 set, then rewrite
# that EA_FULL's elength from 0xf to 0xff00 on the raw device
mount -t ntfs3 -o ro /dev/vda /mnt/ntfs
getxattr("/mnt/ntfs/poc", "user.ntfs6", buf, 128 * 1024);BUG: KASAN: slab-out-of-bounds in ntfs_get_ea+0x294/0x3e0 Read of size 65280 at addr ffff0000cca53acf by task xattr_probe/142 __asan_memcpy+0x3c/0xa0 ntfs_get_ea+0x294/0x3e0 ntfs_getxattr+0x284/0x318 __vfs_getxattr+0x104/0x160 vfs_getxattr+0x1b4/0x1e0 do_getxattr+0xcc/0x230 path_getxattrat+0x184/0x270 __arm64_sys_getxattr+0x64/0x80 Allocated by task 142: __kmalloc_noprof+0x294/0x668 ntfs_read_ea+0x1e4/0x420 ntfs_get_ea+0x2c8/0x3e0 The buggy address belongs to the object at ffff0000cca53a80 which belongs to the cache kmalloc-96 of size 96
The object being over-read is the one ntfs_read_ea() just allocated, and it is 96 bytes.
Entries written by ntfs3 and by Windows set size to the aligned packed size, so the new test does not reject anything a working filesystem produces.
--- fs/ntfs3/xattr.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
fs/ntfs3/xattr.c +14 -11
@@ -145,29 +145,32 @@ static int ntfs_read_ea(struct ntfs_inode *ni, struct EA_FULL **ea,for (off =0 ; off < size; off += ea_size) {const struct EA_FULL *ef =Add2Ptr (ea_p, off);u32 bytes = size - off; -size_t need; - -/* Check if we can use field ea->size. */ -if (bytes <sizeof (ef->size)) - goto out1; +u32 packed_size;/* Check if we can use fields ef->name_len and ef->elength. */ if (bytes < offsetof(struct EA_FULL , name)) goto out1; -/* Size needed to hold this record's name and value. */ - need =struct_size (ef, name, -1 + ef->name_len +le16_to_cpu (ef->elength)); +/* +* The name and the value have to fit in the entry whether or +* not ef->size is set, because ntfs_get_ea() copies elength +* bytes out of this buffer and checks them only against the +* caller supplied buffer size. +*/ + packed_size = +ALIGN (struct_size (ef, name, +1 + ef->name_len + +le16_to_cpu (ef->elength)), +4 );if (ef->size) { ea_size =le32_to_cpu (ef->size); -/* ef->size must fit the list and cover the record. */ -if (ea_size > bytes || ea_size < need) +if (ea_size > bytes || packed_size > ea_size) goto out1;continue ; } - ea_size =ALIGN (need,4 ); + ea_size = packed_size;if (ea_size > bytes) goto out1; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1397/2857 usb: xhci: Fix bounce buffer overflow
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
[ Upstream commit 68c5cb7574c567e83ba95258cb146db95e069a87 ]
High-speed devices with out of spec 1024 byte bulk endpoints exist and are allowed by USB core, but xhci-hcd always sets packet size to 512. The exact nature of these devices isn't documented, commit fb5ee84ea72c ("USB: Accept bulk endpoints with 1024-byte maxpacket") only states that they "don't work with xHCI host controllers", whatever it means.
But somebody (or a malicious device) can try, and then the driver will allocate a 512 byte bounce buffer for this endpoint and may write up to 1024 bytes into it if particular scatter-gather URBs are used, because xhci_align_td() obtains packet size from the descriptor. Fix this.
As a side effect, TRBs will be aligned to the packet size chosen by the driver on all endpoints of all speeds. Alignment serves the xHC, not device, so this is fine. Only out of spec devices are affected anyway.
--- drivers/usb/host/xhci-ring.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/usb/host/xhci-ring.c +3 -6
@@ -3619,15 +3619,13 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred,static int xhci_align_td (struct xhci_hcd *xhci,struct urb *urb,u32 enqd_len, -u32 *trb_buff_len,struct xhci_segment *seg) +u32 *trb_buff_len,struct xhci_segment *seg,u32 max_pkt) {struct device *dev =xhci_to_hcd (xhci)->self.sysdev;unsigned int unalign; -unsigned int max_pkt;u32 new_buff_len;size_t len; - max_pkt =usb_endpoint_maxp (&urb->ep->desc); unalign = (enqd_len + *trb_buff_len) % max_pkt;/* we got lucky, last normal TRB data on segment is packet aligned */
@@ -3772,9 +3770,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,if (enqd_len + trb_buff_len < full_len) { field |=TRB_CHAIN ;if (trb_is_link (ring->enqueue +1 )) { -if (xhci_align_td (xhci, urb, enqd_len, - &trb_buff_len, - ring->enq_seg)) { +if (xhci_align_td (xhci, urb, enqd_len, &trb_buff_len, + ring->enq_seg, ring->bounce_buf_len)) { send_addr = ring->enq_seg->bounce_dma;/* TD bounced at least, and last on this seg */ td->bounce_seg = ring->enq_seg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1398/2857 ALSA: usb-audio: Bound packet copies by the PCM buffer size
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinan Turunc <[email protected]>
[ Upstream commit 06be918062adc1a5a76dc346803b136b20bdb5ae ]
retire_capture_urb() and prepare_playback_urb() assume that one USB packet never carries more data than the whole ALSA ring buffer. Nothing enforces that: the packet size comes from the device (wMaxPacketSize, and curpacksize == maxpacksize when the class-specific endpoint descriptor sets MaxPacketsOnly), while the PCM hardware constraints only require 64-byte periods, two periods and a period time of one data interval. An 8 kHz mono U8 stream on a 128-byte buffer is legal, and a full-speed device can send 1023-byte packets into it.
On the first oversized packet hwptr_done is wrapped once and stays beyond buffer_bytes (895 for 1023 bytes into 128). On the next packet the wrap arithmetic in the copy path computes
bytes1 = subs->buffer_bytes - oldptr
with oldptr > buffer_bytes, so bytes1 wraps to about 4 GB and memcpy() runs off the end of the URB buffer and of the vmalloc'd DMA buffer:
BUG: KASAN: slab-out-of-bounds in retire_capture_urb+0x251/0x870 Read of size 4294966529 at addr ffff88800c1e2800 by task vhci_rx/82
and for playback, where copy_to_urb() has the same shape:
BUG: KASAN: vmalloc-out-of-bounds in copy_to_urb.isra.0+0x188/0x430 Read of size 4294966529 at addr ffffc9000004537f by task vhci_rx/79 prepare_playback_urb+0x98a/0x1fc0
Truncate an oversized capture packet to the buffer size, and stop filling a playback URB once it holds a whole buffer. With bytes <= buffer_bytes the single wrap of hwptr_done and the two-part memcpy() in both copy paths stay inside the buffer. A device whose packets do not fit the buffer at all was never going to play correctly anyway.
Reproduced on 7.3-rc7 with a USB/IP device (dummy_hcd cannot carry isochronous data) advertising a UAC1 endpoint with MaxPacketsOnly and wMaxPacketSize 1023, and a PCM client using period_size 64, periods 2.
--- sound/usb/pcm.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
sound/usb/pcm.c +19 -1
@@ -1248,6 +1248,18 @@ static void retire_capture_urb(struct snd_usb_substream *subs, bytes -= adj; subs->stream_offset_adj -= adj; } +/* +* A packet can be as large as the endpoint's maxpacksize, which +* the device chooses, while the ring buffer can be as small as +* two 64-byte periods. The hwptr_done wrap below handles one +* wrap only, so never take more than one buffer from a packet. +*/ +if (unlikely (bytes > subs->buffer_bytes)) { +dev_warn_ratelimited (&subs->dev->dev, +"%u-byte packet exceeds %u-byte buffer, truncating\n" , + bytes, subs->buffer_bytes); + bytes = subs->buffer_bytes; + } frames = bytes / stride;if (!subs->txfr_quirk) bytes = frames * stride;
@@ -1461,8 +1473,14 @@ static int prepare_playback_urb(struct snd_usb_substream *subs,for (i =0 ; i < ctx->packets; i++) { counts =snd_usb_endpoint_next_packet_size (ep, ctx, i, avail); +/* +* Bound by the ring buffer as well as by the URB: +* copy_to_urb() wraps hwptr_done once, so one URB must +* never carry more than the whole buffer. +*/ if (counts <0 || - (frames + counts) * stride > ctx->buffer_size) + (frames + counts) * stride > ctx->buffer_size || + (frames + counts) * stride > subs->buffer_bytes)break ;/* set up descriptor */ urb->iso_frame_desc[i].offset = frames * stride;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1399/2857 mm/hugetlb: unmap the page where the other VMA maps it
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit ae99c503eb362b42cd5d24d80bc6cba669acc4c2 ]
If the owner of a MAP_PRIVATE hugetlb mapping fails to allocate a page for CoW, unmap_ref_private() unmaps the old page from all other private VMAs that have no reservation of their own. It finds them by the offset in the file, but then zaps each of them at the address of the faulting VMA. Nothing says that another VMA maps the offset at that address: a child can have moved its copy of the VMA with mremap(), and a second mapping of the file is wherever mmap() has put it.
So __unmap_hugepage_range() walks the page tables of the other mm at an address outside of iter_vma, where i_mmap_rwsem of this file protects nothing and where anything can be mapped, and the page stays mapped where it really is.
All of the following was seen on v7.3-rc6+ (g6c377d19d4a5) in KVM guests, as a user without any privilege. It takes a pool of 2 MiB pages with no free page that is not reserved, so that the allocation fails: the user can take or reserve what is free itself.
- The child moves its VMA away. The page is never unmapped, the mapcount stays 2, and the owner goes round retry_avoidcopy in hugetlb_wp() until the child is gone or a page becomes free. SIGKILL to the owner does not end it. 5 of 5 runs.
- The owner's mm has a second private mapping of the offset, made with MAP_NORESERVE. The owner zaps its own entry and reads zeroes where its data was. 5 of 5 runs.
- The child moves its VMA away and maps a 1 GiB hugetlb page at the old address, so this one takes a pool with a 1 GiB page as well. huge_pte_offset() for the 2 MiB size steps through the PUD leaf, so the "PMD table" is the 1 GiB page itself and its "page table lock" is folio->private of that page, which holds 2. Kernels with lock debugging oops in __unmap_hugepage_range(), 7 of 7 runs. Others spin on that word for ever with preemption disabled, 5 of 5 runs:
watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [u_det3:130]
RIP: 0010:queued_spin_lock_slowpath+0x8a/0x290
RAX: 0000000000000002 RBX: ffffea0001000028
Call Trace:
__unmap_hugepage_range+0x154/0x6d0
unmap_hugepage_range+0xc1/0x140
hugetlb_wp+0x55c/0x700
hugetlb_fault+0x5f3/0x8f0RCU stalls follow, and killing all tasks of the user changes nothing. Four such owners, whose children share a single 1 GiB page, took down the whole guest with its four CPUs, 2 of 2 runs: one reported soft lockups on all four, the other gave no sign of life any more.
i_mmap_rwsem stays write locked. With a MAP_PRIVATE mapping of a hugetlbfs file that belongs to another user, and that the attacker can only read, the next mmap() of that file by its owner sleeps uninterruptibly in __mmap_region(), 4 of 4 runs.
Compute the address from the offset for each VMA. The tree walk returns only VMAs that cover pgoff, and vm_start, vm_end and vm_pgoff of a hugetlb VMA are aligned to the huge page size, as pgoff is, so the whole range lies inside iter_vma. Its page tables can not go away there, since the VMA is unlinked from the file under i_mmap_rwsem first.
With the right address the page is unmapped from all VMAs but the owner's, so the retry in hugetlb_wp() finds a mapcount of 1 and reuses the page.
A child that has moved its copy of the VMA now loses the page, and gets SIGBUS when it faults on a missing page of that VMA. That is what the comment above the function has always promised to those who do not own the reservation, and what already happens to a child that has left the VMA in place.
The address has been wrong from the start, and the second case needs only mmap() and fork(). mremap() of hugetlb VMAs, which the other cases use, came with commit 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") in v5.16.
Original fix generated by an LLM and sent in private by Josef.
--- mm/hugetlb.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
mm/hugetlb.c +13 -3
@@ -5500,6 +5500,8 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,struct address_space *mapping;pgoff_t pgoff; +VM_WARN_ON_ONCE (!folio_test_anon (page_folio (page))); +/* * vm_pgoff is in PAGE_SIZE units, hence the different calculation * from page cache lookup which is in HPAGE_SIZE units.
@@ -5535,9 +5537,17 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,* could insert a zeroed page instead of the data existing * from the time of fork. This would look like data corruption */ -if (!is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) -unmap_hugepage_range (iter_vma, address, - address +huge_page_size (h), page,0 ); +if (is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) +continue ; + +/* +* The address in other VMAs can differ. Even though our old +* folio is anon, we always operate on the underlying hugetlb +* file. +*/ + address =vma_pgoff_address (pgoff,1 , iter_vma); +unmap_hugepage_range (iter_vma, address, + address +huge_page_size (h), page,0 ); }i_mmap_unlock_write (mapping); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1400/2857 ipv4: tunnels: use DEV_STATS_INC()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit c4794d22251b979b12a6c8e2d3848b662a44fdb6 ]
Most of code paths in tunnels are lockless (eg NETIF_F_LLTX in tx).
Adopt SMP safe DEV_STATS_INC() to update dev->stats fields.
Stable-dep-of: aa1799e93f5e ("ipmr, ip6mr: validate packets injected into the register vif on xmit")
--- net/ipv4/ip_gre.c | 10 +++++----- net/ipv4/ip_tunnel.c | 32 ++++++++++++++++---------------- net/ipv4/ip_vti.c | 20 ++++++++++---------- net/ipv4/ipip.c | 2 +- net/ipv4/ipmr.c | 12 ++++++------ 5 files changed, 38 insertions(+), 38 deletions(-)
net/ipv4/ip_gre.c +5 -5
@@ -515,7 +515,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev, err_free_skb:kfree_skb (skb); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped); }static void erspan_fb_xmit (struct sk_buff *skb,struct net_device *dev)
@@ -597,7 +597,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev) err_free_skb:kfree_skb (skb); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped); }static int gre_fill_metadata_dst (struct net_device *dev,struct sk_buff *skb)
@@ -671,7 +671,7 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb, free_skb:kfree_skb (skb); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);return NETDEV_TX_OK ; }
@@ -725,7 +725,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb, free_skb:kfree_skb (skb); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);return NETDEV_TX_OK ; }
@@ -753,7 +753,7 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb, free_skb:kfree_skb (skb); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);return NETDEV_TX_OK ; }
net/ipv4/ip_tunnel.c +16 -16
@@ -382,23 +382,23 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,#ifdef CONFIG_NET_IPGRE_BROADCAST if (ipv4_is_multicast (iph->daddr)) { - tunnel->dev->stats.multicast++; +DEV_STATS_INC (tunnel->dev, multicast); skb->pkt_type =PACKET_BROADCAST ; }#endif if ((!(tpi->flags&TUNNEL_CSUM ) && (tunnel->parms.i_flags&TUNNEL_CSUM )) || ((tpi->flags&TUNNEL_CSUM ) && !(tunnel->parms.i_flags&TUNNEL_CSUM ))) { - tunnel->dev->stats.rx_crc_errors++; - tunnel->dev->stats.rx_errors++; +DEV_STATS_INC (tunnel->dev, rx_crc_errors); +DEV_STATS_INC (tunnel->dev, rx_errors); goto drop; }if (tunnel->parms.i_flags&TUNNEL_SEQ ) {if (!(tpi->flags&TUNNEL_SEQ ) || (tunnel->i_seqno && (s32)(ntohl (tpi->seq) - tunnel->i_seqno) <0 )) { - tunnel->dev->stats.rx_fifo_errors++; - tunnel->dev->stats.rx_errors++; +DEV_STATS_INC (tunnel->dev, rx_fifo_errors); +DEV_STATS_INC (tunnel->dev, rx_errors); goto drop; } tunnel->i_seqno =ntohl (tpi->seq) +1 ;
@@ -425,8 +425,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,net_info_ratelimited ("non-ECT from %pI4 with TOS=%#x\n" , &iph->saddr, iph->tos);if (err >1 ) { - ++tunnel->dev->stats.rx_frame_errors; - ++tunnel->dev->stats.rx_errors; +DEV_STATS_INC (tunnel->dev, rx_frame_errors); +DEV_STATS_INC (tunnel->dev, rx_errors); goto drop; } }
@@ -612,7 +612,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,if (!rt) { rt =ip_route_output_key (tunnel->net, &fl4);if (IS_ERR (rt)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error; }if (use_cache)
@@ -621,7 +621,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, }if (rt->dst.dev == dev) {ip_rt_put (rt); - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions); goto tx_error; }
@@ -656,10 +656,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, df, !net_eq(tunnel->net, dev_net(dev)));return ; tx_error: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors); goto kfree; tx_dropped: - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped); kfree:kfree_skb (skb); }
@@ -693,7 +693,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,/* NBMA tunnel */ if (!skb_dst (skb)) { - dev->stats.tx_fifo_errors++; +DEV_STATS_INC (dev, tx_fifo_errors); goto tx_error; }
@@ -780,7 +780,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev, rt =ip_route_output_key (tunnel->net, &fl4);if (IS_ERR (rt)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error; }if (use_cache)
@@ -793,7 +793,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,if (rt->dst.dev == dev) {ip_rt_put (rt); - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions); goto tx_error; }
@@ -834,7 +834,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,if (skb_cow_head (skb, max_headroom)) {ip_rt_put (rt); - dev->stats.tx_dropped++; +DEV_STATS_INC (dev, tx_dropped);kfree_skb (skb);return ; }
@@ -850,7 +850,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,dst_link_failure (skb);#endif tx_error: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb); }EXPORT_SYMBOL_GPL (ip_tunnel_xmit);
net/ipv4/ip_vti.c +10 -10
@@ -107,8 +107,8 @@ static int vti_rcv_cb(struct sk_buff *skb, int err) dev = tunnel->dev;if (err) { - dev->stats.rx_errors++; - dev->stats.rx_dropped++; +DEV_STATS_INC (dev, rx_errors); +DEV_STATS_INC (dev, rx_dropped);return 0 ; }
@@ -183,7 +183,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev, fl->u.ip4.flowi4_flags |=FLOWI_FLAG_ANYSRC ; rt =__ip_route_output_key (dev_net (dev), &fl->u.ip4);if (IS_ERR (rt)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; } dst = &rt->dst;
@@ -198,14 +198,14 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,if (dst->error) {dst_release (dst); dst =NULL ; - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; }skb_dst_set (skb, dst);break ;#endif default : - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; } }
@@ -213,7 +213,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,dst_hold (dst); dst =xfrm_lookup_route (tunnel->net, dst, fl,NULL ,0 );if (IS_ERR (dst)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors); goto tx_error_icmp; }
@@ -221,7 +221,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev, goto xmit;if (!vti_state_check (dst->xfrm, parms->iph.daddr, parms->iph.saddr)) { - dev->stats.tx_carrier_errors++; +DEV_STATS_INC (dev, tx_carrier_errors);dst_release (dst); goto tx_error_icmp; }
@@ -230,7 +230,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev,if (tdev == dev) {dst_release (dst); - dev->stats.collisions++; +DEV_STATS_INC (dev, collisions); goto tx_error; }
@@ -267,7 +267,7 @@ static netdev_tx_t vti_xmit(struct sk_buff *skb, struct net_device *dev, tx_error_icmp:dst_link_failure (skb); tx_error: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb);return NETDEV_TX_OK ; }
@@ -304,7 +304,7 @@ static netdev_tx_t vti_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)return vti_xmit (skb, dev, &fl); tx_err: - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);kfree_skb (skb);return NETDEV_TX_OK ; }
net/ipv4/ipip.c +1 -1
@@ -311,7 +311,7 @@ static netdev_tx_t ipip_tunnel_xmit(struct sk_buff *skb, tx_error:kfree_skb (skb); - dev->stats.tx_errors++; +DEV_STATS_INC (dev, tx_errors);return NETDEV_TX_OK ; }
net/ipv4/ipmr.c +6 -6
@@ -518,8 +518,8 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev)return err; } - dev->stats.tx_bytes += skb->len; - dev->stats.tx_packets++; +DEV_STATS_ADD (dev, tx_bytes, skb->len); +DEV_STATS_INC (dev, tx_packets);rcu_read_lock ();/* Pairs with WRITE_ONCE() in vif_add() and vif_delete() */
@@ -1852,8 +1852,8 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,if (vif->flags &VIFF_REGISTER ) {WRITE_ONCE (vif->pkt_out, vif->pkt_out +1 );WRITE_ONCE (vif->bytes_out, vif->bytes_out + skb->len); - vif_dev->stats.tx_bytes += skb->len; - vif_dev->stats.tx_packets++; +DEV_STATS_ADD (vif_dev, tx_bytes, skb->len); +DEV_STATS_INC (vif_dev, tx_packets);ipmr_cache_report (mrt, skb, vifi,IGMPMSG_WHOLEPKT ); goto out_free; }
@@ -1911,8 +1911,8 @@ static void ipmr_queue_xmit(struct net *net, struct mr_table *mrt,if (vif->flags &VIFF_TUNNEL ) {ip_encap (net, skb, vif->local, vif->remote);/* FIXME: extra output firewall step used to be here. --RR */ - vif_dev->stats.tx_packets++; - vif_dev->stats.tx_bytes += skb->len; +DEV_STATS_INC (vif_dev, tx_packets); +DEV_STATS_ADD (vif_dev, tx_bytes, skb->len); }IPCB (skb)->flags |=IPSKB_FORWARDED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1401/2857 ipmr: Call ipmr_fib_lookup() under RCU.
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 019c892e46544af0ae94ec833f79aa903c837666 ]
Yi Lai reported RCU splat in reg_vif_xmit() below. [0]
When CONFIG_IP_MROUTE_MULTIPLE_TABLES=n, ipmr_fib_lookup() uses rcu_dereference() without explicit rcu_read_lock().
Although rcu_read_lock_bh() is already held by the caller __dev_queue_xmit(), lockdep requires explicit rcu_read_lock() for rcu_dereference().
Let's move up rcu_read_lock() in reg_vif_xmit() to cover ipmr_fib_lookup().
[0]:
WARNING: suspicious RCU usage 7.1.0-rc2-next-20260504-9d0d467c3572 #1 Not tainted
-----------------------------net/ipv4/ipmr.c:329 suspicious rcu_dereference_check() usage!
other info that might help us debug this:
rcu_scheduler_active = 2, debug_locks = 1
2 locks held by syz.2.17/1779:
#0: ffffffff87896440 (rcu_read_lock_bh){....}-{1:3}, at: local_bh_disable include/linux/bottom_half.h:20 [inline] #0: ffffffff87896440 (rcu_read_lock_bh){....}-{1:3}, at: rcu_read_lock_bh include/linux/rcupdate.h:891 [inline] #0: ffffffff87896440 (rcu_read_lock_bh){....}-{1:3}, at: __dev_queue_xmit+0x239/0x4140 net/core/dev.c:4792 #1: ffff88801a199d18 (_xmit_PIMREG#2){+...}-{3:3}, at: spin_lock include/linux/spinlock.h:342 [inline] #1: ffff88801a199d18 (_xmit_PIMREG#2){+...}-{3:3}, at: __netif_tx_lock include/linux/netdevice.h:4795 [inline] #1: ffff88801a199d18 (_xmit_PIMREG#2){+...}-{3:3}, at: __dev_queue_xmit+0x1d5d/0x4140 net/core/dev.c:4865
stack backtrace: CPU: 1 UID: 0 PID: 1779 Comm: syz.2.17 Not tainted 7.1.0-rc2-next-20260504-9d0d467c3572 #1 PREEMPT(lazy) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x121/0x150 lib/dump_stack.c:120 dump_stack+0x19/0x20 lib/dump_stack.c:129 lockdep_rcu_suspicious+0x15b/0x1f0 kernel/locking/lockdep.c:6878 ipmr_fib_lookup net/ipv4/ipmr.c:329 [inline] reg_vif_xmit+0x2ee/0x3c0 net/ipv4/ipmr.c:540 __netdev_start_xmit include/linux/netdevice.h:5382 [inline] netdev_start_xmit include/linux/netdevice.h:5391 [inline] xmit_one net/core/dev.c:3889 [inline] dev_hard_start_xmit+0x170/0x700 net/core/dev.c:3905 __dev_queue_xmit+0x1df1/0x4140 net/core/dev.c:4871 dev_queue_xmit include/linux/netdevice.h:3423 [inline] packet_xmit+0x252/0x370 net/packet/af_packet.c:276 packet_snd net/packet/af_packet.c:3082 [inline] packet_sendmsg+0x39ad/0x5650 net/packet/af_packet.c:3114 sock_sendmsg_nosec net/socket.c:797 [inline] __sock_sendmsg net/socket.c:812 [inline] ____sys_sendmsg+0xa21/0xba0 net/socket.c:2716 ___sys_sendmsg+0x121/0x1c0 net/socket.c:2770 __sys_sendmsg+0x177/0x220 net/socket.c:2802 __do_sys_sendmsg net/socket.c:2807 [inline] __se_sys_sendmsg net/socket.c:2805 [inline] __x64_sys_sendmsg+0x80/0xc0 net/socket.c:2805 x64_sys_call+0x1d9c/0x21c0 arch/x86/include/generated/asm/syscalls_64.h:47 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xc1/0x1020 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x76/0x7e RIP: 0033:0x7f37e563ee5d 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 8b 0d 93 af 1b 00 f7 d8 64 89 01 48 RSP: 002b:00007ffe5caa7fa8 EFLAGS: 00000246 ORIG_RAX: 000000000000002e RAX: ffffffffffffffda RBX: 00000000005c5fa0 RCX: 00007f37e563ee5d RDX: 0000000000000000 RSI: 00002000000012c0 RDI: 0000000000000004 RBP: 00000000005c5fa0 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 R13: 0000000000000000 R14: 00000000005c5fac R15: 00000000005c5fa0 </TASK>
Stable-dep-of: aa1799e93f5e ("ipmr, ip6mr: validate packets injected into the register vif on xmit")
--- net/ipv4/ipmr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/ipv4/ipmr.c +2 -1
@@ -512,15 +512,16 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) };int err; +rcu_read_lock (); err =ipmr_fib_lookup (net, &fl4, &mrt);if (err <0 ) { +rcu_read_unlock ();kfree_skb (skb);return err; }DEV_STATS_ADD (dev, tx_bytes, skb->len);DEV_STATS_INC (dev, tx_packets); -rcu_read_lock ();/* Pairs with WRITE_ONCE() in vif_add() and vif_delete() */ ipmr_cache_report(mrt, skb, READ_ONCE(mrt->mroute_reg_vif_num),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1402/2857 ipmr, ip6mr: validate packets injected into the register vif on xmit
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit aa1799e93f5ebb973252aec649d84d12d9c7fd1c ]
reg_vif_xmit() passes the packet to ipmr_cache_report() which copies its IP header into the IGMPMSG_WHOLEPKT report that is queued to the mroute socket. Nothing guarantees that the packet contains a full IP header, so when a short packet is injected on the register device (e.g., using AF_PACKET), the copy reads past the end of the packet and a recvmsg() on the mroute socket leaks the uninitialized bytes to user space [1].
IPv6 has the same problem [2]. Its reg_vif_xmit() does call pskb_inet_may_pull(), but the helper keys off skb->protocol and does not pull anything when the protocol is neither IPv4 nor IPv6.
Fix by dropping packets whose protocol does not match the address family of the register device or that do not contain a full network header.
[1]
BUG: KMSAN: kernel-infoleak in _copy_to_iter raw_recvmsg
Uninit was stored to memory at:
ipmr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 1-3 of 21 are uninitialized
[2]
BUG: KMSAN: kernel-infoleak in _copy_to_iter rawv6_recvmsg
Uninit was stored to memory at:
ip6mr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 8-23 of 41 are uninitialized
--- net/ipv4/ipmr.c | 6 ++++++ net/ipv6/ip6mr.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ipmr.c +6 -0
@@ -512,6 +512,12 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) };int err; +if (skb->protocol !=htons (ETH_P_IP ) || !pskb_inet_may_pull (skb)) { +DEV_STATS_INC (dev, tx_errors); +kfree_skb (skb); +return NETDEV_TX_OK ; + } +rcu_read_lock (); err =ipmr_fib_lookup (net, &fl4, &mrt);if (err <0 ) {
net/ipv6/ip6mr.c +1 -1
@@ -616,7 +616,7 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, .flowi6_mark = skb->mark, }; -if (!pskb_inet_may_pull (skb)) +if (skb->protocol !=htons (ETH_P_IPV6 ) || !pskb_inet_may_pull (skb)) goto tx_err;if (ip6mr_fib_lookup (net, &fl6, &mrt) <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1403/2857 loop: check for read-write open mode on LOOP_SET_STATUS in lo_compat_ioctl()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominik Maier <[email protected]>
[ Upstream commit 87409eedc543d288cdd49c2174f7d61eca7b8db5 ]
lo_ioctl() checks for (mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN) before allowing LOOP_SET_STATUS or LOOP_SET_STATUS64, but not lo_compat_ioctl(), the handler used by 32-bit user space on 64-bit kernels.
As a result, on 64-bit kernels with CONFIG_COMPAT=y, a 32-bit unprivileged user-space process holding a read-only (O_RDONLY) file descriptor to an active /dev/loopN device can issue a compat LOOP_SET_STATUS ioctl to modify lo_offset, clear lo_sizelimit to 0 (exposing backing-file data past the configured limit), or alter lo_flags.
Enforce the same (mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN) check on LOOP_SET_STATUS in lo_compat_ioctl().
--- drivers/block/loop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/loop.c +4 -2
@@ -1717,8 +1717,10 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode,switch (cmd) {case LOOP_SET_STATUS : - err =loop_set_status_compat (lo, - (const struct compat_loop_info __user *)arg); + err = -EPERM ; +if ((mode &FMODE_WRITE ) ||capable (CAP_SYS_ADMIN )) + err =loop_set_status_compat (lo, + (const struct compat_loop_info __user *)arg);break ;case LOOP_GET_STATUS : err = loop_get_status_compat(lo,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1404/2857 mm/page_vma_mapped: continue past nonmatching huge PMDs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 1a2993227e8a27fc4cdea305bbdae82d290bc885 ]
A PTE-mapped large folio can straddle PMD boundaries after an unaligned mremap(). If the first part is discarded and replaced with an unrelated huge PMD, page_vma_mapped_walk() stops instead of looking for the rest of the folio in subsequent PMDs.
This also affects migration entries. A walk that stops at an unrelated huge PMD can leave migration PTEs behind when migration or an anonymous folio split restores the mappings. Those entries do not hold mapping references and can outlive the source folio.
This issue can lead to memory corruption and I have a reproducer for it.
Skip the current PMD rather than ending the walk on a flag or PFN mismatch. Do the same if the PMD became nonpresent before the locked recheck. Release the PMD lock, clear the per-PMD state and advance with step_forward(), so the existing range limit controls termination. This covers present, migration and device-private huge PMDs while preserving the matching-PMD and split-to-PTE paths.
--- mm/page_vma_mapped.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
mm/page_vma_mapped.c +16 -6
@@ -224,18 +224,18 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)if (!thp_migration_supported () || !(pvmw->flags &PVMW_MIGRATION )) -return not_found (pvmw); + goto next_pmd; entry =pmd_to_swp_entry (pmde);if (!is_migration_entry (entry) || !check_pmd (swp_offset_pfn (entry), pvmw)) -return not_found (pvmw); + goto next_pmd;return true; }if (likely (pmd_trans_huge (pmde) ||pmd_devmap (pmde))) {if (pvmw->flags &PVMW_MIGRATION ) -return not_found (pvmw); + goto next_pmd;if (!check_pmd (pmd_pfn (pmde), pvmw)) -return not_found (pvmw); + goto next_pmd;return true; }/* THP pmd was split under us: handle on pte level */
@@ -254,8 +254,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (ptl); } -step_forward (pvmw,PMD_SIZE ); -continue ; + goto next_pmd; }if (!map_pte (pvmw)) goto next_pte;
@@ -289,6 +288,17 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_lock (pvmw->ptl); } goto this_pte; +next_pmd: +/* +* A large folio can be PTE-mapped across PMDs, so a +* nonmatching PMD does not end the walk. +*/ +if (pvmw->ptl) { +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + } + pvmw->pmd =NULL ; +step_forward (pvmw,PMD_SIZE ); }while (pvmw->address < end);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1405/2857 splice: report related fsnotify events
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chung-Chiang Cheng <[email protected]>
[ Upstream commit 983652c691990b3257a07f67f4263eb847baa82d ]
The fsnotify ACCESS and MODIFY event are missing when manipulating a file with splice(2).
Message-Id: <[email protected]>
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/splice.c +8 -0
@@ -30,6 +30,7 @@#include <linux/export.h> #include <linux/syscalls.h> #include <linux/uio.h> +#include <linux/fsnotify.h> #include <linux/security.h> #include <linux/gfp.h> #include <linux/socket.h>
@@ -1102,6 +1103,9 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); +if (ret >0 ) +fsnotify_modify (out); +if (!off_out) out->f_pos = offset;else
@@ -1125,6 +1129,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, flags |=SPLICE_F_NONBLOCK ; ret =splice_file_to_pipe (in, opipe, &offset, len, flags); + +if (ret >0 ) +fsnotify_access (in); +if (!off_in) in->f_pos = offset;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1406/2857 splice: always fsnotify_access(in), fsnotify_modify(out) on success
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahelenia Ziemiańska <[email protected]>
[ Upstream commit 12ee4b66af34f8e72f3b2fd93a946a955efe7c86 ]
The current behaviour caused an asymmetry where some write APIs (write, sendfile) would notify the written-to/read-from objects, but splice wouldn't.
This affected userspace which uses inotify, most notably coreutils tail -f, to monitor pipes.
If the pipe buffer had been filled by a splice-family function:
* tail wouldn't know and thus wouldn't service the pipe, and
* all writes to the pipe would block because it's full,
thus service was denied.
(For the particular case of tail -f this could be worked around
with ---disable-inotify.)
Message-Id: <604ec704d933e0e0121d9e107ce914512e045fad.1688393619.git.nabijaczleweli@nabijaczleweli.xyz>
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
fs/splice.c +15 -17
@@ -1075,10 +1075,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,if ((in->f_flags | out->f_flags) &O_NONBLOCK ) flags |=SPLICE_F_NONBLOCK ; -return splice_pipe_to_pipe (ipipe, opipe, len, flags); - } - -if (ipipe) { + ret =splice_pipe_to_pipe (ipipe, opipe, len, flags); + }else if (ipipe) {if (off_in)return -ESPIPE ;if (off_out) {
@@ -1103,18 +1101,11 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); -if (ret >0 ) -fsnotify_modify (out); -if (!off_out) out->f_pos = offset;else *off_out = offset; - -return ret; - } - -if (opipe) { + }else if (opipe) {if (off_out)return -ESPIPE ;if (off_in) {
@@ -1130,18 +1121,25 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =splice_file_to_pipe (in, opipe, &offset, len, flags); -if (ret >0 ) -fsnotify_access (in); -if (!off_in) in->f_pos = offset;else *off_in = offset; + }else { + ret = -EINVAL ; + } -return ret; +if (ret >0 ) { +/* +* Generate modify out before access in: +* do_splice_from() may've already sent modify out, +* and this ensures the events get merged. +*/ +fsnotify_modify (out); +fsnotify_access (in); } -return -EINVAL ; +return ret; } static long __do_splice(struct file *in, loff_t __user *off_in,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1407/2857 splice: avoid stale f_pos writeback on error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
[ Upstream commit 79b496ebe382866e3a05090b7dc9ae95e85e65b2 ]
do_splice() snapshots an implicit file position before calling the splice helper. Since splice does not take f_pos_lock, another operation on the same open file description can update f_pos while the helper is blocked. If the helper then fails, the unconditional writeback restores the stale snapshot.
For a directory without ->splice_read, a file-to-pipe splice fails with -EINVAL. A concurrent directory mutation and getdents() call can advance f_pos and refresh the filesystem's revalidation cookie before that failure restores only the old position. The next ext2 readdir can then trust an offset inside a directory entry and copy data from the adjacent page to userspace.
Only update an implicit file position when splice returns a non-negative result, matching read and write. Keep explicit offset updates unchanged.
--- fs/splice.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/splice.c +6 -6
@@ -1101,10 +1101,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); -if (!off_out) - out->f_pos = offset; -else +if (off_out) *off_out = offset; +else if (ret >=0 ) + out->f_pos = offset; }else if (opipe) {if (off_out)return -ESPIPE ;
@@ -1121,10 +1121,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =splice_file_to_pipe (in, opipe, &offset, len, flags); -if (!off_in) - in->f_pos = offset; -else +if (off_in) *off_in = offset; +else if (ret >=0 ) + in->f_pos = offset; }else { ret = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1408/2857 ALSA: control: Fix UAF in snd_ctl_elem_add() on card disconnect
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d4febca239be3c91498762dd0535a87d4af1eabc ]
A use-after-free can be triggered via SNDRV_CTL_IOCTL_ELEM_ADD when a USB audio card is disconnected while an ELEM_ADD ioctl is in flight.
The reproducer parks the ioctl thread inside copy_from_user() using userfaultfd, then tears down the USB device. Unlike every other ALSA control _user handler (ELEM_INFO, ELEM_READ, ELEM_WRITE, TLV_*), snd_ctl_elem_add_user() never calls snd_power_ref_and_wait(), so the parked thread holds no power reference. snd_card_disconnect() therefore cannot observe it via snd_power_sync_ref() and proceeds unimpeded:
1. card->shutdown is set to 1
2. device_del(&card->card_dev) drops the kobject reference on the
parent USB interface device (card->dev = &intf->dev)
3. The USB core drops its own reference and calls device_release(), freeing the struct usb_interface, including the embedded struct device that card->dev points to
When the userfaultfd is resolved and the thread resumes, snd_ctl_elem_add() acquires controls_rwsem without checking card->shutdown and calls __snd_ctl_add_replace(). Because the reproducer pre-registered the same control, the CTL_ADD_EXCLUSIVE path calls dev_err(card->dev, ...) on the freed USB interface:
KASAN: slab-use-after-free Read in __dev_printk
Add a card->shutdown guard immediately after acquiring controls_rwsem in snd_ctl_elem_add(). At that point card->shutdown is guaranteed to be stable: snd_card_disconnect() sets it before freeing the parent device, and it never transitions back to 0. A thread that acquired the lock before disconnect sees shutdown=0 and holds the write lock through the rest of the operation, preventing concurrent disconnect from proceeding past its own controls_rwsem-less shutdown=1 store (which happened earlier, outside the lock) from racing with dev_err().
--- sound/core/control.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/control.c +4 -0
@@ -1723,6 +1723,10 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file, alloc_size =compute_user_elem_size (private_size, count);down_write (&card->controls_rwsem); +if (card->shutdown) { + err = -ENODEV ; + goto unlock; + }if (check_user_elem_overflow (card, alloc_size)) { err = -ENOMEM ; goto unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1409/2857 spi: cadence-xspi: reject SDMA transfers larger than the requested length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weibin Liu <[email protected]>
[ Upstream commit ea9854a169e9c1437df8829bea21c2f2e80b137c ]
The XSPI controller reports the size of the slave-DMA transaction through SDMA_SIZE_REG. Both SDMA handlers take this register at face value and copy the reported number of bytes between the SDMA FIFO and the transfer buffers, without checking it against the length of the transfer that was actually requested.
While cdns_xspi_adjust_mem_op_size() clamps the size of the operations issued by the SPI core, the device can still report a bigger SDMA size than what was programmed, which makes the handlers read from or write to memory beyond the end of the transfer buffers.
Track the number of bytes requested for the current data phase in a new sdma_xfer_len field, set by cdns_xspi_send_stig_command() and by the Marvell b0 transfer path, and reject any SDMA size that exceeds it.
--- drivers/spi/spi-cadence-xspi.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-)
drivers/spi/spi-cadence-xspi.c +17 -2
@@ -221,6 +221,7 @@ struct cdns_xspi_dev {int irq;int cur_cs;unsigned int sdmasize; +unsigned int sdma_xfer_len;struct completion cmd_complete;struct completion auto_cmd_complete;
@@ -327,7 +328,7 @@ static int cdns_xspi_controller_init(struct cdns_xspi_dev *cdns_xspi)return 0 ; } -static void cdns_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) +static int cdns_xspi_sdma_handle (struct cdns_xspi_dev *cdns_xspi) {u32 sdma_size, sdma_trd_info;u8 sdma_dir;
@@ -336,6 +337,13 @@ static void cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) sdma_trd_info =readl (cdns_xspi->iobase +CDNS_XSPI_SDMA_TRD_INFO_REG ); sdma_dir =FIELD_GET (CDNS_XSPI_SDMA_DIR , sdma_trd_info); +if (sdma_size > cdns_xspi->sdma_xfer_len) { +dev_err (cdns_xspi->dev, +"SDMA size %u exceeds the requested length %u\n" , + sdma_size, cdns_xspi->sdma_xfer_len); +return -EINVAL ; + } +switch (sdma_dir) {case CDNS_XSPI_SDMA_DIR_READ : ioread8_rep(cdns_xspi->sdmabase,
@@ -347,6 +355,8 @@ static void cdns_xspi_sdma_handle(struct cdns_xspi_dev *cdns_xspi) cdns_xspi->out_buffer, sdma_size);break ; } + +return 0 ; } static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,
@@ -392,6 +402,7 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi, cdns_xspi->in_buffer = op->data.buf.in; cdns_xspi->out_buffer = op->data.buf.out; + cdns_xspi->sdma_xfer_len = op->data.nbytes;cdns_xspi_trigger_command (cdns_xspi, cmd_regs);
@@ -400,7 +411,11 @@ static int cdns_xspi_send_stig_command(struct cdns_xspi_dev *cdns_xspi,cdns_xspi_set_interrupts (cdns_xspi, false);return -EIO ; } -cdns_xspi_sdma_handle (cdns_xspi); + ret =cdns_xspi_sdma_handle (cdns_xspi); +if (ret) { +cdns_xspi_set_interrupts (cdns_xspi, false); +return ret; + } }wait_for_completion (&cdns_xspi->cmd_complete);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1410/2857 nvme-auth: check chap ctrl_key once constructed
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Grimberg <[email protected]>
[ Upstream commit 546dea18c99928bb81392de63092da0e25d07b10 ]
ctrl ctrl_key member may be overwritten from a sysfs context driven by the user. Once a queue local copy was created, use that instead to minimize checks on a shared resource.
Stable-dep-of: f9e43d924bc7 ("nvme-auth: fail when the controller does not authenticate itself")
--- drivers/nvme/host/auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/auth.c +2 -2
@@ -344,7 +344,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,struct nvmf_auth_dhchap_success1_data *data = chap->buf;size_t size =sizeof (*data); -if (ctrl->ctrl_key) +if (chap->ctrl_key) size += chap->hash_len;if (chap->buf_size < size) {
@@ -819,7 +819,7 @@ static void nvme_queue_auth_work(struct work_struct *work) goto fail2; } -if (ctrl->ctrl_key) { +if (chap->ctrl_key) {/* DH-HMAC-CHAP Step 5: send success2 */ dev_dbg (ctrl->device,"%s: qid %d send success2\n" , __func__, chap->qid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1411/2857 nvme-auth: use chap->s2 to indicate bidirectional authentication
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Martin Wilck <[email protected]>
[ Upstream commit 4ae55a7dce04989f289d5c5c8c8e5c37adc36c71 ]
Commit 546dea18c999 ("nvme-auth: check chap ctrl_key once constructed") replaced the condition "if (ctrl->ctrl_key)" (indicating bidirectional auth) by "if (chap->ctrl_key)", because ctrl->ctrl_key is a resource shared with sysfs. But chap->ctrl_key is set in nvme_auth_process_dhchap_challenge() depending on the DHVLEN in the DH-HMAC-CHAP Challenge message received from the controller, and will thus be non-NULL for every DH-HMAC-CHAP exchange, even if unidirectional auth was requested. This will lead to a protocol violation by sending a Success2 message in the unidirectional case (per NVMe base spec 2.0, the authentication transaction ends after the Success1 message for unidirectional auth). Use chap->s2 instead, which is non-zero if and only if the host requested bi-directional authentication from the controller.
Stable-dep-of: f9e43d924bc7 ("nvme-auth: fail when the controller does not authenticate itself")
--- drivers/nvme/host/auth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/nvme/host/auth.c +2 -2
@@ -344,7 +344,7 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,struct nvmf_auth_dhchap_success1_data *data = chap->buf;size_t size =sizeof (*data); -if (chap->ctrl_key) +if (chap->s2) size += chap->hash_len;if (chap->buf_size < size) {
@@ -819,7 +819,7 @@ static void nvme_queue_auth_work(struct work_struct *work) goto fail2; } -if (chap->ctrl_key) { +if (chap->s2) {/* DH-HMAC-CHAP Step 5: send success2 */ dev_dbg (ctrl->device,"%s: qid %d send success2\n" , __func__, chap->qid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1412/2857 nvme-auth: add flag for bi-directional auth
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark O'Donovan <[email protected]>
[ Upstream commit fc1e03eacac8e5ff8664ce2ebadabba8604f09f4 ]
Introduces an explicit variable for bi-directional auth. The currently used variable chap->s2 is incorrectly zeroed for uni-directional auth. That will be fixed in the next patch so this needs to change to avoid sending unexpected success2 messages
Stable-dep-of: f9e43d924bc7 ("nvme-auth: fail when the controller does not authenticate itself")
--- drivers/nvme/host/auth.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/nvme/host/auth.c +4 -1
@@ -25,6 +25,7 @@ struct nvme_dhchap_queue_context {int error;u32 s1;u32 s2; +bool bi_directional;u16 transaction;u8 status;u8 hash_id;
@@ -315,6 +316,7 @@ static int nvme_auth_set_dhchap_reply_data(struct nvme_ctrl *ctrl, data->dhvlen =cpu_to_le16 (chap->host_key_len);memcpy (data->rval, chap->response, chap->hash_len);if (ctrl->ctrl_key) { + chap->bi_directional = true;get_random_bytes (chap->c2, chap->hash_len); data->cvalid =1 ; chap->s2 =nvme_auth_get_seqnum ();
@@ -671,6 +673,7 @@ static void nvme_auth_reset_dhchap(struct nvme_dhchap_queue_context *chap) chap->error =0 ; chap->s1 =0 ; chap->s2 =0 ; + chap->bi_directional = false; chap->transaction =0 ;memset (chap->c1,0 ,sizeof (chap->c1));memset (chap->c2,0 ,sizeof (chap->c2));
@@ -819,7 +822,7 @@ static void nvme_queue_auth_work(struct work_struct *work) goto fail2; } -if (chap->s2) { +if (chap->bi_directional) {/* DH-HMAC-CHAP Step 5: send success2 */ dev_dbg (ctrl->device,"%s: qid %d send success2\n" , __func__, chap->qid);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1413/2857 nvme-auth: fail when the controller does not authenticate itself
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit f9e43d924bc74feeb56197de82b2845de2a4b85a ]
nvme_auth_process_dhchap_success1() returns success as soon as the controller clears the rvalid flag in its DH-HMAC-CHAP success1 message, without looking at whether the host had asked the controller to authenticate. A host configured with a controller secret sends a challenge in its reply, computes the expected controller response, and sets chap->bi_directional; if the controller then answers with rvalid = 0 the response is never compared, the host still sends success2, and the queue is marked as authenticated.
A malicious or man-in-the-middle controller therefore only has to clear one flag to turn the configured bidirectional authentication into a one-way one, without holding any secret of its own. The target side already treats the mirror image of this as fatal: when the host supplied a challenge but no controller key is configured, nvmet_auth_success1() fails the authentication rather than answering with rvalid = 0.
Refuse the connection if the controller returns no response although bidirectional authentication was requested. chap->bi_directional is the right condition rather than ctrl->ctrl_key, because secure concatenation sends a challenge only to derive the PSK and deliberately clears bi_directional; a one-way setup without a controller secret keeps returning success as before.
--- drivers/nvme/host/auth.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/nvme/host/auth.c +14 -1
@@ -369,8 +369,21 @@ static int nvme_auth_process_dhchap_success1(struct nvme_ctrl *ctrl,nvme_auth_hmac_name (chap->hash_id), nvme_auth_dhgroup_name(chap->dhgroup_id)); -if (!data->rvalid) +if (!data->rvalid) { +/* +* The controller did not return a response. If we asked it to +* authenticate itself the session must not be used, otherwise +* mutual authentication would silently degrade to one-way. +*/ +if (chap->bi_directional) { +dev_warn (ctrl->device, +"qid %d: controller did not authenticate\n" , + chap->qid); + chap->status =NVME_AUTH_DHCHAP_FAILURE_FAILED ; +return -ECONNREFUSED ; + }return 0 ; + }/* Validate controller response */ if (memcmp (chap->response, data->rval, data->hl)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1414/2857 mm/madvise: fix data loss from MADV_FREE on a KSM page
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 22d043c1da48d6c7274f9dd900714b6d58b7b9c6 ]
MADV_FREE can clear the dirty flag of a singly mapped KSM folio. The folio remains in the stable tree and can gain new mappings without being dirtied again. Once marked lazyfree, reclaim can discard data that those mappings still need.
KSM always marks a folio dirty when converting it to a KSM folio in try_to_merge_one_page(). Marking a folio lazyfree clears PG_swapbacked but leaves PG_dirty unchanged. Preserving PG_dirty makes reclaim restore PG_swapbacked instead of discarding the folio. This also protects folios that were already lazyfree when KSM converted them.
Skip KSM folios before clearing their dirty flag, checking under the folio lock to serialize with KSM conversion.
--- mm/madvise.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/madvise.c +9 -0
@@ -675,6 +675,15 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,if (folio_test_swapcache (folio) ||folio_test_dirty (folio)) {if (!folio_trylock (folio))continue ; +/* +* KSM folios can gain new mappings at any time, so we must +* not clear their dirty flag. +*/ +if (folio_test_ksm (folio)) { +folio_unlock (folio); +continue ; + } +/* * If folio is shared with others, we mustn't clear * the folio's dirty flag.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1415/2857 ipmr: prevent info-leak in pmr_cache_report()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 4f34002e2e37639133693c13a2a9977fab86880d ]
Yiming Qian reported:
<quote>
ipmr_cache_report() allocates a report skb with alloc_skb(128, GFP_ATOMIC) and appends a struct igmphdr using skb_put(). In the non-IGMPMSG_WHOLEPKT` path it initializes only:
- igmp->type
- igmp->code
but does not initialize:
- igmp->csum
- igmp->group
Later, igmpmsg_netlink_event() copies the bytes after sizeof(struct igmpmsg) into the IPMRA_CREPORT_PKT netlink attribute and emits RTM_NEWCACHEREPORT on RTNLGRP_IPV4_MROUTE_R.
As a result, 6 bytes of stale heap data from the skb head are disclosed to userspace.
</quote>
Let's use skb_put_zero() instead of skb_put() to fix this bug.
Stable-dep-of: 94a6736bb5ab ("ipmr: only copy pktinfo to cache reports")
--- net/ipv4/ipmr.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/ipv4/ipmr.c +4 -3
@@ -1094,11 +1094,12 @@ static int ipmr_cache_report(const struct mr_table *mrt, msg->im_vif_hi = vifi >>8 ;ipv4_pktinfo_prepare (mroute_sk, pkt, false);memcpy (skb->cb, pkt->cb,sizeof (skb->cb)); -/* Add our header */ - igmp =skb_put (skb,sizeof (struct igmphdr )); +/* Add our header. +* Note that code, csum and group fields are cleared. +*/ + igmp =skb_put_zero (skb,sizeof (struct igmphdr )); igmp->type = assert; msg->im_msgtype = assert; - igmp->code =0 ;ip_hdr (skb)->tot_len =htons (skb->len);/* Fix the length */ skb->transport_header = skb->network_header; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1416/2857 ipmr: only copy pktinfo to cache reports
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 94a6736bb5abe6b2ef38490d0cab19c1c6a7c71f ]
ipmr_cache_report() prepares IP_PKTINFO on the original skb. The ipv4_pktinfo_prepare() helper updates skb->cb and clears the pktinfo fields when packet info is disabled. Since the skb can continue through the data path, preserve and restore its original control block around the helper.
The original implementation copies the entire control block to the report skb. For synthetic RTM_GETROUTE packets, NETLINK_CB data is interpreted as IPCB by the raw IPv4 receive path. With IP_RECVOPTS or IP_RETOPTS enabled, corrupted option offsets cause out-of-bounds reads or a stack buffer overflow. WHOLEPKT and WRVIFWHOLE reports also inherit stale IP option offsets when their header is prepended.
Clear the report skb control block. Only prepare and copy pktinfo when the input skb has an IPv4 header. Synthetic route-query skbs use NETLINK_CB, not IPCB, so leave their report control block zeroed. Restore pkt->cb after preparing pktinfo for regular IPv4 packets.
--- net/ipv4/ipmr.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
net/ipv4/ipmr.c +10 -2
@@ -1037,6 +1037,7 @@ static void ipmr_cache_resolve(struct net *net, struct mr_table *mrt,static int ipmr_cache_report (const struct mr_table *mrt,struct sk_buff *pkt,vifi_t vifi,int assert) { +unsigned char pkt_cb[sizeof (pkt->cb)];const int ihl =ip_hdrlen (pkt);struct sock *mroute_sk;struct igmphdr *igmp;
@@ -1092,8 +1093,6 @@ static int ipmr_cache_report(const struct mr_table *mrt, msg = (struct igmpmsg *)skb_network_header (skb); msg->im_vif = vifi; msg->im_vif_hi = vifi >>8 ; -ipv4_pktinfo_prepare (mroute_sk, pkt, false); -memcpy (skb->cb, pkt->cb,sizeof (skb->cb));/* Add our header. * Note that code, csum and group fields are cleared. */
@@ -1104,6 +1103,15 @@ static int ipmr_cache_report(const struct mr_table *mrt, skb->transport_header = skb->network_header; } +memset (skb->cb,0 ,sizeof (skb->cb)); +/* Route queries from ipmr_get_route() carry NETLINK_CB, not IPCB. */ +if (ip_hdr (pkt)->version) { +memcpy (pkt_cb, pkt->cb,sizeof (pkt_cb)); +ipv4_pktinfo_prepare (mroute_sk, pkt, false); + *PKTINFO_SKB_CB (skb) = *PKTINFO_SKB_CB (pkt); +memcpy (pkt->cb, pkt_cb,sizeof (pkt_cb)); + } +igmpmsg_netlink_event (mrt, skb);/* Deliver to mrouted */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1417/2857 alpha: load the MMU context when switch_mm() switches the current task
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Magnus Lindholm <[email protected]>
[ Upstream commit 9b8be19d5dc9525a408942e2e8012873199e7455 ]
The 6.1.y header still contains ev4_switch_mm(). Retain it, and omit the unrelated do_page_fault() declaration move. Of the direct callers described below, only kthread_use_mm() is present in this tree.
ev5_switch_mm() only prepares the incoming PCB. The context is installed by PAL_swpctx, which alpha_switch_to() issues against that PCB on the way out of the scheduler.
Direct callers reach switch_mm() without going through alpha_switch_to():kthread_use_mm(), which borrows an mm for the current kernel thread, sched_force_init_mm() on the CPU-hotplug teardown path, and do_shoot_lazy_tlb(), which switches to init_mm from an IPI. None explicitly loads the context, so the task can carry on running under whatever was loaded before. For kthread_use_mm(), current->mm then names the borrowed mm even though its context has not been loaded. The other two callers change active_mm while leaving current->mm NULL.
The stale page-table root need not be swapper_pg_dir; it may belong to a user process that ran on the CPU earlier, and the kthread's user accesses can then read and write that process's memory wherever the stale mappings allow. Translations taken that way can also end up tagged with the borrowed mm's ASN: ev5_switch_mm() writes that ASN into the PCB, which the next PAL_swpctx installs against the stale ptbr. An address the stale tables do not map faults instead, and since do_page_fault() resolves faults against current->mm without reloading the context, the same access can fault again on return.
sched_force_init_mm() needs CONFIG_HOTPLUG_CPU and do_shoot_lazy_tlb() needs CONFIG_MMU_LAZY_TLB_SHOOTDOWN. Alpha selects neither, so only kthread_use_mm() is reachable in practice. Test the caller's identity rather than special-casing individual callers.
The scheduler passes the incoming task, which is not current until alpha_switch_to() runs; all three direct callers pass current. Test for that and load the context the way activate_mm() does. All three run with interrupts disabled across the switch, so this completes before any shootdown can be taken and needs no asn_lock handshake.
--- arch/alpha/include/asm/mmu_context.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
arch/alpha/include/asm/mmu_context.h +11 -2
@@ -132,6 +132,8 @@ __get_new_mm_context(struct mm_struct *mm, long cpu)return next; } +extern void __load_new_mm_context (struct mm_struct *); + __EXTERN_INLINE voidev5_switch_mm (struct mm_struct *prev_mm,struct mm_struct *next_mm,struct task_struct *next)
@@ -141,6 +143,15 @@ ev5_switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm,unsigned long mmc;long cpu =smp_processor_id (); +/* +* kthread_use_mm() switches current's mm without alpha_switch_to(), +* which loads the context. +*/ +if (next == current) { +__load_new_mm_context (next_mm); +return ; + } +#ifdef CONFIG_SMP cpu_data[cpu].asn_lock =1 ;barrier ();
@@ -182,8 +193,6 @@ ev4_switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm,ev5_switch_mm (prev_mm, next_mm, next); } -extern void __load_new_mm_context (struct mm_struct *); -#ifdef CONFIG_SMP #define check_mmu_context () \ do { \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1418/2857 alpha: do not skip TLB shootdown IPIs for kthread-borrowed mms
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Magnus Lindholm <[email protected]>
[ Upstream commit fe221b7b2d3ecd042dd391f74ff6a6fdeb7c2038 ]
Keep the older 6.1.y callback argument cast. The Alpha migration callback is present here, so that hunk is retained. The prerequisite which stops clearing remote MMU contexts is already in the 6.1.y base; the remaining stale-TLB prerequisites are in the current stable queue.
flush_tlb_mm(), flush_tlb_page() and flush_icache_user_page() skip the shootdown IPI when mm_users <= 1, on the assumption that no other CPU can be running the mm. A task that borrows an mm through kthread_use_mm() takes mmgrab() rather than mmget(), so it never appears in mm_users, and kthread_use_mm() may be handed an mm that is already the caller's active_mm and loaded on that CPU. Such a CPU was not only left without an IPI, its mm->context[cpu] was cleared from under it.
mm->context[cpu] is already the record of which CPUs hold an ASN for the mm. Test it rather than clearing it: take the shortcut only when no other CPU has one, and otherwise fall through to the IPI, which invalidates those CPUs properly. A CPU that merely ran the mm in the past also holds a context and now costs an IPI, which errs in the safe direction.
Change ipi_flush_tlb_mm(), ipi_flush_icache_page() and the migration callback ipi_flush_mm_and_page() to test current->mm, like ipi_flush_tlb_page(). A CPU that only retains the mm lazily then clears its own slot through flush_tlb_other(), rather than publishing a new ASN on every IPI or migration rendezvous. The migration callback still does its per-VA tbi() afterwards. Returning to the mm allocates a fresh ASN through ev5_switch_mm(), or through the direct-load path when kthread_use_mm() switches current's mm.
Once these historical slots are gone, the shortcut is available again if mm_users remains at most one and no other CPU has taken or kept a context. An explicit kthread_use_mm() borrower has current->mm set and still receives the invalidate it needs.
The caller-side tests in flush_tlb_mm() and flush_icache_user_page() remain current->active_mm. A kernel thread that flushes its lazily held mm can therefore publish its own context slot. Those branches also perform the shortcut check, which excludes the calling CPU's slot, so leave them unchanged. This is distinct from a remote lazy CPU keeping its slot populated through repeated callbacks.
Together with the preceding patch, dropping these clearing loops leaves every runtime write to mm->context[] targeting the writing CPU's own slot, so the array becomes a lockless publication of which CPUs may be using the mm, with a single writer per slot. Mark the two stores that are now observed from other CPUs; flush_tlb_other() already uses WRITE_ONCE(). The uniprocessor flush_icache_user_page() is left alone, as nothing reads another CPU's slot there, and init_new_context() runs before the mm is shared.
Order the slot reads after the page-table changes with smp_mb(). On the publishing CPU, the store in ev5_switch_mm() precedes the mb() in Alpha's arch_spin_unlock(), when finish_lock_switch() drops the rq lock. This relies on Alpha's unlock implementation, not a generic scheduler promise of a full barrier on unlock; document that reliance at the store. Also issue smp_mb() after publishing in __load_new_mm_context(), before loading and using the mm.
This covers every caller, including check_mmu_context(), which can publish a replacement after finish_lock_switch() has already run.
This requires the preceding removal of remote slot clearing from migrate_flush_tlb_page(). It also requires the stale-TLB series to set need_new_asn on both the reused and newly allocated ASN paths. Otherwise an IPI between finish_lock_switch() and check_mmu_context() can zero a new slot while asn_lock is set, and the task can return to user space with a live ASN that the shortcut cannot see.
--- arch/alpha/include/asm/mmu_context.h | 7 +++- arch/alpha/kernel/smp.c | 52 ++++++++++++++-------------- arch/alpha/mm/fault.c | 4 ++- arch/alpha/mm/tlbflush.c | 2 +- 4 files changed, 36 insertions(+), 29 deletions(-)
arch/alpha/include/asm/mmu_context.h +6 -1
@@ -160,7 +160,12 @@ ev5_switch_mm(struct mm_struct *prev_mm, struct mm_struct *next_mm, mmc = next_mm->context[cpu];if ((mmc ^ asn) & ~HARDWARE_ASN_MASK ) { mmc =__get_new_mm_context (next_mm, cpu); - next_mm->context[cpu] = mmc; +/* +* Ordered before any user access through the mm by the +* mb() in arch_spin_unlock(), when finish_lock_switch() +* drops the rq lock. +*/ +WRITE_ONCE (next_mm->context[cpu], mmc); }#ifdef CONFIG_SMP /* A deferred shootdown can also invalidate a newly allocated ASN. */
arch/alpha/kernel/smp.c +26 -26
87 lines not on this page · raw message
arch/alpha/mm/fault.c +3 -1
@@ -45,7 +45,9 @@ __load_new_mm_context(struct mm_struct *next_mm)struct pcb_struct *pcb; mmc =__get_new_mm_context (next_mm,smp_processor_id ()); - next_mm->context[smp_processor_id ()] = mmc; +WRITE_ONCE (next_mm->context[smp_processor_id ()], mmc); +/* Publish the context before this CPU can access the mm. */ +smp_mb (); pcb = ¤t_thread_info ()->pcb; pcb->asn = mmc &HARDWARE_ASN_MASK ;
arch/alpha/mm/tlbflush.c +1 -1
@@ -66,7 +66,7 @@ static void ipi_flush_mm_and_page(void *x)struct tlb_mm_and_addr *d = x;/* Part 1: mm context side (Alpha uses ASN/context as a key mechanism). */ -if (d->mm == current->active_mm && !asn_locked ()) +if (d->mm == current->mm && !asn_locked ())__load_new_mm_context (d->mm);else flush_tlb_other (d->mm);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1419/2857 mm/migrate: untag addresses when querying page nodes
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 7d8746d7dc9cc4003661011424e5880ea7ae364b ]
When move_pages() is used with nodes == NULL, do_pages_stat_array() uses each page address as-is for its VMA lookup. A valid tagged address therefore gets -EFAULT in its status entry instead of the NUMA node reported for the corresponding untagged address.
Strip the tag before the VMA lookup while holding the mmap read lock. Use untagged_addr(), the helper available in 6.1 and already used by the migration path.
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -2168,7 +2168,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,mmap_read_lock (mm);for (i =0 ; i < nr_pages; i++) { -unsigned long addr = (unsigned long )(*pages); +unsigned long addr = (unsigned long )untagged_addr (*pages);unsigned int foll_flags =FOLL_DUMP ;struct vm_area_struct *vma;struct page *page;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1420/2857 x86/init: Initialize wall clock in get_rtc_noop()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naman Jain <[email protected]>
[ Upstream commit 7d5af1f256fdecff6a7986bbc9146b69cb355bb5 ]
get_rtc_noop() is used when an RTC is unavailable, but leaves its output argument untouched. When CONFIG_INIT_STACK_ALL_ZERO is not enabled, timekeeping_init() may therefore receive a nonzero invalid persistent clock value and warn:
"Persistent clock returned invalid value"
Initialize the output to zero, the documented representation of an unsupported persistent clock.
--- arch/x86/kernel/x86_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/x86_init.c +1 -1
@@ -35,7 +35,7 @@ static void iommu_shutdown_noop(void) { }bool __init bool_x86_init_noop (void ) {return false; }void x86_op_int_noop (int cpu) { }static int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } -static void get_rtc_noop (struct timespec64 *now) { } +static void get_rtc_noop (struct timespec64 *now) { *now = (struct timespec64 ){0 }; }static __initconst const struct of_device_id of_cmos_match[] = { { .compatible ="motorola,mc146818" },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1421/2857 drm/nouveau/pci: use config-space MSI rearm on MCP79/MCP7A (NVAC)
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
commit 354d47fb3f35461b7f942831c1b2a7105e92b57f upstream.
NVAC (MCP79/MCP7A) uses g94_pci_func, whose .msi_rearm is nv40_pci_msi_rearm(): a re-arm write through the MMIO mirror of PCI config space. On this IGP that path is unreliable; when a re-arm is missed the interrupt line stays dead, command submission times out and the GPU appears hung until reboot. On an Apple Mac mini (early 2009, MCP79, boot0 0x0ac080b1) this showed as sporadic fifo timeouts and GPU hangs under load unless MSI was disabled via config=NvMSI=0.
Give NVAC its own pci func that re-arms through real PCI config space (nv46_pci_msi_rearm) instead. This follows existing precedent: nv46.c documents the MMIO-mirror re-arm as broken on several related parts, and commit 5112abc6a433 ("drm/nouveau/pci/g92: Fix rearm") fixed g92 the same way while moving the remaining chipsets, NVAC included, into the newly added shared g94 table, where NVAC stayed on the MMIO path. This change completes that fix for NVAC. The sibling IGP NVAA (MCP77/MCP78) has MSI disabled entirely as "reported broken" in nvkm_pci_new_(); NVAC works correctly once the re-arm goes through config space, so disabling MSI is not necessary.
Only NVAC is switched: that is the hardware this has been validated on. The other users of g94_pci_func (G94/G96/G98/GT2xx and the MCP77/MCP89 IGPs) keep their current behavior; MCP77 and MCP89 plausibly want the same treatment but were not tested.
Tested on the Mac mini as a daily driver for two months with MSI enabled and zero fifo timeouts. Independently confirmed stable on an iMac9,1 (MCP79) running 6.12.90 with the v1 form of this change (the same one-line functional switch, applied to that kernel's g94 implementation).
[ Backport note: linux-6.1.y predates commit 2f89bb3264af
("drm/nouveau/pci: add PRI address of config space mirror to nvkm_pci_func"), so struct nvkm_pci_func has no .cfg member here. mcp79_pci_func uses the nv40 .rd32/.wr08/.wr32 accessors instead, exactly as g94_pci_func does in this tree, and still differs from g94_pci_func only in .msi_rearm. ]
--- .../gpu/drm/nouveau/include/nvkm/subdev/pci.h | 1 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 2 +- .../gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 1 + .../gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c | 36 +++++++++++++++++++ 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c
drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h +1 -0
@@ -46,6 +46,7 @@ int nv4c_pci_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nint g84_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int g92_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int g94_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **); +int mcp79_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gf100_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gf106_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);int gk104_pci_new (struct nvkm_device *,enum nvkm_subdev_type ,int inst,struct nvkm_pci **);
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1 -1
@@ -1285,7 +1285,7 @@ nvac_chipset = { .mc = { 0x00000001, g98_mc_new }, .mmu = { 0x00000001, mcp77_mmu_new }, .mxm = { 0x00000001, nv50_mxm_new }, - .pci = { 0x00000001, g94_pci_new }, + .pci = { 0x00000001, mcp79_pci_new }, .therm = { 0x00000001, g84_therm_new }, .timer = { 0x00000001, nv41_timer_new }, .volt = { 0x00000001, nv40_volt_new },
drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild +1 -0
@@ -9,6 +9,7 @@ nvkm-y += nvkm/subdev/pci/nv4c.o nvkm-y += nvkm/subdev/pci/g84.o nvkm-y += nvkm/subdev/pci/g92.o nvkm-y += nvkm/subdev/pci/g94.o +nvkm-y += nvkm/subdev/pci/mcp79.o nvkm-y += nvkm/subdev/pci/gf100.o nvkm-y += nvkm/subdev/pci/gf106.o nvkm-y += nvkm/subdev/pci/gk104.o
drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c new file +36 -0
@@ -0,0 +1,36 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright 2026 Marek Czernohous +* +* MCP79/MCP7A (NVAC): like g94, but MSI re-arm goes through real PCI +* config space. The MMIO-mirror re-arm is unreliable on this IGP and a +* missed re-arm kills the interrupt line (see the nv46 comment; g92 +* already re-arms through config space for the same reason). +*/ +#include "priv.h" + +static const struct nvkm_pci_func +mcp79_pci_func = { + .init = g84_pci_init, + .rd32 = nv40_pci_rd32, + .wr08 = nv40_pci_wr08, + .wr32 = nv40_pci_wr32, + .msi_rearm = nv46_pci_msi_rearm, + + .pcie.init = g84_pcie_init, + .pcie.set_link = g84_pcie_set_link, + + .pcie.max_speed = g84_pcie_max_speed, + .pcie.cur_speed = g84_pcie_cur_speed, + + .pcie.set_version = g84_pcie_set_version, + .pcie.version = g84_pcie_version, + .pcie.version_supported = g92_pcie_version_supported, +}; + +int +mcp79_pci_new (struct nvkm_device *device,enum nvkm_subdev_type type,int inst, +struct nvkm_pci **ppci) +{ +return nvkm_pci_new_ (&mcp79_pci_func, device, type, inst, ppci); +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1422/2857 udf: validate the device specification EA before using it
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunpeng Tian <[email protected]>
[ Upstream commit 9a2390959685ac35a58c80c8016120849a2babf6 ]
udf_get_extendedattr() bounds an extended attribute only against struct genericFormat, which is 12 bytes. A type-12 device specification is struct deviceSpec, which is 24 bytes plus a flexible impUse array. Thus a corrupted filesystem can contain extended attribute that is accepted by udf_get_extendedattr() but udf_write_inode() or udf_read_inode() may access beyond the end of provided buffer.
Provide a udf_device_spec_valid() check to validate correctness of extended attribute that is a deviceSpec. While here, check the result of udf_add_extendedattr() before dereferencing it as it can return NULL in case of error.
[JK: Removed duplicated validity checks]
--- fs/udf/inode.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
fs/udf/inode.c +37 -5
@@ -1185,6 +1185,26 @@ int udf_setsize(struct inode *inode, loff_t newsize)return 0 ; } +/* +* Verify validity of struct deviceSpec on disk. udf_get_extendedattr() has +* already verified the generic header and made sure attribute fits in the +* inode so we just have to make sure attribute space is large enough for +* deviceSpec struct and required impUse information. +*/ +static bool udf_device_spec_valid (struct deviceSpec *dsea) +{ +u32 attr_length, imp_use_length; + + attr_length =le32_to_cpu (dsea->attrLength); + imp_use_length =le32_to_cpu (dsea->impUseLength); +if (attr_length <sizeof (struct deviceSpec ) || + imp_use_length <sizeof (struct regid ) || + imp_use_length > attr_length -sizeof (struct deviceSpec )) +return false; + +return true; +} +/* * Maximum length of linked list formed by ICB hierarchy. The chosen number is * arbitrary - just that we hopefully don't limit any real use of rewritten
@@ -1499,13 +1519,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) {struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr (inode,12 ,1 ); -if (dsea) { -init_special_inode (inode, inode->i_mode, + +if (!dsea || !udf_device_spec_valid (dsea)) + goto out; +init_special_inode (inode, inode->i_mode,MKDEV (le32_to_cpu (dsea->majorDeviceIdent),le32_to_cpu (dsea->minorDeviceIdent))); -/* Developer ID ??? */ - }else - goto out; } ret =0 ; out:
@@ -1653,6 +1672,10 @@ static int udf_update_inode(struct inode *inode, int do_sync)udf_add_extendedattr (inode,sizeof (struct deviceSpec ) +sizeof (struct regid ),12 ,0x3 ); +if (!dsea) { + err = -ENOSPC ; + goto out_unlock; + } dsea->attrType =cpu_to_le32 (12 ); dsea->attrSubtype =1 ; dsea->attrLength = cpu_to_le32(
@@ -1660,6 +1683,10 @@ static int udf_update_inode(struct inode *inode, int do_sync) sizeof(struct regid)); dsea->impUseLength =cpu_to_le32 (sizeof (struct regid )); } +if (!udf_device_spec_valid (dsea)) { + err = -EFSCORRUPTED ; + goto out_unlock; + } eid = (struct regid *)dsea->impUse;memset (eid,0 ,sizeof (*eid));strcpy (eid->ident,UDF_ID_DEVELOPER );
@@ -1799,6 +1826,11 @@ static int udf_update_inode(struct inode *inode, int do_sync)brelse (bh);return err; + +out_unlock: +unlock_buffer (bh); +brelse (bh); +return err; } struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1423/2857 hwmon: (tmp108) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 6b8b1d1d7bc7e579b53fc7c3293b787d68de702a ]
tmp108 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the initial conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot. The continuous-mode path, which sets ->ready_time to jiffies with no added conversion delay, wraps the same way.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp108.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp108.c +4 -4
@@ -73,7 +73,7 @@struct tmp108 {struct regmap *regmap;u16 orig_config; -unsigned long ready_time; +u64 ready_time; };/* convert 12-bit TMP108 register value to milliCelsius */
@@ -124,7 +124,7 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp108->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp108->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ;
@@ -371,7 +371,7 @@ static int tmp108_probe(struct i2c_client *client)return err; } - tmp108->ready_time = jiffies; + tmp108->ready_time =get_jiffies_64 ();if ((tmp108->orig_config &TMP108_CONF_MODE_MASK ) ==TMP108_MODE_SHUTDOWN ) tmp108->ready_time +=
@@ -405,7 +405,7 @@ static int tmp108_resume(struct device *dev) err =regmap_update_bits (tmp108->regmap,TMP108_REG_CONF ,TMP108_CONF_MODE_MASK ,TMP108_MODE_CONTINUOUS ); - tmp108->ready_time = jiffies + + tmp108->ready_time =get_jiffies_64 () +msecs_to_jiffies (TMP108_CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1424/2857 dmaengine: qcom: bam_dma: Defer IRQ trigger type to device tree
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Santhosh <[email protected]>
[ Upstream commit 3cee6f79553202d7d3954555560ac38d719344b8 ]
The driver hardcodes IRQF_TRIGGER_HIGH when registering the BAM interrupt, which overrides the trigger type specified in the device tree. On Qualcomm Shikra SoC, the A2 BAM signals an edge interrupt to the apps processor; registering it as level-high causes the interrupt to not fire, resulting in missed DMA completions.
Use IRQF_TRIGGER_NONE instead, which causes the kernel to use the trigger type already configured by platform_get_irq() when it parsed the device tree interrupts property. This makes the driver platform-agnostic.
Stable-dep-of: 82eed160cfa7 ("dmaengine: qcom: bam_dma: free interrupt before the clock in error path")
--- drivers/dma/qcom/bam_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/bam_dma.c +1 -1
@@ -1325,7 +1325,7 @@ static int bam_dma_probe(struct platform_device *pdev)bam_channel_init (bdev, &bdev->channels[i], i); ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_HIGH ,"bam_dma" , bdev); +IRQF_TRIGGER_NONE ,"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1425/2857 dmaengine: qcom: bam_dma: free interrupt before the clock in error path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit 82eed160cfa7a296ae4eb5acb8dd8f493323eea7 ]
The BAM interrupt is requested with a devres helper and so on error it's freed after probe() returns. We disable the clock before freeing or masking it so it may still fire and we may end up reading BAM registers with clock disabled.
Stop using devres for interrupts as we free it in remove() manually anyway. Add an appropriate label and free the interrupt before disabling the clock in error path and in remove().
--- drivers/dma/qcom/bam_dma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/dma/qcom/bam_dma.c +7 -5
@@ -1324,8 +1324,8 @@ static int bam_dma_probe(struct platform_device *pdev)for (i =0 ; i < bdev->num_channels; i++)bam_channel_init (bdev, &bdev->channels[i], i); - ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_NONE ,"bam_dma" , bdev); + ret =request_irq (bdev->irq, bam_dma_irq,IRQF_TRIGGER_NONE , +"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
@@ -1334,7 +1334,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_set_max_seg_size (bdev->common.dev,BAM_FIFO_SIZE );if (ret) {dev_err (bdev->dev,"cannot set maximum segment size\n" ); - goto err_bam_channel_exit; + goto err_free_irq; }platform_set_drvdata (pdev, bdev);
@@ -1362,7 +1362,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_async_device_register (&bdev->common);if (ret) {dev_err (bdev->dev,"failed to register dma async device\n" ); - goto err_bam_channel_exit; + goto err_free_irq; } ret = of_dma_controller_register(pdev->dev.of_node, bam_dma_xlate,
@@ -1381,6 +1381,8 @@ static int bam_dma_probe(struct platform_device *pdev) err_unregister_dma:dma_async_device_unregister (&bdev->common); +err_free_irq: +free_irq (bdev->irq, bdev); err_bam_channel_exit:for (i =0 ; i < bdev->num_channels; i++)tasklet_kill (&bdev->channels[i].vc.task);
@@ -1406,7 +1408,7 @@ static int bam_dma_remove(struct platform_device *pdev)/* mask all interrupts for this execution environment */ writel_relaxed (0 ,bam_addr (bdev,0 ,BAM_IRQ_SRCS_MSK_EE )); -devm_free_irq (bdev->dev, bdev->irq, bdev); +free_irq (bdev->irq, bdev);for (i =0 ; i < bdev->num_channels; i++) {bam_dma_terminate_all (&bdev->channels[i].vc.chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1426/2857 nilfs2: correct return value kernel-doc descriptions for the rest
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 343d4a33f26d048fde4b02cfc3681f766b3f1b12 ]
Similar to the previous changes to fix return value descriptions, this fixes the format of the return value descriptions of functions for the rest.
Stable-dep-of: 7131aaa74bcc ("nilfs2: ignore non-fatal signals during synchronous log write wait")
--- fs/nilfs2/gcinode.c | 24 +++++++++------------- fs/nilfs2/inode.c | 12 +++-------- fs/nilfs2/recovery.c | 32 +++++++++++------------------ fs/nilfs2/segbuf.c | 12 ++--------- fs/nilfs2/segment.c | 48 ++++++++++++++++--------------------------- fs/nilfs2/the_nilfs.c | 12 +++++------ 6 files changed, 50 insertions(+), 90 deletions(-)
fs/nilfs2/gcinode.c +10 -14
@@ -46,14 +46,11 @@* specified by @pbn to the GC pagecache with the key @blkoff. * This function sets @vbn (@pbn if @vbn is zero) in b_blocknr of the buffer. * -* Return Value: On success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. -* -* %-ENOENT - The block specified with @pbn does not exist. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EIO - I/O error (including metadata corruption). +* * %-ENOENT - The block specified with @pbn does not exist. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff, sector_t pbn, __u64 vbn,
@@ -114,12 +111,11 @@ int nilfs_gccache_submit_read_data(struct inode *inode, sector_t blkoff,* specified by @vbn to the GC pagecache. @pbn can be supplied by the * caller to avoid translation of the disk block address. * -* Return Value: On success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error. -* -* %-ENOMEM - Insufficient amount of memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EIO - I/O error (including metadata corruption). +* * %-ENOENT - Invalid virtual block address. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_gccache_submit_read_node (struct inode *inode,sector_t pbn,__u64 vbn,struct buffer_head **out_bh)
fs/nilfs2/inode.c +3 -9
@@ -676,10 +676,7 @@ struct inode *nilfs_iget_for_gc(struct super_block *sb, unsigned long ino,* or does nothing if the inode already has it. This function allocates * an additional inode to maintain page cache of B-tree nodes one-on-one. * -* Return Value: On success, 0 is returned. On errors, one of the following -* negative error code is returned. -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or %-ENOMEM if memory is insufficient. */ int nilfs_attach_btree_node_cache (struct inode *inode) {
@@ -740,11 +737,8 @@ void nilfs_detach_btree_node_cache(struct inode *inode)* in one inode and the one for b-tree node pages is set up in the * other inode, which is attached to the former inode. * -* Return Value: On success, a pointer to the inode for data pages is -* returned. On errors, one of the following negative error code is returned -* in a pointer type. -* -* %-ENOMEM - Insufficient memory available. +* Return: a pointer to the inode for data pages on success, or %-ENOMEM +* if memory is insufficient. */ struct inode *nilfs_iget_for_shadow (struct inode *inode) {
fs/nilfs2/recovery.c +12 -20
@@ -741,18 +741,13 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* @sb: super block instance * @ri: pointer to a nilfs_recovery_info struct to store search results. * -* Return Value: On success, 0 is returned. On error, one of the following -* negative error code is returned. -* -* %-EINVAL - Inconsistent filesystem state. -* -* %-EIO - I/O error -* -* %-ENOSPC - No space left on device (only in a panic state). -* -* %-ERESTARTSYS - Interrupted. -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EINVAL - Inconsistent filesystem state. +* * %-EIO - I/O error. +* * %-ENOMEM - Insufficient memory available. +* * %-ENOSPC - No space left on device (only in a panic state). +* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
@@ -817,14 +812,11 @@ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs,* segment pointed by the superblock. It sets up struct the_nilfs through * this search. It fills nilfs_recovery_info (ri) required for recovery. * -* Return Value: On success, 0 is returned. On error, one of the following -* negative error code is returned. -* -* %-EINVAL - No valid segment found -* -* %-EIO - I/O error -* -* %-ENOMEM - Insufficient memory available. +* Return: 0 on success, or one of the following negative error codes on +* failure: +* * %-EINVAL - No valid segment found. +* * %-EIO - I/O error. +* * %-ENOMEM - Insufficient memory available. */ int nilfs_search_super_root (struct the_nilfs *nilfs,struct nilfs_recovery_info *ri)
fs/nilfs2/segbuf.c +2 -10
@@ -403,12 +403,7 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,* @segbuf: buffer storing a log to be written * @nilfs: nilfs object * -* Return Value: On Success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error -* -* %-ENOMEM - Insufficient memory available. +* Return: Always 0. */ static int nilfs_segbuf_write (struct nilfs_segment_buffer *segbuf,struct the_nilfs *nilfs)
@@ -449,10 +444,7 @@ static int nilfs_segbuf_write(struct nilfs_segment_buffer *segbuf,* nilfs_segbuf_wait - wait for completion of requested BIOs * @segbuf: segment buffer * -* Return Value: On Success, 0 is returned. On Error, one of the following -* negative error code is returned. -* -* %-EIO - I/O error +* Return: 0 on success, or %-EIO if I/O error is detected. */ static int nilfs_segbuf_wait (struct nilfs_segment_buffer *segbuf) {
fs/nilfs2/segment.c +18 -30
66 lines not on this page · raw message
fs/nilfs2/the_nilfs.c +5 -7
@@ -50,8 +50,8 @@ void nilfs_set_last_segment(struct the_nilfs *nilfs,* alloc_nilfs - allocate a nilfs object * @sb: super block instance * -* Return Value: On success, pointer to the_nilfs is returned. -* On error, NULL is returned. +* Return: a pointer to the allocated nilfs object on success, or NULL on +* failure. */ struct the_nilfs *alloc_nilfs (struct super_block *sb) {
@@ -202,8 +202,7 @@ static int nilfs_store_log_cursor(struct the_nilfs *nilfs,* exponent information written in @sbp and stores it in @blocksize, * or aborts with an error message if it's too large. * -* Return Value: On success, 0 is returned. If the block size is too -* large, -EINVAL is returned. +* Return: 0 on success, or %-EINVAL if the block size is too large. */ static int nilfs_get_blocksize (struct super_block *sb,struct nilfs_super_block *sbp,int *blocksize)
@@ -546,7 +545,7 @@ static int nilfs_valid_sb(struct nilfs_super_block *sbp)* area, or if the parameters themselves are not normal, it is * determined to be invalid. * -* Return Value: true if invalid, false if valid. +* Return: true if invalid, false if valid. */ static bool nilfs_sb2_bad_offset (struct nilfs_super_block *sbp,u64 offset) {
@@ -677,8 +676,7 @@ static int nilfs_load_super_block(struct the_nilfs *nilfs,* reading the super block, getting disk layout information, initializing * shared fields in the_nilfs). * -* Return Value: On success, 0 is returned. On error, a negative error -* code is returned. +* Return: 0 on success, or a negative error code on failure. */ int init_nilfs (struct the_nilfs *nilfs,struct super_block *sb,char *data) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1427/2857 nilfs2: ignore non-fatal signals during synchronous log write wait
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 7131aaa74bcc7c9da1f1d1c8724da75c775557a0 ]
Based on a syzbot report, Wang Jianjian pointed out that following a successful directory operation in nilfs_rename(), a synchronous write requested within nilfs_transaction_commit(), triggered by a sync flag set by nilfs_commit_chunk(), could be interrupted by a user signal. This interruption leaves in-memory metadata updates intact while returning an error, causing inconsistency with the VFS dentry cache and ultimately triggering a kernel warning.
According to "signal(7)", local disks are not classified as "slow devices" (such as terminals, FIFOs, or pipes) and their I/O operations on disk devices are not interrupted by signals. In kernel space, waiting for such disk I/O should therefore not be aborted by ordinary (non-fatal) signals.
Suppress this issue by modifying nilfs_segctor_sync(), which waits for the log writer thread to complete synchronous writes, to catch only fatal signals via fatal_signal_pending() and return -EINTR rather than -ERESTARTSYS. To complement this change and prevent the wait loop from busy-looping when schedule() returns immediately due to a pending non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to TASK_KILLABLE.
This serves as an effective interim stabilization measure without structural changes until a comprehensive fix for metadata consistency is implemented.
--- fs/nilfs2/ioctl.c | 2 +- fs/nilfs2/recovery.c | 2 +- fs/nilfs2/segment.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/nilfs2/ioctl.c +1 -1
@@ -960,10 +960,10 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,* Return: 0 on success, or one of the following negative error codes on * failure: * * %-EFAULT - Failure during execution of requested operation. +* * %-EINTR - Interrupted. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ static int nilfs_ioctl_sync(struct inode *inode, struct file *filp,
fs/nilfs2/recovery.c +1 -1
@@ -743,11 +743,11 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EINVAL - Inconsistent filesystem state. * * %-EIO - I/O error. * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. */ int nilfs_salvage_orphan_logs(struct the_nilfs *nilfs, struct super_block *sb,
fs/nilfs2/segment.c +5 -5
@@ -2234,7 +2234,7 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci)wake_up (&sci->sc_wait_daemon);for (;;) { -set_current_state (TASK_INTERRUPTIBLE ); +set_current_state (TASK_KILLABLE );/* * Synchronize only while the log writer thread is alive.
@@ -2248,11 +2248,11 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci) err = wait_req.err;break ; } -if (!signal_pending (current)) { +if (!fatal_signal_pending (current)) {schedule ();continue ; } - err = -ERESTARTSYS ; + err = -EINTR ;break ; }finish_wait (&sci->sc_wait_request, &wait_req.wq);
@@ -2286,10 +2286,10 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err, bool force)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_segment (struct super_block *sb)
@@ -2316,10 +2316,10 @@ int nilfs_construct_segment(struct super_block *sb)* * Return: 0 on success, or one of the following negative error codes on * failure: +* * %-EINTR - Interrupted. * * %-EIO - I/O error (including metadata corruption). * * %-ENOMEM - Insufficient memory available. * * %-ENOSPC - No space left on device (only in a panic state). -* * %-ERESTARTSYS - Interrupted. * * %-EROFS - Read only filesystem. */ int nilfs_construct_dsync_segment(struct super_block *sb, struct inode *inode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1428/2857 ASoC: stm: stm32_i2s: Drop redundant error messages
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a6cdfb6230944082e7be64f9166eed64656b1162 ]
Both devm_request_irq() and snd_dmaengine_pcm_register() already log failures internally. Drop the redundant error messages and return the original errors directly.
Stable-dep-of: 1b207c85551f ("ASoC: stm: stm32_i2s: request IRQ after regmap initialization")
--- sound/soc/stm/stm32_i2s.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/stm/stm32_i2s.c +2 -4
@@ -1079,10 +1079,8 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev, ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 ,dev_name (&pdev->dev), i2s); -if (ret) { -dev_err (&pdev->dev,"irq request returned %d\n" , ret); +if (ret)return ret; - }/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );
@@ -1138,7 +1136,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret) -return dev_err_probe (&pdev->dev, ret,"PCM DMA register error\n" ); +return ret; ret =snd_soc_register_component (&pdev->dev, &stm32_i2s_component, i2s->dai_drv,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1429/2857 ASoC: stm: stm32_i2s: request IRQ after regmap initialization
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 1b207c85551fd74854d632116849295b2305245f ]
The ISR accesses the managed regmap, but probe requests the IRQ before creating it. An early interrupt can reach an uninitialized regmap. Reverse-order cleanup can free the regmap while the IRQ remains active.
Request the IRQ after regmap initialization so probe unwind and removal free and synchronize it before releasing the regmap.
The teardown ordering issue was found by static analysis.
--- sound/soc/stm/stm32_i2s.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-)
sound/soc/stm/stm32_i2s.c +11 -12
@@ -1027,7 +1027,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,const struct of_device_id *of_id;struct reset_control *rst;struct resource *res; -int irq, ret; +int ret;if (!np)return -ENODEV ;
@@ -1072,16 +1072,6 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,return ret; } -/* Get irqs */ - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; - - ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , -dev_name (&pdev->dev), i2s); -if (ret) -return ret; -/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (IS_ERR (rst))
@@ -1108,7 +1098,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) {struct stm32_i2s_data *i2s;u32 val; -int ret; +int irq, ret; i2s =devm_kzalloc (&pdev->dev,sizeof (*i2s),GFP_KERNEL );if (!i2s)
@@ -1134,6 +1124,15 @@ static int stm32_i2s_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (i2s->regmap),"Regmap init error\n" ); + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + + ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , +dev_name (&pdev->dev), i2s); +if (ret) +return ret; + ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1430/2857 media: davinci: Init async notifier after registering V4L2 device
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sakari Ailus <[email protected]>
[ Upstream commit 2c62a9b8e4d5515638dc2f5e31969675b98c3de0 ]
Initialise the V4L2 async notifier after registering the V4L2 device, just before parsing DT for async sub-devices. This way the device can be made available to the V4L2 async framework from the notifier init time onwards. A subsequent patch will add struct v4l2_device as an argument to v4l2_async_nf_init().
Stable-dep-of: b00fbdad64d4 ("media: vpif_capture: Fix i2c adapter reference leak in vpif_probe()")
--- .../media/platform/ti/davinci/vpif_capture.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/media/platform/ti/davinci/vpif_capture.c +9 -10
@@ -1609,18 +1609,12 @@ static int vpif_probe(struct platform_device *pdev)int res_idx =0 ;int i, err; - pdev->dev.platform_data =vpif_capture_get_pdata (pdev); -if (!pdev->dev.platform_data) { -dev_warn (&pdev->dev,"Missing platform data. Giving up.\n" ); -return -EINVAL ; - } - vpif_dev = &pdev->dev; err =initialize_vpif ();if (err) {v4l2_err (vpif_dev->driver,"Error initializing vpif\n" ); - goto cleanup; +return err; } err =v4l2_device_register (vpif_dev, &vpif_obj.v4l2_dev);
@@ -1647,13 +1641,19 @@ static int vpif_probe(struct platform_device *pdev) goto vpif_unregister; }while (++res_idx); + pdev->dev.platform_data =vpif_capture_get_pdata (pdev); +if (!pdev->dev.platform_data) { +dev_warn (&pdev->dev,"Missing platform data. Giving up.\n" ); + goto vpif_unregister; + } + vpif_obj.config = pdev->dev.platform_data; subdev_count = vpif_obj.config->subdev_count; vpif_obj.sd =kcalloc (subdev_count,sizeof (*vpif_obj.sd),GFP_KERNEL );if (!vpif_obj.sd) { err = -ENOMEM ; - goto vpif_unregister; + goto probe_subdev_out; }if (!vpif_obj.config->asd_sizes[0 ]) {
@@ -1696,14 +1696,13 @@ static int vpif_probe(struct platform_device *pdev)return 0 ; probe_subdev_out: +v4l2_async_nf_cleanup (&vpif_obj.notifier);/* free sub devices memory */ kfree (vpif_obj.sd); vpif_unregister:v4l2_device_unregister (&vpif_obj.v4l2_dev); vpif_free:free_vpif_objs (); -cleanup: -v4l2_async_nf_cleanup (&vpif_obj.notifier);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1431/2857 media: vpif_capture: Fix i2c adapter reference leak in vpif_probe()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b00fbdad64d4ea7d594bc67988c1722fe5b3be50 ]
vpif_probe() takes a reference to the i2c adapter with i2c_get_adapter() and passes it to v4l2_i2c_new_subdev_board(), which does not consume it, but the reference is never released, so it is leaked both when the probe succeeds and when it fails after the adapter has been acquired.
Release the reference with i2c_put_adapter() on the success path and in the probe_subdev_out cleanup, and initialise i2c_adap so that the cleanup is a no-op when the adapter was never acquired.
--- drivers/media/platform/ti/davinci/vpif_capture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/ti/davinci/vpif_capture.c +4 -1
@@ -1604,7 +1604,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)static int vpif_probe (struct platform_device *pdev) {struct vpif_subdev_info *subdevdata; -struct i2c_adapter *i2c_adap; +struct i2c_adapter *i2c_adap =NULL ;int subdev_count;int res_idx =0 ;int i, err;
@@ -1693,9 +1693,12 @@ static int vpif_probe(struct platform_device *pdev) } } +i2c_put_adapter (i2c_adap); +return 0 ; probe_subdev_out: +i2c_put_adapter (i2c_adap);v4l2_async_nf_cleanup (&vpif_obj.notifier);/* free sub devices memory */ kfree (vpif_obj.sd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1432/2857 drm/msm/dsi: Fix VM leak in dsi_tx_buf_alloc_6g()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit ab91ba61871a896ca2ecc6e048d80a152136da44 ]
dsi_tx_buf_alloc_6g() takes a reference to the kms VM with drm_gpuvm_get() and stores it in msm_host->vm. If msm_gem_kernel_new() fails, the function returns early without dropping that reference. Since msm_host->tx_gem_obj is cleared on the error path, msm_dsi_tx_buf_free() will never see a non-NULL tx_gem_obj and thus never calls drm_gpuvm_put(), leaking the VM reference.
Drop the VM reference and clear msm_host->vm on the error path.
Patchwork: https://patchwork.freedesktop.org/patch/754332/
--- drivers/gpu/drm/msm/dsi/dsi_host.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/dsi/dsi_host.c +2 -0
@@ -1147,6 +1147,8 @@ int dsi_tx_buf_alloc_6g(struct msm_dsi_host *msm_host, int size)if (IS_ERR (data)) { msm_host->tx_gem_obj =NULL ; +msm_gem_address_space_put (msm_host->aspace); + msm_host->aspace =NULL ;return PTR_ERR (data); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1433/2857 KVM: arm64: Fix MMFR0 TGRAN advertisement for pVMs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Donnefort <[email protected]>
[ Upstream commit 6c29285e78b5e4811145ebda382ac0ba732ce56a ]
Protected VM ID register emulation leaves unlisted fields at 0. This creates two issues for TGRAN:
* TGRAN16: 0 means non-implemented. It prevents 16KB protected VMs from booting even when the hardware supports it.
* TGRAN4|TGRAN64: 0 means implemented. This may falsely advertise the feature even when the hardware does not support it.
Advertise all the TGRAN fields in pvmid_aa64mmfr0 so that the hardware support is properly propagated.
--- arch/arm64/kvm/hyp/include/nvhe/fixed_config.h | 3 ++- arch/arm64/kvm/hyp/nvhe/sys_regs.c | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-)
arch/arm64/kvm/hyp/include/nvhe/fixed_config.h +2 -1
@@ -90,7 +90,8 @@*/ #define PVM_ID_AA64MMFR0_RESTRICT_UNSIGNED (\ FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_PARANGE), ID_AA64MMFR0_EL1_PARANGE_40) | \ - FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_ASIDBITS), ID_AA64MMFR0_EL1_ASIDBITS_16) \ + FIELD_PREP(ARM64_FEATURE_MASK(ID_AA64MMFR0_EL1_ASIDBITS), ID_AA64MMFR0_EL1_ASIDBITS_16) | \ + SYS_FIELD_PREP_ENUM(ID_AA64MMFR0_EL1, TGRAN16, IMP) \ )/*
arch/arm64/kvm/hyp/nvhe/sys_regs.c +9 -0
@@ -190,6 +190,15 @@ static u64 get_pvm_id_aa64mmfr0(const struct kvm_vcpu *vcpu) set_mask =get_restricted_features_unsigned (id_aa64mmfr0_el1_sys_val,PVM_ID_AA64MMFR0_RESTRICT_UNSIGNED ); + set_mask |=SYS_FIELD_PREP (ID_AA64MMFR0_EL1 ,TGRAN4 , +min_t (int,cpuid_feature_extract_signed_field (id_aa64mmfr0_el1_sys_val, +ID_AA64MMFR0_EL1_TGRAN4_SHIFT ), +ID_AA64MMFR0_EL1_TGRAN4_IMP )); + set_mask |=SYS_FIELD_PREP (ID_AA64MMFR0_EL1 ,TGRAN64 , +min_t (int,cpuid_feature_extract_signed_field (id_aa64mmfr0_el1_sys_val, +ID_AA64MMFR0_EL1_TGRAN64_SHIFT ), +ID_AA64MMFR0_EL1_TGRAN64_IMP )); +return (id_aa64mmfr0_el1_sys_val &PVM_ID_AA64MMFR0_ALLOW ) | set_mask; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1434/2857 mm/hugetlb_cgroup: convert set_hugetlb_cgroup*() to folios
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sidhartha Kumar <[email protected]>
[ Upstream commit de656ed376c4cb47c5713fba52f8bbfbea44f387 ]
Allows __prep_new_huge_page() to operate on a folio by converting set_hugetlb_cgroup*() to take in a folio.
Stable-dep-of: 23fac055c211 ("mm/hugetlb_cgroup: move per-node usage on cgroup reparenting")
--- include/linux/hugetlb_cgroup.h | 12 ++++++------ mm/hugetlb.c | 33 +++++++++++++++++++-------------- mm/hugetlb_cgroup.c | 11 ++++++----- 3 files changed, 31 insertions(+), 25 deletions(-)
include/linux/hugetlb_cgroup.h +6 -6
@@ -112,16 +112,16 @@ static inline void __set_hugetlb_cgroup(struct folio *folio, (unsigned long)h_cg); } -static inline void set_hugetlb_cgroup (struct page *page, +static inline void set_hugetlb_cgroup (struct folio *folio,struct hugetlb_cgroup *h_cg) { -__set_hugetlb_cgroup (page_folio (page), h_cg, false); +__set_hugetlb_cgroup (folio, h_cg, false); } -static inline void set_hugetlb_cgroup_rsvd (struct page *page, +static inline void set_hugetlb_cgroup_rsvd (struct folio *folio,struct hugetlb_cgroup *h_cg) { -__set_hugetlb_cgroup (page_folio (page), h_cg, true); +__set_hugetlb_cgroup (folio, h_cg, true); }static inline bool hugetlb_cgroup_disabled (void )
@@ -199,12 +199,12 @@ hugetlb_cgroup_from_folio_rsvd(struct folio *folio)return NULL ; } -static inline void set_hugetlb_cgroup (struct page *page, +static inline void set_hugetlb_cgroup (struct folio *folio,struct hugetlb_cgroup *h_cg) { } -static inline void set_hugetlb_cgroup_rsvd (struct page *page, +static inline void set_hugetlb_cgroup_rsvd (struct folio *folio,struct hugetlb_cgroup *h_cg) { }
mm/hugetlb.c +19 -14
@@ -1986,19 +1986,21 @@ static void __prep_account_new_huge_page(struct hstate *h, int nid) h->nr_huge_pages_node[nid]++; } -static void __prep_new_huge_page (struct hstate *h,struct page *page) +static void __prep_new_hugetlb_folio (struct hstate *h,struct folio *folio) { -hugetlb_vmemmap_optimize (h, page); -INIT_LIST_HEAD (&page->lru); -set_compound_page_dtor (page,HUGETLB_PAGE_DTOR ); -hugetlb_set_page_subpool (page,NULL ); -set_hugetlb_cgroup (page,NULL ); -set_hugetlb_cgroup_rsvd (page,NULL ); +hugetlb_vmemmap_optimize (h, &folio->page); +INIT_LIST_HEAD (&folio->lru); + folio->_folio_dtor =HUGETLB_PAGE_DTOR ; +hugetlb_set_folio_subpool (folio,NULL ); +set_hugetlb_cgroup (folio,NULL ); +set_hugetlb_cgroup_rsvd (folio,NULL ); }static void prep_new_huge_page (struct hstate *h,struct page *page,int nid) { -__prep_new_huge_page (h, page); +struct folio *folio =page_folio (page); + +__prep_new_hugetlb_folio (h, folio);spin_lock_irq (&hugetlb_lock);__prep_account_new_huge_page (h, nid);spin_unlock_irq (&hugetlb_lock);
@@ -2970,8 +2972,10 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, struct list_head *list) {gfp_t gfp_mask =htlb_alloc_mask (h) | __GFP_THISNODE; -int nid =page_to_nid (old_page); +struct folio *old_folio =page_folio (old_page); +int nid =folio_nid (old_folio);struct page *new_page; +struct folio *new_folio;int ret =0 ;/*
@@ -2984,16 +2988,17 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, new_page =alloc_buddy_huge_page (h, gfp_mask, nid,NULL ,NULL );if (!new_page)return -ENOMEM ; -__prep_new_huge_page (h, new_page); + new_folio =page_folio (new_page); +__prep_new_hugetlb_folio (h, new_folio); retry:spin_lock_irq (&hugetlb_lock); -if (!PageHuge (old_page)) { +if (!folio_test_hugetlb (old_folio)) {/* * Freed from under us. Drop new_page too. */ goto free_new; - }else if (page_count (old_page)) { + }else if (folio_ref_count (old_folio)) {/* * Someone has grabbed the page, try to isolate it here. * Fail with -EBUSY if not possible.
@@ -3002,7 +3007,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, ret =folio_isolate_hugetlb (old_page, list);spin_lock_irq (&hugetlb_lock); goto free_new; - }else if (!HPageFreed (old_page)) { + }else if (!folio_test_hugetlb_freed (old_folio)) {/* * Page's refcount is 0 but it has not been enqueued in the * freelist yet. Race window is small, so we can succeed here if
@@ -3040,7 +3045,7 @@ static int alloc_and_dissolve_huge_page(struct hstate *h, struct page *old_page, free_new:spin_unlock_irq (&hugetlb_lock);/* Page has a zero ref count, but needs a ref to be freed */ -set_page_refcounted (new_page); +folio_ref_unfreeze (new_folio,1 );update_and_free_page (h, new_page, false);return ret;
mm/hugetlb_cgroup.c +6 -5
@@ -212,7 +212,7 @@ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,/* Take the pages off the local counter */ page_counter_cancel (counter, nr_pages); -set_hugetlb_cgroup (page, parent); +set_hugetlb_cgroup (folio, parent); out:return ; }
@@ -890,6 +890,7 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage)struct hugetlb_cgroup *h_cg_rsvd;struct hstate *h =page_hstate (oldhpage);struct folio *old_folio =page_folio (oldhpage); +struct folio *new_folio =page_folio (newhpage);if (hugetlb_cgroup_disabled ())return ;
@@ -897,12 +898,12 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage)spin_lock_irq (&hugetlb_lock); h_cg =hugetlb_cgroup_from_folio (old_folio); h_cg_rsvd =hugetlb_cgroup_from_folio_rsvd (old_folio); -set_hugetlb_cgroup (oldhpage,NULL ); -set_hugetlb_cgroup_rsvd (oldhpage,NULL ); +set_hugetlb_cgroup (old_folio,NULL ); +set_hugetlb_cgroup_rsvd (old_folio,NULL );/* move the h_cg details to new cgroup */ -set_hugetlb_cgroup (newhpage, h_cg); -set_hugetlb_cgroup_rsvd (newhpage, h_cg_rsvd); +set_hugetlb_cgroup (new_folio, h_cg); +set_hugetlb_cgroup_rsvd (new_folio, h_cg_rsvd);list_move (&newhpage->lru, &h->hugepage_activelist);spin_unlock_irq (&hugetlb_lock);return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1435/2857 mm/hugetlb_cgroup: convert hugetlb_cgroup_migrate to folios
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sidhartha Kumar <[email protected]>
[ Upstream commit 29f394304f624b06fafb3cc9c3da8779f71f4bee ]
Cleans up intermediate page to folio conversion code in hugetlb_cgroup_migrate() by changing its arguments from pages to folios.
Stable-dep-of: 23fac055c211 ("mm/hugetlb_cgroup: move per-node usage on cgroup reparenting")
--- include/linux/hugetlb_cgroup.h | 8 ++++---- mm/hugetlb.c | 2 +- mm/hugetlb_cgroup.c | 8 +++----- 3 files changed, 8 insertions(+), 10 deletions(-)
include/linux/hugetlb_cgroup.h +4 -4
@@ -177,8 +177,8 @@ extern void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv, bool region_del);extern void hugetlb_cgroup_file_init (void )__init ; -extern void hugetlb_cgroup_migrate (struct page *oldhpage, -struct page *newhpage); +extern void hugetlb_cgroup_migrate (struct folio *old_folio, +struct folio *new_folio);#else static inline void hugetlb_cgroup_uncharge_file_region(struct resv_map *resv,
@@ -286,8 +286,8 @@ static inline void hugetlb_cgroup_file_init(void) { } -static inline void hugetlb_cgroup_migrate (struct page *oldhpage, -struct page *newhpage) +static inline void hugetlb_cgroup_migrate (struct folio *old_folio, +struct folio *new_folio) { }
mm/hugetlb.c +1 -1
@@ -7555,7 +7555,7 @@ void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason) {struct hstate *h =page_hstate (oldpage); -hugetlb_cgroup_migrate (oldpage, newpage); +hugetlb_cgroup_migrate (page_folio (oldpage),page_folio (newpage));set_page_owner_migrate_reason (newpage, reason);/*
mm/hugetlb_cgroup.c +3 -5
@@ -884,13 +884,11 @@ void __init hugetlb_cgroup_file_init(void)* hugetlb_lock will make sure a parallel cgroup rmdir won't happen * when we migrate hugepages */ -void hugetlb_cgroup_migrate (struct page *oldhpage,struct page *newhpage) +void hugetlb_cgroup_migrate (struct folio *old_folio,struct folio *new_folio) {struct hugetlb_cgroup *h_cg;struct hugetlb_cgroup *h_cg_rsvd; -struct hstate *h =page_hstate (oldhpage); -struct folio *old_folio =page_folio (oldhpage); -struct folio *new_folio =page_folio (newhpage); +struct hstate *h =folio_hstate (old_folio);if (hugetlb_cgroup_disabled ())return ;
@@ -904,7 +902,7 @@ void hugetlb_cgroup_migrate(struct page *oldhpage, struct page *newhpage)/* move the h_cg details to new cgroup */ set_hugetlb_cgroup (new_folio, h_cg);set_hugetlb_cgroup_rsvd (new_folio, h_cg_rsvd); -list_move (&newhpage->lru, &h->hugepage_activelist); +list_move (&new_folio->lru, &h->hugepage_activelist);spin_unlock_irq (&hugetlb_lock);return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1436/2857 mm/hugetlb_cgroup: move per-node usage on cross node migration
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongfu Li <[email protected]>
[ Upstream commit fe0ba1909c59660f078560f5130e7af7c6004f12 ]
Patch series "mm/hugetlb_cgroup: move the per-node usage along with the folio", v2.
The per-node usage reported by hugetlb.<size>.numa_stat is accounted against folio_nid() in __hugetlb_cgroup_commit_charge() and __hugetlb_cgroup_uncharge_folio(), so it is only correct while a folio stays charged on the same node and in the same hugetlb_cgroup.
Two paths move a folio which stays charged, and neither moves the usage with it. hugetlb_cgroup_migrate() only moves the hugetlb_cgroup pointers of a folio migrated to another node, and hugetlb_cgroup_move_parent() only moves the page_counter charges and the hugetlb_cgroup pointer of the folios of a dying cgroup. In both cases the node (or cgroup) which was charged keeps a usage which never goes away, while the node (or cgroup) which ends up uncharging the folio underflows as soon as the folio is freed.
Patch 1/2 moves the usage along with the folio on cross node migration, patch 2/2 does the same for the folios a dying cgroup reparents.
This patch (of 2):
hugetlb.<size>.numa_stat uses folio_nid() to account usage in __hugetlb_cgroup_commit_charge() and __hugetlb_cgroup_uncharge_folio(). hugetlb_cgroup_migrate() only moves hugetlb_cgroup pointers, leaving per-node usage behind on the source node during cross-node migration.
When the migrated folio gets uncharged, we subtract usage from the destination node counter. This creates stale usage on the source node and unsigned long counter underflow on the destination node. The hugetlb.<size>.numa_stat interface exposes these incorrect per-node usage values to userspace.
Add a hugetlb_cgroup_move_usage() helper which moves the usage from the old node to the new node, and call it from hugetlb_cgroup_migrate().
Stable-dep-of: 23fac055c211 ("mm/hugetlb_cgroup: move per-node usage on cgroup reparenting")
--- mm/hugetlb_cgroup.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
mm/hugetlb_cgroup.c +31 -0
@@ -177,6 +177,34 @@ static void hugetlb_cgroup_css_free(struct cgroup_subsys_state *css)hugetlb_cgroup_free (hugetlb_cgroup_from_css (css)); } +static void hugetlb_cgroup_move_usage (struct hugetlb_cgroup *from, +struct hugetlb_cgroup *to, +struct folio *from_folio, +struct folio *to_folio) +{ +int idx =hstate_index (folio_hstate (from_folio)); +unsigned long nr_pages =folio_nr_pages (from_folio); +int from_nid =folio_nid (from_folio); +int to_nid =folio_nid (to_folio); +unsigned long usage; + +lockdep_assert_held (&hugetlb_lock); + +if (!from || !to) +return ; + +if (from == to && from_nid == to_nid) +return ; + + usage = from->nodeinfo[from_nid]->usage[idx]; +if (WARN_ON_ONCE (usage < nr_pages)) +return ; +WRITE_ONCE (from->nodeinfo[from_nid]->usage[idx], usage - nr_pages); + + usage = to->nodeinfo[to_nid]->usage[idx]; +WRITE_ONCE (to->nodeinfo[to_nid]->usage[idx], usage + nr_pages); +} +/* * Should be called with hugetlb_lock held. * Since we are holding hugetlb_lock, pages cannot get moved from
@@ -902,6 +930,9 @@ void hugetlb_cgroup_migrate(struct folio *old_folio, struct folio *new_folio)/* move the h_cg details to new cgroup */ set_hugetlb_cgroup (new_folio, h_cg);set_hugetlb_cgroup_rsvd (new_folio, h_cg_rsvd); + +hugetlb_cgroup_move_usage (h_cg, h_cg, old_folio, new_folio); +list_move (&new_folio->lru, &h->hugepage_activelist);spin_unlock_irq (&hugetlb_lock);return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1437/2857 mm/hugetlb_cgroup: move per-node usage on cgroup reparenting
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongfu Li <[email protected]>
[ Upstream commit 23fac055c21176f66ed453394b533bdfc00f7fba ]
hugetlb_cgroup_css_offline() hands the folios of a dying cgroup over to its parent with hugetlb_cgroup_move_parent(), which moves the page_counter charges and the hugetlb_cgroup pointer of the folio but not its per-node usage. The parent's hugetlb.<size>.numa_stat is short by that usage while they are charged, and underflows once they are freed, exposing incorrect per-node usage values to userspace.
Move the per-node usage to the parent as well. The folios keep their node here, so only the cgroup which holds the usage changes.
--- mm/hugetlb_cgroup.c | 2 ++ 1 file changed, 2 insertions(+)
mm/hugetlb_cgroup.c +2 -0
@@ -240,6 +240,8 @@ static void hugetlb_cgroup_move_parent(int idx, struct hugetlb_cgroup *h_cg,/* Take the pages off the local counter */ page_counter_cancel (counter, nr_pages); +hugetlb_cgroup_move_usage (h_cg, parent, folio, folio); +set_hugetlb_cgroup (folio, parent); out:return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1438/2857 ata: sata_inic162x: remove dangerous broken driver
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Nelson-Moore <[email protected]>
[ Upstream commit 96fdeb7e3fd8d937f8351ed90824c9d904e590a1 ]
The sata_inic162x driver was labeled as "very experimental" in commit bb9696192826 ("libata: make it clear that sata_inic162x is experimental") due to data corruption issues, but not marked as broken. Since then, no changes have been made to it that could fix these issues. Since the driver was not marked as broken, and the message about potential data corruption is only visible in the code and dmesg, it is possible that someone could enable the driver without realizing its potential for data corruption. Remove the driver to protect users' data.
--- drivers/ata/Kconfig | 7 - drivers/ata/Makefile | 1 - drivers/ata/sata_inic162x.c | 904 ------------------------------------ 3 files changed, 912 deletions(-) delete mode 100644 drivers/ata/sata_inic162x.c
drivers/ata/Kconfig +0 -7
@@ -330,13 +330,6 @@ config SATA_AHCI_SEATTLE If unsure, say N -config SATA_INIC162X - tristate "Initio 162x SATA support (Very Experimental)" - depends on PCI - select SATA_HOST - help - This option enables support for Initio 162x Serial ATA. - config SATA_ACARD_AHCI tristate "ACard AHCI variant (ATP 8620)" depends on PCI
drivers/ata/Makefile +0 -1
@@ -9,7 +9,6 @@ obj-$(CONFIG_SATA_AHCI_SEATTLE) += ahci_seattle.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_FSL) += sata_fsl.o obj-$(CONFIG_SATA_GEMINI) += sata_gemini.o -obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o obj-$(CONFIG_SATA_SIL24) += sata_sil24.o obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
drivers/ata/sata_inic162x.c deleted +0 -904
904 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1439/2857 init/version.c: Replace strlcpy with strscpy
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Azeem Shaikh <[email protected]>
[ Upstream commit 8ebab155ea18a6d6c47b17287a0ab4633334f6eb ]
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy().
Direct replacement is safe here since return value of -errno is used to check for truncation instead of sizeof(dest).
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89
Stable-dep-of: b6bec5b63a5b ("init: fix early boot crash with bare hostname parameter")
--- init/version.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
init/version.c +3 -3
@@ -22,10 +22,10 @@ static int __init early_hostname(char *arg) {size_t bufsize =sizeof (init_uts_ns.name.nodename);size_t maxlen = bufsize -1 ; -size_t arglen; +ssize_t arglen; - arglen =strlcpy (init_uts_ns.name.nodename, arg, bufsize); -if (arglen > maxlen) { + arglen =strscpy (init_uts_ns.name.nodename, arg, bufsize); +if (arglen <0 ) {pr_warn ("hostname parameter exceeds %zd characters and will be truncated" , maxlen); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1440/2857 init: fix early boot crash with bare hostname parameter
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit b6bec5b63a5b812145e53aaad1e63661c7214f93 ]
When a bare hostname parameter is specified on the kernel command line without the '=' separator, early parameter parsing passes NULL to early_hostname(), which dereferences it in strscpy() and can crash the system during early boot.
Reject NULL values in early_hostname() and return -EINVAL instead.
--- init/version.c | 3 +++ 1 file changed, 3 insertions(+)
init/version.c +3 -0
@@ -24,6 +24,9 @@ static int __init early_hostname(char *arg)size_t maxlen = bufsize -1 ;ssize_t arglen; +if (!arg) +return -EINVAL ; + arglen =strscpy (init_uts_ns.name.nodename, arg, bufsize);if (arglen <0 ) { pr_warn("hostname parameter exceeds %zd characters and will be truncated",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1441/2857 mm/madvise: use folio_trylock() in the cold/pageout PMD split
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price <[email protected]>
[ Upstream commit 5a6c9cf117fca3c38a98fb2a2d5549795c8b0b73 ]
MADV_COLD or MADV_PAGEOUT over part of a PMD splits the THP in madvise_cold_or_pageout_pte_range(). Two threads doing that to the same THP create spurious failures.
CPU0 CPU1
---- ----
folio_get()
spin_unlock(ptl)
folio_lock()
folio_get() spin_unlock(ptl) folio_lock() <- blocks, keeps its ref
split_folio()
folio_expected_ref_count(folio) != folio_ref_count(folio) - 1
-EAGAINCPU1 cannot drop its reference until it gets the lock CPU0 holds, so CPU0's split always fails. folio_trylock() makes CPU1 leave without ever taking a reference. The PTE branch of this same function already does this, as do madvise_free_pte_range() and madvise_free_huge_pmd().
Reproducer: 400 rounds of eight threads calling MADV_COLD on half of each of eight THPs, re-formed with MADV_COLLAPSE between rounds. From /proc/vmstat:
thp_split_page thp_split_page_failed
before 3186 860
after 3200 0
The short before count is rounds where every thread failed and the advice was dropped for that THP entirely.
On failure the walker returns 0 and nothing retries. The PMD path becomes best effort when the folio lock is held elsewhere - same as the PTE path.
--- mm/madvise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/madvise.c +2 -1
@@ -367,9 +367,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,if (next - addr !=HPAGE_PMD_SIZE ) {int err; +if (!trylock_page (page)) + goto huge_unlock;get_page (page);spin_unlock (ptl); -lock_page (page); err =split_huge_page (page);unlock_page (page);put_page (page);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1442/2857 ALSA: line6: Handle period elapsed calls outside the locks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 443ed4edc2678cc51c5a01e7dffc4c890be40051 ]
LINE6 driver may call snd_pcm_period_elapsed() for both playback and capture substreams at processing the playback substream, and this may lead to a ABBA deadlock.
Move the actual calls of snd_pcm_period_elapsed() outside the locks for avoiding it. The capture period notification at submitting the initial playback URBs (only with the impulse mode) is simply skipped, as it's done in the lock context; it'll be caught up at the next period.
--- sound/usb/line6/capture.c | 17 +++++++++-------- sound/usb/line6/capture.h | 2 +- sound/usb/line6/playback.c | 31 +++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 19 deletions(-)
sound/usb/line6/capture.c +9 -8
@@ -137,18 +137,15 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) line6pcm->in.pos_done -= runtime->buffer_size; } -void line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) +/* update the capture position and check whether we need period_elapsed call */ +bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) { -struct snd_pcm_substream *substream = -get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE ); - line6pcm->in.bytes += length;if (line6pcm->in.bytes >= line6pcm->in.period) { line6pcm->in.bytes %= line6pcm->in.period; -spin_unlock (&line6pcm->in.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->in.lock); +return true; } +return false; }/*
@@ -158,6 +155,7 @@ static void audio_in_callback(struct urb *urb) {int i, index, length =0 , shutdown =0 ;unsigned long flags; +bool capture_period_elapsed = false;struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context;
@@ -221,10 +219,13 @@ static void audio_in_callback(struct urb *urb)if (!test_bit (LINE6_STREAM_IMPULSE , &line6pcm->in.running) &&test_bit (LINE6_STREAM_PCM , &line6pcm->in.running)) -line6_capture_check_period (line6pcm, length); + capture_period_elapsed =line6_capture_check_period (line6pcm, length); }spin_unlock_irqrestore (&line6pcm->in.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); }/* open capture callback */
sound/usb/line6/capture.h +1 -1
@@ -17,7 +17,7 @@ extern const struct snd_pcm_ops snd_line6_capture_ops;extern void line6_capture_copy (struct snd_line6_pcm *line6pcm,char *fbuf,int fsize); -extern void line6_capture_check_period (struct snd_line6_pcm *line6pcm, +extern bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length);extern int line6_create_audio_in_urbs (struct snd_line6_pcm *line6pcm);extern int line6_submit_audio_in_all_urbs (struct snd_line6_pcm *line6pcm);
sound/usb/line6/playback.c +21 -10
@@ -136,6 +136,8 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,/* Find a free URB, prepare audio data, and submit URB. must be called in line6pcm->out.lock context +Returns 1 if snd_pcm_period_elapsed() needs to be called for the +capture stream after releasing the lock, 0 if not, or a negative error */ static int submit_audio_out_urb (struct snd_line6_pcm *line6pcm) {
@@ -151,6 +153,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) line6pcm->properties->rates.rats[0 ].den * (line6pcm->line6->intervals_per_second /LINE6_ISO_INTERVAL );struct urb *urb_out; +bool capture_period_elapsed = false; index =find_first_zero_bit (&line6pcm->out.active_urbs, line6pcm->line6->iso_buffers);
@@ -260,8 +263,9 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer, urb_out-> transfer_buffer_length); -line6_capture_check_period (line6pcm, - urb_out->transfer_buffer_length); + capture_period_elapsed = +line6_capture_check_period (line6pcm, + urb_out->transfer_buffer_length); } }else { if (!(line6pcm->line6->properties->capabilities & LINE6_CAP_HWMON)
@@ -283,24 +287,26 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)dev_err (line6pcm->line6->ifcdev,"URB out #%d submission failed (%d)\n" , index, ret); -return 0 ; +return capture_period_elapsed; }/* Submit all currently available playback URBs. must be called in line6pcm->out.lock context +The capture period notification is skipped here since we can't call +snd_pcm_period_elapsed() in the lock; it'll be caught up at the next one. */ int line6_submit_audio_out_all_urbs (struct snd_line6_pcm *line6pcm) { -int ret =0 , i; +int ret, i;for (i =0 ; i < line6pcm->line6->iso_buffers; ++i) { ret =submit_audio_out_urb (line6pcm);if (ret <0 ) -break ; +return ret; } -return ret; +return 0 ; }/*
@@ -316,6 +322,8 @@ static void audio_out_callback(struct urb *urb)const int bytes_per_frame = line6pcm->properties->bytes_per_channel * line6pcm->properties->playback_hw.channels_max; +bool capture_period_elapsed = false; +bool playback_period_elapsed = false;#if USE_CLEAR_BUFFER_WORKAROUND memset (urb->transfer_buffer,0 , urb->transfer_buffer_length);
@@ -358,19 +366,22 @@ static void audio_out_callback(struct urb *urb) shutdown =1 ;if (!shutdown) { -submit_audio_out_urb (line6pcm); + capture_period_elapsed =submit_audio_out_urb (line6pcm) >0 ;if (test_bit (LINE6_STREAM_PCM , &line6pcm->out.running)) { line6pcm->out.bytes += length;if (line6pcm->out.bytes >= line6pcm->out.period) { line6pcm->out.bytes %= line6pcm->out.period; -spin_unlock (&line6pcm->out.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->out.lock); + playback_period_elapsed = true; } } }spin_unlock_irqrestore (&line6pcm->out.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); +if (playback_period_elapsed) +snd_pcm_period_elapsed (substream); }/* open playback callback */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1443/2857 f2fs: return -EIO for a lost inode block after cp_error
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 53b12b63304b34a3850a901c4de3cc6ad08e0aee ]
After cp_error, dirty node caches are dropped without being written. If such an inode was never written, its NAT entry is still NEW_ADDR, and reading its inode block returns -ENOENT.
f2fs_get_dnode_of_data() passes that -ENOENT up, and callers take it as a hole. Since the inode block is missing, the next offset can only advance one block, so fiemap walks block by block up to maxbytes, about 2^30 blocks, while holding the inode lock. It took hours in a power-off recovery test after shutdown and blocked unlink and umount on the file.
Return -EIO instead of -ENOENT when the inode block itself is missing after cp_error or shutdown. A missing direct or indirect node is still reported as -ENOENT.
--- fs/f2fs/node.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
fs/f2fs/node.c +14 -2
@@ -783,8 +783,20 @@ int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)if (!npage[0 ]) { npage[0 ] =f2fs_get_node_page (sbi, nids[0 ]); -if (IS_ERR (npage[0 ])) -return PTR_ERR (npage[0 ]); +if (IS_ERR (npage[0 ])) { + err =PTR_ERR (npage[0 ]); +/* +* cp_error drops dirty node caches, so the inode block +* of an inode that was never written reads as NEW_ADDR +* and returns -ENOENT. It is not a hole; the inode is +* gone. Callers treat -ENOENT as a hole and keep +* looking block by block (e.g. fiemap up to maxbytes). +*/ +if (err == -ENOENT && (f2fs_cp_error (sbi) || +is_sbi_flag_set (sbi,SBI_IS_SHUTDOWN ))) + err = -EIO ; +return err; + } }/* if inline_data is set, should not report any block indices */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1444/2857 mfd: twl-core: Use i2c_check_functionality as boolean value
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 7ee4fa2674e51a0d100b9240cd8a50355141362f ]
i2c_check_functionality() returns a boolean status rather than an error code - directly use it as a boolean value.
Stable-dep-of: 3c5c55d979dd ("mfd: twl-core: Unregister the auxiliary platform device on unbind")
--- drivers/mfd/twl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/twl-core.c +1 -1
@@ -786,7 +786,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)return status; } -if (i2c_check_functionality (client->adapter,I2C_FUNC_I2C ) ==0 ) { +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; goto free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1445/2857 mfd: twl-core: Unregister the auxiliary platform device on unbind
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3c5c55d979ddcb0765ce531bc7ba173c87c8712a ]
twl_probe() registers a standalone platform device named "twl", but keeps its pointer only in a local variable. Probe errors unregister the device, while successful probe leaves no way for twl_remove() to release it. The platform device therefore remains registered after the I2C driver unbinds.
Register a managed action on the I2C device immediately after adding the platform device. This unregisters it on probe failure and driver unbind, and also handles failure to register the action itself. Remove the manual error-path unregister to avoid releasing the device twice.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mfd/twl-core.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mfd/twl-core.c +14 -7
@@ -752,6 +752,11 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = { { /* sentinel */ }, }; +static void twl_unregister_device (void *data) +{ +platform_device_unregister (data); +} +/* NOTE: This driver only handles a single twl4030/tps659x0 chip */ static int twl_probe (struct i2c_client *client,const struct i2c_device_id *id)
@@ -786,17 +791,22 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)return status; } + status =devm_add_action_or_reset (&client->dev, twl_unregister_device, + pdev); +if (status) +return status; +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; - goto free; + goto out; } twl_priv =devm_kzalloc (&client->dev,sizeof (struct twl_private ),GFP_KERNEL );if (!twl_priv) { status = -ENOMEM ; - goto free; + goto out; }if ((id->driver_data) &TWL6030_CLASS ) {
@@ -820,7 +830,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) GFP_KERNEL);if (!twl_priv->twl_modules) { status = -ENOMEM ; - goto free; + goto out; }for (i =0 ; i < num_slaves; i++) {
@@ -907,10 +917,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) fail:if (status <0 )twl_remove (client); -free: -if (status <0 ) -platform_device_unregister (pdev); - +out:return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1446/2857 ALSA: hda/hdmi: clamp sad_count in ELD proc write handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit b3e7ddd694f8429217ba509b55b910a0e4361dfb ]
snd_hdmi_write_eld_info() parses a "sad_count N" line from the root-writable ELD proc interface and assigns N directly to e->sad_count with no upper bound, unlike the per-index "sadN_*" lines a few lines below which are already bounded to ELD_MAX_SAD.
snd_hdmi_eld_update_pcm_info() later iterates
"for (i = 0; i < e->sad_count; i++)" over the fixed e->sad[ELD_MAX_SAD] array, so an oversized sad_count read from the proc file causes it to walk past the array.
Reject sad_count values above ELD_MAX_SAD, matching the existing per-index guard.
--- sound/pci/hda/hda_eld.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/pci/hda/hda_eld.c +4 -2
@@ -525,9 +525,11 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, e->aud_synch_delay = val; else if (!strcmp(name, "speakers")) e->spk_alloc = val; - else if (!strcmp(name, "sad_count")) + else if (!strcmp(name, "sad_count")) { +if (val >ELD_MAX_SAD ) +continue ; e->sad_count = val; - else if (!strncmp(name, "sad", 3)) { + } else if (!strncmp(name, "sad", 3)) { sname = name +4 ; n = name[3 ] -'0' ;if (name[4 ] >='0' && name[4 ] <='9' ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1447/2857 overflow: Introduce overflows_type() and castable_to_type()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 4b21d25bf519c9487935a664886956bb18f04f6d ]
Implement a robust overflows_type() macro to test if a variable or constant value would overflow another variable or type. This can be used as a constant expression for static_assert() (which requires a constant expression[1][2]) when used on constant values. This must be constructed manually, since __builtin_add_overflow() does not produce a constant expression[3].
Additionally adds castable_to_type(), similar to __same_type(), but for checking if a constant value would overflow if cast to a given type.
Add unit tests for overflows_type(), __same_type(), and castable_to_type() to the existing KUnit "overflow" test:
[16:03:33] ================== overflow (21 subtests) ==================
...
[16:03:33] [PASSED] overflows_type_test
[16:03:33] [PASSED] same_type_test
[16:03:33] [PASSED] castable_to_type_test
[16:03:33] ==================== [PASSED] overflow ===================== [16:03:33] ============================================================ [16:03:33] Testing complete. Ran 21 tests: passed: 21
[16:03:33] Elapsed time: 24.022s total, 0.002s configuring, 22.598s building, 0.767s running
[1] https://en.cppreference.com/w/c/language/_Static_assert
[2] C11 standard (ISO/IEC 9899:2011): 6.7.10 Static assertions
[3] https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html
6.56 Built-in Functions to Perform Arithmetic with Overflow Checking Built-in Function: bool __builtin_add_overflow (type1 a, type2 b,
Stable-dep-of: 1c8f6308e557 ("iommu/dma: Catch scatterlist length overflows")
--- drivers/gpu/drm/i915/i915_user_extensions.c | 2 +- drivers/gpu/drm/i915/i915_utils.h | 4 - include/linux/compiler.h | 1 + include/linux/overflow.h | 47 +++ lib/Makefile | 1 + lib/overflow_kunit.c | 381 ++++++++++++++++++++ 6 files changed, 431 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_user_extensions.c +1 -1
@@ -51,7 +51,7 @@ int i915_user_extensions(struct i915_user_extension __user *ext,return err;if (get_user (next, &ext->next_extension) || -overflows_type (next, ext)) +overflows_type (next, uintptr_t))return -EFAULT ; ext =u64_to_user_ptr (next);
drivers/gpu/drm/i915/i915_utils.h +0 -4
@@ -111,10 +111,6 @@ bool i915_error_injected(void);#define range_overflows_end_t (type, start, size, max) \ range_overflows_end((type)(start), (type)(size), (type)(max)) -/* Note we don't consider signbits :| */ -#define overflows_type (x,T ) \ - (sizeof(x) > sizeof(T) && (x) >> BITS_PER_TYPE(T)) -#define ptr_mask_bits (ptr, n) ({ \ unsigned long __v = (unsigned long)(ptr); \ (typeof(ptr))(__v & -BIT(n)); \
include/linux/compiler.h +1 -0
@@ -243,6 +243,7 @@ static inline void *offset_to_ptr(const int *off)* bool and also pointer types. */ #define is_signed_type (type) (((type)(-1)) < (__force type)1) +#define is_unsigned_type (type) (!is_signed_type(type))/* * Useful shorthand for "is this condition known at compile-time?"
include/linux/overflow.h +47 -0
53 lines not on this page · raw message
lib/Makefile +1 -0
@@ -385,6 +385,7 @@ obj-$(CONFIG_CMDLINE_KUNIT_TEST) += cmdline_kunit.o obj-$(CONFIG_SLUB_KUNIT_TEST) += slub_kunit.o obj-$(CONFIG_MEMCPY_KUNIT_TEST) += memcpy_kunit.o obj-$(CONFIG_IS_SIGNED_TYPE_KUNIT_TEST) += is_signed_type_kunit.o +CFLAGS_overflow_kunit.o = $(call cc-disable-warning, tautological-constant-out-of-range-compare) obj-$(CONFIG_OVERFLOW_KUNIT_TEST) += overflow_kunit.o CFLAGS_stackinit_kunit.o += $(call cc-disable-warning, switch-unreachable) obj-$(CONFIG_STACKINIT_KUNIT_TEST) += stackinit_kunit.o
lib/overflow_kunit.c +381 -0
393 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1448/2857 iommu/dma: Catch scatterlist length overflows
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Karas <[email protected]>
[ Upstream commit 1c8f6308e557f32412e9d4678b3f029f47f6d9aa ]
It is possible, when a very large mapping uses only one scatterlist, that padding overflows scatterlist's length field. This results in:
1) silently wrapping the value
2) smaller than desired mappings produced by iommu_map_sg
3) leaving mapped bytes in memory (no iommu_unmap)
Address this issue by adding overflow detection for scatterlist length field.
--- drivers/iommu/dma-iommu.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +19 -1
@@ -1250,6 +1250,11 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,sg_dma_len (s) = s_length; s->offset -= s_iova_off; s_length =iova_align (iovad, s_length + s_iova_off); +if (overflows_type (s_length, s->length)) { + ret = -EOVERFLOW ; + + goto out_restore_sg; + } s->length = s_length;/*
@@ -1266,7 +1271,20 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,* time through here (i.e. before it has a meaningful value). */ if (pad_len && pad_len < s_length -1 ) { - prev->length += pad_len; +unsigned int new_prev_len; + +/* +* For large mappings spanning multiple GBs we +* may not be able to fit all needed padding into +* sg->length. +*/ +if (check_add_overflow (prev->length, pad_len, &new_prev_len)) { + ret = -EOVERFLOW ; + + goto out_restore_sg; + } + + prev->length = new_prev_len; iova_len += pad_len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1449/2857 mailbox: altera: shut down RX polling timer on channel teardown
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 0cf10e65639cba32d05994f85e6a8f08dd0ffe08 ]
The RX polling callback unconditionally rearms the timer after it processes mailbox data. altera_mbox_shutdown() uses timer_delete_sync(), which waits for a running callback but does not prevent that callback from rearming the timer after the deletion.
Use timer_shutdown_sync() for the final polling teardown so the timer cannot be queued again while the mailbox channel is being released. The timer is reinitialized with timer_setup() on a later channel startup, so polling mode remains reusable.
--- drivers/mailbox/mailbox-altera.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mailbox/mailbox-altera.c +1 -1
@@ -270,7 +270,7 @@ static void altera_mbox_shutdown(struct mbox_chan *chan)writel_relaxed (~0 , mbox->mbox_base +MAILBOX_INTMASK_REG );free_irq (mbox->irq, chan); }else if (!mbox->is_sender) { -del_timer_sync (&mbox->rxpoll_timer); +timer_shutdown_sync (&mbox->rxpoll_timer); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1450/2857 platform/x86: asus-wmi: Serialize WMI method evaluations with a mutex
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit b9428edaf4109e86a97254228d831767d0acc1f8 ]
Concurrent evaluations of ASUS WMI management methods (from ACPI notify, HID, userspace daemons, and debugfs) enter the BIOS ACPI/SMM interface simultaneously, triggering re-entrant SMIs or EC mailbox buffer corruption.
Fix this at the root by introducing a centralized evaluation helper (asus_wmi_evaluate_method_locked()) protected by a global mutex (asus_wmi_eval_lock) using guard(mutex). Route all evaluations of ASUS_WMI_MGMT_GUID (method3, method5, method_buf, and show_call) through this helper.
A static mutex is required because asus_wmi_evaluate_method() is an exported symbol used by external modules (such as hid-asus and asus-armoury) that lack access to struct asus_wmi drvdata, and the underlying ASUS ACPI/EC management method is a single physical platform resource.
The mutex is non-recursive: nested ACPI/WMI notify handlers must not call back into evaluate on the same task (defer via workqueue, as asus_rfkill_notify already does).
The sysfs-versus-notify race predates the later export of asus_wmi_evaluate_method(), so Fixes points at the original shared evaluate helper rather than that export.
--- drivers/platform/x86/asus-wmi.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/platform/x86/asus-wmi.c +21 -9
@@ -15,6 +15,7 @@#include <linux/acpi.h> #include <linux/backlight.h> +#include <linux/cleanup.h> #include <linux/debugfs.h> #include <linux/dmi.h> #include <linux/fb.h>
@@ -26,6 +27,7 @@#include <linux/kernel.h> #include <linux/leds.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/pci.h> #include <linux/pci_hotplug.h> #include <linux/platform_data/x86/asus-wmi.h>
@@ -274,6 +276,20 @@ struct asus_wmi {/* WMI ************************************************************************/ +/* +* Concurrent evaluations of ASUS WMI methods can re-enter firmware +* SMI/EC mailbox handling and corrupt the mailbox. +*/ +static DEFINE_MUTEX (asus_wmi_eval_lock); + +static acpi_status asus_wmi_evaluate_method_locked (u32 method_id, +struct acpi_buffer *input, +struct acpi_buffer *output) +{ +guard (mutex)(&asus_wmi_eval_lock); +return wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, input, output); +} +static int asus_wmi_evaluate_method3 (u32 method_id,u32 arg0,u32 arg1,u32 arg2,u32 *retval) {
@@ -288,8 +304,7 @@ static int asus_wmi_evaluate_method3(u32 method_id,union acpi_object *obj;u32 tmp =0 ; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (method_id, &input, &output);if (ACPI_FAILURE (status))return -EIO ;
@@ -331,8 +346,7 @@ static int asus_wmi_evaluate_method5(u32 method_id,union acpi_object *obj;u32 tmp =0 ; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (method_id, &input, &output);if (ACPI_FAILURE (status))return -EIO ;
@@ -370,8 +384,7 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,union acpi_object *obj;int err =0 ; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (method_id, &input, &output);if (ACPI_FAILURE (status))return -EIO ;
@@ -3660,9 +3673,8 @@ static int show_call(struct seq_file *m, void *data)union acpi_object *obj;acpi_status status; - status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID , -0 , asus->debug.method_id, - &input, &output); + status =asus_wmi_evaluate_method_locked (asus->debug.method_id, + &input, &output);if (ACPI_FAILURE (status))return -EIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1451/2857 mm: disallow ioremaping ordinary RAM in generic_access_phys()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 4590752e20aa393cc0d4fe538c0747d14a98c97a ]
generic_access_phys() can end up getting called on CoW PFNMAP mappings, resulting in it trying to ioremap anonymous folios, which especially the x86 code doesn't enjoy, and which is in general just odd/wrong.
E.g., with a CoW mapping of a PCI BAR:
ioremap on RAM at 0x0000000045623000 - 0x0000000045623fff
WARNING: arch/x86/mm/ioremap.c:216 at __ioremap_caller.isra.0+0x4c2/0x5f0 Call Trace: generic_access_phys+0x130/0x4d0 mm/memory.c:7178 kernfs_vma_access+0x1ce/0x280 fs/kernfs/file.c:437 __access_remote_vm+0x58f/0x890 mm/memory.c:7256 mem_rw+0x2a1/0x670 fs/proc/base.c:912
But more generically, we should disallow access to anything that looks like ordinary RAM in the system: including allocating memory (e.g., alloc_pages) and mapping them in a VM_PFNMAP.
For pages with an online memmap, allow only pages marked as reserved (PageReserved). This also includes memblock allocations, however, distinguishing them from other MMIO is tricky, and nobody should really be mapping them in a PFNMAP (except someone abusing /dev/mem, which we do not care about).
So only allow access if there is no online memmap, or if the pages are marked reserved. Reject other pages with -EINVAL.
Note that, just like other pfn_to_online_page() users, we won't care about concurrent memory offlining; mapping memory that can concurrently get offlined is highly dubious.
--- mm/memory.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
mm/memory.c +14 -0
@@ -5644,6 +5644,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,resource_size_t phys_addr;unsigned long prot =0 ;void __iomem *maddr; +struct page *page;pte_t *ptep, pte;spinlock_t *ptl;int offset =offset_in_page (addr);
@@ -5656,6 +5657,19 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if (follow_pte (vma->vm_mm, addr, &ptep, &ptl))return -EINVAL ; pte = *ptep; + +/* +* Reject anything that looks like ordinary RAM, including anonymous +* folios in CoW mappings or allocated kernel memory. Note that we +* cannot distinguish memblock allocations from non-RAM reliably, so +* we cannot easily reject them here. +*/ + page =pfn_to_online_page (pte_pfn (pte)); +if (page && !PageReserved (page)) { +pte_unmap_unlock (ptep, ptl); +return -EINVAL ; + } +pte_unmap_unlock (ptep, ptl); prot =pgprot_val (pte_pgprot (pte));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1452/2857 KVM: arm64: Move IN_GUEST_MODE ahead of state being loaded
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit 22b6557ad05bf05c73246f62c19af3e04017270e ]
IN_GUEST_MODE is advertised too late, when state has already been moved onto CPU registers and cannot be observed by another CPU anymore.
Move the IN_GUEST_MODE publication ahead of the state being loaded, and immediately check for pending request. This ensures that there is no window of opportunity for another CPU to observe OUTSIDE_GUEST_MODE and yet for state to be loaded.
This also simplifies the "state rollback", which solely amounts to synchronising the timer when no irqchip is present.
--- arch/arm64/kvm/arm.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
arch/arm64/kvm/arm.c +10 -7
@@ -923,30 +923,33 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)local_irq_disable (); -kvm_vgic_flush_hwstate (vcpu); - -kvm_pmu_update_vcpu_events (vcpu); -/* * Ensure we set mode to IN_GUEST_MODE after we disable * interrupts and before the final VCPU requests check. * See the comment in kvm_vcpu_exiting_guest_mode() and * Documentation/virt/kvm/vcpu-requests.rst +* +* Requests to self must be posted before this point, or +* won't be taken into account until the next exit. No state +* loading other than what happens at vcpu_load() time can +* be done before we have checked for pending requests. */ smp_store_mb (vcpu->mode,IN_GUEST_MODE );if (ret <=0 ||kvm_vcpu_exit_request (vcpu, &ret)) { -isb ();/* Ensure work in x_flush_hwstate is committed */ -kvm_pmu_sync_hwstate (vcpu);if (unlikely (!irqchip_in_kernel (vcpu->kvm)))kvm_timer_sync_user (vcpu); -kvm_vgic_sync_hwstate (vcpu);smp_store_release (&vcpu->mode,OUTSIDE_GUEST_MODE );local_irq_enable ();preempt_enable ();continue ; } +/* From here onwards, we are commited to entering the guest */ +kvm_vgic_flush_hwstate (vcpu); + +kvm_pmu_update_vcpu_events (vcpu); +kvm_arm_setup_debug (vcpu);kvm_arch_vcpu_ctxflush_fp (vcpu);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1453/2857 media: rockchip: rga: fix clock cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 254f3337ce2575bf94f1fb40cc40fdbc70371116 ]
Fix this smatch warning:
drivers/media/platform/rockchip/rga/rga.c:734 rga_enable_clocks() warn: 'rga->sclk' from clk_prepare_enable() not released on lines: 734.
The reason is that aclk should be disabled/unprepared before sclk, instead of the other way around.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +2 -2
@@ -717,10 +717,10 @@ static int rga_enable_clocks(struct rockchip_rga *rga)return 0 ; -err_disable_sclk: -clk_disable_unprepare (rga->sclk); err_disable_aclk:clk_disable_unprepare (rga->aclk); +err_disable_sclk: +clk_disable_unprepare (rga->sclk);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1454/2857 media: rockchip: rga: use clk_bulk api
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Püschel <[email protected]>
[ Upstream commit a2a4f69fd2e333bacd17d1788eb5211cb6f373cc ]
Use the clk_bulk API to avoid code duplication for each of the three clocks.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 65 +++-------------------- drivers/media/platform/rockchip/rga/rga.h | 6 +-- 2 files changed, 11 insertions(+), 60 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +8 -57
@@ -693,48 +693,10 @@ static const struct video_device rga_videodev = { .device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING, }; -static int rga_enable_clocks (struct rockchip_rga *rga) -{ -int ret; - - ret =clk_prepare_enable (rga->sclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga sclk: %d\n" , ret); -return ret; - } - - ret =clk_prepare_enable (rga->aclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga aclk: %d\n" , ret); - goto err_disable_sclk; - } - - ret =clk_prepare_enable (rga->hclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga hclk: %d\n" , ret); - goto err_disable_aclk; - } - -return 0 ; - -err_disable_aclk: -clk_disable_unprepare (rga->aclk); -err_disable_sclk: -clk_disable_unprepare (rga->sclk); - -return ret; -} - -static void rga_disable_clocks (struct rockchip_rga *rga) -{ -clk_disable_unprepare (rga->sclk); -clk_disable_unprepare (rga->hclk); -clk_disable_unprepare (rga->aclk); -} -static int rga_parse_dt (struct rockchip_rga *rga) {struct reset_control *core_rst, *axi_rst, *ahb_rst; +int ret; core_rst =devm_reset_control_get (rga->dev,"core" );if (IS_ERR (core_rst)) {
@@ -766,23 +728,12 @@ static int rga_parse_dt(struct rockchip_rga *rga)udelay (1 );reset_control_deassert (ahb_rst); - rga->sclk =devm_clk_get (rga->dev,"sclk" ); -if (IS_ERR (rga->sclk)) { -dev_err (rga->dev,"failed to get sclk clock\n" ); -return PTR_ERR (rga->sclk); - } - - rga->aclk =devm_clk_get (rga->dev,"aclk" ); -if (IS_ERR (rga->aclk)) { -dev_err (rga->dev,"failed to get aclk clock\n" ); -return PTR_ERR (rga->aclk); - } - - rga->hclk =devm_clk_get (rga->dev,"hclk" ); -if (IS_ERR (rga->hclk)) { -dev_err (rga->dev,"failed to get hclk clock\n" ); -return PTR_ERR (rga->hclk); + ret =devm_clk_bulk_get_all (rga->dev, &rga->clks); +if (ret <0 ) { +dev_err (rga->dev,"failed to get clocks\n" ); +return ret; } + rga->num_clks = ret;return 0 ; }
@@ -946,7 +897,7 @@ static int __maybe_unused rga_runtime_suspend(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -rga_disable_clocks (rga); +clk_bulk_disable_unprepare (rga->num_clks, rga->clks);return 0 ; }
@@ -955,7 +906,7 @@ static int __maybe_unused rga_runtime_resume(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -return rga_enable_clocks (rga); +return clk_bulk_prepare_enable (rga->num_clks, rga->clks); }static const struct dev_pm_ops rga_pm = {
drivers/media/platform/rockchip/rga/rga.h +3 -3
@@ -6,6 +6,7 @@#ifndef __RGA_H__#define __RGA_H__ +#include <linux/clk.h> #include <linux/platform_device.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h>
@@ -68,9 +69,8 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; -struct clk *sclk; -struct clk *aclk; -struct clk *hclk; +struct clk_bulk_data *clks; +int num_clks;struct rockchip_rga_version version;/* vfd lock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1455/2857 media: rockchip: rga: quiesce IRQ before releasing m2m state
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit a875c43dd95ee4f9c4e3e5ae1cb8362cc6d7817d ]
rga_remove() releases the m2m state before the IRQ is freed. The IRQ is devm-managed and is only released once rga_remove() returns, so rga_isr() can still run while the m2m device state is being torn down.
Store the IRQ number in struct rockchip_rga, unregister the video device first, and free the IRQ before releasing the m2m state so the handler cannot run against the freed state.
--- drivers/media/platform/rockchip/rga/rga.c | 4 +++- drivers/media/platform/rockchip/rga/rga.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/rockchip/rga/rga.c +3 -1
@@ -773,6 +773,7 @@ static int rga_probe(struct platform_device *pdev) ret = irq; goto err_put_clk; } + rga->irq = irq; ret =devm_request_irq (rga->dev, irq, rga_isr,0 ,dev_name (rga->dev), rga);
@@ -884,8 +885,9 @@ static int rga_remove(struct platform_device *pdev)v4l2_info (&rga->v4l2_dev,"Removing\n" ); -v4l2_m2m_release (rga->m2m_dev);video_unregister_device (rga->vfd); +devm_free_irq (rga->dev, rga->irq, rga); +v4l2_m2m_release (rga->m2m_dev);v4l2_device_unregister (&rga->v4l2_dev);pm_runtime_disable (rga->dev);
drivers/media/platform/rockchip/rga/rga.h +1 -0
@@ -69,6 +69,7 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; +int irq;struct clk_bulk_data *clks;int num_clks;struct rockchip_rga_version version;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1456/2857 fbdev: core: Initialize modelist in framebuffer_alloc()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Misiurov <[email protected]>
[ Upstream commit 0c9cb9321cb3863b52bdea4b8ae5a27705762c9e ]
framebuffer_alloc() returns zeroed memory, so info->modelist starts out with NULL next and prev pointers. The list head is initialized only later, by fb_videomode_to_modelist() or by do_register_framebuffer().
The "fix potential memory leak" commits listed below added fb_destroy_modelist(&info->modelist) to the probe error paths of s3fb, tdfxfb, tridentfb, i740fb and carminefb. These paths can run before the list head is initialized:
- s3fb, tdfxfb, tridentfb and i740fb call fb_videomode_to_modelist() only after a successful EDID read, and tridentfb can also hit the error path on an ioremap() or kmalloc() failure before that;
- carminefb jumps to the error path when fb_find_mode() fails, before its fb_videomode_to_modelist() call.
fb_destroy_modelist() then dereferences the NULL head. Reproduced on Debian 12 (6.1.180) by binding s3fb to a VGA device without EDID and forcing fb_alloc_cmap() to fail:
s3fb 0000:00:03.0: cannot allocate colormap
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:fb_destroy_modelist+0x10/0x80 Call Trace: s3_pci_probe.cold+0x12b/0x2bf [s3fb] local_pci_probe+0x41/0x80 pci_device_probe+0xc3/0x240 really_probe+0xde/0x380 __driver_probe_device+0x84/0x150 driver_probe_device+0x1f/0x90 __driver_attach+0xce/0x1c0 bus_for_each_dev+0x87/0xd0 bus_add_driver+0x1ae/0x200 driver_register+0x89/0xe0 do_one_initcall+0x59/0x220 do_init_module+0x4a/0x1f0
Initialize the list head in framebuffer_alloc(), so info->modelist is always a valid, possibly empty, list and fb_destroy_modelist() is safe on every error path. Keep the lazy initialization in do_register_framebuffer(), as drivers that embed struct fb_info rather than calling framebuffer_alloc() still depend on it.
--- drivers/video/fbdev/core/fbsysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/core/fbsysfs.c +1 -0
@@ -56,6 +56,7 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev) info->device = dev; info->fbcon_rotate_hint =-1 ; +INIT_LIST_HEAD (&info->modelist);#if IS_ENABLED (CONFIG_FB_BACKLIGHT )mutex_init (&info->bl_curve_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1457/2857 s390/pci: Add error cleanup in zpci_directed_irq_init()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Schumacher <[email protected]>
[ Upstream commit 769f66f595c11185c66913ea5d96420504bfebc3 ]
If per-CPU airq_iv allocation fails in the loop, previously allocated vectors and arrays leak. Add proper error path to release all resources on failure.
The error path frees zpci_sbv, but SIC_IRQ_MODE_DIRECT has already programmed its address into the hardware. Set the directed interrupt mode only after all allocations have succeeded, so a failed init leaves no freed memory registered with the hardware.
--- arch/s390/pci/pci_irq.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
arch/s390/pci/pci_irq.c +19 -7
@@ -450,15 +450,10 @@ static int __init zpci_directed_irq_init(void)if (!zpci_sbv)return -ENOMEM ; - iib.diib.isc =PCI_ISC ; - iib.diib.nr_cpus =num_possible_cpus (); - iib.diib.disb_addr =virt_to_phys (zpci_sbv->vector); -zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib); - zpci_ibv =kcalloc (num_possible_cpus (),sizeof (*zpci_ibv),GFP_KERNEL );if (!zpci_ibv) -return -ENOMEM ; + goto out_free_sbv;for_each_possible_cpu (cpu) {/*
@@ -470,13 +465,30 @@ static int __init zpci_directed_irq_init(void)AIRQ_IV_CACHELINE | (!cpu ? AIRQ_IV_ALLOC : 0), NULL);if (!zpci_ibv[cpu]) -return -ENOMEM ; + goto out_free_dibv; } + + iib.diib.isc =PCI_ISC ; + iib.diib.nr_cpus =num_possible_cpus (); + iib.diib.disb_addr =virt_to_phys (zpci_sbv->vector); +zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib);on_each_cpu (cpu_enable_directed_irq,NULL ,1 ); zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;return 0 ; + +out_free_dibv: +for_each_possible_cpu (cpu) { +if (zpci_ibv[cpu]) +airq_iv_release (zpci_ibv[cpu]); + } +kfree (zpci_ibv); + zpci_ibv =NULL ; +out_free_sbv: +airq_iv_release (zpci_sbv); + zpci_sbv =NULL ; +return -ENOMEM ; }static int __init zpci_floating_irq_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1458/2857 ALSA: mpu401: shut down timer before freeing MPU
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9332af5220d42341bb1446a62c545c0518e990ef ]
When an MPU401 interface has no usable IRQ, the driver polls raw-MIDI input and output with a timer. During raw-MIDI teardown, the timer callback can already be running when snd_mpu401_uart_remove_timer() clears the last mode bit and calls timer_delete(). That API neither waits for a running callback nor prevents it from rearming the timer, and free_irq() does not synchronize timer callbacks. snd_mpu401_uart_free() can therefore release mpu while the timer callback still uses it.
Initialize the timer once when the MPU object is created and only rearm it while a timer mode is active. Shut it down synchronously after freeing the IRQ so an in-flight callback completes before mpu and its resources are released.
--- sound/drivers/mpu401/mpu401_uart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/drivers/mpu401/mpu401_uart.c +5 -3
@@ -161,14 +161,15 @@ static void snd_mpu401_uart_timer(struct timer_list *t)spin_lock_irqsave (&mpu->timer_lock, flags);/*mpu->mode |= MPU401_MODE_TIMER;*/ -mod_timer (&mpu->timer,1 + jiffies); +if (mpu->timer_invoked) +mod_timer (&mpu->timer,1 + jiffies);spin_unlock_irqrestore (&mpu->timer_lock, flags);if (mpu->rmidi)_snd_mpu401_uart_interrupt (mpu); }/* -* initialize the timer callback if not programmed yet +* arm the timer if it is not already active */ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu,int input) {
@@ -176,7 +177,6 @@ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input)spin_lock_irqsave (&mpu->timer_lock, flags);if (mpu->timer_invoked ==0 ) { -timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 );mod_timer (&mpu->timer,1 + jiffies); } mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
@@ -490,6 +490,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)struct snd_mpu401 *mpu = rmidi->private_data;if (mpu->irq >=0 )free_irq (mpu->irq, (void *) mpu); +timer_shutdown_sync (&mpu->timer);release_and_free_resource (mpu->res);kfree (mpu); }
@@ -544,6 +545,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->input_lock);spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); +timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 ); mpu->hardware = hardware; mpu->irq =-1 ;if (! (info_flags &MPU401_INFO_INTEGRATED )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1459/2857 f2fs: remove mappedtodisk flag usage in mmap write path
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nanzhe Zhao <[email protected]>
[ Upstream commit b3c9843589257631bac18f30655e82d88970688a ]
PG_mappedtodisk was inherited from the nobh/buffer-head era. However, f2fs has no buffer heads and the flag is no longer meaningful. The only user of the flag is the "no holes" shortcut in f2fs_vm_page_mkwrite(), which makes mmap write faults skip marking the folio dirty. Moreover, it causes the following race condition with filesystem freezing:
CPU0 (write fault) CPU1 (freeze_super)
---- ----
f2fs_vm_page_mkwrite()
sb_start_pagefault()
/* shortcut: no dirty */
sb_end_pagefault()
sb_wait_write(SB_FREEZE_PAGEFAULT)
/* no waiter, passes */
sync_filesystem()
/* folio not dirty, skipped */ finish_fault()
/* PTE writable */
fault_dirty_shared_page()
folio_mark_dirty()
/* dirty folio on a frozen fs */
It will also skip APP_MAPPED_IO iostat/REQ_TIME updates and post-EOF folio zeroing.
Remove this shortcut in f2fs_vm_page_mkwrite() and stop setting it in f2fs_read_single_page().
--- fs/f2fs/data.c | 1 - fs/f2fs/file.c | 6 ------ 2 files changed, 7 deletions(-)
fs/f2fs/data.c +0 -1
@@ -2158,7 +2158,6 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, got_it:if ((map->m_flags &F2FS_MAP_MAPPED )) { block_nr = map->m_pblk + block_in_file - map->m_lblk; -SetPageMappedToDisk (page);if (!f2fs_is_valid_blkaddr (F2FS_I_SB (inode), block_nr,DATA_GENERIC_ENHANCE_READ )) {
fs/f2fs/file.c +0 -6
@@ -134,12 +134,6 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)/* wait for GCed page writeback via META_MAPPING */ f2fs_wait_on_block_writeback (inode, dn.data_blkaddr); -/* -* check to see if the page is mapped already (no holes) -*/ -if (PageMappedToDisk (page)) - goto out_sem; -/* page is wholly or partially inside EOF */ if (((loff_t)(page->index +1 ) <<PAGE_SHIFT ) >i_size_read (inode)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1460/2857 mm: memcontrol: raise MEMCG_MAX for charges that fail without reclaiming
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joe Damato <[email protected]>
[ Upstream commit 374f65b1481992eb6b9c6bffd53f3afa5c2e94cf ]
Charges that exceed memory.max and return through the nomem label can raise no event and simply return -ENOMEM.
A non-blocking charge can hit the limit, get rejected, but is not visible in memory.events.
This was noticed in a production setting where bpf_mem_alloc() attempted to refill its per-cpu freelists, which triggered a non-blocking charge while at the limit.
Commit d6e103a757fa ("mm: memcontrol: do not miss MEMCG_MAX events for enforced allocations") added raised_max_event to cover charges that are force charged without ever reaching reclaim, but charges that are rejected outright were left out. Getting an allocation failure without the corresponding MEMCG_MAX event is unexpected and makes debugging and monitoring harder.
Raise the event on the way out for rejected charges as well, by routing the -ENOMEM return through the same exit path that already covers forced charges. The existing behavior of raising a MEMCG_MAX event on every charge/reclaim/retry iteration is left unchanged.
Tested with a module that performs accounted GFP_NOWAIT page allocations from a task in a cgroup at its memory.max, and measures the resulting memory.events:max delta. Without this patch the rejected charges raise no event at all; with it the delta matches the number of rejected charges exactly. A GFP_KERNEL|__GFP_NORETRY control, which reaches reclaim, raises the same two events per failed charge before and after, confirming the existing charge/reclaim/retry accounting is unchanged.
--- mm/memcontrol.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-)
mm/memcontrol.c +16 -12
@@ -2640,10 +2640,11 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,bool drained = false;bool raised_max_event = false;unsigned long pflags; +int ret =0 ; retry:if (consume_stock (memcg, nr_pages)) -return 0 ; +return ret;if (!do_memsw_account () ||page_counter_try_charge (&memcg->memsw, batch, &counter)) {
@@ -2755,16 +2756,11 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,* put the burden of reclaim on regular allocation requests * and let these go through as privileged allocations. */ -if (!(gfp_mask & (__GFP_NOFAIL | __GFP_HIGH))) -return -ENOMEM ; +if (!(gfp_mask & (__GFP_NOFAIL | __GFP_HIGH))) { + ret = -ENOMEM ; + goto out; + } force: -/* -* If the allocation has to be enforced, don't forget to raise -* a MEMCG_MAX event. -*/ -if (!raised_max_event) -memcg_memory_event (mem_over_limit,MEMCG_MAX ); -/* * The allocation either can't fail or will lead to more memory * being freed very soon. Allow memory usage go over the limit
@@ -2774,7 +2770,15 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask,if (do_memsw_account ())page_counter_charge (&memcg->memsw, nr_pages); -return 0 ; +out: +/* +* Don't forget to raise a MEMCG_MAX event for forced or rejected +* requests. +*/ +if (!raised_max_event) +memcg_memory_event (mem_over_limit,MEMCG_MAX ); + +return ret; done_restock:if (batch > nr_pages)
@@ -2827,7 +2831,7 @@ static int try_charge_memcg(struct mem_cgroup *memcg, gfp_t gfp_mask, gfpflags_allow_blocking(gfp_mask)) {mem_cgroup_handle_over_high (gfp_mask); } -return 0 ; +return ret; } static inline int try_charge(struct mem_cgroup *memcg, gfp_t gfp_mask,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1461/2857 mptcp: reset msk state on early connect failure
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Quanye Yang <[email protected]>
[ Upstream commit 29afe67082b2d33ab2e90c56c337235d725f023f ]
mptcp_connect() can fall back before the subflow SYN is sent, for example when the netns is in an MPTCP blackhole, token allocation fails, or MD5SIG is in use. If the subsequent subflow connect() fails immediately (EAFNOSUPPORT, ENETUNREACH, ...), __inet_stream_connect() returns while the socket is still SS_UNCONNECTED and never calls ->disconnect(). This was reported by Clashiko [1].
The error path only dropped the token and moved the msk back to TCP_CLOSE. MPTCP_FALLBACK_DONE, allow_subflows and request_mptcp were left as after early fallback, so a later connect() on the same fd stayed TCP-only.
--- net/mptcp/protocol.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/mptcp/protocol.c +8 -0
@@ -3937,6 +3937,14 @@ static int mptcp_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)*/ if (unlikely (err && err != -EINPROGRESS )) {inet_sk_state_store (sk,inet_sk_state_load (ssock->sk)); + +spin_lock_bh (&msk->fallback_lock); + msk->allow_subflows = true; + msk->allow_infinite_fallback = true; +clear_bit (MPTCP_FALLBACK_DONE , &msk->flags); +spin_unlock_bh (&msk->fallback_lock); + +mptcp_subflow_ctx_reset (subflow);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1462/2857 f2fs: disallow mmap write and data-modifying fallocate on atomic files
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daeho Jeong <[email protected]>
[ Upstream commit 06dfe4a7eb696d868b196c2a49873142f19bd862 ]
Stores through a shared writable mapping and fallocate with FALLOC_FL_PUNCH_HOLE, FALLOC_FL_ZERO_RANGE, FALLOC_FL_COLLAPSE_RANGE or FALLOC_FL_INSERT_RANGE do not go through ->write_begin, so they bypass the COW inode and modify the original inode directly. Reject them while the file is in atomic write mode, as fallocate already does for pinned and compressed files. A write fault gets SIGBUS and fallocate gets -EOPNOTSUPP.
fallocate without these flags only preallocates blocks and stays allowed.
f2fs_vm_page_mkwrite() cannot take inode_lock, so check the flag under invalidate_lock, and hold invalidate_lock in f2fs_ioc_start_atomic_write() from the flush until the flag is set. Otherwise a fault could check the flag, then start_atomic_write could flush and set the flag, and the fault would dirty the folio afterwards.
--- fs/f2fs/file.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
fs/f2fs/file.c +23 -2
@@ -102,6 +102,18 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)file_update_time (vmf->vma->vm_file);filemap_invalidate_lock_shared (inode->i_mapping); + +/* +* mmap stores bypass the COW inode and would break atomicity. Check +* under invalidate_lock: f2fs_ioc_start_atomic_write() holds it while +* flushing dirty pages and setting FI_ATOMIC_FILE, so either it sees +* our dirty page and writes it back, or we see the flag. +*/ +if (unlikely (f2fs_is_atomic_file (inode))) { + err = -EOPNOTSUPP ; + goto out_sem; + } +lock_page (page); if (unlikely(page->mapping != inode->i_mapping || page_offset(page) > i_size_read(inode) ||
@@ -1882,9 +1894,11 @@ static long f2fs_fallocate(struct file *file, int mode,/* * Pinned file should not support partial truncation since the block -* can be used by applications. +* can be used by applications. Atomic files should not either, since +* these modify the original inode directly and break atomicity. */ -if ((f2fs_compressed_file (inode) ||f2fs_is_pinned_file (inode)) && +if ((f2fs_compressed_file (inode) ||f2fs_is_pinned_file (inode) || +f2fs_is_atomic_file (inode)) && (mode & (FALLOC_FL_PUNCH_HOLE |FALLOC_FL_COLLAPSE_RANGE |FALLOC_FL_ZERO_RANGE |FALLOC_FL_INSERT_RANGE ))) { ret = -EOPNOTSUPP ;
@@ -2168,6 +2182,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) goto out;f2fs_down_write (&fi->i_gc_rwsem[WRITE ]); +/* serialize with f2fs_vm_page_mkwrite(), see the comment there */ +filemap_invalidate_lock (inode->i_mapping);/* * Should wait end_io to count F2FS_WB_CP_DATA correctly by
@@ -2178,6 +2194,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) inode->i_ino, get_dirty_pages(inode)); ret =filemap_write_and_wait_range (inode->i_mapping,0 ,LLONG_MAX );if (ret) { +filemap_invalidate_unlock (inode->i_mapping);f2fs_up_write (&fi->i_gc_rwsem[WRITE ]); goto out; }
@@ -2187,6 +2204,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)/* Create a COW inode for atomic write */ pinode =f2fs_iget (inode->i_sb, fi->i_pino);if (IS_ERR (pinode)) { +filemap_invalidate_unlock (inode->i_mapping);f2fs_up_write (&fi->i_gc_rwsem[WRITE ]); ret =PTR_ERR (pinode); goto out;
@@ -2195,6 +2213,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) ret =f2fs_get_tmpfile (mnt_userns, pinode, &fi->cow_inode);iput (pinode);if (ret) { +filemap_invalidate_unlock (inode->i_mapping);f2fs_up_write (&fi->i_gc_rwsem[WRITE ]); goto out; }
@@ -2209,6 +2228,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp) ret =f2fs_do_truncate_blocks (fi->cow_inode,0 , true);if (ret) { +filemap_invalidate_unlock (inode->i_mapping);f2fs_up_write (&fi->i_gc_rwsem[WRITE ]); goto out; }
@@ -2223,6 +2243,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)stat_inc_atomic_inode (inode);set_inode_flag (inode,FI_ATOMIC_FILE ); +filemap_invalidate_unlock (inode->i_mapping);f2fs_up_write (&fi->i_gc_rwsem[WRITE ]);f2fs_update_time (sbi,REQ_TIME );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1463/2857 serial: sc16is7xx: declare SPR/TLR/XOFF2 register as volatile
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 983f91e5f13149ade6dbd9568053ecd0ab5e9265 ]
SPR shares the same address space as TLR and XOFF2. If SPR or TLR were to be used eventually, this could lead to incorrect read value from the cache.
Prevent this potential bug by declaring SPR/TLR/XOFF2 as volatile.
Stable-dep-of: 1c41d09dcd07 ("serial: sc16is7xx: declare MCR and IER as volatile registers")
--- drivers/tty/serial/sc16is7xx.c | 1 + 1 file changed, 1 insertion(+)
drivers/tty/serial/sc16is7xx.c +1 -0
@@ -534,6 +534,7 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg)case SC16IS7XX_IIR_REG :case SC16IS7XX_LSR_REG :case SC16IS7XX_MSR_REG : +case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG :case SC16IS7XX_RXLVL_REG :case SC16IS7XX_IOSTATE_REG :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1464/2857 serial: sc16is7xx: add comments for lock requirements
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 42405cb77fd35b5acc0e5a11d74eef68c2afa484 ]
Indicate why lock needs to be asserted when accessing
MSR register, as this is not immediately obvious when looking at this register in the device datasheet.
Stable-dep-of: 1c41d09dcd07 ("serial: sc16is7xx: declare MCR and IER as volatile registers")
--- drivers/tty/serial/sc16is7xx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/tty/serial/sc16is7xx.c +5 -4
@@ -530,10 +530,10 @@ static const struct sc16is7xx_devtype sc16is762_devtype = {static bool sc16is7xx_regmap_volatile (struct device *dev,unsigned int reg) {switch (reg) { -case SC16IS7XX_RHR_REG : -case SC16IS7XX_IIR_REG : -case SC16IS7XX_LSR_REG : -case SC16IS7XX_MSR_REG : +case SC16IS7XX_RHR_REG :/* Shared address space with THR & DLL */ +case SC16IS7XX_IIR_REG :/* Shared address space with FCR & EFR */ +case SC16IS7XX_LSR_REG :/* Shared address space with XON2 */ +case SC16IS7XX_MSR_REG :/* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */ case SC16IS7XX_TXLVL_REG :case SC16IS7XX_RXLVL_REG :
@@ -768,6 +768,7 @@ static void sc16is7xx_update_mlines(struct sc16is7xx_one *one)unsigned long flags;unsigned int status, changed; +/* Lock required as MSR address is shared with TCR and XOFF1. */ lockdep_assert_held_once (&one->lock); status =sc16is7xx_get_hwmctrl (port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1465/2857 serial: sc16is7xx: declare MCR and IER as volatile registers
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 1c41d09dcd07ee9648e20aa8238e404c2e6a12fb ]
MCR register has the same address as XON1 register. IER register has the same address as DLH register.
Which register is accessed depends on bits configuration in some other registers.
To prevent potential access errors, declare MCR and IER as volatile registers.
--- drivers/tty/serial/sc16is7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/sc16is7xx.c +2 -0
@@ -531,7 +531,9 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) {switch (reg) {case SC16IS7XX_RHR_REG :/* Shared address space with THR & DLL */ +case SC16IS7XX_IER_REG :/* Shared address space with DLH */ case SC16IS7XX_IIR_REG :/* Shared address space with FCR & EFR */ +case SC16IS7XX_MCR_REG :/* Shared address space with XON1 */ case SC16IS7XX_LSR_REG :/* Shared address space with XON2 */ case SC16IS7XX_MSR_REG :/* Shared address space with TCR & XOFF1 */ case SC16IS7XX_SPR_REG :/* Shared address space with TLR & XOFF2 */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1466/2857 virtiofs: add FUSE protocol validation
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuto Ohnuki <[email protected]>
[ Upstream commit 68b69fa0edb241a946cd4c850110990f30705164 ]
Add virtio_fs_verify_response() to validate that the server properly follows the FUSE protocol by checking:
- Response length is at least sizeof(struct fuse_out_header).
- oh.len matches the actual response length.
- oh.unique matches the request's unique identifier.
On validation failure, set error to -EIO and normalize oh.len to prevent underflow in copy_args_from_argbuf().
Addresses the TODO comment in virtio_fs_request_complete().
Stable-dep-of: 5364d081125a ("virtiofs: validate fixed-output response length")
--- fs/fuse/virtio_fs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
fs/fuse/virtio_fs.c +25 -4
@@ -564,6 +564,27 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req) req->argbuf =NULL ; } +/* Verify that the server properly follows the FUSE protocol */ +static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) +{ +struct fuse_out_header *oh = &req->out.h; + +if (len <sizeof (*oh)) { +pr_warn ("virtio-fs: response too short (%u)\n" , len); +return false; + } +if (oh->len != len) { +pr_warn ("virtio-fs: oh.len mismatch (%u != %u)\n" , oh->len, len); +return false; + } +if (oh->unique != req->in.h.unique) { +pr_warn ("virtio-fs: oh.unique mismatch (%llu != %llu)\n" , + oh->unique, req->in.h.unique); +return false; + } +return true; +} +/* Work function for request completion */ static void virtio_fs_request_complete (struct fuse_req *req,struct virtio_fs_vq *fsvq)
@@ -574,10 +595,6 @@ static void virtio_fs_request_complete(struct fuse_req *req,unsigned int len, i, thislen;struct page *page; -/* -* TODO verify that server properly follows FUSE protocol -* (oh.uniq, oh.len) -*/ args = req->args;copy_args_from_argbuf (args, req);
@@ -633,6 +650,10 @@ static void virtio_fs_requests_done_work(struct work_struct *work)virtqueue_disable_cb (vq);while ((req =virtqueue_get_buf (vq, &len)) !=NULL ) { +if (!virtio_fs_verify_response (req, len)) { + req->out.h.error = -EIO ; + req->out.h.len =sizeof (struct fuse_out_header ); + }spin_lock (&fpq->lock);list_move_tail (&req->list, &reqs);spin_unlock (&fpq->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1467/2857 virtiofs: validate fixed-output response length
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 5364d081125a34e90851fbb46ecc93f79339ce78 ]
A short successful virtiofs response can leave the fixed-output portion of the request argument buffer unwritten. The completion path nevertheless copies the full declared output to the request destination, allowing stale allocator contents to reach callers such as fuse_statfs().
Require successful fixed-output responses to contain their complete declared output. Continue to permit a shorter final argument only for out_argvar requests. Reject positive and internal restart error values and require valid error replies to be header-only. The error already stored in the FUSE output header is returned by fuse_request_end(), so do not copy output arguments from an error reply.
This was found by source review with AI assistance. A header-only successful FUSE_STATFS reply returned stale fields in nine of nine calls across three boots. The fixed kernel rejected the short response and preserved complete replies, valid negative-error replies, and variable-output replies.
--- fs/fuse/virtio_fs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
fs/fuse/virtio_fs.c +30 -0
@@ -535,6 +535,10 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)unsigned int num_out;unsigned int i; +/* fuse_request_end() returns this error; there are no args to copy. */ +if (req->out.h.error) + goto out; + remaining = req->out.h.len -sizeof (req->out.h); num_in = args->in_numargs - args->in_pages; num_out = args->out_numargs - args->out_pages;
@@ -560,6 +564,7 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)if (args->out_argvar) args->out_args[args->out_numargs -1 ].size = remaining; +out:kfree (req->argbuf); req->argbuf =NULL ; }
@@ -567,7 +572,9 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)/* Verify that the server properly follows the FUSE protocol */ static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) { +struct fuse_args *args = req->args;struct fuse_out_header *oh = &req->out.h; +unsigned int expected;if (len <sizeof (*oh)) {pr_warn ("virtio-fs: response too short (%u)\n" , len);
@@ -582,6 +589,29 @@ static bool virtio_fs_verify_response(struct fuse_req *req, unsigned int len) oh->unique, req->in.h.unique);return false; } +if (oh->error <= -ERESTARTSYS || oh->error >0 ) { +pr_warn ("virtio-fs: invalid error value (%d)\n" , oh->error); +return false; + } + +if (oh->error) { +if (len !=sizeof (*oh)) { +pr_warn ("virtio-fs: error response too long (%u)\n" , len); +return false; + } +return true; + } + + expected =sizeof (*oh) + +fuse_len_args (args->out_numargs, args->out_args); +if (len > expected || + (len < expected && + (!args->out_argvar || + expected - len > args->out_args[args->out_numargs -1 ].size))) { +pr_warn ("virtio-fs: invalid response length (%u, expected %u)\n" , + len, expected); +return false; + }return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1468/2857 mm/page_table_check: skip zero pages
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhiling Zou <[email protected]>
[ Upstream commit 33afd07412a1efe5b750a3fd5eb0272ebdd12761 ]
page_table_check_set() accounts pages by whether they are PageAnon(). The shared zero page is a special page, not an ordinary file-backed page. Read faults on private anonymous mappings can install many read-only PTEs that point at the zero page, but page_table_check currently accounts them in file_map_count.
That lets an unprivileged process populate enough zero-page mappings to overflow file_map_count and trip the BUG_ON() in page_table_check_set().
Skip zero pages in page_table_check accounting. They do not need the anonymous/file mapping conflict checks that page_table_check performs for ordinary pages, and this keeps the existing counter size and page_ext layout unchanged.
--- mm/page_table_check.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
mm/page_table_check.c +4 -2
@@ -64,7 +64,8 @@ static void page_table_check_clear(struct mm_struct *mm, unsigned long addr,unsigned long i;bool anon; -if (!pfn_valid (pfn)) +if (!pfn_valid (pfn) ||is_zero_pfn (pfn) || +is_huge_zero_page (compound_head (pfn_to_page (pfn))))return ; page =pfn_to_page (pfn);
@@ -105,7 +106,8 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr,unsigned long i;bool anon; -if (!pfn_valid (pfn)) +if (!pfn_valid (pfn) ||is_zero_pfn (pfn) || +is_huge_zero_page (compound_head (pfn_to_page (pfn))))return ; page =pfn_to_page (pfn);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1469/2857 mm/memory: constrain generic_access_phys() to page boundary
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luxiao Xu <[email protected]>
[ Upstream commit ae0298a5fbeff32951c0d31398ccec97ec6aa0ea ]
This patch addresses an issue in generic_access_phys() where accessing memory across page boundaries in PFNMAP VMAs assumes physical pages are contiguous, which can lead to accessing unintended physical memory or exceeding VMA boundaries.
generic_access_phys() improperly validates the memory access range: it only validates the start address using follow_pfnmap_start() and passes PAGE_ALIGN(len + offset) to ioremap_prot().
This poses two problems:
1. In PFNMAP VMAs, consecutive virtual pages are not guaranteed to be physically contiguous, and individual PTEs may have different access permissions or writability.
2. The mapping may cross VMA boundaries if len extends beyond vma->vm_end.
Constrain the access in generic_access_phys() to at most the current page boundary (PAGE_SIZE - offset) and map only a single PAGE_SIZE via ioremap_prot(). Since the caller __access_remote_vm() already loops over the requested length and handles partial transfers, it will naturally iterate over the remaining pages.
Also add a missing (resource_size_t) cast during PFN re-validation to avoid truncation on 32-bit PAE systems.
--- mm/memory.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
mm/memory.c +7 -1
@@ -5653,6 +5653,12 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if (!(vma->vm_flags & (VM_IO |VM_PFNMAP )))return -EINVAL ; +/* +* Limit access to one page at a time, as that's what follow_pte() +* guarantees; expect the caller to retry to read larger ranges. +*/ + len =min_t (int, len,PAGE_SIZE - offset); + retry:if (follow_pte (vma->vm_mm, addr, &ptep, &ptl))return -EINVAL ;
@@ -5678,7 +5684,7 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,if ((write &FOLL_WRITE ) && !pte_write (pte))return -EINVAL ; - maddr =ioremap_prot (phys_addr,PAGE_ALIGN (len + offset), prot); + maddr =ioremap_prot (phys_addr,PAGE_SIZE , prot);if (!maddr)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1470/2857 mptcp: fix MP_CAPABLE token migration when cloning reqsk
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruide Cao <[email protected]>
[ Upstream commit 2093bc7fa50056fef8620d2b82bcb2e9a0a5575d ]
TCP request migration clones pending request sockets with inet_reqsk_clone(). For MPTCP MP_CAPABLE requests this byte-copies the token_node hlist state into the clone even though the token table still names the original request, and the following warning can be seen:
WARNING: net/mptcp/token.c:364 at mptcp_token_destroy_request+0x2b0/0x330, CPU#2: swapper/2/0 CPU: 2 UID: 0 PID: 0 Comm: swapper/2 Not tainted 7.2.0-rc5-00353-gc27e36054537 #10 PREEMPT(full) RIP: 0010:mptcp_token_destroy_request (net/mptcp/token.c:364 (discriminator 1)) Call Trace: <IRQ> subflow_v4_req_destructor (net/mptcp/subflow.c:694) __reqsk_free (net/ipv4/inet_connection_sock.c:906) reqsk_timer_handler (include/net/request_sock.h:137 net/ipv4/inet_connection_sock.c:1147) call_timer_fn (kernel/time/timer.c:1748)
Move token request ownership from the original request to the clone under the token bucket lock. Make mptcp_token_accept() and mptcp_token_destroy_request() re-check token_node under the same lock and treat an already moved or removed request as a normal race instead of warning. This also keeps token bucket chain_len accounting balanced.
If a passive MP_CAPABLE socket cannot claim the token, destroy the provisional MPTCP socket and let the subflow fall back rather than installing a socket with mismatched token ownership. Mark that path as a passive handshake fallback so MPCapableFallbackACK records the downgrade.
If the speculative clone later loses the inet_ehash_insert() ownership arbitration, the original request may find that its token was already moved and fall back to plain TCP. The clone destructor then releases the token reservation and keeps chain_len balanced. This trades an exceptionally rare fallback for eliminating the warning and persistent accounting drift.
--- net/mptcp/protocol.c | 29 +++++++++++++++---- net/mptcp/protocol.h | 4 ++- net/mptcp/subflow.c | 6 +++- net/mptcp/token.c | 65 ++++++++++++++++++++++++++++++++++++++---- net/mptcp/token_test.c | 4 +-- 5 files changed, 93 insertions(+), 15 deletions(-)
net/mptcp/protocol.c +24 -5
@@ -3372,6 +3372,21 @@ static void mptcp_copy_ip_options(struct sock *newsk, const struct sock *sk)rcu_read_unlock (); } +static void mptcp_sk_clone_destroy (struct sock *nsk) +{ +inet_sk_state_store (nsk,TCP_CLOSE ); +/* inet_csk_prepare_forced_close() clears TCP sock_ops state via +* tcp_sk(), but nsk is an MPTCP master socket; keep the inet-level +* destroy preparation here. +*/ +bh_unlock_sock (nsk); +sock_put (nsk); +sock_set_flag (nsk,SOCK_DEAD ); +this_cpu_inc (*nsk->sk_prot->orphan_count); +inet_sk (nsk)->inet_num =0 ; +inet_csk_destroy_sock (nsk); +} + struct sock *mptcp_sk_clone_init(const struct sock *sk, const struct mptcp_options_received *mp_opt, struct sock *ssk,
@@ -3436,11 +3451,6 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,list_add (&mptcp_subflow_ctx (ssk)->node, &msk->conn_list);sock_hold (ssk); -/* new mpc subflow takes ownership of the newly -* created mptcp socket -*/ -mptcp_token_accept (subflow_req, msk); -/* set msk addresses early to ensure mptcp_pm_get_local_id() * uses the correct data */
@@ -3448,6 +3458,14 @@ struct sock *mptcp_sk_clone_init(const struct sock *sk,mptcp_propagate_sndbuf (nsk, ssk);mptcp_rcv_space_init (msk, ssk); + +if (!mptcp_token_accept (subflow_req, msk)) { +list_del_init (&mptcp_subflow_ctx (ssk)->node); +WRITE_ONCE (msk->first,NULL ); +sock_put (ssk); +mptcp_sk_clone_destroy (nsk); +return NULL ; + }bh_unlock_sock (nsk);/* note: the newly allocated socket refcount is 2 now */
@@ -3977,6 +3995,7 @@ static struct proto mptcp_prot = { .get_port = mptcp_get_port, .forward_alloc_get = mptcp_forward_alloc_get, .sockets_allocated = &mptcp_sockets_allocated, + .orphan_count = &tcp_orphan_count, .memory_allocated = &tcp_memory_allocated, .per_cpu_fw_alloc = &tcp_memory_per_cpu_fw_alloc,
net/mptcp/protocol.h +3 -1
@@ -778,9 +778,11 @@ static inline void mptcp_token_init_request(struct request_sock *req) }int mptcp_token_new_request (struct request_sock *req); +void mptcp_token_move_request (struct request_sock *req, +struct request_sock *new_req);void mptcp_token_destroy_request (struct request_sock *req);int mptcp_token_new_connect (struct sock *sk); -void mptcp_token_accept (struct mptcp_subflow_request_sock *r, +bool mptcp_token_accept (struct mptcp_subflow_request_sock *r,struct mptcp_sock *msk);bool mptcp_token_exists (u32 token);struct mptcp_sock *mptcp_token_get_sock (struct net *net,u32 token);
net/mptcp/subflow.c +5 -1
@@ -81,6 +81,8 @@ void mptcp_subflow_reqsk_clone(struct request_sock *req, } new_subflow_req->msk = msk; + +mptcp_token_move_request (req, new_req); } static void subflow_generate_hmac(u64 key1, u64 key2, u32 nonce1, u32 nonce2,
@@ -811,8 +813,10 @@ static struct sock *subflow_syn_recv_sock(const struct sock *sk,if (ctx->mp_capable) { ctx->conn =mptcp_sk_clone_init (listener->conn, &mp_opt, child, req); -if (!ctx->conn) +if (!ctx->conn) { + fallback = true; goto fallback; + } owner =mptcp_sk (ctx->conn);
net/mptcp/token.c +59 -6
103 lines not on this page · raw message
net/mptcp/token_test.c +2 -2
@@ -91,7 +91,7 @@ static void mptcp_token_test_accept(struct kunit *test)KUNIT_ASSERT_EQ (test,0 ,mptcp_token_new_request ((struct request_sock *)req)); msk->token = req->token; -mptcp_token_accept (req, msk); +KUNIT_EXPECT_TRUE (test,mptcp_token_accept (req, msk));KUNIT_EXPECT_PTR_EQ (test, msk,mptcp_token_get_sock (&init_net, msk->token));/* this is now a no-op */
@@ -114,7 +114,7 @@ static void mptcp_token_test_destroyed(struct kunit *test)KUNIT_ASSERT_EQ (test,0 ,mptcp_token_new_request ((struct request_sock *)req)); msk->token = req->token; -mptcp_token_accept (req, msk); +KUNIT_EXPECT_TRUE (test,mptcp_token_accept (req, msk));/* simulate race on removal */ refcount_set (&sk->sk_refcnt,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1471/2857 irqchip/atmel-aic[5]: Disable interrupts in the irq_pm_shutdown() callbacks
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 0ca21fe111457c843624a835641bb490e704bb2f ]
irq_gc_shutdown() calls the irq_pm_shutdown() callbacks from syscore_shutdown() with interrupts enabled. aic_pm_shutdown() and aic5_pm_shutdown() take the generic chip lock with raw_spin_lock(), and irq_gc_eoi() takes the same lock from the interrupt handler. An interrupt from the chip while the lock is held spins in irq_gc_eoi() and hangs the reboot.
Lockdep reports this on every reboot of a SAM9X75 Curiosity board:
WARNING: inconsistent lock state
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. busybox/101 [HC0[0]:SC0[0]:HE1:SE1] takes:
c1c2b434 (&gc->lock){?.-.}-{2:2}, at: aic5_pm_shutdown+0x34/0xd8 {IN-HARDIRQ-W} state was registered at:
...
irq_gc_eoi+0x28/0x60
handle_fasteoi_irq+0x120/0x214 ...
aic5_pm_shutdown from irq_gc_shutdown+0x4c/0x58 irq_gc_shutdown from syscore_shutdown+0x5c/0x9c syscore_shutdown from kernel_restart+0x34/0x78 kernel_restart from sys_reboot+0x180/0x25c
Use the irqsave guard, as
commit 33517881ede7 ("irqchip/brcmstb-l2: Use _irqsave locking variants in non-interrupt code") did for brcmstb-l2.
--- drivers/irqchip/irq-atmel-aic.c | 5 +++-- drivers/irqchip/irq-atmel-aic5.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/irqchip/irq-atmel-aic.c +3 -2
@@ -126,11 +126,12 @@ static void aic_resume(struct irq_data *d)static void aic_pm_shutdown (struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +unsigned long flags; -irq_gc_lock (gc); +irq_gc_lock_irqsave (gc, flags);irq_reg_writel (gc,0xffffffff ,AT91_AIC_IDCR );irq_reg_writel (gc,0xffffffff ,AT91_AIC_ICCR ); -irq_gc_unlock (gc); +irq_gc_unlock_irqrestore (gc, flags); }#else #define aic_suspend NULL
drivers/irqchip/irq-atmel-aic5.c +3 -2
@@ -224,15 +224,16 @@ static void aic5_pm_shutdown(struct irq_data *d)struct irq_domain_chip_generic *dgc = domain->gc;struct irq_chip_generic *bgc =irq_get_domain_generic_chip (domain,0 );struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); +unsigned long flags;int i; -irq_gc_lock (bgc); +irq_gc_lock_irqsave (bgc, flags);for (i =0 ; i < dgc->irqs_per_chip; i++) {irq_reg_writel (bgc, i + gc->irq_base,AT91_AIC5_SSR );irq_reg_writel (bgc,1 ,AT91_AIC5_IDCR );irq_reg_writel (bgc,1 ,AT91_AIC5_ICCR ); } - irq_gc_unlock(bgc); + irq_gc_unlock_irqrestore(bgc, flags); }#else #define aic5_suspend NULL
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1472/2857 irqchip/imx-intmux: Convert to platform_driver::remove_new() callback
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 984e5c7b8d7bac9efd3818e06dcf1f7aab7701b2 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: b167c1a30e9e ("irqchip/imx-intmux: Fix runtime PM teardown on remove")
--- drivers/irqchip/irq-imx-intmux.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/irqchip/irq-imx-intmux.c +6 -8
@@ -281,7 +281,7 @@ static int imx_intmux_probe(struct platform_device *pdev)return ret; } -static int imx_intmux_remove (struct platform_device *pdev) +static void imx_intmux_remove (struct platform_device *pdev) {struct intmux_data *data =platform_get_drvdata (pdev);int i;
@@ -297,8 +297,6 @@ static int imx_intmux_remove(struct platform_device *pdev) }pm_runtime_disable (&pdev->dev); - -return 0 ; }#ifdef CONFIG_PM
@@ -353,11 +351,11 @@ static const struct of_device_id imx_intmux_id[] = {static struct platform_driver imx_intmux_driver = { .driver = { - .name ="imx-intmux" , - .of_match_table = imx_intmux_id, - .pm = &imx_intmux_pm_ops, + .name ="imx-intmux" , + .of_match_table = imx_intmux_id, + .pm = &imx_intmux_pm_ops, }, - .probe = imx_intmux_probe, - .remove = imx_intmux_remove, + .probe = imx_intmux_probe, + .remove_new = imx_intmux_remove, };builtin_platform_driver (imx_intmux_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1473/2857 irqchip/imx-intmux: Fix runtime PM teardown on remove
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b167c1a30e9e020e4c5e102c7a555943742c024b ]
imx_intmux_probe() enables the IPG clock and then drops its runtime PM reference with pm_runtime_put(). With CONFIG_PM enabled, the runtime suspend callback disables the IPG clock. With CONFIG_PM disabled, the clock remains enabled after probe.
imx_intmux_remove() accesses the CHANIER registers without first making sure that the device is runtime active. The device may therefore be runtime suspended with the IPG clock disabled when these registers are accessed. In addition, the remove path only calls pm_runtime_disable() and does not balance the clock enable when CONFIG_PM is disabled.
Resume the device and acquire a runtime PM reference before accessing the registers. If resume fails, skip the register accesses but still tear down the chained handlers and IRQ domains. Disable runtime PM afterwards, drop the acquired reference without triggering another runtime suspend, and explicitly disable the IPG clock.
This keeps the clock enabled while the hardware registers are accessed and balances the clk_prepare_enable() performed during probe for both CONFIG_PM configurations.
This issue was found by manual code inspection.
--- drivers/irqchip/irq-imx-intmux.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/irqchip/irq-imx-intmux.c +12 -3
@@ -284,12 +284,16 @@ static int imx_intmux_probe(struct platform_device *pdev)static void imx_intmux_remove (struct platform_device *pdev) {struct intmux_data *data =platform_get_drvdata (pdev); -int i; +int i, ret; + + ret =pm_runtime_resume_and_get (&pdev->dev); +if (ret <0 ) +dev_warn (&pdev->dev,"failed to resume device: %d\n" , ret);for (i =0 ; i < data->channum; i++) {/* disable all interrupt sources of this channel */ -writel_relaxed (0 , data->regs +CHANIER (i)); - +if (ret >=0 ) +writel_relaxed (0 , data->regs +CHANIER (i));irq_set_chained_handler_and_data (data->irqchip_data[i].irq,NULL ,NULL );
@@ -297,6 +301,11 @@ static void imx_intmux_remove(struct platform_device *pdev) }pm_runtime_disable (&pdev->dev); +if (ret >=0 ) { +pm_runtime_put_noidle (&pdev->dev); +clk_disable_unprepare (data->ipg_clk); +pm_runtime_set_suspended (&pdev->dev); + } }#ifdef CONFIG_PM
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1474/2857 PCI: rockchip: Drive at 2.5 GT/s, error other speeds
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geraldo Nascimento <[email protected]>
[ Upstream commit 84d08ff902f1ec01177fef1a21a38934927f5aee ]
Configure the core to be driven at 2.5 GT/s Link Speed and ignore any other speed with a warning. Also drop the 5.0 GT/s Link Speed defines from Rockchip PCIe header.
The reason is that Shawn Lin from Rockchip has reiterated that there may be danger of "catastrophic failure" in using their PCIe with 5.0 GT/s speeds.
While Rockchip has done so informally without issuing a proper errata, and the particulars are thus unknown, this may cause data loss or worse.
This change is corroborated by RK3399 official datasheet [1], which states maximum link speed for this platform is 2.5 GT/s.
[1] https://opensource.rock-chips.com/images/d/d7/Rockchip_RK3399_Datasheet_V2.1-20200323.pdf
--- drivers/pci/controller/pcie-rockchip.c | 14 ++++++-------- drivers/pci/controller/pcie-rockchip.h | 3 --- 2 files changed, 6 insertions(+), 11 deletions(-)
drivers/pci/controller/pcie-rockchip.c +6 -8
@@ -65,8 +65,10 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) } rockchip->link_gen =of_pci_get_max_link_speed (node); -if (rockchip->link_gen <0 || rockchip->link_gen >2 ) - rockchip->link_gen =2 ; +if (rockchip->link_gen <0 || rockchip->link_gen >=2 ) { + rockchip->link_gen =1 ; +dev_warn (dev,"invalid max-link-speed, limited to 2.5 GT/s\n" ); + } rockchip->core_rst =devm_reset_control_get_exclusive (dev,"core" );if (IS_ERR (rockchip->core_rst)) {
@@ -236,12 +238,8 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) goto err_exit_phy; } -if (rockchip->link_gen ==2 ) -rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_2 , -PCIE_CLIENT_CONFIG ); -else -rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_1 , -PCIE_CLIENT_CONFIG ); +rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_1 , +PCIE_CLIENT_CONFIG ); regs =PCIE_CLIENT_LINK_TRAIN_ENABLE |PCIE_CLIENT_ARI_ENABLE |PCIE_CLIENT_CONF_LANE_NUM (rockchip->lanes);
drivers/pci/controller/pcie-rockchip.h +0 -3
@@ -37,7 +37,6 @@#define PCIE_CLIENT_MODE_RC HIWORD_UPDATE_BIT(0x0040)#define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0)#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) -#define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080)#define PCIE_CLIENT_LEGACY_INT_CTRL (PCIE_CLIENT_BASE + 0x0c)#define PCIE_CLIENT_INT_IN_ASSERT HIWORD_UPDATE_BIT(0x0002)#define PCIE_CLIENT_INT_IN_DEASSERT HIWORD_UPDATE(0x0002, 0)
@@ -184,8 +183,6 @@ (((x) & PCIE_CLIENT_DEBUG_LTSSM_MASK) == PCIE_CLIENT_DEBUG_LTSSM_L2)#define PCIE_LINK_UP (x) \ (((x) & PCIE_CLIENT_LINK_STATUS_MASK) == PCIE_CLIENT_LINK_STATUS_UP) -#define PCIE_LINK_IS_GEN2 (x) \ - (((x) & PCIE_CORE_PL_CONF_SPEED_MASK) == PCIE_CORE_PL_CONF_SPEED_5G)#define RC_REGION_0_ADDR_TRANS_H 0x00000000#define RC_REGION_0_ADDR_TRANS_L 0x00000000
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1475/2857 drm/amdkfd: fix doorbell allocation race creating duplicate allocations
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit bebad45050945a3d668d6701fb77ae2571c5d44b ]
The check-and-allocate sequence on pdd->qpd.proc_doorbells is lockless at every call site of kfd_alloc_process_doorbells():kfd_get_process_doorbells() (mmap of /dev/kfd), kfd_ioctl_create_queue() and the CRIU restore path each test the pointer under different locking (or none), so two racing threads can both observe NULL and each allocate a doorbell BO and bitmap, orphaning one allocation and handing the two mappings different backing pages.
Move the serialization into kfd_alloc_process_doorbells() itself, using a new per-process-device mutex so all three call sites are covered regardless of their own locking. The device-global kfd->doorbell_mutex is not suitable here: it is acquired under dqm->lock on the kernel-doorbell path (start_cpsch() -> pm_init() -> kq_initialize() -> kfd_get_kernel_doorbell()), so holding it across the sleeping allocations above would create a lock-ordering inversion with dqm->lock via TTM eviction, and it would also serialize doorbell setup of unrelated processes behind a device-wide lock for per-process state.
This issue was discovered by Tencent CodeBuddy Security.
v3 (Felix Kuehling):
- Removed unlocked check in kfd_get_process_doorbell flagged as problematic by Sashiko Bot. Fall back to the locked check inside kfd_alloc_process_doorbells
- Added missing mutex_destroy
v4 (Felix Kuehling):
- Removed unlocked checks around other kfd_alloc_process_doorbells calls
--- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 ++--- drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c | 23 +++++++++++-------- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 5 +++- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 3 +++ .../amd/amdkfd/kfd_process_queue_manager.c | 3 +-- 5 files changed, 24 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +2 -4
@@ -333,8 +333,7 @@ static int kfd_ioctl_create_queue(struct file *filep, struct kfd_process *p, goto err_bind_process; } -if (!pdd->doorbell_index && -kfd_alloc_process_doorbells (dev, &pdd->doorbell_index) <0 ) { +if (kfd_alloc_process_doorbells (dev, pdd) <0 ) { err = -ENOMEM ; goto err_alloc_doorbells; }
@@ -2203,8 +2202,7 @@ static int criu_restore_devices(struct kfd_process *p, goto exit; } -if (!pdd->doorbell_index && -kfd_alloc_process_doorbells (pdd->dev, &pdd->doorbell_index) <0 ) { +if (kfd_alloc_process_doorbells (pdd->dev, pdd) <0 ) { ret = -ENOMEM ; goto exit; }
drivers/gpu/drm/amd/amdkfd/kfd_doorbell.c +14 -9
@@ -277,35 +277,40 @@ uint64_t kfd_get_number_elems(struct kfd_dev *kfd)phys_addr_t kfd_get_process_doorbells (struct kfd_process_device *pdd) { -if (!pdd->doorbell_index) { -int r =kfd_alloc_process_doorbells (pdd->dev, - &pdd->doorbell_index); -if (r <0 ) -return 0 ; - } +if (kfd_alloc_process_doorbells (pdd->dev, pdd) <0 ) +return 0 ;return pdd->dev->doorbell_base + pdd->doorbell_index *kfd_doorbell_process_slice (pdd->dev); } -int kfd_alloc_process_doorbells (struct kfd_dev *kfd,unsigned int *doorbell_index) +int kfd_alloc_process_doorbells (struct kfd_dev *kfd,struct kfd_process_device *pdd) {int r =0 ; +mutex_lock (&pdd->doorbell_mutex); + +/* Another thread may have won the check-and-allocate race */ +if (pdd->doorbell_index) { +mutex_unlock (&pdd->doorbell_mutex); +return 0 ; + } +if (!kfd->shared_resources.enable_mes) r =ida_simple_get (&kfd->doorbell_ida,1 , kfd->max_doorbell_slices,GFP_KERNEL );else r =amdgpu_mes_alloc_process_doorbells ( (struct amdgpu_device *)kfd->adev, - doorbell_index); + &pdd->doorbell_index);if (r >0 ) - *doorbell_index = r; + pdd->doorbell_index = r;if (r <0 )pr_err ("Failed to allocate process doorbells\n" ); +mutex_unlock (&pdd->doorbell_mutex);return r; }
drivers/gpu/drm/amd/amdkfd/kfd_priv.h +4 -1
@@ -712,6 +712,9 @@ struct kfd_process_device {/* per-process-per device QCM data structure */ struct qcm_process_device qpd; +/* Serializes process doorbell allocation for this device */ +struct mutex doorbell_mutex; +/*Apertures*/ uint64_t lds_base;uint64_t lds_limit;
@@ -1017,7 +1020,7 @@ unsigned int kfd_get_doorbell_dw_offset_in_bar(struct kfd_dev *kfd, unsigned int doorbell_id);phys_addr_t kfd_get_process_doorbells (struct kfd_process_device *pdd);int kfd_alloc_process_doorbells (struct kfd_dev *kfd, -unsigned int *doorbell_index); +struct kfd_process_device *pdd);void kfd_free_process_doorbells (struct kfd_dev *kfd,unsigned int doorbell_index);/* GTT Sub-Allocator */
drivers/gpu/drm/amd/amdkfd/kfd_process.c +3 -0
@@ -1065,6 +1065,8 @@ static void kfd_process_destroy_pdds(struct kfd_process *p) pdd->runtime_inuse = false; } +mutex_destroy (&pdd->doorbell_mutex); +kfree (pdd); p->pdds[i] =NULL ; }
@@ -1613,6 +1615,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,memset (pdd->proc_ctx_cpu_ptr,0 ,AMDGPU_MES_PROC_CTX_SIZE ); } +mutex_init (&pdd->doorbell_mutex); p->pdds[p->n_pdds++] = pdd;/* Init idr used for memory handle translation */
drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c +1 -2
@@ -868,8 +868,7 @@ int kfd_criu_restore_queue(struct kfd_process *p, *priv_data_offset += q_extra_data_size; -if (!pdd->doorbell_index && -kfd_alloc_process_doorbells (pdd->dev, &pdd->doorbell_index) <0 ) { +if (kfd_alloc_process_doorbells (pdd->dev, pdd) <0 ) { ret = -ENOMEM ; goto exit; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1476/2857 nilfs2: force clear dirty state when restoring from the shadow map
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit cb6702e63e0a16afd83875294e5ce53becdd1b1f ]
When garbage collection fails, nilfs2 rolls the DAT metadata file's page cache back to a shadow copy taken before GC started. nilfs_clear_dirty_pages() drops the dirty state of the folios in the DAT cache, then nilfs_copy_back_pages() overwrites them with the saved contents and warns if one is still dirty:
/* overwrite existing folio in the destination cache */ WARN_ON(folio_test_dirty(dfolio));
nilfs_clear_dirty_pages() used to clear the dirty state unconditionally, which is safe here because the rollback runs with the log writer stopped, so nothing else can dirty the cache while it runs. The same helper is also used when writeback finds dirty folios after the filesystem has degraded to read-only, where it does run concurrently with the log writer, so commit ca76bb226bf4 ("nilfs2: do not force clear folio if buffer is referenced") made nilfs_clear_folio_dirty() skip a folio if any of its buffer heads is busy. The rollback caller shares that helper, so its clearing step can now return with a folio still dirty.
A DAT folio can hold a busy buffer head without anyone modifying the
folio: nilfs_mdt_read_block() submits read-ahead for the blocks following the one it was asked for and waits only for the first, so the read-ahead buffers are still locked when it returns. With a block size smaller than the page size, a locked read-ahead buffer can share a folio with a block that GC dirtied and keep the whole folio dirty past the clearing step.
Add a force flag to nilfs_clear_dirty_pages() and nilfs_clear_folio_dirty() that skips the busy buffer check, and set it in the two calls from nilfs_mdt_restore_from_shadow_map(). The read-only fallback callers keep passing false, so that commit still protects them and the WARN_ON() is left alone.
--- fs/nilfs2/inode.c | 4 ++-- fs/nilfs2/mdt.c | 6 +++--- fs/nilfs2/page.c | 50 +++++++++++++++++++++++++++-------------------- fs/nilfs2/page.h | 4 ++-- 4 files changed, 36 insertions(+), 28 deletions(-)
fs/nilfs2/inode.c +2 -2
@@ -162,7 +162,7 @@ static int nilfs_writepages(struct address_space *mapping,int err =0 ;if (sb_rdonly (inode->i_sb)) { -nilfs_clear_dirty_pages (mapping); +nilfs_clear_dirty_pages (mapping, false);return -EROFS ; }
@@ -185,7 +185,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)* have dirty pages that try to be flushed in background. * So, here we simply discard this dirty page. */ -nilfs_clear_dirty_page (page); +nilfs_clear_dirty_page (page, false);unlock_page (page);return -EROFS ; }
fs/nilfs2/mdt.c +3 -3
@@ -411,7 +411,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)* have dirty pages that try to be flushed in background. * So, here we simply discard this dirty page. */ -nilfs_clear_dirty_page (page); +nilfs_clear_dirty_page (page, false);unlock_page (page);return -EROFS ; }
@@ -634,10 +634,10 @@ void nilfs_mdt_restore_from_shadow_map(struct inode *inode)if (mi->mi_palloc_cache)nilfs_palloc_clear_cache (inode); -nilfs_clear_dirty_pages (inode->i_mapping); +nilfs_clear_dirty_pages (inode->i_mapping, true);nilfs_copy_back_pages (inode->i_mapping, shadow->inode->i_mapping); -nilfs_clear_dirty_pages (ii->i_assoc_inode->i_mapping); +nilfs_clear_dirty_pages (ii->i_assoc_inode->i_mapping, true);nilfs_copy_back_pages (ii->i_assoc_inode->i_mapping,NILFS_I (shadow->inode)->i_assoc_inode->i_mapping);
fs/nilfs2/page.c +29 -21
81 lines not on this page · raw message
fs/nilfs2/page.h +2 -2
@@ -41,8 +41,8 @@ void nilfs_page_bug(struct page *);int nilfs_copy_dirty_pages (struct address_space *,struct address_space *);void nilfs_copy_back_pages (struct address_space *,struct address_space *); -void nilfs_clear_dirty_page (struct page *page); -void nilfs_clear_dirty_pages (struct address_space *mapping); +void nilfs_clear_dirty_page (struct page *page,bool force); +void nilfs_clear_dirty_pages (struct address_space *mapping,bool force);unsigned int nilfs_page_count_clean_buffers (struct page *,unsigned int ,unsigned int ); unsigned long nilfs_find_uncommitted_extent(struct inode *inode,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1477/2857 IB/hfi1: Shutdown self-rearming timers before freeing
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9d3259e41ccd5016cd2c6d013232b89df6d73011 ]
The HFI1 receive error and synthetic counter timers rearm themselves from their callbacks. Their cleanup paths use timer_delete_sync(), which only waits for a running callback and does not prevent a concurrent or subsequent rearm.
Use timer_shutdown_sync() when releasing these timers. This prevents a callback from enqueueing either timer after cleanup begins, before the containing hfi1_devdata is freed.
Preserve the existing work cancellation and workqueue destruction ordering for synthetic counters.
--- drivers/infiniband/hw/hfi1/chip.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/infiniband/hw/hfi1/chip.c +2 -2
@@ -5575,7 +5575,7 @@ static int init_rcverr(struct hfi1_devdata *dd)static void free_rcverr (struct hfi1_devdata *dd) {if (dd->rcverr_timer.function) -del_timer_sync (&dd->rcverr_timer); +timer_shutdown_sync (&dd->rcverr_timer); }static void handle_rxe_err (struct hfi1_devdata *dd,u32 unused,u64 reg)
@@ -12306,7 +12306,7 @@ static void free_cntrs(struct hfi1_devdata *dd)int i;if (dd->synth_stats_timer.function) -del_timer_sync (&dd->synth_stats_timer); +timer_shutdown_sync (&dd->synth_stats_timer);cancel_work_sync (&dd->update_cntr_work); ppd = (struct hfi1_pportdata *)(dd +1 );for (i =0 ; i < dd->num_pports; i++, ppd++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1478/2857 wifi: brcmfmac: cfg80211: Report port_authorized for 4-way HS offload
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janne Grunau <[email protected]>
[ Upstream commit 6fff9de5c5b425817588eeed42bd56d665751c13 ]
Since commit 416386060 ("Mark authorization completed on driver indication during 4-way HS offload") [0] wpa_supplicant expects NL80211_CMD_PORT_AUTHORIZED to complete the authentication when the driver supports 4-way handshake offload.
This was apparently never tested with the upstream brcmfmac driver as it does not report this. This broke authentication on Apple silicon devices (BRCM4378, BRMC4387, BRMC4388) and other devices when wpa_supplicant 2.11 was released [1]. This was initially dealt with by reverting the commit in Fedora [2] and other Linux distributions.
Instead of carrying the revert over to wpa_supplicant 2.12 add the expected NL80211_CMD_PORT_AUTHORIZED when the connection is established.
The "Fixes:" tag is not fully accurate as this has only became an issue after userspace changes years after the change. Since the change is expected to be required in all active stable branches for wpa_supplicant 2.11 / 2.12 compatibility it is helpful even though BRCMF_PROFILE_FWSUP_SAE did not exists then.
--- .../net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +7 -0
@@ -6027,6 +6027,7 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg,struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;struct brcmf_cfg80211_connect_info *conn_info =cfg_to_conn (cfg);struct cfg80211_connect_resp_params conn_params; +bool authorized;brcmf_dbg (TRACE ,"Enter\n" );
@@ -6047,7 +6048,13 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg, conn_params.req_ie_len = conn_info->req_ie_len; conn_params.resp_ie = conn_info->resp_ie; conn_params.resp_ie_len = conn_info->resp_ie_len; + authorized = completed && + (profile->use_fwsup ==BRCMF_PROFILE_FWSUP_SAE || + profile->use_fwsup ==BRCMF_PROFILE_FWSUP_PSK );cfg80211_connect_done (ndev, &conn_params,GFP_KERNEL ); +if (authorized) +cfg80211_port_authorized (ndev, profile->bssid,NULL ,0 , +GFP_KERNEL );brcmf_dbg (CONN ,"Report connect result - connection %s\n" , completed ?"succeeded" :"failed" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1479/2857 mptcp: fix subflow bitfield misuse
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 7538fa33bb2f66b8b809ff39d58308be48e197a0 ]
The subflow status bitfield is protected by the subflow socket lock, with one notable exception: the close_event_done bit is actually under the msk socket lock protection.
As reported by Clashiko [1], flipping the latter bit may corrupt other entries in the same bitfield.
Move the close_event_done outside the bitfield, in a 32bit hole.
--- net/mptcp/protocol.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/mptcp/protocol.h +4 -2
@@ -492,11 +492,13 @@ struct mptcp_subflow_context { disposable : 1, /* ctx can be free at ulp release time */ stale : 1, /* unable to snd/rcv data, do not use for xmit */ valid_csum_seen : 1, /* at least one csum validated */ - close_event_done : 1, /* has done the post-closed part */ resetting : 1, /* subflow is resetting */ - __unused : 8; + __unused : 9;enum mptcp_data_avail data_avail;bool pm_listener;/* a listener managed by the kernel PM? */ +bool close_event_done;/* has done the post-closed part, +* protected by msk socket lock +*/ u32 remote_nonce;u64 thmac;u32 local_nonce;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1480/2857 serial: 8250_exar: Clear interrupts before registering handler
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 5bc430afeba5d5101765c1f1a4437a90218b00b9 ]
While now there is no issue if IRQ is fired before we clearing the interrupts as the handler does the same, but strictly speaking it might be problematic if IRQ handler wants to do something more.
Move clearing interrupt code to be called before registering the IRQ handler.
Stable-dep-of: 33d337816e00 ("serial: 8250_exar: store the GPIO platform device in struct exar8250")
--- drivers/tty/serial/8250/8250_exar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/tty/serial/8250/8250_exar.c +3 -3
@@ -718,14 +718,14 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) uart.port.irq =pci_irq_vector (pcidev,0 ); uart.port.dev = &pcidev->dev; +/* Clear interrupts */ +exar_misc_clear (priv); + rc =devm_request_irq (&pcidev->dev, uart.port.irq, exar_misc_handler,IRQF_SHARED ,"exar_uart" , priv);if (rc)return rc; -/* Clear interrupts */ -exar_misc_clear (priv); -for (i =0 ; i < nr_ports && i < maxnr; i++) { rc = board->setup (priv, pcidev, &uart, i);if (rc) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1481/2857 serial: exar: add optional board_init function
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parker Newman <[email protected]>
[ Upstream commit 393b520a99b21d9ec6d4bb32e7c05bbb4f6dc777 ]
Add an optional "board_init()" function pointer to struct exar8250_board which is called once during probe prior to setting up the ports. It will be used in subsequent patches of this series.
Stable-dep-of: 33d337816e00 ("serial: 8250_exar: store the GPIO platform device in struct exar8250")
--- drivers/tty/serial/8250/8250_exar.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_exar.c +12 -1
@@ -177,12 +177,14 @@ struct exar8250_platform {* struct exar8250_board - board information * @num_ports: number of serial ports * @reg_shift: describes UART register mapping in PCI memory -* @setup: quirk run at ->probe() stage +* @board_init: quirk run once at ->probe() stage before setting up ports +* @setup: quirk run at ->probe() stage for each port * @exit: quirk run at ->remove() stage */ struct exar8250_board {unsigned int num_ports;unsigned int reg_shift; +int (*board_init)(struct exar8250 *priv,struct pci_dev *pcidev);int (*setup)(struct exar8250 *,struct pci_dev *,struct uart_8250_port *,int );void (*exit)(struct pci_dev *pcidev);
@@ -726,6 +728,15 @@ exar_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)if (rc)return rc; +if (board->board_init) { + rc = board->board_init (priv, pcidev); +if (rc) { +dev_err_probe (&pcidev->dev, rc, +"failed to init serial board\n" ); +return rc; + } + } +for (i =0 ; i < nr_ports && i < maxnr; i++) { rc = board->setup (priv, pcidev, &uart, i);if (rc) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1482/2857 serial: exar: fix checkpach warnings
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parker Newman <[email protected]>
[ Upstream commit c6795fbffc4547b40933ec368200bd4926a41b44 ]
-Fix several "missing identifier name" warnings from checkpatch in struct exar8250_platform and struct exar8250_board. Example:
WARNING: function definition argument <arg> should also have an identifier name
- Fix space before tab warning from checkpatch:
WARNING: please, no space before tabs
+ * 0^I^I2 ^IMode bit 0$
Stable-dep-of: 33d337816e00 ("serial: 8250_exar: store the GPIO platform device in struct exar8250")
--- drivers/tty/serial/8250/8250_exar.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/tty/serial/8250/8250_exar.c +5 -5
@@ -133,7 +133,7 @@* * MPIO Port Function * ---- ---- -------- -* 0 2 Mode bit 0 +* 0 2 Mode bit 0 * 1 2 Mode bit 1 * 2 2 Terminate bus * 3 - <reserved>
@@ -169,8 +169,8 @@ struct exar8250_platform {int (*rs485_config)(struct uart_port *port,struct ktermios *termios,struct serial_rs485 *rs485);const struct serial_rs485 *rs485_supported; -int (*register_gpio)(struct pci_dev *,struct uart_8250_port *); -void (*unregister_gpio)(struct uart_8250_port *); +int (*register_gpio)(struct pci_dev *pcidev,struct uart_8250_port *port); +void (*unregister_gpio)(struct uart_8250_port *port); };/**
@@ -185,8 +185,8 @@ struct exar8250_board {unsigned int num_ports;unsigned int reg_shift;int (*board_init)(struct exar8250 *priv,struct pci_dev *pcidev); -int (*setup)(struct exar8250 *,struct pci_dev *, -struct uart_8250_port *,int ); +int (*setup)(struct exar8250 *priv,struct pci_dev *pcidev, +struct uart_8250_port *port,int idx);void (*exit)(struct pci_dev *pcidev); };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1483/2857 serial: 8250_exar: store the GPIO platform device in struct exar8250
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 33d337816e00994daaf670243186d9e537ee090d ]
The GPIO platform device is registered via platform->register_gpio() when port 0 is being set up. It is stored to port->port.private_data of the on-stack uart template (and from there it is copied into every registered port). pci_xr17v35x_exit() then fetches it back by serial8250_get_port(priv->line[0]).
But port 0 does not have to exist at that point. If serial8250_register_8250_port() fails for port 0, priv->line[0] holds a negative error code. The probe still succeeds (it only breaks the loop), so on unbind, priv->line[0] (a negative value) is passed to serial8250_get_port(). The GPIO device is never unregistered and a bogus port is accessed.
The same problem would also occur after the planned conversion of serial8250_register_8250_port() to return a uart port instead of a line. As Sashiko pointed out in that case:
If board->setup() fails for the first port (i=0) in exar_pci_probe(), priv->uport[0] remains NULL. If serial8250_register_8250_port() fails, it returns an ERR_PTR. In either case, the loop breaks and probe returns success. When the device is later unbound, pci_xr17v35x_exit() unconditionally passes priv->uport[0] to platform->unregister_gpio(), which will dereference it without checking for validity.
The GPIO device belongs to the PCI device, not to any particular port. So store it in a new struct exar8250::gpio member. Pass priv to both ->register_gpio() and ->unregister_gpio(), so that pci_xr17v35x_exit() does not need to look up any port at all.
--- drivers/tty/serial/8250/8250_exar.c | 36 ++++++++++++++--------------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/tty/serial/8250/8250_exar.c +18 -18
@@ -169,8 +169,9 @@ struct exar8250_platform {int (*rs485_config)(struct uart_port *port,struct ktermios *termios,struct serial_rs485 *rs485);const struct serial_rs485 *rs485_supported; -int (*register_gpio)(struct pci_dev *pcidev,struct uart_8250_port *port); -void (*unregister_gpio)(struct uart_8250_port *port); +int (*register_gpio)(struct exar8250 *priv,struct pci_dev *pcidev, +struct uart_8250_port *port); +void (*unregister_gpio)(struct exar8250 *priv); };/**
@@ -194,6 +195,7 @@ struct exar8250 {unsigned int nr;struct exar8250_board *board;void __iomem *virt; +struct platform_device *gpio;int line[]; };
@@ -448,22 +450,21 @@ static const struct software_node exar_gpio_node = { .properties = exar_gpio_properties, }; -static int xr17v35x_register_gpio (struct pci_dev *pcidev,struct uart_8250_port *port) +static int xr17v35x_register_gpio (struct exar8250 *priv,struct pci_dev *pcidev, +struct uart_8250_port *port) {if (pcidev->vendor ==PCI_VENDOR_ID_EXAR ) - port->port.private_data = -__xr17v35x_register_gpio (pcidev, &exar_gpio_node); + priv->gpio =__xr17v35x_register_gpio (pcidev, &exar_gpio_node);return 0 ; } -static void xr17v35x_unregister_gpio (struct uart_8250_port *port) +static void xr17v35x_unregister_gpio (struct exar8250 *priv) { -if (!port->port.private_data) -return ; - -__xr17v35x_unregister_gpio (port->port.private_data); - port->port.private_data =NULL ; +if (priv->gpio) { +__xr17v35x_unregister_gpio (priv->gpio); + priv->gpio =NULL ; + } } static int generic_rs485_config(struct uart_port *port, struct ktermios *termios,
@@ -546,8 +547,9 @@ static const struct software_node iot2040_gpio_node = { .properties = iot2040_gpio_properties, }; -static int iot2040_register_gpio (struct pci_dev *pcidev, -struct uart_8250_port *port) +static int iot2040_register_gpio (struct exar8250 *priv, +struct pci_dev *pcidev, +struct uart_8250_port *port) {u8 __iomem *p = port->port.membase;
@@ -556,8 +558,7 @@ static int iot2040_register_gpio(struct pci_dev *pcidev,writeb (IOT2040_UARTS_ENABLE , p +UART_EXAR_MPIOLVL_15_8 );writeb (IOT2040_UARTS_GPIO_HI_MODE , p +UART_EXAR_MPIOSEL_15_8 ); - port->port.private_data = -__xr17v35x_register_gpio (pcidev, &iot2040_gpio_node); + priv->gpio =__xr17v35x_register_gpio (pcidev, &iot2040_gpio_node);return 0 ; }
@@ -631,7 +632,7 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,/* Setup Multipurpose Input/Output pins. */ setup_gpio (pcidev, p); - ret = platform->register_gpio (pcidev, port); + ret = platform->register_gpio (priv, pcidev, port); }return ret;
@@ -641,9 +642,8 @@ static void pci_xr17v35x_exit(struct pci_dev *pcidev) {const struct exar8250_platform *platform =exar_get_platform ();struct exar8250 *priv =pci_get_drvdata (pcidev); -struct uart_8250_port *port =serial8250_get_port (priv->line[0 ]); - platform->unregister_gpio (port); + platform->unregister_gpio (priv); }static inline void exar_misc_clear (struct exar8250 *priv)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1484/2857 f2fs: bound the SIT/NAT bitmaps by the checkpoint pack
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixuan Li <[email protected]>
[ Upstream commit 080833a32fd5dc10b3acf2fa9af9b3213e6cb617 ]
sit_ver_bitmap_bytesize and nat_ver_bitmap_bytesize are used as memcpy lengths into and out of sbi->ckpt, which is sized from cp_payload alone, and nothing compares either length against that allocation.
sanity_check_ckpt() has checked these two fields since c77ec61ca0a4, which added them after a crafted image overran build_sit_info(). That check ties each length to a segment count; it never compares either against the allocation, which is the half this adds.
Mounting over-reads in build_sit_info() and build_node_manager(), and the first checkpoint writes the same lengths back through the same pointers, so the over-read's contents reach the on-disk checkpoint. An unmount is enough; the filesystem does not have to be used.
Bound both ends the way __bitmap_ptr() lays them out. The three branches differ, so a single sum of the two lengths would still admit a small overflow when cp_payload is non-zero.
--- fs/f2fs/super.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/f2fs/super.c +24 -0
@@ -3553,6 +3553,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)block_t avail_node_count, valid_node_count;unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks;unsigned int sit_blk_cnt; +unsigned long long ckpt_size, sit_end, nat_end;int i, j; total =le32_to_cpu (raw_super->segment_count);
@@ -3684,6 +3685,29 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)return 1 ; } +/* +* Nothing above ties the bitmap lengths to sbi->ckpt, which is +* (1 + cp_payload) blocks. Bound both ends the way __bitmap_ptr() +* lays them out. +*/ + ckpt_size = (unsigned long long )(cp_payload +1 ) *F2FS_BLKSIZE ; +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG )) { + nat_end =CP_MIN_CHKSUM_OFFSET +sizeof (__le32) + nat_bitmap_size; + sit_end = nat_end + sit_bitmap_size; + }else if (cp_payload >0 ) { + nat_end =CP_MIN_CHKSUM_OFFSET + nat_bitmap_size; + sit_end =F2FS_BLKSIZE + sit_bitmap_size; + }else { + sit_end =CP_MIN_CHKSUM_OFFSET + sit_bitmap_size; + nat_end = sit_end + nat_bitmap_size; + } + +if (sit_end > ckpt_size || nat_end > ckpt_size) { +f2fs_err (sbi,"Bitmaps do not fit the checkpoint pack: sit ends at %llu, nat at %llu, pack is %llu bytes" , + sit_end, nat_end, ckpt_size); +return 1 ; + } +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG ) &&le32_to_cpu (ckpt->checksum_offset) !=CP_MIN_CHKSUM_OFFSET ) { f2fs_warn(sbi, "using deprecated layout of large_nat_bitmap, "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1485/2857 f2fs: fix to use bio_in_atomic() in f2fs_read_end_io()
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chao Yu <[email protected]>
[ Upstream commit a605d5d71a6d280c43c7ede9778dda63fb5c3f22 ]
f2fs_read_end_io() uses "in_task() && !irqs_disabled()" to decide whether it is safe to sleep, the result is passed down as @in_task to:
- f2fs_put_dic() -> f2fs_free_dic() -> f2fs_release_decomp_mem() -> vm_unmap_ram(), which may sleep.
- f2fs_end_read_compressed_page() -> f2fs_cache_compressed_page() -> f2fs_grab_cache() -> f2fs_lock_cache(), which may sleep in wait_on_bit_lock().
However, the check still treats below task contexts as sleepable:
- with spinlock held via spin_lock(), i.e. preempt count != 0 while irqs are enabled.
- with BH disabled via local_bh_disable().
- inside an RCU read lock on kernels with CONFIG_PREEMPTION.
- with any spinlock held on kernels without CONFIG_PREEMPT_COUNT.
So the "sleeping function called from invalid context" issue fixed by commit 08a7efc5b02a ("f2fs: vm_unmap_ram() may be called from an invalid context") can still be triggered.
The block layer provides bio_in_atomic() for exactly this purpose, it checks rcu_preempt_depth() and preemptible(), and conservatively returns true if CONFIG_PREEMPT_COUNT is disabled, let's use it instead. The difference is as below:
old: intask = in_task() && !irqs_disabled()
new: intask = !bio_in_atomic()
Context | old intask | new intask
-------------------------------------+----------------+----------------
Hard IRQ / softirq | false | false IRQs disabled | false | false spin_lock() held, IRQs enabled | true (wrong) | false BH disabled by local_bh_disable() | true (wrong) | false RCU read lock (CONFIG_PREEMPTION) | true (wrong) | false Spinlock held, w/o PREEMPT_COUNT | true (wrong) | false
Note that on kernels without CONFIG_PREEMPT_COUNT, bio_in_atomic() always returns true, so dic freeing will always be offloaded to sbi->wq, and compressed pages will not be cached in f2fs_read_end_io(); this is the price of correctness, since there is no way to tell whether the current context can sleep.
--- fs/f2fs/data.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/f2fs/data.c +2 -1
@@ -273,7 +273,8 @@ static void f2fs_read_end_io(struct bio *bio) {struct f2fs_sb_info *sbi =F2FS_P_SB (bio_first_page_all (bio));struct bio_post_read_ctx *ctx; -bool intask =in_task () && !irqs_disabled (); +bool intask = !(IS_ENABLED (CONFIG_PREEMPTION ) &&rcu_preempt_depth ()) && +IS_ENABLED (CONFIG_PREEMPT_COUNT ) &&preemptible ();iostat_update_and_unbind_ctx (bio,0 ); ctx = bio->bi_private;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1486/2857 scsi: ufs: core: Add a helper for clearing hba->outstanding_reqs
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <[email protected]>
[ Upstream commit 22d14117ec1845a81acb3a5c4be325f7e8332f70 ]
ufshcd_poll() and ufshcd_abort() each have their own copy of the code that clears bits in hba->outstanding_reqs under hba->outstanding_lock.
Move that code into ufshcd_clear_outstanding_reqs() and its locked variant __ufshcd_clear_outstanding_reqs(), and use them in both functions. No functional change.
--- drivers/ufs/core/ufshcd.c | 48 +++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-)
drivers/ufs/core/ufshcd.c +36 -12
@@ -5435,6 +5435,37 @@ static void ufshcd_clear_polled(struct ufs_hba *hba, } } +/* +* Return a bitmask of the transfer requests cleared from +* @hba->outstanding_reqs. +*/ +static unsigned long __ufshcd_clear_outstanding_reqs (struct ufs_hba *hba, +unsigned long mask, +bool from_irq) + __must_hold(&hba->outstanding_lock) +{ +unsigned long completed_reqs = mask & hba->outstanding_reqs; + +if (from_irq) { +/* Do not complete polled requests from interrupt context. */ +ufshcd_clear_polled (hba, &completed_reqs); + } + hba->outstanding_reqs &= ~completed_reqs; + +return completed_reqs; +} + +/* +* Return a bitmask of the transfer requests cleared from +* @hba->outstanding_reqs. +*/ +static unsigned long ufshcd_clear_outstanding_reqs (struct ufs_hba *hba, +unsigned long mask) +{ +guard (spinlock_irqsave)(&hba->outstanding_lock); +return __ufshcd_clear_outstanding_reqs (hba, mask, false); +} +/* * Returns > 0 if one or more commands have been completed or 0 if no * requests have been completed.
@@ -5444,15 +5475,13 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)struct ufs_hba *hba =shost_priv (shost);unsigned long completed_reqs, flags;u32 tr_doorbell; +bool from_irq;spin_lock_irqsave (&hba->outstanding_lock, flags); tr_doorbell =ufshcd_readl (hba,REG_UTP_TRANSFER_REQ_DOOR_BELL ); - completed_reqs = ~tr_doorbell & hba->outstanding_reqs; -if (queue_num ==UFSHCD_POLL_FROM_INTERRUPT_CONTEXT ) { -/* Do not complete polled requests from interrupt context. */ -ufshcd_clear_polled (hba, &completed_reqs); - } - hba->outstanding_reqs &= ~completed_reqs; + from_irq = queue_num ==UFSHCD_POLL_FROM_INTERRUPT_CONTEXT ; + completed_reqs =__ufshcd_clear_outstanding_reqs (hba, ~tr_doorbell, + from_irq);spin_unlock_irqrestore (&hba->outstanding_lock, flags);if (completed_reqs)
@@ -7251,7 +7280,6 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)struct ufshcd_lrb *lrbp = &hba->lrb[tag];unsigned long flags;int err =FAILED ; -bool outstanding;u32 reg;WARN_ONCE (tag <0 ,"Invalid tag %d\n" , tag);
@@ -7333,11 +7361,7 @@ static int ufshcd_abort(struct scsi_cmnd *cmd)* Clear the corresponding bit from outstanding_reqs since the command * has been aborted successfully. */ -spin_lock_irqsave (&hba->outstanding_lock, flags); - outstanding =__test_and_clear_bit (tag, &hba->outstanding_reqs); -spin_unlock_irqrestore (&hba->outstanding_lock, flags); - -if (outstanding) +if (ufshcd_clear_outstanding_reqs (hba,BIT (tag)))ufshcd_release_scsi_cmd (hba, lrbp); err =SUCCESS ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1487/2857 fuse: dont launder folios of a bad inode
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joanne Koong <[email protected]>
[ Upstream commit 01d0f3d294af126f517d92c11e100525537f8be4 ]
fuse_flush() and fuse_writepages() reject writing back dirty data for any inode that has been marked bad, but fuse_launder_folio() doesn't.
This can cause the following warning in fuse_write_file_get() to trigger, as reported by syzbot:
WARNING: fs/fuse/file.c:2043 at fuse_write_file_get fs/fuse/file.c:2043 [inline]
WARNING: fs/fuse/file.c:2043 at fuse_iomap_writeback_range+0x7c8/0x18f0 fs/fuse/file.c:2227
Call Trace:
iomap_writeback_folio+0x1526/0x2490 fs/iomap/buffered-io.c:2022
fuse_launder_folio+0x17b/0x240 fs/fuse/file.c:2331
folio_unmap_invalidate+0x4cd/0x830 mm/truncate.c:634
invalidate_inode_pages2_range+0x629/0xb30 mm/truncate.c:726
fuse_open+0x5a6/0x770 fs/fuse/file.c:297This can be hit on a writeback cache mount:
1) a writeable file is open and a buffered write dirties some pages
2) another thread opens the same file read-only. fuse_open() passes the bad inode check and sends OPEN to the server.
3) a SETATTR reply with the wrong file type marks the inode bad
4) the writeable file is closed. Flush and release skip writeback because the inode is bad. The pages stay dirty but the file gets removed from write_files.
5) server replies to the OPEN. The reply has no FOPEN_KEEP_CACHE, so fuse_open() calls invalidate_inode_pages2().
6) the invalidation finds the dirty pages and calls fuse_launder_folio(), which finds no wriable file and hits the WARN_ON in fuse_write_file_get().
Instead of trying to write back dirty data for the bad inode, fuse_launder_folio() should return -EIO.
--- fs/fuse/file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/fuse/file.c +4 -0
@@ -2438,6 +2438,10 @@ static int fuse_write_end(struct file *file, struct address_space *mapping,static int fuse_launder_folio (struct folio *folio) {int err =0 ; + +if (fuse_is_bad (folio->mapping->host)) +return -EIO ; +if (folio_clear_dirty_for_io (folio)) {struct inode *inode = folio->mapping->host;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1488/2857 block: amiflop: synchronize flush timer before track flush
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9690943353cec1690a715e000ba6a74e5139f530 ]
The amiflop track buffer is shared with the timer callback. timer_delete() does not wait for an in-flight callback, and that callback can rearm itself when it cannot acquire the floppy controller. A synchronous track flush can therefore race with the callback.
Stop the timer before synchronous track writes and use timer_delete_sync() to wait for any callback already running. Keep callback rearming disabled until the write is complete. Apply this to the FDFMTTRK path as well.
FDFLUSH, FDFMTTRK and close-time flushes run outside the blk-mq request callback. Freeze their queues so an in-flight request cannot change the shared track buffer while it is encoded and written. Restart the timer if a track remains dirty after a failed flush.
--- drivers/block/amiflop.c | 69 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-)
drivers/block/amiflop.c +61 -8
@@ -264,6 +264,8 @@ static struct fd_data_type data_types[] = {static struct amiga_floppy_struct unit[FD_MAX_UNITS ];static struct timer_list flush_track_timer[FD_MAX_UNITS ]; +static DEFINE_SPINLOCK (flush_track_timer_lock); +static bool flush_track_timer_stopped[FD_MAX_UNITS ];static struct timer_list post_write_timer;static unsigned long post_write_timer_drive;static struct timer_list motor_on_timer;
@@ -1369,11 +1371,22 @@ static void flush_track_callback(struct timer_list *timer)sizeof (flush_track_timer[0 ]); nr&=3 ; +spin_lock (&flush_track_timer_lock); +if (flush_track_timer_stopped[nr]) { +spin_unlock (&flush_track_timer_lock); +return ; + } +spin_unlock (&flush_track_timer_lock); + writefromint =1 ;if (!try_fdc (nr)) {/* we might block in an interrupt, so try again later */ - flush_track_timer[nr].expires = jiffies +1 ; -add_timer (flush_track_timer + nr); +spin_lock (&flush_track_timer_lock); +if (!flush_track_timer_stopped[nr]) { + flush_track_timer[nr].expires = jiffies +1 ; +add_timer (flush_track_timer + nr); + } +spin_unlock (&flush_track_timer_lock);return ; }get_fdc (nr);
@@ -1420,6 +1433,35 @@ static int non_int_flush_track (unsigned long nr)return 1 ; } +static void flush_track_timer_stop (unsigned int drive) +{ +unsigned long flags; + +spin_lock_irqsave (&flush_track_timer_lock, flags); + flush_track_timer_stopped[drive] = true; +spin_unlock_irqrestore (&flush_track_timer_lock, flags); + +timer_delete_sync (flush_track_timer + drive); +} + +static void flush_track_timer_start (unsigned int drive) +{ +unsigned long flags; + +spin_lock_irqsave (&flush_track_timer_lock, flags); + flush_track_timer_stopped[drive] = false; +if (unit[drive].dirty) +mod_timer (flush_track_timer + drive, jiffies +1 ); +spin_unlock_irqrestore (&flush_track_timer_lock, flags); +} + +static void flush_track_timer_sync (unsigned int drive) +{ +flush_track_timer_stop (drive); +non_int_flush_track (drive); +flush_track_timer_start (drive); +} +static int get_track (int drive,int track) {int error, errcnt;
@@ -1434,8 +1476,7 @@ static int get_track(int drive, int track) }if (unit[drive].dirty ==1 ) { -del_timer (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive); } errcnt =0 ;while (errcnt <MAX_ERRORS ) {
@@ -1562,6 +1603,12 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,case FDFMTTRK :if (param < p->type->tracks * p->type->heads) { +flush_track_timer_stop (drive); +if (unit[drive].dirty ==1 && + !non_int_flush_track (drive)) { +flush_track_timer_start (drive); +return -EIO ; + }get_fdc (drive);if (fd_seek (drive,param) !=0 ){ memset(p->trackbuf, FD_FILL_BYTE,
@@ -1570,6 +1617,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, }floppy_off (drive);rel_fdc (); +flush_track_timer_start (drive); }else return -EINVAL ;
@@ -1591,8 +1639,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,case FDDEFPRM :return -EINVAL ;case FDFLUSH :/* unconditionally, even if not needed */ -del_timer (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive);break ;#ifdef RAW_IOCTL case IOCTL_RAW_TRACK :
@@ -1611,9 +1658,14 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) { int ret; +bool freeze_queue = cmd ==FDFMTTRK || cmd ==FDFLUSH ;mutex_lock (&amiflop_mutex); +if (freeze_queue) +blk_mq_freeze_queue (bdev->bd_disk->queue); ret =fd_locked_ioctl (bdev, mode, cmd, param); +if (freeze_queue) +blk_mq_unfreeze_queue (bdev->bd_disk->queue);mutex_unlock (&amiflop_mutex);return ret;
@@ -1715,9 +1767,9 @@ static void floppy_release(struct gendisk *disk, fmode_t mode)int drive = p - unit;mutex_lock (&amiflop_mutex); +blk_mq_freeze_queue (disk->queue);if (unit[drive].dirty ==1 ) { -del_timer (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive); }if (!fd_ref[drive]--) {
@@ -1727,6 +1779,7 @@ static void floppy_release(struct gendisk *disk, fmode_t mode)#ifdef MODULE floppy_off (drive);#endif +blk_mq_unfreeze_queue (disk->queue);mutex_unlock (&amiflop_mutex); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1489/2857 leds: ktd2692: Pass context to regulator cleanup
In reply to Greg Kroah-Hartman6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit c73e9f04445f361d5f19ca2edfde742ce18348ef ]
regulator_disable_action() retrieves the driver context from device driver data. However, ktd2692_parse_dt() registers the action before ktd2692_probe() stores the context with platform_set_drvdata().
If devm_add_action_or_reset() cannot allocate the action, it invokes the callback immediately. A later probe failure also invokes it during managed-resource unwinding. Both paths dereference a NULL context.
Pass the already allocated context directly to the action and retain the device pointer in it for error reporting. The context is allocated before the action is registered, so reverse-order devres unwinding keeps it alive through the callback.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/leds/flash/leds-ktd2692.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/leds/flash/leds-ktd2692.c +6 -4
@@ -72,6 +72,8 @@ struct ktd2692_led_config_data { };struct ktd2692_context { +struct device *dev; +/* Related LED Flash class device */ struct led_classdev_flash fled_cdev;
@@ -258,13 +260,12 @@ static void ktd2692_setup(struct ktd2692_context *led)static void regulator_disable_action (void *_data) { -struct device *dev = _data; -struct ktd2692_context *led =dev_get_drvdata (dev); +struct ktd2692_context *led = _data;int ret; ret =regulator_disable (led->regulator);if (ret) -dev_err (dev,"Failed to disable supply: %d\n" , ret); +dev_err (led->dev,"Failed to disable supply: %d\n" , ret); } static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
@@ -296,7 +297,7 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,dev_err (dev,"Failed to enable supply: %d\n" , ret); }else { ret =devm_add_action_or_reset (dev, - regulator_disable_action, dev); + regulator_disable_action, led);if (ret)return ret; }
@@ -354,6 +355,7 @@ static int ktd2692_probe(struct platform_device *pdev)if (!led)return -ENOMEM ; + led->dev = &pdev->dev; fled_cdev = &led->fled_cdev; led_cdev = &fled_cdev->led_cdev;
Signature · 1 line
2.53.0