6.12.119-rc1 review
Subsystems (3)
Greg Kroah-Hartman
maintainerPATCH 992/1756 ALSA: usb-audio: Check mixer matrix size for UAC2/3 at parsing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 22185ffd7b31885d03fdeb20055a8707779a70f9 ]
The matrix of input/output channels specified in a UAC2/3 mixer unit must fit to the upper limit 256. Add a sanity check and returns an error if an invalid size is detected.
Stable-dep-of: c01fb2ed90c0 ("ALSA: usb-audio: Fix invalid UAC2/3 mixer unit matrix evaluation")
--- sound/usb/mixer.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
sound/usb/mixer.c +10 -0
@@ -2284,6 +2284,16 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, num_outs = err; input_pins = desc->bNrInPins; +if (state->mixer->protocol ==UAC_VERSION_2 || + state->mixer->protocol ==UAC_VERSION_3 ) { +if (input_pins * num_outs >256 ) { +usb_audio_err (state->chip, +"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , + unitid, input_pins, num_outs); +return -EINVAL ; + } + } + num_ins =0 ; ich =0 ;for (pin =0 ; pin < input_pins; pin++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 993/1756 ALSA: usb-audio: Fix invalid UAC2/3 mixer unit matrix evaluation
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit c01fb2ed90c0770560ea9cc1644f205956b26a70 ]
The bitmap matrix in the mixer unit descriptor for UAC2 and UAC3 has rather the size of input-pins x output-pins, while the current USB-audio driver code wrongly assumes the UAC1 bitmap matrix size, which is input-channels x output-pins. That is, when input pins have multiple channels, the column size differs and it leads to the accesses at a wrong position.
This patch corrects the access of the bitmap matrix for UAC2/UAC3. For making the code cleaner, split the parser to UAC1 and UAC2/3, too.
--- sound/usb/mixer.c | 112 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 34 deletions(-)
sound/usb/mixer.c +78 -34
@@ -2180,7 +2180,7 @@ static bool mixer_bitmap_overflow(struct uac_mixer_unit_descriptor *desc,*/ static void build_mixer_unit_ctl (struct mixer_build *state,struct uac_mixer_unit_descriptor *desc, -int in_pin,int in_ch,int num_outs, +int in_ch,int num_outs,int unitid,struct usb_audio_term *iterm) {struct usb_mixer_elem_info *cval;
@@ -2265,34 +2265,13 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,/* * parse a mixer unit */ -static int parse_audio_mixer_unit (struct mixer_build *state,int unitid, -void *raw_desc) +/* UAC1 mixer unit */ +static int parse_audio_mixer_unit_v1 (struct mixer_build *state,int unitid, +int input_pins,int num_outs, +struct uac_mixer_unit_descriptor *desc) { -struct uac_mixer_unit_descriptor *desc = raw_desc;struct usb_audio_term iterm; -int input_pins, num_ins, num_outs; -int pin, ich, err; - - err =uac_mixer_unit_get_channels (state, desc); -if (err <0 ) { -usb_audio_err (state->chip, -"invalid MIXER UNIT descriptor %d\n" , - unitid); -return err; - } - - num_outs = err; - input_pins = desc->bNrInPins; - -if (state->mixer->protocol ==UAC_VERSION_2 || - state->mixer->protocol ==UAC_VERSION_3 ) { -if (input_pins * num_outs >256 ) { -usb_audio_err (state->chip, -"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , - unitid, input_pins, num_outs); -return -EINVAL ; - } - } +int num_ins, pin, ich, och, err; num_ins =0 ; ich =0 ;
@@ -2311,25 +2290,90 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid, num_ins, num_outs))break ;for (; ich < num_ins; ich++) { -int och, ich_has_controls =0 ; -for (och =0 ; och < num_outs; och++) {__u8 *c =uac_mixer_unit_bmControls (desc, state->mixer->protocol); -if (check_matrix_bitmap (c, ich, och, num_outs)) { - ich_has_controls =1 ; +if (check_matrix_bitmap (c, ich, och, num_outs))break ; - } } -if (ich_has_controls) -build_mixer_unit_ctl (state, desc, pin, ich, num_outs, +if (och < num_outs) +build_mixer_unit_ctl (state, desc, ich, num_outs, unitid, &iterm); } }return 0 ; } +/* UAC2/UAC3 mixer unit */ +static int parse_audio_mixer_unit_v2 (struct mixer_build *state,int unitid, +int input_pins,int num_outs, +struct uac_mixer_unit_descriptor *desc) +{ +struct usb_audio_term iterm; +int pin, och, err; + +if (input_pins * num_outs >256 || +mixer_bitmap_overflow (desc, state->mixer->protocol, + input_pins, num_outs)) { +usb_audio_err (state->chip, +"invalid channels for MIXER UNIT %d: input=%d, output=%d\n" , + unitid, input_pins, num_outs); +return -EINVAL ; + } + +for (pin =0 ; pin < input_pins; pin++) { + err =parse_audio_unit (state, desc->baSourceID[pin]); +if (err <0 ) +continue ; +if (!num_outs) +continue ; + err =check_input_term (state, desc->baSourceID[pin], &iterm); +if (err <0 ) +return err; + +for (och =0 ; och < num_outs; och++) { +__u8 *c =uac_mixer_unit_bmControls (desc, + state->mixer->protocol); + +if (check_matrix_bitmap (c, pin, och, num_outs)) +break ; + } +if (och < num_outs) +build_mixer_unit_ctl (state, desc, pin, num_outs, + unitid, &iterm); + } +return 0 ; +} + +static int parse_audio_mixer_unit (struct mixer_build *state,int unitid, +void *raw_desc) +{ +struct uac_mixer_unit_descriptor *desc = raw_desc; +int num_outs; + + num_outs =uac_mixer_unit_get_channels (state, desc); +if (num_outs <0 ) { +usb_audio_err (state->chip, +"invalid MIXER UNIT descriptor %d\n" , + unitid); +return num_outs; + } + +switch (state->mixer->protocol) { +case UAC_VERSION_1 : +default : +return parse_audio_mixer_unit_v1 (state, unitid, + desc->bNrInPins, num_outs, + desc); +case UAC_VERSION_2 : +case UAC_VERSION_3 : +return parse_audio_mixer_unit_v2 (state, unitid, + desc->bNrInPins, num_outs, + desc); + } +} +/* * Processing Unit / Extension Unit */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 994/1756 ALSA: pcmtest: Fix a bogus pointer read in snd_pcmtst_pcm_pointer()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 905a07c711baf184d01aebd3cf9028a89bcd8b7f ]
Sashiko reported a potential bogus value for a pcmtest driver when a concurrent call to PCM pointer is invoked while the pcmtest's timer callback is running: since the position is updated in the timer callback without locking, the following wrapping in inc_buf_pos() might be screwed up:
if (v_iter->buf_pos >= bytes) v_iter->buf_pos %= bytes;
Although it was reported as an OOB, the actual return is corrected inside buffer_size, so no corruption is expected in this scenario, but an error message could show a bogus value.
Also, the whole state is read and modified locklessly in the timer callback, which can be racy against the pause operation, too.
For avoiding those races, simply put the PCM stream lock in the timer callback (while the snd_pcm_period_elapsed() must be changed to its *_under_stream_lock() variant for avoiding the deadlock).
--- sound/drivers/pcmtest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/drivers/pcmtest.c +2 -1
@@ -344,6 +344,7 @@ static void timer_timeout(struct timer_list *data) v_iter =from_timer (v_iter, data, timer_instance); substream = v_iter->substream; +guard (pcm_stream_lock_irqsave)(substream);if (v_iter->suspend)return ;
@@ -357,7 +358,7 @@ static void timer_timeout(struct timer_list *data) v_iter->period_pos += v_iter->b_rw;if (v_iter->period_pos >= v_iter->period_bytes) { v_iter->period_pos %= v_iter->period_bytes; -snd_pcm_period_elapsed (substream); +snd_pcm_period_elapsed_under_stream_lock (substream); }if (!v_iter->suspend)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 995/1756 ALSA: core: Add missing barriers for power_ref vs card->shutdown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a6913835735469751f56473f5212eb291a4805e7 ]
snd_power_ref_and_wait() increments card->power_ref and then reads card->shutdown (and the power state) locklessly, while snd_card_disconnect() sets card->shutdown and then waits for power_ref to drop to zero via snd_power_sync_ref(). Due to the missing barrier on both sides, the caller proceeds with shutdown still seen as false, while the disconnect side sees a zero refcount and continues tearing down incorrectly.
For addressing the potential race, add smp_mb__after_atomic() after the refcount increment and smp_mb() before snd_power_sync_ref() in snd_card_disconnect().
--- sound/core/init.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/core/init.c +4 -0
@@ -552,6 +552,8 @@ void snd_card_disconnect(struct snd_card *card)clear_bit (card->number, snd_cards_lock); } +/* order card->shutdown store against power_ref read */ +smp_mb ();snd_power_sync_ref (card); }EXPORT_SYMBOL (snd_card_disconnect);
@@ -1142,6 +1144,8 @@ EXPORT_SYMBOL(snd_card_file_remove);int snd_power_ref_and_wait (struct snd_card *card) {snd_power_ref (card); +/* order power_ref increment against card->shutdown read */ +smp_mb__after_atomic ();if (snd_power_get_state (card) !=SNDRV_CTL_POWER_D0 ) { wait_event_cmd(card->power_sleep, card->shutdown ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 996/1756 ALSA: seq: Fix missing direction and ump_group handling in 32bit compat ioctl
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 9d3e19c192b97b4c4c0abcafdbf1edb1e56cee88 ]
I forgot to cover the two new fields, direction and ump_group, in struct snd_seq_port_info for the 32bit compat ioctls of SNDRV_SEQ_IOCTL_GET_PORT_INFO & co, which ended up with the garbage copies in those fields. Add the handling of those two fields in the compat layer.
Also, avoid over-copying the 64bit snd_seq_port_info but only the first part (before the field kernel); this avoids the copy of kernel-space garbage value in the reserved field.
--- sound/core/seq/seq_compat.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
sound/core/seq/seq_compat.c +11 -4
@@ -25,7 +25,9 @@ struct snd_seq_port_info32 {u32 kernel;/* reserved for kernel use (must be NULL) */ u32 flags;/* misc. conditioning */ unsigned char time_queue;/* queue # for timestamping */ -char reserved[59 ];/* for future use */ +unsigned char direction;/* port usage direction (r/w/bidir) */ +unsigned char ump_group;/* 0 = UMP EP (no conversion), 1-16 = UMP group number */ +char reserved[57 ];/* for future use */ }; static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsigned int cmd,
@@ -40,7 +42,9 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsignedif (copy_from_user (data, data32,sizeof (*data32)) ||get_user (data->flags, &data32->flags) || -get_user (data->time_queue, &data32->time_queue)) +get_user (data->time_queue, &data32->time_queue) || +get_user (data->direction, &data32->direction) || +get_user (data->ump_group, &data32->ump_group))return -EFAULT ; data->kernel =NULL ;
@@ -50,9 +54,12 @@ static int snd_seq_call_port_info_ioctl(struct snd_seq_client *client, unsignedif (err <0 )return err; -if (copy_to_user (data32, data,sizeof (*data32)) || +if (copy_to_user (data32, data, + offsetof(struct snd_seq_port_info32 , kernel)) ||put_user (data->flags, &data32->flags) || -put_user (data->time_queue, &data32->time_queue)) +put_user (data->time_queue, &data32->time_queue) || +put_user (data->direction, &data32->direction) || +put_user (data->ump_group, &data32->ump_group))return -EFAULT ;return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 997/1756 ALSA: info: Fix memory leak at card removal
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit a3e8eec7692eac706ba0934fa18453e46acd1a08 ]
The fix for potential deadlock at disconnection by the commit c7a606519533 ("ALSA: info: Fix potential deadlock at disconnection") clears card->proc_root pointer at snd_info_card_disconnect(), in order just to be sure. But this leads to a memory leak of card->proc_root content that should have been released at a later call of snd_info_card_free().
For addressing the memory leak, simply drop the card->proc_root clearance at snd_info_card_disconnect().
Since card->proc_root might be still looked at in snd_info_card_id_change() that may be running concurrently during the connection procedure, add a sanity check there, too.
--- sound/core/info.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/core/info.c +2 -1
@@ -528,6 +528,8 @@ int snd_info_card_register(struct snd_card *card)void snd_info_card_id_change (struct snd_card *card) {guard (mutex)(&info_mutex); +if (card->shutdown) +return ;if (card->proc_root_link) {proc_remove (card->proc_root_link); card->proc_root_link =NULL ;
@@ -555,7 +557,6 @@ void snd_info_card_disconnect(struct snd_card *card)if (card->proc_root)snd_info_clear_entries (card->proc_root); card->proc_root_link =NULL ; - card->proc_root =NULL ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 998/1756 ALSA: hda: Avoid non-operational GPU warning at regular device removal
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 3af4ed9f927c469f23d03a76e3b438ed09715bd3 ]
When a hda-intel driver is removed manually and it has a GPU with switcheroo, it always gives a warning like "GPU sound probed, but not operational:..." no matter whether GPU has been actually operational or not. This warning was originally put for machines that really suffer from the non-operational GPU HDMI audio, but it's seen at the common path a normal device removal also goes over.
For avoiding a confusing warning, move the check and the warning at the error path of azx_probe_continue() that is the point where the non-functional GPU gets detected and given up.
--- sound/pci/hda/hda_intel.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +2 -1
@@ -1371,7 +1371,6 @@ static void azx_free(struct azx *chip)* actually stop the chip) to allow GPU to suspend via * vga_switcheroo, and print a warning. */ -dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" );pm_runtime_disable (&pci->dev);pm_runtime_set_suspended (&pci->dev);pm_runtime_enable (&pci->dev);
@@ -2412,6 +2411,8 @@ static int azx_probe_continue(struct azx *chip) out_free:if (err <0 ) {pci_set_drvdata (pci,NULL ); +if (hda->vga_switcheroo_registered) +dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" );snd_card_free (chip->card);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 999/1756 ALSA: hda/intel: Move firmware loading into the probe work
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit eb90ae3cca783ebec65704597027811431465de4 ]
The hda-intel driver uses request_firmware_nowait() for loading its patch, and tries to continue the probe directly from the fw loader callback. This works in principle, but it has a few drawbacks:
- The driver may be released before the firmware callback completes
- Having two ways of async probe makes the code flow unnecessarily complex
The former issue is more severe, as it may potentially lead to a UAF, and there is no explicit way to cancel the pending firmware worker for now.
This patch changes the firmware loading to be performed rather in the common probe work without *_nowait(). Then the pending work can be easily canceled, and the code becomes more straightforward.
A nice bonus is that, by moving into the probe work, the firmware doesn't need any longer to be cached, hence we can get rid of struct azx.fw field, and release the firmware immediately after parsing it, too.
Stable-dep-of: 7e1ad3c55baa ("ALSA: hda: Don't free card at probe error in vga_switcheroo handler")
--- sound/pci/hda/hda_controller.h | 4 --- sound/pci/hda/hda_intel.c | 58 +++++++++------------------------- 2 files changed, 15 insertions(+), 47 deletions(-)
sound/pci/hda/hda_controller.h +0 -4
@@ -127,10 +127,6 @@ struct azx {unsigned int beep_mode;bool ctl_dev_id; -#ifdef CONFIG_SND_HDA_PATCH_LOADER -const struct firmware *fw; -#endif -/* flags */ int bdl_pos_adj; unsigned int running:1;
sound/pci/hda/hda_intel.c +15 -43
88 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1000/1756 ALSA: hda: Dont free card at probe error in vga_switcheroo handler
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 7e1ad3c55baa80399f1727dfd2303fa4d1558d9a ]
The vga_switcheroo handler azx_vs_set_state() calls azx_probe_contine() for enabling the audio, and if an error happens during the probe, azx_probe_continue() releases its associated sound card object at the error path. The card release procedure includes the call of vga_switcheroo_unregister_client(), and this triggers the vgasr_mutex lock again that had been already held by the caller (vga_switcheroo_process_delayed_switch()) -- leading to a deadlock.
(Moreover, the card release will cause a potential UAF at the error message in azx_vs_set_state() since the card object is already gone; this was the original report by Sashiko.)
For avoiding the unneeded crash, it's better to avoid the card release in this error path, so we make azx_probe_continue() behaving conditionally. In return, set hda->init_failed flag, so that any further (re-)attempts will be filtered after that point.
The check of hda->init_failed is dropped from azx_vs_can_switch(). It's because otherwise vga_switcheroo can't be switched to turn off GPU once when a probe error happens at the audio side.
--- sound/pci/hda/hda_intel.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
sound/pci/hda/hda_intel.c +10 -8
@@ -1175,7 +1175,7 @@ static const struct dev_pm_ops azx_pm = { }; -static int azx_probe_continue (struct azx *chip); +static int azx_probe_continue (struct azx *chip,bool free_on_error);#ifdef SUPPORT_VGA_SWITCHEROO static struct pci_dev *get_bound_vga (struct pci_dev *pci);
@@ -1202,8 +1202,10 @@ static void azx_vs_set_state(struct pci_dev *pci,if (!disabled) {dev_info (chip->card->dev,"Start delayed initialization\n" ); -if (azx_probe_continue (chip) <0 ) +if (azx_probe_continue (chip, false) <0 ) { + hda->init_failed =1 ;dev_err (chip->card->dev,"initialization error\n" ); + } } }else { dev_info(chip->card->dev, "%s via vga_switcheroo\n",
@@ -1242,8 +1244,6 @@ static bool azx_vs_can_switch(struct pci_dev *pci) struct hda_intel *hda = container_of(chip, struct hda_intel, chip);wait_for_completion (&hda->probe_wait); -if (hda->init_failed) -return false;if (chip->disabled || !hda->probe_continued)return true;if (snd_hda_lock_devices (&chip->bus))
@@ -1728,7 +1728,7 @@ static void azx_check_snoop_available(struct azx *chip)static void azx_probe_work (struct work_struct *work) { struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work); -azx_probe_continue (&hda->chip); +azx_probe_continue (&hda->chip, true); }static int default_bdl_pos_adj (struct azx *chip)
@@ -2290,7 +2290,7 @@ static const unsigned int azx_max_codecs[AZX_NUM_DRIVERS] = { [AZX_DRIVER_TERA] = 1, }; -static int azx_probe_continue (struct azx *chip) +static int azx_probe_continue (struct azx *chip,bool free_on_error) { struct hda_intel *hda = container_of(chip, struct hda_intel, chip);struct hdac_bus *bus =azx_bus (chip);
@@ -2382,10 +2382,12 @@ static int azx_probe_continue(struct azx *chip) out_free:if (err <0 ) { -pci_set_drvdata (pci,NULL );if (hda->vga_switcheroo_registered)dev_warn (&pci->dev,"GPU sound probed, but not operational: please add a quirk to driver_denylist\n" ); -snd_card_free (chip->card); +if (free_on_error) { +pci_set_drvdata (pci,NULL ); +snd_card_free (chip->card); + }return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1001/1756 crypto: qat - force an edge when re-enabling all VF2PF interrupts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Abraham P <[email protected]>
[ Upstream commit 2b91570f72670054ddae5b11b8c70a79c340014a ]
VF2PF interrupts are edge-triggered: a source only fires on a masked -> unmasked transition of VM2PF_MSK, not by being unmasked. adf_enable_all_vf2pf_interrupts() does a plain read-modify-write unmask, assuming VM2PF_MSK still holds the all-masked value left by adf_disable_all_vf2pf_interrupts().
That breaks across a device reset: adf_dev_autoreset() (and AER recovery) FLR the PF while VFs stay alive, so a VF can latch a source in VM2PF_SOU with no vectors set up to deliver it. The FLR then resets VM2PF_MSK to its power-on default of 0 (unmasked) without a software write, so the following RMW unmask writes 0 over an already-0
register: no edge occurs and the latched VF2PF message is never delivered.
Fix by having adf_enable_all_vf2pf_interrupts() mask all sources immediately before unmasking them, mirroring the idiom already used in adf_gen4_disable_pending_vf2pf_interrupts(), forcing the required edge regardless of the prior state of VM2PF_MSK.
--- drivers/crypto/intel/qat/qat_common/adf_isr.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_isr.c +14 -1
@@ -70,6 +70,7 @@ void adf_enable_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 vf_mask)void adf_enable_all_vf2pf_interrupts (struct adf_accel_dev *accel_dev,u32 num_vfs) {void __iomem *pmisc_addr =adf_get_pmisc_base (accel_dev); +struct adf_pfvf_ops *pfvf_ops =GET_PFVF_OPS (accel_dev);unsigned long flags;u32 vf_mask;
@@ -79,7 +80,19 @@ void adf_enable_all_vf2pf_interrupts(struct adf_accel_dev *accel_dev, u32 num_vfspin_lock_irqsave (&accel_dev->pf.vf2pf_ints_lock, flags);WRITE_ONCE (accel_dev->pf.vf2pf_disabled, false); -GET_PFVF_OPS (accel_dev)->enable_vf2pf_interrupts (pmisc_addr, vf_mask); +/* +* A VF2PF interrupt is only generated when a source transitions from +* masked to unmasked. A VF may write to its VF2PF CSR while the source +* is masked or while the MSI-X vectors are torn down, for example +* during a device reset, leaving the source latched with no interrupt +* pending. The FLR performed as part of a device reset returns the mask +* register to its default value, which leaves all the sources unmasked, +* so simply unmasking is not guaranteed to be a transition. Mask all the +* sources first, so that unmasking always generates an interrupt for +* the sources latched in the meantime. +*/ + pfvf_ops->disable_all_vf2pf_interrupts (pmisc_addr); + pfvf_ops->enable_vf2pf_interrupts (pmisc_addr, vf_mask);spin_unlock_irqrestore (&accel_dev->pf.vf2pf_ints_lock, flags); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1002/1756 crypto: talitos - allocate channels with main struct
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 24818f77603b3fcb7f3da5802b28bcc5ac7604aa ]
Use a flexible array member to combine allocations.
Add __counted_by for extra runtime analysis.
Error in case of no channels as they are required.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 19 +++++++------------ drivers/crypto/talitos.h | 5 +++-- 2 files changed, 10 insertions(+), 14 deletions(-)
drivers/crypto/talitos.c +7 -12
@@ -3410,14 +3410,20 @@ static int talitos_probe(struct platform_device *ofdev)struct device *dev = &ofdev->dev;struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv; +unsigned int num_channels;int i, err;int stride;struct resource *res; - priv =devm_kzalloc (dev,sizeof (struct talitos_private ),GFP_KERNEL ); +if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels)) +return -EINVAL ; + + priv =devm_kzalloc (dev,struct_size (priv, chan, num_channels),GFP_KERNEL );if (!priv)return -ENOMEM ; + priv->num_channels = num_channels; +INIT_LIST_HEAD (&priv->alg_list);dev_set_drvdata (dev, priv);
@@ -3437,7 +3443,6 @@ static int talitos_probe(struct platform_device *ofdev) }/* get SEC version capabilities from device tree */ -of_property_read_u32 (np,"fsl,num-channels" , &priv->num_channels);of_property_read_u32 (np,"fsl,channel-fifo-len" , &priv->chfifo_len);of_property_read_u32 (np,"fsl,exec-units-mask" , &priv->exec_units); of_property_read_u32(np, "fsl,descriptor-types-mask",
@@ -3512,16 +3517,6 @@ static int talitos_probe(struct platform_device *ofdev) } } - priv->chan =devm_kcalloc (dev, - priv->num_channels, -sizeof (struct talitos_channel ), -GFP_KERNEL ); -if (!priv->chan) { -dev_err (dev,"failed to allocate channel management space\n" ); - err = -ENOMEM ; - goto err_out; - } - priv->fifo_len =roundup_pow_of_two (priv->chfifo_len);for (i =0 ; i < priv->num_channels; i++) {
drivers/crypto/talitos.h +3 -2
@@ -151,8 +151,6 @@ struct talitos_private {*/ unsigned int fifo_len; -struct talitos_channel *chan; -/* next channel to be assigned next incoming descriptor */ atomic_t last_chan____cacheline_aligned ;
@@ -165,6 +163,9 @@ struct talitos_private {/* hwrng device */ struct hwrng rng;bool rng_registered; + + struct talitos_channel chan[] __counted_by(num_channels); + };/* .features flag */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1003/1756 crypto: talitos - use devm_platform_ioremap_resource()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 463be1c718fb9f07bdce3d51363a17eac4522538 ]
platform_get_resource and devm_ioremap effectively open codes this.
The return type of devm_platform_ioremap_resource() is also nice as it has multiple errors that it can return.
Because it internally calls devm_request_mem_region(), reg values and sizes cannot overlap. This was manually verified to be the case for all talitos users.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/crypto/talitos.c +3 -7
@@ -3413,7 +3413,6 @@ static int talitos_probe(struct platform_device *ofdev)unsigned int num_channels;int i, err;int stride; -struct resource *res;if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels))return -EINVAL ;
@@ -3432,13 +3431,10 @@ static int talitos_probe(struct platform_device *ofdev)spin_lock_init (&priv->reg_lock); - res =platform_get_resource (ofdev,IORESOURCE_MEM ,0 ); -if (!res) -return -ENXIO ; - priv->reg =devm_ioremap (dev, res->start,resource_size (res)); -if (!priv->reg) { + priv->reg =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (priv->reg)) {dev_err (dev,"failed to of_iomap\n" ); - err = -ENOMEM ; + err =PTR_ERR (priv->reg); goto err_out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1004/1756 crypto: talitos - Use platform_get_irq() to retrieve interrupt
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 4a1c7518cc31430b96458202b6a5b4064ff0cfa0 ]
Remove the need to call irq_dispose_mapping as needed by irq_of_parse_and_map().
Simplify the function as a result. No need for gotos anymore.
Add a missing free_irq.
Stable-dep-of: 666d66df2525 ("crypto: talitos - init tasklets before requesting IRQs")
--- drivers/crypto/talitos.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
drivers/crypto/talitos.c +13 -17
@@ -192,7 +192,7 @@ static int reset_device(struct device *dev) && --timeout)cpu_relax (); -if (priv->irq[1 ]) { +if (priv->irq[1 ] >0 ) { mcr =TALITOS_MCR_RCA1 |TALITOS_MCR_RCA3 ;setbits32 (priv->reg +TALITOS_MCR , mcr); }
@@ -3242,13 +3242,11 @@ static void talitos_remove(struct platform_device *ofdev)talitos_unregister_rng (dev);for (i =0 ; i <2 ; i++) -if (priv->irq[i]) { +if (priv->irq[i] >0 )free_irq (priv->irq[i], dev); -irq_dispose_mapping (priv->irq[i]); - }tasklet_kill (&priv->done_task[0 ]); -if (priv->irq[1 ]) +if (priv->irq[1 ] >0 )tasklet_kill (&priv->done_task[1 ]); }
@@ -3354,26 +3352,26 @@ static struct talitos_crypto_alg *talitos_alg_alloc(struct device *dev,static int talitos_probe_irq (struct platform_device *ofdev) {struct device *dev = &ofdev->dev; -struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv =dev_get_drvdata (dev);int err;bool is_sec1 =has_ftr_sec1 (priv); - priv->irq[0 ] =irq_of_parse_and_map (np,0 ); -if (!priv->irq[0 ]) { -dev_err (dev,"failed to map irq\n" ); -return -EINVAL ; - } + priv->irq[0 ] =platform_get_irq (ofdev,0 ); +if (priv->irq[0 ] <0 ) +return priv->irq[0 ]; +if (is_sec1) { err =request_irq (priv->irq[0 ], talitos1_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out; } - priv->irq[1 ] =irq_of_parse_and_map (np,1 ); + priv->irq[1 ] =platform_get_irq_optional (ofdev,1 ); +if (priv->irq[1 ] == -EPROBE_DEFER ) +return priv->irq[1 ];/* get the primary irq line */ -if (!priv->irq[1 ]) { +if (priv->irq[1 ] <0 ) { err =request_irq (priv->irq[0 ], talitos2_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out;
@@ -3389,7 +3387,6 @@ static int talitos_probe_irq(struct platform_device *ofdev) dev_driver_string(dev), dev);if (err) {dev_err (dev,"failed to request secondary irq\n" ); -irq_dispose_mapping (priv->irq[1 ]); priv->irq[1 ] =0 ; }
@@ -3398,7 +3395,6 @@ static int talitos_probe_irq(struct platform_device *ofdev) primary_out:if (err) {dev_err (dev,"failed to request primary irq\n" ); -irq_dispose_mapping (priv->irq[0 ]); priv->irq[0 ] =0 ; }
@@ -3499,7 +3495,7 @@ static int talitos_probe(struct platform_device *ofdev)tasklet_init (&priv->done_task[0 ], talitos1_done_4ch, (unsigned long )dev); }else { -if (priv->irq[1 ]) { +if (priv->irq[1 ] >0 ) {tasklet_init (&priv->done_task[0 ], talitos2_done_ch0_2, (unsigned long )dev); tasklet_init(&priv->done_task[1], talitos2_done_ch1_3,
@@ -3517,7 +3513,7 @@ static int talitos_probe(struct platform_device *ofdev)for (i =0 ; i < priv->num_channels; i++) { priv->chan[i].reg = priv->reg + stride * (i +1 ); -if (!priv->irq[1 ] || !(i &1 )) +if (priv->irq[1 ] <0 || !(i &1 )) priv->chan[i].reg +=TALITOS_CH_BASE_OFFSET ;spin_lock_init (&priv->chan[i].head_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1005/1756 crypto: talitos - init tasklets before requesting IRQs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 666d66df25253070cb297cb920b0bcfcfe5eb871 ]
The talitos interrupt handlers schedule priv->done_task[] via tasklet_schedule(). Since the second IRQ support, probe has requested the IRQs before calling tasklet_init(), so an interrupt already pending when a line is requested, e.g. engine state left by the bootloader or a kexec'd kernel, would schedule a tasklet with a NULL callback.
Look up the IRQ numbers and map the registers up front, so that -EPROBE_DEFER returns before anything is allocated and the done_task[] selection and reset_device() can see the secondary IRQ. Only request the IRQs once the channel fifos are allocated and init_device() has reset the engine. This matches remove(), which frees the IRQs before killing the tasklets.
remove() frees every IRQ number that is > 0, so make sure that only requested lines are set when it runs from the probe error path: clear both numbers when probe fails before the request, and clear any line talitos_probe_irq() did not request. Previously a failed primary request in the two-IRQ case freed the never-requested secondary line.
--- drivers/crypto/talitos.c | 54 ++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 21 deletions(-)
drivers/crypto/talitos.c +33 -21
@@ -3356,21 +3356,13 @@ static int talitos_probe_irq(struct platform_device *ofdev)int err;bool is_sec1 =has_ftr_sec1 (priv); - priv->irq[0 ] =platform_get_irq (ofdev,0 ); -if (priv->irq[0 ] <0 ) -return priv->irq[0 ]; -if (is_sec1) { err =request_irq (priv->irq[0 ], talitos1_interrupt_4ch,0 ,dev_driver_string (dev), dev); goto primary_out; } - priv->irq[1 ] =platform_get_irq_optional (ofdev,1 ); -if (priv->irq[1 ] == -EPROBE_DEFER ) -return priv->irq[1 ]; - -/* get the primary irq line */ +/* single (or primary) irq line */ if (priv->irq[1 ] <0 ) { err =request_irq (priv->irq[0 ], talitos2_interrupt_4ch,0 ,dev_driver_string (dev), dev);
@@ -3382,7 +3374,7 @@ static int talitos_probe_irq(struct platform_device *ofdev)if (err) goto primary_out; -/* get the secondary irq line */ +/* secondary irq line */ err =request_irq (priv->irq[1 ], talitos2_interrupt_ch1_3,0 ,dev_driver_string (dev), dev);if (err) {
@@ -3395,7 +3387,9 @@ static int talitos_probe_irq(struct platform_device *ofdev) primary_out:if (err) {dev_err (dev,"failed to request primary irq\n" ); +/* neither line is requested, keep remove() from freeing them */ priv->irq[0 ] =0 ; + priv->irq[1 ] =0 ; }return err;
@@ -3407,12 +3401,27 @@ static int talitos_probe(struct platform_device *ofdev)struct device_node *np = ofdev->dev.of_node;struct talitos_private *priv;unsigned int num_channels; +void __iomem *reg;int i, err;int stride; +int irq0; +int irq1;if (of_property_read_u32 (np,"fsl,num-channels" , &num_channels))return -EINVAL ; + irq0 =platform_get_irq (ofdev,0 ); +if (irq0 <0 ) +return irq0; + + irq1 =platform_get_irq_optional (ofdev,1 ); +if (irq1 == -EPROBE_DEFER ) +return irq1; + + reg =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (reg)) +return PTR_ERR (reg); + priv =devm_kzalloc (dev,struct_size (priv, chan, num_channels),GFP_KERNEL );if (!priv)return -ENOMEM ;
@@ -3427,12 +3436,7 @@ static int talitos_probe(struct platform_device *ofdev)spin_lock_init (&priv->reg_lock); - priv->reg =devm_platform_ioremap_resource (ofdev,0 ); -if (IS_ERR (priv->reg)) { -dev_err (dev,"failed to of_iomap\n" ); - err =PTR_ERR (priv->reg); - goto err_out; - } + priv->reg = reg;/* get SEC version capabilities from device tree */ of_property_read_u32 (np,"fsl,channel-fifo-len" , &priv->chfifo_len);
@@ -3483,9 +3487,7 @@ static int talitos_probe(struct platform_device *ofdev) stride =TALITOS2_CH_STRIDE ; } - err =talitos_probe_irq (ofdev); -if (err) - goto err_out; + priv->irq[0 ] = irq0;if (has_ftr_sec1 (priv)) {if (priv->num_channels ==1 )
@@ -3495,6 +3497,7 @@ static int talitos_probe(struct platform_device *ofdev)tasklet_init (&priv->done_task[0 ], talitos1_done_4ch, (unsigned long )dev); }else { + priv->irq[1 ] = irq1;if (priv->irq[1 ] >0 ) {tasklet_init (&priv->done_task[0 ], talitos2_done_ch0_2, (unsigned long )dev);
@@ -3526,7 +3529,7 @@ static int talitos_probe(struct platform_device *ofdev)if (!priv->chan[i].fifo) {dev_err (dev,"failed to allocate request fifo %d\n" , i); err = -ENOMEM ; - goto err_out; + goto err_noirq; } atomic_set(&priv->chan[i].submit_count,
@@ -3539,9 +3542,14 @@ static int talitos_probe(struct platform_device *ofdev) err =init_device (dev);if (err) {dev_err (dev,"failed to initialize device\n" ); - goto err_out; + goto err_noirq; } +/* enable interrupts once the channel fifos and tasklets are set up */ + err =talitos_probe_irq (ofdev); +if (err) + goto err_out; +/* register the RNG, if available */ if (hw_supports (dev,DESC_HDR_SEL0_RNG )) { err =talitos_register_rng (dev);
@@ -3599,6 +3607,10 @@ static int talitos_probe(struct platform_device *ofdev)return 0 ; +err_noirq: +/* the irq numbers are known, but the lines are not requested yet */ + priv->irq[0 ] =0 ; + priv->irq[1 ] =0 ; err_out:talitos_remove (ofdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1006/1756 ASoC: mediatek: common: Keep codec references until the card is bound
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michał Kopeć <[email protected]>
[ Upstream commit 6cb1f09e1f699d0c7f748057bc50d84a1e9e77fc ]
mtk_soundcard_common_probe() drops the codec references parsed from the devicetree right after devm_snd_soc_register_card() returns. When a component is still missing, snd_soc_bind_card() queues the card for a later rebind and registration still returns success, so the card is not instantiated yet. The rebind reuses the same dai_link array, but with the codec references released both the codec name and of_node are unset, so it fails the dai link sanity check and the sound card never appears.
Release the references right away only when the card was instantiated or registration failed. Otherwise keep them for the rebind and release them when the device is unbound.
--- .../mediatek/common/mtk-soundcard-driver.c | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
sound/soc/mediatek/common/mtk-soundcard-driver.c +21 -2
@@ -139,6 +139,11 @@ void clean_card_reference(struct snd_soc_card *card) }EXPORT_SYMBOL_GPL (clean_card_reference); +static void mtk_soundcard_put_card_reference (void *data) +{ +clean_card_reference (data); +} +int mtk_soundcard_startup (struct snd_pcm_substream *substream,enum mtk_pcm_constraint_type ctype) {
@@ -319,8 +324,22 @@ int mtk_soundcard_common_probe(struct platform_device *pdev) ret =devm_snd_soc_register_card (&pdev->dev, card); -if (!needs_legacy_probe) -clean_card_reference (card); +/* +* When a component is still missing, snd_soc_bind_card() queues the +* card for a later rebind and returns success, so the card is not +* instantiated yet. That rebind reuses this same dai_link array, so +* the codec references parsed from the devicetree must be kept until +* the device is unbound: dropping them leaves both name and of_node +* unset and the rebind fails the dai link sanity check instead. +*/ +if (!needs_legacy_probe) { +if (ret ||snd_soc_card_is_instantiated (card)) +clean_card_reference (card); +else + ret =devm_add_action_or_reset (&pdev->dev, + mtk_soundcard_put_card_reference, + card); + }if (ret) {dev_err_probe (&pdev->dev, ret,"Cannot register card\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1007/1756 ASoC: mediatek: remove dpcm_xxx flags
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit ec15e5043d0bedcb93a2653725fb50d5b358b06b ]
dpcm_xxx flags are no longer needed. It converts dpcm_xxx flag to xxx_only if needed.
Stable-dep-of: 76775717c4ad ("ASoC: mediatek: mt8188: Constrain UL8 FE to its back end's capabilities")
--- sound/soc/mediatek/mt2701/mt2701-cs42448.c | 20 ++--- sound/soc/mediatek/mt2701/mt2701-wm8960.c | 6 +- sound/soc/mediatek/mt6797/mt6797-mt6351.c | 24 ++---- sound/soc/mediatek/mt7986/mt7986-wm8960.c | 6 +- sound/soc/mediatek/mt8173/mt8173-max98090.c | 6 +- .../mediatek/mt8173/mt8173-rt5650-rt5514.c | 6 +- .../mediatek/mt8173/mt8173-rt5650-rt5676.c | 10 +-- sound/soc/mediatek/mt8173/mt8173-rt5650.c | 10 +-- .../mediatek/mt8183/mt8183-da7219-max98357.c | 34 +++----- .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 34 +++----- sound/soc/mediatek/mt8186/mt8186-mt6366.c | 86 +++++++------------ sound/soc/mediatek/mt8188/mt8188-mt6359.c | 58 ++++++------- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 78 ++++++++--------- sound/soc/mediatek/mt8195/mt8195-mt6359.c | 60 +++++++------ sound/soc/mediatek/mt8365/mt8365-mt6357.c | 14 ++- 15 files changed, 185 insertions(+), 267 deletions(-)
sound/soc/mediatek/mt2701/mt2701-cs42448.c +5 -15
@@ -221,7 +221,7 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { SND_SOC_DPCM_TRIGGER_POST}, .ops = &mt2701_cs42448_48k_fe_ops, .dynamic = 1, - .dpcm_playback =1 , + .playback_only =1 , SND_SOC_DAILINK_REG(fe_multi_ch_out), }, [DAI_LINK_FE_PCM0_IN] = {
@@ -231,7 +231,7 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { SND_SOC_DPCM_TRIGGER_POST}, .ops = &mt2701_cs42448_48k_fe_ops, .dynamic = 1, - .dpcm_capture =1 , + .capture_only =1 , SND_SOC_DAILINK_REG(fe_pcm0_in), }, [DAI_LINK_FE_PCM1_IN] = {
@@ -241,7 +241,7 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { SND_SOC_DPCM_TRIGGER_POST}, .ops = &mt2701_cs42448_48k_fe_ops, .dynamic = 1, - .dpcm_capture =1 , + .capture_only =1 , SND_SOC_DAILINK_REG(fe_pcm1_in), }, [DAI_LINK_FE_BT_OUT] = {
@@ -250,7 +250,7 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(fe_bt_out), }, [DAI_LINK_FE_BT_IN] = {
@@ -259,7 +259,7 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(fe_bt_in), },/* BE */
@@ -269,8 +269,6 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_GATED, .ops = &mt2701_cs42448_be_ops, - .dpcm_playback = 1, - .dpcm_capture =1 , SND_SOC_DAILINK_REG(be_i2s0), }, [DAI_LINK_BE_I2S1] = {
@@ -279,8 +277,6 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_GATED, .ops = &mt2701_cs42448_be_ops, - .dpcm_playback = 1, - .dpcm_capture =1 , SND_SOC_DAILINK_REG(be_i2s1), }, [DAI_LINK_BE_I2S2] = {
@@ -289,8 +285,6 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_GATED, .ops = &mt2701_cs42448_be_ops, - .dpcm_playback = 1, - .dpcm_capture =1 , SND_SOC_DAILINK_REG(be_i2s2), }, [DAI_LINK_BE_I2S3] = {
@@ -299,15 +293,11 @@ static struct snd_soc_dai_link mt2701_cs42448_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_GATED, .ops = &mt2701_cs42448_be_ops, - .dpcm_playback = 1, - .dpcm_capture = 1,SND_SOC_DAILINK_REG (be_i2s3), }, [DAI_LINK_BE_MRG_BT] = { .name ="mt2701-cs42448-MRG-BT" , .no_pcm =1 , - .dpcm_playback =1 , - .dpcm_capture =1 ,SND_SOC_DAILINK_REG (be_mrg_bt), }, };
sound/soc/mediatek/mt2701/mt2701-wm8960.c +2 -4
@@ -67,7 +67,7 @@ static struct snd_soc_dai_link mt2701_wm8960_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback), }, {
@@ -76,7 +76,7 @@ static struct snd_soc_dai_link mt2701_wm8960_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture), },/* BE */
@@ -86,8 +86,6 @@ static struct snd_soc_dai_link mt2701_wm8960_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_GATED, .ops = &mt2701_wm8960_be_ops, - .dpcm_playback = 1, - .dpcm_capture = 1, SND_SOC_DAILINK_REG(codec), }, };
sound/soc/mediatek/mt6797/mt6797-mt6351.c +7 -17
@@ -78,7 +78,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback_1), }, {
@@ -87,7 +87,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback_2), }, {
@@ -96,7 +96,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback_3), }, {
@@ -105,7 +105,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture_1), }, {
@@ -114,7 +114,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture_2), }, {
@@ -123,7 +123,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture_3), }, {
@@ -132,7 +132,7 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture_mono_1), }, {
@@ -141,8 +141,6 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(hostless_lpbk), },
@@ -152,8 +150,6 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(hostless_speech), },
@@ -161,24 +157,18 @@ static struct snd_soc_dai_link mt6797_mt6351_dai_links[] = { { .name = "Primary Codec", .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(primary_codec), }, { .name = "PCM 1", .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(pcm1), }, { .name = "PCM 2", .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(pcm2), },
sound/soc/mediatek/mt7986/mt7986-wm8960.c +2 -4
@@ -45,7 +45,7 @@ static struct snd_soc_dai_link mt7986_wm8960_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback), }, {
@@ -54,7 +54,7 @@ static struct snd_soc_dai_link mt7986_wm8960_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture), },/* BE */
@@ -65,8 +65,6 @@ static struct snd_soc_dai_link mt7986_wm8960_dai_links[] = { SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_GATED, - .dpcm_playback = 1, - .dpcm_capture = 1, SND_SOC_DAILINK_REG(codec), }, };
sound/soc/mediatek/mt8173/mt8173-max98090.c +2 -4
@@ -104,7 +104,7 @@ static struct snd_soc_dai_link mt8173_max98090_dais[] = { .stream_name = "MAX98090 Playback", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback), }, {
@@ -112,7 +112,7 @@ static struct snd_soc_dai_link mt8173_max98090_dais[] = { .stream_name = "MAX98090 Capture", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture), },/* Back End DAI links */
@@ -123,8 +123,6 @@ static struct snd_soc_dai_link mt8173_max98090_dais[] = { .ops = &mt8173_max98090_ops, .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, - .dpcm_playback = 1, - .dpcm_capture = 1, SND_SOC_DAILINK_REG(hifi), }, };
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5514.c +2 -4
@@ -139,7 +139,7 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5514_dais[] = { .stream_name = "rt5650_rt5514 Playback", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback), }, [DAI_LINK_CAPTURE] = {
@@ -147,7 +147,7 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5514_dais[] = { .stream_name = "rt5650_rt5514 Capture", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture), },/* Back End DAI links */
@@ -159,8 +159,6 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5514_dais[] = { SND_SOC_DAIFMT_CBS_CFS, .ops = &mt8173_rt5650_rt5514_ops, .ignore_pmdown_time = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, SND_SOC_DAILINK_REG(codec), }, };
sound/soc/mediatek/mt8173/mt8173-rt5650-rt5676.c +4 -6
@@ -171,7 +171,7 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = { .stream_name = "rt5650_rt5676 Playback", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback), }, [DAI_LINK_CAPTURE] = {
@@ -179,7 +179,7 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = { .stream_name = "rt5650_rt5676 Capture", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture), }, [DAI_LINK_HDMI] = {
@@ -187,7 +187,7 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = { .stream_name = "HDMI PCM", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(hdmi_pcm), },
@@ -200,14 +200,12 @@ static struct snd_soc_dai_link mt8173_rt5650_rt5676_dais[] = { SND_SOC_DAIFMT_CBS_CFS, .ops = &mt8173_rt5650_rt5676_ops, .ignore_pmdown_time = 1, - .dpcm_playback = 1, - .dpcm_capture = 1,SND_SOC_DAILINK_REG (codec), }, [DAI_LINK_HDMI_I2S] = { .name ="HDMI BE" , .no_pcm =1 , - .dpcm_playback =1 , + .playback_only =1 ,SND_SOC_DAILINK_REG (hdmi_be), }, /* rt5676 <-> rt5650 intercodec link: Sets rt5676 I2S2 as master */
sound/soc/mediatek/mt8173/mt8173-rt5650.c +4 -6
@@ -210,7 +210,7 @@ static struct snd_soc_dai_link mt8173_rt5650_dais[] = { .stream_name = "rt5650 Playback", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback), }, [DAI_LINK_CAPTURE] = {
@@ -218,7 +218,7 @@ static struct snd_soc_dai_link mt8173_rt5650_dais[] = { .stream_name = "rt5650 Capture", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture), }, [DAI_LINK_HDMI] = {
@@ -226,7 +226,7 @@ static struct snd_soc_dai_link mt8173_rt5650_dais[] = { .stream_name = "HDMI PCM", .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(hdmi_pcm), },/* Back End DAI links */
@@ -238,14 +238,12 @@ static struct snd_soc_dai_link mt8173_rt5650_dais[] = { SND_SOC_DAIFMT_CBS_CFS, .ops = &mt8173_rt5650_ops, .ignore_pmdown_time = 1, - .dpcm_playback = 1, - .dpcm_capture = 1,SND_SOC_DAILINK_REG (codec), }, [DAI_LINK_HDMI_I2S] = { .name ="HDMI BE" , .no_pcm =1 , - .dpcm_playback =1 , + .playback_only =1 , .init = mt8173_rt5650_hdmi_init,SND_SOC_DAILINK_REG (hdmi_be), },
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +14 -20
@@ -425,7 +425,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, .ops = &mt8183_da7219_max98357_ops, SND_SOC_DAILINK_REG(playback1), },
@@ -435,7 +435,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, .ops = &mt8183_da7219_max98357_bt_sco_ops, SND_SOC_DAILINK_REG(playback2), },
@@ -445,7 +445,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback3), }, {
@@ -454,7 +454,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, .ops = &mt8183_da7219_max98357_bt_sco_ops, SND_SOC_DAILINK_REG(capture1), },
@@ -464,7 +464,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture2), }, {
@@ -473,7 +473,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, .ops = &mt8183_da7219_max98357_ops, SND_SOC_DAILINK_REG(capture3), },
@@ -483,7 +483,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture_mono), }, {
@@ -492,38 +492,32 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback_hdmi), }, /* BE */ { .name ="Primary Codec" , .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(primary_codec), }, { .name ="PCM 1" , .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(pcm1), }, { .name ="PCM 2" , .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(pcm2), }, { .name ="I2S0" , .no_pcm = 1, - .dpcm_capture = 1, + .capture_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops,
@@ -532,7 +526,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { { .name = "I2S1", .no_pcm = 1, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops,
@@ -541,7 +535,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { { .name = "I2S2", .no_pcm = 1, - .dpcm_capture = 1, + .capture_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_da7219_i2s_ops,
@@ -551,13 +545,13 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { { .name = "I2S3", .no_pcm = 1, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, }, { .name = "I2S5", .no_pcm = 1, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops,
@@ -570,7 +564,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ignore = 1,
sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c +14 -20
@@ -430,7 +430,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, .ops = &mt8183_mt6358_ops, SND_SOC_DAILINK_REG(playback1), },
@@ -440,7 +440,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, .ops = &mt8183_mt6358_ts3a227_max98357_bt_sco_ops, SND_SOC_DAILINK_REG(playback2), },
@@ -450,7 +450,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback3), }, {
@@ -459,7 +459,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, .ops = &mt8183_mt6358_ts3a227_max98357_bt_sco_ops, SND_SOC_DAILINK_REG(capture1), },
@@ -469,7 +469,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture2), }, {
@@ -478,7 +478,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, .ops = &mt8183_mt6358_ops, SND_SOC_DAILINK_REG(capture3), },
@@ -488,7 +488,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(capture_mono), }, {
@@ -497,7 +497,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .trigger = {SND_SOC_DPCM_TRIGGER_PRE, SND_SOC_DPCM_TRIGGER_PRE}, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, SND_SOC_DAILINK_REG(playback_hdmi), }, {
@@ -513,31 +513,25 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { { .name = "Primary Codec", .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(primary_codec), }, { .name = "PCM 1", .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(pcm1), }, { .name = "PCM 2", .no_pcm = 1, - .dpcm_playback = 1, - .dpcm_capture = 1, .ignore_suspend = 1, SND_SOC_DAILINK_REG(pcm2), }, { .name = "I2S0", .no_pcm = 1, - .dpcm_capture = 1, + .capture_only = 1, .ignore_suspend = 1, .ops = &mt8183_mt6358_i2s_ops, SND_SOC_DAILINK_REG(i2s0),
@@ -545,7 +539,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { { .name = "I2S1", .no_pcm = 1, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops,
@@ -554,7 +548,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { { .name = "I2S2", .no_pcm = 1, - .dpcm_capture = 1, + .capture_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops,
@@ -564,13 +558,13 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { { .name = "I2S3", .no_pcm = 1, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, }, { .name = "I2S5", .no_pcm = 1, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, .ops = &mt8183_mt6358_i2s_ops, .init = &mt8183_bt_init,
@@ -582,7 +576,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .dai_fmt = SND_SOC_DAIFMT_I2S |SND_SOC_DAIFMT_IB_IF | SND_SOC_DAIFMT_CBM_CFM, - .dpcm_playback = 1, + .playback_only = 1, .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_tdm_ops,
sound/soc/mediatek/mt8186/mt8186-mt6366.c +32 -54
341 lines not on this page · raw message
sound/soc/mediatek/mt8188/mt8188-mt6359.c +28 -30
231 lines not on this page · raw message
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +35 -43
312 lines not on this page · raw message
sound/soc/mediatek/mt8195/mt8195-mt6359.c +29 -31
237 lines not on this page · raw message
sound/soc/mediatek/mt8365/mt8365-mt6357.c +5 -9
@@ -168,7 +168,7 @@ static struct snd_soc_dai_link mt8365_mt6357_dais[] = { SND_SOC_DPCM_TRIGGER_POST }, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, .dpcm_merged_rate = 1, SND_SOC_DAILINK_REG(playback1), },
@@ -181,7 +181,7 @@ static struct snd_soc_dai_link mt8365_mt6357_dais[] = { SND_SOC_DPCM_TRIGGER_POST }, .dynamic = 1, - .dpcm_playback = 1, + .playback_only = 1, .dpcm_merged_rate = 1, SND_SOC_DAILINK_REG(playback2), },
@@ -194,7 +194,7 @@ static struct snd_soc_dai_link mt8365_mt6357_dais[] = { SND_SOC_DPCM_TRIGGER_POST }, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, .dpcm_merged_rate = 1, SND_SOC_DAILINK_REG(awb_capture), },
@@ -207,7 +207,7 @@ static struct snd_soc_dai_link mt8365_mt6357_dais[] = { SND_SOC_DPCM_TRIGGER_POST }, .dynamic = 1, - .dpcm_capture = 1, + .capture_only = 1, .dpcm_merged_rate = 1, SND_SOC_DAILINK_REG(vul), },
@@ -219,23 +219,19 @@ static struct snd_soc_dai_link mt8365_mt6357_dais[] = { .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS, - .dpcm_playback = 1, - .dpcm_capture = 1, SND_SOC_DAILINK_REG(i2s3), }, [DAI_LINK_DMIC] = { .name = "DMIC_BE", .no_pcm = 1, .id = DAI_LINK_DMIC, - .dpcm_capture = 1, + .capture_only = 1, SND_SOC_DAILINK_REG(dmic), }, [DAI_LINK_INT_ADDA] = { .name = "MTK_Codec", .no_pcm = 1, .id = DAI_LINK_INT_ADDA, - .dpcm_playback = 1, - .dpcm_capture = 1, .ops = &mt8365_mt6357_int_adda_ops, SND_SOC_DAILINK_REG(primary_codec), },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1008/1756 ASoC: mediatek: mt8188: Constrain UL8 FE to its back ends capabilities
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michał Kopeć <[email protected]>
[ Upstream commit 76775717c4adc283d5e7aed469468c8fa1ada4a7 ]
UL8 advertises up to 24 channels, but its only back end, ETDM1_IN, supports at most 16, and its bit clock is limited to 24.576 MHz. Without merged constraints, userspace can open UL8 with 48 kHz, 24 channels and 32-bit slots, which then fails in hw_params:
mtk_dai_etdm_configure bck rate 36864000 not support ASoC error (-22): at snd_soc_dai_hw_params() on ETDM1_IN
Set dpcm_merged_chan/rate/format, as the DL front ends already do, so the FE only offers configurations the back end can accept.
--- sound/soc/mediatek/mt8188/mt8188-mt6359.c | 3 +++ 1 file changed, 3 insertions(+)
sound/soc/mediatek/mt8188/mt8188-mt6359.c +3 -0
@@ -1089,6 +1089,9 @@ static struct snd_soc_dai_link mt8188_mt6359_dai_links[] = { }, .dynamic = 1, .capture_only = 1, + .dpcm_merged_chan = 1, + .dpcm_merged_rate = 1, + .dpcm_merged_format =1 , SND_SOC_DAILINK_REG(capture8), }, [DAI_LINK_UL9_FE] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1009/1756 nilfs2: reject non-regular inodes in dsync recovery
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jake Labelle <[email protected]>
[ Upstream commit ef2ccb1554df254eb4066171ce93e6d5fb1af2e3 ]
During roll-forward recovery, nilfs_recover_dsync_blocks() obtains the inode designated by fi_ino of a dsync log without checking its type. If a corrupted image designates a special inode (e.g. a device node) there, the inode's embedded bmap was never initialized:__nilfs_read_inode() calls nilfs_bmap_read() only for regular files, directories and symlinks. The subsequent nilfs_get_block() then dereferences the uninitialized bmap->b_ops and jumps through it, crashing the kernel or worse.
Regular files, directories, and symlinks are the only inode types with data blocks to recover; reject anything else before touching its block mapping.
[ryusuke: conformed AI tag to guidelines]
--- fs/nilfs2/recovery.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
fs/nilfs2/recovery.c +17 -0
@@ -519,6 +519,23 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs *nilfs, goto failed_inode; } +/* +* Regular files, directories, and symlinks are the only +* inode types with data blocks and an initialized bmap; +* a crafted image can reference some other inode type +* here, whose i_bmap_data was never set up by +* __nilfs_read_inode(). +*/ +if (!likely (S_ISREG (inode->i_mode) ||S_ISDIR (inode->i_mode) || +S_ISLNK (inode->i_mode))) { +nilfs_warn (sb, +"%s: invalid inode type (ino=%lu, mode=0%o)" , + __func__, (unsigned long )rb->ino, + inode->i_mode); + err = -EINVAL ; + goto failed_inode; + } + pos = rb->blkoff << inode->i_blkbits; err =block_write_begin (inode->i_mapping, pos, blocksize, &folio, nilfs_get_block);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1010/1756 cpufreq: qcom-cpufreq-hw: fix device node refcount leak in phandle parsing
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 6fa50b1988b8dfd2e92a9cecba073fe4347a5e23 ]
of_parse_phandle_with_args() transfers a reference to the provider node in out_args->np, which the caller is responsible for releasing with of_node_put(). Neither qcom_get_related_cpus() nor qcom_cpufreq_hw_cpu_init() ever puts args.np: they only put cpu_np, which is a different node obtained from of_cpu_device_node_get(). The reference is therefore leaked on every successful call, and qcom_get_related_cpus() leaks one per present CPU.
Release args.np after the parsed index has been read in both call sites.
--- drivers/cpufreq/qcom-cpufreq-hw.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/cpufreq/qcom-cpufreq-hw.c +3 -0
@@ -320,6 +320,8 @@ static void qcom_get_related_cpus(int index, struct cpumask *m)if (index == args.args[0 ])cpumask_set_cpu (cpu, m); + +of_node_put (args.np); } }
@@ -537,6 +539,7 @@ static int qcom_cpufreq_hw_cpu_init(struct cpufreq_policy *policy)return ret; index = args.args[0 ]; +of_node_put (args.np); data = &qcom_cpufreq.data[index];/* HW should be in enabled state to proceed */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1011/1756 xen/pcifront: Fix PCI device reference leak in AER handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 5d12c51bd98cdb5a32cbfb606963b05740ec42f2 ]
pci_get_domain_bus_and_slot() increments the reference count of the returned PCI device. pcifront_common_process() drops that reference only when the device or its driver is missing. All paths for a bound device either return directly after invoking an error recovery callback or fall through without calling pci_dev_put(). Consequently, each AER request for a bound device leaks a reference and can keep the device allocated after removal.
Declare the looked-up device with __free(pci_dev_put), so every return path releases the reference after callback dispatch. This keeps the device alive while its callback runs and balances the lookup without restructuring the callback returns.
This issue was found by a static analysis checker and confirmed by manual source review.
Message-ID: <[email protected]>
--- drivers/pci/xen-pcifront.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +2 -3
@@ -579,16 +579,15 @@ static pci_ers_result_t pcifront_common_process(int cmd,int bus = pdev->sh_info->aer_op.bus;int devfn = pdev->sh_info->aer_op.devfn;int domain = pdev->sh_info->aer_op.domain; -struct pci_dev *pcidev; + struct pci_dev *pcidev __free(pci_dev_put) = +pci_get_domain_bus_and_slot (domain, bus, devfn);dev_dbg (&pdev->xdev->dev,"pcifront AER process: cmd %x (bus:%x, devfn%x)" , cmd, bus, devfn); - pcidev =pci_get_domain_bus_and_slot (domain, bus, devfn);if (!pcidev || !pcidev->dev.driver) {dev_err (&pdev->xdev->dev,"device or AER driver is NULL\n" ); -pci_dev_put (pcidev);return PCI_ERS_RESULT_NONE ; } pdrv =to_pci_driver (pcidev->dev.driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1012/1756 xen/blkback: Prevent missed completion when draining I/O
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gui-Dong Han <[email protected]>
[ Upstream commit 9b4df0baa2aa03d22310e59846ca628f7afd4115 ]
xen_blk_drain_io() sets drain before checking inflight. xen_blkbk_unmap_and_respond_callback() decrements inflight with atomic_dec_and_test() before checking drain.
The pre-wait condition check was added to avoid missing a completion, but atomic_set() is unordered. With one I/O in flight, the drain path can set drain to 1 and read inflight as 1 before the completion decrement. The completion path then decrements inflight to 0 but can still read drain as
0. It skips complete(), so the drain path waits until the timeout despite no I/O remaining.
Add a full barrier between setting drain and reading inflight. atomic_dec_and_test() already provides full ordering on the completion side.
Message-ID: <[email protected]>
--- drivers/block/xen-blkback/blkback.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/block/xen-blkback/blkback.c +7 -0
@@ -1022,6 +1022,13 @@ static void xen_blk_drain_io(struct xen_blkif_ring *ring)struct xen_blkif *blkif = ring->blkif;atomic_set (&blkif->drain,1 ); +/* +* Publish drain before checking inflight. Otherwise, +* xen_blkbk_unmap_and_respond_callback() can decrement inflight with +* atomic_dec_and_test() and still see drain == 0 after this path saw +* inflight > 0, missing the completion. +*/ +smp_mb (); do { if (atomic_read(&ring->inflight) == 0) break;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1013/1756 x86/PVH: dont truncate initrd address/size
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jan Beulich <[email protected]>
[ Upstream commit fcc43d1d6bf5fbd41e1e308b17187f9b759df56a ]
Consuming merely the lower halves of the provided values isn't very useful. (While generally loaders try to place it below 4G, especially when it's huge it may not fit there.)
Message-ID: <[email protected]>
--- arch/x86/platform/pvh/enlighten.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/platform/pvh/enlighten.c +2 -0
@@ -83,7 +83,9 @@ static void __init init_pvh_bootparams(bool xen_guest)struct hvm_modlist_entry *modaddr =__va (pvh_start_info.modlist_paddr); pvh_bootparams.hdr.ramdisk_image = modaddr->paddr; + pvh_bootparams.ext_ramdisk_image = modaddr->paddr >>32 ; pvh_bootparams.hdr.ramdisk_size = modaddr->size; + pvh_bootparams.ext_ramdisk_size = modaddr->size >>32 ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1014/1756 gpu: buddy: Drop the stale @p line from the gpu_buddy_print() kernel-doc
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit b7027ff72c2fd4f7697a00b854c882445e9150b5 ]
gpu_buddy_print() takes only the allocator since commit ba110db8e1bc ("gpu: Move DRM buddy allocator one level up (part two)"), but the kernel-doc still describes a printer argument and kernel-doc warns about the excess parameter on every docs build.
Drop the line.
--- drivers/gpu/buddy.c | 1 - 1 file changed, 1 deletion(-)
drivers/gpu/buddy.c +0 -1
@@ -1291,7 +1291,6 @@ EXPORT_SYMBOL(gpu_buddy_block_print);* gpu_buddy_print - print allocator state * * @mm: GPU buddy manager -* @p: GPU printer to use */ void gpu_buddy_print (struct gpu_buddy *mm) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1015/1756 ALSA: caiaq: Fix races at MIDI URB and trigger accesses
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 52b1213e2a086f2828500ab9c8bac45b213429bb ]
URB completion and rawmidi trigger callbacks can race with each other, which may put the state inconsistent, causing double submissions, etc.
Guard both with a new spinlock for avoiding the races.
--- sound/usb/caiaq/device.c | 1 + sound/usb/caiaq/device.h | 3 ++- sound/usb/caiaq/midi.c | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-)
sound/usb/caiaq/device.c +1 -0
@@ -448,6 +448,7 @@ static int create_card(struct usb_device *usb_dev, cdev->chip.usb_id =USB_ID (le16_to_cpu (usb_dev->descriptor.idVendor),le16_to_cpu (usb_dev->descriptor.idProduct));spin_lock_init (&cdev->spinlock); +spin_lock_init (&cdev->midi_lock);mutex_init (&cdev->ep1_out_mutex); *cardp = card;
sound/usb/caiaq/device.h +2 -1
@@ -74,7 +74,8 @@ struct snd_usb_caiaqdev {unsigned char midi_out_buf[EP1_BUFSIZE ];struct caiaq_device_spec spec; -spinlock_t spinlock; +spinlock_t spinlock;/* for PCM audio */ +spinlock_t midi_lock;/* midi_x_stream, midi_out_active */ wait_queue_head_t ep1_wait_queue;wait_queue_head_t prepare_wait_queue;int spec_received, audio_parm_answer;
sound/usb/caiaq/midi.c +2 -0
@@ -79,6 +79,7 @@ static void snd_usb_caiaq_midi_output_trigger(struct snd_rawmidi_substream *subs {struct snd_usb_caiaqdev *cdev = substream->rmidi->private_data; +guard (spinlock_irqsave)(&cdev->midi_lock);if (up) { cdev->midi_out_substream = substream;if (!cdev->midi_out_active)
@@ -151,6 +152,7 @@ void snd_usb_caiaq_midi_output_done(struct urb* urb) {struct snd_usb_caiaqdev *cdev = urb->context; +guard (spinlock_irqsave)(&cdev->midi_lock); cdev->midi_out_active =0 ;if (urb->status !=0 )return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1016/1756 ALSA: usb: mixer: use snd_kcontrol_chip()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuninori Morimoto <[email protected]>
[ Upstream commit 3abd2e168d69c7bbd80a622112065e0577a8cca0 ]
We can use snd_kcontrol_chip(). Let's use it.
Stable-dep-of: 589fccbe1e9d ("ALSA: usb: us16x08: Fix racy accesses of mixer elements")
--- sound/usb/mixer.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
sound/usb/mixer.c +11 -11
@@ -547,7 +547,7 @@ int snd_usb_set_cur_mix_value(struct usb_mixer_elem_info *cval, int channel,int snd_usb_mixer_vol_tlv (struct snd_kcontrol *kcontrol,int op_flag,unsigned int size,unsigned int __user *_tlv) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);DECLARE_TLV_DB_MINMAX (scale,0 ,0 );if (size <sizeof (scale))
@@ -1389,7 +1389,7 @@ static int get_max_exposed(struct usb_mixer_elem_info *cval)static int mixer_ctl_feature_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);if (cval->val_type ==USB_MIXER_BOOLEAN || cval->val_type ==USB_MIXER_INV_BOOLEAN )
@@ -1421,7 +1421,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol,static int mixer_ctl_feature_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int c, cnt, val, err; ucontrol->value.integer.value[0 ] = cval->min;
@@ -1453,7 +1453,7 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol,static int mixer_ctl_feature_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int max_val =get_max_exposed (cval);int c, cnt, val, oval, err;int changed =0 ;
@@ -1502,7 +1502,7 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol,static int mixer_ctl_master_bool_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, err; err =snd_usb_get_cur_mix_value (cval,0 ,0 , &val);
@@ -1570,7 +1570,7 @@ static int get_connector_value(struct usb_mixer_elem_info *cval,static int mixer_ctl_connector_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int ret, val; ret =get_connector_value (cval, kcontrol->id.name, &val);
@@ -2382,7 +2382,7 @@ static int parse_audio_mixer_unit(struct mixer_build *state, int unitid,static int mixer_ctl_procunit_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int err, val; err =get_cur_ctl_value (cval, cval->control <<8 , &val);
@@ -2399,7 +2399,7 @@ static int mixer_ctl_procunit_get(struct snd_kcontrol *kcontrol,static int mixer_ctl_procunit_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, oval, err; err =get_cur_ctl_value (cval, cval->control <<8 , &oval);
@@ -2736,7 +2736,7 @@ static int parse_audio_extension_unit(struct mixer_build *state, int unitid,static int mixer_ctl_selector_info (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_info *uinfo) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);const char **itemlist = (const char **)kcontrol->private_value;if (snd_BUG_ON (!itemlist))
@@ -2748,7 +2748,7 @@ static int mixer_ctl_selector_info(struct snd_kcontrol *kcontrol,static int mixer_ctl_selector_get (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, err; err =get_cur_ctl_value (cval, cval->control <<8 , &val);
@@ -2765,7 +2765,7 @@ static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol,static int mixer_ctl_selector_put (struct snd_kcontrol *kcontrol,struct snd_ctl_elem_value *ucontrol) { -struct usb_mixer_elem_info *cval = kcontrol->private_data; +struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, oval, err; err =get_cur_ctl_value (cval, cval->control <<8 , &oval);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1017/1756 ALSA: usb-audio: Fix data race at mixer_ctl_feature_info()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit f701f6738de2d11e206a74d2a81465051dbf1ba3 ]
The info callback for USB-audio mixer controls for feature unit has a dynamic initialization of the contents with the check of cval->initialized flag. But, since the info callback may be concurrently called, this may lead to a data race, giving back an inconsistent state. Similarly, get and put callbacks may have concurrent accesses and can get bogus states.
For avoiding the data race, introduce a mutex locking for the controls and protect against concurrent info callback calls.
Stable-dep-of: 589fccbe1e9d ("ALSA: usb: us16x08: Fix racy accesses of mixer elements")
--- sound/usb/mixer.c | 14 +++++++++++++- sound/usb/mixer.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-)
sound/usb/mixer.c +13 -1
@@ -1391,6 +1391,7 @@ static int mixer_ctl_feature_info(struct snd_kcontrol *kcontrol, {struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol); +guard (mutex)(&cval->head.mixer->lock);if (cval->val_type ==USB_MIXER_BOOLEAN || cval->val_type ==USB_MIXER_INV_BOOLEAN ) uinfo->type =SNDRV_CTL_ELEM_TYPE_BOOLEAN ;
@@ -1424,6 +1425,7 @@ static int mixer_ctl_feature_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int c, cnt, val, err; +guard (mutex)(&cval->head.mixer->lock); ucontrol->value.integer.value[0 ] = cval->min;if (cval->cmask) { cnt =0 ;
@@ -1454,10 +1456,12 @@ static int mixer_ctl_feature_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) {struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol); -int max_val =get_max_exposed (cval); +int max_val;int c, cnt, val, oval, err;int changed =0 ; +guard (mutex)(&cval->head.mixer->lock); + max_val =get_max_exposed (cval);if (cval->cmask) { cnt =0 ;for (c =0 ; c <MAX_CHANNELS ; c++) {
@@ -1505,6 +1509,7 @@ static int mixer_ctl_master_bool_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, err; +guard (mutex)(&cval->head.mixer->lock); err =snd_usb_get_cur_mix_value (cval,0 ,0 , &val);if (err <0 )return filter_error (cval, err);
@@ -2385,6 +2390,7 @@ static int mixer_ctl_procunit_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int err, val; +guard (mutex)(&cval->head.mixer->lock); err =get_cur_ctl_value (cval, cval->control <<8 , &val);if (err <0 ) { ucontrol->value.integer.value[0 ] = cval->min;
@@ -2402,6 +2408,7 @@ static int mixer_ctl_procunit_put(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, oval, err; +guard (mutex)(&cval->head.mixer->lock); err =get_cur_ctl_value (cval, cval->control <<8 , &oval);if (err <0 )return filter_error (cval, err);
@@ -2751,6 +2758,7 @@ static int mixer_ctl_selector_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, err; +guard (mutex)(&cval->head.mixer->lock); err =get_cur_ctl_value (cval, cval->control <<8 , &val);if (err <0 ) { ucontrol->value.enumerated.item[0 ] =0 ;
@@ -2768,6 +2776,7 @@ static int mixer_ctl_selector_put(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *cval =snd_kcontrol_chip (kcontrol);int val, oval, err; +guard (mutex)(&cval->head.mixer->lock); err =get_cur_ctl_value (cval, cval->control <<8 , &oval);if (err <0 )return filter_error (cval, err);
@@ -3040,6 +3049,7 @@ static void snd_usb_mixer_free(struct usb_mixer_interface *mixer) }usb_free_urb (mixer->rc_urb);kfree (mixer->rc_setup_packet); +mutex_destroy (&mixer->lock);kfree (mixer); }
@@ -3682,6 +3692,8 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif)return -ENOMEM ; } +mutex_init (&mixer->lock); + mixer->hostif = &usb_ifnum_to_if (chip->dev, ctrlif)->altsetting[0 ];switch (get_iface_desc (mixer->hostif)->bInterfaceProtocol) {case UAC_VERSION_1 :
sound/usb/mixer.h +1 -0
@@ -18,6 +18,7 @@ struct usb_mixer_interface {struct usb_host_interface *hostif;struct list_head list;unsigned int ignore_ctl_error; +struct mutex lock;/* lock for feature unit callbacks */ /* UAC2 status interrupt endpoint; owned by mixer.c */ struct urb *urb;/* array[MAX_ID_ELEMS], indexed by unit id */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1018/1756 ALSA: usb: us16x08: Fix racy accesses of mixer elements
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 589fccbe1e9dd8aaf075cc073a7489c0c015ee49 ]
All get and put callbacks for us16x08 mixer have no proper protection, hence the concurrent accesses to multiple elements may face data races, resulting in unexpected values.
Put the new mixer->lock mutex for protecting the concurrent accesses.
--- sound/usb/mixer_us16x08.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
sound/usb/mixer_us16x08.c +16 -0
@@ -183,6 +183,7 @@ static int snd_us16x08_route_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *elem = kcontrol->private_data;int index = ucontrol->id.index; +guard (mutex)(&elem->head.mixer->lock);/* route has no bias */ ucontrol->value.enumerated.item[0 ] = elem->cache_val[index];
@@ -198,6 +199,7 @@ static int snd_us16x08_route_put(struct snd_kcontrol *kcontrol,char buf[sizeof (route_msg)];int val, val_org, err; +guard (mutex)(&elem->head.mixer->lock);/* get the new value (no bias for routes) */ val = ucontrol->value.enumerated.item[0 ];
@@ -252,6 +254,7 @@ static int snd_us16x08_master_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *elem = kcontrol->private_data;int index = ucontrol->id.index; +guard (mutex)(&elem->head.mixer->lock); ucontrol->value.integer.value[0 ] = elem->cache_val[index];return 0 ;
@@ -266,6 +269,7 @@ static int snd_us16x08_master_put(struct snd_kcontrol *kcontrol,int val, err;int index = ucontrol->id.index; +guard (mutex)(&elem->head.mixer->lock);/* new control value incl. bias*/ val = ucontrol->value.integer.value[0 ];
@@ -304,6 +308,7 @@ static int snd_us16x08_bus_put(struct snd_kcontrol *kcontrol, val = ucontrol->value.integer.value[0 ]; +guard (mutex)(&elem->head.mixer->lock);/* prepare the message buffer from template */ switch (elem->head.id) {case SND_US16X08_ID_BYPASS :
@@ -340,6 +345,7 @@ static int snd_us16x08_bus_get(struct snd_kcontrol *kcontrol, {struct usb_mixer_elem_info *elem = kcontrol->private_data; +guard (mutex)(&elem->head.mixer->lock);switch (elem->head.id) {case SND_US16X08_ID_BUSS_OUT : ucontrol->value.integer.value[0 ] = elem->cache_val[0 ];
@@ -362,6 +368,7 @@ static int snd_us16x08_channel_get(struct snd_kcontrol *kcontrol,struct usb_mixer_elem_info *elem = kcontrol->private_data;int index = ucontrol->id.index; +guard (mutex)(&elem->head.mixer->lock); ucontrol->value.integer.value[0 ] = elem->cache_val[index];return 0 ;
@@ -376,6 +383,7 @@ static int snd_us16x08_channel_put(struct snd_kcontrol *kcontrol,int val, err;int index = ucontrol->id.index; +guard (mutex)(&elem->head.mixer->lock); val = ucontrol->value.integer.value[0 ];/* sanity check */
@@ -422,6 +430,7 @@ static int snd_us16x08_comp_get(struct snd_kcontrol *kcontrol,int index = ucontrol->id.index;int val_idx =COMP_STORE_IDX (elem->head.id); +guard (mutex)(&elem->head.mixer->lock); ucontrol->value.integer.value[0 ] = store->val[val_idx][index];return 0 ;
@@ -439,6 +448,7 @@ static int snd_us16x08_comp_put(struct snd_kcontrol *kcontrol,int threshold, ratio, attack, release, gain, switch_on;int err; +guard (mutex)(&elem->head.mixer->lock); val = ucontrol->value.integer.value[0 ];/* sanity check */
@@ -515,6 +525,7 @@ static int snd_us16x08_eqswitch_get(struct snd_kcontrol *kcontrol,struct snd_us16x08_eq_store *store = elem->private_data;int index = ucontrol->id.index; +guard (mutex)(&elem->head.mixer->lock);/* get low switch from cache is enough, cause all bands are together */ val = store->val[EQ_STORE_BAND_IDX (elem->head.id)] [EQ_STORE_PARAM_IDX (elem->head.id)][index];
@@ -534,6 +545,7 @@ static int snd_us16x08_eqswitch_put(struct snd_kcontrol *kcontrol,int val, err =0 ;int b_idx; +guard (mutex)(&elem->head.mixer->lock);/* new control value incl. bias*/ val = ucontrol->value.integer.value[0 ] +SND_US16X08_KCBIAS (kcontrol);
@@ -576,6 +588,7 @@ static int snd_us16x08_eq_get(struct snd_kcontrol *kcontrol,int b_idx =EQ_STORE_BAND_IDX (elem->head.id) -1 ;int p_idx =EQ_STORE_PARAM_IDX (elem->head.id); +guard (mutex)(&elem->head.mixer->lock); val = store->val[b_idx][p_idx][index]; ucontrol->value.integer.value[0 ] = val;
@@ -595,6 +608,7 @@ static int snd_us16x08_eq_put(struct snd_kcontrol *kcontrol,int b_idx =EQ_STORE_BAND_IDX (elem->head.id) -1 ;int p_idx =EQ_STORE_PARAM_IDX (elem->head.id); +guard (mutex)(&elem->head.mixer->lock); val = ucontrol->value.integer.value[0 ];/* sanity check */
@@ -723,6 +737,7 @@ static int snd_us16x08_meter_get(struct snd_kcontrol *kcontrol,struct snd_us16x08_meter_store *store = elem->private_data;u8 meter_urb[64 ] = {0 }; +guard (mutex)(&elem->head.mixer->lock);switch (kcontrol->private_value) {case 0 : {char tmp[sizeof (mix_init_msg1)];
@@ -782,6 +797,7 @@ static int snd_us16x08_meter_put(struct snd_kcontrol *kcontrol,struct snd_us16x08_meter_store *store = elem->private_data;int val; +guard (mutex)(&elem->head.mixer->lock); val = ucontrol->value.integer.value[0 ];/* sanity check */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1019/1756 ALSA: line6: Reject too small max packet sizes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit e2ef553dfe923959632e580bcad8583d922868ac ]
Although the LINE6 driver has a sanity check for the given max packet sizes, it still has an implicit requirement of the minimal size being bytes-per-frame; e.g. the impulse test signal assuming the fixed size, and when a too small size is specified by a malformed USB descriptor, this may lead to an OOB access.
Change the sanity check conditions to reject too small max packet sizes for avoiding the scenario above.
--- sound/usb/line6/pcm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/usb/line6/pcm.c +5 -1
@@ -561,7 +561,11 @@ int line6_init_pcm(struct usb_line6 *line6, line6pcm->max_packet_size_out =usb_maxpacket (line6->usbdev,usb_sndisocpipe (line6->usbdev, ep_write)); -if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) { +/* reject max packet sizes smaller than bytes-per-frame; +* (the magic number 6 is taken from the playback case) +*/ +if (line6pcm->max_packet_size_in <6 || + line6pcm->max_packet_size_out <6 ) {dev_err (line6pcm->line6->ifcdev,"cannot get proper max packet size\n" );return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1020/1756 ALSA: line6: Fix potential OOB write in line6_capture_copy()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d69798357b5d562bcda1af488cda3ead4d039f8f ]
line6_capture_copy() copies the data for the original byte size, but the buffer overwrap is checked against the frame size. Because of it, when the data size isn't aligned in frames, the remaining bytes might be still copied above the buffer size.
For avoiding the potential OOB write, correct the copied data size in line6_capture_copy() to be aligned with frames.
--- sound/usb/line6/capture.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/usb/line6/capture.c +2 -1
@@ -129,7 +129,8 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) }else {/* copy single chunk */ memcpy (runtime->dma_area + - line6pcm->in.pos_done * bytes_per_frame, fbuf, fsize); + line6pcm->in.pos_done * bytes_per_frame, fbuf, + frames * bytes_per_frame); } line6pcm->in.pos_done += frames;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1021/1756 ALSA: hda: intel: Cancel delayed work at shutdown, too
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b83b78df0e53d9dd872d24e49a99658815b12770 ]
The shutdown procedure needs to cancel the delayed probe work in case where the probe work stalls or is slow but still possible to reactivated.
--- sound/pci/hda/hda_intel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +6 -1
@@ -2433,12 +2433,17 @@ static void azx_remove(struct pci_dev *pci)static void azx_shutdown (struct pci_dev *pci) {struct snd_card *card =pci_get_drvdata (pci); +struct hda_intel *hda;struct azx *chip;if (!card)return ; chip = card->private_data; -if (chip && chip->running) +if (!chip) +return ; + hda = container_of(chip, struct hda_intel, chip); +cancel_delayed_work_sync (&hda->probe_work); +if (chip->running)__azx_shutdown_chip (chip, true); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1022/1756 wifi: ath6kl: dont take RTNL in del_virtual_intf
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 97aab70a03df478ffefcf890ed4be258c0240bcb ]
cfg80211 already holds the RTNL here, so this will just deadlock. Remove the extra RTNL acquisition.
Oddly enough this was all true even back when the
locking here was added, so this is just a revert
of a broken ~13 year old commit.
--- drivers/net/wireless/ath/ath6kl/cfg80211.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/wireless/ath/ath6kl/cfg80211.c +0 -2
@@ -1551,9 +1551,7 @@ static int ath6kl_cfg80211_del_iface(struct wiphy *wiphy,ath6kl_cfg80211_vif_stop (vif,test_bit (WMI_READY , &ar->flag)); -rtnl_lock ();ath6kl_cfg80211_vif_cleanup (vif); -rtnl_unlock ();return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1023/1756 wifi: mac80211: clear fragment cache entry is_protected
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit f3d29dc9224b0881d10d34664456adf113bc4777 ]
In practice, we probably shouldn't end up with a fragmented frame that's protected, filled into the cache, finished or dropped and then the next frame is unprotected, since only unicast data frames can be fragmented.
However, tools complain and it's more correct to be able to do this (e.g. an unencrypted fragmented EAPOL _could_, at least in theory, happen), so clear the flag when the entry is reused.
--- net/mac80211/rx.c | 1 + 1 file changed, 1 insertion(+)
net/mac80211/rx.c +1 -0
@@ -2188,6 +2188,7 @@ ieee80211_reassemble_add(struct ieee80211_fragment_cache *cache, entry->rx_queue = rx_queue; entry->last_frag = frag; entry->check_sequential_pn = false; + entry->is_protected = false; entry->extra_len =0 ;return entry;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1024/1756 wifi: mac80211: mesh: use hlist_add_head_rcu()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 2ce8b78102e91c9d6536630cdef96491121c84d3 ]
The mesh paths walk list used under RCU, so we must use hlist_add_head_rcu() to publish an entry. Fix one place that didn't do that.
--- net/mac80211/mesh_pathtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +1 -1
@@ -712,7 +712,7 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, &new_mpath->rhash, mesh_rht_params);if (!mpath) -hlist_add_head (&new_mpath->walk_list, &tbl->walk_head); +hlist_add_head_rcu (&new_mpath->walk_list, &tbl->walk_head);spin_unlock_bh (&tbl->walk_lock);if (mpath) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1025/1756 wifi: mac80211: kill wake_txqs_tasklet on unregistration
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 8ea4f50c3426aaaf3f4c118ee2c2876326ca5db5 ]
We never kill the wake_txqs_tasklet so it could be running while the hardware is being freed. Kill it, late enough to never be able to restart afterwards.
--- net/mac80211/main.c | 2 ++ 1 file changed, 2 insertions(+)
net/mac80211/main.c +2 -0
@@ -1694,6 +1694,8 @@ void ieee80211_unregister_hw(struct ieee80211_hw *hw)cancel_work_sync (&local->restart_work); +tasklet_kill (&local->wake_txqs_tasklet); +ieee80211_clear_tx_pending (local);rate_control_deinitialize (local);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1026/1756 wifi: mac80211: init radiotap iter after length checks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e3cf8da7e0c560db67ac5ee8c9197514bb298ea7 ]
The radiotap iterator initialization will already parse the presence bitmaps, so it accesses a good part of the header. This might not be present in the linear part of the SKB, we haven't checked it at this point. Check the lengths first.
--- net/mac80211/tx.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/mac80211/tx.c +4 -3
@@ -2160,8 +2160,6 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,struct ieee80211_radiotap_header *rthdr = (struct ieee80211_radiotap_header *) skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb); -int ret =ieee80211_radiotap_iterator_init (&iterator, rthdr, skb->len, -NULL );u16 txflags;u16 rate =0 ;bool rate_found = false;
@@ -2170,11 +2168,14 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb,u8 mcs_known, mcs_flags, mcs_bw;u16 vht_known;u8 vht_mcs =0 , vht_nss =0 ; -int i; +int ret, i;if (!ieee80211_validate_radiotap_len (skb))return false; + ret =ieee80211_radiotap_iterator_init (&iterator, rthdr, skb->len, +NULL ); + info->flags |=IEEE80211_TX_INTFL_DONT_ENCRYPT |IEEE80211_TX_CTL_DONTFRAG ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1027/1756 wifi: mac80211: limit injected HT/VHT MCSes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 22d8e38161c722fe6e7ffb2a4c7fadab0f111271 ]
With radiotap injection the HT/VHT MCSes can be just about anything, but that can later get problematic.
Limit them to the rates the device reports, which is presumably going to be a subset of what mac80211 can do, except for HT MCS 32 which some devices report as supported, but then TX status can't deal with it.
If it's not supported just ignore the config.
--- net/mac80211/tx.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
net/mac80211/tx.c +30 -3
@@ -2151,6 +2151,27 @@ static bool ieee80211_rate_bw_usable(u16 rate_flags,return width <=cfg80211_chandef_get_width (chandef); } +static bool +ieee80211_vht_tx_rate_supported (const struct ieee80211_sta_vht_cap *vht_cap, +u8 mcs,u8 nss) +{ +u16 map =le16_to_cpu (vht_cap->vht_mcs.tx_mcs_map); + +if (!vht_cap->vht_supported) +return false; + +switch ((map >> (2 * (nss -1 ))) &3 ) { +case IEEE80211_VHT_MCS_SUPPORT_0_7 : +return mcs <=7 ; +case IEEE80211_VHT_MCS_SUPPORT_0_8 : +return mcs <=8 ; +case IEEE80211_VHT_MCS_SUPPORT_0_9 : +return mcs <=9 ; +default : +return false; + } +} +bool ieee80211_parse_tx_radiotap (struct sk_buff *skb,struct net_device *dev,const struct cfg80211_chan_def *chandef)
@@ -2345,14 +2366,20 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, hweight8(info->control.antennas)) info->control.antennas =0 ; - info->control.rates[0 ].idx = rate; +/* MCS 32 and up aren't handled, e.g. by TX status */ +if (sband && sband->ht_cap.ht_supported && rate <32 && + sband->ht_cap.mcs.rx_mask[rate /8 ] &BIT (rate %8 )) + info->control.rates[0 ].idx = rate; }else if (rate_flags &IEEE80211_TX_RC_VHT_MCS ) {/* reset antennas if not enough */ if (vht_nss >hweight8 (info->control.antennas)) info->control.antennas =0 ; -ieee80211_rate_set_vht (info->control.rates, vht_mcs, - vht_nss); +if (sband && +ieee80211_vht_tx_rate_supported (&sband->vht_cap, + vht_mcs, vht_nss)) +ieee80211_rate_set_vht (info->control.rates, + vht_mcs, vht_nss); }else if (sband) {for (i =0 ; i < sband->n_bitrates; i++) {if (rate *5 != sband->bitrates[i].bitrate)
Signature · 1 line
2.53.0
Quoted 9 lines · Greg Kroah-Hartman
This is the start of the stable review cycle for the 6.12.119 release. There are 1756 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Fri, 20 Nov 2026 14:55:44 +0000. Anything received after that time might be too late.
The whole patch series can be found in one patch at:
Quoted 8 lines
https://www.kernel.org/pub/linux/kernel/v6.x/stable-review/patch-6.12.119-rc1.gzor in the git tree and branch at:
git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.gitlinux-6.12.y
and the diffstat can be found below.thanks,
greg k-h
perf fails to build with:
util/annotate-data.c: In function 'global_var__collect':util/annotate-data.c:731:30: warning: implicit declaration of function 'die_get_type_die'; did you mean 'die_get_typename'? [-Wimplicit-function-declaration]
731 | if (!die_get_type_die(dwarf,pos->die_off, pos->die_tag,
| ^~~~~~~~~~~~~~~~
| die_get_typename
util/annotate-data.c:731:71: error: 'struct die_var_type' has no member named 'die_tag'
731 | if (!die_get_type_die(dwarf,
pos->die_off, pos->die_tag,
|
^~util/annotate-data.c:732:50: error: 'struct die_var_type' has no member named 'from_alt'
732 | pos->from_alt,&type_die))
| ^~util/annotate-data.c:743:44: error: 'struct die_var_type' has no member named 'from_alt'
743 | pos->from_alt);
| ^~util/annotate-data.c: In function 'get_global_var_type':util/annotate-data.c:801:26: warning: implicit declaration of function 'die_same_file' [-Wimplicit-function-declaration]
801 | !die_same_file(cu_die, type_die));
| ^~~~~~~~~~~~~util/annotate-data.c: In function 'update_var_state':util/annotate-data.c:839:42: error: 'struct die_var_type' has no member named 'die_tag'
839 | var->die_tag,var->from_alt, &mem_die))
| ^~util/annotate-data.c:839:56: error: 'struct die_var_type' has no member named 'from_alt'
839 | var->die_tag,var->from_alt, &mem_die))
| ^~
make[6]: *** [/local/users/fainelli/buildroot/output/arm/build/linux-custom/tools/build/Makefile.build:105: /local/users/fainelli/buildroot/output/arm/build/linux-custom/tools/perf/util/annotate-data.o] Error 1 make[6]: *** Waiting for unfinished jobs....
Signature · 1 line
Florian
Greg Kroah-Hartman
maintainerPATCH 1028/1756 wifi: mac80211: remove redundant null check in ieee80211_assign_beacon()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aloka Dixit <[email protected]>
[ Upstream commit 229cf0621950919c38a271ab3c07dfd41dd301d0 ]
The else-if branch condition 'old && old->mbssid_ies' already guarantees 'old' is non-NULL. The inner 'old &&' in 'if (old && old->rnr_ies)' is therefore redundant; remove it.
Stable-dep-of: baf0d4feed2f ("wifi: mac80211: fix mbssid/rnr allocation in beacon data")
--- net/mac80211/cfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/cfg.c +1 -1
@@ -1178,7 +1178,7 @@ ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata, }else if (old && old->mbssid_ies) { mbssid = old->mbssid_ies; size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); -if (old && old->rnr_ies) { +if (old->rnr_ies) { rnr = old->rnr_ies; size +=struct_size (new->rnr_ies, elem, rnr->cnt); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1029/1756 wifi: mac80211: fix mbssid/rnr allocation in beacon data
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit baf0d4feed2f0fed8e045f948534a4bd43ae464e ]
These structs are placed after the tail, but that can make them unaligned. Change the order so the structs are after one another, and then followed by the head/tail/elements.
--- net/mac80211/cfg.c | 53 +++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 22 deletions(-)
net/mac80211/cfg.c +31 -22
@@ -1141,6 +1141,7 @@ ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,struct beacon_data *new, *old;int new_head_len, new_tail_len;int size, err; +u8 *pos;u64 _changed =BSS_CHANGED_BEACON ;struct ieee80211_bss_conf *link_conf = link->conf;
@@ -1168,20 +1169,16 @@ ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,/* new or old multiple BSSID elements? */ if (params->mbssid_ies) { mbssid = params->mbssid_ies; - size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); -if (params->rnr_ies) { - rnr = params->rnr_ies; - size +=struct_size (new->rnr_ies, elem, rnr->cnt); - } - size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, - mbssid->cnt); + rnr = params->rnr_ies; }else if (old && old->mbssid_ies) { mbssid = old->mbssid_ies; + rnr = old->rnr_ies; + } + +if (mbssid) { size +=struct_size (new->mbssid_ies, elem, mbssid->cnt); -if (old->rnr_ies) { - rnr = old->rnr_ies; +if (rnr) size +=struct_size (new->rnr_ies, elem, rnr->cnt); - } size +=ieee80211_get_mbssid_beacon_len (mbssid, rnr, mbssid->cnt); }
@@ -1193,26 +1190,38 @@ ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,/* start filling the new info now */ /* -* pointers go into the block we allocated, -* memory is | beacon_data | head | tail | mbssid_ies | rnr_ies +* pointers go into the block we allocated, the order in memory is +* - struct beacon_data +* - struct mbssid_ies (including variable array) +* - struct rnr_ies (including variable array) +* - beacon head +* - beacon tail +* - mbssid/rnr elements +* so that the structs (which contain pointers) are all aligned */ - new->head = ((u8 *) new) +sizeof (*new); - new->tail = new->head + new_head_len; - new->head_len = new_head_len; - new->tail_len = new_tail_len; -/* copy in optional mbssid_ies */ + pos = (u8 *)(new +1 );if (mbssid) { -u8 *pos = new->tail + new->tail_len; - new->mbssid_ies = (void *)pos; pos +=struct_size (new->mbssid_ies, elem, mbssid->cnt); - pos +=ieee80211_copy_mbssid_beacon (pos, new->mbssid_ies, - mbssid);if (rnr) { new->rnr_ies = (void *)pos; pos +=struct_size (new->rnr_ies, elem, rnr->cnt); -ieee80211_copy_rnr_beacon (pos, new->rnr_ies, rnr); } + } + + new->head = pos; + new->head_len = new_head_len; + pos += new_head_len; + new->tail = pos; + new->tail_len = new_tail_len; + pos += new_tail_len; + +/* copy in optional mbssid_ies */ +if (mbssid) { + pos +=ieee80211_copy_mbssid_beacon (pos, new->mbssid_ies, + mbssid); +if (rnr) +ieee80211_copy_rnr_beacon (pos, new->rnr_ies, rnr);/* update bssid_indicator */ link_conf->bssid_indicator =ilog2 (__roundup_pow_of_two (mbssid->cnt +1 ));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1030/1756 wifi: cfg80211: reg: protect regdb pointer with RCU
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 298618f28bd3d1da677828354b504c12e2f375e4 ]
reg_query_regdb_wmm() is only used by iwlwifi, but even when it was introduced was already broken, as it reads the global db without any locking (drivers can't really guarantee any). Certainly iwlwifi doesn't since it calls it for FW messages. Therefore, it can race against regdb updates. The function uses a local pointer, but doesn't help.
Use RCU to protect the regdb pointer to fix that, and update the documentation to mention this (and do some cleanups).
--- include/net/cfg80211.h | 12 ++++++------ net/wireless/reg.c | 41 +++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 22 deletions(-)
include/net/cfg80211.h +6 -6
@@ -7412,20 +7412,20 @@ bool regulatory_pre_cac_allowed(struct wiphy *wiphy);*/ /** -* reg_query_regdb_wmm - Query internal regulatory db for wmm rule -* Regulatory self-managed driver can use it to proactively -* +* reg_query_regdb_wmm - Query internal regulatory db for WMM rules * @alpha2: the ISO/IEC 3166 alpha2 wmm rule to be queried. * @freq: the frequency (in MHz) to be queried. -* @rule: pointer to store the wmm rule from the regulatory db. +* @rule: pointer to store the WMM rule from the regulatory db. * -* Self-managed wireless drivers can use this function to query +* Self-managed wireless drivers can use this function to query * the internal regulatory database to check whether the given -* ISO/IEC 3166 alpha2 country and freq have wmm rule limitations. +* ISO/IEC 3166 alpha2 country and freq have WMM rule limitations. * * Drivers should check the return value, its possible you can get * an -ENODATA. * +* This uses RCU internally so can be called in just about any context. +* * Return: 0 on success. -ENODATA. */ int reg_query_regdb_wmm(char *alpha2, int freq,
net/wireless/reg.c +25 -16
130 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1031/1756 wifi: mac80211: use link address as TA for non-MLO 4-addr station on MLD AP
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit 07b3eb8b9048976b585d29f1a1df9a435423c473 ]
A 4-address AP_VLAN always sets A2 to sdata->vif.addr, which on an MLD AP is the AP MLD address. For a non-MLO station, A2 must be the link address it associated to.
Use the link address for a non-MLO station in the 4-address case as well, like the AP case already does in ieee80211_build_hdr() and ieee80211_check_fast_xmit(). Share the address selection between both cases and both TX paths.
--- net/mac80211/tx.c | 65 +++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 28 deletions(-)
net/mac80211/tx.c +37 -28
@@ -2692,6 +2692,29 @@ static void ieee80211_remove_ack_skb(struct ieee80211_local *local, u16 info_id)kfree_skb (ack_skb); } +static int ieee80211_ap_tx_addr_get (struct ieee80211_sub_if_data *sdata, +struct sta_info *sta,u8 *addr,u8 *link_id) +{ +struct ieee80211_link_data *link; + +if (!ieee80211_vif_is_mld (&sdata->vif) || sta->sta.mlo) { +memcpy (addr, sdata->vif.addr,ETH_ALEN ); +return 0 ; + } + +guard (rcu)(); + + link =rcu_dereference (sdata->link[sta->deflink.link_id]); +if (WARN_ON (!link)) +return -ENOLINK ; + +memcpy (addr, link->conf->addr,ETH_ALEN ); +if (link_id) + *link_id = sta->deflink.link_id; + +return 0 ; +} +/** * ieee80211_build_hdr - build 802.11 header in the given frame * @sdata: virtual interface to build the header for
@@ -2760,7 +2783,10 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata, fc |=cpu_to_le16 (IEEE80211_FCTL_FROMDS |IEEE80211_FCTL_TODS );/* RA TA DA SA */ memcpy (hdr.addr1, sta->sta.addr,ETH_ALEN ); -memcpy (hdr.addr2, sdata->vif.addr,ETH_ALEN ); + ret =ieee80211_ap_tx_addr_get (sdata, sta, hdr.addr2, + &link_id); +if (ret) + goto free;memcpy (hdr.addr3, skb->data,ETH_ALEN );memcpy (hdr.addr4, skb->data +ETH_ALEN ,ETH_ALEN ); hdrlen =30 ;
@@ -2785,18 +2811,12 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata,/* DA BSSID SA */ memcpy (hdr.addr1, skb->data,ETH_ALEN ); -if (ieee80211_vif_is_mld (&sdata->vif) && sta && !sta->sta.mlo) { -struct ieee80211_link_data *link; - - link_id = sta->deflink.link_id; - link =rcu_dereference (sdata->link[link_id]); -if (WARN_ON (!link)) { - ret = -ENOLINK ; +if (sta) { + ret =ieee80211_ap_tx_addr_get (sdata, sta, hdr.addr2, + &link_id); +if (ret) goto free; - } -memcpy (hdr.addr2, link->conf->addr,ETH_ALEN ); - }else if (link_id ==IEEE80211_LINK_UNSPECIFIED || - (sta && sta->sta.mlo)) { + }else if (link_id ==IEEE80211_LINK_UNSPECIFIED ) {memcpy (hdr.addr2, sdata->vif.addr,ETH_ALEN ); }else {struct ieee80211_bss_conf *conf;
@@ -3263,7 +3283,9 @@ void ieee80211_check_fast_xmit(struct sta_info *sta) IEEE80211_FCTL_TODS);/* RA TA DA SA */ memcpy (hdr->addr1, sta->sta.addr,ETH_ALEN ); -memcpy (hdr->addr2, sdata->vif.addr,ETH_ALEN ); +if (ieee80211_ap_tx_addr_get (sdata, sta, hdr->addr2, +NULL )) + goto out; build.da_offs = offsetof(struct ieee80211_hdr , addr3); build.sa_offs = offsetof(struct ieee80211_hdr , addr4); build.hdr_len =30 ;
@@ -3274,21 +3296,8 @@ void ieee80211_check_fast_xmit(struct sta_info *sta) fc |=cpu_to_le16 (IEEE80211_FCTL_FROMDS );/* DA BSSID SA */ build.da_offs = offsetof(struct ieee80211_hdr , addr1); -if (sta->sta.mlo || !ieee80211_vif_is_mld (&sdata->vif)) { -memcpy (hdr->addr2, sdata->vif.addr,ETH_ALEN ); - }else { -unsigned int link_id = sta->deflink.link_id; -struct ieee80211_link_data *link; - -rcu_read_lock (); - link =rcu_dereference (sdata->link[link_id]); -if (WARN_ON (!link)) { -rcu_read_unlock (); - goto out; - } -memcpy (hdr->addr2, link->conf->addr,ETH_ALEN ); -rcu_read_unlock (); - } +if (ieee80211_ap_tx_addr_get (sdata, sta, hdr->addr2,NULL )) + goto out; build.sa_offs = offsetof(struct ieee80211_hdr , addr3); build.hdr_len =24 ;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1032/1756 nvmem: layouts: sl28vpd: fix device_node reference leak in error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Cheng <[email protected]>
[ Upstream commit 73bd84aa58ad1fd775d6af2e8445a9456659c445 ]
sl28vpd_add_cells() takes a reference on the child node via of_get_child_by_name() for each entry and passes it to nvmem_add_one_cell() as info.np. On success the created cell entry adopts that reference and releases it later via of_node_put() when the entry is torn down; nvmem_add_one_cell() does not take its own reference. On failure it does not consume the reference either, so the caller still owns it, but the error path only puts layout_np before returning, leaking the child node reference.
Put info.np on the error path as well. of_node_put(NULL) is a no-op, so this is safe even when of_get_child_by_name() returned NULL.
--- drivers/nvmem/layouts/sl28vpd.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/layouts/sl28vpd.c +1 -0
@@ -126,6 +126,7 @@ static int sl28vpd_add_cells(struct nvmem_layout *layout) ret =nvmem_add_one_cell (nvmem, &info);if (ret) { +of_node_put (info.np);of_node_put (layout_np);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1033/1756 nvmem: layouts: onie-tlv: fix device_node reference leak in error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Cheng <[email protected]>
[ Upstream commit 9d44e80151dd360fad6155f36b6bfa57efb0f2f5 ]
onie_tlv_add_cells() takes a reference on the child node via of_get_child_by_name() for each parsed TLV and passes it to nvmem_add_one_cell() as cell.np. On success the created cell entry adopts that reference and releases it later via of_node_put(); on failure nvmem_add_one_cell() does not consume it, so the caller still owns it, but the error path only puts layout before returning, leaking the child node reference.
Put cell.np on the error path as well. of_node_put(NULL) is a no-op, so this is safe even when of_get_child_by_name() returned NULL.
--- drivers/nvmem/layouts/onie-tlv.c | 1 + 1 file changed, 1 insertion(+)
drivers/nvmem/layouts/onie-tlv.c +1 -0
@@ -128,6 +128,7 @@ static int onie_tlv_add_cells(struct device *dev, struct nvmem_device *nvmem, ret =nvmem_add_one_cell (nvmem, &cell);if (ret) { +of_node_put (cell.np);of_node_put (layout);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1034/1756 rtc: abx80x: fix error check after i2c_smbus_read in read_alarm()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 07c57022afb3afc0d7c20efef45a4d3c7389b1c0 ]
i2c_smbus_read_i2c_block_data() returns the number of bytes read on success and a negative error code on failure. The existing code treated any non-zero return value as an error.
Fix the error handling by checking only for negative return values.
--- drivers/rtc/rtc-abx80x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/rtc/rtc-abx80x.c +4 -2
@@ -294,8 +294,10 @@ static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t) err =i2c_smbus_read_i2c_block_data (client,ABX8XX_REG_ASC ,sizeof (buf), buf); -if (err) +if (err <0 )return err; +if (err <ARRAY_SIZE (buf)) +return -EIO ; irq_mask =i2c_smbus_read_byte_data (client,ABX8XX_REG_IRQ );if (irq_mask <0 )
@@ -311,7 +313,7 @@ static int abx80x_read_alarm(struct device *dev, struct rtc_wkalrm *t) t->enabled = !!(irq_mask &ABX8XX_IRQ_AIE ); t->pending = (buf[6 ] &ABX8XX_STATUS_AF ) && t->enabled; -return err; +return 0 ; }static int abx80x_set_alarm (struct device *dev,struct rtc_wkalrm *t)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1035/1756 rtc: abx80x: properly handle shared IRQs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antoni Pokusinski <[email protected]>
[ Upstream commit 632916c7bde35495f2f6776d8e335c3ec6e306ec ]
The abx80x RTC driver registers its interrupt handler with IRQF_SHARED, but the handler always returned IRQ_HANDLED and cleared the status register even when no interrupt source from the RTC was active.
This could cause the driver to claim interrupts belonging to other devices sharing the same IRQ line and could also clear unrelated status bits in the RTC status register.
Only handle the interrupt when the alarm or watchdog flags are set, and clear only those interrupt status bits that were handled. Return IRQ_NONE when the interrupt was not generated by the RTC.
--- drivers/rtc/rtc-abx80x.c | 52 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-)
drivers/rtc/rtc-abx80x.c +50 -2
@@ -50,12 +50,18 @@#define ABX8XX_CTRL2_RSVD BIT(5)#define ABX8XX_REG_IRQ 0x12 +#define ABX8XX_IRQ_EX1E BIT(0) +#define ABX8XX_IRQ_EX2E BIT(1)#define ABX8XX_IRQ_AIE BIT(2) +#define ABX8XX_IRQ_TIE BIT(3) +#define ABX8XX_IRQ_BLIE BIT(4)#define ABX8XX_IRQ_IM_1_4 (0x3 << 5)#define ABX8XX_REG_CD_TIMER_CTL 0x18#define ABX8XX_REG_OSC 0x1c +#define ABX8XX_OSC_ACIE BIT(0) +#define ABX8XX_OSC_OFIE BIT(1)#define ABX8XX_OSC_FOS BIT(3)#define ABX8XX_OSC_BOS BIT(4)#define ABX8XX_OSC_ACAL_512 BIT(5)
@@ -261,6 +267,7 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)struct i2c_client *client = dev_id;struct abx80x_priv *priv =i2c_get_clientdata (client);struct rtc_device *rtc = priv->rtc; +unsigned int status_flags_clear;int status; status =i2c_smbus_read_byte_data (client,ABX8XX_REG_STATUS );
@@ -277,9 +284,15 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id)if (status &ABX8XX_STATUS_WDT )dev_alert (&client->dev,"watchdog timeout interrupt.\n" ); -i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS ,0 ); + status_flags_clear = status & (ABX8XX_STATUS_AF |ABX8XX_STATUS_WDT ); -return IRQ_HANDLED ; +if (status_flags_clear) { +i2c_smbus_write_byte_data (client,ABX8XX_REG_STATUS , + status & ~status_flags_clear); +return IRQ_HANDLED ; + } + +return IRQ_NONE ; }static int abx80x_read_alarm (struct device *dev,struct rtc_wkalrm *t)
@@ -914,6 +927,41 @@ static int abx80x_probe(struct i2c_client *client)i2c_set_clientdata (client, priv); +/* Disable unused interrupts */ + data =i2c_smbus_read_byte_data (client,ABX8XX_REG_IRQ ); +if (data <0 ) { +dev_err (&client->dev,"Unable to read irq register\n" ); +return -EIO ; + } + + err =i2c_smbus_write_byte_data (client,ABX8XX_REG_IRQ , + data & ~(ABX8XX_IRQ_EX1E | +ABX8XX_IRQ_EX2E | +ABX8XX_IRQ_TIE | +ABX8XX_IRQ_BLIE )); +if (err <0 ) { +dev_err (&client->dev,"Unable to write irq register\n" ); +return -EIO ; + } + + data =i2c_smbus_read_byte_data (client,ABX8XX_REG_OSC ); +if (data <0 ) { +dev_err (&client->dev,"Unable to read Oscillator Control register\n" ); +return -EIO ; + } + +/* Unlock write access to Oscillator Control Register */ +if (abx80x_write_config_key (client,ABX8XX_CFG_KEY_OSC ) <0 ) +return -EIO ; + + err =i2c_smbus_write_byte_data (client,ABX8XX_REG_OSC , + data & ~(ABX8XX_OSC_ACIE | +ABX8XX_OSC_OFIE )); +if (err <0 ) { +dev_err (&client->dev,"Unable to write Oscillator Control register\n" ); +return -EIO ; + } +if (abx80x_caps[part].has_wdog) { err =abx80x_setup_watchdog (priv);if (err)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1036/1756 PCI/P2PDMA: Safely terminate ACS redirect lists
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit fa291d6429ebc1efb7fab011f643b842ae5f23f1 ]
seq_buf marks an overflow by setting len to size + 1. The ACS diagnostic path unconditionally writes a terminator to buffer[len - 1], so a path with enough ACS ports to fill the 128-byte buffer writes one byte beyond the buffer when verbose diagnostics are requested.
Use seq_buf_str() to terminate truncated output safely and remove the final semicolon only when the buffer did not overflow.
--- drivers/pci/p2pdma.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/p2pdma.c +4 -2
@@ -641,11 +641,13 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, }if (verbose) { - acs_list.buffer[acs_list.len-1 ] =0 ;/* drop final semicolon */ +/* Drop the final semicolon; the list is not empty here */ +if (!seq_buf_has_overflowed (&acs_list)) + acs_list.buffer[acs_list.len -1 ] ='\0' ;pci_warn (client,"ACS redirect is set between the client and provider (%s)\n" ,pci_name (provider));pci_warn (client,"to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n" , - acs_list.buffer); +seq_buf_str (&acs_list)); } acs_redirects = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1037/1756 PCI/P2PDMA: Gate the host bridge whitelist warning on verbose
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 36038f0e8377ef316b723d0d85b1510bc64069ab ]
calc_map_type_and_dist() prints every other diagnostic under its verbose argument, but reaches the "Host bridge not in P2PDMA whitelist" warning through host_bridge_whitelist(), which it hands acs_redirects instead. A caller that asked for a silent answer still gets the warning whenever any port on the path has an ACS redirect bit set, the CPU is not whitelisted by cpu_supports_p2pdma(), and the host bridge is not in pci_p2pdma_whitelist[].
pci_p2pmem_find_many() is such a caller. It sweeps every device with published p2pmem and asks for the distance to each client with verbose=false, and pci_p2pdma_distance_many() recomputes rather than consulting the map_types cache, so the warning repeats on every sweep.
The argument was never meant to say "ACS redirects were found". When commit cf201bfe8cdc ("PCI/P2PDMA: Warn if host bridge not in whitelist") added it, acs_redirects was a bool pointer that the quiet entry point passed as NULL:
if (verbose)
map = calc_map_type_and_dist_warn(provider, pci_client, &distance); else map = calc_map_type_and_dist(provider, pci_client, &distance, NULL, NULL);
so the argument was true on exactly the path that commit describes. Folding the two entry points into one verbose flag turned the pointer into a value and left the call site alone, silently narrowing the warning to paths that carry an ACS redirect.
Pass verbose. This also restores the warning for a verbose caller that takes the host bridge route with no ACS redirect on the path, which until now was told it could not use peer-to-peer DMA without being told which vendor and device would have to be added to the whitelist.
--- drivers/pci/p2pdma.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/p2pdma.c +1 -3
@@ -578,7 +578,6 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client, {enum pci_p2pdma_map_type map_type =PCI_P2PDMA_MAP_THRU_HOST_BRIDGE ;struct pci_dev *a = provider, *b = client, *bb; -bool acs_redirects = false;struct pci_p2pdma *p2pdma;struct seq_buf acs_list;int acs_cnt =0 ;
@@ -649,11 +648,10 @@ calc_map_type_and_dist(struct pci_dev *provider, struct pci_dev *client,pci_warn (client,"to disable ACS redirect for this path, add the kernel parameter: pci=disable_acs_redir=%s\n" ,seq_buf_str (&acs_list)); } - acs_redirects = true; map_through_host_bridge:if (!cpu_supports_p2pdma () && - !host_bridge_whitelist (provider, client, acs_redirects)) { + !host_bridge_whitelist (provider, client, verbose)) {if (verbose)pci_warn (client,"cannot be used for peer-to-peer DMA as the client and provider (%s) do not share an upstream bridge or whitelisted host bridge\n" ,pci_name (provider));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1038/1756 vfio/pci: Drain eventfd RCU callbacks on module exit
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 3b2e9b05011ee74543b6d17401bb02f1df3b93ff ]
vfio_pci_eventfd_replace_locked() defers freeing replaced eventfds to vfio_pci_eventfd_rcu_free(). A callback can remain queued after close_device() returns and the device driver module reference is dropped. Once the dependent driver is removed, vfio-pci-core can be unloaded while the callback still points into its module text.
Wait for outstanding RCU callbacks before vfio-pci-core exits.
--- drivers/vfio/pci/vfio_pci_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/vfio/pci/vfio_pci_core.c +1 -0
@@ -2613,6 +2613,7 @@ EXPORT_SYMBOL_GPL(vfio_pci_core_set_params);static void vfio_pci_core_cleanup (void ) {vfio_pci_uninit_perm_bits (); +rcu_barrier (); }static int __init vfio_pci_core_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1039/1756 kconfig: fix infinite loop in conf_choice() when no choice value is visible
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leizhen Zhang <[email protected]>
[ Upstream commit 52f26261e27dbdb7c6dea75d8f1a92ea805b2c58 ]
If a choice is visible but none of its choice values is, conf_choice() counts cnt == 0 visible values and finds no default. When the choice has to be asked, e.g. because a new symbol was added to the same menu (oldconfig, syncconfig) or because stdin is at EOF (oldaskconfig), the loop that maps the answer to a menu entry never finds one and the while (1) loop repeats forever, printing "choice[1-0?]: 0" each time.
This happens in the tree for s390 when the compiler supports none of the -march=z* options (e.g. a non-s390 host compiler), so that all values of the "Processor type" choice are invisible:
$ make ARCH=s390 defconfig $ sed -i '/^CONFIG_NR_CPUS=/d' .config $ make ARCH=s390 oldconfig # hangs
Before the removal of tristate choice support, conf_choice() returned early in this case. Do the same when there is no visible choice value.
Found by fuzzing Kconfig input with ASan/UBSan.
--- scripts/kconfig/conf.c | 3 +++ 1 file changed, 3 insertions(+)
scripts/kconfig/conf.c +3 -0
@@ -483,6 +483,9 @@ static void conf_choice(struct menu *menu) }printf ("\n" ); } +/* Nothing to ask if none of the choice values is visible. */ +if (!cnt) +return ;printf ("%*schoice" , indent -1 ,"" );if (cnt ==1 ) {printf ("[1]: 1\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1040/1756 clang-tools: Import os for broken pipe handling
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ting-Han Hou <[email protected]>
[ Upstream commit d26ab84593e63bc5395ed9b518502830fda3367c ]
The BrokenPipeError handler in run-clang-tools.py calls os.open() and os.dup2() without importing os. If this handler is reached, it raises NameError instead of redirecting stdout and exiting with status 1.
Import os so the handler can work as intended.
--- scripts/clang-tools/run-clang-tools.py | 1 + 1 file changed, 1 insertion(+)
scripts/clang-tools/run-clang-tools.py +1 -0
@@ -12,6 +12,7 @@ compile_commands.json. import argparse import json import multiprocessing +import os import subprocess import sys
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1041/1756 scripts/make_fit: Ignore schema checks when decomposing DTBs
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ting-Han Hou <[email protected]>
[ Upstream commit 3bf2237f59af842e546fa4b2c146198db95d1519 ]
With CHECK_DTBS enabled, Kbuild appends a schema validation command to the fdtoverlay command saved in a composite DTB's .cmd file. When DTB decomposition is requested, process_dtb() treats every word after -i as an input file, including the semicolon and the validator arguments. FIT generation then fails with FileNotFoundError while opening or checking the size of those words as files.
Limit the input list to the fdtoverlay command before extracting its arguments. This preserves the base DTB and overlay order and ignores the subsequent schema validation command.
--- scripts/make_fit.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/make_fit.py +2 -1
@@ -240,7 +240,8 @@ def process_dtb(fname, args): if 'scripts/dtc/fdtoverlay' in cmd: # This depends on the structure of the composite DTB command - files = cmd.split() + # Ignore any subsequent commands, such as schema validation + files = cmd.split(';', 1)[0].split() files = files[files.index('-i') + 1:] else: files = [fname]
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1042/1756 ALSA: hda: Add NULL check for the driver pointer at unsol event work
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 8cbf75d115e97b7f5ba7859d30d0ce74d1af6c19 ]
snd_hdac_bus_process_unsol_events() assumes that the codec driver is always set when it's accessible from the codec table. It's true in general, but in a sheer timing, it might have been already NULLified at the driver unbinding.
Although the codec removal should have been done properly by the previous fixes, just for more safety, let's add a NULL check before dereferencing and calling the driver's unsol_event callback.
--- sound/hda/hdac_bus.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
sound/hda/hdac_bus.c +6 -3
@@ -181,10 +181,13 @@ static void snd_hdac_bus_process_unsol_events(struct work_struct *work) codec = bus->caddr_tbl[caddr &0x0f ];if (!codec || !codec->registered)continue ; -spin_unlock_irq (&bus->reg_lock); +if (!codec->dev.driver) +continue ; drv =drv_to_hdac_driver (codec->dev.driver); -if (drv->unsol_event) - drv->unsol_event (codec, res); +if (!drv->unsol_event) +continue ; +spin_unlock_irq (&bus->reg_lock); + drv->unsol_event (codec, res);spin_lock_irq (&bus->reg_lock); }spin_unlock_irq (&bus->reg_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1043/1756 bpf: test_run: Fix false -EBADMSG after skb leaves CHECKSUM_COMPLETE
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxim Skokov <[email protected]>
[ Upstream commit 36edb1c7738dade8ed83ec4e0aef000e538b2095 ]
With BPF_F_TEST_SKB_CHECKSUM_COMPLETE, bpf_prog_test_run_skb() computes skb->csum over the packet from the network header to the end and marks the skb CHECKSUM_COMPLETE. After the program has run, it recomputes the checksum and returns -EBADMSG if it does not match skb->csum.
bpf_skb_change_tail() resizes the skb with __skb_trim_rcsum() and __skb_grow_rcsum(), which move a CHECKSUM_COMPLETE skb to CHECKSUM_NONE and leave skb->csum as it is. The post-run check still compares against that stale value, so a correct program fails with -EBADMSG. After a trim, skb->csum still covers the removed bytes. After a grow, later writes cannot update skb->csum, even with BPF_F_RECOMPUTE_CSUM, because skb->csum is only adjusted for CHECKSUM_COMPLETE skbs.
skb->csum only holds the packet checksum while ip_summed is CHECKSUM_COMPLETE. With CHECKSUM_NONE the stack does not rely on it and validates the packet in software, so there is nothing to compare. Only do the check if the skb is still CHECKSUM_COMPLETE after the run. A program that keeps the skb CHECKSUM_COMPLETE but leaves skb->csum stale still gets -EBADMSG.
Dropping the checksum offload is documented behaviour of bpf_skb_change_tail() ("implicitly linearizes, unclones and drops offloads"), and the stack does the same in other places, for example skb_forward_csum(). The test harness has to accept CHECKSUM_NONE either way, whether or not the helper is later taught to keep CHECKSUM_COMPLETE.
--- net/bpf/test_run.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/bpf/test_run.c +7 -1
@@ -1131,7 +1131,13 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,memset (__skb_push (skb, hh_len),0 , hh_len); } -if (kattr->test.flags &BPF_F_TEST_SKB_CHECKSUM_COMPLETE ) { +/* +* A helper such as bpf_skb_change_tail() may have downgraded the skb +* from CHECKSUM_COMPLETE. skb->csum is then unused by the stack and +* there is nothing to validate. +*/ +if ((kattr->test.flags &BPF_F_TEST_SKB_CHECKSUM_COMPLETE ) && + skb->ip_summed ==CHECKSUM_COMPLETE ) {const int off =skb_network_offset (skb);int len = skb->len - off;__wsum csum;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1044/1756 kbuild: Mark the initcall ordering recipe as recursive
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit ae5f6044c4cdffe2b3361b15c1d6fc67b339f2a4 ]
generate_initcall_order.pl, which orders initcalls for Clang LTO, forks a child per input file, up to the job count scripts/jobserver-exec passes it in PARALLELISM. It used to run from link-vmlinux.sh, which the top-level Makefile invokes as a recursive recipe, but commit 5d45950dfbb15 ("kbuild: move vmlinux.o link to scripts/Makefile.vmlinux_o") moved it into a recipe without "+".
GNU Make passes the jobserver pipe only to recipes it treats as recursive, and the make 4.3 in CentOS Stream 9 also hides it in sub-makes (a backport of the fix for GNU Make bug 58232), so jobserver-exec cannot open it and prints:
WARNING: Unable to reopen jobserver read-side pipe: FileNotFoundError(2, 'No such file or directory')
PARALLELISM is then left unset, and the script caps its children at the number of online CPUs instead of the free job slots.
Mark the recipe as recursive again (this makes "make -n" runs the script again too, as it did from link-vmlinux.sh). Masahiro posted the same change and withdrew it because the script was given only vmlinux.a, and so never ran more than one child [1]. But on arm64, LoongArch, and RISC-V with CONFIG_EFI_STUB, KBUILD_VMLINUX_LIBS also gives it the EFI stub's lib.a. Either way, the warning is silenced.
Tested ARCH=x86_64 defconfig with CONFIG_LTO_CLANG_THIN=y, LLVM=1 (Clang 24.0.0git), and GNU Make 4.3 plus CentOS Stream 9's make-4.3-cloexec.patch.
--- scripts/Makefile.vmlinux_o | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Makefile.vmlinux_o +1 -1
@@ -19,7 +19,7 @@ quiet_cmd_gen_initcalls_lds = GEN $@ .tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \ vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE - $(call if_changed,gen_initcalls_lds) + +$(call if_changed,gen_initcalls_lds) targets := .tmp_initcalls.lds
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1045/1756 bpf, riscv: Fix stack-passed arguments for indirect trampolines
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kumar Kartikeya Dwivedi <[email protected]>
[ Upstream commit b4a1ecae94ae803fcd75fb16a7653ff86b64ed8b ]
store_args() reads stack-passed arguments relative to FP assuming the trampoline was entered through the fentry call from a traced function. In that path, the trampoline pushes the parent frame before establishing its final FP, so the incoming stack arguments start at FP + 16.
An indirect trampoline for a struct_ops callback is called through a function pointer. Its prologue allocates only the trampoline frame and sets FP to the incoming SP. The RISC-V ABI places the first stack argument at that incoming SP, so the arguments start at FP, not FP + 16. Every stack-passed argument of a callback with more than eight argument slots is therefore read two slots late.
Pass the prologue-dependent offset to store_args(), using zero for a direct struct_ops trampoline and 16 for the fentry path.
--- arch/riscv/net/bpf_jit_comp64.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
arch/riscv/net/bpf_jit_comp64.c +10 -4
@@ -729,7 +729,8 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type poke_type,return ret; } -static void store_args (int nr_arg_slots,int args_off,struct rv_jit_context *ctx) +static void store_args (int nr_arg_slots,int args_off,int stack_args_off, +struct rv_jit_context *ctx) {int i;
@@ -737,8 +738,8 @@ static void store_args(int nr_arg_slots, int args_off, struct rv_jit_context *ctif (i <RV_MAX_REG_ARGS ) {emit_sd (RV_REG_FP , -args_off,RV_REG_A0 + i, ctx); }else { -/* skip slots for T0 and FP of traced function */ -emit_ld (RV_REG_T1 ,16 + (i -RV_MAX_REG_ARGS ) *8 ,RV_REG_FP , ctx); +emit_ld (RV_REG_T1 , stack_args_off + + (i -RV_MAX_REG_ARGS ) *8 ,RV_REG_FP , ctx);emit_sd (RV_REG_FP , -args_off,RV_REG_T1 , ctx); } args_off -=8 ;
@@ -973,7 +974,12 @@ static int __arch_prepare_bpf_trampoline(struct bpf_tramp_image *im,emit_li (RV_REG_T1 , nr_arg_slots, ctx);emit_sd (RV_REG_FP , -nregs_off,RV_REG_T1 , ctx); -store_args (nr_arg_slots, args_off, ctx); +/* +* A direct struct_ops call has its first stack argument at the incoming +* SP, which the trampoline keeps as FP. The fentry path pushes the +* parent frame first, so its incoming stack arguments start at FP + 16. +*/ +store_args (nr_arg_slots, args_off, is_struct_ops ?0 :16 , ctx);/* skip to actual body of traced function */ if (flags &BPF_TRAMP_F_SKIP_FRAME )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1046/1756 xhci: dbc: lock the minor IDR on registration failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sang-Hoon Choi <[email protected]>
[ Upstream commit 47f4e983b5de7616fb11d5f537fc9a605387d136 ]
dbc_tty_minors is protected by dbc_tty_minors_lock when entries are allocated and during normal device removal. The registration error path removes an entry without taking that lock. Different DbC instances have separate event work items, so this removal can race with an IDR update for another instance.
Take the same mutex around the error-path removal.
--- drivers/usb/host/xhci-dbgtty.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/usb/host/xhci-dbgtty.c +2 -0
@@ -503,7 +503,9 @@ static int xhci_dbc_tty_register_device(struct xhci_dbc *dbc) err_free_fifo:kfifo_free (&port->port.xmit_fifo); err_exit_port: +mutex_lock (&dbc_tty_minors_lock);idr_remove (&dbc_tty_minors, port->minor); +mutex_unlock (&dbc_tty_minors_lock); err_idr:xhci_dbc_tty_exit_port (port);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1047/1756 mailbox: pcc: Free the channel before unmapping the shared memory
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Breno Leitao <[email protected]>
[ Upstream commit 4ac21f3fac3e8584fd395c59044a8e99ac618572 ]
I am seeing a crash on PCC that is related to a an shared memory being unmapped before the IRQ is disabled, and the IRQ kicks in and hits the unmapped (NULL) address. This is a summary of what I see on my box:
scmi_protocol scmi_dev.1: Message for 1 type 0 is not expected! Unable to handle kernel NULL pointer dereference at virtual address 0000000000000004 __handle_irq_event_percpu+0x1c4/0x9e0 handle_irq_event+0x98/0x218 handle_fasteoi_irq+0x230/0x750 generic_handle_domain_irq+0xac/0x138 gic_handle_irq+0x344/0x740 call_on_irq_stack+0x30/0x48
The trapping store is iowrite32(SCMI_SHMEM_FLAG_INTR_ENABLED, &shmem->header.flags), a write of 1 at offset 4 of a NULL base.
But, back to the problem, pcc_mbox_free_channel() unmaps the shared memory and clears pchan->chan.shmem *before* freeing the IRQ (aka calling mbox_free_channel()).
The interrupt is still live when the mapping goes away.
Free the channel first, before the memory unmap. mbox_free_channel() calls pcc_shutdown(), which frees the platform interrupt, and then unmap shared memory.
--- drivers/mailbox/pcc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/mailbox/pcc.c +3 -2
@@ -422,12 +422,13 @@ void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan)return ; pchan_info = chan->con_priv; pcc_mbox_chan = &pchan_info->chan; + +mbox_free_channel (chan); +if (pcc_mbox_chan->shmem) {iounmap (pcc_mbox_chan->shmem); pcc_mbox_chan->shmem =NULL ; } - -mbox_free_channel (chan); }EXPORT_SYMBOL_GPL (pcc_mbox_free_channel);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1048/1756 mailbox: ti-msgmgr: Read exact number of trailing message bytes
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Beleswar Padhi <[email protected]>
[ Upstream commit 645ae2edd5597501b4af3837a644877fbe194227 ]
ti_msgmgr_send_data() copies the message to the data registers in u32 units. This has been harmless so far because the clients (TI-SCI) always passed its preallocated message buffer, which is sized to the maximum message size (60 or 64 bytes, a multiple of 4), so the extra bytes read were still within the buffer. But, with a later TI-SCI update, the message size can be varying now and not guaranteed to be a multiple of 4, which would trigger KASAN out-of-bounds reports.
Therefore, memcpy() only the trailing bytes into a zeroed u32 before writing it to the register. This is at most 3 bytes, so the overhead is negligible.
--- drivers/mailbox/ti-msgmgr.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/mailbox/ti-msgmgr.c +10 -4
@@ -20,6 +20,7 @@#include <linux/platform_device.h> #include <linux/property.h> #include <linux/soc/ti/ti-msgmgr.h> +#include <linux/string.h> #define Q_DATA_OFFSET (proxy, queue, reg) \ ((0x10000 * (proxy)) + (0x80 * (queue)) + ((reg) * 4))
@@ -425,10 +426,15 @@ static int ti_msgmgr_send_data(struct mbox_chan *chan, void *data) trail_bytes = message->len %sizeof (u32);if (trail_bytes) { -u32 data_trail = *word_data; - -/* Ensure all unused data is 0 */ - data_trail &=0xFFFFFFFF >> (8 * (sizeof (u32) - trail_bytes)); +/* +* Copy only the trailing bytes instead of reading a full u32, +* as the message buffer may end right after them and a u32 +* read would go past the end of it. This also leaves all +* unused data as 0. +*/ +u32 data_trail =0 ; + +memcpy (&data_trail, word_data, trail_bytes);writel (data_trail, data_reg); data_reg +=sizeof (u32); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1049/1756 mailbox: arm_mhuv2: time out if the receiver never comes up
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 86976f7cc324aac254136a352f74ac17f21e574c ]
mhuv2_tx_init() waits forever for access_ready. Fail probe after 1s instead of hanging boot.
--- drivers/mailbox/arm_mhuv2.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/mailbox/arm_mhuv2.c +7 -2
@@ -27,6 +27,7 @@#include <linux/amba/bus.h> #include <linux/interrupt.h> +#include <linux/iopoll.h> #include <linux/mailbox_controller.h> #include <linux/mailbox/arm_mhuv2_message.h> #include <linux/module.h>
@@ -968,6 +969,7 @@ static int mhuv2_tx_init(struct amba_device *adev, struct mhuv2 *mhu, {struct device *dev = mhu->mbox.dev;int ret, i; +u32 val; mhu->frame =SENDER_FRAME ; mhu->mbox.ops = &mhuv2_sender_ops;
@@ -1011,8 +1013,11 @@ static int mhuv2_tx_init(struct amba_device *adev, struct mhuv2 *mhu, out:/* Wait for receiver to be ready */ writel_relaxed (0x1 , &mhu->send->access_request); -while (!readl_relaxed (&mhu->send->access_ready)) -continue ; +if (readl_relaxed_poll_timeout (&mhu->send->access_ready, val, val, +100 ,1000000 )) { +dev_err (dev,"receiver not ready\n" ); +return -ETIMEDOUT ; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1050/1756 mailbox: qcom-ipcc: remove stray disable_irq_wake() call
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anup Vishwakarma <[email protected]>
[ Upstream commit 134ef0278d4e48bcc325a7699250dfe861c11953 ]
Commit afaf2ba5b430 ("mailbox: qcom-ipcc: Support interrupt wake up from suspend") replaced enable_irq_wake() with IRQF_NO_SUSPEND on the IRQ request, but left the paired disable_irq_wake() in remove() behind.
disable_irq_wake() decrements the IRQ's wake_depth. With no matching enable_irq_wake() left to increment it, wake_depth stays at 0 and irq_set_irq_wake() reports:
WARN(1, "Unbalanced IRQ %d wake disable\n", irq)
on every unbind. Since there is no enable_irq_wake() to pair it with, remove the stray disable_irq_wake() call; IRQF_NO_SUSPEND already provides the intended wake behaviour.
--- drivers/mailbox/qcom-ipcc.c | 1 - 1 file changed, 1 deletion(-)
drivers/mailbox/qcom-ipcc.c +0 -1
@@ -341,7 +341,6 @@ static void qcom_ipcc_remove(struct platform_device *pdev) {struct qcom_ipcc *ipcc =platform_get_drvdata (pdev); -disable_irq_wake (ipcc->irq);irq_domain_remove (ipcc->irq_domain); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1051/1756 ALSA: timer: Pin the module for userspace timer controllers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit f9e882ac8257bc55a8c99399e504e434d9e72eb9 ]
The static snd_utimer_ids IDA must remain live until a userspace timer controller has returned its ID. However, snd_utimer_fops has no owner, so anon_inode_getfd() does not take a reference to snd-timer for the controller file.
With CONFIG_SND_TIMER=m and CONFIG_SND_UTIMER=y, userspace can create a controller with SNDRV_TIMER_IOCTL_CREATE and close the native timer file. If no timer instances or dependent modules retain snd-timer, ordinary module unload can then overlap the controller's final release:
Controller final release Module unload
snd_utimer_release()
snd_utimer_free()
snd_timer_free(): unlink provider
snd_utimer_put_id()
enter ida_free()
delete_module()
alsa_timer_exit() free_module(): free MOD_DATA
access snd_utimer_ids.xa
The provider is already absent from snd_timer_free_all() when unload runs. Neither register_mutex nor the IDA's lock keeps module storage resident through the remaining IDA access. That access can therefore use freed module data and fault while acquiring the XArray lock, as shown in the Oops below.
Set snd_utimer_fops.owner to THIS_MODULE so anonymous-file creation takes the existing module reference. The VFS drops it only after snd_utimer_release() returns, keeping the IDA resident through ida_free() and preventing ordinary unload during that interval.
Oops report as below:
BUG: unable to handle page fault for address: fffffbfff80480af
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 1a7ff6067 P4D 1a7ff6067 PUD 1a7ff2067 PMD 100ad6067 PTE 0
Oops: Oops: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 485 Comm: alsa-utimer-fix Tainted: G O 7.2.0-rc6-pmb-bt-functional-v1+ #1 PREEMPT(lazy)
Tainted: [O]=OOT_MODULE
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:kasan_byte_accessible+0x15/0x30
Code: 00 00 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 40 d6 48 b8 00 00 00 00 00 fc ff df 48 c1 ef 03 48 01 c7 <0f> b6 07 3c 07 0f 96 c0 e9 69 f1 2b ff 66 66 2e 0f 1f 84 00 00 00
RSP: 0018:ffff88811a457c48 EFLAGS: 00010086
RAX: dffffc0000000000 RBX: ffffffffc0240578 RCX: 0000000000000000
RDX: 0000000000000000 RSI: ffffffff861f111c RDI: fffffbfff80480af
RBP: ffffffffc0240578 R08: 0000000000000001 R09: 0000000000000000
R10: ffffffff891cc057 R11: ffff88811531ba00 R12: ffffffff861f111c
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS: 00007ff190ff7780(0000) GS:ffff8881fda2a000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: fffffbfff80480af CR3: 0000000116890003 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
__kasan_check_byte+0x13/0x50
lock_acquire+0x113/0x2f0
? __pfx_pmbd_probe_hit_cookie+0x10/0x10
? lock_release+0xc8/0x280
? srso_alias_return_thunk+0x5/0xfbef5
_raw_spin_lock_irqsave+0x3c/0x60
? ida_free+0xd4/0x2b0
ida_free+0xd4/0x2b0
? __pfx_ida_free+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __pfx_locks_remove_file+0x10/0x10
? __fput+0x39f/0xa60
? fput_close_sync+0xff/0x200
? __pfx_fput_close_sync+0x10/0x10
? dnotify_flush+0x22/0x4b0
? __x64_sys_close+0x8c/0xf0
? do_syscall_64+0x115/0x6a0
? entry_SYSCALL_64_after_hwframe+0x77/0x7f
</TASK>
Modules linked in: snd(O) [last unloaded: snd_timer(O)]
CR2: fffffbfff80480af
---[ end trace 0000000000000000 ]------ sound/core/timer.c | 1 + 1 file changed, 1 insertion(+)
sound/core/timer.c +1 -0
@@ -2101,6 +2101,7 @@ static long snd_utimer_ioctl(struct file *file, unsigned int ioctl, unsigned lon }static const struct file_operations snd_utimer_fops = { + .owner =THIS_MODULE , .llseek = noop_llseek, .release = snd_utimer_release, .unlocked_ioctl = snd_utimer_ioctl,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1052/1756 ALSA: virtio: reset I/O message fill level on prepare
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ting-Han Hou <[email protected]>
[ Upstream commit f0e9db0f84249b65a72b5fba43e91212281ad378 ]
Since commit fe981e67568c ("ALSA: virtio: use ack callback"), an I/O message is only queued to the device once the application has filled the whole period: virtsnd_pcm_msg_send() accumulates the transferred bytes in msg->length and queues the message when it reaches period_bytes. msg->length is reset to 0 only when the device completes the message.
If the substream is stopped (e.g. snd_pcm_drop()) while a period is only partially filled, the corresponding message is never queued and keeps its partial length. virtsnd_pcm_prepare() resets msg_count, hw_ptr and the indirect PCM state, but not msg->length. After the next start, the stale length is added to the new data, the sum never equals period_bytes, and the message is never sent again. Playback then stalls once hw_ptr reaches that period: writes fail with -EIO ("DMA or IRQ trouble") and drain fails with -EIO. Capture is affected the same way after a partial read.
Clear the fill level of all messages in prepare. Outside of the resume path, virtsnd_pcm_prepare() already refuses to run while I/O messages are pending, so no message is owned by the device at this point and the reset does not race with message completion.
Reproduced in QEMU (virtio-sound-pci, wav audiodev): prepare, write 1.5 periods, drop, prepare, write 16 full periods, drain. Without this patch WRITEI returns -EIO after 14 periods and DRAIN fails; with it all 16 periods are played and DRAIN succeeds. Period-aligned prefill works in both cases. The same sequence on capture (read 1.5 periods, drop, prepare, read 16 periods) fails with -EIO after 10 periods without this patch and reads all 16 with it.
Found by code inspection, confirmed with the reproducer above.
--- sound/virtio/virtio_pcm.h | 2 ++ sound/virtio/virtio_pcm_msg.c | 19 +++++++++++++++++++ sound/virtio/virtio_pcm_ops.c | 1 + 3 files changed, 22 insertions(+)
sound/virtio/virtio_pcm.h +2 -0
@@ -119,6 +119,8 @@ int virtsnd_pcm_msg_alloc(struct virtio_pcm_substream *vss,void virtsnd_pcm_msg_free (struct virtio_pcm_substream *vss); +void virtsnd_pcm_msg_reset (struct virtio_pcm_substream *vss); +int virtsnd_pcm_msg_send (struct virtio_pcm_substream *vss,unsigned long offset,unsigned long bytes);
sound/virtio/virtio_pcm_msg.c +19 -0
@@ -182,6 +182,25 @@ void virtsnd_pcm_msg_free(struct virtio_pcm_substream *vss) vss->nmsgs =0 ; } +/** +* virtsnd_pcm_msg_reset() - Reset the fill level of all I/O messages. +* @vss: VirtIO PCM substream. +* +* Messages that were only partially filled by the application when the +* substream was stopped are never sent to the device, so their length must be +* cleared before the substream is started again. +* +* Context: Any context. Takes and releases the VirtIO substream spinlock. +*/ +void virtsnd_pcm_msg_reset (struct virtio_pcm_substream *vss) +{ +unsigned int i; + +guard (spinlock_irqsave)(&vss->lock); +for (i =0 ; vss->msgs && i < vss->nmsgs; ++i) + vss->msgs[i]->length =0 ; +} +/** * virtsnd_pcm_msg_send() - Send asynchronous I/O messages. * @vss: VirtIO PCM substream.
sound/virtio/virtio_pcm_ops.c +1 -0
@@ -299,6 +299,7 @@ static int virtsnd_pcm_prepare(struct snd_pcm_substream *substream) vss->xfer_xrun = false; vss->suspended = false; vss->msg_count =0 ; +virtsnd_pcm_msg_reset (vss);memset (&vss->pcm_indirect,0 ,sizeof (vss->pcm_indirect)); vss->pcm_indirect.sw_buffer_size =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1053/1756 RDMA/mlx5: Cancel deferred page-fault EQ work before teardown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prathamesh Deshpande <[email protected]>
[ Upstream commit aea64024ac37d29e99b82b315a56a9145dc0bc23 ]
Page-fault EQ work can remain queued after the notifier is disabled. Destroying the EQ before cancelling that work can let the worker access freed EQ memory.
Cancel the deferred work before destroying the EQ.
--- drivers/infiniband/hw/mlx5/odp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/odp.c +1 -1
@@ -1843,8 +1843,8 @@ mlx5_ib_odp_destroy_eq(struct mlx5_ib_dev *dev, struct mlx5_ib_pf_eq *eq)if (!eq->core)return 0 ;mlx5_eq_disable (dev->mdev, eq->core, &eq->irq_nb); - err =mlx5_eq_destroy_generic (dev->mdev, eq->core);cancel_work_sync (&eq->work); + err =mlx5_eq_destroy_generic (dev->mdev, eq->core);destroy_workqueue (eq->wq);mempool_destroy (eq->pool);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1054/1756 RDMA/mlx5: Support driver APIs pre_destroy_cq and post_destroy_cq
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Zhang <[email protected]>
[ Upstream commit b5eeb8365d196c95dbb0fd0a5b5a69a44832f16f ]
- pre_destroy_cq: Destroy FW CQ object so that no new CQ event would
be generated;
- post_destroy_cq: Release all resources.
This patch, along with last one, fixes the crash below.
Unable to handle kernel paging request at virtual address ffff8000114b1180 Mem abort info: ESR = 0x96000047 EC = 0x25: DABT (current EL), IL = 32 bits SET = 0, FnV = 0 EA = 0, S1PTW = 0 Data abort info: ISV = 0, ISS = 0x00000047 CM = 0, WnR = 1 swapper pgtable: 4k pages, 48-bit VAs, pgdp=00000000f4582000 [ffff8000114b1180] pgd=00000447fffff003, p4d=00000447fffff003, pud=00000447ffffe003, pmd=00000447ffffb003, pte=0000000000000000 Internal error: Oops: 96000047 [#1] SMP Modules linked in: udp_diag uio_pci_generic uio tcp_diag inet_diag binfmt_misc sn_core_odd(OE) rpcrdma(OE) xprtrdma(OE) ib_isert(OE) ib_iser(OE) ib_srpt(OE) ib_srp(OE) ib_ipoib(OE) kpatch_9658536(OK) kpatch_9322385(OK) kpatch_8843421(OK) kpatch_8636216(OK) vfat fat aes_ce_blk crypto_simd cryptd aes_ce_cipher crct10dif_ce ghash_ce sm4_ce sha2_ce sha256_arm64 sha1_ce sbsa_gwdt sg acpi_ipmi ipmi_si ipmi_msghandler m1_uncore_ddrss_pmu m1_uncore_cmn_pmu team_yosemite9rc6(OE) vnic(OE) ip_tables mlx5_ib(OE) sd_mod ast mlx5_core(OE) i2c_algo_bit drm_vram_helper psample drm_kms_helper mlxdevm(OE) auxiliary(OE) mlxfw(OE) syscopyarea sysfillrect tls sysimgblt fb_sys_fops drm_ttm_helper nvme ttm nvme_core drm t10_pi i2c_designware_platform i2c_designware_core i2c_core ahci libahci libata rdma_ucm(OE) ib_uverbs(OE) rdma_cm(OE) iw_cm(OE) ib_cm(OE) ib_umad(OE) ib_core(OE) ib_ucm(OE) mlx_compat(OE) [last unloaded: ipmi_devintf] CPU: 83 PID: 59375 Comm: kworker/u253:1 Kdump: loaded Tainted: G OE K 5.10.84-004.ali5000.alios7.aarch64 #1 Hardware name: Inspur AliServer-Xuanwu2.0AM-02-2UM1P-5B/AS1221MG1, BIOS 1.2.M1.AL.P.158.00 08/31/2023 Workqueue: ib-comp-unb-wq ib_cq_poll_work [ib_core] pstate: 82c00089 (Nzcv daIf +PAN +UAO +TCO BTYPE=--) pc : native_queued_spin_lock_slowpath+0x1c4/0x31c lr : mlx5_ib_poll_cq+0x18c/0x2f8 [mlx5_ib] sp : ffff80002be1bc80 x29: ffff80002be1bc80 x28: ffff000810e69000 x27: ffff000810e69000 x26: ffff000810e69200 x25: 0000000000000000 x24: ffff8000117db000 x23: ffff04000156b780 x22: 0000000000000000 x21: ffff04000ce6c160 x20: ffff0008196a4000 x19: 0000000000000010 x18: 0000000000000020 x17: 0000000000000000 x16: 0000000000000000 x15: ffff040055a364e8 x14: ffffffffffffffff x13: ffff80002318bda8 x12: ffff0400358836e8 x11: 0000000000000040 x10: 0000000000000eb0 x9 : 0000000000000000 x8 : 0000000000000000 x7 : ffff04477fa20140 x6 : ffff8000114b1140 x5 : ffff04477fa20140 x4 : ffff8000114b1180 x3 : ffff000810e69200 x2 : ffff8000114b1180 x1 : 0000000001500000 x0 : ffff04477fa20148 Call trace: native_queued_spin_lock_slowpath+0x1c4/0x31c __ib_process_cq+0x74/0x1b8 [ib_core] ib_cq_poll_work+0x34/0xa0 [ib_core] process_one_work+0x1d8/0x4b0 worker_thread+0x180/0x440 kthread+0x114/0x120 Code: 910020e0 8b0400c4 f862d929 aa0403e2 (f8296847) ---[ end trace 387be2290557729c ]--- Kernel panic - not syncing: Oops: Fatal exception SMP: stopping secondary CPUs Kernel Offset: disabled CPU features: 0x9850817,7a60aa38 Memory Limit: none Starting crashdump kernel... Bye!
Stable-dep-of: a0ab2bb269e7 ("RDMA/mlx5: Cancel software CQ notifications before teardown")
--- drivers/infiniband/hw/mlx5/cq.c | 19 +++++++++++++++---- drivers/infiniband/hw/mlx5/main.c | 2 ++ drivers/infiniband/hw/mlx5/mlx5_ib.h | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-)
drivers/infiniband/hw/mlx5/cq.c +15 -4
@@ -1059,20 +1059,31 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,return err; } -int mlx5_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata) +int mlx5_ib_pre_destroy_cq (struct ib_cq *cq) {struct mlx5_ib_dev *dev =to_mdev (cq->device);struct mlx5_ib_cq *mcq =to_mcq (cq); + +return mlx5_core_destroy_cq (dev->mdev, &mcq->mcq); +} + +void mlx5_ib_post_destroy_cq (struct ib_cq *cq) +{ +destroy_cq_kernel (to_mdev (cq->device),to_mcq (cq)); +} + +int mlx5_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata) +{int ret; - ret =mlx5_core_destroy_cq (dev->mdev, &mcq->mcq); + ret =mlx5_ib_pre_destroy_cq (cq);if (ret)return ret;if (udata) -destroy_cq_user (mcq, udata); +destroy_cq_user (to_mcq (cq), udata);else -destroy_cq_kernel (dev, mcq); +mlx5_ib_post_destroy_cq (cq);return 0 ; }
drivers/infiniband/hw/mlx5/main.c +2 -0
@@ -4277,7 +4277,9 @@ static const struct ib_device_ops mlx5_ib_dev_ops = { .modify_port = mlx5_ib_modify_port, .modify_qp = mlx5_ib_modify_qp, .modify_srq = mlx5_ib_modify_srq, + .pre_destroy_cq = mlx5_ib_pre_destroy_cq, .poll_cq = mlx5_ib_poll_cq, + .post_destroy_cq = mlx5_ib_post_destroy_cq, .post_recv = mlx5_ib_post_recv_nodrain, .post_send = mlx5_ib_post_send_nodrain, .post_srq_recv = mlx5_ib_post_srq_recv,
drivers/infiniband/hw/mlx5/mlx5_ib.h +2 -0
@@ -1344,6 +1344,8 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr, struct uverbs_attr_bundle *attrs);int mlx5_ib_destroy_cq (struct ib_cq *cq,struct ib_udata *udata);int mlx5_ib_poll_cq (struct ib_cq *ibcq,int num_entries,struct ib_wc *wc); +int mlx5_ib_pre_destroy_cq (struct ib_cq *cq); +void mlx5_ib_post_destroy_cq (struct ib_cq *cq);int mlx5_ib_arm_cq (struct ib_cq *ibcq,enum ib_cq_notify_flags flags);int mlx5_ib_modify_cq (struct ib_cq *cq,u16 cq_count,u16 cq_period);int mlx5_ib_resize_cq (struct ib_cq *ibcq,int entries,struct ib_udata *udata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1055/1756 RDMA/mlx5: Cancel software CQ notifications before teardown
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prathamesh Deshpande <[email protected]>
[ Upstream commit a0ab2bb269e7fd8523f87950b91a42a36c7f8f2a ]
GSI completions queue notify_work to invoke the CQ completion handler. CQ destruction drains hardware events and core polling, but does not cancel this software notifier.
--- drivers/infiniband/hw/mlx5/cq.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/infiniband/hw/mlx5/cq.c +3 -0
@@ -1064,6 +1064,9 @@ int mlx5_ib_pre_destroy_cq(struct ib_cq *cq)struct mlx5_ib_dev *dev =to_mdev (cq->device);struct mlx5_ib_cq *mcq =to_mcq (cq); +if (!cq->uobject) +cancel_work_sync (&mcq->notify_work); +return mlx5_core_destroy_cq (dev->mdev, &mcq->mcq); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1056/1756 bpftool: Fix out-of-bounds read in kprobe_multi link info dump
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 0d5e3fc78a6f2522e6339743b8e5ecc02351a9dd ]
show_kprobe_multi_{plain,json}() walk the sorted kallsyms array against the sorted addr/cookie array with j as a cursor into the latter. The loop terminating condition is checked after the cursor has already been used to access the array:
if (j++ == info->kprobe_multi.count)
break;After all count entries have been printed, j has been bumped to count, but the loop keeps running and dereferences data[count] -- one element past the end of the calloc(count, sizeof(*data)) allocation -- while comparing every remaining kallsyms symbol. If the out-of-bounds value happens to match a symbol address, a bogus entry with a garbage addr/cookie pair is printed to boot.
Fix the off-by-one by advancing the cursor before the comparison, so the loop terminates as soon as the last entry has been printed.
Verified with an ASAN build of bpftool against a live kprobe_multi link of 3 symbols:
before: ERROR: AddressSanitizer: heap-buffer-overflow READ of size 8
at link.c:860 (show_kprobe_multi_plain) and link.c:352 (show_kprobe_multi_json), 0 bytes after the 48-byte get_addr_cookie_array() allocation
after: clean output, no ASAN report
--- tools/bpf/bpftool/link.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/bpf/bpftool/link.c +2 -2
@@ -321,7 +321,7 @@ show_kprobe_multi_json(struct bpf_link_info *info, json_writer_t *wtr) }jsonw_uint_field (json_wtr,"cookie" , data[j].cookie);jsonw_end_object (json_wtr); -if (j++ == info->kprobe_multi.count) +if (++j == info->kprobe_multi.count)break ; }jsonw_end_array (json_wtr);
@@ -750,7 +750,7 @@ static void show_kprobe_multi_plain(struct bpf_link_info *info)else printf (" " ); -if (j++ == info->kprobe_multi.count) +if (++j == info->kprobe_multi.count)break ; } error:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1057/1756 dm-snapshot: make the chunk list sorted by the chunk number
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit bbd6f974d0386036e560af332b6b8cdd17010a72 ]
Commit 8581b19eb2c5 ("dm-snapshot: fix 'scheduling while atomic' on real-time kernels") replaced hlist_bl_for_each_entry with hlist_for_each_entry, but the two iteration macros differ after the loop
ends: hlist_bl_for_each_entry leaves "e" pointing at the last element, while hlist_for_each_entry() sets it to NULL.
The result is that the list is no longer sorted by chunk number as it was intended to be. This bug doesn't cause data corruption because dm_lookup_exception walks the full list.
Restore the invariant by tracking the list tail in the "prev" variable and appending after it with hlist_add_behind.
--- drivers/md/dm-snap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/md/dm-snap.c +10 -8
@@ -770,7 +770,7 @@ static void dm_insert_exception(struct dm_exception_table *eh, struct dm_exception *new_e) {struct hlist_head *l; -struct dm_exception *e =NULL ; +struct dm_exception *e =NULL , *prev =NULL ; l = &eh->table[exception_hash (eh, new_e->old_chunk)].head;
@@ -802,21 +802,23 @@ static void dm_insert_exception(struct dm_exception_table *eh,if (new_e->old_chunk < e->old_chunk)break ; + + prev = e; } out: -if (!e) { +if (e && new_e->old_chunk < e->old_chunk) { +/* Add before an existing exception */ +hlist_add_before (&new_e->hash_list, &e->hash_list); + }else if (prev) { +/* Add to l's tail: prev is the last exception in this slot */ +hlist_add_behind (&new_e->hash_list, &prev->hash_list); + }else {/* * Either the table doesn't support consecutive chunks or slot * l is empty. */ hlist_add_head (&new_e->hash_list, l); - }else if (new_e->old_chunk < e->old_chunk) { -/* Add before an existing exception */ -hlist_add_before (&new_e->hash_list, &e->hash_list); - }else { -/* Add to l's tail: e is the last exception in this slot */ -hlist_add_behind (&new_e->hash_list, &e->hash_list); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1058/1756 ALSA: control: Relax __free() variable declarations
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 7b4721ca3159bce6338dbdf9188b785083571ed4 ]
We used to have a variable declaration with __free() initialized with NULL. This was to keep the old coding style rule, but recently it's relaxed and rather recommends to follow the new rule to declare in place of use for __free() -- which avoids potential deadlocks or UAFs with nested cleanups.
Although the current code has no bug, per se, let's follow the new standard and move the declaration to the place of assignment (or directly assign the allocated result) instead of NULL initializations.
Stable-dep-of: 682d6bb5f783 ("ALSA: control_led: Fix deadlock between sysfs writes and card disconnect")
--- sound/core/control.c | 12 ++++++------ sound/core/control_compat.c | 21 +++++++++++---------- sound/core/control_led.c | 12 ++++++------ 3 files changed, 23 insertions(+), 22 deletions(-)
sound/core/control.c +6 -6
@@ -867,9 +867,9 @@ EXPORT_SYMBOL(snd_ctl_find_id);static int snd_ctl_card_info (struct snd_card *card,struct snd_ctl_file * ctl,unsigned int cmd,void __user *arg) { - struct snd_ctl_card_info *info __free(kfree) = NULL; + struct snd_ctl_card_info *info __free(kfree) = +kzalloc (sizeof (*info),GFP_KERNEL ); - info =kzalloc (sizeof (*info),GFP_KERNEL );if (! info)return -ENOMEM ; scoped_guard(rwsem_read, &snd_ioctl_rwsem) {
@@ -1244,10 +1244,10 @@ static int snd_ctl_elem_read(struct snd_card *card,static int snd_ctl_elem_read_user (struct snd_card *card,struct snd_ctl_elem_value __user *_control) { - struct snd_ctl_elem_value *control __free(kfree) = NULL;int result; + struct snd_ctl_elem_value *control __free(kfree) = +memdup_user (_control,sizeof (*control)); - control =memdup_user (_control,sizeof (*control));if (IS_ERR (control))return PTR_ERR (control);
@@ -1320,11 +1320,11 @@ static int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,static int snd_ctl_elem_write_user (struct snd_ctl_file *file,struct snd_ctl_elem_value __user *_control) { - struct snd_ctl_elem_value *control __free(kfree) = NULL;struct snd_card *card;int result; + struct snd_ctl_elem_value *control __free(kfree) = +memdup_user (_control,sizeof (*control)); - control =memdup_user (_control,sizeof (*control));if (IS_ERR (control))return PTR_ERR (control);
sound/core/control_compat.c +11 -10
@@ -80,10 +80,10 @@ static int snd_ctl_elem_info_compat(struct snd_ctl_file *ctl, struct snd_ctl_elem_info32 __user *data32) {struct snd_card *card = ctl->card; - struct snd_ctl_elem_info *data __free(kfree) = NULL;int err; + struct snd_ctl_elem_info *data __free(kfree) = +kzalloc (sizeof (*data),GFP_KERNEL ); - data =kzalloc (sizeof (*data),GFP_KERNEL );if (! data)return -ENOMEM ;
@@ -169,14 +169,15 @@ static int get_ctl_type(struct snd_card *card, struct snd_ctl_elem_id *id, int *countp) {struct snd_kcontrol *kctl; - struct snd_ctl_elem_info *info __free(kfree) = NULL;int err;guard (rwsem_read)(&card->controls_rwsem); kctl =snd_ctl_find_id (card, id);if (!kctl)return -ENOENT ; - info =kzalloc (sizeof (*info),GFP_KERNEL ); + + struct snd_ctl_elem_info *info __free(kfree) = +kzalloc (sizeof (*info),GFP_KERNEL );if (info ==NULL )return -ENOMEM ; info->id = *id;
@@ -280,10 +281,10 @@ static int copy_ctl_value_to_user(void __user *userdata,static int __ctl_elem_read_user (struct snd_card *card,void __user *userdata,void __user *valuep) { - struct snd_ctl_elem_value *data __free(kfree) = NULL;int err, type, count; + struct snd_ctl_elem_value *data __free(kfree) = +kzalloc (sizeof (*data),GFP_KERNEL ); - data =kzalloc (sizeof (*data),GFP_KERNEL );if (data ==NULL )return -ENOMEM ;
@@ -314,11 +315,11 @@ static int ctl_elem_read_user(struct snd_card *card,static int __ctl_elem_write_user (struct snd_ctl_file *file,void __user *userdata,void __user *valuep) { - struct snd_ctl_elem_value *data __free(kfree) = NULL;struct snd_card *card = file->card;int err, type, count; + struct snd_ctl_elem_value *data __free(kfree) = +kzalloc (sizeof (*data),GFP_KERNEL ); - data =kzalloc (sizeof (*data),GFP_KERNEL );if (data ==NULL )return -ENOMEM ;
@@ -378,9 +379,9 @@ static int snd_ctl_elem_add_compat(struct snd_ctl_file *file, struct snd_ctl_elem_info32 __user *data32, int replace) { - struct snd_ctl_elem_info *data __free(kfree) = NULL; + struct snd_ctl_elem_info *data __free(kfree) = +kzalloc (sizeof (*data),GFP_KERNEL ); - data =kzalloc (sizeof (*data),GFP_KERNEL );if (! data)return -ENOMEM ;
sound/core/control_led.c +6 -6
@@ -243,12 +243,12 @@ static void snd_ctl_led_notify(struct snd_card *card, unsigned int mask,static int snd_ctl_led_set_id (int card_number,struct snd_ctl_elem_id *id,unsigned int group,bool set) { - struct snd_card *card __free(snd_card_unref) = NULL;struct snd_kcontrol *kctl;struct snd_kcontrol_volatile *vd;unsigned int ioff, access, new_access; + struct snd_card *card __free(snd_card_unref) = +snd_card_ref (card_number); - card =snd_card_ref (card_number);if (!card)return -ENXIO ;guard (rwsem_write)(&card->controls_rwsem);
@@ -302,13 +302,13 @@ static void snd_ctl_led_clean(struct snd_card *card)static int snd_ctl_led_reset (int card_number,unsigned int group) { - struct snd_card *card __free(snd_card_unref) = NULL;struct snd_ctl_led_ctl *lctl, *_lctl;struct snd_ctl_led *led;struct snd_kcontrol_volatile *vd;bool change = false; + struct snd_card *card __free(snd_card_unref) = +snd_card_ref (card_number); - card =snd_card_ref (card_number);if (!card)return -ENXIO ;
@@ -598,11 +598,11 @@ static ssize_t list_show(struct device *dev, struct device_attribute *attr, char *buf) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); - struct snd_card *card __free(snd_card_unref) = NULL;struct snd_ctl_led_ctl *lctl;size_t l =0 ; + struct snd_card *card __free(snd_card_unref) = +snd_card_ref (led_card->number); - card =snd_card_ref (led_card->number);if (!card)return -ENXIO ;guard (rwsem_read)(&card->controls_rwsem);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1059/1756 ALSA: control_led: Fix deadlock between sysfs writes and card disconnect
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memiş <[email protected]>
[ Upstream commit 682d6bb5f783adea7fa2a5b05166bff01b338081 ]
snd_ctl_led_disconnect() removes the ctl-led sysfs files while holding card->controls_rwsem. device_unregister() waits for running sysfs callbacks which can deadlock when a concurrent write causes the attach or detach callback to wait for controls_rwsem.
Break kernfs active protection in the attach, detach and list callbacks and hold a module reference instead.
--- sound/core/control_led.c | 62 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 57 insertions(+), 5 deletions(-)
sound/core/control_led.c +57 -5
@@ -563,12 +563,43 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, sireturn count; } +/* +* snd_ctl_led_disconnect() removes these files with card->controls_rwsem +* held. so don't let the removal wait for a callback that takes it. +*/ +static struct kernfs_node *snd_ctl_led_sysfs_enter (struct device *dev, +struct device_attribute *attr) +{ +struct kernfs_node *kn; + +if (!try_module_get (THIS_MODULE )) +return NULL ; + kn =sysfs_break_active_protection (&dev->kobj, &attr->attr); +if (!kn) +module_put (THIS_MODULE ); +return kn; +} + +static void snd_ctl_led_sysfs_exit (struct kernfs_node *kn) +{ +sysfs_unbreak_active_protection (kn); +module_put (THIS_MODULE ); +} +static ssize_t attach_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); -return set_led_id (led_card, buf, count, true); +struct kernfs_node *kn; +ssize_t ret; + + kn =snd_ctl_led_sysfs_enter (dev, attr); +if (!kn) +return -ENODEV ; + ret =set_led_id (led_card, buf, count, true); +snd_ctl_led_sysfs_exit (kn); +return ret; } static ssize_t detach_store(struct device *dev,
@@ -576,7 +607,15 @@ static ssize_t detach_store(struct device *dev, const char *buf, size_t count) { struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); -return set_led_id (led_card, buf, count, false); +struct kernfs_node *kn; +ssize_t ret; + + kn =snd_ctl_led_sysfs_enter (dev, attr); +if (!kn) +return -ENODEV ; + ret =set_led_id (led_card, buf, count, false); +snd_ctl_led_sysfs_exit (kn); +return ret; } static ssize_t reset_store(struct device *dev,
@@ -594,10 +633,8 @@ static ssize_t reset_store(struct device *dev,return count; } -static ssize_t list_show (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t snd_ctl_led_list (struct snd_ctl_led_card *led_card,char *buf) { - struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev);struct snd_ctl_led_ctl *lctl;size_t l =0 ; struct snd_card *card __free(snd_card_unref) =
@@ -620,6 +657,21 @@ static ssize_t list_show(struct device *dev,return l; } +static ssize_t list_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ + struct snd_ctl_led_card *led_card = container_of(dev, struct snd_ctl_led_card, dev); +struct kernfs_node *kn; +ssize_t ret; + + kn =snd_ctl_led_sysfs_enter (dev, attr); +if (!kn) +return -ENODEV ; + ret =snd_ctl_led_list (led_card, buf); +snd_ctl_led_sysfs_exit (kn); +return ret; +} +static DEVICE_ATTR_WO (attach);static DEVICE_ATTR_WO (detach);static DEVICE_ATTR_WO (reset);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1060/1756 drm/panfrost: Explicitly enable MMU interrupts at device init
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Adrián Larumbe <[email protected]>
[ Upstream commit 8a597d099b8b2f25df655cbe8e30765013784fed ]
Because the device must be in a position to accept jobs between the time drm_dev_register() is called and autosuspend first kicks in, there's a very narrow window inbetween during which jobs targeting the tiler buffer object would time out, since the device's PM status is 'Active', but no MMU interrupts were enabled at device initialisation time.
--- drivers/gpu/drm/panfrost/panfrost_mmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/gpu/drm/panfrost/panfrost_mmu.c +9 -2
@@ -227,6 +227,12 @@ void panfrost_mmu_as_put(struct panfrost_device *pfdev, struct panfrost_mmu *mmuWARN_ON (atomic_read (&mmu->as_count) <0 ); } +static void panfrost_mmu_enable_interrupts (struct panfrost_device *pfdev) +{ +mmu_write (pfdev,MMU_INT_CLEAR , ~0 ); +mmu_write (pfdev,MMU_INT_MASK , ~0 ); +} +void panfrost_mmu_reset (struct panfrost_device *pfdev) {struct panfrost_mmu *mmu, *mmu_tmp;
@@ -246,8 +252,7 @@ void panfrost_mmu_reset(struct panfrost_device *pfdev)spin_unlock (&pfdev->as_lock); -mmu_write (pfdev,MMU_INT_CLEAR , ~0 ); -mmu_write (pfdev,MMU_INT_MASK , ~0 ); +panfrost_mmu_enable_interrupts (pfdev); }static size_t get_pgsize (u64 addr,size_t size,size_t *count)
@@ -783,6 +788,8 @@ int panfrost_mmu_init(struct panfrost_device *pfdev)return err; } +panfrost_mmu_enable_interrupts (pfdev); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1061/1756 ACPI: PCI: pci_link: clear driver_data before free
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 691c33289b4d7a50b6fe1e03918bfbc21d4641c5 ]
acpi_pci_link_remove() frees the link object without clearing the ACPI device's driver_data pointer. The ACPI device survives hot-removal and can later be retrieved by acpi_fetch_acpi_dev(), leaving callers with a dangling pointer.
Clear driver_data before freeing the link.
--- drivers/acpi/pci_link.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/pci_link.c +1 -0
@@ -780,6 +780,7 @@ static void acpi_pci_link_remove(struct acpi_device *device)list_del (&link->list);mutex_unlock (&acpi_link_lock); + device->driver_data =NULL ;kfree (link); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1062/1756 block: use iomap_dirty_folio for block devices
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tal Zussman <[email protected]>
[ Upstream commit be1e33eda3e6699e57ed3fe6e34078f115b4a1ec ]
With CONFIG_BUFFER_HEAD=n, block devices are written back through iomap, but def_blk_aops uses filemap_dirty_folio, which only sets PG_dirty. It does not set the per-block dirty bits in the folio's iomap_folio_state, so iomap_writeback_folio() finds no dirty range, submits no I/O and clears PG_dirty, resulting in data loss.
Other iomap users set .dirty_folio to iomap_dirty_folio, which marks the folio's blocks dirty before calling filemap_dirty_folio().
This is only observable with block size < folio size. With a single block there is no iomap_folio_state to get out of sync and iomap_writeback_folio() marks the whole folio dirty itself. For a page-aligned device, this may require using the BLKBSZSET ioctl to set the block size, which requires CAP_SYS_ADMIN. A device whose size is not page aligned already gets a sub-page block size from set_init_blocksize(), so no ioctl and no privilege is needed.
To reproduce, on a device with a sub-page block size, write a known pattern with O_DIRECT, mmap the same range, store to it, msync() and fsync(), then read it back with O_DIRECT. A reproducer is available at [1].
[1] https://gist.github.com/tzussman/18ab05cba4b3fdc79cce0a69d1fd05b4
--- block/fops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/fops.c +1 -1
@@ -515,7 +515,7 @@ static int blkdev_writepages(struct address_space *mapping, }const struct address_space_operations def_blk_aops = { - .dirty_folio = filemap_dirty_folio, + .dirty_folio = iomap_dirty_folio, .release_folio = iomap_release_folio, .invalidate_folio = iomap_invalidate_folio, .read_folio = blkdev_read_folio,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1063/1756 block: honor IOCB_NOWAIT in the block device buffered read path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tal Zussman <[email protected]>
[ Upstream commit d16519a561f4ccc2cebbf52831435833cac1fec6 ]
blkdev_read_iter() takes inode_lock_shared() unconditionally around filemap_read(). Unlike blkdev_write_iter(), it does not reject IOCB_NOWAIT for buffered I/O, so a non-blocking read, or the buffered tail of a short IOCB_NOWAIT direct read, blocks behind set_blocksize() holding i_rwsem across sync_blockdev().
A preadv2(RWF_NOWAIT) issued while another thread changes the block size with a dirty page cache blocks for as long as sync_blockdev() takes, 4 to 6 seconds on a scsi_debug device with delay=5.
Use inode_trylock_shared() for IOCB_NOWAIT and return the bytes the direct path already read, or -EAGAIN if none, when the lock is contended, preserving NOWAIT semantics.
--- block/fops.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
block/fops.c +9 -1
@@ -780,7 +780,15 @@ static ssize_t blkdev_read_iter(struct kiocb *iocb, struct iov_iter *to)* Take i_rwsem and invalidate_lock to avoid racing with set_blocksize * changing i_blkbits/folio order and punching out the pagecache. */ -inode_lock_shared (bd_inode); +if (iocb->ki_flags &IOCB_NOWAIT ) { +if (!inode_trylock_shared (bd_inode)) { +if (!ret) + ret = -EAGAIN ; + goto reexpand; + } + }else { +inode_lock_shared (bd_inode); + } ret =filemap_read (iocb, to, ret);inode_unlock_shared (bd_inode);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1064/1756 btrfs: refactor read_key_bytes() to remove the dest_folio parameter
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit fdf56b9d03d475881d73b75afbdbe4058db04ffc ]
The function read_key_bytes() have 3 call sites:
- For BTRFS_VERITY_DESC_ITEM_KEY offset 0 inside btrfs_get_verity_descriptor()
- For BTRFS_VERITY_DESC_ITEM_KEY offset 1 inside btrfs_get_verity_descriptor() Those are to read the description items, which are pretty small with fixed item size.
Those call sites do not utilize the @dest_folio parameter.
- For btrfs_read_merkle_tree_page()
This is to read the BTRFS_VERITY_MERKLE_ITEM_KEY, which can be pretty large and split into multiple items.
This is the only call site utilizing the @dest_folio parameter.
Just for the only btrfs_read_merkle_tree_page() call site, we have a complex scheme for @dest and @dest_folio parameters.
Since @dest can be NULL, it means if we pass @dest as NULL, then no matter if @dest_folio is provided, the merkle data will not be loaded into that @dest_folio.
This can lead to a bug where a highmem folio is not mapped, then we pass folio_address(folio), which is NULL, into read_key_bytes(), causing no data to be written into @dest_folio.
To address the complex scheme between @dest and @dest_folio, remove the @dest_folio parameter completely, and let the only caller to map the folio and pass the mapped kernel address into read_key_bytes() instead.
This not only reduces the parameter list, but also make it much clear on the @dest parameter handling.
The only downside is a longer duration of locally mapped page, but this should still be fine, as kmap_local_folio() can survive context switch.
--- fs/btrfs/verity.c | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-)
fs/btrfs/verity.c +14 -17
@@ -280,21 +280,17 @@ static int write_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,* @dest: Buffer to read into. This parameter has slightly tricky * semantics. If it is NULL, the function will not do any copying * and will just return the size of all the items up to len bytes. -* If dest_page is passed, then the function will kmap_local the -* page and ignore dest, but it must still be non-NULL to avoid the -* counting-only behavior. * @len: length in bytes to read -* @dest_folio: copy into this folio instead of the dest buffer * * Helper function to read items from the btree. This returns the number of * bytes read or < 0 for errors. We can return short reads if the items don't * exist on disk or aren't big enough to fill the desired length. Supports -* reading into a provided buffer (dest) or into the page cache +* reading into a provided buffer (dest). * * Returns number of bytes read or a negative error code on failure. */ static int read_key_bytes (struct btrfs_inode *inode,u8 key_type,u64 offset, -char *dest,u64 len,struct folio *dest_folio) +char *dest,u64 len) {struct btrfs_path *path;struct btrfs_root *root = inode->root;
@@ -314,7 +310,11 @@ static int read_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,if (!path)return -ENOMEM ; -if (dest_folio) +/* +* Merkle items can be large and split across multiple items, so enable +* readahead for such cases. +*/ +if (key_type ==BTRFS_VERITY_MERKLE_ITEM_KEY ) path->reada =READA_FORWARD ; key.objectid =btrfs_ino (inode);
@@ -358,7 +358,7 @@ static int read_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset,break ; } -/* desc = NULL to just sum all the item lengths */ +/* dest == NULL to just sum all the item lengths */ if (!dest) copy_end = item_end;else
@@ -371,16 +371,10 @@ static int read_key_bytes(struct btrfs_inode *inode, u8 key_type, u64 offset, copy_offset = offset - key.offset;if (dest) { -if (dest_folio) - kaddr =kmap_local_folio (dest_folio,0 ); - data =btrfs_item_ptr (leaf, path->slots[0 ], void);read_extent_buffer (leaf, kaddr + dest_offset, (unsigned long )data + copy_offset, copy_bytes); - -if (dest_folio) -kunmap_local (kaddr); } offset += copy_bytes;
@@ -672,7 +666,7 @@ int btrfs_get_verity_descriptor(struct inode *inode, void *buf, size_t buf_size)memset (&item,0 ,sizeof (item)); ret =read_key_bytes (BTRFS_I (inode),BTRFS_VERITY_DESC_ITEM_KEY ,0 , - (char *)&item,sizeof (item),NULL ); + (char *)&item,sizeof (item));if (ret <0 )return ret;
@@ -689,7 +683,7 @@ int btrfs_get_verity_descriptor(struct inode *inode, void *buf, size_t buf_size)return -ERANGE ; ret =read_key_bytes (BTRFS_I (inode),BTRFS_VERITY_DESC_ITEM_KEY ,1 , - buf, buf_size,NULL ); + buf, buf_size);if (ret <0 )return ret;if (ret != true_size)
@@ -717,6 +711,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,struct folio *folio;u64 off = (u64 )index <<PAGE_SHIFT ;loff_t merkle_pos =merkle_file_pos (inode); +void *kaddr;int ret;if (merkle_pos <0 )
@@ -760,6 +755,7 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode, } read_folio: + kaddr =kmap_local_folio (folio,0 );/* * Merkle item keys are indexed from byte 0 in the merkle tree. * They have the form:
@@ -767,7 +763,8 @@ static struct page *btrfs_read_merkle_tree_page(struct inode *inode,* [ inode objectid, BTRFS_MERKLE_ITEM_KEY, offset in bytes ] */ ret =read_key_bytes (BTRFS_I (inode),BTRFS_VERITY_MERKLE_ITEM_KEY , off, -folio_address (folio),PAGE_SIZE , folio); + kaddr,PAGE_SIZE ); +kunmap_local (kaddr);if (ret <0 ) {folio_unlock (folio);folio_put (folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1065/1756 btrfs: fix off by one super block end offset calculation when writing super blocks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 7884a8f3279c28ff990e2eacd5c2479bb1c930d0 ]
We are skipping the write of a super block mirror if its end offset matches exactly the device's end offset. This happens because we are using a greater than or equals comparison instead of just a greater than comparison.
--- fs/btrfs/disk-io.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/btrfs/disk-io.c +2 -4
@@ -3744,8 +3744,7 @@ static int write_dev_supers(struct btrfs_device *device,atomic_inc (&device->sb_write_errors);continue ; } -if (bytenr +BTRFS_SUPER_INFO_SIZE >= - device->commit_total_bytes) +if (bytenr +BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes)break ;btrfs_set_super_bytenr (sb, bytenr_orig);
@@ -3828,8 +3827,7 @@ static int wait_dev_supers(struct btrfs_device *device, int max_mirrors) primary_failed = true;continue ; } -if (bytenr +BTRFS_SUPER_INFO_SIZE >= - device->commit_total_bytes) +if (bytenr +BTRFS_SUPER_INFO_SIZE > device->commit_total_bytes)break ; folio = filemap_get_folio(device->bdev->bd_mapping,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1066/1756 btrfs: fix dangling nodes in tree-mod-log after error in btrfs_tree_mod_log_insert_root()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 057e3c350a9185df598c88b4081168ed047c9247 ]
If in btrfs_tree_mod_log_insert_root() there is an error in the call to tree_mod_log_insert() (the only possible error is -EEXIST, which means we have a bug or some memory corruption maybe) we free all the nodes in the 'tm_list' array but we don't remove them from the tree-mod-log rbtree, which can result in use-after-free bugs later.
So make sure we remove the nodes from the rbtree before freeing them after an error.
--- fs/btrfs/tree-mod-log.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
fs/btrfs/tree-mod-log.c +10 -3
@@ -446,10 +446,17 @@ int btrfs_tree_mod_log_insert_root(struct extent_buffer *old_root, goto out_unlock; } -if (tm_list) +if (tm_list) { ret =tree_mod_log_free_eb (fs_info, tm_list, nritems); -if (!ret) - ret =tree_mod_log_insert (fs_info, tm); +if (ret) + goto out_unlock; + } + + ret =tree_mod_log_insert (fs_info, tm); +if (ret && tm_list) { +for (i =0 ; i < nritems; i++) +rb_erase (&tm_list[i]->node, &fs_info->tree_mod_log); + } out_unlock:write_unlock (&fs_info->tree_mod_log_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1067/1756 btrfs: zoned: fix double list add in btrfs_load_block_group_zone_info
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 9bdef63e2b5d4a88810329a1cab3642d6378a895 ]
For DUP and RAID profiles with zones in a mismatching active state, i.e. due to one of the zones of the block-group being on a conventional zone, btrfs_zone_activate() has already put the block group on the list.
This leads to a double list add and refcounting problems.
--- fs/btrfs/zoned.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/btrfs/zoned.c +5 -3
@@ -1937,10 +1937,12 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)if (!ret) { cache->meta_write_pointer = cache->alloc_offset + cache->start;if (test_bit (BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE , &cache->runtime_flags)) { -btrfs_get_block_group (cache);spin_lock (&fs_info->zone_active_bgs_lock); -list_add_tail (&cache->active_bg_list, - &fs_info->zone_active_bgs); +if (list_empty (&cache->active_bg_list)) { +btrfs_get_block_group (cache); +list_add_tail (&cache->active_bg_list, + &fs_info->zone_active_bgs); + }spin_unlock (&fs_info->zone_active_bgs_lock); } }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1068/1756 btrfs: fix incomplete iteration over fs state when logging messages
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit d1d74665ab9a8971d42177ca865cfbe2897c1fc7 ]
In btrfs_state_to_string() we iterate over all the bits set in fs_info->fs_state using for_each_set_bit(), which requires its third argument to match the number of bits, but we pass it the number of bytes of the type used by fs_info->fs_state, an unsigned long, which is 8 on 64 bits platforms and 4 on 32 bits platforms. This means we are not iterating over bits in the ranges [8, 63] or [4, 31].
Fix this by passing BTRFS_FS_STATE_COUNT instead of sizeof(fs_state). Note that we could pass BITS_PER_TYPE(fs_state), but since BTRFS_FS_STATE_COUNT is 11 and we have no bits beyond that, it would cause pointless iterations over fs_state.
This also makes pointless the checks for the bit being inside the limit of BTRFS_FS_STATE_COUNT inside the loop.
--- fs/btrfs/messages.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/messages.c +2 -3
@@ -40,9 +40,8 @@ static void btrfs_state_to_string(const struct btrfs_fs_info *info, char *buf) states_printed = true; } -for_each_set_bit (bit, &fs_state,sizeof (fs_state)) { -WARN_ON_ONCE (bit >=BTRFS_FS_STATE_COUNT ); -if ((bit <BTRFS_FS_STATE_COUNT ) && fs_state_chars[bit]) { +for_each_set_bit (bit, &fs_state,BTRFS_FS_STATE_COUNT ) { +if (fs_state_chars[bit]) { *curr++ = fs_state_chars[bit]; states_printed = true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1069/1756 btrfs: dont use token set/get accessors for btrfs_item members
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 114b806a733ffbd3906fca3493d47529dbc8210b ]
The token versions of set/get accessors will be removed, use the normal helpers. The btrfs_item members use that interface the most but there are no real benefits anymore.
This reduces stack consumption on x86_64 release config:
setup_items_for_insert -32 (144 -> 112) __push_leaf_left -32 (176 -> 144) btrfs_extend_item -16 (104 -> 88) copy_for_split -32 (144 -> 112) btrfs_del_items -16 (144 -> 128) btrfs_truncate_item -24 (152 -> 128) __push_leaf_right -24 (168 -> 144)
and module size:
text data bss dec hex filename
1463615 115665 16088 1595368 1857e8 pre/btrfs.ko 1463413 115665 16088 1595166 18571e post/btrfs.ko
DELTA: -202
Stable-dep-of: 08f750d9f893 ("btrfs: fix off-by-one end offset check in report_setget_bounds()")
--- fs/btrfs/ctree.c | 51 +++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 33 deletions(-)
fs/btrfs/ctree.c +18 -33
@@ -3137,7 +3137,6 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans,struct btrfs_fs_info *fs_info = right->fs_info;struct extent_buffer *left = path->nodes[0 ];struct extent_buffer *upper = path->nodes[1 ]; -struct btrfs_map_token token;struct btrfs_disk_key disk_key;int slot;u32 i;
@@ -3211,13 +3210,12 @@ static noinline int __push_leaf_right(struct btrfs_trans_handle *trans,copy_leaf_items (right, left,0 , left_nritems - push_items, push_items);/* update the item pointers */ -btrfs_init_map_token (&token, right); right_nritems += push_items;btrfs_set_header_nritems (right, right_nritems); push_space =BTRFS_LEAF_DATA_SIZE (fs_info);for (i =0 ; i < right_nritems; i++) { - push_space -=btrfs_token_item_size (&token, i); -btrfs_set_token_item_offset (&token, i, push_space); + push_space -=btrfs_item_size (right, i); +btrfs_set_item_offset (right, i, push_space); } left_nritems -= push_items;
@@ -3360,7 +3358,6 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans,int ret =0 ;u32 this_item_size;u32 old_left_item_size; -struct btrfs_map_token token;if (empty) nr =min (right_nritems, max_slot);
@@ -3408,13 +3405,12 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, old_left_nritems =btrfs_header_nritems (left);BUG_ON (old_left_nritems <=0 ); -btrfs_init_map_token (&token, left); old_left_item_size =btrfs_item_offset (left, old_left_nritems -1 );for (i = old_left_nritems; i < old_left_nritems + push_items; i++) {u32 ioff; - ioff =btrfs_token_item_offset (&token, i); -btrfs_set_token_item_offset (&token, i, + ioff =btrfs_item_offset (left, i); +btrfs_set_item_offset (left, i, ioff - (BTRFS_LEAF_DATA_SIZE (fs_info) - old_left_item_size)); }btrfs_set_header_nritems (left, old_left_nritems + push_items);
@@ -3435,13 +3431,12 @@ static noinline int __push_leaf_left(struct btrfs_trans_handle *trans, btrfs_header_nritems(right) - push_items); } -btrfs_init_map_token (&token, right); right_nritems -= push_items;btrfs_set_header_nritems (right, right_nritems); push_space =BTRFS_LEAF_DATA_SIZE (fs_info);for (i =0 ; i < right_nritems; i++) { - push_space = push_space -btrfs_token_item_size (&token, i); -btrfs_set_token_item_offset (&token, i, push_space); + push_space = push_space -btrfs_item_size (right, i); +btrfs_set_item_offset (right, i, push_space); }btrfs_mark_buffer_dirty (trans, left);
@@ -3555,7 +3550,6 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans,int i;int ret;struct btrfs_disk_key disk_key; -struct btrfs_map_token token; nritems = nritems - mid;btrfs_set_header_nritems (right, nritems);
@@ -3568,12 +3562,11 @@ static noinline int copy_for_split(struct btrfs_trans_handle *trans, rt_data_off =BTRFS_LEAF_DATA_SIZE (fs_info) -btrfs_item_data_end (l, mid); -btrfs_init_map_token (&token, right);for (i =0 ; i < nritems; i++) {u32 ioff; - ioff =btrfs_token_item_offset (&token, i); -btrfs_set_token_item_offset (&token, i, ioff + rt_data_off); + ioff =btrfs_item_offset (right, i); +btrfs_set_item_offset (right, i, ioff + rt_data_off); }btrfs_set_header_nritems (l, mid);
@@ -4038,7 +4031,6 @@ void btrfs_truncate_item(struct btrfs_trans_handle *trans,unsigned int old_size;unsigned int size_diff;int i; -struct btrfs_map_token token; leaf = path->nodes[0 ]; slot = path->slots[0 ];
@@ -4061,12 +4053,11 @@ void btrfs_truncate_item(struct btrfs_trans_handle *trans,* item0..itemN ... dataN.offset..dataN.size .. data0.size */ /* first correct the data pointers */ -btrfs_init_map_token (&token, leaf);for (i = slot; i < nritems; i++) {u32 ioff; - ioff =btrfs_token_item_offset (&token, i); -btrfs_set_token_item_offset (&token, i, ioff + size_diff); + ioff =btrfs_item_offset (leaf, i); +btrfs_set_item_offset (leaf, i, ioff + size_diff); }/* shift the data */
@@ -4129,7 +4120,6 @@ void btrfs_extend_item(struct btrfs_trans_handle *trans,unsigned int old_data;unsigned int old_size;int i; -struct btrfs_map_token token; leaf = path->nodes[0 ];
@@ -4155,12 +4145,11 @@ void btrfs_extend_item(struct btrfs_trans_handle *trans,* item0..itemN ... dataN.offset..dataN.size .. data0.size */ /* first correct the data pointers */ -btrfs_init_map_token (&token, leaf);for (i = slot; i < nritems; i++) {u32 ioff; - ioff =btrfs_token_item_offset (&token, i); -btrfs_set_token_item_offset (&token, i, ioff - data_size); + ioff =btrfs_item_offset (leaf, i); +btrfs_set_item_offset (leaf, i, ioff - data_size); }/* shift the data */
@@ -4200,7 +4189,6 @@ static void setup_items_for_insert(struct btrfs_trans_handle *trans,struct btrfs_disk_key disk_key;struct extent_buffer *leaf;int slot; -struct btrfs_map_token token;u32 total_size;/*
@@ -4228,7 +4216,6 @@ static void setup_items_for_insert(struct btrfs_trans_handle *trans,BUG (); } -btrfs_init_map_token (&token, leaf);if (slot != nritems) {unsigned int old_data =btrfs_item_data_end (leaf, slot);
@@ -4246,8 +4233,8 @@ static void setup_items_for_insert(struct btrfs_trans_handle *trans,for (i = slot; i < nritems; i++) {u32 ioff; - ioff =btrfs_token_item_offset (&token, i); -btrfs_set_token_item_offset (&token, i, + ioff =btrfs_item_offset (leaf, i); +btrfs_set_item_offset (leaf, i, ioff - batch->total_data_size); }/* shift the items */
@@ -4264,8 +4251,8 @@ static void setup_items_for_insert(struct btrfs_trans_handle *trans,btrfs_cpu_key_to_disk (&disk_key, &batch->keys[i]);btrfs_set_item_key (leaf, &disk_key, slot + i); data_end -= batch->data_sizes[i]; -btrfs_set_token_item_offset (&token, slot + i, data_end); -btrfs_set_token_item_size (&token, slot + i, batch->data_sizes[i]); +btrfs_set_item_offset (leaf, slot + i, data_end); +btrfs_set_item_size (leaf, slot + i, batch->data_sizes[i]); }btrfs_set_header_nritems (leaf, nritems + batch->nr);
@@ -4506,7 +4493,6 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,if (slot + nr != nritems) {const u32 last_off =btrfs_item_offset (leaf, slot + nr -1 );const int data_end =leaf_data_end (leaf); -struct btrfs_map_token token;u32 dsize =0 ;int i;
@@ -4516,12 +4502,11 @@ int btrfs_del_items(struct btrfs_trans_handle *trans, struct btrfs_root *root,memmove_leaf_data (leaf, data_end + dsize, data_end, last_off - data_end); -btrfs_init_map_token (&token, leaf);for (i = slot + nr; i < nritems; i++) {u32 ioff; - ioff =btrfs_token_item_offset (&token, i); -btrfs_set_token_item_offset (&token, i, ioff + dsize); + ioff =btrfs_item_offset (leaf, i); +btrfs_set_item_offset (leaf, i, ioff + dsize); }memmove_leaf_items (leaf, slot, slot + nr, nritems - slot - nr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1070/1756 btrfs: dont use token set/get accessors in inode.c:fill_inode_item()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit e3df5141a4c1b85e1f6dc117f48fb634eb275f6c ]
The token versions of set/get accessors will be removed, use the normal helpers.
There's additional overhead of the token helpers that update the cached address in case it moves to another page/folio. The normal versions don't need to do that.
Stable-dep-of: 08f750d9f893 ("btrfs: fix off-by-one end offset check in report_setget_bounds()")
--- fs/btrfs/inode.c | 60 ++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 35 deletions(-)
fs/btrfs/inode.c +25 -35
@@ -3988,45 +3988,35 @@ static void fill_inode_item(struct btrfs_trans_handle *trans,struct btrfs_inode_item *item, struct inode *inode) { - struct btrfs_map_token token; u64 flags; -btrfs_init_map_token (&token, leaf); - -btrfs_set_token_inode_uid (&token, item,i_uid_read (inode)); -btrfs_set_token_inode_gid (&token, item,i_gid_read (inode)); -btrfs_set_token_inode_size (&token, item,BTRFS_I (inode)->disk_i_size); -btrfs_set_token_inode_mode (&token, item, inode->i_mode); -btrfs_set_token_inode_nlink (&token, item, inode->i_nlink); - -btrfs_set_token_timespec_sec (&token, &item->atime, -inode_get_atime_sec (inode)); -btrfs_set_token_timespec_nsec (&token, &item->atime, -inode_get_atime_nsec (inode)); - -btrfs_set_token_timespec_sec (&token, &item->mtime, -inode_get_mtime_sec (inode)); -btrfs_set_token_timespec_nsec (&token, &item->mtime, -inode_get_mtime_nsec (inode)); - -btrfs_set_token_timespec_sec (&token, &item->ctime, -inode_get_ctime_sec (inode)); -btrfs_set_token_timespec_nsec (&token, &item->ctime, -inode_get_ctime_nsec (inode)); - -btrfs_set_token_timespec_sec (&token, &item->otime,BTRFS_I (inode)->i_otime_sec); -btrfs_set_token_timespec_nsec (&token, &item->otime,BTRFS_I (inode)->i_otime_nsec); - -btrfs_set_token_inode_nbytes (&token, item,inode_get_bytes (inode)); -btrfs_set_token_inode_generation (&token, item, -BTRFS_I (inode)->generation); -btrfs_set_token_inode_sequence (&token, item,inode_peek_iversion (inode)); -btrfs_set_token_inode_transid (&token, item, trans->transid); -btrfs_set_token_inode_rdev (&token, item, inode->i_rdev); +btrfs_set_inode_uid (leaf, item,i_uid_read (inode)); +btrfs_set_inode_gid (leaf, item,i_gid_read (inode)); +btrfs_set_inode_size (leaf, item,BTRFS_I (inode)->disk_i_size); +btrfs_set_inode_mode (leaf, item, inode->i_mode); +btrfs_set_inode_nlink (leaf, item, inode->i_nlink); + +btrfs_set_timespec_sec (leaf, &item->atime,inode_get_atime_sec (inode)); +btrfs_set_timespec_nsec (leaf, &item->atime,inode_get_atime_nsec (inode)); + +btrfs_set_timespec_sec (leaf, &item->mtime,inode_get_mtime_sec (inode)); +btrfs_set_timespec_nsec (leaf, &item->mtime,inode_get_mtime_nsec (inode)); + +btrfs_set_timespec_sec (leaf, &item->ctime,inode_get_ctime_sec (inode)); +btrfs_set_timespec_nsec (leaf, &item->ctime,inode_get_ctime_nsec (inode)); + +btrfs_set_timespec_sec (leaf, &item->otime,BTRFS_I (inode)->i_otime_sec); +btrfs_set_timespec_nsec (leaf, &item->otime,BTRFS_I (inode)->i_otime_nsec); + +btrfs_set_inode_nbytes (leaf, item,inode_get_bytes (inode)); +btrfs_set_inode_generation (leaf, item,BTRFS_I (inode)->generation); +btrfs_set_inode_sequence (leaf, item,inode_peek_iversion (inode)); +btrfs_set_inode_transid (leaf, item, trans->transid); +btrfs_set_inode_rdev (leaf, item, inode->i_rdev); flags =btrfs_inode_combine_flags (BTRFS_I (inode)->flags,BTRFS_I (inode)->ro_flags); -btrfs_set_token_inode_flags (&token, item, flags); -btrfs_set_token_inode_block_group (&token, item,0 ); +btrfs_set_inode_flags (leaf, item, flags); +btrfs_set_inode_block_group (leaf, item,0 ); }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1071/1756 btrfs: accessors: delete token versions of set/get helpers
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit b37eb352c4c6ecd8e6aa62d08dbf3f5d3ce8afd7 ]
Once upon a time there was a need to cache address of extent buffer pages, as it was a costly operation (map_private_extent_buffer(), cfed81a04eb555 ("Btrfs: add the ability to cache a pointer into the eb")). This was not even due to use of HIGHMEM, this had been removed before that due to possible locking issues (a65917156e3459 ("Btrfs:
stop using highmem for extent_buffers")).
Over time the amount of work in the set/get helpers got reduced and became quite straightforward bounds checking with an unaligned read/write, commit db3756c879773c ("btrfs: remove unused map_private_extent_buffer").
The actual caching of the page_address()/folio_address() in the token was more work for very little gain. This depended on subsequent access into the same page/folio, otherwise the cached pointer had to be updated.
For metadata-heavy operations this showed up in the 'perf top' profile where the btrfs_get_token_32() calls were at the top, on my testing machine consuming about 2-3%. The other generic 32/64 bit helpers also appeared in the profile with similar fraction.
After removing use of the token helpers we can remove them completely, this leads to reduction of btrfs.ko by 6.7KiB on release config.
text data bss dec hex filename
1463289 115665 16088 1595042 1856a2 pre/btrfs.ko 1456601 115665 16088 1588354 183c82 post/btrfs.ko
DELTA: -6688
Stable-dep-of: 08f750d9f893 ("btrfs: fix off-by-one end offset check in report_setget_bounds()")
--- fs/btrfs/accessors.c | 78 -------------------------------------------- fs/btrfs/accessors.h | 37 --------------------- 2 files changed, 115 deletions(-)
fs/btrfs/accessors.c +0 -78
@@ -25,13 +25,6 @@ static bool check_setget_bounds(const struct extent_buffer *eb,return true; } -void btrfs_init_map_token (struct btrfs_map_token *token,struct extent_buffer *eb) -{ - token->eb = eb; - token->kaddr =folio_address (eb->folios[0 ]); - token->offset =0 ; -} -/* * Macro templates that define helpers to read/write extent buffer data of a * given size, that are also used via ctree.h for access to item members by
@@ -41,11 +34,6 @@ void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *e* - btrfs_set_8 (for 8/16/32/64) * - btrfs_get_8 (for 8/16/32/64) * -* Generic helpers with a token (cached address of the most recently accessed -* page): -* - btrfs_set_token_8 (for 8/16/32/64) -* - btrfs_get_token_8 (for 8/16/32/64) -* * The set/get functions handle data spanning two pages transparently, in case * metadata block size is larger than page. Every pointer to metadata items is * an offset into the extent buffer page array, cast to a specific type. This
@@ -57,37 +45,6 @@ void btrfs_init_map_token(struct btrfs_map_token *token, struct extent_buffer *e*/ #define DEFINE_BTRFS_SETGET_BITS (bits) \ -u##bits btrfs_get_token_##bits(struct btrfs_map_token *token, \ - const void *ptr, unsigned long off) \ -{ \ - const unsigned long member_offset = (unsigned long)ptr + off; \ - const unsigned long idx = get_eb_folio_index(token->eb, member_offset); \ - const unsigned long oil = get_eb_offset_in_folio(token->eb, \ - member_offset);\ - const int unit_size = token->eb->folio_size; \ - const int unit_shift = token->eb->folio_shift; \ - const int size = sizeof(u##bits); \ - u8 lebytes[sizeof(u##bits)]; \ - const int part = unit_size - oil; \ - \ - ASSERT(token); \ - ASSERT(token->kaddr); \ - ASSERT(check_setget_bounds(token->eb, ptr, off, size)); \ - if (token->offset <= member_offset && \ - member_offset + size <= token->offset + unit_size) { \ - return get_unaligned_le##bits(token->kaddr + oil); \ - } \ - token->kaddr = folio_address(token->eb->folios[idx]); \ - token->offset = idx << unit_shift; \ - if (INLINE_EXTENT_BUFFER_PAGES == 1 || oil + size <= unit_size) \ - return get_unaligned_le##bits(token->kaddr + oil); \ - \ - memcpy(lebytes, token->kaddr + oil, part); \ - token->kaddr = folio_address(token->eb->folios[idx + 1]); \ - token->offset = (idx + 1) << unit_shift; \ - memcpy(lebytes + part, token->kaddr, size - part); \ - return get_unaligned_le##bits(lebytes); \ -} \ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \ const void *ptr, unsigned long off) \ { \
@@ -110,41 +67,6 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \memcpy (lebytes + part, kaddr, size - part); \ return get_unaligned_le##bits(lebytes); \ } \ -void btrfs_set_token_##bits(struct btrfs_map_token *token, \ - const void *ptr, unsigned long off, \ - u##bits val) \ -{ \ - const unsigned long member_offset = (unsigned long)ptr + off; \ - const unsigned long idx = get_eb_folio_index(token->eb, member_offset); \ - const unsigned long oil = get_eb_offset_in_folio(token->eb, \ - member_offset);\ - const int unit_size = token->eb->folio_size; \ - const int unit_shift = token->eb->folio_shift; \ - const int size = sizeof(u##bits); \ - u8 lebytes[sizeof(u##bits)]; \ - const int part = unit_size - oil; \ - \ - ASSERT(token); \ - ASSERT(token->kaddr); \ - ASSERT(check_setget_bounds(token->eb, ptr, off, size)); \ - if (token->offset <= member_offset && \ - member_offset + size <= token->offset + unit_size) { \ - put_unaligned_le##bits(val, token->kaddr + oil); \ - return; \ - } \ - token->kaddr = folio_address(token->eb->folios[idx]); \ - token->offset = idx << unit_shift; \ - if (INLINE_EXTENT_BUFFER_PAGES == 1 || \ - oil + size <= unit_size) { \ - put_unaligned_le##bits(val, token->kaddr + oil); \ - return; \ - } \ - put_unaligned_le##bits(val, lebytes); \ - memcpy(token->kaddr + oil, lebytes, part); \ - token->kaddr = folio_address(token->eb->folios[idx + 1]); \ - token->offset = (idx + 1) << unit_shift; \ - memcpy(token->kaddr, lebytes + part, size - part); \ -} \ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \ unsigned long off, u##bits val) \ { \
fs/btrfs/accessors.h +0 -37
@@ -16,14 +16,6 @@struct extent_buffer ; -struct btrfs_map_token { -struct extent_buffer *eb; -char *kaddr; -unsigned long offset; -}; - -void btrfs_init_map_token (struct btrfs_map_token *token,struct extent_buffer *eb); -/* * Some macros to generate set/get functions for the struct fields. This * assumes there is a lefoo_to_cpu for every type, so lets make a simple one
@@ -56,11 +48,6 @@ static inline void put_unaligned_le8(u8 val, void *p) sizeof_field(type, member)))#define DECLARE_BTRFS_SETGET_BITS (bits) \ -u##bits btrfs_get_token_##bits(struct btrfs_map_token *token, \ - const void *ptr, unsigned long off); \ -void btrfs_set_token_##bits(struct btrfs_map_token *token, \ - const void *ptr, unsigned long off, \ - u##bits val); \ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \ const void *ptr, unsigned long off); \ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \
@@ -83,18 +70,6 @@ static inline void btrfs_set_##name(const struct extent_buffer *eb, type *s, \ { \ static_assert(sizeof(u##bits) == sizeof_field(type, member)); \ btrfs_set_##bits(eb, s, offsetof(type, member), val); \ -} \ -static inline u##bits btrfs_token_##name(struct btrfs_map_token *token, \ - const type *s) \ -{ \ - static_assert(sizeof(u##bits) == sizeof_field(type, member)); \ - return btrfs_get_token_##bits(token, s, offsetof(type, member));\ -} \ -static inline void btrfs_set_token_##name(struct btrfs_map_token *token,\ - type *s, u##bits val) \ -{ \ - static_assert(sizeof(u##bits) == sizeof_field(type, member)); \ - btrfs_set_token_##bits(token, s, offsetof(type, member), val); \ }#define BTRFS_SETGET_HEADER_FUNCS (name, type, member, bits) \
@@ -479,18 +454,6 @@ static inline void btrfs_set_item_##member(const struct extent_buffer *eb, \ int slot, u32 val) \ { \ btrfs_set_raw_item_##member(eb, btrfs_item_nr(eb, slot), val); \ -} \ -static inline u32 btrfs_token_item_##member(struct btrfs_map_token *token, \ - int slot) \ -{ \ - struct btrfs_item *item = btrfs_item_nr(token->eb, slot); \ - return btrfs_token_raw_item_##member(token, item); \ -} \ -static inline void btrfs_set_token_item_##member(struct btrfs_map_token *token, \ - int slot, u32 val) \ -{ \ - struct btrfs_item *item = btrfs_item_nr(token->eb, slot); \ - btrfs_set_token_raw_item_##member(token, item, val); \ }BTRFS_ITEM_SETGET_FUNCS (offset)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1072/1756 btrfs: accessors: simplify folio bounds checks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 00c0cf844465139ee6d9b271549295da3c7822ca ]
As we can a have non-contiguous range in the eb->folios, any item can be straddling two folios and we need to check if it can be read in one go or in two parts. For that there's a check which is not implemented in the simplest way:
offset in folio + size <= folio size
With a simple expression transformation:
oil + size <= unit_size
size <= unit_size - oil
sizeof() <= part
this can be simplified and reusing existing run-time or compile-time constants.
Add likely() annotation for this expression as this is the fast path and compiler sometimes reorders that after the followup block with the memcpy (observed in practice with other simplifications).
Overall effect on stack consumption:
btrfs_get_8 -8 (80 -> 72)
btrfs_set_8 -8 (88 -> 80)
And .ko size (due to optimizations making use of the direct constants):
text data bss dec hex filename
1456601 115665 16088 1588354 183c82 pre/btrfs.ko 1456093 115665 16088 1587846 183a86 post/btrfs.ko
DELTA: -508
Stable-dep-of: 08f750d9f893 ("btrfs: fix off-by-one end offset check in report_setget_bounds()")
--- fs/btrfs/accessors.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/accessors.c +2 -2
@@ -59,7 +59,7 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \ u8 lebytes[sizeof(u##bits)]; \ \ ASSERT(check_setget_bounds(eb, ptr, off, size)); \ - if (INLINE_EXTENT_BUFFER_PAGES == 1 || oil + size <= unit_size) \ + if (INLINE_EXTENT_BUFFER_PAGES == 1 || likely(sizeof(u##bits) <= part)) \ return get_unaligned_le##bits(kaddr + oil); \ \ memcpy(lebytes, kaddr + oil, part); \
@@ -82,7 +82,7 @@ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \ \ASSERT (check_setget_bounds (eb, ptr, off, size)); \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || \ - oil + size <= unit_size) { \ + likely(sizeof(u##bits) <= part)) { \ put_unaligned_le##bits(val, kaddr + oil); \ return; \ } \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1073/1756 btrfs: accessors: use type sizeof constants directly
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit 378c95c477b4bdc3a8283ebdf3754e308bf65891 ]
Now unit_size is used only once, so use it directly in 'part' calculation. Don't cache sizeof(type) in a variable. While this is a compile-time constant, forcing the type 'int' generates worse code as it leads to additional conversion from 32 to 64 bit type on x86_64.
The sizeof() is used only a few times and it does not make the code that harder to read, so use it directly and let the compiler utilize the immediate constants in the context it needs. The .ko code size slightly increases (+50) but further patches will reduce that again.
Stable-dep-of: 08f750d9f893 ("btrfs: fix off-by-one end offset check in report_setget_bounds()")
--- fs/btrfs/accessors.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-)
fs/btrfs/accessors.c +6 -10
@@ -52,19 +52,17 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \const unsigned long idx =get_eb_folio_index (eb, member_offset);\const unsigned long oil =get_eb_offset_in_folio (eb, \ member_offset);\ -const int unit_size = eb->folio_size; \char *kaddr =folio_address (eb->folios[idx]); \ - const int size = sizeof(u##bits); \ - const int part = unit_size - oil; \ +const int part = eb->folio_size - oil; \ u8 lebytes[sizeof(u##bits)]; \ \ - ASSERT(check_setget_bounds(eb, ptr, off, size)); \ + ASSERT(check_setget_bounds(eb, ptr, off, sizeof(u##bits))); \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || likely(sizeof(u##bits) <= part)) \ return get_unaligned_le##bits(kaddr + oil); \ \ memcpy(lebytes, kaddr + oil, part); \ kaddr = folio_address(eb->folios[idx + 1]); \ - memcpy(lebytes + part, kaddr, size - part); \ + memcpy(lebytes + part, kaddr, sizeof(u##bits) - part); \ return get_unaligned_le##bits(lebytes); \ } \ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \
@@ -74,13 +72,11 @@ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \const unsigned long idx =get_eb_folio_index (eb, member_offset);\const unsigned long oil =get_eb_offset_in_folio (eb, \ member_offset);\ -const int unit_size = eb->folio_size; \char *kaddr =folio_address (eb->folios[idx]); \ - const int size = sizeof(u##bits); \ - const int part = unit_size - oil; \ +const int part = eb->folio_size - oil; \ u8 lebytes[sizeof(u##bits)]; \ \ - ASSERT(check_setget_bounds(eb, ptr, off, size)); \ + ASSERT(check_setget_bounds(eb, ptr, off, sizeof(u##bits))); \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || \ likely(sizeof(u##bits) <= part)) { \ put_unaligned_le##bits(val, kaddr + oil); \
@@ -90,7 +86,7 @@ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \ put_unaligned_le##bits(val, lebytes); \ memcpy(kaddr + oil, lebytes, part); \ kaddr = folio_address(eb->folios[idx + 1]); \ - memcpy(kaddr, lebytes + part, size - part); \ + memcpy(kaddr, lebytes + part, sizeof(u##bits) - part); \ }DEFINE_BTRFS_SETGET_BITS (8 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1074/1756 btrfs: accessors: inline eb bounds check and factor out the error report
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Sterba <[email protected]>
[ Upstream commit d5a87dbd958398c1926dd35a328ccf89a410cbd2 ]
There's a check in each set/get helper if the requested range is within extent buffer bounds, and if it's not then report it. This was in an ASSERT statement so with CONFIG_BTRFS_ASSERT this crashes right away, on other configs this is only reported but reading out of the bounds is done anyway. There are currently no known reports of this particular condition failing.
There are some drawbacks though. The behaviour dependence on the assertions being compiled in or not and a less visible effect of inlining report_setget_bounds() into each helper.
As the bounds check is expected to succeed almost always it's ok to inline it but make the report a function and move it out of the helper completely (__cold puts it to a different section). This also skips reading/writing the requested range in case it fails.
This improves stack usage significantly:
btrfs_get_16 -48 (80 -> 32) btrfs_get_32 -48 (80 -> 32) btrfs_get_64 -48 (80 -> 32) btrfs_get_8 -48 (72 -> 24) btrfs_set_16 -56 (88 -> 32) btrfs_set_32 -56 (88 -> 32) btrfs_set_64 -56 (88 -> 32) btrfs_set_8 -48 (80 -> 32)
NEW (48):
report_setget_bounds 48
LOST/NEW DELTA: +48
PRE/POST DELTA: -360
Same as .ko size:
text data bss dec hex filename
1456079 115665 16088 1587832 183a78 pre/btrfs.ko 1454951 115665 16088 1586704 183610 post/btrfs.ko
DELTA: -1128
Stable-dep-of: 08f750d9f893 ("btrfs: fix off-by-one end offset check in report_setget_bounds()")
--- fs/btrfs/accessors.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
fs/btrfs/accessors.c +15 -14
@@ -9,20 +9,15 @@#include "fs.h" #include "accessors.h" -static bool check_setget_bounds (const struct extent_buffer *eb, -const void *ptr,unsigned off,int size) +static void __cold report_setget_bounds (const struct extent_buffer *eb, +const void *ptr,unsigned off,int size) { -const unsigned long member_offset = (unsigned long )ptr + off; +unsigned long member_offset = (unsigned long )ptr + off; -if (unlikely (member_offset + size > eb->len)) { -btrfs_warn (eb->fs_info, -"bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d" , - (member_offset > eb->len ?"start" :"end" ), - (unsigned long )ptr, eb->start, member_offset, size); -return false; - } - -return true; +btrfs_warn (eb->fs_info, +"bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d" , + (member_offset > eb->len ?"start" :"end" ), + (unsigned long )ptr, eb->start, member_offset, size); }/*
@@ -56,7 +51,10 @@ u##bits btrfs_get_##bits(const struct extent_buffer *eb, \const int part = eb->folio_size - oil; \ u8 lebytes[sizeof(u##bits)]; \ \ - ASSERT(check_setget_bounds(eb, ptr, off, sizeof(u##bits))); \ + if (unlikely(member_offset + sizeof(u##bits) > eb->len)) { \ + report_setget_bounds(eb, ptr, off, sizeof(u##bits)); \ + return 0; \ + } \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || likely(sizeof(u##bits) <= part)) \ return get_unaligned_le##bits(kaddr + oil); \ \
@@ -76,7 +74,10 @@ void btrfs_set_##bits(const struct extent_buffer *eb, void *ptr, \const int part = eb->folio_size - oil; \ u8 lebytes[sizeof(u##bits)]; \ \ - ASSERT(check_setget_bounds(eb, ptr, off, sizeof(u##bits))); \ + if (unlikely(member_offset + sizeof(u##bits) > eb->len)) { \ + report_setget_bounds(eb, ptr, off, sizeof(u##bits)); \ + return; \ + } \ if (INLINE_EXTENT_BUFFER_PAGES == 1 || \ likely(sizeof(u##bits) <= part)) { \ put_unaligned_le##bits(val, kaddr + oil); \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1075/1756 btrfs: fix off-by-one end offset check in report_setget_bounds()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 08f750d9f8930e4ca053913b5ca3fd49fd9268c9 ]
The addressable range with an extent buffer goes from byte 0 to byte eb->len - 1, so if a byte address matches eb->len, it's already beyond the addressable range and we should log that it's bad start address and not end address.
--- fs/btrfs/accessors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/accessors.c +1 -1
@@ -16,7 +16,7 @@ static void __cold report_setget_bounds(const struct extent_buffer *eb,btrfs_warn (eb->fs_info,"bad eb member %s: ptr 0x%lx start %llu member offset %lu size %d" , - (member_offset > eb->len ?"start" :"end" ), + (member_offset >= eb->len ?"start" :"end" ), (unsigned long )ptr, eb->start, member_offset, size); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1076/1756 btrfs: qgroup: do not treat "ret > 0" as error when deleting a qgroup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qu Wenruo <[email protected]>
[ Upstream commit dd906477cc2c33c82ec17e6301bd4be4ea588565 ]
[BUG]
There is a bug report that when removing a child qgroup, if removing the qgroup requires a rescan, it will delete the on-disk relation and qgroup items but not the in-memory qgroup rb entry.
This makes all later qgroup rescan to fail.
[CAUSE]
The call chain looks like the following:
btrfs_remove_qgroup()
|- __del_qgroup_relation() | |- quick_update_accounting() | Which returns 1, showing this operation will require | a qgroup rescan |- if (ret) goto out;
Which skips the del_qgroup_rb() call, leaving the in-memory qgroup rb entry still intact.
Then later qgroup rescan/update will always fail and mark qgroup inconsistent:
btrfs_run_qgroups()
|- update_qgroup_info_item() | |- btrfs_search_slot() | Which returns -ENOENT, as the qgroup info item is already | deleted. |- qgroup_mark_inconsistent() |- return -ENOENT;
[FIX]
Do not treat "ret > 0" as an error.
--- fs/btrfs/qgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/qgroup.c +1 -1
@@ -1865,7 +1865,7 @@ int btrfs_remove_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid) struct btrfs_qgroup_list, next_group); ret =__del_qgroup_relation (trans, qgroupid, list->group->qgroupid); -if (ret) +if (ret <0 ) goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1077/1756 btrfs: qgroup: fix swapped blocks existence check when tracing after COW
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 0388b5bd3a6eb8bcb20208c3b6dbee96fd30bbe0 ]
In btrfs_qgroup_trace_subtree_after_cow(), after we erase the swapped block, iterate over all possible tree levels to check if we sill have other swapped blocks. However the check is wrong, it considers that there are other swapped blocks if any rbtree for any level is empty, instead of not empty. As a consequence we set blocks->swapped to true basically every time since we always find an empty rbtree at least at level 7, since in practice it's nearly impossible to find such a huge btree. This makes every future call to btrfs_qgroup_trace_subtree_after_cow() do an unnecessary rbtree search instead of returning immediately.
Fix this by updating the condition to set swapped to true if we find an rbtree that is not empty.
--- fs/btrfs/ctree.h | 2 +- fs/btrfs/qgroup.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/ctree.h +1 -1
@@ -155,7 +155,7 @@ enum {*/ struct btrfs_qgroup_swapped_blocks {spinlock_t lock; -/* RM_EMPTY_ROOT() of above blocks[] */ +/* True if any of the rbtrees in the blocks array below is not empty. */ bool swapped;struct rb_root blocks[BTRFS_MAX_LEVEL ]; };
fs/btrfs/qgroup.c +1 -1
@@ -4918,7 +4918,7 @@ int btrfs_qgroup_trace_subtree_after_cow(struct btrfs_trans_handle *trans,/* Found one, remove it from @blocks first and update blocks->swapped */ rb_erase (&block->node, &blocks->blocks[level]);for (i =0 ; i <BTRFS_MAX_LEVEL ; i++) { -if (RB_EMPTY_ROOT (&blocks->blocks[i])) { +if (!RB_EMPTY_ROOT (&blocks->blocks[i])) { swapped = true;break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1078/1756 btrfs: fix lost error return value in btrfs_alloc_logged_file_extent()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 784cd5a83476c6c720521f21350fb823928555ff ]
If we fail to allocate a reserved file extent we then call btrfs_record_squota_delta() and assign its return value to 'ret', discarding the error from the failed allocation attempt and allowing log replay to proceed as if no errors happened, resulting in some replayed file extent item to point to an unallocated extent. At the moment btrfs_record_squota_delta() always returns 0 (success).
--- fs/btrfs/extent-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/extent-tree.c +2 -1
@@ -5010,7 +5010,8 @@ int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, offset, ins, 1, root_objectid);if (ret)btrfs_pin_extent (trans, ins->objectid, ins->offset); - ret =btrfs_record_squota_delta (fs_info, &delta); +else + ret =btrfs_record_squota_delta (fs_info, &delta);btrfs_put_block_group (block_group);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1079/1756 btrfs: defrag: fix check to see if next extent can be defragged too
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit eb55bc2bfe204e6bfccfe179226d7fb5024cb010 ]
We want to check if the next extent is at maximum capacity but we are passing the current extent map to get_extent_max_capacity() and not the next extent map. For example if the current extent is compressed (its maximum capacity is 128K) and the next extent is uncompressed (its maximum capacity is 128M), then we can bail out and not defrag the next extent too - when for example the next extent as a size of 128K, is uncompressed, and the extent threshold is >= 256K.
--- fs/btrfs/defrag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/defrag.c +1 -1
@@ -826,7 +826,7 @@ static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em,* If the next extent is at its max capacity, defragging current extent * makes no sense, as the total number of extents won't change. */ -if (next->len >=get_extent_max_capacity (fs_info, em)) +if (next->len >=get_extent_max_capacity (fs_info, next)) goto out;/* Skip older extent */ if (next->generation < newer_than)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1080/1756 power: supply: generic-adc-battery: Propagate charged GPIO errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 36b0abe904ac9cbdce6161d9c7c0bcac963bb3fe ]
devm_gpiod_get_optional() may return an error pointer such as -EPROBE_DEFER, but gab_probe() only checks for NULL. The error pointer is then passed to gpiod_to_irq() and the original error, including -EPROBE_DEFER, is lost.
Check the return value and propagate errors from the charged GPIO lookup.
--- drivers/power/supply/generic-adc-battery.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/power/supply/generic-adc-battery.c +3 -0
@@ -243,6 +243,9 @@ static int gab_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev, ret,"Failed to register delayed work\n" ); adc_bat->charge_finished =devm_gpiod_get_optional (&pdev->dev,"charged" ,GPIOD_IN ); +if (IS_ERR (adc_bat->charge_finished)) +return dev_err_probe (&pdev->dev,PTR_ERR (adc_bat->charge_finished), +"failed to get charged GPIO\n" );if (adc_bat->charge_finished) {int irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1081/1756 mtd: rawnand: pl353: fix clk reference leak in pl35x_nfc_setup_interface()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haotian Zhang <[email protected]>
[ Upstream commit 1ce45f0e74d60e8279ed380c97047e6c351aee1b ]
pl35x_nfc_setup_interface() obtains a reference to the SMC "memclk" with of_clk_get_by_name() and only uses it to read the clock rate. The reference is never released: the function has many early return paths and no clk_put() call anywhere, so the clock reference is leaked.
The hook is invoked repeatedly by the NAND core (nand_reset(), nand_setup_interface() and the NAND_DATA_IFACE_CHECK_ONLY mode probing loops), so the reference count keeps growing.
Release the clock reference with clk_put() as soon as its rate has been read.
--- drivers/mtd/nand/raw/pl35x-nand-controller.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/nand/raw/pl35x-nand-controller.c +1 -0
@@ -807,6 +807,7 @@ static int pl35x_nfc_setup_interface(struct nand_chip *chip, int cs,* macro to convert from one to the other. */ period_ns =NSEC_PER_SEC /clk_get_rate (mclk); +clk_put (mclk);/* * PL35X SMC needs one extra read cycle in SDR Mode 5. This is not
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1082/1756 nfs: set gencount on protocol-specific remove
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roberto Bergantinos Corpas <[email protected]>
[ Upstream commit 8c955dacf45f8964b98f26910ffecb5e26c02e31 ]
commit bd4928ec799b ("NFS: Avoid changing nlink when file removes and attribute updates race") avoids races on attribute cache with any inflight RPC that may modify inode attributes (and gencount) during i.e. REMOVE.
However it does not take into account that REMOVE may trigger a delegation return which also advances gencount (via the attribute refresh during delegation return), and in that case the gencount mismatch is not due to an inflight RPC that already reflected the removal.
Push the setting of gencount under each version-specific layer, reordering correctly for nfsv4 case after the delegation returns.
This fixes LTP/inotify04 failure after bd4928ec799b.
--- fs/nfs/dir.c | 13 +++---------- fs/nfs/internal.h | 1 + fs/nfs/nfs3proc.c | 8 ++++++++ fs/nfs/nfs4proc.c | 5 +++++ fs/nfs/proc.c | 8 ++++++++ 5 files changed, 25 insertions(+), 10 deletions(-)
fs/nfs/dir.c +3 -10
@@ -1904,7 +1904,7 @@ static int nfs_dentry_delete(const struct dentry *dentry) }/* Ensure that we revalidate inode->i_nlink */ -static void nfs_drop_nlink (struct inode *inode,unsigned long gencount) +void nfs_drop_nlink (struct inode *inode,unsigned long gencount) {struct nfs_inode *nfsi =NFS_I (inode);
@@ -1918,6 +1918,7 @@ static void nfs_drop_nlink(struct inode *inode, unsigned long gencount) NFS_INO_INVALID_NLINK);spin_unlock (&inode->i_lock); } +EXPORT_SYMBOL_GPL (nfs_drop_nlink);/* * Called when the dentry loses inode.
@@ -2522,7 +2523,6 @@ EXPORT_SYMBOL_GPL(nfs_rmdir);static int nfs_safe_remove (struct dentry *dentry) {struct inode *dir =d_inode (dentry->d_parent); -struct inode *inode =d_inode (dentry);int error = -EBUSY ;dfprintk (VFS ,"NFS: safe_remove(%pd2)\n" , dentry);
@@ -2534,14 +2534,7 @@ static int nfs_safe_remove(struct dentry *dentry) }trace_nfs_remove_enter (dir, dentry); -if (inode !=NULL ) { -unsigned long gencount =READ_ONCE (NFS_I (inode)->attr_gencount); - - error =NFS_PROTO (dir)->remove (dir, dentry); -if (error ==0 ) -nfs_drop_nlink (inode, gencount); - }else - error =NFS_PROTO (dir)->remove (dir, dentry); + error =NFS_PROTO (dir)->remove (dir, dentry);if (error == -ENOENT )nfs_dentry_handle_enoent (dentry);trace_nfs_remove_exit (dir, dentry, error);
fs/nfs/internal.h +1 -0
@@ -396,6 +396,7 @@ extern unsigned long nfs_access_cache_count(struct shrinker *shrink, struct shrink_control *sc);extern unsigned long nfs_access_cache_scan (struct shrinker *shrink,struct shrink_control *sc); +extern void nfs_drop_nlink (struct inode *inode,unsigned long gencount);struct dentry *nfs_lookup (struct inode *,struct dentry *,unsigned int );void nfs_d_prune_case_insensitive_aliases (struct inode *inode); int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *,
fs/nfs/nfs3proc.c +8 -0
@@ -448,13 +448,21 @@ nfs3_proc_remove(struct inode *dir, struct dentry *dentry) .rpc_resp = &res, };int status = -ENOMEM ; +struct inode *inode =d_inode (dentry); +unsigned long gencount;dprintk ("NFS call remove %pd2\n" , dentry); res.dir_attr =nfs_alloc_fattr ();if (res.dir_attr ==NULL ) goto out; +if (inode) + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); + status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); +if (status ==0 && inode) +nfs_drop_nlink (inode, gencount); +nfs_post_op_update_inode (dir, res.dir_attr);nfs_free_fattr (res.dir_attr); out:
fs/nfs/nfs4proc.c +5 -0
@@ -4915,12 +4915,14 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) };struct inode *inode =d_inode (dentry);int err; +unsigned long gencount;if (inode) {if (inode->i_nlink ==1 )nfs4_inode_return_delegation (inode);else nfs4_inode_make_writeable (inode); + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); } do { err = _nfs4_proc_remove(dir, &dentry->d_name, NF4REG);
@@ -4928,6 +4930,9 @@ static int nfs4_proc_remove(struct inode *dir, struct dentry *dentry) err =nfs4_handle_exception (NFS_SERVER (dir), err, &exception); }while (exception.retry); + +if (err ==0 && inode) +nfs_drop_nlink (inode, gencount);return err; }
fs/nfs/proc.c +8 -0
@@ -322,9 +322,17 @@ nfs_proc_remove(struct inode *dir, struct dentry *dentry) .rpc_argp = &arg, };int status; +struct inode *inode =d_inode (dentry); +unsigned long gencount;dprintk ("NFS call remove %pd2\n" ,dentry); +if (inode) + gencount =READ_ONCE (NFS_I (inode)->attr_gencount); + status =rpc_call_sync (NFS_CLIENT (dir), &msg,0 ); +if (status ==0 && inode) +nfs_drop_nlink (inode, gencount); +nfs_mark_for_revalidate (dir);dprintk ("NFS reply remove: %d\n" , status);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1083/1756 ASoC: codecs: rt5659: propagate GPIO errors
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit c1e321bd5ce6ae3702db65837cfe0c792634d603 ]
devm_gpiod_get_optional() may return an error pointer, including -EPROBE_DEFER, but rt5659_i2c_probe() does not handle these errors for the ldo1-en GPIO and does not check for errors for the reset GPIO.
Check the return values and propagate GPIO lookup errors.
--- sound/soc/codecs/rt5659.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5659.c +5 -1
@@ -4112,10 +4112,14 @@ static int rt5659_i2c_probe(struct i2c_client *i2c) rt5659->gpiod_ldo1_en =devm_gpiod_get_optional (&i2c->dev,"ldo1-en" ,GPIOD_OUT_HIGH );if (IS_ERR (rt5659->gpiod_ldo1_en)) -dev_warn (&i2c->dev,"Request ldo1-en GPIO failed\n" ); +return dev_err_probe (&i2c->dev,PTR_ERR (rt5659->gpiod_ldo1_en), +"failed to get ldo1-en GPIO\n" ); rt5659->gpiod_reset =devm_gpiod_get_optional (&i2c->dev,"reset" ,GPIOD_OUT_HIGH ); +if (IS_ERR (rt5659->gpiod_reset)) +return dev_err_probe (&i2c->dev,PTR_ERR (rt5659->gpiod_reset), +"failed to get reset GPIO\n" );/* Sleep for 300 ms miniumum */ msleep (300 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1084/1756 rcutorture: Fix divide-by-zero with fwd_progress_div=1
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kunwu Chan <[email protected]>
[ Upstream commit 5b748d8aa6833f2dec3f545311be69a2064bc6d1 ]
When fwd_progress_div=1, the forward-progress test computes:
sd4 = (sd + div - 1) / div = sd
dur = sd4 + torture_random(&trs) % (sd - sd4) = sd4 + % 0
The modulo operation with a zero divisor triggers an integer division by zero (undefined behavior at the C level, #DE trap on x86), causing a kernel Oops and panic. On x86_64, this manifests as:
rcu_torture_fwd_prog_nr: Starting forward-progress test 0
Oops: divide error: 0000 [#1] SMP PTI RIP: 0010:rcu_torture_fwd_prog+0x90b/0x1160 R12: 0000000000000000
The existing guard only handles non-positive values. However, fwd_progress_div=1 also makes the random range empty because sd4 == sd.
Change the guard to reject values below 2. The forward-progress test only reaches this calculation when stall_dur() is positive, so sd = stall_dur() + 1 >= 2. For fwd_progress_div >= 2, sd4 < sd, ensuring that sd - sd4 is at least 1.
Keep the existing fallback to the default value of 4 for invalid values.
Verified with QEMU/KVM: a 138-second run with fwd_progress_div=1 completed 81 forward-progress test cycles without a crash.
--- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/rcu/rcutorture.c +1 -1
@@ -3034,7 +3034,7 @@ static int __init rcu_torture_fwd_prog_init(void) }if (fwd_progress_holdoff <=0 ) fwd_progress_holdoff =1 ; -if (fwd_progress_div <=0 ) +if (fwd_progress_div <2 ) fwd_progress_div =4 ; rfp =kcalloc (fwd_progress,sizeof (*rfp),GFP_KERNEL ); fwd_prog_tasks =kcalloc (fwd_progress,sizeof (*fwd_prog_tasks),GFP_KERNEL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1085/1756 wifi: ath10k: avoid IDR mutation during TX cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 1c1a208e65a08191901cfded3bbccc4a54e4a75c ]
ath10k_htt_flush_tx_queue() walks pending_tx with idr_for_each(). Its callback calls ath10k_txrx_tx_unref(), which removes the current entry from pending_tx through ath10k_htt_tx_free_msdu_id().
idr_for_each() keeps radix-tree iterator state across the callback. Removing the current entry can therefore invalidate that state and make the remaining walk unsafe.
Use idr_for_each_entry(), which starts a fresh lookup after each callback. The current entry can then be removed safely, while the following idr_destroy() continues to release the IDR itself.
--- drivers/net/wireless/ath/ath10k/htt_tx.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath10k/htt_tx.c +7 -5
@@ -506,9 +506,8 @@ int ath10k_htt_tx_start(struct ath10k_htt *htt)return ret; } -static int ath10k_htt_tx_clean_up_pending (int msdu_id,void *skb,void *ctx) +static void ath10k_htt_tx_clean_up_pending (int msdu_id,struct ath10k *ar) { -struct ath10k *ar = ctx;struct ath10k_htt *htt = &ar->htt;struct htt_tx_done tx_done = {0 };
@@ -518,8 +517,6 @@ static int ath10k_htt_tx_clean_up_pending(int msdu_id, void *skb, void *ctx) tx_done.status =HTT_TX_COMPL_STATE_DISCARD ;ath10k_txrx_tx_unref (htt, &tx_done); - -return 0 ; }void ath10k_htt_tx_destroy (struct ath10k_htt *htt)
@@ -536,8 +533,13 @@ void ath10k_htt_tx_destroy(struct ath10k_htt *htt)static void ath10k_htt_flush_tx_queue (struct ath10k_htt *htt) { +struct sk_buff *msdu; +int msdu_id; +ath10k_htc_stop_hl (htt->ar); -idr_for_each (&htt->pending_tx, ath10k_htt_tx_clean_up_pending, htt->ar); + +idr_for_each_entry (&htt->pending_tx, msdu, msdu_id) +ath10k_htt_tx_clean_up_pending (msdu_id, htt->ar); }void ath10k_htt_tx_stop (struct ath10k_htt *htt)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1086/1756 wifi: ath11k: avoid IDR mutation during pending mgmt TX cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 3e7f5d362b2b3a21b3adb4b860aad14b69a896ad ]
The pending management TX cleanup walks txmgmt_idr with idr_for_each(), and its callback removes the current entry. This can invalidate the radix-tree iterator retained by idr_for_each().
Use idr_for_each_entry() so every iteration starts with a fresh lookup. Continue to remove each entry under txmgmt_idr_lock before freeing its skb, preventing concurrent TX completion from finding a stale skb pointer.
--- drivers/net/wireless/ath/ath11k/core.c | 3 +-- drivers/net/wireless/ath/ath11k/mac.c | 12 ++++++------ drivers/net/wireless/ath/ath11k/mac.h | 2 +- 3 files changed, 8 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath11k/core.c +1 -2
@@ -2122,8 +2122,7 @@ void ath11k_core_pre_reconfigure_recovery(struct ath11k_base *ab)complete (&ar->thermal.wmi_sync);wake_up (&ar->dp.tx_empty_waitq); -idr_for_each (&ar->txmgmt_idr, - ath11k_mac_tx_mgmt_pending_free, ar); +ath11k_mac_tx_mgmt_pending_free (ar);idr_destroy (&ar->txmgmt_idr);wake_up (&ar->txmgmt_empty_waitq);
drivers/net/wireless/ath/ath11k/mac.c +6 -6
@@ -6026,13 +6026,13 @@ static void ath11k_mac_tx_mgmt_free(struct ath11k *ar, int buf_id)ath11k_mgmt_over_wmi_tx_drop (ar, msdu); } -int ath11k_mac_tx_mgmt_pending_free (int buf_id,void *skb,void *ctx) +void ath11k_mac_tx_mgmt_pending_free (struct ath11k *ar) { -struct ath11k *ar = ctx; - -ath11k_mac_tx_mgmt_free (ar, buf_id); +struct sk_buff *msdu; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, msdu, buf_id) +ath11k_mac_tx_mgmt_free (ar, buf_id); }static int ath11k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx)
@@ -10277,7 +10277,7 @@ static void __ath11k_mac_unregister(struct ath11k *ar)ieee80211_unregister_hw (ar->hw); -idr_for_each (&ar->txmgmt_idr, ath11k_mac_tx_mgmt_pending_free, ar); +ath11k_mac_tx_mgmt_pending_free (ar);idr_destroy (&ar->txmgmt_idr);kfree (ar->mac.sbands[NL80211_BAND_2GHZ ].channels);
drivers/net/wireless/ath/ath11k/mac.h +1 -1
@@ -162,7 +162,7 @@ struct ath11k *ath11k_mac_get_ar_by_pdev_id(struct ath11k_base *ab, u32 pdev_id)void ath11k_mac_drain_tx (struct ath11k *ar);void ath11k_mac_peer_cleanup_all (struct ath11k *ar); -int ath11k_mac_tx_mgmt_pending_free (int buf_id,void *skb,void *ctx); +void ath11k_mac_tx_mgmt_pending_free (struct ath11k *ar);u8 ath11k_mac_bw_to_mac80211_bw (u8 bw);enum nl80211_he_gi ath11k_mac_he_gi_to_nl80211_he_gi (u8 sgi);enum nl80211_he_ru_alloc ath11k_mac_phy_he_ru_to_nl80211_he_ru_alloc (u16 ru_phy);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1087/1756 wifi: ath11k: avoid IDR mutation during vif mgmt TX cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit dc29226dada34a6d19af77b4b51e90f8a3a8de34 ]
ath11k_mac_op_remove_interface() walks txmgmt_idr with idr_for_each(), and its callback removes each entry belonging to the interface. Removing the current entry can invalidate the radix-tree iterator retained by idr_for_each().
Move the walk into a helper that uses idr_for_each_entry(). It performs a fresh lookup for every iteration, so each matching entry can be removed through the locked removal helper without retaining iterator state across the removal.
--- drivers/net/wireless/ath/ath11k/mac.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath11k/mac.c +11 -10
@@ -6035,16 +6035,18 @@ void ath11k_mac_tx_mgmt_pending_free(struct ath11k *ar)ath11k_mac_tx_mgmt_free (ar, buf_id); } -static int ath11k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx) +static void ath11k_mac_vif_txmgmt_cleanup (struct ath11k *ar, +struct ieee80211_vif *vif) { -struct ieee80211_vif *vif = ctx; -struct ath11k_skb_cb *skb_cb =ATH11K_SKB_CB ((struct sk_buff *)skb); -struct ath11k *ar = skb_cb->ar; - -if (skb_cb->vif == vif) -ath11k_mac_tx_mgmt_free (ar, buf_id); +struct ath11k_skb_cb *skb_cb; +struct sk_buff *skb; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, skb, buf_id) { + skb_cb =ATH11K_SKB_CB (skb); +if (skb_cb->vif == vif) +ath11k_mac_tx_mgmt_free (ar, buf_id); + } } static int ath11k_mac_mgmt_tx_wmi(struct ath11k *ar, struct ath11k_vif *arvif,
@@ -7100,8 +7102,7 @@ static void ath11k_mac_op_remove_interface(struct ieee80211_hw *hw,ath11k_peer_cleanup (ar, arvif->vdev_id); -idr_for_each (&ar->txmgmt_idr, - ath11k_mac_vif_txmgmt_idr_remove, vif); +ath11k_mac_vif_txmgmt_cleanup (ar, vif);for (i =0 ; i < ab->hw_params.max_tx_ring; i++) {spin_lock_bh (&ab->dp.tx_ring[i].tx_idr_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1088/1756 wifi: ath12k: avoid IDR mutation during vif mgmt TX cleanup
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 4aa45334eb23d40bf31c43405daea9b73469f2a6 ]
ath12k_mac_vdev_delete() walks txmgmt_idr with idr_for_each(), and its callback removes each entry belonging to the interface. Removing the current entry can invalidate the radix-tree iterator retained by idr_for_each().
Move the walk into a helper that uses idr_for_each_entry(). It performs a fresh lookup for every iteration, so each matching entry can be removed through the locked removal helper without retaining iterator state across the removal.
--- drivers/net/wireless/ath/ath12k/mac.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +11 -10
@@ -5708,16 +5708,18 @@ int ath12k_mac_tx_mgmt_pending_free(int buf_id, void *skb, void *ctx)return 0 ; } -static int ath12k_mac_vif_txmgmt_idr_remove (int buf_id,void *skb,void *ctx) +static void ath12k_mac_vif_txmgmt_cleanup (struct ath12k *ar, +struct ieee80211_vif *vif) { -struct ieee80211_vif *vif = ctx; -struct ath12k_skb_cb *skb_cb =ATH12K_SKB_CB (skb); -struct ath12k *ar = skb_cb->ar; - -if (skb_cb->vif == vif) -ath12k_mac_tx_mgmt_free (ar, buf_id); +struct ath12k_skb_cb *skb_cb; +struct sk_buff *skb; +int buf_id; -return 0 ; +idr_for_each_entry (&ar->txmgmt_idr, skb, buf_id) { + skb_cb =ATH12K_SKB_CB (skb); +if (skb_cb->vif == vif) +ath12k_mac_tx_mgmt_free (ar, buf_id); + } } static int ath12k_mac_mgmt_tx_wmi(struct ath12k *ar, struct ath12k_vif *arvif,
@@ -6877,8 +6879,7 @@ static int ath12k_mac_vdev_delete(struct ath12k *ar, struct ieee80211_vif *vif)ath12k_peer_cleanup (ar, arvif->vdev_id);ath12k_arvif_put_cache (arvif); -idr_for_each (&ar->txmgmt_idr, - ath12k_mac_vif_txmgmt_idr_remove, vif); +ath12k_mac_vif_txmgmt_cleanup (ar, vif);ath12k_mac_vif_unref (&ab->dp, vif);ath12k_dp_tx_put_bank_profile (&ab->dp, arvif->bank_id);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1089/1756 selftests/cgroup: ignore memory.reclaim -EAGAIN for zswap writeback test
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Harry Yoo (Meta) <[email protected]>
[ Upstream commit adbb0adb434d55bd02b18c8de6356f954a077c79 ]
The zswap_writeback_enabled test fails when a write to memory.reclaim returns -EAGAIN, which means less than the requested amount was reclaimed. attempt_writeback() propagates the -EAGAIN to the caller, and the test case is marked as failed even when zswap writeback did happen.
This heavily depends on the performance of the backing swap device. Reclaim does not wait for writeback (on cgroup v2), does not count pages that are under writeback as reclaimed, and memory.reclaim gives up after MAX_RECLAIM_RETRIES passes without making progress. On a slow device where reclaim does not make any progress before writeback completes, a write to memory.reclaim fails.
On a VM with zswap enabled, where IO delay was injected via dm-delay, the success rate of the zswap writeback test drops dramatically once the delay reaches 11 ms: 7% failures at 10 ms and 79% failures at 11 ms, n = 100.
When zswap writeback is enabled, ignore -EAGAIN from memory.reclaim and determine pass/fail based on the zswpwb counter because that is what zswap_writeback_enabled actually wants to test.
With this change, the test reliably passes even on a slow swap device (tested up to 1000 ms delay). This makes the test resilient against the performance of the swap device.
--- tools/testing/selftests/cgroup/test_zswap.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
tools/testing/selftests/cgroup/test_zswap.c +10 -1
@@ -322,7 +322,16 @@ static int attempt_writeback(const char *cgroup, void *arg)* it can't writeback to swap. */ ret =cg_write_numeric (cgroup,"memory.reclaim" , memsize); -if (!wb_enabled) + +/* +* When writeback is enabled, memory.reclaim may still fail to reclaim +* the requested amount of memory due to a slow swap device. +* Ignore -EAGAIN here. The caller determines pass/fail based on the +* zswap writeback counter. +*/ +if (wb_enabled && ret == -EAGAIN ) + ret =0 ; +else if (!wb_enabled) ret = (ret == -EAGAIN ) ?0 :-1 ; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1090/1756 mm/hmm/test: reject overflowing page counts
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit b59925301211ccc351d98d70b11f6d1b2c63150f ]
The number of pages comes directly from userspace. Shifting a value larger than ULONG_MAX >> PAGE_SHIFT discards its high bits before the existing end-address check. A request for a huge number of pages can therefore be accepted and processed as a much smaller request.
Reject page counts that cannot be represented as a byte size before performing the shift.
So far as ChatGPT and I can tell this doesn't cause an issue in practice but preventing this integer overflow is the correct thing to do.
--- lib/test_hmm.c | 2 ++ 1 file changed, 2 insertions(+)
lib/test_hmm.c +2 -0
@@ -1323,6 +1323,8 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp,if (cmd.addr & ~PAGE_MASK )return -EINVAL ; +if (cmd.npages >ULONG_MAX >>PAGE_SHIFT ) +return -EINVAL ;if (cmd.addr >= (cmd.addr + (cmd.npages <<PAGE_SHIFT )))return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1091/1756 ALSA: jack: Remove debugfs before freeing unregistered jacks
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit d3b59d50e1ff206aa519ed5c13bf6907f97dd6a6 ]
Jack debugfs files store a raw snd_jack_kctl pointer, so their callbacks must be drained before the attachment is freed. snd_jack_dev_free() unlinks and frees the attachments before calling snd_jack_dev_disconnect(). Its late snd_jack_remove_debugfs() call then has no entries left to traverse.
With CONFIG_SND_JACK_INJECTION_DEBUG and input support enabled, an HDA codec rebind on a live card can publish a non-phantom jack's type file while its component is still in SNDRV_DEV_BUILD. A later jack-control allocation failure permits the following order:
1. hda_codec_driver_probe() creates a jack and publishes its debugfs files before reaching snd_card_register().
2. A later control-build failure calls snd_hda_codec_cleanup_for_unbind(), then snd_hda_jack_tbl_clear() and snd_device_free(). __snd_device_disconnect() skips BUILD components. snd_jack_dev_free() frees the attachment before its late disconnect, leaving the debugfs files published.
3. After cleanup, a reader opens the surviving type file and jack_type_read() dereferences the freed attachment's jack pointer.
The card's debugfs root remains live throughout this sequence. The result is a use-after-free even without an overlapping read. An already admitted callback is also not drained by this cleanup.
Call snd_jack_remove_debugfs() before unlinking any controls in the free callback. The existing debugfs_remove() rundown blocks new accesses and waits for active callbacks while the attachment, control and jack remain valid. Roots cleared by an earlier disconnect are NULL, so repeating the removal is harmless.
KASAN report as below:
==================================================================
BUG: KASAN: slab-use-after-free in jack_type_read+0x1da/0x1f0
Read of size 8 at addr ffff8881085f9da0 by task python3/429
CPU: 2 UID: 0 PID: 429 Comm: python3 Not tainted 7.2.0-rc6-pmb-alsa-functional-v2+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? jack_type_read+0x1da/0x1f0
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? jack_type_read+0x1da/0x1f0
kasan_report+0xe0/0x110
? jack_type_read+0x1da/0x1f0
jack_type_read+0x1da/0x1f0
? __pfx_jack_type_read+0x10/0x10
? __pfx___debugfs_file_get+0x10/0x10
? __pfx_cp_new_stat+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? srso_alias_return_thunk+0x5/0xfbef5
? selinux_file_permission+0x122/0x570
full_proxy_read+0x11f/0x180
? __pfx_full_proxy_read+0x10/0x10
vfs_read+0x1a0/0xc20
? __pfx_vfs_read+0x10/0x10
? srso_alias_return_thunk+0x5/0xfbef5
? __do_sys_newfstat+0xa6/0x100
? find_held_lock+0x2b/0x80
? __pfx___do_sys_newfstat+0x10/0x10
ksys_read+0x111/0x200
? __pfx_ksys_read+0x10/0x10
? full_proxy_llseek+0x11e/0x170
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f7e392e7687
Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP: 002b:00007fff5f7b9180 EFLAGS: 00000202 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f7e39253780 RCX: 00007f7e392e7687
RDX: 0000000000002000 RSI: 000000003d2e9b00 RDI: 0000000000000003
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000202 R12: 00007f7e39253700
R13: 0000000000002000 R14: 00007f7e38d7e2c0 R15: 0000000000a55b98
</TASK>
Allocated by task 425:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
snd_jack_kctl_new+0x80/0x180
snd_jack_new+0x4b/0x490
snd_hda_jack_add_kctl_mst+0x19b/0x610
add_jack_kctl+0x204/0x320
snd_hda_jack_add_kctls+0x212/0x910
snd_hda_gen_build_controls+0x233/0x600
snd_hda_codec_build_controls+0x2e4/0x9f0
hda_codec_driver_probe+0x26e/0x590
really_probe+0x21f/0xa90
__driver_probe_device+0x1ec/0x490
device_driver_attach+0xdc/0x210
bind_store+0xec/0x180
drv_attr_store+0x79/0xb0
sysfs_kf_write+0xed/0x140
kernfs_fop_write_iter+0x34b/0x500
vfs_write+0x637/0x1010
ksys_write+0x111/0x200
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 425:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
snd_jack_kctl_private_free+0x153/0x200
__snd_ctl_remove+0x29f/0x3b0
snd_ctl_remove+0x46/0x70
snd_jack_dev_free+0x1b1/0x370
__snd_device_free+0x193/0x3f0
snd_device_free+0xcf/0x190
snd_hda_jack_tbl_clear+0x159/0x2e0
snd_hda_codec_cleanup_for_unbind+0x37e/0x9c0
hda_codec_driver_probe+0x3ae/0x590
really_probe+0x21f/0xa90
__driver_probe_device+0x1ec/0x490
device_driver_attach+0xdc/0x210
bind_store+0xec/0x180
drv_attr_store+0x79/0xb0
sysfs_kf_write+0xed/0x140
kernfs_fop_write_iter+0x34b/0x500
vfs_write+0x637/0x1010
ksys_write+0x111/0x200
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff8881085f9d80
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 32 bytes inside of
freed 64-byte region [ffff8881085f9d80, ffff8881085f9dc0)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x1085f9
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881000428c0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000200020 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8881085f9c80: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
ffff8881085f9d00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
>ffff8881085f9d80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff8881085f9e00: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8881085f9e80: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================--- sound/core/jack.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/jack.c +3 -0
@@ -67,6 +67,9 @@ static int snd_jack_dev_free(struct snd_device *device)struct snd_card *card = device->card;struct snd_jack_kctl *jack_kctl, *tmp_jack_kctl; +/* Remove debugfs while the controls are still linked. */ +snd_jack_remove_debugfs (jack); +list_for_each_entry_safe (jack_kctl, tmp_jack_kctl, &jack->kctl_list, list) {list_del_init (&jack_kctl->list);snd_ctl_remove (card, jack_kctl->kctl);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1092/1756 ALSA: hda: intel: Dont free card in the probe work
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ali Ahmet Memiş <[email protected]>
[ Upstream commit fbaccb1b19c79e79220e3bcc5bb18ca54ffb017b ]
If the delayed probe fails, azx_probe_work() frees the card and clears the drvdata. azx_remove() reads the card before it waits for the probe work with cancel_delayed_work_sync() so when the device is removed while the probe work is running, it frees the card again after the work has already freed it.
Only disconnect the card in the work so that its slot is released right away and leave freeing it to azx_remove().
--- sound/pci/hda/hda_intel.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +6 -1
@@ -1728,7 +1728,12 @@ static void azx_check_snoop_available(struct azx *chip)static void azx_probe_work (struct work_struct *work) { struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work); -azx_probe_continue (&hda->chip, true); + +if (azx_probe_continue (&hda->chip, false) <0 ) { + hda->init_failed =1 ; +complete_all (&hda->probe_wait); +snd_card_disconnect (hda->chip.card); + } }static int default_bdl_pos_adj (struct azx *chip)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1093/1756 platform/x86: asus-wmi: validate custom fan curves on enable
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahmed Yaseen <[email protected]>
[ Upstream commit bcbdfe03566ad0d01c6af3b5476e8cadffe4d3df ]
Custom fan curves reach firmware unchecked, so a curve whose temperature or PWM decreases from one point to the next is accepted. The firmware does not respect such a curve: a first point of 100% followed by 50% leaves every point running at 100%. The kernel keeps reporting the points that were written, so sysfs stops describing what the fans are actually doing.
Check the curve when enabling and reject it if it is invalid. Validation is done on enable rather than on write because fan curves are written one point at a time and are inconsistent mid-write.
--- drivers/platform/x86/asus-wmi.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+)
drivers/platform/x86/asus-wmi.c +32 -0
@@ -3347,6 +3347,33 @@ static int fan_curve_write(struct asus_wmi *asus, arg1, arg2, arg3, arg4, &ret); } +/* +* A fan curve is a set of points the firmware interpolates between, so it +* only makes sense if neither temperature nor PWM ever decreases along it. +*/ +static int fan_curve_validate (struct device *dev,struct fan_curve_data *data) +{ +u8 *percents = data->percents; +u8 *temps = data->temps; +int i; + +for (i =1 ; i <FAN_CURVE_POINTS ; i++) { +if (temps[i] < temps[i -1 ]) { +dev_warn (dev,"fan curve: temperature decreases at point %d (%u < %u)\n" , + i, temps[i], temps[i -1 ]); +return -EINVAL ; + } + +if (percents[i] < percents[i -1 ]) { +dev_warn (dev,"fan curve: pwm decreases at point %d (%u < %u)\n" , + i, percents[i], percents[i -1 ]); +return -EINVAL ; + } + } + +return 0 ; +} +static ssize_t fan_curve_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count)
@@ -3431,6 +3458,11 @@ static ssize_t fan_curve_enable_store(struct device *dev, }if (data->enabled) { + err =fan_curve_validate (dev, data); +if (err) { + data->enabled = false; +return err; + } err =fan_curve_write (asus, data);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1094/1756 platform/x86: msi-ec: Report valid charge thresholds when unset
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daasaradhi Mannava <[email protected]>
[ Upstream commit a102207eaf4a18c60c2ffbdc421ad3d30bfed591 ]
The charge thresholds are computed by subtracting a fixed offset from the raw EC value. When no charge limit has been set, the EC can hold a value below range_min (0x80 on an MSI GL65 Leopard 9SCXK), and reading the sysfs attributes returns nonsense:
charge_control_start_threshold: -10
charge_control_end_threshold: 0
Both attributes are documented to be within 0 - 100, and an end threshold of 0 wrongly suggests that charging is disabled.
The store path already rejects values outside range_min..range_max. Apply the same range to the show path and report the maximum threshold for any value outside of it.
Tested on an MSI GL65 Leopard 9SCXK (EC firmware 16U8EMS2.100) with the EC holding 0x80: the attributes now read 90 and 100.
--- drivers/platform/x86/msi-ec.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/platform/x86/msi-ec.c +9 -0
@@ -1197,6 +1197,15 @@ static ssize_t charge_control_threshold_show(u8 offset,if (result <0 )return result; +/* +* The EC may hold an out-of-range value (e.g. 0x80) when no charge +* limit has been set. Report the maximum threshold instead of a +* meaningless (possibly negative) percentage. +*/ +if (rdata < conf.charge_control.range_min || + rdata > conf.charge_control.range_max) + rdata = conf.charge_control.range_max; +return sysfs_emit (buf,"%i\n" , rdata - offset); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1095/1756 platform/x86: intel_telemetry: initialize default trace verbosity
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aleksandrova Alyona <[email protected]>
[ Upstream commit 1b55ec81926eb7f6e4fad692fa4040a569e9daf7 ]
telemetry_def_get_trace_verbosity() returns success without initializing the output verbosity value.
The default telemetry operations are installed when the core driver is initialized and again by telemetry_clear_pltdata() when the platform driver is removed. The telemetry debugfs files can remain available after the platform driver removal.
A subsequent read of pss_trace_verbosity or ioss_trace_verbosity calls telemetry_get_trace_verbosity(), which may use the default callback and return success without setting verbosity. The uninitialized value is then passed to seq_printf().
Validate the output pointer and initialize the default verbosity to zero so callers never use an uninitialized value after a successful call.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/platform/x86/intel/telemetry/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/intel/telemetry/core.c +4 -0
@@ -51,6 +51,10 @@ static int telemetry_def_get_eventconfig(static int telemetry_def_get_trace_verbosity (enum telemetry_unit telem_unit,u32 *verbosity) { +if (!verbosity) +return -EINVAL ; + + *verbosity =0 ;return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1096/1756 platform/olpc: Reserve space for a string terminator
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiale Yao <[email protected]>
[ Upstream commit 1fe88b1741ff655bb59e4fd78178fe2c557b9185 ]
ec_dbgfs_cmd_write() copies user input into a zero-initialized stack buffer and passes it to sscanf(). A write that overwrites the entire buffer leaves no terminator, so the subsequent parsing can read beyond the buffer.
Limit the copy to leave room for the trailing NUL.
--- drivers/platform/olpc/olpc-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/olpc/olpc-ec.c +1 -1
@@ -269,7 +269,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf,mutex_lock (&ec_dbgfs_lock); - size =simple_write_to_buffer (cmdbuf,sizeof (cmdbuf), ppos, buf, size); + size =simple_write_to_buffer (cmdbuf,sizeof (cmdbuf) -1 , ppos, buf, size); m = sscanf(cmdbuf, "%x:%u %x %x %x %x %x", &ec_cmd_int[0], &ec_dbgfs_resp_bytes, &ec_cmd_int[1], &ec_cmd_int[2],
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1097/1756 platform/x86/amd/pmc: Use managed APIs for mutex
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Sundar S K <[email protected]>
[ Upstream commit 6ad1b2dc0f2a76b23a31fc7a52ed4ec06e4344a3 ]
Adopt managed devm_* APIs for handling mutex creation and deletion, facilitating automatic resource cleanup.
Stable-dep-of: c9ba86f54117 ("platform/x86/amd/pmc: clear devm-managed pointers on remove to prevent stale reuse")
--- drivers/platform/x86/amd/pmc/pmc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmc/pmc.c +3 -2
@@ -917,7 +917,9 @@ static int amd_pmc_probe(struct platform_device *pdev) goto err_pci_dev_put; } -mutex_init (&dev->lock); + err =devm_mutex_init (dev->dev, &dev->lock); +if (err) +return err;/* Get num of IP blocks within the SoC */ amd_pmc_get_ip_info (dev);
@@ -960,7 +962,6 @@ static void amd_pmc_remove(struct platform_device *pdev)pci_dev_put (dev->rdev);if (IS_ENABLED (CONFIG_AMD_MP2_STB ))amd_mp2_stb_deinit (dev); -mutex_destroy (&dev->lock); }static const struct acpi_device_id amd_pmc_acpi_ids[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1098/1756 platform/x86/amd/pmc: clear devm-managed pointers on remove to prevent stale reuse
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shyam Sundar S K <[email protected]>
[ Upstream commit c9ba86f5411730ebd333d94b9e1aa8f652dc743f ]
The driver stores its state in a single file-scope static struct amd_pmc_dev, which is reused on every bind. Its regbase, smu_virt_addr, stb_virt_addr and fch_virt_addr members are MMIO mappings created with devm_ioremap().
On unbind the driver core unmaps these mappings, but it does not clear the pointers in the static struct. Since the struct is not freed, the members keep pointing at the now-unmapped addresses.
On the next bind, the probe path re-maps a region only when its pointer is still NULL, so the stale pointer is reused and the following memcpy_fromio()/ioread32() touches freed MMIO, causing use-after-unmap crash. Clear these pointers in amd_pmc_remove() so the next probe re-maps them instead of reusing stale ones.
--- drivers/platform/x86/amd/pmc/pmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/platform/x86/amd/pmc/pmc.c +4 -0
@@ -962,6 +962,10 @@ static void amd_pmc_remove(struct platform_device *pdev)pci_dev_put (dev->rdev);if (IS_ENABLED (CONFIG_AMD_MP2_STB ))amd_mp2_stb_deinit (dev); + dev->regbase =NULL ; + dev->smu_virt_addr =NULL ; + dev->stb_virt_addr =NULL ; + dev->fch_virt_addr =NULL ; }static const struct acpi_device_id amd_pmc_acpi_ids[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1099/1756 fbdev: gxt4500: Release WC setup on probe failure
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit b71e0bb7ad40c005b167e9b48be3af5a3fa51974 ]
gxt4500_probe() adds a write-combining range before allocating the cmap and registering the framebuffer. If a later step fails, the range is not released. Add the missing cleanup before unmapping the framebuffer, matching the successful remove path.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/video/fbdev/gxt4500.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/gxt4500.c +1 -0
@@ -719,6 +719,7 @@ static int gxt4500_probe(struct pci_dev *pdev, const struct pci_device_id *ent) err_free_cmap:fb_dealloc_cmap (&info->cmap); err_unmap_all: +arch_phys_wc_del (par->wc_cookie);iounmap (info->screen_base); err_unmap_regs:iounmap (par->regs);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1100/1756 ALSA: rawmidi: Drain input work before freeing the runtime
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 8c3529f0a8faaac7d73333486f69da1617ecc579 ]
The input runtime embeds event_work, so the work must be drained before close_substream() frees the runtime. The cancellation in snd_rawmidi_input_trigger() runs before close clears substream->opened, leaving a window for snd_rawmidi_receive() to enqueue more work.
With a sequencer subscription to a USB MIDI input port, an in-flight completion can overlap the last subscription's midisynth_unsubscribe():
1. snd_usbmidi_input_data() observes input_triggered and is delayed before calling snd_rawmidi_receive().
2. Unsubscribe enters close_substream(), clears input_triggered through the provider trigger callback and returns from cancel_work_sync(). The substream is still opened.
3. The completion resumes. snd_rawmidi_receive() takes substream->lock, sees opened set and queues runtime->event_work before dropping the lock.
4. Close clears opened under that lock, closes the provider and frees the runtime. Stopping USB URBs does not drain the raw-MIDI work.
5. The queued work runs and snd_rawmidi_input_event_work() reads event or substream from the freed runtime, causing a use-after-free.
Cancel input event_work again after clearing opened, before closing the provider or releasing the runtime's private data. Receive holds substream->lock through its opened check and work enqueue, so once close has cleared opened under that lock, no further receive can queue work. The final cancellation therefore drains any late work before the runtime is freed. Keep it outside the spinlock so a running callback can finish.
--- sound/core/rawmidi.c | 3 +++ 1 file changed, 3 insertions(+)
sound/core/rawmidi.c +3 -0
@@ -557,6 +557,9 @@ static void close_substream(struct snd_rawmidi *rmidi, substream->opened =0 ; substream->append =0 ; } +/* Drain input work queued after the earlier cancellation. */ +if (substream->stream ==SNDRV_RAWMIDI_STREAM_INPUT ) +cancel_work_sync (&substream->runtime->event_work); substream->ops->close (substream);if (substream->runtime->private_free) substream->runtime->private_free (substream);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1101/1756 ALSA: pcm: Protect delay DMA sync against concurrent HW_FREE
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 50f413b83b31ea8d8ee4276165ab95ed5ab0e10f ]
A PCM DMA buffer must remain allocated until explicit DMA synchronization finishes. snd_pcm_delay() calls snd_pcm_dma_buffer_sync() after dropping the stream lock, without participating in the buffer-access exclusion used by HW_FREE.
With a managed NONCONTIG buffer requiring explicit sync, HW_PARAMS can allocate a separate runtime descriptor when the requested ring exceeds the preallocation. In PREPARED state with mmap_count zero, concurrent HWSYNC and HW_FREE calls on the same open PCM file can interleave:
1. HWSYNC checks the state in snd_pcm_delay() under the stream lock and releases that lock.
2. The sync helper fetches runtime->dma_buffer_p and enters snd_dma_noncontig_sync() with that descriptor.
3. HW_FREE takes the negative buffer-access count, checks PREPARED under the stream lock, releases the lock, and frees the DMA allocation and dynamic descriptor through snd_pcm_lib_free_pages().
4. The sync callback resumes and reads the freed descriptor.
The stream lock does not cover the allocation's release, and the sync operation has no positive buffer-access count to prevent it. The stale read causes a use-after-free in snd_dma_noncontig_sync(). DELAY uses the same snd_pcm_delay() path.
Take a positive buffer-access count before checking the state and keep it until the DMA sync finishes, as the transfer and mmap paths already do. HW_FREE then returns -EBUSY while this access is active. If a buffer writer has already entered, snd_pcm_delay() returns -EBUSY before using the buffer. Keep the sync outside the stream lock and balance the count on the state-error path as well.
KASAN report as below:
BUG: KASAN: slab-use-after-free in snd_dma_noncontig_sync+0x295/0x310 [snd_pcm]
Read of size 4 at addr ffff888108f58584 by task pcm-uaf-fixture/487
CPU: 1 UID: 0 PID: 487 Comm: pcm-uaf-fixture Not tainted 7.2.0-rc6-pmb-alsa-functional-v2+ #1 PREEMPT(lazy)
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
Call Trace:
<TASK>
dump_stack_lvl+0x93/0xd0
print_report+0xce/0x630
? snd_dma_noncontig_sync+0x295/0x310 [snd_pcm]
? srso_alias_return_thunk+0x5/0xfbef5
? __virt_addr_valid+0x20d/0x410
? snd_dma_noncontig_sync+0x295/0x310 [snd_pcm]
kasan_report+0xe0/0x110
? snd_dma_noncontig_sync+0x295/0x310 [snd_pcm]
? __pfx_snd_dma_noncontig_sync+0x10/0x10 [snd_pcm]
snd_dma_noncontig_sync+0x295/0x310 [snd_pcm]
? __pfx_snd_dma_noncontig_sync+0x10/0x10 [snd_pcm]
snd_dma_buffer_sync+0xc9/0x110 [snd_pcm]
snd_pcm_delay+0x3bd/0x550 [snd_pcm]
snd_pcm_common_ioctl+0x1e7/0x3aa0 [snd_pcm]
? srso_alias_return_thunk+0x5/0xfbef5
? do_vfs_ioctl+0x1f5/0x1280
? __pfx_do_vfs_ioctl+0x10/0x10
? ioctl_has_perm.constprop.0.isra.0+0x34f/0x500
? __pfx_snd_pcm_common_ioctl+0x10/0x10 [snd_pcm]
? srso_alias_return_thunk+0x5/0xfbef5
snd_pcm_ioctl+0x76/0xb0 [snd_pcm]
? __pfx_snd_pcm_ioctl+0x10/0x10 [snd_pcm]
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1cae7ab91b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007ffe12d544f0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f1cae7ab91b
RDX: 0000000000000000 RSI: 0000000000004122 RDI: 0000000000000003
RBP: 00000000000001ee R08: 0000000000000073 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
R13: 0000000000000001 R14: 00005584f32b1398 R15: 00005584f32b2ce8
</TASK>
Allocated by task 487:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
__kasan_kmalloc+0xaa/0xb0
__kmalloc_cache_noprof+0x251/0x610
snd_pcm_lib_malloc_pages+0x27c/0x9f0 [snd_pcm]
snd_pcm_hw_params+0x171c/0x1d10 [snd_pcm]
snd_pcm_common_ioctl+0x1f62/0x3aa0 [snd_pcm]
snd_pcm_ioctl+0x76/0xb0 [snd_pcm]
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Freed by task 499:
kasan_save_stack+0x33/0x60
kasan_save_track+0x14/0x30
kasan_save_free_info+0x3b/0x60
__kasan_slab_free+0x5f/0x80
kfree+0x307/0x580
snd_pcm_lib_free_pages+0x1c9/0x420 [snd_pcm]
snd_pcm_common_ioctl+0x2bd3/0x3aa0 [snd_pcm]
snd_pcm_ioctl+0x76/0xb0 [snd_pcm]
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
The buggy address belongs to the object at ffff888108f58580
which belongs to the cache kmalloc-64 of size 64
The buggy address is located 4 bytes inside of
freed 64-byte region [ffff888108f58580, ffff888108f585c0)
The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x108f58
flags: 0x200000000000000(node=0|zone=2)
page_type: f5(slab)
raw: 0200000000000000 ffff8881000428c0 dead000000000100 dead000000000122
raw: 0000000000000000 0000000000200020 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff888108f58480: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff888108f58500: 00 00 00 00 00 06 fc fc fc fc fc fc fc fc fc fc
>ffff888108f58580: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
^
ffff888108f58600: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff888108f58680: fa fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
==================================================================
Disabling lock debugging due to kernel taint
------------[ cut here ]------------
kernel BUG at kernel/dma/mapping.c:417!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 1 UID: 0 PID: 487 Comm: pcm-uaf-fixture Tainted: G B 7.2.0-rc6-pmb-alsa-functional-v2+ #1 PREEMPT(lazy)
Tainted: [B]=BAD_PAGE
Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
RIP: 0010:__dma_sync_sg_for_cpu+0x230/0x360
Code: df 48 c1 e8 03 80 3c 10 00 0f 85 fa 00 00 00 4c 8b 35 d4 6b 7a 09 e8 7f e2 17 00 83 fd 02 0f 86 39 fe ff ff e8 71 e2 17 00 90 <0f> 0b e8 69 e2 17 00 be 08 00 00 00 4c 89 ff e8 bc 5f 77 00 4c 89
RSP: 0018:ffff888111f3fc50 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffffffffc0250d10 RCX: ffffffff816d395f
RDX: ffff88810836ba00 RSI: ffff888108f58580 RDI: ffffffffc02510d8
RBP: 00000000ffff8881 R08: 0000000000000000 R09: fffffbfff804a239
R10: ffffffffc02511cf R11: 6e696c6261736944 R12: ffff888108f58580
R13: 0000000002ce00e5 R14: ffffffffc0258720 R15: 0000000000000000
FS: 00007f1cae69c780(0000) GS:ffff8881fd861000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055d1affa2480 CR3: 0000000108fc0003 CR4: 0000000000770ef0
PKRU: 55555554
Call Trace:
<TASK>
snd_dma_noncontig_sync+0x15a/0x310 [snd_pcm]
? __pfx_snd_dma_noncontig_sync+0x10/0x10 [snd_pcm]
snd_dma_buffer_sync+0xc9/0x110 [snd_pcm]
snd_pcm_delay+0x3bd/0x550 [snd_pcm]
snd_pcm_common_ioctl+0x1e7/0x3aa0 [snd_pcm]
? srso_alias_return_thunk+0x5/0xfbef5
? do_vfs_ioctl+0x1f5/0x1280
? __pfx_do_vfs_ioctl+0x10/0x10
? ioctl_has_perm.constprop.0.isra.0+0x34f/0x500
? __pfx_snd_pcm_common_ioctl+0x10/0x10 [snd_pcm]
? srso_alias_return_thunk+0x5/0xfbef5
snd_pcm_ioctl+0x76/0xb0 [snd_pcm]
? __pfx_snd_pcm_ioctl+0x10/0x10 [snd_pcm]
__x64_sys_ioctl+0x163/0x1d0
do_syscall_64+0x115/0x6a0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f1cae7ab91b
Code: 00 48 89 44 24 18 31 c0 48 8d 44 24 60 c7 04 24 10 00 00 00 48 89 44 24 08 48 8d 44 24 20 48 89 44 24 10 b8 10 00 00 00 0f 05 <89> c2 3d 00 f0 ff ff 77 1c 48 8b 44 24 18 64 48 2b 04 25 28 00 00
RSP: 002b:00007ffe12d544f0 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000004 RCX: 00007f1cae7ab91b
RDX: 0000000000000000 RSI: 0000000000004122 RDI: 0000000000000003
RBP: 00000000000001ee R08: 0000000000000073 R09: 00000000ffffffff
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000003
R13: 0000000000000001 R14: 00005584f32b1398 R15: 00005584f32b2ce8
</TASK>
Modules linked in: snd_pcmtest snd_pcm
---[ end trace 0000000000000000 ]---
RIP: 0010:__dma_sync_sg_for_cpu+0x230/0x360
Code: df 48 c1 e8 03 80 3c 10 00 0f 85 fa 00 00 00 4c 8b 35 d4 6b 7a 09 e8 7f e2 17 00 83 fd 02 0f 86 39 fe ff ff e8 71 e2 17 00 90 <0f> 0b e8 69 e2 17 00 be 08 00 00 00 4c 89 ff e8 bc 5f 77 00 4c 89
RSP: 0018:ffff888111f3fc50 EFLAGS: 00010293
RAX: 0000000000000000 RBX: ffffffffc0250d10 RCX: ffffffff816d395f
RDX: ffff88810836ba00 RSI: ffff888108f58580 RDI: ffffffffc02510d8
RBP: 00000000ffff8881 R08: 0000000000000000 R09: fffffbfff804a239
R10: ffffffffc02511cf R11: 6e696c6261736944 R12: ffff888108f58580
R13: 0000000002ce00e5 R14: ffffffffc0258720 R15: 0000000000000000
FS: 00007f1cae69c780(0000) GS:ffff8881fd861000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055d1affa2480 CR3: 0000000108fc0003 CR4: 0000000000770ef0
PKRU: 55555554
Kernel panic - not syncing: Fatal exception
Kernel Offset: disabled
Rebooting in 1 seconds..--- sound/core/pcm_native.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/core/pcm_native.c +5 -0
@@ -3075,14 +3075,19 @@ static snd_pcm_sframes_t snd_pcm_forward(struct snd_pcm_substream *substream,static int snd_pcm_delay (struct snd_pcm_substream *substream,snd_pcm_sframes_t *delay) { +struct snd_pcm_runtime *runtime = substream->runtime;int err; +/* Keep the DMA buffer alive through the sync below. */ +if (!atomic_inc_unless_negative (&runtime->buffer_accessing)) +return -EBUSY ; scoped_guard(pcm_stream_lock_irq, substream) { err =do_pcm_hwsync (substream);if (delay && !err) *delay =snd_pcm_calc_delay (substream); }snd_pcm_dma_buffer_sync (substream,SNDRV_DMA_SYNC_CPU ); +atomic_dec (&runtime->buffer_accessing);return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1102/1756 PCI: qcom: Honor IOMMU providers #iommu-cells in qcom_pcie_config_sid_1_9_0()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manivannan Sadhasivam <[email protected]>
[ Upstream commit 5121d76cb9dde74662962cd5678a64abeaf3b3e4 ]
qcom_pcie_config_sid_1_9_0() reads the "iommu-map" property as an array of fixed four-word {rid-base, phandle, sid, rid-len} entries to program the BDF to SID translation table. But that layout only holds for an IOMMU with '#iommu-cells = <1>'. The PCIe SMMUs on these SoCs use '#iommu-cells = <2>' (SID and mask), so per the pci-iommu binding each entry is really five cells long.
This used to work only because the DTs were themselves broken. They described iommu-map with four-cell entries that omitted the SID mask, which of_map_id() tolerated via its of_check_bad_map() fallback, and the four-word parsing coincidentally matched that malformed shape.
Since commit ccb2fd725d41 ("of: Respect #{iommu,msi}-cells in maps") the OF core parses such maps correctly, so the device trees were converted to proper five-cell entries, e.g. commit c41749e9554d ("arm64: dts:
qcom: sm8250: Fix the PCIe iommu-map entries"). With five-cell entries the fixed four-word stride slips by one cell for each entry after the first, so qcom_pcie_config_sid_1_9_0() reads the endpoint mapping's RID from the preceding entry's length cell and its SID from the phandle cell. As the RID is the hash key, the endpoint's real RID is never programmed into the BDF to SID table. Its DMA then hashes to an unprogrammed slot, gets tagged with SID 0 and the SMMU faults like below on QCS8300:
arm-smmu 15200000.iommu: Unhandled context fault: fsr=0x402, iova=0xffa00000, cbfrsynra=0x0, cb=1
To fix this, walk the map with a stride of 3 + '#iommu-cells' of the referenced IOMMU and take the SID from the first specifier cell, which is all the BDF to SID table needs. Validate the layout instead of trusting the array size. Also, preserve the legacy behavior of the old DTs by detecting the same pattern that of_check_bad_map() recognizes and falling back to a stride of four.
--- drivers/pci/controller/dwc/pcie-qcom.c | 90 ++++++++++++++++++-------- 1 file changed, 64 insertions(+), 26 deletions(-)
drivers/pci/controller/dwc/pcie-qcom.c +64 -26
@@ -1044,50 +1044,90 @@ static void qcom_pcie_deinit_2_7_0(struct qcom_pcie *pcie)static int qcom_pcie_config_sid_1_9_0 (struct qcom_pcie *pcie) { -/* iommu map structure */ -struct { -u32 bdf; -u32 phandle; -u32 smmu_sid; -u32 smmu_sid_len; - } *map;void __iomem *bdf_to_sid_base = pcie->parf +PARF_BDF_TO_SID_TABLE_N ;struct device *dev = pcie->pci->dev; +struct device_node *iommu_np;u8 qcom_pcie_crc8_table[CRC8_TABLE_SIZE ]; -int i, nr_map, size =0 ; -u32 smmu_sid_base; +const __be32 *map; +u32 iommu_cells, entry_cells, phandle, smmu_sid_base; +int i, nr_cells, nr_map, size =0 ;u32 val; -of_get_property (dev->of_node,"iommu-map" , &size); -if (!size) + map =of_get_property (dev->of_node,"iommu-map" , &size); +if (!map || !size)return 0 ; +if (size %sizeof (*map)) { +dev_err (dev,"Malformed iommu-map property\n" ); +return -EINVAL ; + } + nr_cells = size /sizeof (*map); + +/* +* Each iommu-map entry is: rid-base (1 cell), phandle (1 cell), +* IOMMU specifier (#iommu-cells cells), length (1 cell). Read +* #iommu-cells from the IOMMU provider referenced by the first +* entry to compute the per-entry stride. +*/ + phandle =be32_to_cpu (map[1 ]); + iommu_np =of_find_node_by_phandle (phandle); +if (!iommu_np) { +dev_err (dev,"Failed to find IOMMU node in iommu-map\n" ); +return -ENODEV ; + } + +if (of_property_read_u32 (iommu_np,"#iommu-cells" , &iommu_cells)) + iommu_cells =1 ; +of_node_put (iommu_np); + + entry_cells =3 + iommu_cells; + +/* +* Retain backward compatibility with DTs that describe iommu-map +* with 4-cell entries against an IOMMU declaring #iommu-cells = 2, +* matching the fallback in drivers/of/base.c::of_check_bad_map(). +*/ +if (iommu_cells ==2 && !(nr_cells %4 )) { +bool legacy = true; + +for (i =0 ; i < nr_cells; i +=4 ) { +if (be32_to_cpu (map[i +1 ]) != phandle || +be32_to_cpu (map[i +3 ]) !=1 ) { + legacy = false; +break ; + } + } + +if (legacy) { +dev_warn_once (dev,"iommu-map has 1-cell entries with #iommu-cells=2, using 1-cell\n" ); + entry_cells =4 ; + } + } + +if (nr_cells % entry_cells) { +dev_err (dev,"Malformed iommu-map property\n" ); +return -EINVAL ; + } + nr_map = nr_cells / entry_cells; +/* Enable BDF to SID translation by disabling bypass mode (default) */ val =readl (pcie->parf +PARF_BDF_TO_SID_CFG ); val &= ~BDF_TO_SID_BYPASS ;writel (val, pcie->parf +PARF_BDF_TO_SID_CFG ); - map =kzalloc (size,GFP_KERNEL ); -if (!map) -return -ENOMEM ; - -of_property_read_u32_array (dev->of_node,"iommu-map" , (u32 *)map, - size /sizeof (u32)); - - nr_map = size / (sizeof (*map)); -crc8_populate_msb (qcom_pcie_crc8_table,QCOM_PCIE_CRC8_POLYNOMIAL );/* Registers need to be zero out first */ memset_io (bdf_to_sid_base,0 ,CRC8_TABLE_SIZE *sizeof (u32));/* Extract the SMMU SID base from the first entry of iommu-map */ - smmu_sid_base = map[0 ].smmu_sid; + smmu_sid_base =be32_to_cpu (map[2 ]);/* Look for an available entry to hold the mapping */ for (i =0 ; i < nr_map; i++) { -__be16 bdf_be =cpu_to_be16 (map[i].bdf); -u32 val; +u32 bdf =be32_to_cpu (map[i * entry_cells]); +u32 sid =be32_to_cpu (map[i * entry_cells +2 ]); +__be16 bdf_be =cpu_to_be16 (bdf);u8 hash; hash =crc8 (qcom_pcie_crc8_table, (u8 *)&bdf_be,sizeof (bdf_be),0 );
@@ -1109,12 +1149,10 @@ static int qcom_pcie_config_sid_1_9_0(struct qcom_pcie *pcie) }/* BDF [31:16] | SID [15:8] | NEXT [7:0] */ - val = map[i].bdf <<16 | (map[i].smmu_sid - smmu_sid_base) <<8 |0 ; + val = bdf <<16 | (sid - smmu_sid_base) <<8 |0 ;writel (val, bdf_to_sid_base + hash *sizeof (u32)); } -kfree (map); -return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1103/1756 calipso: hash the cache key, not the option start, in calipso_cache_add()
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joas Antonio dos Santos <[email protected]>
[ Upstream commit d538cc3ec0bc4cb7b40981b3213a6c6671959ed5 ]
calipso_cache_add() stores calipso_ptr + 2 as the cache key, but computes entry->hash over calipso_ptr, i.e. starting two bytes earlier at the option type and length. calipso_opt_getattr() looks entries up with calipso_cache_check(calipso + 2, calipso[1], ...), which hashes the key itself.
The two hashes only match on a jhash collision, so the CALIPSO label cache never hits and every labelled packet takes the full DOI lookup and category conversion path. The memcmp() on the key keeps lookups correct, so this is a performance bug only.
Hash the stored key, as cipso_v4_cache_add() does for CIPSO.
--- net/ipv6/calipso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/calipso.c +1 -1
@@ -284,7 +284,7 @@ static int calipso_cache_add(const unsigned char *calipso_ptr, goto cache_add_failure; } entry->key_len = calipso_ptr_len; - entry->hash =calipso_map_cache_hash (calipso_ptr, calipso_ptr_len); + entry->hash =calipso_map_cache_hash (entry->key, calipso_ptr_len);refcount_inc (&secattr->cache->refcount); entry->lsm_data = secattr->cache;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1104/1756 clocksource/drivers/timer-mediatek: Fix random crash at boot
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Leonardo Scorcia <[email protected]>
[ Upstream commit 8496a1d234e8cf9cb15c4282cb3a11c6550bd242 ]
MediaTek bootloaders generally enable APXGPT timers at boot. This means that a timer IRQ can sometimes happen between the IRQ line request and the configuration of the clock event handler. This leads to a hard crash with an instruction abort, branch to pc 0x0 in mtk_gpt_interrupt handler as clkevt is null.
To avoid this issue request the IRQ with IRQF_NO_AUTOEN and enable it explicitly after the clock event is configured.
Issue was reported and fix tested on the Lenovo Tab E7 (TB-7104F, mt8167).
--- drivers/clocksource/timer-mediatek.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-mediatek.c +3 -1
@@ -277,7 +277,7 @@ static struct timer_of to = { }, .of_irq = { - .flags = IRQF_TIMER | IRQF_IRQPOLL, + .flags = IRQF_TIMER | IRQF_IRQPOLL | IRQF_NO_AUTOEN, }, };
@@ -298,6 +298,7 @@ static int __init mtk_syst_init(struct device_node *node)clockevents_config_and_register (&to.clkevt,timer_of_rate (&to),TIMER_SYNC_TICKS ,0xffffffff ); +enable_irq (timer_of_irq (&to));return 0 ; }
@@ -334,6 +335,7 @@ static int __init mtk_gpt_init(struct device_node *node) TIMER_SYNC_TICKS, 0xffffffff);mtk_gpt_enable_irq (&to,TIMER_CLK_EVT ); +enable_irq (timer_of_irq (&to));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1105/1756 RDMA/siw: Enforce IB_ACCESS_REMOTE_READ for read responses
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Haitam Lazaar <[email protected]>
[ Upstream commit f74eac4fc6c56274fb96c2c44ffad8f01c325f17 ]
When generating an RDMA READ response (SIW_OP_READ_RESPONSE), siw_check_sgl_tx() unconditionally passes 0 as the required permission mask:
/* Reference memory to be tx'd w/o checking access for LOCAL_READ */
rv = siw_check_sgl_tx(qp->pd, wqe, 0);Because perms is 0, siw_check_mem()'s authorization test:
if ((mem->perms & perms) < perms)
evaluates to (mem->perms & 0) < 0, which is always false. Consequently, an untrusted remote peer can issue an RDMA Read targeting any valid STag in the Protection Domain, even if the memory was registered strictly as write-only (IB_ACCESS_REMOTE_WRITE) without IB_ACCESS_REMOTE_READ.
Enforce that the target memory region was granted IB_ACCESS_REMOTE_READ when answering SIW_OP_READ_RESPONSE work queue entries, while preserving perms = 0 for standard local sends.
--- drivers/infiniband/sw/siw/siw_qp_tx.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/infiniband/sw/siw/siw_qp_tx.c +11 -7
@@ -801,17 +801,21 @@ static int siw_qp_sq_proc_tx(struct siw_qp *qp, struct siw_wqe *wqe)if (wqe->wr_status ==SIW_WR_QUEUED ) {if (!(wqe->sqe.flags &SIW_WQE_INLINE )) { -if (tx_type (wqe) ==SIW_OP_READ_RESPONSE ) - wqe->sqe.num_sge =1 ; -if (tx_type (wqe) !=SIW_OP_READ &&tx_type (wqe) !=SIW_OP_READ_LOCAL_INV ) { +enum ib_access_flags perms =0 ; +/* -* Reference memory to be tx'd w/o checking -* access for LOCAL_READ permission, since -* not defined in RDMA core. +* Local READ permission doesn't exist in RDMA core. +* A READ RESPONSE source is read by the remote peer, +* so it must be checked for REMOTE_READ permission. */ - rv =siw_check_sgl_tx (qp->pd, wqe,0 ); +if (tx_type (wqe) ==SIW_OP_READ_RESPONSE ) { + perms =IB_ACCESS_REMOTE_READ ; + wqe->sqe.num_sge =1 ; + } + + rv =siw_check_sgl_tx (qp->pd, wqe, perms);if (rv <0 ) {if (tx_type (wqe) ==SIW_OP_READ_RESPONSE )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1106/1756 RDMA/efa: Fix race between admin command timeout and completion
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonatan Nachum <[email protected]>
[ Upstream commit 466612f8a8020c6b3af6377c730775a4c630f12c ]
An admin command that times out can race with the interrupt handler processing its completion, in two ways.
The timeout path releases the completion context without synchronizing against the handler. A handler that has already seen the command as submitted then copies the CQE into the caller's response buffer after the waiter returned and that buffer went out of scope.
The waiter can also observe the command as completed before the CQE was copied, since the status is published first. It decodes its own uninitialized response buffer, returns success with garbage contents and leaks stack data to the caller. Both wait paths read the status without the CQ lock.
Add a timed-out state and publish it under the CQ lock in both wait paths before returning, so the handler, which only completes commands in submitted state, cannot act on an abandoned context. In the interrupt wait path test the return value of the wait instead of the status: the handler signals the completion after copying the CQE, so a successful wait implies a valid response. Read the status in the polling wait path inside the critical section that drains the CQ, which also lets a completion arriving on the last iteration be honored instead of reported as a timeout.
--- drivers/infiniband/hw/efa/efa_com.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/infiniband/hw/efa/efa_com.c +20 -8
@@ -23,6 +23,7 @@enum efa_cmd_status {EFA_CMD_SUBMITTED ,EFA_CMD_COMPLETED , +EFA_CMD_TIMED_OUT , };struct efa_comp_ctx {
@@ -497,6 +498,7 @@ static int efa_com_comp_status_to_errno(u8 comp_status)static int efa_com_wait_and_process_admin_cq_polling (struct efa_comp_ctx *comp_ctx,struct efa_com_admin_queue *aq) { +bool comp_timeout = false;unsigned long timeout;unsigned long flags;
@@ -505,12 +507,19 @@ static int efa_com_wait_and_process_admin_cq_polling(struct efa_comp_ctx *comp_cwhile (1 ) {spin_lock_irqsave (&aq->cq.lock, flags);efa_com_handle_admin_completion (aq); -spin_unlock_irqrestore (&aq->cq.lock, flags); - -if (comp_ctx->status !=EFA_CMD_SUBMITTED ) +if (comp_ctx->status !=EFA_CMD_SUBMITTED ) { +spin_unlock_irqrestore (&aq->cq.lock, flags);break ; + }if (time_is_before_jiffies (timeout)) { + comp_ctx->status =EFA_CMD_TIMED_OUT ; + comp_timeout = true; + } + +spin_unlock_irqrestore (&aq->cq.lock, flags); + +if (comp_timeout) {ibdev_err_ratelimited ( aq->efa_dev,"Wait for completion (polling) timeout\n" );
@@ -531,10 +540,11 @@ static int efa_com_wait_and_process_admin_cq_polling(struct efa_comp_ctx *comp_cstatic int efa_com_wait_and_process_admin_cq_interrupts (struct efa_comp_ctx *comp_ctx,struct efa_com_admin_queue *aq) { -unsigned long flags; +unsigned long flags, remaining_jiffies; +bool completed; -wait_for_completion_timeout (&comp_ctx->wait_event, -usecs_to_jiffies (aq->completion_timeout)); + remaining_jiffies =wait_for_completion_timeout ( + &comp_ctx->wait_event,usecs_to_jiffies (aq->completion_timeout));/* * In case the command wasn't completed find out the root cause.
@@ -542,14 +552,16 @@ static int efa_com_wait_and_process_admin_cq_interrupts(struct efa_comp_ctx *com* 1) No completion (timeout reached) * 2) There is completion but the device didn't get any msi-x interrupt. */ -if (comp_ctx->status ==EFA_CMD_SUBMITTED ) { +if (remaining_jiffies ==0 ) {spin_lock_irqsave (&aq->cq.lock, flags);efa_com_handle_admin_completion (aq); + completed = (comp_ctx->status ==EFA_CMD_COMPLETED ); + comp_ctx->status =EFA_CMD_TIMED_OUT ;spin_unlock_irqrestore (&aq->cq.lock, flags);atomic64_inc (&aq->stats.no_completion); -if (comp_ctx->status ==EFA_CMD_COMPLETED ) +if (completed) ibdev_err_ratelimited( aq->efa_dev, "The device sent a completion but the driver didn't receive any MSI-X interrupt for admin cmd %s(%d) status %d (ctx: 0x%p, sq producer: %d, sq consumer: %d, cq consumer: %d)\n",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1107/1756 wifi: mac80211: fix encryption tailroom
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chien Wong <[email protected]>
[ Upstream commit c49f54fd2abff08964677db8fdc1674c713ab42c ]
BIP-CMAC-256 and BIP-GMAC append a 26-byte MME but mac80211 currently reserves only 18 bytes of encryption tailroom.
Generating 26-byte MME may happen to work because the actual skb tailroom can exceed the requested amount. For example, dev_alloc_skb() rounds the allocation to kmalloc size buckets or alignment boundaries, and the extra space may cover the 8-byte shortfall.
Reserve enough tailroom for the 26-byte MME.
--- net/mac80211/ieee80211_i.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/ieee80211_i.h +1 -1
@@ -52,7 +52,7 @@ struct ieee80211_mesh_fast_tx;/* Required encryption head and tailroom */ #define IEEE80211_ENCRYPT_HEADROOM 8 -#define IEEE80211_ENCRYPT_TAILROOM 18 +#define IEEE80211_ENCRYPT_TAILROOM 26/* current max: GMAC/CMAC-256 MME */ /* power level hasn't been configured (or set to automatic) */ #define IEEE80211_UNSET_POWER_LEVEL INT_MIN
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1108/1756 wifi: mac80211: reserve MME tailroom for protected beacons
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chien Wong <[email protected]>
[ Upstream commit 48002331da85c7c962cfbc09c8bd84d219a6fe1c ]
Beacon protection appends an MME to beacons, but the skb allocation does not reserve tailroom for it. If the available tailroom is too small, the crypto path drops the beacon.
Two factors often mask this: the 256-byte TIM reservation is rarely fully used, and dev_alloc_skb() may round up the allocation, leaving extra tailroom. Neither guarantees enough room for the MME.
Reserve enough room for the largest MME.
--- net/mac80211/tx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/mac80211/tx.c +2 -1
@@ -5545,7 +5545,8 @@ ieee80211_beacon_get_ap(struct ieee80211_hw *hw, skb =dev_alloc_skb (local->tx_headroom + beacon->head_len + beacon->tail_len +256 + - local->hw.extra_beacon_tailroom + mbssid_len); + local->hw.extra_beacon_tailroom + mbssid_len + +IEEE80211_ENCRYPT_TAILROOM );if (!skb)return NULL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1109/1756 wifi: mwifiex: append hotfix number to firmware version string
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Chen <[email protected]>
[ Upstream commit 958f20d5aa0aa645068454fdb62ebc625ac9a115 ]
mwifiex_ret_get_hw_spec() parses and logs the FW_HOTFIX_VER_ID TLV, but the hotfix value is not stored in the adapter structure. As a result, the hotfix number never appears in the firmware version string returned by mwifiex_drv_get_driver_version().
Store the hotfix version from FW_HOTFIX_VER_ID and append it to the firmware version string.
--- drivers/net/wireless/marvell/mwifiex/cmdevt.c | 10 ++++++++-- drivers/net/wireless/marvell/mwifiex/fw.h | 6 ++++++ drivers/net/wireless/marvell/mwifiex/init.c | 1 + drivers/net/wireless/marvell/mwifiex/main.h | 1 + drivers/net/wireless/marvell/mwifiex/sta_ioctl.c | 3 ++- 5 files changed, 18 insertions(+), 3 deletions(-)
drivers/net/wireless/marvell/mwifiex/cmdevt.c +8 -2
@@ -1621,11 +1621,17 @@ int mwifiex_ret_get_hw_spec(struct mwifiex_private *priv, api_rev->major_ver, api_rev->minor_ver);break ; -case FW_HOTFIX_VER_ID : +case FW_HOTFIX_VER_ID : { +struct hw_spec_fw_hotfix_ver *hf; + + hf = (void *)tlv; + adapter->fw_hotfix_ver = +le16_to_cpu (hf->hotfix_ver);mwifiex_dbg (adapter,INFO ,"Firmware hotfix version %d\n" , - api_rev->major_ver); + adapter->fw_hotfix_ver);break ; + }default : mwifiex_dbg(adapter, FATAL, "Unknown api_id: %d\n",
drivers/net/wireless/marvell/mwifiex/fw.h +6 -0
@@ -1099,6 +1099,12 @@ struct hw_spec_api_rev {u8 minor_ver; } __packed; +struct hw_spec_fw_hotfix_ver { +struct mwifiex_ie_types_header header; +__le16 api_id; +__le16 hotfix_ver; +} __packed; +struct host_cmd_ds_get_hw_spec {__le16 hw_if_version;__le16 version;
drivers/net/wireless/marvell/mwifiex/init.c +1 -0
@@ -295,6 +295,7 @@ static void mwifiex_init_adapter(struct mwifiex_adapter *adapter) adapter->config_bands =0 ; adapter->adhoc_start_band =0 ; adapter->fw_release_number =0 ; + adapter->fw_hotfix_ver =0 ; adapter->fw_cap_info =0 ;memset (&adapter->upld_buf,0 ,sizeof (adapter->upld_buf)); adapter->event_cause =0 ;
drivers/net/wireless/marvell/mwifiex/main.h +1 -0
@@ -1010,6 +1010,7 @@ struct mwifiex_adapter {bool host_mlme_enabled;struct ieee80211_txrx_stypes mwifiex_mgmt_stypes[NUM_NL80211_IFTYPES ];u8 fw_api_ver; +u16 fw_hotfix_ver;u8 key_api_major_ver, key_api_minor_ver;u8 max_p2p_conn, max_sta_conn;struct memory_type_mapping *mem_type_mapping_tbl;
drivers/net/wireless/marvell/mwifiex/sta_ioctl.c +2 -1
@@ -1089,7 +1089,8 @@ mwifiex_drv_get_driver_version(struct mwifiex_adapter *adapter, char *version,char fw_ver[32 ]; ver.l =cpu_to_le32 (adapter->fw_release_number); -sprintf (fw_ver,"%u.%u.%u.p%u" , ver.c[2 ], ver.c[1 ], ver.c[0 ], ver.c[3 ]); +sprintf (fw_ver,"%u.%u.%u.p%u.%u" , ver.c[2 ], ver.c[1 ], + ver.c[0 ], ver.c[3 ], adapter->fw_hotfix_ver);snprintf (version, max_len, driver_version, fw_ver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1110/1756 tcp_bic: fix divide by zero on max_increment == 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 8edbf6c23363563e508a61f3f26f4e4b6eec9dd5 ]
max_increment is how many packets cwnd can grow per RTT, so 0 makes no sense, and bictcp_update() divides by it.
Reject values below 1 when the parameter is written.
--- net/ipv4/tcp_bic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/tcp_bic.c +12 -2
@@ -27,15 +27,25 @@*/ static int fast_convergence =1 ; -static int max_increment =16 ; +static unsigned int max_increment =16 ;static int low_window =14 ;static int beta =819 ;/* = 819/1024 (BICTCP_BETA_SCALE) */ static int initial_ssthresh;static int smooth_part =20 ; +static int max_increment_set (const char *val,const struct kernel_param *kp) +{ +return param_set_uint_minmax (val, kp,1 ,INT_MAX ); +} + +static const struct kernel_param_ops max_increment_ops = { + .set = max_increment_set, + .get = param_get_uint, +}; +module_param (fast_convergence, int,0644 );MODULE_PARM_DESC (fast_convergence,"turn on/off fast convergence" ); -module_param (max_increment, int,0644 ); +module_param_cb (max_increment, &max_increment_ops, &max_increment,0644 );MODULE_PARM_DESC (max_increment,"Limit on increment allowed during binary search" );module_param (low_window, int,0644 );MODULE_PARM_DESC (low_window,"lower bound on congestion window (for TCP friendliness)" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1111/1756 tcp_hybla: fix divide by zero on rtt0 == 0
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit f09eb97322b16a6f709a47599c95b62f786905f9 ]
rtt0 is the reference RTT in ms, so 0 makes no sense, and hybla_recalc_param() divides by it right from hybla_init().
Reject values below 1 when the parameter is written. Also cap it at U32_MAX / USEC_PER_MSEC, since rtt0 * USEC_PER_MSEC can wrap to 0 on 32-bit. An rtt0 above that (about 71 minutes) makes no sense anyway.
--- net/ipv4/tcp_hybla.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
net/ipv4/tcp_hybla.c +14 -2
@@ -26,8 +26,20 @@ struct hybla { };/* Hybla reference round trip time (default= 1/40 sec = 25 ms), in ms */ -static int rtt0 =25 ; -module_param (rtt0, int,0644 ); +static unsigned int rtt0 =25 ; + +static int rtt0_set (const char *val,const struct kernel_param *kp) +{ +/* avoid rtt0 * USEC_PER_MSEC overflow */ +return param_set_uint_minmax (val, kp,1 ,U32_MAX /USEC_PER_MSEC ); +} + +static const struct kernel_param_ops rtt0_ops = { + .set = rtt0_set, + .get = param_get_uint, +}; + +module_param_cb (rtt0, &rtt0_ops, &rtt0,0644 );MODULE_PARM_DESC (rtt0,"reference rout trip time (ms)" );/* This is called to refresh values for hybla parameters */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1112/1756 tcp_cubic: fix divide by zero and endless loop on bad module params
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiayuan Chen <[email protected]>
[ Upstream commit 7d52b5d16afc1cf8484ae321658e217a80e3ff4d ]
beta_scale and cube_factor are computed once at module init, and beta == 1024 or bic_scale == 0 is a divide by zero right there. Other out of range values give garbage: negative beta can make beta_scale 0, and bic_scale * 10 can overflow. Reject them. Read beta once, as it can be written through sysfs before the init function runs.
A small beta also gives a small beta_scale, and (cwnd * beta_scale) >> 3 truncates to 0 for a tiny cwnd, so the TCP friendliness loop never ends. Rather than testing delta on every ACK, make sure beta_scale is at least 8 at init, so delta is >= 1 within the cwnd < 1 million packets limit this code is designed for. This slows the TCP friendly estimate for beta < 512, a backoff harder than Reno's 0.5, which is not a setting anyone should use.
--- net/ipv4/tcp_cubic.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
net/ipv4/tcp_cubic.c +12 -2
@@ -503,16 +503,26 @@ static const struct btf_kfunc_id_set tcp_cubic_kfunc_set = {static int __init cubictcp_register (void ) { +int b =READ_ONCE (beta);int ret;BUILD_BUG_ON (sizeof (struct bictcp ) >ICSK_CA_PRIV_SIZE ); +if (b <0 || b >=BICTCP_BETA_SCALE || + bic_scale <=0 || bic_scale >INT_MAX /10 ) { +pr_err ("tcp_cubic: invalid beta %d or bic_scale %d\n" , + b, bic_scale); +return -EINVAL ; + } +/* Precompute a bunch of the scaling factors that are used per-packet * based on SRTT of 100ms */ - beta_scale =8 *(BICTCP_BETA_SCALE +beta) /3 - / (BICTCP_BETA_SCALE - beta); + beta_scale =8 * (BICTCP_BETA_SCALE + b) /3 + / (BICTCP_BETA_SCALE - b); +/* bictcp_update() needs (cwnd * beta_scale) >> 3 to be >= 1 */ + beta_scale =max (beta_scale,8U ); cube_rtt_scale = (bic_scale *10 );/* 1024*c/rtt */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1113/1756 serial: max310x: dont clobber the TX break bit in set_termios
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 3b2de448ec0332c1cb8c38b4c5ff0c8e860befbc ]
A TX break asserted with TIOCSBRK ends early, with no error reported, as soon as any termios change lands on the port: a break is a state that must hold until TIOCCBRK, but max310x_set_termios() overwrites the whole LCR register, and LCR also carries the TX break bit that break_ctl() drives. No concurrency is required - a baud or parity change from the same process ends the break just as well, and break-led protocols lose their break with nothing in the logs.
Update only the LCR bits that are derived from termios and leave the TX break and RTS pin control bits untouched. Since nothing clears a break when a port is closed with the break still asserted - the tty core sends no break-off on release, and the unconditional write here was the accidental recovery - clear TXBREAK in startup(), the same way 8250 does.
--- drivers/tty/serial/max310x.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/tty/serial/max310x.c +15 -2
@@ -156,6 +156,8 @@#define MAX310X_LCR_FORCEPARITY_BIT (1 << 5)/* 9-bit multidrop parity */ #define MAX310X_LCR_TXBREAK_BIT (1 << 6)/* TX break enable */ #define MAX310X_LCR_RTS_BIT (1 << 7)/* RTS pin control */ +/* LCR bits owned by termios; TX break and RTS are driven elsewhere */ +#define MAX310X_LCR_TERMIOS_MASK GENMASK(5, 0)/* IRDA register bits */ #define MAX310X_IRDA_IRDAEN_BIT (1 << 0)/* IRDA mode enable */
@@ -926,8 +928,12 @@ static void max310x_set_termios(struct uart_port *port,if (termios->c_cflag &CSTOPB ) lcr |=MAX310X_LCR_STOPLEN_BIT ;/* 2 stops */ -/* Update LCR register */ -max310x_port_write (port,MAX310X_LCR_REG , lcr); +/* +* Update LCR register. Leave the TX break bit alone: it is driven by +* break_ctl(), and a whole-register write here would end a break in +* progress. +*/ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TERMIOS_MASK , lcr);/* Set read status mask */ port->read_status_mask =MAX310X_LSR_RXOVR_BIT ;
@@ -1045,6 +1051,13 @@ static int max310x_startup(struct uart_port *port)max310x_power (port,1 ); +/* +* Clear a latched break: nothing clears TXBREAK when a port is +* closed with a break still asserted, and set_termios() no longer +* rewrites it. +*/ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT ,0 ); +/* Configure MODE1 register */ max310x_port_update (port,MAX310X_MODE1_REG ,MAX310X_MODE1_TRNSCVCTRL_BIT ,0 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1114/1756 serial: max310x: fix breaks not reaching the wire in RS485 mode
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 4efacb600bf98b13e0659f05afa4549795277e35 ]
The chip's auto-RTS (MODE1.TRNSCVCTRL) asserts the RS485 transceiver only while FIFO data is shifting out, and a break is not FIFO data: on an RS485 port a requested break sets the TX break bit but the transceiver is never enabled, so the break never reaches the wire. Break-led protocols cannot work at all.
Disable auto-RTS for the break duration and drive RTS manually via the LCR RTS bit, then restore auto-RTS when the break ends. Track the break in tx_break and leave MODE1 alone in the rs485-config worker while it is set - a TIOCSRS485 arriving mid-break would otherwise re-enable auto-RTS on top of the manual RTS and release the transceiver before the break ends; break_ctl() restores auto-RTS from the then-current configuration when the break completes. The worker runs under port->mutex - break_ctl() and set_termios() already do - so the tx_break test and the MODE1 write cannot straddle a break starting or ending, and startup() clears tx_break alongside the latched TXBREAK bit, since a port can be closed with a break still asserted.
Only the break assertion is gated on RS485 being enabled; the restore at break end runs unconditionally and derives MODE1 from the current configuration. Returning early for a port whose RS485 was disabled mid-break - that reconfigure is deferred like any other - would leak the manually driven RTS and leave the transceiver holding the bus indefinitely after the break ends. On a non-RS485 port the restore is a no-op: nothing else writes the LCR RTS bit.
--- drivers/tty/serial/max310x.c | 49 ++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-)
drivers/tty/serial/max310x.c +47 -2
@@ -285,6 +285,7 @@ struct max310x_one {struct work_struct md_work;struct work_struct rs_work;struct regmap *regmap; +bool tx_break;/* break_ctl() owns the transceiver */ u8 rx_buf[MAX310X_FIFO_SIZE ]; };
@@ -651,6 +652,12 @@ static void max310x_batch_read(struct uart_port *port, u8 *rxbuf, unsigned int lregmap_noinc_read (one->regmap,MAX310X_RHR_REG , rxbuf, len); } +static void max310x_rts_ctl (struct uart_port *port,bool rts_state) +{ +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_RTS_BIT , + rts_state ?MAX310X_LCR_RTS_BIT :0 ); +} +static void max310x_handle_rx (struct uart_port *port,unsigned int rxlen) {struct max310x_one *one =to_max310x_port (port);
@@ -886,9 +893,32 @@ static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl)static void max310x_break_ctl (struct uart_port *port,int break_state) { +struct max310x_one *one =to_max310x_port (port); + + one->tx_break = break_state; +max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT , break_state ?MAX310X_LCR_TXBREAK_BIT :0 ); + +/* +* The chip's auto-RTS asserts the transceiver only while FIFO data is +* shifting out, and a break is not FIFO data. Disable auto-RTS for the +* break duration and drive RTS manually so the break reaches the wire; +* restore auto-RTS when the break ends. +*/ +if (break_state) { +if (!(port->rs485.flags &SER_RS485_ENABLED )) +return ; +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT ,0 ); + }else { +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT , + (port->rs485.flags &SER_RS485_ENABLED ) ? +MAX310X_MODE1_TRNSCVCTRL_BIT :0 ); + } +max310x_rts_ctl (port, break_state); } static void max310x_set_termios(struct uart_port *port,
@@ -1012,6 +1042,13 @@ static void max310x_rs_proc(struct work_struct *ws) struct max310x_one *one = container_of(ws, struct max310x_one, rs_work);unsigned int delay, mode1 =0 , mode2 =0 ; +/* +* Serialize against break_ctl() and set_termios(), which run under +* port->mutex: the tx_break test below and the MODE1 write must not +* straddle a break starting or ending. +*/ +guard (mutex)(&one->port.state->port.mutex); + delay = (one->port.rs485.delay_rts_before_send <<4 ) | one->port.rs485.delay_rts_after_send;max310x_port_write (&one->port,MAX310X_HDPIXDELAY_REG , delay);
@@ -1023,8 +1060,14 @@ static void max310x_rs_proc(struct work_struct *ws) mode2 =MAX310X_MODE2_ECHOSUPR_BIT ; } -max310x_port_update (&one->port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , mode1); +/* +* A break owns the transceiver: break_ctl() disabled auto-RTS and +* drives RTS manually, and restores it when the break ends. Leave +* MODE1 alone meanwhile or the break goes undriven mid-way. +*/ +if (!one->tx_break) +max310x_port_update (&one->port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT , mode1);max310x_port_update (&one->port,MAX310X_MODE2_REG ,MAX310X_MODE2_ECHOSUPR_BIT , mode2); }
@@ -1047,6 +1090,7 @@ static int max310x_rs485_config(struct uart_port *port, struct ktermios *termiosstatic int max310x_startup (struct uart_port *port) { +struct max310x_one *one =to_max310x_port (port);unsigned int val;max310x_power (port,1 );
@@ -1056,6 +1100,7 @@ static int max310x_startup(struct uart_port *port)* closed with a break still asserted, and set_termios() no longer * rewrites it. */ + one->tx_break = false;max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT ,0 );/* Configure MODE1 register */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1115/1756 serial: max310x: centralize the RS485 transceiver programming
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 56051740bf9720335a1a56e87a99e3491c33ce54 ]
The HDPIXDELAY RTS delays and the MODE1 auto-transceiver enable are programmed in three places - the rs485-config worker, startup() and break_ctl()'s break-off restore - each with its own copy of the register sequence. Move the sequence into a helper, max310x_set_rts_ctl_params(), together with the tx_break guard that keeps the MODE1 write away from a break in progress; the break-off restore reapplies the current configuration through the same helper.
No functional change intended. The copies differed only in that startup() clamped the delays to the 4-bit field while the worker wrote them unclamped; the helper clamps, and the difference is unreachable while rs485_config() still rejects delays above 15 ms with -ERANGE. Break-off additionally rewrites HDPIXDELAY with the values it already holds, a no-op on the wire.
Stable-dep-of: 7784d6aee59a ("serial: max310x: fix RS485 delays being programmed as bit-times")
--- drivers/tty/serial/max310x.c | 85 ++++++++++++++++++++---------------- 1 file changed, 47 insertions(+), 38 deletions(-)
drivers/tty/serial/max310x.c +47 -38
@@ -891,6 +891,38 @@ static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl)schedule_work (&one->md_work); } +/* +* Program the chip's RS485 RTS timing (HDPIXDELAY) and the auto +* transceiver control (MODE1) from the current configuration. The +* rs485-config worker, startup() and break_ctl()'s break-off restore +* each carried their own copy of this sequence. +*/ +static void max310x_set_rts_ctl_params (struct max310x_one *one) +{ +struct uart_port *port = &one->port; +unsigned int delay; +u8 mode1 =0 ; + + delay = (clamp (port->rs485.delay_rts_before_send,0U ,15U ) <<4 ) | +clamp (port->rs485.delay_rts_after_send,0U ,15U ); +max310x_port_write (port,MAX310X_HDPIXDELAY_REG , delay); + +if (port->rs485.flags &SER_RS485_ENABLED ) + mode1 =MAX310X_MODE1_TRNSCVCTRL_BIT ; + +/* +* A break owns the transceiver: break_ctl() disabled auto-RTS and +* drives RTS manually, and restores it from the current +* configuration when the break ends. Touching MODE1 here would +* release the transceiver mid-break. +*/ +if (one->tx_break) +return ; + +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TRNSCVCTRL_BIT , mode1); +} +static void max310x_break_ctl (struct uart_port *port,int break_state) {struct max310x_one *one =to_max310x_port (port);
@@ -913,10 +945,7 @@ static void max310x_break_ctl(struct uart_port *port, int break_state)max310x_port_update (port,MAX310X_MODE1_REG ,MAX310X_MODE1_TRNSCVCTRL_BIT ,0 ); }else { -max310x_port_update (port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , - (port->rs485.flags &SER_RS485_ENABLED ) ? -MAX310X_MODE1_TRNSCVCTRL_BIT :0 ); +max310x_set_rts_ctl_params (one); }max310x_rts_ctl (port, break_state); }
@@ -1040,36 +1069,23 @@ static void max310x_set_termios(struct uart_port *port,static void max310x_rs_proc (struct work_struct *ws) { struct max310x_one *one = container_of(ws, struct max310x_one, rs_work); -unsigned int delay, mode1 =0 , mode2 =0 ; +unsigned int mode2 =0 ;/* * Serialize against break_ctl() and set_termios(), which run under -* port->mutex: the tx_break test below and the MODE1 write must not +* port->mutex: the tx_break-guarded register writes must not * straddle a break starting or ending. */ guard (mutex)(&one->port.state->port.mutex); - delay = (one->port.rs485.delay_rts_before_send <<4 ) | - one->port.rs485.delay_rts_after_send; -max310x_port_write (&one->port,MAX310X_HDPIXDELAY_REG , delay); +max310x_set_rts_ctl_params (one); -if (one->port.rs485.flags &SER_RS485_ENABLED ) { - mode1 =MAX310X_MODE1_TRNSCVCTRL_BIT ; +if (one->port.rs485.flags &SER_RS485_ENABLED && + !(one->port.rs485.flags &SER_RS485_RX_DURING_TX )) + mode2 =MAX310X_MODE2_ECHOSUPR_BIT ; -if (!(one->port.rs485.flags &SER_RS485_RX_DURING_TX )) - mode2 =MAX310X_MODE2_ECHOSUPR_BIT ; - } - -/* -* A break owns the transceiver: break_ctl() disabled auto-RTS and -* drives RTS manually, and restores it when the break ends. Leave -* MODE1 alone meanwhile or the break goes undriven mid-way. -*/ -if (!one->tx_break) -max310x_port_update (&one->port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , mode1);max310x_port_update (&one->port,MAX310X_MODE2_REG , -MAX310X_MODE2_ECHOSUPR_BIT , mode2); +MAX310X_MODE2_ECHOSUPR_BIT , mode2); } static int max310x_rs485_config(struct uart_port *port, struct ktermios *termios,
@@ -1113,21 +1129,14 @@ static int max310x_startup(struct uart_port *port)max310x_port_update (port,MAX310X_MODE2_REG ,MAX310X_MODE2_FIFORST_BIT ,0 ); -/* Configure mode1/mode2 to have rs485/rs232 enabled at startup */ - val = (clamp (port->rs485.delay_rts_before_send,0U ,15U ) <<4 ) | -clamp (port->rs485.delay_rts_after_send,0U ,15U ); -max310x_port_write (port,MAX310X_HDPIXDELAY_REG , val); - -if (port->rs485.flags &SER_RS485_ENABLED ) { -max310x_port_update (port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT , -MAX310X_MODE1_TRNSCVCTRL_BIT ); +/* Configure the RS485 RTS timing and the RS485/RS232 mode bits. */ +max310x_set_rts_ctl_params (one); -if (!(port->rs485.flags &SER_RS485_RX_DURING_TX )) -max310x_port_update (port,MAX310X_MODE2_REG , -MAX310X_MODE2_ECHOSUPR_BIT , -MAX310X_MODE2_ECHOSUPR_BIT ); - } +if (port->rs485.flags &SER_RS485_ENABLED && + !(port->rs485.flags &SER_RS485_RX_DURING_TX )) +max310x_port_update (port,MAX310X_MODE2_REG , +MAX310X_MODE2_ECHOSUPR_BIT , +MAX310X_MODE2_ECHOSUPR_BIT );/* * Configure flow control levels:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1116/1756 serial: max310x: fix RS485 delays being programmed as bit-times
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit 7784d6aee59a142505072b3fbea97932b2fd1fa0 ]
The HDPIXDELAY register counts the RTS setup and hold delays in bit-times, four bits per direction, but the driver has been writing the struct serial_rs485 delay_rts_before_send/delay_rts_after_send values into it unconverted - and the uapi expresses those in milliseconds. A requested 9 ms setup delay is programmed as 9 bit-times, which at 9600 baud is 0.94 ms, roughly a tenth of what userspace asked for; the error grows with the baud rate.
Cache the baud rate in set_termios() and convert the delays to bit-times at the current rate, rounding up so the delay on the wire is never shorter than requested, and capping at the 15 bit-times the 4-bit field can hold. The conversion lives in max310x_set_rts_ctl_params(); set_termios() now calls it as well, since the conversion depends on the baud rate.
The delays a 4-bit bit-time field can represent still fall well short of the milliseconds the uapi can express; requests beyond 15 bit-times are capped, and the -ERANGE rejection of values above 15 ms remains in place for now.
--- drivers/tty/serial/max310x.c | 40 ++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 9 deletions(-)
drivers/tty/serial/max310x.c +31 -9
@@ -163,6 +163,10 @@#define MAX310X_IRDA_IRDAEN_BIT (1 << 0)/* IRDA mode enable */ #define MAX310X_IRDA_SIR_BIT (1 << 1)/* SIR mode enable */ +/* HDPIXDELAY accessor macros */ +#define MAX310X_HDPIXDELAY_SETUP (val) (((val) & 0x0f) << 4) +#define MAX310X_HDPIXDELAY_HOLD (val) ((val) & 0x0f) +/* Flow control trigger level register masks */ #define MAX310X_FLOWLVL_HALT_MASK GENMASK(3, 0)/* Flow control halt level */ #define MAX310X_FLOWLVL_RES_MASK GENMASK(7, 4)/* Flow control resume level */
@@ -285,6 +289,7 @@ struct max310x_one {struct work_struct md_work;struct work_struct rs_work;struct regmap *regmap; +unsigned int baud;bool tx_break;/* break_ctl() owns the transceiver */ u8 rx_buf[MAX310X_FIFO_SIZE ];
@@ -892,23 +897,33 @@ static void max310x_set_mctrl(struct uart_port *port, unsigned int mctrl) }/* -* Program the chip's RS485 RTS timing (HDPIXDELAY) and the auto -* transceiver control (MODE1) from the current configuration. The -* rs485-config worker, startup() and break_ctl()'s break-off restore -* each carried their own copy of this sequence. +* Program the chip's RS485 RTS timing. The HDPIXDELAY setup and hold fields +* count bit-times, four bits per direction, while the uapi expresses the +* delays in milliseconds: convert at the current baud rate, rounding up, and +* cap at the field maximum. */ static void max310x_set_rts_ctl_params (struct max310x_one *one) { +const unsigned int max_bit_dly =15 ;struct uart_port *port = &one->port; -unsigned int delay; +unsigned int setup =0 , hold =0 ;u8 mode1 =0 ; - delay = (clamp (port->rs485.delay_rts_before_send,0U ,15U ) <<4 ) | -clamp (port->rs485.delay_rts_after_send,0U ,15U ); -max310x_port_write (port,MAX310X_HDPIXDELAY_REG , delay); +if (port->rs485.flags &SER_RS485_ENABLED ) { +/* Convert milliseconds to bit-times, rounding up. */ + setup =DIV_ROUND_UP (one->baud * port->rs485.delay_rts_before_send, +MSEC_PER_SEC ); + hold =DIV_ROUND_UP (one->baud * port->rs485.delay_rts_after_send, +MSEC_PER_SEC ); + setup =min (setup, max_bit_dly); + hold =min (hold, max_bit_dly); -if (port->rs485.flags &SER_RS485_ENABLED ) mode1 =MAX310X_MODE1_TRNSCVCTRL_BIT ; + } + +max310x_port_write (port,MAX310X_HDPIXDELAY_REG , +MAX310X_HDPIXDELAY_SETUP (setup) | +MAX310X_HDPIXDELAY_HOLD (hold));/* * A break owns the transceiver: break_ctl() disabled auto-RTS and
@@ -1064,6 +1079,13 @@ static void max310x_set_termios(struct uart_port *port,/* Update timeout according to new baud rate */ uart_update_timeout (port, termios->c_cflag, baud); + +/* +* Cache the new baud rate and reprogram the RS485 RTS delays, whose +* millisecond-to-bit-time conversion depends on it. +*/ +to_max310x_port (port)->baud = baud; +max310x_set_rts_ctl_params (to_max310x_port (port)); }static void max310x_rs_proc (struct work_struct *ws)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1117/1756 serial: max310x: dont power down the port mid-transmission on close
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tapio Reijonen <[email protected]>
[ Upstream commit c3ad42ccd303113a08bd0b441fb5b3380f29c5bf ]
max310x_shutdown() powers the port down regardless of what the transmitter is doing. The power-off stops the UART clock mid-character, truncating the final frame, and on the auto-RTS path it freezes the RTS output at its current level: a close() with data still queued leaves the RS485 transceiver asserted until the next open, which also emits the interrupted character corrupted.
Waiting for the data to drain is no better: the tty layer's wait-until-sent is bounded by closing_wait, configurable to none, and a hangup arrives with no wait at all, so draining a full FIFO blocks close() in uninterruptible sleep for seconds at low baud rates - and forever when CTS flow control blocks the FIFO.
Instead, set MODE1 TxDisabl: the character in flight completes and the transmitter ceases with TX_ at idle. Give that character one character time (the chip has no transmitter-idle status), then reset the FIFOs so the auto-RTS engine sees the transmitter empty and releases RTS within the configured after-send hold; wait that hold plus one bit time before powering off. Abandoned data was explicitly not waited for, and startup() resets the FIFOs and TxDisabl on open anyway.
Measured on a MAX14830: a truncating close() at 50 baud takes 0.23 s, RTS releases one character plus the hold after the last stop bit on both polarities, and the reopen corruption is gone.
--- drivers/tty/serial/max310x.c | 44 ++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-)
drivers/tty/serial/max310x.c +40 -4
@@ -289,6 +289,7 @@ struct max310x_one {struct work_struct md_work;struct work_struct rs_work;struct regmap *regmap; +unsigned int char_time_us;unsigned int baud;bool tx_break;/* break_ctl() owns the transceiver */
@@ -969,6 +970,7 @@ static void max310x_set_termios(struct uart_port *port,struct ktermios *termios, const struct ktermios *old) { + unsigned int frame_bits = tty_get_frame_size(termios->c_cflag);unsigned int lcr =0 , flow =0 ;int baud;
@@ -1081,10 +1083,13 @@ static void max310x_set_termios(struct uart_port *port,uart_update_timeout (port, termios->c_cflag, baud);/* -* Cache the new baud rate and reprogram the RS485 RTS delays, whose -* millisecond-to-bit-time conversion depends on it. +* Cache the new baud rate and the time it takes to clock out one +* character before reprogramming the RS485 RTS delays: the +* millisecond-to-bit-time conversion divides by the baud rate. */ to_max310x_port (port)->baud = baud; +to_max310x_port (port)->char_time_us = +DIV_ROUND_UP (USEC_PER_SEC * frame_bits, baud);max310x_set_rts_ctl_params (to_max310x_port (port)); }
@@ -1141,9 +1146,10 @@ static int max310x_startup(struct uart_port *port) one->tx_break = false;max310x_port_update (port,MAX310X_LCR_REG ,MAX310X_LCR_TXBREAK_BIT ,0 ); -/* Configure MODE1 register */ +/* Configure MODE1: re-enable the transmitter shutdown() stopped */ max310x_port_update (port,MAX310X_MODE1_REG , -MAX310X_MODE1_TRNSCVCTRL_BIT ,0 ); +MAX310X_MODE1_TRNSCVCTRL_BIT | +MAX310X_MODE1_TXDIS_BIT ,0 );/* Configure MODE2 register & Reset FIFOs*/ val =MAX310X_MODE2_RXEMPTINV_BIT |MAX310X_MODE2_FIFORST_BIT ;
@@ -1180,9 +1186,39 @@ static int max310x_startup(struct uart_port *port)static void max310x_shutdown (struct uart_port *port) { +struct max310x_one *one =to_max310x_port (port); +/* Disable all interrupts */ max310x_port_write (port,MAX310X_IRQEN_REG ,0 ); +/* +* Stop the transmitter: the character in flight completes, data +* still queued is abandoned (the next startup() resets the FIFOs). +*/ +max310x_port_update (port,MAX310X_MODE1_REG , +MAX310X_MODE1_TXDIS_BIT ,MAX310X_MODE1_TXDIS_BIT ); + +/* +* Let the character in flight finish (the chip has no +* transmitter-idle status), then empty the FIFO: auto-RTS releases +* only once the transmitter is empty, and the power-off below +* would freeze an asserted pin until the next open. +*/ +fsleep (one->char_time_us); +max310x_port_update (port,MAX310X_MODE2_REG , +MAX310X_MODE2_FIFORST_BIT , +MAX310X_MODE2_FIFORST_BIT ); +max310x_port_update (port,MAX310X_MODE2_REG , +MAX310X_MODE2_FIFORST_BIT ,0 ); +if (port->rs485.flags &SER_RS485_ENABLED && one->baud) { +unsigned int hold =DIV_ROUND_UP (one->baud * + port->rs485.delay_rts_after_send, +MSEC_PER_SEC ); + +fsleep (max (DIV_ROUND_UP ((hold +1 ) *USEC_PER_SEC , + one->baud),100U )); + } +max310x_power (port,0 ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1118/1756 ntfs3: add FS_IOC_GETFSLABEL ioctl
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Ferguson <[email protected]>
[ Upstream commit e4dff970091118f2ecf66146d0b286979078b5cc ]
Add support for the FS_IOC_GETFSLABEL ioctl.
Stable-dep-of: 80218408836f ("fs/ntfs3: do not mark frame pages uptodate on read error")
--- fs/ntfs3/file.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
fs/ntfs3/file.c +10 -0
@@ -49,6 +49,14 @@ static int ntfs_ioctl_fitrim(struct ntfs_sb_info *sbi, unsigned long arg)return 0 ; } +static int ntfs_ioctl_get_volume_label (struct ntfs_sb_info *sbi,u8 __user *buf) +{ +if (copy_to_user (buf, sbi->volume.label,FSLABEL_MAX )) +return -EFAULT ; + +return 0 ; +} +/* * ntfs_fileattr_get - inode_operations::fileattr_get */
@@ -144,6 +152,8 @@ long ntfs_ioctl(struct file *filp, u32 cmd, unsigned long arg)switch (cmd) {case FITRIM :return ntfs_ioctl_fitrim (sbi, arg); +case FS_IOC_GETFSLABEL : +return ntfs_ioctl_get_volume_label (sbi, (u8 __user *)arg); }return -ENOTTY ;/* Inappropriate ioctl for device. */ }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1119/1756 ntfs3: add FS_IOC_SETFSLABEL ioctl
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Ferguson <[email protected]>
[ Upstream commit 21dc07ac9c25f01ab2023e3e8605861d8fd6e00c ]
Add support for the FS_IOC_SETFSLABEL ioctl.
Stable-dep-of: 80218408836f ("fs/ntfs3: do not mark frame pages uptodate on read error")
--- fs/ntfs3/file.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
fs/ntfs3/file.c +18 -0
@@ -57,6 +57,22 @@ static int ntfs_ioctl_get_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)return 0 ; } +static int ntfs_ioctl_set_volume_label (struct ntfs_sb_info *sbi,u8 __user *buf) +{ +u8 user[FSLABEL_MAX ] = {0 }; +int len; + +if (!capable (CAP_SYS_ADMIN )) +return -EPERM ; + +if (copy_from_user (user, buf,FSLABEL_MAX )) +return -EFAULT ; + + len =strnlen (user,FSLABEL_MAX ); + +return ntfs_set_label (sbi, user, len); +} +/* * ntfs_fileattr_get - inode_operations::fileattr_get */
@@ -154,6 +170,8 @@ long ntfs_ioctl(struct file *filp, u32 cmd, unsigned long arg)return ntfs_ioctl_fitrim (sbi, arg);case FS_IOC_GETFSLABEL :return ntfs_ioctl_get_volume_label (sbi, (u8 __user *)arg); +case FS_IOC_SETFSLABEL : +return ntfs_ioctl_set_volume_label (sbi, (u8 __user *)arg); }return -ENOTTY ;/* Inappropriate ioctl for device. */ }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1120/1756 ntfs: Do not kmap pages used for reading from disk
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 14656154d26cf244d063477a03606775eec19780 ]
These pages are accessed through DMA and vmap; they are not accessed by calling page_address(), so they do not need to be kmapped.
Stable-dep-of: 80218408836f ("fs/ntfs3: do not mark frame pages uptodate on read error")
--- fs/ntfs3/frecord.c | 4 ---- 1 file changed, 4 deletions(-)
fs/ntfs3/frecord.c +0 -4
@@ -2684,7 +2684,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages, } pages_disk[i] = pg;lock_page (pg); -kmap (pg); }/* Read 'ondisk_size' bytes from disk. */
@@ -2743,7 +2742,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,for (i =0 ; i < npages_disk; i++) { pg = pages_disk[i];if (pg) { -kunmap (pg);unlock_page (pg);put_page (pg); }
@@ -2838,7 +2836,6 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages, } pages_disk[i] = pg;lock_page (pg); -kmap (pg); }/* To simplify compress algorithm do vmap for source and target pages. */
@@ -2919,7 +2916,6 @@ int ni_write_frame(struct ntfs_inode *ni, struct page **pages,for (i =0 ; i < pages_per_frame; i++) { pg = pages_disk[i];if (pg) { -kunmap (pg);unlock_page (pg);put_page (pg); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1121/1756 fs/ntfs3: remove ntfs_bio_pages and use page cache for compressed I/O
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Konstantin Komarov <[email protected]>
[ Upstream commit f35590ee26f5722bfe12cdff14396c4c057a8f74 ]
Replace the use of ntfs_bio_pages with the disk page cache for reading and writing compressed files. This slightly improves performance when reading compressed data and simplifies the I/O logic.
When an XPRESS or LZX compressed file is opened for writing, it is now decompressed into a normal file before modification. A new argument (int copy) is added to ni_read_frame() to handle writing of decompressed and mapped data.
Stable-dep-of: 80218408836f ("fs/ntfs3: do not mark frame pages uptodate on read error")
--- fs/ntfs3/attrib.c | 4 +- fs/ntfs3/file.c | 6 +- fs/ntfs3/frecord.c | 152 ++++++++++++--------------------------------- fs/ntfs3/fsntfs.c | 123 ++++++++++++++++-------------------- fs/ntfs3/inode.c | 1 - fs/ntfs3/ntfs_fs.h | 20 ++++-- 6 files changed, 114 insertions(+), 192 deletions(-)
fs/ntfs3/attrib.c +1 -3
@@ -1482,7 +1482,6 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,pgoff_t index = vbo[i] >>PAGE_SHIFT ;if (index != folio->index) { -struct page *page = &folio->page;u64 from = vbo[i] & ~(u64)(PAGE_SIZE -1 );u64 to =min (from +PAGE_SIZE , wof_size);
@@ -1492,8 +1491,7 @@ int attr_wof_frame_info(struct ntfs_inode *ni, struct ATTRIB *attr,if (err) goto out1; - err =ntfs_bio_pages (sbi, run, &page,1 , from, - to - from,REQ_OP_READ ); + err =ntfs_read_run (sbi, run, addr, from, to - from);if (err) { folio->index =-1 ; goto out1;
fs/ntfs3/file.c +3 -3
@@ -59,7 +59,7 @@ static int ntfs_ioctl_get_volume_label(struct ntfs_sb_info *sbi, u8 __user *buf)static int ntfs_ioctl_set_volume_label (struct ntfs_sb_info *sbi,u8 __user *buf) { -u8 user[FSLABEL_MAX ] = {0 }; +u8 user[FSLABEL_MAX ] = {0 };int len;if (!capable (CAP_SYS_ADMIN ))
@@ -1087,7 +1087,7 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from)if (!frame_uptodate && off) { err =ni_read_frame (ni, frame_vbo, pages, - pages_per_frame); + pages_per_frame,0 );if (err) {for (ip =0 ; ip < pages_per_frame; ip++) { page = pages[ip];
@@ -1152,7 +1152,7 @@ static ssize_t ntfs_compress_write(struct kiocb *iocb, struct iov_iter *from)if (off || (to < i_size && (to & (frame_size -1 )))) { err =ni_read_frame (ni, frame_vbo, pages, - pages_per_frame); + pages_per_frame,0 );if (err) {for (ip =0 ; ip < pages_per_frame; ip++) {
fs/ntfs3/frecord.c +39 -113
285 lines not on this page · raw message
fs/ntfs3/fsntfs.c +55 -68
154 lines not on this page · raw message
fs/ntfs3/inode.c +0 -1
@@ -2134,7 +2134,6 @@ const struct address_space_operations ntfs_aops = {const struct address_space_operations ntfs_aops_cmpr = { .read_folio = ntfs_read_folio, - .readahead = ntfs_readahead, .dirty_folio = block_dirty_folio, .direct_IO = ntfs_direct_IO, };
fs/ntfs3/ntfs_fs.h +16 -4
@@ -574,7 +574,7 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo,int ni_read_folio_cmpr (struct ntfs_inode *ni,struct folio *folio);int ni_decompress_file (struct ntfs_inode *ni);int ni_read_frame (struct ntfs_inode *ni,u64 frame_vbo,struct page **pages, -u32 pages_per_frame); +u32 pages_per_frame,int copy);int ni_write_frame (struct ntfs_inode *ni,struct page **pages,u32 pages_per_frame); int ni_remove_name(struct ntfs_inode *dir_ni, struct ntfs_inode *ni,
@@ -639,9 +639,21 @@ int ntfs_get_bh(struct ntfs_sb_info *sbi, const struct runs_tree *run, u64 vbo, u32 bytes, struct ntfs_buffers *nb);int ntfs_write_bh (struct ntfs_sb_info *sbi,struct NTFS_RECORD_HEADER *rhdr,struct ntfs_buffers *nb,int sync); -int ntfs_bio_pages (struct ntfs_sb_info *sbi,const struct runs_tree *run, -struct page **pages,u32 nr_pages,u64 vbo,u32 bytes, -enum req_op op); +int ntfs_read_write_run (struct ntfs_sb_info *sbi,const struct runs_tree *run, +void *buf,u64 vbo,size_t bytes,int wr); +static inline int ntfs_read_run (struct ntfs_sb_info *sbi, +const struct runs_tree *run,void *buf,u64 vbo, +size_t bytes) +{ +return ntfs_read_write_run (sbi, run, buf, vbo, bytes,0 ); +} +static inline int ntfs_write_run (struct ntfs_sb_info *sbi, +const struct runs_tree *run,void *buf, +u64 vbo,size_t bytes) +{ +return ntfs_read_write_run (sbi, run, buf, vbo, bytes,1 ); +} +int ntfs_bio_fill_1 (struct ntfs_sb_info *sbi,const struct runs_tree *run);int ntfs_vbo_to_lbo (struct ntfs_sb_info *sbi,const struct runs_tree *run,u64 vbo,u64 *lbo,u64 *bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1122/1756 fs/ntfs3: do not mark frame pages uptodate on read error
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 80218408836fa6fc91a9c26a9c014f81abf9e41f ]
ni_read_frame() ends with a loop that marks every page of a compressed frame uptodate regardless of whether the read succeeded:
out:
for (i = 0; i < pages_per_frame; i++) {
pg = pages[i];
SetPageUptodate(pg);
}Non-critical frame pages come from __filemap_get_folio(FGP_CREAT) and are not zeroed. On an error path that reaches out: before frame_mem is written, these pages keep uninitialized page-allocator contents but are still marked uptodate. A later read() is then served from the page cache and returns that stale kernel memory to user space.
For an unprivileged user mounting a crafted NTFS image this is a repeatable kernel memory disclosure.
Mark the pages uptodate only on success; on error leave them !uptodate so the read path re-reads them or reports the error.
--- fs/ntfs3/frecord.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
fs/ntfs3/frecord.c +4 -6
@@ -2479,7 +2479,6 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,u64 vbo_disk;size_t unc_size;u32 frame_size, i, ondisk_size; -struct page *pg;struct ATTRIB *attr;CLST frame, clst_data;
@@ -2710,11 +2709,10 @@ int ni_read_frame(struct ntfs_inode *ni, u64 frame_vbo, struct page **pages,#endif vunmap (frame_mem); out: -for (i =0 ; i < pages_per_frame; i++) { - pg = pages[i]; -if (err) -clear_highpage (pg); -SetPageUptodate (pg); +if (!err) { +for (i =0 ; i < pages_per_frame; i++) { +SetPageUptodate (pages[i]); + } }return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1123/1756 net: alacritech: fix dma_free_coherent() in error path
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 05b5019b01fb9443b09ae4ed34af1135a80a84c8 ]
In slic_init_stat_queue(), a series of coherent buffers is allocated with the length size. The size is then stored in stq->mem_size for normal deallocation. However, in the error path, stq->mem_size is also used but is not initialized. This error may leave the freed buffers mapped, leaking a resource and allowing the device to access freed memory.
Change the length in error path to size.
--- drivers/net/ethernet/alacritech/slicoss.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/alacritech/slicoss.c +1 -1
@@ -813,7 +813,7 @@ static int slic_init_stat_queue(struct slic_device *sdev) free_descs:while (i--) { -dma_free_coherent (&sdev->pdev->dev, stq->mem_size, +dma_free_coherent (&sdev->pdev->dev, size, stq->descs[i] - stq->addr_offset[i], stq->paddr[i] - stq->addr_offset[i]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1124/1756 comedi: comedi_parport: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 790ea6844593bcd03b0379986fc821d8c511746e ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. comedi_parport passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
A parallel port asserts a legacy ISA interrupt, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
syzbot hit this one:
remove_proc_entry: removing non-empty directory 'irq/20', leaking at least 'comedi_parport' WARNING: fs/proc/generic.c:747 at remove_proc_entry+0x4e7/0x610 fs/proc/generic.c:747 Call Trace: <TASK> unregister_irq_proc+0x206/0x2a0 kernel/irq/proc.c:406 free_desc+0x89/0x330 kernel/irq/irqdesc.c:482 irq_free_descs+0x84/0xc0 kernel/irq/irqdesc.c:865 irq_domain_free_irqs+0x46a/0x5c0 kernel/irq/irqdomain.c:1917 mp_unmap_irq+0xf8/0x130 arch/x86/kernel/apic/io_apic.c:1061 acpi_unregister_gsi_ioapic+0x40/0x60 arch/x86/kernel/acpi/boot.c:722 acpi_pci_irq_disable+0x275/0x360 drivers/acpi/pci_irq.c:517 pci_disable_device+0x130/0x270 drivers/pci/pci.c:2206 pci_device_remove+0xb2/0x1d0 drivers/pci/pci-driver.c:512 device_release_driver_internal+0x44e/0x620 drivers/base/dd.c:1372 unbind_store+0xf8/0x110 drivers/base/bus.c:244 </TASK>
The leaked /proc entry the warning names is the mild part. mp_chip_data->count tracks GSI mappings rather than request_irq() users, and __setup_irq() takes no reference on the descriptor, so the irq_desc is freed with the comedi irqaction still attached to it.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/comedi_parport.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/comedi_parport.c +2 -1
@@ -241,7 +241,8 @@ static int parport_attach(struct comedi_device *dev,outb (0 , dev->iobase +PARPORT_DATA_REG );outb (0 , dev->iobase +PARPORT_CTRL_REG ); -if (it->options[1 ]) { +/* only ISA interrupts are valid on a parallel port */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], parport_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1125/1756 comedi: ni_atmio16d: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 71424db0ebb5f484fa3f386910f8ce9da95b8b2e ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. ni_atmio16d passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
The driver already documents which interrupts the board can assert -- "0 == no irq; or 3,4,5,6,7,9,10,11,12,14,15" -- so use exactly that set rather than the whole ISA range.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/ni_atmio16d.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/comedi/drivers/ni_atmio16d.c +3 -1
@@ -592,7 +592,9 @@ static int atmio16d_attach(struct comedi_device *dev,/* reset the atmio16d hardware */ reset_atmio16d (dev); -if (it->options[1 ]) { +/* only irqs 3, 4, 5, 6, 7, 9, 10, 11, 12, 14, and 15 are valid */ +if (it->options[1 ] >=3 && it->options[1 ] <=15 && + (1 << it->options[1 ]) &0xdef8 ) { ret =request_irq (it->options[1 ], atmio16d_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1126/1756 comedi: dt2814: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 81026c2b3f9096cdfdfa02918f94865629fb7f90 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. dt2814 passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/dt2814.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/dt2814.c +2 -1
@@ -315,7 +315,8 @@ static int dt2814_attach(struct comedi_device *dev, struct comedi_devconfig *it)return -EIO ; } -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], dt2814_interrupt,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1127/1756 comedi: dmm32at: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 797d56d7f90864e67424f8e82639a9b3aedf37e0 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. dmm32at passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/dmm32at.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/dmm32at.c +2 -1
@@ -584,7 +584,8 @@ static int dmm32at_attach(struct comedi_device *dev,return ret; } -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], dmm32at_isr,0 , dev->board_name, dev);if (ret ==0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1128/1756 comedi: pcmmio: validate the IRQ supplied by userspace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 23c6fc62e754f8bc412ceb5c0d9aaa14f2c9ff31 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. pcmmio passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
The board's interrupt is routed in software rather than jumpered, and the driver notes that "any IRQ from 1-15 is OK", so the ISA range is exactly the right bound.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
--- drivers/comedi/drivers/pcmmio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/comedi/drivers/pcmmio.c +2 -1
@@ -683,7 +683,8 @@ static int pcmmio_attach(struct comedi_device *dev, struct comedi_devconfig *it)pcmmio_reset (dev); -if (it->options[1 ]) { +/* the irq is configured in software, so any ISA irq is OK */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) { ret =request_irq (it->options[1 ], interrupt_pcmmio,0 , dev->board_name, dev);if (ret ==0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 1129/1756 comedi: pcmuio: validate the IRQs supplied by userspace
In reply to Greg Kroah-Hartman6.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yogesh Gaur <[email protected]>
[ Upstream commit 9c325b21bba99e597771137fc11b9427c86618d8 ]
comedi boards are configured through the COMEDI_DEVCONFIG ioctl, so it->options[1] is a number chosen by userspace. pcmuio passes it to request_irq() without checking it first, which lets an interrupt owned by another irqdomain -- a PCI device's IO-APIC GSI, for instance -- be claimed for this board. When the owner of that interrupt is later released the descriptor is freed while this driver's handler is still installed on it.
Every interrupt this board can assert is a legacy ISA one, so the ISA range is the right bound; it is also sufficient, because mp_chip_data->isa_irq is set only by alloc_isa_irq_from_domain() and mp_unmap_irq() returns early when it is set.
Bound the value before requesting it, as das16m1.c already does. An out-of-range value is ignored rather than rejected, so the board still attaches without interrupt support, exactly as it does today when request_irq() fails.
This board takes two interrupts, one per ASIC, so options[1] and options[2] both need the check. The existing options[2] == dev->irq case is left alone: it covers both ASICs sharing one interrupt and neither having one, and by then options[1] has already been validated.
--- drivers/comedi/drivers/pcmuio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/comedi/drivers/pcmuio.c +3 -2
@@ -545,7 +545,8 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)pcmuio_reset (dev); -if (it->options[1 ]) { +/* only ISA interrupts are valid on this board */ +if (it->options[1 ] >=1 && it->options[1 ] <=15 ) {/* request the irq for the 1st asic */ ret =request_irq (it->options[1 ], pcmuio_interrupt,0 , dev->board_name, dev);
@@ -557,7 +558,7 @@ static int pcmuio_attach(struct comedi_device *dev, struct comedi_devconfig *it)if (it->options[2 ] == dev->irq) {/* the same irq (or none) is used by both asics */ devpriv->irq2 = it->options[2 ]; - }else if (it->options[2 ]) { + }else if (it->options[2 ] >=1 && it->options[2 ] <=15 ) {/* request the irq for the 2nd asic */ ret =request_irq (it->options[2 ], pcmuio_interrupt,0 , dev->board_name, dev);
Signature · 1 line
2.53.0