5.10.275-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 801/1848 batman-adv: tt: only update flags for TT events
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit ad1fd828aa3944efc393b84b0d7c02483f1b5638 upstream.
In the first implementation of the translation table events, it was only possible to announce:
* ADD: new locally detected client
* DEL: disappeared local client
If an ADD event was queued and then a DEL event was queued in the same timeslot, it is valid to destroy both events because nothing actually changed for remode nodes
But with commit 3c4f7ab60cc2 ("batman-adv: improve the TT component to support runtime flag changes") and subsequent changes, it could also happen that there are extra ADD events:
* ADD: _NEW_ locally detected client
* ADD: already existing client with new flags
* DEL: disappeared local client
The first and the last type of event could in theory still be removed together from the (to be announced) events queue. But if the "update flags" ADD is dropped together with the DEL, it would still leave global translation table of a remote node in the incorrect state - believing that the client didn't disappear.
If a detected client was previously announced, a DEL event must only overwrite the "update flags" ADD but the DEL itself must still continue to exist in the (to be anounced) events queue. For now, adjustment of the announced flags is used for everything instead of dropping already queued up events completely.
Similarly, a DEL followed by an ADD caused both entries to be deleted. But the new ADD could announce flags changes which were not yet present for the client before it was marked for DELetion. The new ADD must therefore only overwrite the DEL - but still be kept.
--- net/batman-adv/translation-table.c | 41 ++++++++---------------------- 1 file changed, 11 insertions(+), 30 deletions(-)
net/batman-adv/translation-table.c +11 -30
@@ -456,6 +456,9 @@ batadv_tt_orig_list_entry_put(struct batadv_tt_orig_list_entry *orig_entry)* @bat_priv: the bat priv with all the soft interface information * @tt_local_entry: the TT entry involved in the event * @event_flags: flags to store in the event structure +* +* Only a single change per client is queued. It describes the latest state of +* the client and a new event therefore replaces an already queued one. */ static void batadv_tt_local_event(struct batadv_priv *bat_priv, struct batadv_tt_local_entry *tt_local_entry,
@@ -464,8 +467,7 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,struct batadv_tt_change_node *tt_change_node, *entry, *safe;struct batadv_tt_common_entry *common = &tt_local_entry->common;u8 flags = common->flags | event_flags; -bool event_removed = false; -bool del_op_requested, del_op_entry; +bool del_op_requested; tt_change_node =kmem_cache_alloc (batadv_tt_change_cache,GFP_ATOMIC );if (!tt_change_node)
@@ -497,44 +499,23 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,if (entry->change.vid != tt_change_node->change.vid)continue ; -/* DEL+ADD in the same orig interval have no effect and can be -* removed to avoid silly behaviour on the receiver side. The -* other way around (ADD+DEL) can happen in case of roaming of -* a client still in the NEW state. Roaming of NEW clients is -* now possible due to automatically recognition of "temporary" -* clients -*/ - del_op_entry = entry->change.flags &BATADV_TT_CLIENT_DEL ; -if (!del_op_requested && del_op_entry) - goto del; -if (del_op_requested && !del_op_entry) - goto del; - -/* this is a second add in the same originator interval. It -* means that flags have been changed: update them! +/* the other nodes may know the client with different +* flags. A DEL+ADD must therefore still announce the +* current flags and an ADD+DEL must still remove the +* client. ADD+ADD and DEL+DEL only update the flags */ -if (!del_op_requested && !del_op_entry) - entry->change.flags = flags; - -continue ; -del: -list_del (&entry->list); -kmem_cache_free (batadv_tt_change_cache, entry); + entry->change.flags = flags;kmem_cache_free (batadv_tt_change_cache, tt_change_node); - event_removed = true; + goto unlock; }/* track the change in the OGMinterval list */ list_add_tail (&tt_change_node->list, &bat_priv->tt.changes_list); +atomic_inc (&bat_priv->tt.local_changes); unlock:spin_unlock_bh (&bat_priv->tt.changes_list_lock); - -if (event_removed) -atomic_dec (&bat_priv->tt.local_changes); -else -atomic_inc (&bat_priv->tt.local_changes); }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 802/1848 batman-adv: tt: dont drop local events queued during TVLV update
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Eckelmann <[email protected]>
commit ed7a0dfdd370acb48be7a281df732c1bebcc7f1d upstream.
batadv_tt_tvlv_container_update() read the number of local changes without holding changes_list_lock. batadv_tt_local_event() is not serialized by the commit_lock and can queue new events before the changes_list is flushed:
CPU0 CPU1
batadv_tt_tvlv_container_update()
num = ...local_changes;
batadv_tt_local_event()
list_add_tail(...);
...local_changes++;
spin_lock_bh(&...changes_list_lock);
/* only num events copied but all freed */The additional events were freed without ever being sent. Other nodes will only notice this via a CRC mismatch and must request the full table.
The number of changes and the changes_list must therefore be taken atomically. Events queued afterwards then stay in the tt.changes_list for the next TT round.
The changes can no longer be kept for the next round when the TVLV buffer allocation fails. But they would be sent with a skipped TTVN anyway, so the other nodes have to request the full table in this case either way. The last changeset is only dropped in this case when the TTVN was incremented. Without new changes, it still describes the current TTVN.
Previously, the unconsumed changes caused a retry of the TVLV container update in the next commit round. Since the changes are now consumed, the next round would only take the path without changes and wait for BATADV_TT_OGM_APPEND_MAX rounds before updating the container again. Until then, the outdated container with the previous TTVN would still be announced. The ogm_append_cnt is therefore reset on failure to retry the update in the next OGM interval.
This doesn't make the CRC consistent with the announced changeset. The local table modifications are still not serialized with the commit and batadv_tt_local_transition_new() can still make a client part of the CRC for which the event is only part of the next TT round. Such an inconsistency is detected by the CRC check of the other nodes and solved via a full table request.
[ Context, switch to old "mesh_iface" name "soft_iface", access
local_changes with atomic_t helpers ]
--- net/batman-adv/translation-table.c | 61 +++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 13 deletions(-)
net/batman-adv/translation-table.c +48 -13
@@ -1023,20 +1023,22 @@ batadv_tt_prepare_tvlv_local_data(struct batadv_priv *bat_priv,* batadv_tt_tvlv_container_update() - update the translation table tvlv * container after local tt changes have been committed * @bat_priv: the bat priv with all the soft interface information +* @changes_list: list of committed changes which will be consumed +* @tt_diff_entries_num: number of entries in @changes_list */ -static void batadv_tt_tvlv_container_update (struct batadv_priv *bat_priv) +static void batadv_tt_tvlv_container_update (struct batadv_priv *bat_priv, +struct list_head *changes_list, +int tt_diff_entries_num) {struct batadv_tt_change_node *entry, *safe;struct batadv_tvlv_tt_data *tt_data;struct batadv_tvlv_tt_change *tt_change;int tt_diff_len, tt_change_len =0 ; -int tt_diff_entries_num =0 ;int tt_diff_entries_count =0 ;bool drop_changes = false;size_t tt_extra_len =0 ;u16 tvlv_len; - tt_diff_entries_num =atomic_read (&bat_priv->tt.local_changes); tt_diff_len =batadv_tt_len (tt_diff_entries_num);/* if we have too many changes for one packet don't send any
@@ -1054,19 +1056,39 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv) tvlv_len =batadv_tt_prepare_tvlv_local_data (bat_priv, &tt_data, &tt_change, &tt_diff_len); -if (!tvlv_len) +if (!tvlv_len) { +/* the changes are lost and the other nodes have to request the +* full table. Don't answer TT requests for the new TTVN with +* the stale changeset of the previous TTVN. Without changes, the +* TTVN was not incremented and the last changeset is still valid +*/ +if (drop_changes || tt_diff_entries_num >0 ) { +list_for_each_entry_safe (entry, safe, changes_list, + list) { +list_del (&entry->list); +kmem_cache_free (batadv_tt_change_cache, entry); + } + +spin_lock_bh (&bat_priv->tt.last_changeset_lock); +kfree (bat_priv->tt.last_changeset); + bat_priv->tt.last_changeset =NULL ; + bat_priv->tt.last_changeset_len =0 ; +spin_unlock_bh (&bat_priv->tt.last_changeset_lock); + } + +/* announce the already committed TTVN in the next OGM interval +* instead of waiting for BATADV_TT_OGM_APPEND_MAX idle rounds +*/ +atomic_set (&bat_priv->tt.ogm_append_cnt,0 );return ; + } tt_data->flags =BATADV_TT_OGM_DIFF ;if (!drop_changes && tt_diff_len ==0 ) goto container_register; -spin_lock_bh (&bat_priv->tt.changes_list_lock); -atomic_set (&bat_priv->tt.local_changes,0 ); - -list_for_each_entry_safe (entry, safe, &bat_priv->tt.changes_list, - list) { +list_for_each_entry_safe (entry, safe, changes_list, list) {if (tt_diff_entries_count < tt_diff_entries_num) { memcpy(tt_change + tt_diff_entries_count, &entry->change,
@@ -1076,7 +1098,6 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)list_del (&entry->list);kmem_cache_free (batadv_tt_change_cache, entry); } -spin_unlock_bh (&bat_priv->tt.changes_list_lock); tt_extra_len =batadv_tt_len (tt_diff_entries_num - tt_diff_entries_count);
@@ -3998,11 +4019,25 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv)*/ static void batadv_tt_local_commit_changes_nolock (struct batadv_priv *bat_priv) { +LIST_HEAD (changes_list); +int changes_num; +lockdep_assert_held (&bat_priv->tt.commit_lock); -if (atomic_read (&bat_priv->tt.local_changes) <1 ) { +/* atomically get the list of changes. The TTVN decision and the +* announced changeset must cover the same events. Events queued +* afterwards stay in the tt.changes_list for the next TT round +*/ +spin_lock_bh (&bat_priv->tt.changes_list_lock); +list_splice_init (&bat_priv->tt.changes_list, &changes_list); + changes_num =atomic_read (&bat_priv->tt.local_changes); +atomic_set (&bat_priv->tt.local_changes,0 ); +spin_unlock_bh (&bat_priv->tt.changes_list_lock); + +if (changes_num ==0 ) {if (!batadv_atomic_dec_not_zero (&bat_priv->tt.ogm_append_cnt)) -batadv_tt_tvlv_container_update (bat_priv); +batadv_tt_tvlv_container_update (bat_priv, &changes_list, + changes_num);return ; }
@@ -4019,7 +4054,7 @@ static void batadv_tt_local_commit_changes_nolock(struct batadv_priv *bat_priv)/* reset the sending counter */ atomic_set (&bat_priv->tt.ogm_append_cnt,BATADV_TT_OGM_APPEND_MAX ); -batadv_tt_tvlv_container_update (bat_priv); +batadv_tt_tvlv_container_update (bat_priv, &changes_list, changes_num); }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 803/1848 lib/crypto: mips: Disable Octeon SHA code on little-endian kernels
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Biggers <[email protected]>
commit dd2a4edb26e1c78823c50ba10c42f2d3de2e5ec4 upstream.
Kernels built for the MIPS64-based Cavium Octeon SoCs are normally big-endian, but little-endian builds are also supported. Currently, the SHA-1, SHA-256, and SHA-512 code using the Octeon crypto co-processor is enabled in both builds.
This code is untestable without the hardware. However, based on the code itself, it is implausible that it computes hash values correctly in little-endian builds. Such builds write many incorrect values to COP2:
- SHA-1 and SHA-256: The 64-bit integer that contains the last two 32-bit message words of each block is written to COP2 entirely byte-reflected, due to missing endianness conversion in octeon_sha1_start() and octeon_sha256_start() to compensate for using native 64-bit loads from the message bytes. This differs from all the earlier message words which are written correctly.
Furthermore, the state is written to COP2 with each 32-bit word byte-reflected within each 64-bit integer, due to incorrect use of 64-bit endianness conversion in write_octeon_64bit_hash_dword() when the state is kept in memory in native-endian 32-bit words.
- SHA-512: All the 64-bit message words are written to COP2 byte-reflected, due to missing endianness conversion in write_octeon_64bit_block_sha512() and octeon_sha512_start(). The SHA-512 state words seem to be written correctly.
Big-endian kernels aren't affected by these bugs. These bugs also aren't new; this code has been broken on little-endian ever since it and Octeon little-endian support were first added in v4.1.
Commit d2a948d2db68 ("MIPS: Octeon: Make octeon-md5 driver endian-agnostic") made the MD5 code work on little-endian kernels by adding 64-bit endianness conversions to the COP2 macros used by MD5 (some of which are shared by SHA-1 and SHA-256, despite those algorithms keeping the state words in native-endian instead of MD5's little-endian, causing some of the strange behavior described above). However, SHA-1, SHA-256, and SHA-512 were never fixed to work on little-endian kernels.
Therefore, disable the Octeon SHA-1, SHA-256, and SHA-512 code in little-endian kernels. This causes the generic code that actually computes hash values correctly to be used instead.
--- crypto/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
crypto/Kconfig +3 -3
@@ -918,7 +918,7 @@ config CRYPTO_SHA512_SSSE3 config CRYPTO_SHA1_OCTEON tristate "SHA1 digest algorithm (OCTEON)" - depends on CPU_CAVIUM_OCTEON + depends on CPU_CAVIUM_OCTEON && CPU_BIG_ENDIAN select CRYPTO_SHA1 select CRYPTO_HASH help
@@ -972,7 +972,7 @@ config CRYPTO_SHA256_PPC_SPE config CRYPTO_SHA256_OCTEON tristate "SHA224 and SHA256 digest algorithm (OCTEON)" - depends on CPU_CAVIUM_OCTEON + depends on CPU_CAVIUM_OCTEON && CPU_BIG_ENDIAN select CRYPTO_SHA256 select CRYPTO_HASH help
@@ -1002,7 +1002,7 @@ config CRYPTO_SHA512 config CRYPTO_SHA512_OCTEON tristate "SHA384 and SHA512 digest algorithms (OCTEON)" - depends on CPU_CAVIUM_OCTEON + depends on CPU_CAVIUM_OCTEON && CPU_BIG_ENDIAN select CRYPTO_SHA512 select CRYPTO_HASH help
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 804/1848 ALSA: usx2y: Refuse a retried DSP load after a failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit 1f8101b6adc87a3ddbd51fcb6609251591758026 ]
snd_usx2y_hwdep_dsp_load() sets up the asynchronous sequence URBs and the interrupt URB when the FPGA firmware image with index 1 is loaded, and then creates the ALSA devices. If usx2y_in04_init() or usx2y_create_alsa_devices() fails, the URBs that were already set up are left in place.
The core keeps the index unloaded when the callback fails, so user space may issue the same request again. The second attempt then enters usx2y_async_seq04_init() or usx2y_in04_init() with the URBs still allocated and trips WARN_ON(usx2y->as04.buffer) or WARN_ON(usx2y->in04_urb).
The URBs cannot be released at this point: the card may already have registered PCM devices that user space can still open, and the disconnect handler accesses the URBs without holding the DSP lock. Mark the chip as hung instead, so that a retried request is refused with -ENODEV and the assertions keep their meaning. The URBs are released by snd_usx2y_card_private_free() when the card is freed.
A failing usx2y_async_seq04_init() still releases its own URBs, so that path remains retryable.
In 5.10 a failure of usx2y_create_alsa_devices() frees the card, so there is no retry to refuse on that path and only usx2y_in04_init() is marked as hung here.
--- sound/usb/usx2y/usX2Yhwdep.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/usb/usx2y/usX2Yhwdep.c +4 -0
@@ -193,6 +193,9 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw,int lret, err;char *buf; +if (priv->chip_status &USX2Y_STAT_CHIP_HUP ) +return -ENODEV ; +snd_printdd ("dsp_load %s\n" , dsp->name); buf =memdup_user (dsp->image, dsp->length);
@@ -217,6 +220,7 @@ static int snd_usx2y_hwdep_dsp_load(struct snd_hwdep *hw, err =usx2y_in04_init (priv);if (err) {snd_printk (KERN_ERR "usx2y_in04_init error\n" ); + priv->chip_status |=USX2Y_STAT_CHIP_HUP ;return err; } err =usx2y_create_alsa_devices (hw->card);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 805/1848 ALSA: bcd2000: Fix race between rawmidi and disconnect
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
commit 221253723dc58bb901c3f27a7659823e63fc598c upstream.
The 5.10.y tree is still built with -std=gnu89, so the guard() and scoped_guard() helpers used by the upstream patch cannot be used here. Use explicit spin_lock_irqsave()/spin_unlock_irqrestore() pairs instead; the locking scope is unchanged.
Although we tried to fix the potential UAF issues at USB disconnect on bcd2000 driver, there is still an overlooked case -- namely, when a rawmidi trigger callback has been already running at USB disconnect handling, the in-flight function (e.g. bcd2000_midi_send()) could still access the URB, because the previous URB NULL-check & clearance was considered only for the URB complete callbacks, but not about the parallel rawmidi operations.
For addressing the race, this patch introduced a new spinlock that covers each rawmidi operation as well as the rawmidi handling in the complete callback. The URB is cleared with the lock, so it guarantees that the pending rawmidi task already finished or a NULL check is effective.
--- sound/usb/bcd2000/bcd2000.c | 45 +++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 7 deletions(-)
sound/usb/bcd2000/bcd2000.c +38 -7
@@ -43,6 +43,7 @@ struct bcd2000 {struct usb_interface *intf;int card_index; +spinlock_t midi_lock;int midi_out_active;struct snd_rawmidi *rmidi;struct snd_rawmidi_substream *midi_receive_substream;
@@ -90,7 +91,11 @@ static void bcd2000_midi_input_trigger(struct snd_rawmidi_substream *substream, int up) {struct bcd2000 *bcd2k = substream->rmidi->private_data; +unsigned long flags; + +spin_lock_irqsave (&bcd2k->midi_lock, flags); bcd2k->midi_receive_substream = up ? substream :NULL ; +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); } static void bcd2000_midi_handle_input(struct bcd2000 *bcd2k,
@@ -194,6 +199,9 @@ static void bcd2000_midi_output_trigger(struct snd_rawmidi_substream *substream, int up) {struct bcd2000 *bcd2k = substream->rmidi->private_data; +unsigned long flags; + +spin_lock_irqsave (&bcd2k->midi_lock, flags);if (up) { bcd2k->midi_out_substream = substream;
@@ -203,11 +211,14 @@ static void bcd2000_midi_output_trigger(struct snd_rawmidi_substream *substream, }else { bcd2k->midi_out_substream =NULL ; } + +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); }static void bcd2000_output_complete (struct urb *urb) {struct bcd2000 *bcd2k = urb->context; +unsigned long flags; bcd2k->midi_out_active =0 ;
@@ -219,12 +230,15 @@ static void bcd2000_output_complete(struct urb *urb)return ;/* check if there is more data userspace wants to send */ +spin_lock_irqsave (&bcd2k->midi_lock, flags);bcd2000_midi_send (bcd2k); +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); }static void bcd2000_input_complete (struct urb *urb) {int ret; +unsigned long flags;struct bcd2000 *bcd2k = urb->context;if (urb->status)
@@ -234,6 +248,8 @@ static void bcd2000_input_complete(struct urb *urb)if (!bcd2k || urb->status == -ESHUTDOWN )return ; +spin_lock_irqsave (&bcd2k->midi_lock, flags); +if (urb->actual_length >0 )bcd2000_midi_handle_input (bcd2k, urb->transfer_buffer, urb->actual_length);
@@ -244,6 +260,8 @@ static void bcd2000_input_complete(struct urb *urb)dev_err (&bcd2k->dev->dev,PREFIX "%s: usb_submit_urb() failed, ret=%d\n" , __func__, ret); + +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); }static const struct snd_rawmidi_ops bcd2000_midi_output = {
@@ -348,16 +366,28 @@ static int bcd2000_init_midi(struct bcd2000 *bcd2k)return 0 ; } +static void bcd2000_midi_free (struct bcd2000 *bcd2k, +struct urb **urb_p) +{ +struct urb *urb = *urb_p; +unsigned long flags; + +if (!urb) +return ; + +usb_poison_urb (urb); +spin_lock_irqsave (&bcd2k->midi_lock, flags); + *urb_p =NULL ; +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); + +usb_free_urb (urb); +} +static void bcd2000_free_usb_related_resources (struct bcd2000 *bcd2k,struct usb_interface *interface) { -usb_poison_urb (bcd2k->midi_out_urb); -usb_poison_urb (bcd2k->midi_in_urb); - -usb_free_urb (bcd2k->midi_out_urb); -usb_free_urb (bcd2k->midi_in_urb); - bcd2k->midi_out_urb =NULL ; - bcd2k->midi_in_urb =NULL ; +bcd2000_midi_free (bcd2k, &bcd2k->midi_out_urb); +bcd2000_midi_free (bcd2k, &bcd2k->midi_in_urb);if (bcd2k->intf) {usb_set_intfdata (bcd2k->intf,NULL );
@@ -397,6 +427,7 @@ static int bcd2000_probe(struct usb_interface *interface, bcd2k->card = card; bcd2k->card_index = card_index; bcd2k->intf = interface; +spin_lock_init (&bcd2k->midi_lock);snd_card_set_dev (card, &interface->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 806/1848 ALSA: bcd2000: Fix use-after-free of MIDI URBs on file close
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
commit f6c7bb1f0799591a62be75b9bcf84245b4f208b7 upstream.
The 5.10.y tree is still built with -std=gnu89, so the guard() and scoped_guard() helpers used by the upstream patch cannot be used here. Use explicit spin_lock_irqsave()/spin_unlock_irqrestore() pairs instead; the locking scope is unchanged.
bcd2000_disconnect() calls snd_card_disconnect(), which only prevents new opens, and then frees the MIDI URBs. A rawmidi file that was already open can still be closed afterwards, and its close callback, bcd2000_midi_output_close(), calls usb_kill_urb() on midi_out_urb.
The URB pointers are cleared on disconnect and their accesses are serialized with midi_lock, but bcd2000_midi_output_close() reads midi_out_urb without that lock. The check can therefore pass just before the pointer is cleared, and usb_kill_urb() then runs on the URB that has already been freed:
BUG: KASAN: slab-use-after-free in usb_kill_urb+0x74/0x80 Read of size 8 at addr ffff8880078e7d40 usb_kill_urb bcd2000_midi_output_close close_substream rawmidi_release_priv snd_rawmidi_release
Allocated by: usb_alloc_urb <- bcd2000_init_midi <- bcd2000_probe
Freed by: usb_free_urb <- bcd2000_midi_free
<- bcd2000_disconnect
Take the lock in bcd2000_midi_output_close() and reference the URB with usb_get_urb() before releasing it. The URB then stays valid until usb_put_urb() after usb_kill_urb() has returned, even if a disconnect frees it in the meantime. usb_kill_urb() itself cannot run under midi_lock, as the completion handler takes the same lock.
--- sound/usb/bcd2000/bcd2000.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
sound/usb/bcd2000/bcd2000.c +16 -1
@@ -185,11 +185,26 @@ static int bcd2000_midi_output_open(struct snd_rawmidi_substream *substream)static int bcd2000_midi_output_close (struct snd_rawmidi_substream *substream) {struct bcd2000 *bcd2k = substream->rmidi->private_data; +struct urb *urb =NULL ; +unsigned long flags; +/* +* Reference the URB under the lock so that it stays valid until +* usb_kill_urb() returns, even if a disconnect frees it in the +* meantime. usb_kill_urb() cannot run under the lock, as the +* completion handler takes the same lock. +*/ +spin_lock_irqsave (&bcd2k->midi_lock, flags);if (bcd2k->midi_out_active && bcd2k->midi_out_urb) { -usb_kill_urb (bcd2k->midi_out_urb); + urb =usb_get_urb (bcd2k->midi_out_urb); bcd2k->midi_out_active =0 ; } +spin_unlock_irqrestore (&bcd2k->midi_lock, flags); + +if (urb) { +usb_kill_urb (urb); +usb_put_urb (urb); + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 807/1848 of/fdt: Ignore disabled memory nodes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
commit df5cd369876114f91f9ae60658fea80acfb15890 upstream.
When we boot a machine using a devicetree, the generic DT code goes through all nodes with a 'device_type = "memory"' property, and collects all memory banks mentioned there. However it does not check for the status property, so any nodes which are explicitly "disabled" will still be added as a memblock.
This ends up badly for QEMU, when booting with secure firmware on arm/arm64 machines, because QEMU adds a node describing secure-only memory:
===================
secram@e000000 {
secure-status = "okay";
status = "disabled";
reg = <0x00 0xe000000 0x00 0x1000000>;
device_type = "memory";
};===================
The kernel will eventually use that memory block (which is located below the main DRAM bank), but accesses to that will be answered with an SError:
===================
[ 0.000000] Internal error: synchronous external abort: 96000050 [#1] PREEMPT SMP [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.18.0-rc6-00014-g10c8acb8b679 #524 [ 0.000000] Hardware name: linux,dummy-virt (DT) [ 0.000000] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 0.000000] pc : new_slab+0x190/0x340 [ 0.000000] lr : new_slab+0x184/0x340 [ 0.000000] sp : ffff80000a4b3d10
....
==================
The actual crash location and call stack will be somewhat random, and depend on the specific allocation of that physical memory range.
As the DT spec[1] explicitly mentions standard properties, add a simple check to skip over disabled memory nodes, so that we only use memory that is meant for non-secure code to use.
That fixes booting a QEMU arm64 VM with EL3 enabled ("secure=on"), when not using UEFI. In this case the QEMU generated DT will be handed on to the kernel, which will see the secram node.
This issue is reproducible when using TF-A together with U-Boot as firmware, then booting with the "booti" command.
When using U-Boot as an UEFI provider, the code there [2] explicitly filters for disabled nodes when generating the UEFI memory map, so we are safe.
EDK/2 only reads the first bank of the first DT memory node [3] to learn about memory, so we got lucky there.
[1] https://github.com/devicetree-org/devicetree-specification/blob/main/source/chapter3-devicenodes.rst#memory-node (after the table)
[2] https://source.denx.de/u-boot/u-boot/-/blob/master/lib/fdtdec.c#L1061-1063
[3] https://github.com/tianocore/edk2/blob/master/ArmVirtPkg/PrePi/FdtParser.c
[ Georgiy: 5.10 lacks commit 1f012283e936 ("of/fdt: Rework
early_init_dt_scan_memory() to call directly"), so the function still handles one node per of_scan_flat_dt() call: return 0 instead of continue and use initial_boot_params instead of the local fdt. ]
--- drivers/of/fdt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/of/fdt.c +3 -0
@@ -1000,6 +1000,9 @@ int __init early_init_dt_scan_memory(unsigned long node, const char *uname,if (type ==NULL ||strcmp (type,"memory" ) !=0 )return 0 ; +if (!of_fdt_device_is_available (initial_boot_params, node)) +return 0 ; + reg =of_get_flat_dt_prop (node,"linux,usable-memory" , &l);if (reg ==NULL ) reg =of_get_flat_dt_prop (node,"reg" , &l);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 808/1848 wifi: mac80211: queue frames while off-channel
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislaw Gruszka <[email protected]>
[ Upstream commit 13e51269b6656768dc595ed6025e4974f2026543 ]
Drivers without FAST_XMIT and hardware scan support currently drop TX frames during software scanning while being off-channel. This happens in ieee80211_tx_h_check_assoc() before frames reach internal TX queue.
Move the off-channel check to invoke_tx_handlers_late(), after ieee80211_queue_skb(). Frames can then remain queued and be transmitted when the interface returns on-channel. This how TX works currently when code goes via ieee80211_xmit_fast() path.
Below is rt2x00 driver ping output example while scanning, before and after the fix. After the fix, packets are no longer lost. Some have increased latency, what is expected behavior.
BEFORE:
64 bytes from 192.168.0.1: icmp_seq=29 ttl=64 time=3.61 ms 64 bytes from 192.168.0.1: icmp_seq=31 ttl=64 time=3.33 ms # Missed 30 64 bytes from 192.168.0.1: icmp_seq=32 ttl=64 time=4.03 ms 64 bytes from 192.168.0.1: icmp_seq=34 ttl=64 time=3.10 ms # Missed 33 64 bytes from 192.168.0.1: icmp_seq=36 ttl=64 time=3.04 ms # Missed 35 64 bytes from 192.168.0.1: icmp_seq=38 ttl=64 time=3.05 ms # Missed 37 64 bytes from 192.168.0.1: icmp_seq=40 ttl=64 time=4.14 ms # Missed 39 64 bytes from 192.168.0.1: icmp_seq=41 ttl=64 time=4.50 ms
AFTER:
64 bytes from 192.168.0.1: icmp_seq=29 ttl=64 time=3.40 ms 64 bytes from 192.168.0.1: icmp_seq=30 ttl=64 time=6.10 ms 64 bytes from 192.168.0.1: icmp_seq=31 ttl=64 time=4.69 ms 64 bytes from 192.168.0.1: icmp_seq=32 ttl=64 time=4.49 ms 64 bytes from 192.168.0.1: icmp_seq=33 ttl=64 time=148 ms 64 bytes from 192.168.0.1: icmp_seq=34 ttl=64 time=6.83 ms 64 bytes from 192.168.0.1: icmp_seq=35 ttl=64 time=8.66 ms 64 bytes from 192.168.0.1: icmp_seq=36 ttl=64 time=13.0 ms 64 bytes from 192.168.0.1: icmp_seq=37 ttl=64 time=4.78 ms 64 bytes from 192.168.0.1: icmp_seq=38 ttl=64 time=3.85 ms
--- net/mac80211/tx.c | 50 ++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 22 deletions(-)
net/mac80211/tx.c +28 -22
@@ -291,7 +291,6 @@ ieee80211_tx_h_dynamic_ps(struct ieee80211_tx_data *tx) static ieee80211_tx_result debug_noinlineieee80211_tx_h_check_assoc (struct ieee80211_tx_data *tx) { -struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb);bool assoc = false;
@@ -299,23 +298,6 @@ ieee80211_tx_h_check_assoc(struct ieee80211_tx_data *tx)if (unlikely (info->flags &IEEE80211_TX_CTL_INJECTED ))return TX_CONTINUE ; -if (unlikely (test_bit (SCAN_SW_SCANNING , &tx->local->scanning)) && -test_bit (SDATA_STATE_OFFCHANNEL , &tx->sdata->state) && - !ieee80211_is_probe_req (hdr->frame_control) && - !ieee80211_is_any_nullfunc (hdr->frame_control)) -/* -* When software scanning only nullfunc frames (to notify -* the sleep state to the AP) and probe requests (for the -* active scan) are allowed, all other frames should not be -* sent and we should not get here, but if we do -* nonetheless, drop them to avoid sending them -* off-channel. See the link below and -* ieee80211_start_scan() for more. -* -* http://article.gmane.org/gmane.linux.kernel.wireless.general/30089 -*/ -return TX_DROP ; -if (tx->sdata->vif.type ==NL80211_IFTYPE_OCB )return TX_CONTINUE ;
@@ -801,6 +783,33 @@ ieee80211_tx_h_rate_ctrl(struct ieee80211_tx_data *tx)return TX_CONTINUE ; } +static ieee80211_tx_result debug_noinline +ieee80211_tx_h_check_offchannel (struct ieee80211_tx_data *tx) +{ +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb); + +if (unlikely (info->flags &IEEE80211_TX_CTL_INJECTED )) +return TX_CONTINUE ; + +if (unlikely (test_bit (SCAN_SW_SCANNING , &tx->local->scanning)) && +test_bit (SDATA_STATE_OFFCHANNEL , &tx->sdata->state) && + !ieee80211_is_probe_req (hdr->frame_control) && + !ieee80211_is_any_nullfunc (hdr->frame_control)) { +/* +* When software scanning only nullfunc frames (to notify +* the sleep state to the AP) and probe requests (for the +* active scan) are allowed, all other frames should not be +* sent and we should not get here, but if we do +* nonetheless, drop them to avoid sending them +* off-channel. See __ieee80211_start_scan() for more. +*/ +return TX_DROP ; + } + +return TX_CONTINUE ; +} +static __le16 ieee80211_tx_next_seq (struct sta_info *sta,int tid) {u16 *seq = &sta->tid_seq[tid];
@@ -1825,6 +1834,7 @@ static int invoke_tx_handlers_late(struct ieee80211_tx_data *tx) goto txh_done; } +CALL_TXH (ieee80211_tx_h_check_offchannel);CALL_TXH (ieee80211_tx_h_michael_mic_add);CALL_TXH (ieee80211_tx_h_sequence);CALL_TXH (ieee80211_tx_h_fragment);
@@ -4282,10 +4292,6 @@ static void ieee80211_8023_xmit(struct ieee80211_sub_if_data *sdata,skb_get_hash (skb); } -if (unlikely (test_bit (SCAN_SW_SCANNING , &local->scanning)) && -test_bit (SDATA_STATE_OFFCHANNEL , &sdata->state)) - goto out_free; -memset (info,0 ,sizeof (*info)); tid = skb->priority &IEEE80211_QOS_CTL_TAG1D_MASK ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 809/1848 crypto: hisilicon/hpre - fix GFP flags for dma_alloc_coherent
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weili Qian <[email protected]>
[ Upstream commit 40ec9605cb195e065470f8f23ef94b1b541411a3 ]
The HPRE driver hard-codes GFP_ATOMIC for RSA/DH and GFP_KERNEL for ECDH. This may cause "scheduling while atomic" in atomic context or unnecessary allocation failures under memory pressure.
Select GFP flags dynamically based on CRYPTO_TFM_REQ_MAY_SLEEP and store them in hpre_asym_request::flags. The areq field is a union of rsa/dh/ecdh request pointers; reading base.flags through any union member other than the one that was written would be type-punning, so a dedicated flags field avoids that.
--- drivers/crypto/hisilicon/hpre/hpre_crypto.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/crypto/hisilicon/hpre/hpre_crypto.c +5 -1
@@ -96,6 +96,7 @@ struct hpre_asym_request {int req_id;hpre_cb cb;struct timespec64 req_time; +u32 flags; };static int hpre_alloc_req_id (struct hpre_ctx *ctx)
@@ -201,6 +202,7 @@ static int hpre_prepare_dma_buf(struct hpre_asym_request *hpre_req, struct scatterlist *data, unsigned int len, int is_src, dma_addr_t *tmp) { + gfp_t gfp = hpre_req->flags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : GFP_ATOMIC;struct hpre_ctx *ctx = hpre_req->ctx;struct device *dev =HPRE_DEV (ctx);void *ptr;
@@ -210,7 +212,7 @@ static int hpre_prepare_dma_buf(struct hpre_asym_request *hpre_req,if (unlikely (shift <0 ))return -EINVAL ; - ptr =dma_alloc_coherent (dev, ctx->key_sz, tmp,GFP_ATOMIC ); + ptr =dma_alloc_coherent (dev, ctx->key_sz, tmp, gfp);if (unlikely (!ptr))return -ENOMEM ;
@@ -455,6 +457,7 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, void *req, bool is_rsa) h_req =PTR_ALIGN (tmp,HPRE_ALIGN_SZ ); h_req->cb = hpre_rsa_cb; h_req->areq.rsa = akreq; + h_req->flags = akreq->base.flags; msg = &h_req->req;memset (msg,0 ,sizeof (*msg)); }else {
@@ -469,6 +472,7 @@ static int hpre_msg_request_set(struct hpre_ctx *ctx, void *req, bool is_rsa) h_req =PTR_ALIGN (tmp,HPRE_ALIGN_SZ ); h_req->cb = hpre_dh_cb; h_req->areq.dh = kreq; + h_req->flags = kreq->base.flags; msg = &h_req->req;memset (msg,0 ,sizeof (*msg)); msg->key =cpu_to_le64 (ctx->dh.dma_xa_p);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 810/1848 media: microchip-isc: fix WB offset and gain register field masking
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 6e9eaa3b93870e4edac1bd2539fe113c24663eaf ]
ISC_WB_O_* and ISC_WB_G_* each pack two 13-bit fields. A negative offset sign-extends and corrupts the adjacent field. Add masks for the two fields and write them with FIELD_PREP(), which masks each value into its field, so sign extension can no longer bleed across.
--- drivers/media/platform/atmel/atmel-isc-base.c | 17 +++++++++-------- drivers/media/platform/atmel/atmel-isc-regs.h | 6 ++++++ 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/media/platform/atmel/atmel-isc-base.c +9 -8
@@ -9,6 +9,7 @@* */ +#include <linux/bitfield.h> #include <linux/clk.h> #include <linux/clkdev.h> #include <linux/clk-provider.h>
@@ -248,17 +249,17 @@ static inline void isc_update_awb_ctrls(struct isc_device *isc)/* In here we set our actual hw pipeline config */ regmap_write (isc->regmap,ISC_WB_O_RGR , - ((ctrls->offset[ISC_HIS_CFG_MODE_R ])) | - ((ctrls->offset[ISC_HIS_CFG_MODE_GR ]) <<16 )); +FIELD_PREP (ISC_WB_O_LO , ctrls->offset[ISC_HIS_CFG_MODE_R ]) | +FIELD_PREP (ISC_WB_O_HI , ctrls->offset[ISC_HIS_CFG_MODE_GR ]));regmap_write (isc->regmap,ISC_WB_O_BGB , - ((ctrls->offset[ISC_HIS_CFG_MODE_B ])) | - ((ctrls->offset[ISC_HIS_CFG_MODE_GB ]) <<16 )); +FIELD_PREP (ISC_WB_O_LO , ctrls->offset[ISC_HIS_CFG_MODE_B ]) | +FIELD_PREP (ISC_WB_O_HI , ctrls->offset[ISC_HIS_CFG_MODE_GB ]));regmap_write (isc->regmap,ISC_WB_G_RGR , - ctrls->gain[ISC_HIS_CFG_MODE_R ] | - (ctrls->gain[ISC_HIS_CFG_MODE_GR ] <<16 )); +FIELD_PREP (ISC_WB_G_LO , ctrls->gain[ISC_HIS_CFG_MODE_R ]) | +FIELD_PREP (ISC_WB_G_HI , ctrls->gain[ISC_HIS_CFG_MODE_GR ]));regmap_write (isc->regmap,ISC_WB_G_BGB , - ctrls->gain[ISC_HIS_CFG_MODE_B ] | - (ctrls->gain[ISC_HIS_CFG_MODE_GB ] <<16 )); +FIELD_PREP (ISC_WB_G_LO , ctrls->gain[ISC_HIS_CFG_MODE_B ]) | +FIELD_PREP (ISC_WB_G_HI , ctrls->gain[ISC_HIS_CFG_MODE_GB ])); }static inline void isc_reset_awb_ctrls (struct isc_device *isc)
drivers/media/platform/atmel/atmel-isc-regs.h +6 -0
@@ -108,6 +108,12 @@/* ISC White Balance Gain for B, GB Register */ #define ISC_WB_G_BGB 0x0000006c +/* Each WB offset/gain register packs two 13-bit fields, low and high */ +#define ISC_WB_O_LO GENMASK(12, 0)/* R or B offset [12:0] */ +#define ISC_WB_O_HI GENMASK(28, 16)/* GR or GB offset [28:16] */ +#define ISC_WB_G_LO GENMASK(12, 0)/* R or B gain [12:0] */ +#define ISC_WB_G_HI GENMASK(28, 16)/* GR or GB gain [28:16] */ +/* ISC Color Filter Array Control Register */ #define ISC_CFA_CTRL 0x00000070
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 811/1848 media: microchip-isc: synchronize the IRQ before disabling clocks on stop
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 19fa5407da5ef3e605cacfcd90f70d8b2c121cd7 ]
isc_stop_streaming() masks the DMA interrupt and then drops the runtime PM reference, which disables the ISC clocks. microchip_isc_interrupt() may still be executing on another CPU at that point; it reads ISC_INTSR over regmap, and touching the unclocked registers triggers an external abort.
Store the IRQ number at probe and call synchronize_irq() after masking the interrupt, before dropping the PM reference.
--- drivers/media/platform/atmel/atmel-isc-base.c | 3 +++ drivers/media/platform/atmel/atmel-isc.h | 1 + drivers/media/platform/atmel/atmel-sama5d2-isc.c | 2 ++ 3 files changed, 6 insertions(+)
drivers/media/platform/atmel/atmel-isc-base.c +3 -0
@@ -871,6 +871,9 @@ static void isc_stop_streaming(struct vb2_queue *vq)/* Disable DMA interrupt */ regmap_write (isc->regmap,ISC_INTDIS ,ISC_INT_DDONE ); +/* let a running IRQ handler finish before the clock is disabled */ +synchronize_irq (isc->irq); +pm_runtime_put_sync (isc->dev);/* Disable stream on the sub device */
drivers/media/platform/atmel/atmel-isc.h +1 -0
@@ -194,6 +194,7 @@ struct isc_device {struct isc_clk isc_clks[2 ];struct device *dev; +int irq;struct v4l2_device v4l2_dev;struct video_device video_dev;
drivers/media/platform/atmel/atmel-sama5d2-isc.c +2 -0
@@ -163,6 +163,8 @@ static int atmel_isc_probe(struct platform_device *pdev)if (irq <0 )return irq; + isc->irq = irq; + ret =devm_request_irq (dev, irq, isc_interrupt,0 ,ATMEL_ISC_NAME , isc);if (ret <0 ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 812/1848 media: microchip-isc: dont sleep in the clk .is_enabled callback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Balakrishnan Sambath <[email protected]>
[ Upstream commit 61490ff518c7b3ea3ff1cd16bbc012e9e4f1ab74 ]
isc_clk_is_enabled() calls pm_runtime_resume_and_get() and pm_runtime_put_sync(), which can sleep and are not safe here, as .is_enabled must run in atomic context. clk_disable_unused() calls it so at boot, and CONFIG_DEBUG_ATOMIC_SLEEP reports a "sleeping function called from invalid context" BUG.
Use the atomic-safe pm_runtime_get_if_active() and pm_runtime_put() instead. A suspended ISC has its clocks gated, so report the clock disabled when the device is not already active.
--- drivers/media/platform/atmel/atmel-isc-base.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/media/platform/atmel/atmel-isc-base.c +5 -3
@@ -355,13 +355,15 @@ static int isc_clk_is_enabled(struct clk_hw *hw)struct isc_clk *isc_clk =to_isc_clk (hw);u32 status; -if (isc_clk->id ==ISC_ISPCK ) -pm_runtime_get_sync (isc_clk->dev); +/* Runs in atomic context, so must not sleep to resume the ISC. */ +if (isc_clk->id ==ISC_ISPCK && +pm_runtime_get_if_active (isc_clk->dev, true) <=0 ) +return 0 ;regmap_read (isc_clk->regmap,ISC_CLKSR , &status);if (isc_clk->id ==ISC_ISPCK ) -pm_runtime_put_sync (isc_clk->dev); +pm_runtime_put (isc_clk->dev);return status &ISC_CLK (isc_clk->id) ?1 :0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 813/1848 KVM: nSVM: Ignore EFER.LMA if EFER.LME=0 when preparing L2 state
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 1c4c84a643b704e473cb171f7b61359ff29b12a4 ]
Force EFER.LMA=0 if EFER.LME=0 when preparing L2 state for VMRUN, i.e. mimic real hardware's behavior of ignoring EFER.LMA if EFER.LME=0. VMRUN unfortunately allows the nonsensical combination, i.e. doesn't fail, but KVM itself has an invariant EFER.LMA can be set et if and only if EFER.LME
is set. Breaking that invariant can lead to a variety of issue,
particularly in MMU code that keys off EFER.LMA when determining whether to emulate/virtualization 4/5-level paging versus PAE paging.
--- arch/x86/kvm/svm/nested.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
arch/x86/kvm/svm/nested.c +7 -1
@@ -403,6 +403,8 @@ static int nested_svm_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3,static void nested_prepare_vmcb_save (struct vcpu_svm *svm,struct vmcb *vmcb12) { +u64 efer =READ_ONCE (vmcb12->save.efer); +/* Load the nested guest state */ svm->vmcb->save.es = vmcb12->save.es; svm->vmcb->save.cs = vmcb12->save.cs;
@@ -412,12 +414,16 @@ static void nested_prepare_vmcb_save(struct vcpu_svm *svm, struct vmcb *vmcb12) svm->vmcb->save.idtr = vmcb12->save.idtr;kvm_set_rflags (&svm->vcpu, vmcb12->save.rflags); +/* SVM ignores EFER.LMA if EFER.LME=0 (instead of failing VMRUN). */ +if (!(efer &EFER_LME )) + efer &= ~EFER_LMA ; +/* * Force-set EFER_SVME even though it is checked earlier on the * VMCB12, because the guest can flip the bit between the check * and now. Clearing EFER_SVME would call svm_free_nested. */ -svm_set_efer (&svm->vcpu, vmcb12->save.efer |EFER_SVME ); +svm_set_efer (&svm->vcpu, efer |EFER_SVME );svm_set_cr0 (&svm->vcpu, vmcb12->save.cr0);svm_set_cr4 (&svm->vcpu, vmcb12->save.cr4);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 814/1848 KVM: x86/mmu: Bug the VM if a vCPU ends up in long mode without PAE enabled
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 72e2fb24a0b0528bcc16a8f6ad2cf336ac361525 ]
Promote the ASSERT(), which is quite dead code in KVM, into a KVM_BUG_ON() for KVM's sanity check that CR4.PAE=1 if the vCPU is in long mode when performing a walk of guest page tables. The sanity is quite cheap since neither EFER nor CR4.PAE requires a VMREAD, especially relative to the cost of walking the guest page tables.
More importantly, the sanity check would have prevented the true badness fixed by commit 112e66017bff ("KVM: nVMX: add missing consistency checks for CR0 and CR4"). The missed consistency check resulted in some versions of KVM corrupting the on-stack guest_walker structure due to KVM thinking there are 4/5 levels of page tables, but wiring up the MMU hooks to point at the paging32 implementation, which only allocates space for two levels of page tables in "struct guest_walker32".
Queue a page fault for injection if the assertion fails, as both callers, FNAME(gva_to_gpa) and FNAME(walk_addr_generic), assume that walker.fault contains sane info on a walk failure. E.g. not populating the fault info could result in KVM consuming and/or exposing uninitialized stack data before the vCPU is kicked out to userspace, which doesn't happen until KVM checks for KVM_REQ_VM_DEAD on the next enter.
Move the check below the initialization of "pte_access" so that the aforementioned to-be-injected page fault doesn't consume uninitialized stack data. The information _shouldn't_ reach the guest or userspace, but there's zero downside to being paranoid in this case.
Stable-dep-of: 115f9405a2ed ("KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has")
--- arch/x86/kvm/mmu/paging_tmpl.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
arch/x86/kvm/mmu/paging_tmpl.h +11 -1
@@ -351,7 +351,6 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, }#endif walker->max_level = walker->level; -ASSERT (!(is_long_mode (vcpu) && !is_pae (vcpu)));/* * FIXME: on Intel processors, loads of the PDPTE registers for PAE paging
@@ -361,6 +360,17 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, nested_access = (have_ad ?PFERR_WRITE_MASK :0 ) |PFERR_USER_MASK ; pte_access = ~0 ; + +/* +* Queue a page fault for injection if this assertion fails, as callers +* assume that walker.fault contains sane info on a walk failure. I.e. +* avoid making the situation worse by inducing even worse badness +* between when the assertion fails and when KVM kicks the vCPU out to +* userspace (because the VM is bugged). +*/ +if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm)) + goto error; + ++walker->level; do {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 815/1848 KVM: x86/mmu: Bug the VM if KVM attempts to walk more levels than the MMU has
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Christopherson <[email protected]>
[ Upstream commit 115f9405a2ed6d78ee7ad8436bdd638743f6d1d4 ]
Extend the "EFER.LMA && !CR4.PAE" check, which exists largely to guard against KVM configuring a paging32 MMU with more than 2 levels of paging, with a very explicit check for exactly that: that KVM isn't trying to walk more levels of paging than the MMU template provides. I.e. harden KVM against all bugs that would cause KVM to generates accesses beyond the bounds of guest_walker's arrays, regardless of how KVM ended up with the misconfigured MMU.
Note, don't use w->cpu_role.base.level directly as the paging64 template only provides two levels of page tables for PAE paging on 32-bit hosts, and handles the third level by manually emulating the PDPTR access.
--- arch/x86/kvm/mmu/paging_tmpl.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
arch/x86/kvm/mmu/paging_tmpl.h +7 -6
@@ -362,13 +362,14 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker, pte_access = ~0 ;/* -* Queue a page fault for injection if this assertion fails, as callers -* assume that walker.fault contains sane info on a walk failure. I.e. -* avoid making the situation worse by inducing even worse badness -* between when the assertion fails and when KVM kicks the vCPU out to -* userspace (because the VM is bugged). +* Queue a page fault for injection if any of the below assertions fail, +* as callers assume that walker.fault contains sane info on a walk +* failure. I.e. avoid making the situation worse by inducing even +* worse badness between when the assertion fails and when KVM kicks +* the vCPU out to userspace (because the VM is bugged). */ -if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm)) +if (KVM_BUG_ON (is_long_mode (vcpu) && !is_pae (vcpu), vcpu->kvm) || +KVM_BUG_ON (walker->max_level >PT_MAX_FULL_LEVELS , vcpu->kvm)) goto error; ++walker->level;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 816/1848 iio: light: isl29028: fix runtime PM reference leak on error paths
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabio Cesari <[email protected]>
[ Upstream commit 0e30d15b15647df786e60022650613e16dd70645 ]
isl29028_read_raw() and isl29028_write_raw() take a runtime PM reference with pm_runtime_resume_and_get() but return directly on their error paths without dropping it. The usage count never balances again and the device stops entering autosuspend for good. In isl29028_read_raw() this needs a regmap access to fail; in isl29028_write_raw() one rejected sysfs write is enough, for example
echo 200 > in_proximity_sampling_frequency
which is outside the [1:100] range and returns -EINVAL with the reference still held.
Take the reference with PM_RUNTIME_ACQUIRE_AUTOSUSPEND() instead, so it is released on every return path.
This also stops the return value of pm_runtime_put_autosuspend() from reaching userspace. That value only says whether the device could be suspended right away, so -EAGAIN or -EPERM turns a successful access into a failure, and with CONFIG_PM=n the stub returns -ENOSYS on every access.
--- drivers/iio/light/isl29028.c | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-)
drivers/iio/light/isl29028.c +4 -19
@@ -409,14 +409,9 @@ static int isl29028_write_raw(struct iio_dev *indio_dev,mutex_unlock (&chip->lock); -if (ret <0 ) -return ret; +isl29028_set_pm_runtime_busy (chip, false); - ret =isl29028_set_pm_runtime_busy (chip, false); -if (ret <0 ) -return ret; - -return 0 ; +return ret; } static int isl29028_read_raw(struct iio_dev *indio_dev,
@@ -425,7 +420,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev, {struct isl29028_chip *chip =iio_priv (indio_dev);struct device *dev =regmap_get_device (chip->regmap); -int ret, pm_ret; +int ret; ret =isl29028_set_pm_runtime_busy (chip, true);if (ret <0 )
@@ -478,17 +473,7 @@ static int isl29028_read_raw(struct iio_dev *indio_dev,mutex_unlock (&chip->lock); -if (ret <0 ) -return ret; - -/** -* Preserve the ret variable if the call to -* isl29028_set_pm_runtime_busy() is successful so the reading -* (if applicable) is returned to user space. -*/ - pm_ret =isl29028_set_pm_runtime_busy (chip, false); -if (pm_ret <0 ) -return pm_ret; +isl29028_set_pm_runtime_busy (chip, false);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 817/1848 KVM: arm64: vgic-v3: Undo assignment on iodev registration failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 8a88a46b86ca3dbbd24522760d29edfb3f24ac2a ]
vgic_register_redist_iodev() assigns a redistributor region and base address to the vCPU before adding its iodev to the MMIO bus. However, the region's free_index is advanced only after registration succeeds.
If kvm_io_bus_register_dev() fails, the vCPU retains the assignment while free_index still identifies the same slot as free. A later registration can therefore reuse a slot that remains assigned to the vCPU.
Reserve the slot before registering its iodev. The caller holds slots_lock, so a registration failure cannot race with a later assignment. Undo the reservation and clear the cached assignment on failure.
--- arch/arm64/kvm/vgic/vgic-mmio-v3.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
arch/arm64/kvm/vgic/vgic-mmio-v3.c +9 -4
@@ -731,16 +731,21 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu) rd_dev->nr_regions =ARRAY_SIZE (vgic_v3_rd_registers); rd_dev->redist_vcpu = vcpu; +/* Protected by kvm->lock */ + rdreg->free_index++; +mutex_lock (&kvm->slots_lock); ret =kvm_io_bus_register_dev (kvm,KVM_MMIO_BUS , rd_base,2 *SZ_64K , &rd_dev->dev);mutex_unlock (&kvm->slots_lock); -if (ret) -return ret; +if (ret) { + vgic_cpu->rdreg->free_index--; + vgic_cpu->rdreg =NULL ; + vgic_cpu->rd_iodev.base_addr =VGIC_ADDR_UNDEF ; + } - rdreg->free_index++; -return 0 ; +return ret; }static void vgic_unregister_redist_iodev (struct kvm_vcpu *vcpu)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 818/1848 media: mtk-vpu: Remove redundant flush_workqueue() calls
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christophe JAILLET <[email protected]>
[ Upstream commit 360c887a39cb56e75be4f558b16f1b6409ecb93f ]
'destroy_workqueue()' already drains the queue before destroying it, so there is no need to flush it explicitly.
Remove the redundant 'flush_workqueue()' calls.
This was generated with coccinelle:
@@
expression E;
@@
- flush_workqueue(E); destroy_workqueue(E);
Stable-dep-of: 2c50b58d4105 ("media: mediatek: vpu: free IRQ before destroying watchdog workqueue")
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/mtk-vpu/mtk_vpu.c +1 -3
@@ -938,10 +938,8 @@ static int mtk_vpu_remove(struct platform_device *pdev)#ifdef CONFIG_DEBUG_FS debugfs_remove (vpu_debugfs);#endif -if (vpu->wdt.wq) { -flush_workqueue (vpu->wdt.wq); +if (vpu->wdt.wq)destroy_workqueue (vpu->wdt.wq); - }vpu_free_ext_mem (vpu,P_FW );vpu_free_ext_mem (vpu,D_FW );of_reserved_mem_device_release (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 819/1848 media: mediatek: vpu: free IRQ before destroying watchdog workqueue
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit 2c50b58d4105f6dbaa36d6306087954b9100e9ae ]
mtk_vpu_remove() destroys the watchdog workqueue while the interrupt handler requested with devm_request_irq() is still registered: the devres core frees the interrupt only after remove() has returned. If the VPU watchdog fires in that window, vpu_irq_handler() queues vpu->wdt.ws on the already destroyed vpu->wdt.wq.
Fix this by calling devm_free_irq() before destroy_workqueue(), which releases the interrupt and waits for a running handler, so no new work can be queued while the workqueue is drained and freed.
This issue was found by an in-house static analysis tool.
--- drivers/media/platform/mtk-vpu/mtk_vpu.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/platform/mtk-vpu/mtk_vpu.c +1 -0
@@ -938,6 +938,7 @@ static int mtk_vpu_remove(struct platform_device *pdev)#ifdef CONFIG_DEBUG_FS debugfs_remove (vpu_debugfs);#endif +devm_free_irq (&pdev->dev, vpu->reg.irq, vpu);if (vpu->wdt.wq)destroy_workqueue (vpu->wdt.wq);vpu_free_ext_mem (vpu,P_FW );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 820/1848 mtd: mtdsuper: Fix MTD device reference leak in mtd_get_sb()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 62ee3da38f41bef83c1cf250f6816a0ee187674b ]
mtd_get_sb() is called with a reference to the MTD device already taken by the caller. When sget_dev() fails, the function returns the error without dropping that reference, so the device is never released and its refcount never reaches zero. Every mount attempt on an MTD device whose superblock cannot be set up leaks a reference.
Restore the put_mtd_device() that the fs_context conversion dropped on this path.
--- drivers/mtd/mtdsuper.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mtd/mtdsuper.c +3 -1
@@ -63,8 +63,10 @@ static int mtd_get_sb(struct fs_context *fc, fc->sget_key = mtd; sb =sget_fc (fc, mtd_test_super, mtd_set_super); -if (IS_ERR (sb)) +if (IS_ERR (sb)) { +put_mtd_device (mtd);return PTR_ERR (sb); + }if (sb->s_root) {/* new mountpoint for an already mounted superblock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 821/1848 ALSA: usb-audio: Protect Roland control activation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 19b42c1fff7f220a6346c614d79ce1bda6d95b40 ]
The USB MIDI driver changes the Roland MIDI Input Mode control's access flags directly from the rawmidi open and close paths. These changes are not protected by the ALSA control core and the corresponding notifications can race with control access.
Use snd_ctl_activate_id() so that the control core updates the access flags and sends the notification under its lock. Release the USB MIDI mutex before calling it because the control write path holds controls_rwsem while roland_load_put() takes the USB MIDI mutex.
Keep the state transition and alternate-setting change under the USB MIDI mutex; rawmidi's open mutex serializes the enclosing open and close paths.
--- sound/usb/midi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
sound/usb/midi.c +11 -11
@@ -1168,7 +1168,9 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir, int open) {struct snd_usb_midi *umidi = substream->rmidi->private_data; -struct snd_kcontrol *ctl; +struct snd_ctl_elem_id ctl_id; +bool activate_ctl = false; +bool active;down_read (&umidi->disc_rwsem);if (umidi->disconnected) {
@@ -1180,11 +1182,9 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,if (open) {if (!umidi->opened[0 ] && !umidi->opened[1 ]) {if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0 ].access |= -SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (umidi->card, -SNDRV_CTL_EVENT_MASK_INFO , &ctl->id); + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = false;update_roland_altsetting (umidi); } }
@@ -1197,15 +1197,15 @@ static int substream_open(struct snd_rawmidi_substream *substream, int dir,snd_usbmidi_input_stop (&umidi->list);if (!umidi->opened[0 ] && !umidi->opened[1 ]) {if (umidi->roland_load_ctl) { - ctl = umidi->roland_load_ctl; - ctl->vd[0 ].access &= - ~SNDRV_CTL_ELEM_ACCESS_INACTIVE ; -snd_ctl_notify (umidi->card, -SNDRV_CTL_EVENT_MASK_INFO , &ctl->id); + ctl_id = umidi->roland_load_ctl->id; + activate_ctl = true; + active = true; } } }mutex_unlock (&umidi->mutex); +if (activate_ctl) +snd_ctl_activate_id (umidi->card, &ctl_id, active);up_read (&umidi->disc_rwsem);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 822/1848 hwmon: (tmp102) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 56c1d32323e773b8b927316f8beeae9238576335 ]
tmp102 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the first ~35 ms conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp102.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp102.c +4 -4
@@ -54,7 +54,7 @@struct tmp102 {struct regmap *regmap;u16 config_orig; -unsigned long ready_time; +u64 ready_time; };/* convert left adjusted 13-bit TMP102 register value to milliCelsius */
@@ -79,7 +79,7 @@ static int tmp102_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp102->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp102->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ; }
@@ -245,7 +245,7 @@ static int tmp102_probe(struct i2c_client *client)* Mark that we are not ready with data until the first * conversion is complete */ - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS ); hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, tmp102,
@@ -279,7 +279,7 @@ static int tmp102_resume(struct device *dev) err =regmap_update_bits (tmp102->regmap,TMP102_CONF_REG ,TMP102_CONF_SD ,0 ); - tmp102->ready_time = jiffies +msecs_to_jiffies (CONVERSION_TIME_MS ); + tmp102->ready_time =get_jiffies_64 () +msecs_to_jiffies (CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 823/1848 gfs2: reject invalid inode sizes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit 33ed0a0567e0abe66ea65e89dad2e35082890fbe ]
A corrupted GFS2 image can store a dinode size that is larger than what VFS i_size can represent. gfs2_dinode_in() reads the on-disk di_size as a u64 and writes it directly into inode->i_size. If the value is larger than S64_MAX, the incore i_size becomes negative. That negative value can bypass the existing stuffed inode size check:
inode->i_size > gfs2_max_stuffed_size(ip)
Later, gfs2_quotad may try to sync the quota file and unstuff the quota inode. gfs2_unstuffer_folio() reads the negative i_size into an unsigned length and passes it to memcpy(), turning it into a huge copy size and triggering a out-of-bound issue.
Reject dinodes whose size exceeds sb->s_maxbytes before storing the value in inode->i_size. Also make the stuffed inode check use the raw on-disk size while it is still unsigned.
--- fs/gfs2/glops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/gfs2/glops.c +6 -2
@@ -410,6 +410,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)const struct gfs2_dinode *str = buf;struct timespec64 atime;u16 height, depth; +u64 size;if (unlikely (ip->i_no_addr !=be64_to_cpu (str->di_num.no_addr))) goto corrupt;
@@ -427,7 +428,10 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)i_uid_write (&ip->i_inode,be32_to_cpu (str->di_uid));i_gid_write (&ip->i_inode,be32_to_cpu (str->di_gid));set_nlink (&ip->i_inode,be32_to_cpu (str->di_nlink)); -i_size_write (&ip->i_inode,be64_to_cpu (str->di_size)); + size =be64_to_cpu (str->di_size); +if (unlikely (size > ip->i_inode.i_sb->s_maxbytes)) + goto corrupt; +i_size_write (&ip->i_inode, size);gfs2_set_inode_blocks (&ip->i_inode,be64_to_cpu (str->di_blocks)); atime.tv_sec =be64_to_cpu (str->di_atime); atime.tv_nsec =be32_to_cpu (str->di_atime_nsec);
@@ -459,7 +463,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf) ip->i_depth = (u8 )depth; ip->i_entries =be32_to_cpu (str->di_entries); -if (gfs2_is_stuffed (ip) && ip->i_inode.i_size >gfs2_max_stuffed_size (ip)) +if (gfs2_is_stuffed (ip) && size >gfs2_max_stuffed_size (ip)) goto corrupt;if (S_ISREG (ip->i_inode.i_mode))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 824/1848 iio: light: ltr501: Power down chip if request irq fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Esben Haabendal <[email protected]>
[ Upstream commit 8a9bcd587d7d768e6c8e9fff88bb89645e412731 ]
In case devm_request_threaded_irq() failed, we were leaving the chip powered instead of powering it down again. Power down the chip switching ALS and PS modes to standby.
--- drivers/iio/light/ltr501.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/light/ltr501.c +1 -1
@@ -1510,7 +1510,7 @@ static int ltr501_probe(struct i2c_client *client,if (ret) {dev_err (&client->dev,"request irq (%d) failed\n" , client->irq); -return ret; + goto powerdown_on_error; } }else { indio_dev->info = data->chip_info->info_no_irq;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 825/1848 media: redrat3: Error path leaves device in transmitting state
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Young <[email protected]>
[ Upstream commit 8024d5e84531d828535365718278f1cf0ce67db0 ]
In the allocation failure error path, the transmitting boolean is not cleared. If this error path is followed the transmitter cannot be used again until the device is replugged or the module reloaded.
Fix the error path by moving the assignment statement.
Remove the check for the transmitting state in transmit, since rc-core ensures there is never a reentrant call to the driver transmit function; the transmit function is always called with dev->lock held.
The transmitting boolean is only used for interpretting firmware errors.
--- drivers/media/rc/redrat3.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/media/rc/redrat3.c +3 -8
@@ -773,17 +773,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf,u8 curlencheck =0 ;unsigned i, sendbuf_len; -if (rr3->transmitting) { -dev_warn (dev,"%s: transmitter already in use\n" , __func__); -return -EAGAIN ; - } -if (count >RR3_MAX_SIG_SIZE -RR3_TX_TRAILER_LEN )return -EINVAL ; -/* rr3 will disable rc detector on transmit */ - rr3->transmitting = true; - sample_lens =kcalloc (RR3_DRIVER_MAXLENS ,sizeof (*sample_lens),GFP_KERNEL );
@@ -796,6 +788,9 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, goto out; } +/* rr3 will disable rc detector on transmit */ + rr3->transmitting = true; +for (i =0 ; i < count; i++) { cur_sample_len =redrat3_us_to_len (txbuf[i]);if (cur_sample_len >0xffff ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 826/1848 mtd: rawnand: ndfc: fix gcc uninitialized var
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit cceca8cb776b03e83985578f84bd730c30d57f70 ]
Now that this can be built with COMPILE_TEST, an unassigned variable was found. Set to 0 to fix the W=1 error under GCC.
Stable-dep-of: 0d66f9895f28 ("mtd: rawnand: ndfc: use devm_platform_ioremap_resource()")
--- drivers/mtd/nand/raw/ndfc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/raw/ndfc.c +1 -1
@@ -188,7 +188,7 @@ static int ndfc_probe(struct platform_device *ofdev)const __be32 *reg;u32 ccr;u32 cs; -int err, len; +int err, len =0 ;/* Read the reg property to get the chip select */ reg =of_get_property (ofdev->dev.of_node,"reg" , &len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 827/1848 mtd: rawnand: ndfc: use devm_platform_ioremap_resource()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rosen Penev <[email protected]>
[ Upstream commit 0d66f9895f286d2fab396a71e6efeb95c4a7e5a6 ]
Replace the open-coded of_iomap()/iounmap() with the managed devm_platform_ioremap_resource() helper. This fixes a mapping leak on driver remove (the old code never called iounmap()) and simplifies the error path by dropping the manual cleanup in ndfc_probe().
There is no overlapping memory-region concern introduced by this
change: each supported board DT describes a single ndfc node with a unique 0x2000 register region, and the EBC parent uses dcr-reg rather than a MEM reg resource, so the newly added request_mem_region() cannot conflict with an existing reservation. Distinct chip selects map to distinct 64-bit physical addresses, so CS instances do not overlap.
--- drivers/mtd/nand/raw/ndfc.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/ndfc.c +8 -13
@@ -185,10 +185,15 @@ static int ndfc_chip_init(struct ndfc_controller *ndfc,static int ndfc_probe (struct platform_device *ofdev) {struct ndfc_controller *ndfc; +void __iomem *ndfcbase;const __be32 *reg;u32 ccr;u32 cs; -int err, len =0 ; +int len =0 ; + + ndfcbase =devm_platform_ioremap_resource (ofdev,0 ); +if (IS_ERR (ndfcbase)) +return PTR_ERR (ndfcbase);/* Read the reg property to get the chip select */ reg =of_get_property (ofdev->dev.of_node,"reg" , &len);
@@ -210,11 +215,7 @@ static int ndfc_probe(struct platform_device *ofdev) ndfc->ofdev = ofdev;dev_set_drvdata (&ofdev->dev, ndfc); - ndfc->ndfcbase =of_iomap (ofdev->dev.of_node,0 ); -if (!ndfc->ndfcbase) { -dev_err (&ofdev->dev,"failed to get memory\n" ); -return -EIO ; - } + ndfc->ndfcbase = ndfcbase; ccr =NDFC_CCR_BS (ndfc->chip_select);
@@ -232,13 +233,7 @@ static int ndfc_probe(struct platform_device *ofdev)out_be32 (ndfc->ndfcbase + offset,be32_to_cpup (reg)); } - err =ndfc_chip_init (ndfc, ofdev->dev.of_node); -if (err) { -iounmap (ndfc->ndfcbase); -return err; - } - -return 0 ; +return ndfc_chip_init (ndfc, ofdev->dev.of_node); }static int ndfc_remove (struct platform_device *ofdev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 828/1848 staging: media: av7110: fix sp8870 initialization failure state
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Punnay Sharma <[email protected]>
[ Upstream commit 30684fa98394bc0eb4362282908612aab7d4dad9 ]
The SP8870 DVB frontend driver prematurely flags the device as initialized at the very beginning of the sp8870_init() routine, prior to requesting the firmware (dvb-fe-sp8870.fw) and executing the I2C upload sequence.
If request_firmware() times out or sp8870_firmware_upload() encounters an I2C bus error, the function aborts and returns -EIO. However, because state->initialised is already set to 1, all subsequent invocations of fe->ops.init() by the DVB core will immediately return 0 (success) without attempting to load the firmware again. This leaves the demodulator microcontroller halted and the frontend permanently dead until the module is forcibly reloaded.
Relocate the state->initialised = 1 assignment to the end of sp8870_init(), ensuring the flag is only set after the firmware is successfully uploaded and the system controller is actually restarted.
--- drivers/media/dvb-frontends/sp8870.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/dvb-frontends/sp8870.c +2 -1
@@ -297,7 +297,6 @@ static int sp8870_init (struct dvb_frontend* fe)sp8870_wake_up (state);if (state->initialised)return 0 ; - state->initialised =1 ;dprintk ("%s\n" , __func__);
@@ -336,6 +335,8 @@ static int sp8870_init (struct dvb_frontend* fe)sp8870_writereg (state,0x0D00 ,0x010 );sp8870_writereg (state,0x0D01 ,0x000 ); + state->initialised =1 ; +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 829/1848 Bluetooth: L2CAP: Reject signalling responses in invalid states
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
commit 6320736af7dcb90da6ee9fd651ecc11c564d45b7 upstream.
Adjusted context as stable does not have the lockdep_assert_held() calls, and l2cap_get_chan_by_scid() still returns the channel locked, so l2cap_config_rsp() does not lock it again.
A peer can send configuration messages while an incoming channel is in BT_CONNECT2, before the security or deferred accept gate has completed. A configuration response can then promote the channel to BT_CONNECTED. Configuration responses can also act on channels that are closing, and a late connection response can move a disconnecting channel back to BT_CONFIG.
Accept connection responses only while waiting inBT_CONNECT. Answer configuration requests inBT_CONNECT2, but defer our own request untilBT_CONFIG so configuration cannot complete before
the gate. Ignore configuration responses outsideBT_CONFIG and BT_CONNECTED, and only complete
configuration in BT_CONFIG.
--- net/bluetooth/l2cap_core.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
net/bluetooth/l2cap_core.c +19 -1
@@ -4478,6 +4478,10 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); +/* Ignore a late response after the channel has left BT_CONNECT. */ +if (chan->state !=BT_CONNECT ) + goto done; +switch (result) {case L2CAP_CR_SUCCESS :if (__l2cap_get_chan_by_dcid (conn, dcid)) {
@@ -4507,6 +4511,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,break ; } +done:l2cap_chan_unlock (chan);l2cap_chan_put (chan);
@@ -4642,7 +4647,13 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, goto unlock; } -if (!test_and_set_bit (CONF_REQ_SENT , &chan->conf_state)) { +/* A channel in BT_CONNECT2 has not passed security or userspace +* accept yet. Answer the peer's request, but hold our own until +* the channel reaches BT_CONFIG: the CONNECT2 -> CONFIG sites send +* it. Connected channels may also need to reconfigure. +*/ +if ((chan->state ==BT_CONFIG || chan->state ==BT_CONNECTED ) && + !test_and_set_bit (CONF_REQ_SENT , &chan->conf_state)) {u8 buf[64 ];l2cap_send_cmd (conn,l2cap_get_ident (conn),L2CAP_CONF_REQ ,l2cap_build_conf_req (chan, buf,sizeof (buf)), buf);
@@ -4693,6 +4704,10 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,if (!chan)return 0 ; +/* Connected channels may also receive reconfiguration responses. */ +if (chan->state !=BT_CONFIG && chan->state !=BT_CONNECTED ) + goto done; +switch (result) {case L2CAP_CONF_SUCCESS :l2cap_conf_rfc_get (chan, rsp->data, len);
@@ -4767,6 +4782,9 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn,if (test_bit (CONF_OUTPUT_DONE , &chan->conf_state)) {set_default_fcs (chan); +if (chan->state !=BT_CONFIG ) + goto done; +if (chan->mode ==L2CAP_MODE_ERTM || chan->mode ==L2CAP_MODE_STREAMING ) err =l2cap_ertm_init (chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 830/1848 Bluetooth: L2CAP: Only accept connection responses to outstanding requests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Siwei Zhang <[email protected]>
commit a518b9a9ef6ee3b18ecdf6ba5360c608aaf969e9 upstream.
Adjusted context as stable does not have the lockdep_assert_held() call and the __must_hold() context analysis annotations, and l2cap_connect_create_rsp() still holds conn->chan_lock and returns through the unlock label when the channel lookup fails.
Stable still has AMP support, which upstream removed in commit e7b02296fb40 ("Bluetooth: Remove BT_HS"). The response to an L2CAP_CREATE_CHAN_REQ is also handled by l2cap_connect_create_rsp(), so set CONF_CONNECT_PEND in l2cap_send_create_chan_req() as l2cap_send_conn_req() does. Otherwise that response is dropped and an outgoing AMP channel hangs in BT_CONNECT. This also makes __l2cap_no_conn_pending() see the request as outstanding, so l2cap_do_start(), l2cap_conn_start() and l2cap_security_cfm() leave the channel alone until it is answered, as they already do for a pending connection request.
An outgoing channel waits in BT_CONNECT until security and the feature mask exchange complete, and only then sends its connection request. A peer can answer it before that with a connection response matching our source CID. The channel then moves to BT_CONFIG, completes configuration and becomes connected before security has completed. If security then fails, l2cap_security_cfm() leaves the connected channel alone, so it stays up on a link that did not reach the required security level.
A connection response with a zero source CID is matched by identifier. Another channel can hold the same identifier for a response it still has to send, so the lookup can pick the wrong channel.
Only accept a connection response while our request is outstanding, and only look at such channels when matching by identifier.
--- net/bluetooth/l2cap_core.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
net/bluetooth/l2cap_core.c +30 -3
@@ -185,6 +185,28 @@ static struct l2cap_chan *l2cap_get_chan_by_ident(struct l2cap_conn *conn,return c; } +/* Our connection request has been sent and is still outstanding */ +static bool l2cap_chan_connect_pending (struct l2cap_chan *chan) +{ +return chan->state ==BT_CONNECT && +test_bit (CONF_CONNECT_PEND , &chan->conf_state); +} + +/* Other channels may hold the same ident for a response they still have +* to send, so only look at channels waiting for a connection response. +*/ +static struct l2cap_chan *__l2cap_get_connect_chan_by_ident (struct l2cap_conn *conn, +u8 ident) +{ +struct l2cap_chan *c; + +list_for_each_entry (c, &conn->chan_l, list) { +if (c->ident == ident &&l2cap_chan_connect_pending (c)) +return c; + } +return NULL ; +} +static struct l2cap_chan *__l2cap_global_chan_by_addr (__le16 psm,bdaddr_t *src,u8 src_type) {
@@ -1355,6 +1377,8 @@ static void l2cap_send_create_chan_req(struct l2cap_chan *chan, u8 amp_id) chan->ident =l2cap_get_ident (chan->conn); +set_bit (CONF_CONNECT_PEND , &chan->conf_state); +l2cap_send_cmd (chan->conn, chan->ident,L2CAP_CREATE_CHAN_REQ ,sizeof (req), &req); }
@@ -4461,7 +4485,7 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn, goto unlock; } }else { - chan =__l2cap_get_chan_by_ident (conn, cmd->ident); + chan =__l2cap_get_connect_chan_by_ident (conn, cmd->ident);if (!chan) { err = -EBADSLT ; goto unlock;
@@ -4478,8 +4502,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); -/* Ignore a late response after the channel has left BT_CONNECT. */ -if (chan->state !=BT_CONNECT ) +/* Only accept a response to a connection request we sent and that +* is still outstanding. A channel waiting in BT_CONNECT for security +* or the feature mask has not sent one yet. +*/ +if (!l2cap_chan_connect_pending (chan)) goto done;switch (result) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 831/1848 Bluetooth: L2CAP: Ignore connection responses with wrong ident
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jinwang Li <[email protected]>
commit a9f9eeb5344fc7dc625e5700ccf09891bc2603b5 upstream.
Adjusted context as stable does not have the lockdep_assert_held() call in l2cap_connect_create_rsp().
L2CAP/COS/CED/BI-28-C requires the IUT to ignore a Connection Response that carries an invalid Identifier.
l2cap_connect_create_rsp() only checks that a connection request is outstanding, not that the response answers it. Add an ident check against the pending request so that a mismatched response is dropped.
--- net/bluetooth/l2cap_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/bluetooth/l2cap_core.c +4 -4
@@ -4502,11 +4502,11 @@ static int l2cap_connect_create_rsp(struct l2cap_conn *conn,l2cap_chan_lock (chan); -/* Only accept a response to a connection request we sent and that -* is still outstanding. A channel waiting in BT_CONNECT for security -* or the feature mask has not sent one yet. +/* Only accept a response matching a connection request we sent and +* that is still outstanding. A channel waiting in BT_CONNECT for +* security or the feature mask has not sent one yet. */ -if (!l2cap_chan_connect_pending (chan)) +if (!l2cap_chan_connect_pending (chan) || chan->ident != cmd->ident) goto done;switch (result) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 832/1848 xen/gntdev: prevent private mappings from becoming writable
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Abdifatah Suruur <[email protected]>
[ Upstream commit 2176dea8d8c19cb43a9b3651bfa1cb21eab1b31a ]
gntdev_mmap() rejects writable private (non-shared) mappings of foreign grant pages, because a private writable mapping takes the COW path on pages that have no proper struct-page backing. However, VM_MAYWRITE is left set, so userspace can map the grant read-only and then upgrade the mapping to writable with mprotect(), hitting the same COW path the check was written to prevent.
Clear VM_MAYWRITE for private mappings, as i915 does for its read-only objects and as fixed in drm/vc4 (CVE-2026-68445) and drm/panthor (CVE-2024-53071) and ptp: vmclock (commit a5edadbae57e2298a56cf7a4e774a027905a331f).
Message-ID: <[email protected]>
--- drivers/xen/gntdev.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/xen/gntdev.c +7 -0
@@ -1064,6 +1064,13 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma)if ((vma->vm_flags &VM_WRITE ) && !(vma->vm_flags &VM_SHARED ))return -EINVAL ; +/* +* Private mappings of foreign grant pages must never become +* writable: they would take the COW path on granted pages. +*/ +if (!(vma->vm_flags &VM_SHARED )) + vma->vm_flags &= ~VM_MAYWRITE ; +pr_debug ("map %d+%d at %lx (pgoff %lx)\n" , index, count, vma->vm_start, vma->vm_pgoff);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 833/1848 ext4: fix ABBA deadlock in ext4_rmdir()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Senozhatsky <[email protected]>
[ Upstream commit 19e16597f9baf1b5719a3a6c710486446f6808fd ]
We observe the following ABBA deadlock (casefolding enabled):
INFO: task jbd2/dm-13-8:447 blocked for more than 720 seconds. task:jbd2/dm-13-8 state:D stack:0 pid:447 tgid:447 ppid:2 Call Trace: <TASK> __schedule+0xc2c/0xe60 schedule+0x40/0xe0 jbd2_journal_wait_updates+0x8f/0xf0 jbd2_journal_commit_transaction+0x321/0x1850 kjournald2+0xa9/0x230 kthread+0x226/0x2a0 ret_from_fork+0x101/0x1e0 ret_from_fork_asm+0x1a/0x30 INFO: task Thread-10:4161 blocked for more than 720 seconds. task:Thread-10 state:D stack:0 pid:4161 tgid:3848 ppid:540 Call Trace: <TASK> __schedule+0xc2c/0xe60 schedule+0x40/0xe0 wait_transaction_locked+0x8c/0xd0 start_this_handle+0x252/0x870 jbd2__journal_start+0x120/0x280 __ext4_journal_start_sb+0x11a/0x250 ext4_evict_inode+0x208/0x760 iput+0x222/0x5c0 dput+0x293/0x690 ____fput+0x145/0x2b0 task_work_run+0x7a/0xb0 exit_to_user_mode_loop+0xc0/0xd0 do_syscall_64+0x14b/0xf10 entry_SYSCALL_64_after_hwframe+0x76/0x7e
NMI backtrace for cpu 0
CPU: 0 UID: 1010216 PID: 4160 Comm: Thread-7 RIP: 0010:d_walk+0x0/0x290 [..] Call Trace: <TASK> shrink_dcache_parent+0xb2/0x100 d_invalidate+0x50/0x110 ext4_rmdir+0x3a2/0x3d0 vfs_rmdir+0x9d/0x1d0 do_rmdir+0xf0/0x330 __x64_sys_unlinkat+0x34/0x50 do_syscall_64+0x61/0xf10
The problem is that ext4_rmdir() calls d_invalidate() before stopping the jbd2 transaction handle. Because d_invalidate() traverses child dentries it can encounter dying or in-use dentries. If a concurrent thread executing __dentry_kill() on a child dentry invokes ext4_evict_inode(), it requests a new transaction handle via ext4_journal_start(), which waits for all running handles to close. However, the thread executing ext4_rmdir() still holds its active transaction handle while looping in shrink_dcache_parent() waiting for the dying child dentry to complete eviction.
Stop transaction handle in ext4_rmdir() before calling d_invalidate().
--- fs/ext4/namei.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
fs/ext4/namei.c +6 -5
@@ -3275,6 +3275,11 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)ext4_fc_track_unlink (handle, dentry); retval =ext4_mark_inode_dirty (handle, dir); +end_rmdir: +brelse (bh); +if (handle) +ext4_journal_stop (handle); +#ifdef CONFIG_UNICODE /* VFS negative dentries are incompatible with Encoding and * Case-insensitiveness. Eventually we'll want avoid
@@ -3282,14 +3287,10 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry)* negative dentries at ext4_lookup(), when it is better * supported by the VFS for the CI case. */ -if (IS_CASEFOLDED (dir)) +if (!retval &&IS_CASEFOLDED (dir))d_invalidate (dentry);#endif -end_rmdir: -brelse (bh); -if (handle) -ext4_journal_stop (handle);return retval; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 834/1848 crypto: ecc - Handle exceptional points in Shamir multiplication
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérémy Jean <[email protected]>
[ Upstream commit 6fd70bc8bc01a578c7728b7bd1cb5689c62cc5b7 ]
Shamir multiplication mishandles equal points, opposite points and the point at infinity. This rejects valid ECDSA signatures and can accept invalid digest/signature tuples when the public key is G or -G. The kernel incorrectly rejects 16 valid signatures from Wycheproof.
Handle doubling, cancellation and the point at infinity in precomputation and accumulation. Add regression tests for P-256 ECDSA and 256/512-bit EC-RDSA. The valid vectors are Wycheproof P1363 secp256r1/SHA-256 cases 60 and 210 converted to X9.62, two constructed ECDSA signatures for Q = +/-G with k = 2, and six constructed EC-RDSA signatures for Q = G, -G and -2G. Also add two invalid P-256 digest/signature tuples for Q = +/-G that must return -EKEYREJECTED.
--- crypto/ecc.c | 33 +++++++- crypto/testmgr.h | 198 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 228 insertions(+), 3 deletions(-)
crypto/ecc.c +31 -2
@@ -1224,9 +1224,22 @@ static void ecc_point_add(const struct ecc_point *result,vli_set (result->x, q->x, ndigits);vli_set (result->y, q->y, ndigits);vli_mod_sub (z, result->x, p->x, curve->p, ndigits); +if (vli_is_zero (z, ndigits)) { +if (vli_cmp (p->y, q->y, ndigits)) { +/* P + (-P) is the point at infinity. */ +vli_clear (result->x, ndigits); +vli_clear (result->y, ndigits); +return ; + } +/* The co-Z addition formula does not handle P == Q. */ + z[0 ] =1 ; +ecc_point_double_jacobian (result->x, result->y, z, curve->p, ndigits); + goto out; + }vli_set (px, p->x, ndigits);vli_set (py, p->y, ndigits);xycz_add (px, py, result->x, result->y, curve->p, ndigits); +out:vli_mod_inv (z, z, curve->p, ndigits);apply_z (result->x, result->y, z, curve->p, ndigits); }
@@ -1266,21 +1279,37 @@ void ecc_point_mult_shamir(const struct ecc_point *result,vli_set (rx, point->x, ndigits);vli_set (ry, point->y, ndigits);vli_clear (z +1 , ndigits -1 ); - z[0 ] =1 ; + z[0 ] = !ecc_point_is_zero (point);for (--i; i >=0 ; i--) {ecc_point_double_jacobian (rx, ry, z, curve->p, ndigits); idx = (!!vli_test_bit (u1, i)) | ((!!vli_test_bit (u2, i)) <<1 ); point = points[idx]; -if (point) { +if (point && !ecc_point_is_zero (point)) {u64 tx[ECC_MAX_DIGITS ];u64 ty[ECC_MAX_DIGITS ];u64 tz[ECC_MAX_DIGITS ]; +if (vli_is_zero (z, ndigits)) { +/* Adding to infinity starts a new accumulator. */ +vli_set (rx, point->x, ndigits); +vli_set (ry, point->y, ndigits); + z[0 ] =1 ; +continue ; + }vli_set (tx, point->x, ndigits);vli_set (ty, point->y, ndigits);apply_z (tx, ty, z, curve->p, ndigits);vli_mod_sub (tz, rx, tx, curve->p, ndigits); +if (vli_is_zero (tz, ndigits)) { +if (!vli_cmp (ry, ty, ndigits)) +ecc_point_double_jacobian (rx, ry, z, + curve->p, ndigits); +else +/* Adding opposite points yields infinity. */ +vli_clear (z, ndigits); +continue ; + }xycz_add (tx, ty, rx, ry, curve->p, ndigits);vli_mod_mult_fast (z, z, tz, curve->p, ndigits); }
crypto/testmgr.h +197 -1
210 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 835/1848 usb: typec: ucsi: ccg: Validate altmode index in GET_CURRENT_CAM response
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Seungjin Bae <[email protected]>
[ Upstream commit 02ee864e8d2142c5648998944c3306ea6a763c26 ]
When the PPM reports more than one DisplayPort alternate mode for a connector, ucsi_ccg_update_altmodes() merges them into a single entry in uc->updated[] and sets uc->has_multiple_dp. In that case, ucsi_ccg_update_get_current_cam_cmd() rewrites the response of the GET_CURRENT_CAM command. The response is a single byte holding the index of the currently active alternate mode, and it is provided by the PPM firmware.
The function uses this byte directly as an index into uc->orig[], and then uses the linked_idx read from that entry as the translated index into uc->updated[]. Both arrays have UCSI_MAX_ALTMODES entries, but neither index is checked against that size.
If a malicious or buggy PPM reports a value of UCSI_MAX_ALTMODES or larger, e.g. 0xFF, uc->orig[cam].linked_idx reads over the end of uc->orig[]. The byte read from there is then used as the index for writing cam into uc->updated[new_cam].active_idx, so the out-of-bounds read is followed by an out-of-bounds write. This happens without any userspace action, since the UCSI core issues GET_CURRENT_CAM on its own when handling connector changes.
Fix this by rejecting responses whose index is out of range, printing an error and returning -EPROTO, so that the caller cannot accept this. Also check linked_idx before using it as an index, so that the write into uc->updated[] is always within bounds.
The response is now only processed when the command completed without an error. ucsi_sync_control_common() only reads the response when the CCI reports command completion, so otherwise the buffer is not filled and must not be mistaken for an invalid index.
This bug was found with a Python script that traces where firmware input is used.
--- drivers/usb/typec/ucsi/ucsi_ccg.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/usb/typec/ucsi/ucsi_ccg.c +16 -2
@@ -351,14 +351,28 @@ static int ucsi_ccg_init(struct ucsi_ccg *uc)return -ETIMEDOUT ; } -static void ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) +static int ucsi_ccg_update_get_current_cam_cmd (struct ucsi_ccg *uc,u8 *data) {u8 cam, new_cam; cam = data[0 ]; +if (cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"PPM returned invalid alternate mode index %u\n" , + cam); +return -EPROTO ; + } + new_cam = uc->orig[cam].linked_idx; +if (new_cam >=UCSI_MAX_ALTMODES ) { +dev_err (uc->dev,"invalid linked alternate mode index %u for %u\n" , + new_cam, cam); +return -EPROTO ; + } + uc->updated[new_cam].active_idx = cam; data[0 ] = new_cam; + +return 0 ; } static bool ucsi_ccg_update_altmodes(struct ucsi *ucsi,
@@ -541,7 +555,7 @@ static int ucsi_ccg_read(struct ucsi *ucsi, unsigned int offset,switch (UCSI_COMMAND (uc->last_cmd_sent)) {case UCSI_GET_CURRENT_CAM :if (uc->has_multiple_dp) -ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val); + ret =ucsi_ccg_update_get_current_cam_cmd (uc, (u8 *)val);break ;case UCSI_GET_ALTERNATE_MODES : if (UCSI_ALTMODE_RECIPIENT(uc->last_cmd_sent) ==
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 836/1848 sctp: hold shkey across socket migration
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Lee <[email protected]>
[ Upstream commit ad1320865b1826ffa2e81e37c49535751e81335c ]
sctp_sock_migrate() transfers queued DATA skbs from the old socket to the new one. skb_orphan() invokes sctp_wfree() during that transfer and drops the skb-owned shared-key reference.
If userspace has removed that key from the association, this can be the final reference. The following sctp_set_owner_w() then dereferences the freed chunk->shkey while trying to take the new owner reference.
Take a temporary shared-key reference before orphaning the skb and release it after the new owner has taken its reference. This preserves the selected authentication key throughout the ownership transfer.
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.
Stable-dep-of: 52ffeaa358d1 ("sctp: re-point retained control chunks on association migration")
--- net/sctp/socket.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
net/sctp/socket.c +11 -1
@@ -146,9 +146,19 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)static void sctp_clear_owner_w (struct sctp_chunk *chunk) { +/* Keep the shkey alive until the new owner takes its reference. */ +if (chunk->shkey) +sctp_auth_shkey_hold (chunk->shkey);skb_orphan (chunk->skb); } +static void sctp_set_owner_w_migrate (struct sctp_chunk *chunk) +{ +sctp_set_owner_w (chunk); +if (chunk->shkey) +sctp_auth_shkey_release (chunk->shkey); +} +#define traverse_and_process () \ do { \ msg = chunk->msg; \
@@ -9462,7 +9472,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,lock_sock_nested (newsk,SINGLE_DEPTH_NESTING );sctp_for_each_tx_datachunk (assoc, true, sctp_clear_owner_w);sctp_assoc_migrate (assoc, newsk); -sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w); +sctp_for_each_tx_datachunk (assoc, false, sctp_set_owner_w_migrate);/* If the association on the newsk is already closed before accept() * is called, set RCV_SHUTDOWN flag.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 837/1848 sctp: re-point retained control chunks on association migration
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jun Yang <[email protected]>
[ Upstream commit 52ffeaa358d1f3d91aa87a26ad90d77769cff74b ]
sctp_sock_migrate() transfers DATA chunk ownership but leaves retained control chunks pointing at the old socket. A later retransmission can therefore access the socket after it has been freed.
Extend the migration walk to cover retained control chunks and use sctp_control_set_owner_w() to assign their new owner. Reuse the DATA ownership check so each chunk is processed once per pass, even when it is reachable through multiple lists or retained pointers.
Preserve a control chunk's existing authentication key across migration so its final release can still generate SCTP_AUTH_FREE_KEY when needed.
--- include/net/sctp/sm.h | 1 + net/sctp/sm_make_chunk.c | 5 ++-- net/sctp/socket.c | 53 ++++++++++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 15 deletions(-)
include/net/sctp/sm.h +1 -0
@@ -250,6 +250,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc, struct sctp_fwdtsn_skip *skiplist);struct sctp_chunk *sctp_make_auth (const struct sctp_association *asoc,__u16 key_id); +void sctp_control_set_owner_w (struct sctp_chunk *chunk);struct sctp_chunk *sctp_make_strreset_req (const struct sctp_association *asoc,__u16 stream_num,__be16 *stream_list,bool out,bool in);
net/sctp/sm_make_chunk.c +3 -2
@@ -95,7 +95,7 @@ static void sctp_control_release_owner(struct sk_buff *skb) } } -static void sctp_control_set_owner_w (struct sctp_chunk *chunk) +void sctp_control_set_owner_w (struct sctp_chunk *chunk) {struct sctp_association *asoc = chunk->asoc;struct sk_buff *skb = chunk->skb;
@@ -108,7 +108,8 @@ static void sctp_control_set_owner_w(struct sctp_chunk *chunk)* For now don't do anything for now. */ if (chunk->auth) { - chunk->shkey = asoc->shkey; +if (!chunk->shkey) + chunk->shkey = asoc->shkey;sctp_auth_shkey_hold (chunk->shkey); } skb->sk = asoc ? asoc->base.sk :NULL ;
net/sctp/socket.c +40 -13
81 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 838/1848 netfilter: nf_reject: initialize IPCB at inet ingress
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 73a73d442f9986353fe284bd1b504d0313d0f153 ]
The inet ingress hook runs before ip_rcv_core() and ip6_rcv_core(), so neither IPCB nor IP6CB has been initialized when nft_reject_inet passes a packet to nf_send_unreach() or nf_send_unreach6(). skb->cb can therefore retain metadata from an earlier protocol layer.
For IPv4, icmp_send() treats IPCB(skb)->opt as parsed IPv4 options. Stale option offsets can make __ip_options_echo() copy an attacker-controlled length into its 40-byte reply option buffer and overflow the stack. On an unpatched v7.2-rc5 kernel, the IPv4 reproducer produced:
BUG: KASAN: stack-out-of-bounds in __ip_options_echo() Write of size 255
For IPv6, icmpv6_send() consumes IP6CB(skb) as parsed IPv6 metadata. It always uses iif for source selection and, when MIP6 is enabled, uses dsthao as an extension-header offset. These fields must not be stale.
For NF_INET_INGRESS, clear the address-family-specific control block and restore its input interface before constructing the ICMP error. This matches similar initialization normally performed by ip_rcv_core() and ip6_rcv_core().
--- net/ipv4/netfilter/nf_reject_ipv4.c | 5 +++++ net/ipv6/netfilter/nf_reject_ipv6.c | 5 +++++ 2 files changed, 10 insertions(+)
net/ipv4/netfilter/nf_reject_ipv4.c +5 -0
@@ -198,6 +198,11 @@ void nf_send_unreach(struct sk_buff *skb_in, int code, int hook)if (!skb_valid_dst (skb_in) &&nf_reject_fill_skb_dst (skb_in) <0 )return ; +if (hook ==NF_INET_INGRESS ) { +memset (IPCB (skb_in),0 ,sizeof (*IPCB (skb_in))); +IPCB (skb_in)->iif = skb_in->skb_iif; + } +if (skb_csum_unnecessary (skb_in) || !nf_reject_verify_csum (proto)) {icmp_send (skb_in,ICMP_DEST_UNREACH , code,0 );return ;
net/ipv6/netfilter/nf_reject_ipv6.c +5 -0
@@ -263,6 +263,11 @@ void nf_send_unreach6(struct net *net, struct sk_buff *skb_in,if (hooknum ==NF_INET_LOCAL_OUT && skb_in->dev ==NULL ) skb_in->dev = net->loopback_dev; +if (hooknum ==NF_INET_INGRESS ) { +memset (IP6CB (skb_in),0 ,sizeof (*IP6CB (skb_in))); +IP6CB (skb_in)->iif = skb_in->skb_iif; + } +if (!skb_valid_dst (skb_in) &&nf_reject6_fill_skb_dst (skb_in) <0 )return ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 839/1848 bnxt_en: dont leave an XDP program installed when the open fails
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vaibhav Nagare <[email protected]>
[ Upstream commit 78731b46967e3e7102b5cd5062bef185f3404b5c ]
bnxt_xdp_set() stores the new program and drops the reference on the old one before reopening the NIC. If bnxt_open_nic() then fails, ndo_bpf() returns an error with the new program still in bp->xdp_prog. The caller treats the error as "nothing was installed" and drops its own reference, so bp->xdp_prog is left pointing at a freed program and the next XDP update dereferences it:
BUG: unable to handle page fault for address: ff78ecc80ddd1038 RIP: 0010:__bpf_prog_put+0x5/0x80 Call Trace: bnxt_xdp_set+0xad/0x1b0 [bnxt_en] dev_xdp_propagate+0x36/0xa0 bond_xdp_set+0xeb/0x2d0 [bonding] dev_xdp_install+0x1b1/0x350 bpf_xdp_link_update+0xc5/0x1b0 link_update+0x104/0x1e0 __sys_bpf+0x662/0xcf0
Seen on a 6.12 based kernel after bnxt_alloc_mem() failed an order-4 allocation on a fragmented host:
bnxt_en 0000:a0:00.1 ens4f1np1: nic open fail (rc: fffffff4)
bond1: (slave ens4f1np1): Error -12 calling ndo_bpf
Bonding is not required to hit this; a plain XDP attach on a bnxt interface takes the same path.
Restore the previous program when an attach or a replace fails, and recompute the page-mode and XDP TX ring configuration from it. The configuration matters because bnxt_init_one_rx_ring() only assigns rxr->xdp_prog in page mode, and __bnxt_set_rx_skb_mode() derives dev->max_mtu from the installed program. Release the old program only once the change has been committed.
A detach is not undone. dev_xdp_detach_link() clears the core's record of the program even when the driver returns an error, so putting the program back would leave the driver running a program the core has already dropped. If the reopen fails during a detach, bnxt_xdp_set() therefore returns 0 with the device closed; bnxt_open_nic() has already logged the failure.
Found in a crash dump; the change was not tested on hardware.
--- drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c +20 -5
@@ -268,6 +268,7 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)struct net_device *dev = bp->dev;int tx_xdp =0 , rc, tc;struct bpf_prog *old; +int old_tx_xdp;if (prog && bp->dev->mtu >BNXT_MAX_PAGE_MODE_MTU ) { netdev_warn(dev, "MTU %d larger than largest XDP supported MTU %d.\n",
@@ -293,11 +294,12 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)if (netif_running (dev))bnxt_close_nic (bp, true, false); + old_tx_xdp = bp->tx_nr_rings_xdp; old =xchg (&bp->xdp_prog, prog); -if (old) -bpf_prog_put (old); -if (prog) { +apply_cfg: + tc =netdev_get_num_tc (dev) ? :1 ; +if (bp->xdp_prog) {bnxt_set_rx_skb_mode (bp, true); }else {int rx, tx;
@@ -315,8 +317,21 @@ static int bnxt_xdp_set(struct bnxt *bp, struct bpf_prog *prog)bnxt_set_tpa_flags (bp);bnxt_set_ring_params (bp); -if (netif_running (dev)) -return bnxt_open_nic (bp, true, false); +if (rc) +return rc; + +if (netif_running (dev)) { + rc =bnxt_open_nic (bp, true, false); +/* a detach cannot be undone, only an attach */ +if (rc && prog) { +WRITE_ONCE (bp->xdp_prog, old); + tx_xdp = old_tx_xdp; + goto apply_cfg; + } + } + +if (old) +bpf_prog_put (old);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 840/1848 mm/madvise: atomically clear the young bit on THP MADV_COLD
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pedro Falcato <[email protected]>
[ Upstream commit 246c8cc33438a71c28f9b86baa492d9a0a130316 ]
As-is, madvise_cold_or_pageout_pte_range() discards the hardware young bit by invalidating the PMD, doing pmd_mkold() and subsequently writing to the pmd again. However, it does so in a racy manner, looking at a possibly-stale snapshot. It's entirely possible that a write elsewhere set the hardware D bit, which this logic now loses.
Fix it by using pmdp_test_and_clear_young(). This is an atomic modification of the PMD entry, and thus safe against any possible racing writes. As a (nice) side-effect, this elides one non-required TLB flush in pmdp_invalidate().
This bug can interact with the swapping system in complicated ways, leading to data loss. For instance, if a folio is marked lazyfree, but was later read from, and then MADV_COLD'd while racing a write to that same THP, dropping the dirty bit may lead to data loss as reclaim/MADV_PAGEOUT drops the "clean" anon folio:
T0 T1
================================================================MADV_FREE(thp) |
folio marked lazyfree |
read(thp) |
PMD marked young by hardware |
| MADV_COLD(thp)
write(thp) | if (pmd_young(pmd)) {
PMD marked dirty by hardware | set(pmdp, pmd_mkold(pmd));
MADV_PAGEOUT/reclaim |
dirty bit may or may not be |
set |
reclaim/pageout may drop |
the folio |
--- mm/madvise.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
mm/madvise.c +1 -4
@@ -361,10 +361,7 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd, }if (pmd_young (orig_pmd)) { -pmdp_invalidate (vma, addr, pmd); - orig_pmd =pmd_mkold (orig_pmd); - -set_pmd_at (mm, addr, pmd, orig_pmd); +pmdp_test_and_clear_young (vma, addr, pmd);tlb_remove_pmd_tlb_entry (tlb, pmd, addr); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 841/1848 ceph: fix integer overflow in the snap trace bounds check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit b3bf89767e3ca9506f1c7167cac97c41ec254d42 ]
ceph_update_snap_trace() bounds the two encoded snapid arrays that follow a struct ceph_mds_snap_realm with sizeof(u64) * (num_snaps + num_prior_parent_snaps). Both counts come straight off the wire as __le32, so the addition is evaluated in unsigned int and wraps before sizeof(u64) promotes it to size_t: an MDS sending num_snaps = 1 and num_prior_parent_snaps = 0xffffffff makes the sum zero and the check degenerates to ceph_decode_need(&p, e, 0, bad), which always passes. dup_array() then reads num_snaps * 8 bytes past the end of the message front, which ceph_msg_new2() allocates at exactly front_len bytes. An unsolicited CEPH_MSG_CLIENT_SNAP reaches this from a malicious or compromised MDS with no client-side action, as do the snaptraces carried in an MDS reply and in a cap import.
Compute the length with size_add()/size_mul() so it saturates at SIZE_MAX instead of wrapping, in the style fs/ceph/mdsmap.c already uses for num_export_targets.
BUG: KASAN: slab-out-of-bounds in dup_array (include/linux/unaligned.h:28 fs/ceph/snap.c:500) Read of size 8 at addr ffff8880102a16c8 by task kworker/1:2/129 Workqueue: ceph-msgr ceph_con_workfn Call Trace: dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120) print_report (mm/kasan/report.c:378 mm/kasan/report.c:482) kasan_report (mm/kasan/report.c:595) dup_array (include/linux/unaligned.h:28 fs/ceph/snap.c:500) ceph_update_snap_trace (fs/ceph/snap.c:836) ceph_handle_snap (fs/ceph/snap.c:1155) mds_dispatch (fs/ceph/mds_client.c:7234) ceph_con_process_message (net/ceph/messenger.c:1424) ceph_con_v1_try_read (net/ceph/messenger_v1.c:1430) ceph_con_workfn (net/ceph/messenger.c:1576) process_one_work (kernel/workqueue.c:3396) worker_thread (kernel/workqueue.c:3479 kernel/workqueue.c:3560) kthread (kernel/kthread.c:436) ret_from_fork (arch/x86/kernel/process.c:158) ret_from_fork_asm (arch/x86/entry/entry_64.S:245) ... The buggy address is located 0 bytes to the right of allocated 72-byte region [ffff8880102a1680, ffff8880102a16c8)
--- fs/ceph/snap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/ceph/snap.c +5 -2
@@ -702,6 +702,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,struct ceph_snap_realm *realm;struct ceph_snap_realm *first_realm =NULL ;struct ceph_snap_realm *realm_to_rebuild =NULL ; +size_t snaps_len;int rebuild_snapcs;int err = -ENOMEM ;LIST_HEAD (dirty_realms);
@@ -715,8 +716,10 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc,ceph_decode_need (&p, e,sizeof (*ri), bad); ri = p; p +=sizeof (*ri); -ceph_decode_need (&p, e,sizeof (u64)*(le32_to_cpu (ri->num_snaps) + -le32_to_cpu (ri->num_prior_parent_snaps)), bad); + snaps_len =size_mul (size_add (le32_to_cpu (ri->num_snaps), +le32_to_cpu (ri->num_prior_parent_snaps)), +sizeof (u64)); +ceph_decode_need (&p, e, snaps_len, bad); snaps = p; p +=sizeof (u64) *le32_to_cpu (ri->num_snaps); prior_parent_snaps = p;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 842/1848 usb: xhci: Fix bounce buffer overflow
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michal Pecio <[email protected]>
[ Upstream commit 68c5cb7574c567e83ba95258cb146db95e069a87 ]
High-speed devices with out of spec 1024 byte bulk endpoints exist and are allowed by USB core, but xhci-hcd always sets packet size to 512. The exact nature of these devices isn't documented, commit fb5ee84ea72c ("USB: Accept bulk endpoints with 1024-byte maxpacket") only states that they "don't work with xHCI host controllers", whatever it means.
But somebody (or a malicious device) can try, and then the driver will allocate a 512 byte bounce buffer for this endpoint and may write up to 1024 bytes into it if particular scatter-gather URBs are used, because xhci_align_td() obtains packet size from the descriptor. Fix this.
As a side effect, TRBs will be aligned to the packet size chosen by the driver on all endpoints of all speeds. Alignment serves the xHC, not device, so this is fine. Only out of spec devices are affected anyway.
--- drivers/usb/host/xhci-ring.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/usb/host/xhci-ring.c +3 -6
@@ -3389,15 +3389,13 @@ static u32 xhci_td_remainder(struct xhci_hcd *xhci, int transferred,static int xhci_align_td (struct xhci_hcd *xhci,struct urb *urb,u32 enqd_len, -u32 *trb_buff_len,struct xhci_segment *seg) +u32 *trb_buff_len,struct xhci_segment *seg,u32 max_pkt) {struct device *dev =xhci_to_hcd (xhci)->self.sysdev;unsigned int unalign; -unsigned int max_pkt;u32 new_buff_len;size_t len; - max_pkt =usb_endpoint_maxp (&urb->ep->desc); unalign = (enqd_len + *trb_buff_len) % max_pkt;/* we got lucky, last normal TRB data on segment is packet aligned */
@@ -3542,9 +3540,8 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,if (enqd_len + trb_buff_len < full_len) { field |=TRB_CHAIN ;if (trb_is_link (ring->enqueue +1 )) { -if (xhci_align_td (xhci, urb, enqd_len, - &trb_buff_len, - ring->enq_seg)) { +if (xhci_align_td (xhci, urb, enqd_len, &trb_buff_len, + ring->enq_seg, ring->bounce_buf_len)) { send_addr = ring->enq_seg->bounce_dma;/* TD bounced at least, and last on this seg */ td->bounce_seg = ring->enq_seg;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 843/1848 platform/x86: hp-wmi: rename "thermal policy" to "thermal profile"
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Elia Devito <[email protected]>
[ Upstream commit d7da7534272f7b42629042a5b6fa51debca9201e ]
rename "thermal policy" with the more appropriate term "thermal profile"
Stable-dep-of: 6dea092b261f ("platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()")
--- drivers/platform/x86/hp-wmi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/platform/x86/hp-wmi.c +6 -6
@@ -87,7 +87,7 @@ enum hp_wmi_commandtype {HPWMI_FEATURE2_QUERY =0x0d ,HPWMI_WIRELESS2_QUERY =0x1b ,HPWMI_POSTCODEERROR_QUERY =0x2a , - HPWMI_THERMAL_POLICY_QUERY = 0x4c, + HPWMI_THERMAL_PROFILE_QUERY = 0x4c, }; enum hp_wmi_command {
@@ -875,19 +875,19 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)return err; } -static int thermal_policy_setup (struct platform_device *device) +static int thermal_profile_setup (struct platform_device *device) {int err, tp; - tp =hp_wmi_read_int (HPWMI_THERMAL_POLICY_QUERY ); + tp =hp_wmi_read_int (HPWMI_THERMAL_PROFILE_QUERY );if (tp <0 )return tp;/* -* call thermal policy write command to ensure that the firmware correctly +* call thermal profile write command to ensure that the firmware correctly * sets the OEM variables for the DPTF */ - err =hp_wmi_perform_query (HPWMI_THERMAL_POLICY_QUERY ,HPWMI_WRITE , &tp, + err =hp_wmi_perform_query (HPWMI_THERMAL_PROFILE_QUERY ,HPWMI_WRITE , &tp,sizeof (tp),0 );if (err)return err;
@@ -914,7 +914,7 @@ static int __init hp_wmi_bios_setup(struct platform_device *device)hp_wmi_rfkill2_setup (device); } -thermal_policy_setup (device); +thermal_profile_setup (device);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 844/1848 platform/x86: Rename hp-wireless to wireless-hotkey
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mario Limonciello <[email protected]>
[ Upstream commit a558ea42c0decd088df1950bb232ac2257929281 ]
This driver was originally intended to support some HP laptops, but later support was added for Xioami and AMD laptops.
Rename it to make it clear that it supports a larger variety of systems.
Stable-dep-of: 6dea092b261f ("platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()")
--- drivers/platform/x86/Kconfig | 9 ++- drivers/platform/x86/Makefile | 2 +- drivers/platform/x86/hp-wireless.c | 102 ------------------------ drivers/platform/x86/wireless-hotkey.c | 103 +++++++++++++++++++++++++ 4 files changed, 109 insertions(+), 107 deletions(-) delete mode 100644 drivers/platform/x86/hp-wireless.c create mode 100644 drivers/platform/x86/wireless-hotkey.c
drivers/platform/x86/Kconfig +5 -4
@@ -530,16 +530,17 @@ config HP_ACCEL To compile this driver as a module, choose M here: the module will be called hp_accel. -config HP_WIRELESS - tristate "HP wireless button" +config WIRELESS_HOTKEY + tristate "Wireless hotkey button" depends on ACPI depends on INPUT help - This driver provides supports for new HP wireless button for Windows 8. + This driver provides supports for the wireless buttons found on some AMD, + HP, & Xioami laptops. On such systems the driver should load automatically (via ACPI alias). To compile this driver as a module, choose M here: the module will - be called hp-wireless. + be called wireless-hotkey. config HP_WMI tristate "HP WMI extras"
drivers/platform/x86/Makefile +1 -1
@@ -58,7 +58,6 @@ obj-$(CONFIG_GPD_POCKET_FAN) += gpd-pocket-fan.o # Hewlett Packard obj-$(CONFIG_HP_ACCEL) += hp_accel.o -obj-$(CONFIG_HP_WIRELESS) += hp-wireless.o obj-$(CONFIG_HP_WMI) += hp-wmi.o obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
@@ -124,6 +123,7 @@ obj-$(CONFIG_TOPSTAR_LAPTOP) += topstar-laptop.o obj-$(CONFIG_I2C_MULTI_INSTANTIATE) += i2c-multi-instantiate.o obj-$(CONFIG_MLX_PLATFORM) += mlx-platform.o obj-$(CONFIG_TOUCHSCREEN_DMI) += touchscreen_dmi.o +obj-$(CONFIG_WIRELESS_HOTKEY) += wireless-hotkey.o # Intel uncore drivers obj-$(CONFIG_INTEL_IPS) += intel_ips.o
drivers/platform/x86/hp-wireless.c deleted +0 -102
102 lines not on this page · raw message
drivers/platform/x86/wireless-hotkey.c new file +103 -0
103 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 845/1848 platform/x86: Move existing HP drivers to a new hp subdir
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jorge Lopez <[email protected]>
[ Upstream commit 6e9b8992b122cb12688bd259fc99e67d1be234eb ]
The purpose of this patch is to provide a central location where all HP related drivers are found. HP drivers will recide under drivers/platform/x86/hp directory.
Introduce changes to Kconfig file to list all HP driver under "HP X86 Platform Specific Device Drivers" menu option. Additional changes include update MAINTAINERS file to indicate hp related drivers new path.
HP related drivers are found. HP drivers will reside in the new subdirectory.
Introduce changes to Kconfig file to list all HP driver under "HP X86 Platform Specific Device Drivers" menu option. Additional changes include update MAINTAINERS file to indicate hp related drivers new path.
Keep the existing HP WMI configuration requirements: platform profile and hardware monitoring support are not present in this driver.
Include the missing-object cleanup branch and invalid-object diagnostic from the later query implementation so the subsequent buffer bounds check applies without pulling in the unrelated buffer allocation changes.
Stable-dep-of: 6dea092b261f ("platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()")
---
MAINTAINERS | 4 +-
drivers/platform/x86/Kconfig | 41 +--------------
drivers/platform/x86/Makefile | 4 +-
drivers/platform/x86/hp/Kconfig | 61 ++++++++++++++++++++++
drivers/platform/x86/hp/Makefile | 10 ++++
drivers/platform/x86/{ => hp}/hp-wmi.c | 7 ++-
drivers/platform/x86/{ => hp}/hp_accel.c | 2 +-
drivers/platform/x86/{ => hp}/tc1100-wmi.c | 0
8 files changed, 81 insertions(+), 48 deletions(-)
create mode 100644 drivers/platform/x86/hp/Kconfig
create mode 100644 drivers/platform/x86/hp/Makefile
rename drivers/platform/x86/{ => hp}/hp-wmi.c (99%)
rename drivers/platform/x86/{ => hp}/hp_accel.c (99%)
rename drivers/platform/x86/{ => hp}/tc1100-wmi.c (100%)MAINTAINERS +2 -2
@@ -8028,7 +8028,7 @@ F: drivers/net/wireless/intersil/hostap/ HP COMPAQ TC1100 TABLET WMI EXTRAS DRIVER L: [email protected] S: Orphan -F: drivers/platform/x86/tc1100-wmi.c +F: drivers/platform/x86/hp/tc1100-wmi.c HPET: High Precision Event Timers driver M: Clemens Ladisch <[email protected]>
@@ -10159,7 +10159,7 @@ M: Eric Piel <[email protected]> S: Maintained F: Documentation/misc-devices/lis3lv02d.rst F: drivers/misc/lis3lv02d/ -F: drivers/platform/x86/hp_accel.c +F: drivers/platform/x86/hp/hp_accel.c LIST KUNIT TEST M: David Gow <[email protected]>
drivers/platform/x86/Kconfig +1 -40
53 lines not on this page · raw message
drivers/platform/x86/Makefile +1 -3
@@ -57,9 +57,7 @@ obj-$(CONFIG_FUJITSU_TABLET) += fujitsu-tablet.o obj-$(CONFIG_GPD_POCKET_FAN) += gpd-pocket-fan.o # Hewlett Packard -obj-$(CONFIG_HP_ACCEL) += hp_accel.o -obj-$(CONFIG_HP_WMI) += hp-wmi.o -obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o +obj-$(CONFIG_X86_PLATFORM_DRIVERS_HP) += hp/ # IBM Thinkpad and Lenovo obj-$(CONFIG_IBM_RTL) += ibm_rtl.o
drivers/platform/x86/hp/Kconfig new file +61 -0
61 lines not on this page · raw message
drivers/platform/x86/hp/Makefile new file +10 -0
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Makefile for linux/drivers/platform/x86/hp +# HP x86 Platform-Specific Drivers +# + +# Hewlett Packard +obj-$(CONFIG_HP_ACCEL) += hp_accel.o +obj-$(CONFIG_HP_WMI) += hp-wmi.o +obj-$(CONFIG_TC1100_WMI) += tc1100-wmi.o
drivers/platform/x86/hp/hp-wmi.c renamed from drivers/platform/x86/hp-wmi.c +5 -2
@@ -241,10 +241,13 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, obj = output.pointer; -if (!obj) -return -EINVAL ; +if (!obj) { + ret = -EINVAL ; + goto out_free; + }if (obj->type !=ACPI_TYPE_BUFFER ) { +pr_warn ("query 0x%x returned an invalid object 0x%x\n" , query, ret); ret = -EINVAL ; goto out_free; }
drivers/platform/x86/hp/hp_accel.c renamed from drivers/platform/x86/hp_accel.c +1 -1
@@ -26,7 +26,7 @@#include <linux/acpi.h> #include <linux/i8042.h> #include <linux/serio.h> -#include "../../misc/lis3lv02d/lis3lv02d.h" +#include "../../../misc/lis3lv02d/lis3lv02d.h" #define DRIVER_NAME "hp_accel"#define ACPI_MDPS_CLASS "accelerometer"
drivers/platform/x86/hp/tc1100-wmi.c renamed from drivers/platform/x86/tc1100-wmi.c +0 -0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 846/1848 platform/x86: hp-wmi: fix heap OOB read and memory corruption in hp_wmi_perform_query()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Muhammad Bilal <[email protected]>
[ Upstream commit 6dea092b261f04d632411c2be52d13190f5f67b1 ]
hp_wmi_perform_query() evaluates an ACPI WMI method and expects a struct bios_return header in the returned buffer. However, it only checks that the ACPI object type is ACPI_TYPE_BUFFER without verifying that obj->buffer.length is at least sizeof(*bios_return) (8 bytes).
If the firmware or ACPI method returns a buffer shorter than 8 bytes:
1. bios_return->return_code at offset 4 reads out of bounds from the allocated ACPI buffer slab.
2. If return_code evaluates to 0 and outsize is non-zero, (int)(obj->buffer.length - sizeof(*bios_return)) evaluates to a negative integer (e.g. -8 for a 0-length buffer). actual_outsize is set to this negative value and passed to memcpy(buffer, ..., actual_outsize), where the signed negative value is cast to size_t (e.g. 0xfffffffffffffff8), attempting to copy ~18 Exabytes and triggering an immediate kernel crash. Additionally, memset(buffer + actual_outsize, ...) performs an out-of-bounds write before buffer.
Fix this by ensuring obj->buffer.length is at least sizeof(*bios_return) before accessing the return code, and compute actual_outsize safely using min_t(u32, ...), which is sound specifically because the guard above already rules out obj->buffer.length being smaller than sizeof(*bios_return) by the time that subtraction runs.
--- drivers/platform/x86/hp/hp-wmi.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/platform/x86/hp/hp-wmi.c +4 -3
@@ -246,8 +246,9 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, goto out_free; } -if (obj->type !=ACPI_TYPE_BUFFER ) { -pr_warn ("query 0x%x returned an invalid object 0x%x\n" , query, ret); +if (obj->type !=ACPI_TYPE_BUFFER || + obj->buffer.length <sizeof (*bios_return)) { +pr_warn ("query 0x%x returned wrong type or too small buffer\n" , query); ret = -EINVAL ; goto out_free; }
@@ -266,7 +267,7 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command,if (!outsize) goto out_free; - actual_outsize =min (outsize, (int )(obj->buffer.length -sizeof (*bios_return))); + actual_outsize =min_t (u32, outsize, obj->buffer.length -sizeof (*bios_return));memcpy (buffer, obj->buffer.pointer +sizeof (*bios_return), actual_outsize);memset (buffer + actual_outsize,0 , outsize - actual_outsize);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 847/1848 ALSA: usb-audio: Bound packet copies by the PCM buffer size
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sinan Turunc <[email protected]>
[ Upstream commit 06be918062adc1a5a76dc346803b136b20bdb5ae ]
retire_capture_urb() and prepare_playback_urb() assume that one USB packet never carries more data than the whole ALSA ring buffer. Nothing enforces that: the packet size comes from the device (wMaxPacketSize, and curpacksize == maxpacksize when the class-specific endpoint descriptor sets MaxPacketsOnly), while the PCM hardware constraints only require 64-byte periods, two periods and a period time of one data interval. An 8 kHz mono U8 stream on a 128-byte buffer is legal, and a full-speed device can send 1023-byte packets into it.
On the first oversized packet hwptr_done is wrapped once and stays beyond buffer_bytes (895 for 1023 bytes into 128). On the next packet the wrap arithmetic in the copy path computes
bytes1 = subs->buffer_bytes - oldptr
with oldptr > buffer_bytes, so bytes1 wraps to about 4 GB and memcpy() runs off the end of the URB buffer and of the vmalloc'd DMA buffer:
BUG: KASAN: slab-out-of-bounds in retire_capture_urb+0x251/0x870 Read of size 4294966529 at addr ffff88800c1e2800 by task vhci_rx/82
and for playback, where copy_to_urb() has the same shape:
BUG: KASAN: vmalloc-out-of-bounds in copy_to_urb.isra.0+0x188/0x430 Read of size 4294966529 at addr ffffc9000004537f by task vhci_rx/79 prepare_playback_urb+0x98a/0x1fc0
Truncate an oversized capture packet to the buffer size, and stop filling a playback URB once it holds a whole buffer. With bytes <= buffer_bytes the single wrap of hwptr_done and the two-part memcpy() in both copy paths stay inside the buffer. A device whose packets do not fit the buffer at all was never going to play correctly anyway.
Reproduced on 7.3-rc7 with a USB/IP device (dummy_hcd cannot carry isochronous data) advertising a UAC1 endpoint with MaxPacketsOnly and wMaxPacketSize 1023, and a PCM client using period_size 64, periods 2.
--- sound/usb/pcm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
sound/usb/pcm.c +20 -0
@@ -1438,6 +1438,18 @@ static void retire_capture_urb(struct snd_usb_substream *subs, bytes -= adj; subs->stream_offset_adj -= adj; } +/* +* A packet can be as large as the endpoint's maxpacksize, which +* the device chooses, while the ring buffer can be as small as +* two 64-byte periods. The hwptr_done wrap below handles one +* wrap only, so never take more than one buffer from a packet. +*/ +if (unlikely (bytes > runtime->buffer_size * stride)) { +dev_warn_ratelimited (&subs->dev->dev, +"%u-byte packet exceeds %lu-byte buffer, truncating\n" , + bytes, runtime->buffer_size * stride); + bytes = runtime->buffer_size * stride; + } frames = bytes / stride;if (!subs->txfr_quirk) bytes = frames * stride;
@@ -1614,6 +1626,14 @@ static void prepare_playback_urb(struct snd_usb_substream *subs,else counts =snd_usb_endpoint_next_packet_size (ep); +/* +* Bound by the ring buffer as well as by the URB: +* copy_to_urb() wraps hwptr_done once, so one URB must +* never carry more than the whole buffer. +*/ +if ((frames + counts) * ep->stride > ctx->buffer_size || + (frames + counts) * ep->stride > runtime->buffer_size * stride) +break ;/* set up descriptor */ urb->iso_frame_desc[i].offset = frames * ep->stride; urb->iso_frame_desc[i].length = counts * ep->stride;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 848/1848 mm/hugetlb: unmap the page where the other VMA maps it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit ae99c503eb362b42cd5d24d80bc6cba669acc4c2 ]
If the owner of a MAP_PRIVATE hugetlb mapping fails to allocate a page for CoW, unmap_ref_private() unmaps the old page from all other private VMAs that have no reservation of their own. It finds them by the offset in the file, but then zaps each of them at the address of the faulting VMA. Nothing says that another VMA maps the offset at that address: a child can have moved its copy of the VMA with mremap(), and a second mapping of the file is wherever mmap() has put it.
So __unmap_hugepage_range() walks the page tables of the other mm at an address outside of iter_vma, where i_mmap_rwsem of this file protects nothing and where anything can be mapped, and the page stays mapped where it really is.
All of the following was seen on v7.3-rc6+ (g6c377d19d4a5) in KVM guests, as a user without any privilege. It takes a pool of 2 MiB pages with no free page that is not reserved, so that the allocation fails: the user can take or reserve what is free itself.
- The child moves its VMA away. The page is never unmapped, the mapcount stays 2, and the owner goes round retry_avoidcopy in hugetlb_wp() until the child is gone or a page becomes free. SIGKILL to the owner does not end it. 5 of 5 runs.
- The owner's mm has a second private mapping of the offset, made with MAP_NORESERVE. The owner zaps its own entry and reads zeroes where its data was. 5 of 5 runs.
- The child moves its VMA away and maps a 1 GiB hugetlb page at the old address, so this one takes a pool with a 1 GiB page as well. huge_pte_offset() for the 2 MiB size steps through the PUD leaf, so the "PMD table" is the 1 GiB page itself and its "page table lock" is folio->private of that page, which holds 2. Kernels with lock debugging oops in __unmap_hugepage_range(), 7 of 7 runs. Others spin on that word for ever with preemption disabled, 5 of 5 runs:
watchdog: BUG: soft lockup - CPU#0 stuck for 26s! [u_det3:130]
RIP: 0010:queued_spin_lock_slowpath+0x8a/0x290
RAX: 0000000000000002 RBX: ffffea0001000028
Call Trace:
__unmap_hugepage_range+0x154/0x6d0
unmap_hugepage_range+0xc1/0x140
hugetlb_wp+0x55c/0x700
hugetlb_fault+0x5f3/0x8f0RCU stalls follow, and killing all tasks of the user changes nothing. Four such owners, whose children share a single 1 GiB page, took down the whole guest with its four CPUs, 2 of 2 runs: one reported soft lockups on all four, the other gave no sign of life any more.
i_mmap_rwsem stays write locked. With a MAP_PRIVATE mapping of a hugetlbfs file that belongs to another user, and that the attacker can only read, the next mmap() of that file by its owner sleeps uninterruptibly in __mmap_region(), 4 of 4 runs.
Compute the address from the offset for each VMA. The tree walk returns only VMAs that cover pgoff, and vm_start, vm_end and vm_pgoff of a hugetlb VMA are aligned to the huge page size, as pgoff is, so the whole range lies inside iter_vma. Its page tables can not go away there, since the VMA is unlinked from the file under i_mmap_rwsem first.
With the right address the page is unmapped from all VMAs but the owner's, so the retry in hugetlb_wp() finds a mapcount of 1 and reuses the page.
A child that has moved its copy of the VMA now loses the page, and gets SIGBUS when it faults on a missing page of that VMA. That is what the comment above the function has always promised to those who do not own the reservation, and what already happens to a child that has left the VMA in place.
The address has been wrong from the start, and the second case needs only mmap() and fork(). mremap() of hugetlb VMAs, which the other cases use, came with commit 550a7d60bd5e ("mm, hugepages: add mremap() support for hugepage backed vma") in v5.16.
Original fix generated by an LLM and sent in private by Josef.
--- mm/hugetlb.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
mm/hugetlb.c +14 -3
@@ -4067,6 +4067,8 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,struct address_space *mapping;pgoff_t pgoff; +VM_WARN_ON_ONCE (!PageAnon (page)); +/* * vm_pgoff is in PAGE_SIZE units, hence the different calculation * from page cache lookup which is in HPAGE_SIZE units.
@@ -4102,9 +4104,18 @@ static void unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,* could insert a zeroed page instead of the data existing * from the time of fork. This would look like data corruption */ -if (!is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) -unmap_hugepage_range (iter_vma, address, - address +huge_page_size (h), page); +if (is_vma_resv_set (iter_vma,HPAGE_RESV_OWNER )) +continue ; + +/* +* The address in other VMAs can differ. Even though our old +* page is anon, we always operate on the underlying hugetlb +* file. +*/ + address = iter_vma->vm_start + + ((pgoff - iter_vma->vm_pgoff) <<PAGE_SHIFT ); +unmap_hugepage_range (iter_vma, address, + address +huge_page_size (h), page); }i_mmap_unlock_write (mapping); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 849/1848 ipmr, ip6mr: validate packets injected into the register vif on xmit
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ido Schimmel <[email protected]>
[ Upstream commit aa1799e93f5ebb973252aec649d84d12d9c7fd1c ]
reg_vif_xmit() passes the packet to ipmr_cache_report() which copies its IP header into the IGMPMSG_WHOLEPKT report that is queued to the mroute socket. Nothing guarantees that the packet contains a full IP header, so when a short packet is injected on the register device (e.g., using AF_PACKET), the copy reads past the end of the packet and a recvmsg() on the mroute socket leaks the uninitialized bytes to user space [1].
IPv6 has the same problem [2]. Its reg_vif_xmit() does call pskb_inet_may_pull(), but the helper keys off skb->protocol and does not pull anything when the protocol is neither IPv4 nor IPv6.
Fix by dropping packets whose protocol does not match the address family of the register device or that do not contain a full network header.
[1]
BUG: KMSAN: kernel-infoleak in _copy_to_iter raw_recvmsg
Uninit was stored to memory at:
ipmr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 1-3 of 21 are uninitialized
[2]
BUG: KMSAN: kernel-infoleak in _copy_to_iter rawv6_recvmsg
Uninit was stored to memory at:
ip6mr_cache_report
reg_vif_xmit
packet_sendmsg
Uninit was created at:
__alloc_skb
sock_alloc_send_pskb
packet_sendmsg
Bytes 8-23 of 41 are uninitialized
--- net/ipv4/ipmr.c | 6 ++++++ net/ipv6/ip6mr.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-)
net/ipv4/ipmr.c +6 -0
@@ -514,6 +514,12 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, struct net_device *dev) };int err; +if (skb->protocol !=htons (ETH_P_IP ) || !pskb_inet_may_pull (skb)) { +DEV_STATS_INC (dev, tx_errors); +kfree_skb (skb); +return NETDEV_TX_OK ; + } + err =ipmr_fib_lookup (net, &fl4, &mrt);if (err <0 ) {kfree_skb (skb);
net/ipv6/ip6mr.c +1 -1
@@ -601,7 +601,7 @@ static netdev_tx_t reg_vif_xmit(struct sk_buff *skb, .flowi6_mark = skb->mark, }; -if (!pskb_inet_may_pull (skb)) +if (skb->protocol !=htons (ETH_P_IPV6 ) || !pskb_inet_may_pull (skb)) goto tx_err;if (ip6mr_fib_lookup (net, &fl6, &mrt) <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 850/1848 loop: check for read-write open mode on LOOP_SET_STATUS in lo_compat_ioctl()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dominik Maier <[email protected]>
[ Upstream commit 87409eedc543d288cdd49c2174f7d61eca7b8db5 ]
lo_ioctl() checks for (mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN) before allowing LOOP_SET_STATUS or LOOP_SET_STATUS64, but not lo_compat_ioctl(), the handler used by 32-bit user space on 64-bit kernels.
As a result, on 64-bit kernels with CONFIG_COMPAT=y, a 32-bit unprivileged user-space process holding a read-only (O_RDONLY) file descriptor to an active /dev/loopN device can issue a compat LOOP_SET_STATUS ioctl to modify lo_offset, clear lo_sizelimit to 0 (exposing backing-file data past the configured limit), or alter lo_flags.
Enforce the same (mode & BLK_OPEN_WRITE) || capable(CAP_SYS_ADMIN) check on LOOP_SET_STATUS in lo_compat_ioctl().
--- drivers/block/loop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/loop.c +4 -2
@@ -1850,8 +1850,10 @@ static int lo_compat_ioctl(struct block_device *bdev, fmode_t mode,switch (cmd) {case LOOP_SET_STATUS : - err =loop_set_status_compat (lo, - (const struct compat_loop_info __user *)arg); + err = -EPERM ; +if ((mode &FMODE_WRITE ) ||capable (CAP_SYS_ADMIN )) + err =loop_set_status_compat (lo, + (const struct compat_loop_info __user *)arg);break ;case LOOP_GET_STATUS : err = loop_get_status_compat(lo,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 851/1848 mm/page_vma_mapped: continue past nonmatching huge PMDs
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kyle Zeng <[email protected]>
[ Upstream commit 1a2993227e8a27fc4cdea305bbdae82d290bc885 ]
A PTE-mapped large folio can straddle PMD boundaries after an unaligned mremap(). If the first part is discarded and replaced with an unrelated huge PMD, page_vma_mapped_walk() stops instead of looking for the rest of the folio in subsequent PMDs.
This also affects migration entries. A walk that stops at an unrelated huge PMD can leave migration PTEs behind when migration or an anonymous folio split restores the mappings. Those entries do not hold mapping references and can outlive the source folio.
This issue can lead to memory corruption and I have a reproducer for it.
Skip the current PMD rather than ending the walk on a flag or PFN mismatch. Do the same if the PMD became nonpresent before the locked recheck. Release the PMD lock, clear the per-PMD state and advance with step_forward(), so the existing range limit controls termination. This covers present, migration and device-private huge PMDs while preserving the matching-PMD and split-to-PTE paths.
--- mm/page_vma_mapped.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
mm/page_vma_mapped.c +16 -6
@@ -219,9 +219,9 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) pmde = *pvmw->pmd;if (likely (pmd_trans_huge (pmde))) {if (pvmw->flags &PVMW_MIGRATION ) -return not_found (pvmw); + goto next_pmd;if (pmd_page (pmde) != page) -return not_found (pvmw); + goto next_pmd;return true; }if (!pmd_present (pmde)) {
@@ -229,11 +229,11 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)if (!thp_migration_supported () || !(pvmw->flags &PVMW_MIGRATION )) -return not_found (pvmw); + goto next_pmd; entry =pmd_to_swp_entry (pmde);if (!is_migration_entry (entry) ||migration_entry_to_page (entry) != page) -return not_found (pvmw); + goto next_pmd;return true; }/* THP pmd was split under us: handle on pte level */
@@ -251,8 +251,7 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_unlock (ptl); } -step_forward (pvmw,PMD_SIZE ); -continue ; + goto next_pmd; }if (!map_pte (pvmw)) goto next_pte;
@@ -286,6 +285,17 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)spin_lock (pvmw->ptl); } goto this_pte; +next_pmd: +/* +* A large folio can be PTE-mapped across PMDs, so a +* nonmatching PMD does not end the walk. +*/ +if (pvmw->ptl) { +spin_unlock (pvmw->ptl); + pvmw->ptl =NULL ; + } + pvmw->pmd =NULL ; +step_forward (pvmw,PMD_SIZE ); }while (pvmw->address < end);return false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 852/1848 do_splice_to(): move the logics for limiting the read length in
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 313d64a35d36b4bb00edde418179ff1a5f342070 ]
Both callers have the identical logics limiting the amount of data we try to read into pipe - no more than would fit into that pipe. Move that into do_splice_to() itself.
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
fs/splice.c +7 -14
@@ -774,11 +774,16 @@ static long do_splice_to(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags) { + unsigned int p_space;int ret;if (unlikely (!(in->f_mode &FMODE_READ )))return -EBADF ; +/* Don't try to read more the pipe has space for. */ + p_space = pipe->max_usage -pipe_occupancy (pipe->head, pipe->tail); + len =min_t (size_t, len, p_space <<PAGE_SHIFT ); + ret =rw_verify_area (READ , in, ppos, len);if (unlikely (ret <0 ))return ret;
@@ -859,15 +864,10 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,WARN_ON_ONCE (!pipe_empty (pipe->head, pipe->tail));while (len) { -unsigned int p_space;size_t read_len;loff_t pos = sd->pos, prev_pos = pos; -/* Don't try to read more the pipe has space for. */ - p_space = pipe->max_usage - -pipe_occupancy (pipe->head, pipe->tail); - read_len =min_t (size_t, len, p_space <<PAGE_SHIFT ); - ret =do_splice_to (in, &pos, pipe, read_len, flags); + ret =do_splice_to (in, &pos, pipe, len, flags);if (unlikely (ret <=0 )) goto out_release;
@@ -1086,15 +1086,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,pipe_lock (opipe); ret =wait_for_space (opipe, flags); -if (!ret) { -unsigned int p_space; - -/* Don't try to read more the pipe has space for. */ - p_space = opipe->max_usage -pipe_occupancy (opipe->head, opipe->tail); - len =min_t (size_t, len, p_space <<PAGE_SHIFT ); - +if (!ret) ret =do_splice_to (in, &offset, opipe, len, flags); - }pipe_unlock (opipe);if (ret >0 )wakeup_pipe_readers (opipe);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 853/1848 take the guts of file-to-pipe splice into a helper function
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit faa97c48c33454ac0107db930a491b692dd1dff1 ]
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
fs/splice.c +18 -7
@@ -1005,6 +1005,23 @@ static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,struct pipe_inode_info *opipe, size_t len, unsigned int flags); +static long splice_file_to_pipe (struct file *in, +struct pipe_inode_info *opipe, +loff_t *offset, +size_t len,unsigned int flags) +{ +long ret; + +pipe_lock (opipe); + ret =wait_for_space (opipe, flags); +if (!ret) + ret =do_splice_to (in, offset, opipe, len, flags); +pipe_unlock (opipe); +if (ret >0 ) +wakeup_pipe_readers (opipe); +return ret; +} +/* * Determine where to splice to/from. */
@@ -1084,13 +1101,7 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,if (out->f_flags &O_NONBLOCK ) flags |=SPLICE_F_NONBLOCK ; -pipe_lock (opipe); - ret =wait_for_space (opipe, flags); -if (!ret) - ret =do_splice_to (in, &offset, opipe, len, flags); -pipe_unlock (opipe); -if (ret >0 ) -wakeup_pipe_readers (opipe); + ret =splice_file_to_pipe (in, opipe, &offset, len, flags);if (!off_in) in->f_pos = offset;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 854/1848 splice: report related fsnotify events
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chung-Chiang Cheng <[email protected]>
[ Upstream commit 983652c691990b3257a07f67f4263eb847baa82d ]
The fsnotify ACCESS and MODIFY event are missing when manipulating a file with splice(2).
Message-Id: <[email protected]>
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 8 ++++++++ 1 file changed, 8 insertions(+)
fs/splice.c +8 -0
@@ -30,6 +30,7 @@#include <linux/export.h> #include <linux/syscalls.h> #include <linux/uio.h> +#include <linux/fsnotify.h> #include <linux/security.h> #include <linux/gfp.h> #include <linux/socket.h>
@@ -1079,6 +1080,9 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); +if (ret >0 ) +fsnotify_modify (out); +if (!off_out) out->f_pos = offset;else
@@ -1102,6 +1106,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, flags |=SPLICE_F_NONBLOCK ; ret =splice_file_to_pipe (in, opipe, &offset, len, flags); + +if (ret >0 ) +fsnotify_access (in); +if (!off_in) in->f_pos = offset;else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 855/1848 splice: always fsnotify_access(in), fsnotify_modify(out) on success
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahelenia Ziemiańska <[email protected]>
[ Upstream commit 12ee4b66af34f8e72f3b2fd93a946a955efe7c86 ]
The current behaviour caused an asymmetry where some write APIs (write, sendfile) would notify the written-to/read-from objects, but splice wouldn't.
This affected userspace which uses inotify, most notably coreutils tail -f, to monitor pipes.
If the pipe buffer had been filled by a splice-family function:
* tail wouldn't know and thus wouldn't service the pipe, and
* all writes to the pipe would block because it's full,
thus service was denied.
(For the particular case of tail -f this could be worked around
with ---disable-inotify.)
Message-Id: <604ec704d933e0e0121d9e107ce914512e045fad.1688393619.git.nabijaczleweli@nabijaczleweli.xyz>
Stable-dep-of: 79b496ebe382 ("splice: avoid stale f_pos writeback on error")
--- fs/splice.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-)
fs/splice.c +15 -17
@@ -1052,10 +1052,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,if ((in->f_flags | out->f_flags) &O_NONBLOCK ) flags |=SPLICE_F_NONBLOCK ; -return splice_pipe_to_pipe (ipipe, opipe, len, flags); - } - -if (ipipe) { + ret =splice_pipe_to_pipe (ipipe, opipe, len, flags); + }else if (ipipe) {if (off_in)return -ESPIPE ;if (off_out) {
@@ -1080,18 +1078,11 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); -if (ret >0 ) -fsnotify_modify (out); -if (!off_out) out->f_pos = offset;else *off_out = offset; - -return ret; - } - -if (opipe) { + }else if (opipe) {if (off_out)return -ESPIPE ;if (off_in) {
@@ -1107,18 +1098,25 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =splice_file_to_pipe (in, opipe, &offset, len, flags); -if (ret >0 ) -fsnotify_access (in); -if (!off_in) in->f_pos = offset;else *off_in = offset; + }else { + ret = -EINVAL ; + } -return ret; +if (ret >0 ) { +/* +* Generate modify out before access in: +* do_splice_from() may've already sent modify out, +* and this ensures the events get merged. +*/ +fsnotify_modify (out); +fsnotify_access (in); } -return -EINVAL ; +return ret; } static long __do_splice(struct file *in, loff_t __user *off_in,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 856/1848 splice: avoid stale f_pos writeback on error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daehyeon Ko <[email protected]>
[ Upstream commit 79b496ebe382866e3a05090b7dc9ae95e85e65b2 ]
do_splice() snapshots an implicit file position before calling the splice helper. Since splice does not take f_pos_lock, another operation on the same open file description can update f_pos while the helper is blocked. If the helper then fails, the unconditional writeback restores the stale snapshot.
For a directory without ->splice_read, a file-to-pipe splice fails with -EINVAL. A concurrent directory mutation and getdents() call can advance f_pos and refresh the filesystem's revalidation cookie before that failure restores only the old position. The next ext2 readdir can then trust an offset inside a directory entry and copy data from the adjacent page to userspace.
Only update an implicit file position when splice returns a non-negative result, matching read and write. Keep explicit offset updates unchanged.
--- fs/splice.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/splice.c +6 -6
@@ -1078,10 +1078,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =do_splice_from (ipipe, out, &offset, len, flags);file_end_write (out); -if (!off_out) - out->f_pos = offset; -else +if (off_out) *off_out = offset; +else if (ret >=0 ) + out->f_pos = offset; }else if (opipe) {if (off_out)return -ESPIPE ;
@@ -1098,10 +1098,10 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret =splice_file_to_pipe (in, opipe, &offset, len, flags); -if (!off_in) - in->f_pos = offset; -else +if (off_in) *off_in = offset; +else if (ret >=0 ) + in->f_pos = offset; }else { ret = -EINVAL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 857/1848 ALSA: control: Fix UAF in snd_ctl_elem_add() on card disconnect
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit d4febca239be3c91498762dd0535a87d4af1eabc ]
A use-after-free can be triggered via SNDRV_CTL_IOCTL_ELEM_ADD when a USB audio card is disconnected while an ELEM_ADD ioctl is in flight.
The reproducer parks the ioctl thread inside copy_from_user() using userfaultfd, then tears down the USB device. Unlike every other ALSA control _user handler (ELEM_INFO, ELEM_READ, ELEM_WRITE, TLV_*), snd_ctl_elem_add_user() never calls snd_power_ref_and_wait(), so the parked thread holds no power reference. snd_card_disconnect() therefore cannot observe it via snd_power_sync_ref() and proceeds unimpeded:
1. card->shutdown is set to 1
2. device_del(&card->card_dev) drops the kobject reference on the
parent USB interface device (card->dev = &intf->dev)
3. The USB core drops its own reference and calls device_release(), freeing the struct usb_interface, including the embedded struct device that card->dev points to
When the userfaultfd is resolved and the thread resumes, snd_ctl_elem_add() acquires controls_rwsem without checking card->shutdown and calls __snd_ctl_add_replace(). Because the reproducer pre-registered the same control, the CTL_ADD_EXCLUSIVE path calls dev_err(card->dev, ...) on the freed USB interface:
KASAN: slab-use-after-free Read in __dev_printk
Add a card->shutdown guard immediately after acquiring controls_rwsem in snd_ctl_elem_add(). At that point card->shutdown is guaranteed to be stable: snd_card_disconnect() sets it before freeing the parent device, and it never transitions back to 0. A thread that acquired the lock before disconnect sees shutdown=0 and holds the write lock through the rest of the operation, preventing concurrent disconnect from proceeding past its own controls_rwsem-less shutdown=1 store (which happened earlier, outside the lock) from racing with dev_err().
--- sound/core/control.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
sound/core/control.c +4 -1
@@ -1525,7 +1525,10 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,/* This function manage to free the instance on failure. */ down_write (&card->controls_rwsem); - err =__snd_ctl_add_replace (card, kctl,CTL_ADD_EXCLUSIVE ); +if (card->shutdown) + err = -ENODEV ; +else + err =__snd_ctl_add_replace (card, kctl,CTL_ADD_EXCLUSIVE );if (err <0 ) {snd_ctl_free_one (kctl); goto unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 858/1848 mm/madvise: fix data loss from MADV_FREE on a KSM page
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 22d043c1da48d6c7274f9dd900714b6d58b7b9c6 ]
MADV_FREE can clear the dirty flag of a singly mapped KSM folio. The folio remains in the stable tree and can gain new mappings without being dirtied again. Once marked lazyfree, reclaim can discard data that those mappings still need.
KSM always marks a folio dirty when converting it to a KSM folio in try_to_merge_one_page(). Marking a folio lazyfree clears PG_swapbacked but leaves PG_dirty unchanged. Preserving PG_dirty makes reclaim restore PG_swapbacked instead of discarding the folio. This also protects folios that were already lazyfree when KSM converted them.
Skip KSM folios before clearing their dirty flag, checking under the folio lock to serialize with KSM conversion.
--- mm/madvise.c | 9 +++++++++ 1 file changed, 9 insertions(+)
mm/madvise.c +9 -0
@@ -649,6 +649,15 @@ static int madvise_free_pte_range(pmd_t *pmd, unsigned long addr,if (PageSwapCache (page) ||PageDirty (page)) {if (!trylock_page (page))continue ; +/* +* KSM pages can gain new mappings at any time, so we must +* not clear their dirty flag. +*/ +if (PageKsm (page)) { +unlock_page (page); +continue ; + } +/* * If page is shared with others, we couldn't clear * PG_dirty of the page.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 859/1848 ALSA: hwdep: Serialize DSP load requests
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: YuanZhe Liu <[email protected]>
[ Upstream commit aee83c204f80d56b4d55f53acdb8594308ddcd4a ]
The check of the loaded DSP indices and the call of the driver's dsp_load callback in snd_hwdep_dsp_load() are not serialized. A hwdep file descriptor can be shared among threads, or inherited across fork, so two SNDRV_HWDEP_IOCTL_DSP_LOAD requests for the same index can both observe the index as unloaded and enter the driver's callback concurrently, even though the device itself is opened exclusively.
This breaks the assumption behind hw->dsp_loaded that a firmware index is loaded only once. For example, snd-usb-usx2y hits WARN_ON(usx2y->as04.buffer) in usx2y_async_seq04_init() and may allocate the US-428 sequence URBs twice.
Serialize the check, the callback invocation and the bookkeeping with a per-hwdep mutex, so that the second request returns -EBUSY.
5.10 and 5.15 still build with -std=gnu89, so guard() cannot be used after the early returns of this function. Take the mutex explicitly and release it on every exit path instead.
--- include/sound/hwdep.h | 1 + sound/core/hwdep.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-)
include/sound/hwdep.h +1 -0
@@ -57,6 +57,7 @@ struct snd_hwdep {struct mutex open_mutex;int used;/* reference counter */ +struct mutex dsp_mutex;/* serializes DSP load requests */ unsigned int dsp_loaded;/* bit fields of loaded dsp indices */ unsigned int exclusive:1; /* exclusive access mode */ };
sound/core/hwdep.c +10 -4
@@ -211,14 +211,19 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw,return -ENXIO ;if (info->index >=32 )return -EINVAL ; +mutex_lock (&hw->dsp_mutex);/* check whether the dsp was already loaded */ -if (hw->dsp_loaded & (1u << info->index)) -return -EBUSY ; +if (hw->dsp_loaded & (1u << info->index)) { + err = -EBUSY ; + goto unlock; + } err = hw->ops.dsp_load (hw, info);if (err <0 ) -return err; + goto unlock; hw->dsp_loaded |= (1u << info->index); -return 0 ; +unlock: +mutex_unlock (&hw->dsp_mutex); +return err; } static int snd_hwdep_dsp_load_user(struct snd_hwdep *hw,
@@ -376,6 +381,7 @@ int snd_hwdep_new(struct snd_card *card, char *id, int device,init_waitqueue_head (&hwdep->open_wait);mutex_init (&hwdep->open_mutex); +mutex_init (&hwdep->dsp_mutex); hwdep->card = card; hwdep->device = device;if (id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 860/1848 mm/migrate: untag addresses when querying page nodes
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hungyu Lin <[email protected]>
[ Upstream commit 7d8746d7dc9cc4003661011424e5880ea7ae364b ]
When move_pages() is used with nodes == NULL, do_pages_stat_array() uses each page address as-is for its VMA lookup. A valid tagged address therefore gets -EFAULT in its status entry instead of the NUMA node reported for the corresponding untagged address.
Strip the tag before the VMA lookup while holding the mmap read lock. Use untagged_addr(), the helper available in 5.10 and already used by the migration path.
--- mm/migrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/migrate.c +1 -1
@@ -1813,7 +1813,7 @@ static void do_pages_stat_array(struct mm_struct *mm, unsigned long nr_pages,mmap_read_lock (mm);for (i =0 ; i < nr_pages; i++) { -unsigned long addr = (unsigned long )(*pages); +unsigned long addr = (unsigned long )untagged_addr (*pages);struct vm_area_struct *vma;struct page *page;int err = -EFAULT ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 861/1848 x86/init: Initialize wall clock in get_rtc_noop()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Naman Jain <[email protected]>
[ Upstream commit 7d5af1f256fdecff6a7986bbc9146b69cb355bb5 ]
get_rtc_noop() is used when an RTC is unavailable, but leaves its output argument untouched. When CONFIG_INIT_STACK_ALL_ZERO is not enabled, timekeeping_init() may therefore receive a nonzero invalid persistent clock value and warn:
"Persistent clock returned invalid value"
Initialize the output to zero, the documented representation of an unsupported persistent clock.
--- arch/x86/kernel/x86_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/x86_init.c +1 -1
@@ -33,7 +33,7 @@ static void iommu_shutdown_noop(void) { }bool __init bool_x86_init_noop (void ) {return false; }void x86_op_int_noop (int cpu) { }static int set_rtc_noop (const struct timespec64 *now) {return -EINVAL ; } -static void get_rtc_noop (struct timespec64 *now) { } +static void get_rtc_noop (struct timespec64 *now) { *now = (struct timespec64 ){0 }; }static __initconst const struct of_device_id of_cmos_match[] = { { .compatible ="motorola,mc146818" },
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 862/1848 drm/nouveau/pci: use config-space MSI rearm on MCP79/MCP7A (NVAC)
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marek Czernohous <[email protected]>
commit 354d47fb3f35461b7f942831c1b2a7105e92b57f upstream.
NVAC (MCP79/MCP7A) uses g94_pci_func, whose .msi_rearm is nv40_pci_msi_rearm(): a re-arm write through the MMIO mirror of PCI config space. On this IGP that path is unreliable; when a re-arm is missed the interrupt line stays dead, command submission times out and the GPU appears hung until reboot. On an Apple Mac mini (early 2009, MCP79, boot0 0x0ac080b1) this showed as sporadic fifo timeouts and GPU hangs under load unless MSI was disabled via config=NvMSI=0.
Give NVAC its own pci func that re-arms through real PCI config space (nv46_pci_msi_rearm) instead. This follows existing precedent: nv46.c documents the MMIO-mirror re-arm as broken on several related parts, and commit 5112abc6a433 ("drm/nouveau/pci/g92: Fix rearm") fixed g92 the same way while moving the remaining chipsets, NVAC included, into the newly added shared g94 table, where NVAC stayed on the MMIO path. This change completes that fix for NVAC. The sibling IGP NVAA (MCP77/MCP78) has MSI disabled entirely as "reported broken" in nvkm_pci_new_(); NVAC works correctly once the re-arm goes through config space, so disabling MSI is not necessary.
Only NVAC is switched: that is the hardware this has been validated on. The other users of g94_pci_func (G94/G96/G98/GT2xx and the MCP77/MCP89 IGPs) keep their current behavior; MCP77 and MCP89 plausibly want the same treatment but were not tested.
Tested on the Mac mini as a daily driver for two months with MSI enabled and zero fifo timeouts. Independently confirmed stable on an iMac9,1 (MCP79) running 6.12.90 with the v1 form of this change (the same one-line functional switch, applied to that kernel's g94 implementation).
[ Backport note: linux-5.10.y predates commit 2f89bb3264af
("drm/nouveau/pci: add PRI address of config space mirror to nvkm_pci_func"), so struct nvkm_pci_func has no .cfg member here. mcp79_pci_func uses the nv40 .rd32/.wr08/.wr32 accessors instead, exactly as g94_pci_func does in this tree, and still differs from g94_pci_func only in .msi_rearm. This tree also still uses the older (device, index) subdev constructor form, so mcp79_pci_new(), its declaration and the nvac_chipset entry follow g94_pci_new() there. ]
--- .../gpu/drm/nouveau/include/nvkm/subdev/pci.h | 1 + .../gpu/drm/nouveau/nvkm/engine/device/base.c | 2 +- .../gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 1 + .../gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c | 35 +++++++++++++++++++ 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c
drivers/gpu/drm/nouveau/include/nvkm/subdev/pci.h +1 -0
@@ -46,6 +46,7 @@ int nv4c_pci_new(struct nvkm_device *, int, struct nvkm_pci **);int g84_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);int g92_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);int g94_pci_new (struct nvkm_device *,int ,struct nvkm_pci **); +int mcp79_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);int gf100_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);int gf106_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);int gk104_pci_new (struct nvkm_device *,int ,struct nvkm_pci **);
drivers/gpu/drm/nouveau/nvkm/engine/device/base.c +1 -1
@@ -1286,7 +1286,7 @@ nvac_chipset = { .mc = g98_mc_new, .mmu = mcp77_mmu_new, .mxm = nv50_mxm_new, - .pci = g94_pci_new, + .pci = mcp79_pci_new, .therm = g84_therm_new, .timer = nv41_timer_new, .volt = nv40_volt_new,
drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild +1 -0
@@ -9,6 +9,7 @@ nvkm-y += nvkm/subdev/pci/nv4c.o nvkm-y += nvkm/subdev/pci/g84.o nvkm-y += nvkm/subdev/pci/g92.o nvkm-y += nvkm/subdev/pci/g94.o +nvkm-y += nvkm/subdev/pci/mcp79.o nvkm-y += nvkm/subdev/pci/gf100.o nvkm-y += nvkm/subdev/pci/gf106.o nvkm-y += nvkm/subdev/pci/gk104.o
drivers/gpu/drm/nouveau/nvkm/subdev/pci/mcp79.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +/* +* Copyright 2026 Marek Czernohous +* +* MCP79/MCP7A (NVAC): like g94, but MSI re-arm goes through real PCI +* config space. The MMIO-mirror re-arm is unreliable on this IGP and a +* missed re-arm kills the interrupt line (see the nv46 comment; g92 +* already re-arms through config space for the same reason). +*/ +#include "priv.h" + +static const struct nvkm_pci_func +mcp79_pci_func = { + .init = g84_pci_init, + .rd32 = nv40_pci_rd32, + .wr08 = nv40_pci_wr08, + .wr32 = nv40_pci_wr32, + .msi_rearm = nv46_pci_msi_rearm, + + .pcie.init = g84_pcie_init, + .pcie.set_link = g84_pcie_set_link, + + .pcie.max_speed = g84_pcie_max_speed, + .pcie.cur_speed = g84_pcie_cur_speed, + + .pcie.set_version = g84_pcie_set_version, + .pcie.version = g84_pcie_version, + .pcie.version_supported = g92_pcie_version_supported, +}; + +int +mcp79_pci_new (struct nvkm_device *device,int index,struct nvkm_pci **ppci) +{ +return nvkm_pci_new_ (&mcp79_pci_func, device, index, ppci); +}
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 863/1848 udf: validate the device specification EA before using it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yunpeng Tian <[email protected]>
[ Upstream commit 9a2390959685ac35a58c80c8016120849a2babf6 ]
udf_get_extendedattr() bounds an extended attribute only against struct genericFormat, which is 12 bytes. A type-12 device specification is struct deviceSpec, which is 24 bytes plus a flexible impUse array. Thus a corrupted filesystem can contain extended attribute that is accepted by udf_get_extendedattr() but udf_write_inode() or udf_read_inode() may access beyond the end of provided buffer.
Provide a udf_device_spec_valid() check to validate correctness of extended attribute that is a deviceSpec. While here, check the result of udf_add_extendedattr() before dereferencing it as it can return NULL in case of error.
[JK: Removed duplicated validity checks]
--- fs/udf/inode.c | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-)
fs/udf/inode.c +37 -5
@@ -1284,6 +1284,26 @@ int udf_setsize(struct inode *inode, loff_t newsize)return 0 ; } +/* +* Verify validity of struct deviceSpec on disk. udf_get_extendedattr() has +* already verified the generic header and made sure attribute fits in the +* inode so we just have to make sure attribute space is large enough for +* deviceSpec struct and required impUse information. +*/ +static bool udf_device_spec_valid (struct deviceSpec *dsea) +{ +u32 attr_length, imp_use_length; + + attr_length =le32_to_cpu (dsea->attrLength); + imp_use_length =le32_to_cpu (dsea->impUseLength); +if (attr_length <sizeof (struct deviceSpec ) || + imp_use_length <sizeof (struct regid ) || + imp_use_length > attr_length -sizeof (struct deviceSpec )) +return false; + +return true; +} +/* * Maximum length of linked list formed by ICB hierarchy. The chosen number is * arbitrary - just that we hopefully don't limit any real use of rewritten
@@ -1598,13 +1618,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)if (S_ISCHR (inode->i_mode) ||S_ISBLK (inode->i_mode)) {struct deviceSpec *dsea = (struct deviceSpec *)udf_get_extendedattr (inode,12 ,1 ); -if (dsea) { -init_special_inode (inode, inode->i_mode, + +if (!dsea || !udf_device_spec_valid (dsea)) + goto out; +init_special_inode (inode, inode->i_mode,MKDEV (le32_to_cpu (dsea->majorDeviceIdent),le32_to_cpu (dsea->minorDeviceIdent))); -/* Developer ID ??? */ - }else - goto out; } ret =0 ; out:
@@ -1752,6 +1771,10 @@ static int udf_update_inode(struct inode *inode, int do_sync)udf_add_extendedattr (inode,sizeof (struct deviceSpec ) +sizeof (struct regid ),12 ,0x3 ); +if (!dsea) { + err = -ENOSPC ; + goto out_unlock; + } dsea->attrType =cpu_to_le32 (12 ); dsea->attrSubtype =1 ; dsea->attrLength = cpu_to_le32(
@@ -1759,6 +1782,10 @@ static int udf_update_inode(struct inode *inode, int do_sync) sizeof(struct regid)); dsea->impUseLength =cpu_to_le32 (sizeof (struct regid )); } +if (!udf_device_spec_valid (dsea)) { + err = -EFSCORRUPTED ; + goto out_unlock; + } eid = (struct regid *)dsea->impUse;memset (eid,0 ,sizeof (*eid));strcpy (eid->ident,UDF_ID_DEVELOPER );
@@ -1898,6 +1925,11 @@ static int udf_update_inode(struct inode *inode, int do_sync)brelse (bh);return err; + +out_unlock: +unlock_buffer (bh); +brelse (bh); +return err; } struct inode *__udf_iget(struct super_block *sb, struct kernel_lb_addr *ino,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 864/1848 hwmon: (tmp108) Fix jiffies wraparound in conversion-ready check
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Verdonck <[email protected]>
[ Upstream commit 6b8b1d1d7bc7e579b53fc7c3293b787d68de702a ]
tmp108 records a one-shot deadline in ->ready_time at probe (and resume) and, on every temperature read, refuses the read with -EAGAIN while time_before(jiffies, ready_time) is true, in order to skip the initial conversion.
->ready_time is an unsigned long compared with time_before(), whose signed difference is only meaningful while the two values are within LONG_MAX jiffies of each other. Because ->ready_time is set once and never refreshed, jiffies keeps advancing away from it, and after 2^31 jiffies the difference flips sign. On a 32-bit HZ=100 kernel that happens ~248.5 days after boot: time_before() then permanently reports "not ready" and the driver returns -EAGAIN on every read, without ever touching the sensor, until the next reboot. The continuous-mode path, which sets ->ready_time to jiffies with no added conversion delay, wraps the same way.
Store the deadline as a 64-bit jiffies value and compare it with get_jiffies_64()/time_before64(), which does not wrap in any practical uptime.
--- drivers/hwmon/tmp108.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/tmp108.c +4 -4
@@ -73,7 +73,7 @@struct tmp108 {struct regmap *regmap;u16 orig_config; -unsigned long ready_time; +u64 ready_time; };/* convert 12-bit TMP108 register value to milliCelsius */
@@ -124,7 +124,7 @@ static int tmp108_read(struct device *dev, enum hwmon_sensor_types type,switch (attr) {case hwmon_temp_input:/* Is it too early to return a conversion ? */ -if (time_before (jiffies, tmp108->ready_time)) { +if (time_before64 (get_jiffies_64 (), tmp108->ready_time)) {dev_dbg (dev,"%s: Conversion not ready yet..\n" , __func__);return -EAGAIN ;
@@ -371,7 +371,7 @@ static int tmp108_probe(struct i2c_client *client)return err; } - tmp108->ready_time = jiffies; + tmp108->ready_time =get_jiffies_64 ();if ((tmp108->orig_config &TMP108_CONF_MODE_MASK ) ==TMP108_MODE_SHUTDOWN ) tmp108->ready_time +=
@@ -405,7 +405,7 @@ static int __maybe_unused tmp108_resume(struct device *dev) err =regmap_update_bits (tmp108->regmap,TMP108_REG_CONF ,TMP108_CONF_MODE_MASK ,TMP108_MODE_CONTINUOUS ); - tmp108->ready_time = jiffies + + tmp108->ready_time =get_jiffies_64 () +msecs_to_jiffies (TMP108_CONVERSION_TIME_MS );return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 865/1848 dmaengine: qcom: bam_dma: Defer IRQ trigger type to device tree
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishnu Santhosh <[email protected]>
[ Upstream commit 3cee6f79553202d7d3954555560ac38d719344b8 ]
The driver hardcodes IRQF_TRIGGER_HIGH when registering the BAM interrupt, which overrides the trigger type specified in the device tree. On Qualcomm Shikra SoC, the A2 BAM signals an edge interrupt to the apps processor; registering it as level-high causes the interrupt to not fire, resulting in missed DMA completions.
Use IRQF_TRIGGER_NONE instead, which causes the kernel to use the trigger type already configured by platform_get_irq() when it parsed the device tree interrupts property. This makes the driver platform-agnostic.
Stable-dep-of: 82eed160cfa7 ("dmaengine: qcom: bam_dma: free interrupt before the clock in error path")
--- drivers/dma/qcom/bam_dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/qcom/bam_dma.c +1 -1
@@ -1313,7 +1313,7 @@ static int bam_dma_probe(struct platform_device *pdev)bam_channel_init (bdev, &bdev->channels[i], i); ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_HIGH ,"bam_dma" , bdev); +IRQF_TRIGGER_NONE ,"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 866/1848 dmaengine: qcom: bam_dma: free interrupt before the clock in error path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bartosz Golaszewski <[email protected]>
[ Upstream commit 82eed160cfa7a296ae4eb5acb8dd8f493323eea7 ]
The BAM interrupt is requested with a devres helper and so on error it's freed after probe() returns. We disable the clock before freeing or masking it so it may still fire and we may end up reading BAM registers with clock disabled.
Stop using devres for interrupts as we free it in remove() manually anyway. Add an appropriate label and free the interrupt before disabling the clock in error path and in remove().
--- drivers/dma/qcom/bam_dma.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/dma/qcom/bam_dma.c +7 -5
@@ -1312,8 +1312,8 @@ static int bam_dma_probe(struct platform_device *pdev)for (i =0 ; i < bdev->num_channels; i++)bam_channel_init (bdev, &bdev->channels[i], i); - ret =devm_request_irq (bdev->dev, bdev->irq, bam_dma_irq, -IRQF_TRIGGER_NONE ,"bam_dma" , bdev); + ret =request_irq (bdev->irq, bam_dma_irq,IRQF_TRIGGER_NONE , +"bam_dma" , bdev);if (ret) goto err_bam_channel_exit;
@@ -1322,7 +1322,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_set_max_seg_size (bdev->common.dev,BAM_FIFO_SIZE );if (ret) {dev_err (bdev->dev,"cannot set maximum segment size\n" ); - goto err_bam_channel_exit; + goto err_free_irq; }platform_set_drvdata (pdev, bdev);
@@ -1350,7 +1350,7 @@ static int bam_dma_probe(struct platform_device *pdev) ret =dma_async_device_register (&bdev->common);if (ret) {dev_err (bdev->dev,"failed to register dma async device\n" ); - goto err_bam_channel_exit; + goto err_free_irq; } ret = of_dma_controller_register(pdev->dev.of_node, bam_dma_xlate,
@@ -1374,6 +1374,8 @@ static int bam_dma_probe(struct platform_device *pdev) err_unregister_dma:dma_async_device_unregister (&bdev->common); +err_free_irq: +free_irq (bdev->irq, bdev); err_bam_channel_exit:for (i =0 ; i < bdev->num_channels; i++)tasklet_kill (&bdev->channels[i].vc.task);
@@ -1399,7 +1401,7 @@ static int bam_dma_remove(struct platform_device *pdev)/* mask all interrupts for this execution environment */ writel_relaxed (0 ,bam_addr (bdev,0 ,BAM_IRQ_SRCS_MSK_EE )); -devm_free_irq (bdev->dev, bdev->irq, bdev); +free_irq (bdev->irq, bdev);for (i =0 ; i < bdev->num_channels; i++) {bam_dma_terminate_all (&bdev->channels[i].vc.chan);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 867/1848 nilfs2: ignore non-fatal signals during synchronous log write wait
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryusuke Konishi <[email protected]>
[ Upstream commit 7131aaa74bcc7c9da1f1d1c8724da75c775557a0 ]
Based on a syzbot report, Wang Jianjian pointed out that following a successful directory operation in nilfs_rename(), a synchronous write requested within nilfs_transaction_commit(), triggered by a sync flag set by nilfs_commit_chunk(), could be interrupted by a user signal. This interruption leaves in-memory metadata updates intact while returning an error, causing inconsistency with the VFS dentry cache and ultimately triggering a kernel warning.
According to "signal(7)", local disks are not classified as "slow devices" (such as terminals, FIFOs, or pipes) and their I/O operations on disk devices are not interrupted by signals. In kernel space, waiting for such disk I/O should therefore not be aborted by ordinary (non-fatal) signals.
Suppress this issue by modifying nilfs_segctor_sync(), which waits for the log writer thread to complete synchronous writes, to catch only fatal signals via fatal_signal_pending() and return -EINTR rather than -ERESTARTSYS. To complement this change and prevent the wait loop from busy-looping when schedule() returns immediately due to a pending non-fatal signal, switch the wait state from TASK_INTERRUPTIBLE to TASK_KILLABLE.
This serves as an effective interim stabilization measure without structural changes until a comprehensive fix for metadata consistency is implemented.
--- fs/nilfs2/ioctl.c | 2 +- fs/nilfs2/recovery.c | 2 +- fs/nilfs2/segment.c | 10 +++++----- 3 files changed, 7 insertions(+), 7 deletions(-)
fs/nilfs2/ioctl.c +1 -1
@@ -1011,7 +1011,7 @@ static int nilfs_ioctl_clean_segments(struct inode *inode, struct file *filp,* * %-ENOSPC - No space left on device (only in a panic state). * -* %-ERESTARTSYS - Interrupted. +* %-EINTR - Interrupted. * * %-ENOMEM - Insufficient memory available. *
fs/nilfs2/recovery.c +1 -1
@@ -750,7 +750,7 @@ static void nilfs_abort_roll_forward(struct the_nilfs *nilfs)* * %-ENOSPC - No space left on device (only in a panic state). * -* %-ERESTARTSYS - Interrupted. +* %-EINTR - Interrupted. * * %-ENOMEM - Insufficient memory available. */
fs/nilfs2/segment.c +5 -5
@@ -2236,7 +2236,7 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci)wake_up (&sci->sc_wait_daemon);for (;;) { -set_current_state (TASK_INTERRUPTIBLE ); +set_current_state (TASK_KILLABLE );/* * Synchronize only while the log writer thread is alive.
@@ -2250,11 +2250,11 @@ static int nilfs_segctor_sync(struct nilfs_sc_info *sci) err = wait_req.err;break ; } -if (!signal_pending (current)) { +if (!fatal_signal_pending (current)) {schedule ();continue ; } - err = -ERESTARTSYS ; + err = -EINTR ;break ; }finish_wait (&sci->sc_wait_request, &wait_req.wq);
@@ -2295,7 +2295,7 @@ static void nilfs_segctor_wakeup(struct nilfs_sc_info *sci, int err, bool force)* * %-ENOSPC - No space left on device (only in a panic state). * -* %-ERESTARTSYS - Interrupted. +* %-EINTR - Interrupted. * * %-ENOMEM - Insufficient memory available. */
@@ -2332,7 +2332,7 @@ int nilfs_construct_segment(struct super_block *sb)* * %-ENOSPC - No space left on device (only in a panic state). * -* %-ERESTARTSYS - Interrupted. +* %-EINTR - Interrupted. * * %-ENOMEM - Insufficient memory available. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 868/1848 ASoC: stm32: i2s: remove irqf_oneshot flag
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Olivier Moysan <[email protected]>
[ Upstream commit 7c0f8f1462c9edeaa202a2cbea1bde0960434b09 ]
The IRQF_ONESHOT flag allows to ensure that the interrupt is not unmasked after the hard interrupt context handler has been executed and the thread has been woken. The interrupt line is unmasked after the thread handler function has been executed.
The STM32 I2S driver does not implement a threaded IRQ handler. So, the IRQF_ONESHOT flag is not useful in I2S driver. Remove this flag to allow the interrupt routine to be managed as a thread in RT mode.
Stable-dep-of: 1b207c85551f ("ASoC: stm: stm32_i2s: request IRQ after regmap initialization")
--- sound/soc/stm/stm32_i2s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/stm/stm32_i2s.c +1 -1
@@ -854,7 +854,7 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,if (irq <0 )return irq; - ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,IRQF_ONESHOT , + ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 ,dev_name (&pdev->dev), i2s);if (ret) {dev_err (&pdev->dev,"irq request returned %d\n" , ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 869/1848 ASoC: stm: stm32_i2s: Drop redundant error messages
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit a6cdfb6230944082e7be64f9166eed64656b1162 ]
Both devm_request_irq() and snd_dmaengine_pcm_register() already log failures internally. Drop the redundant error messages and return the original errors directly.
Stable-dep-of: 1b207c85551f ("ASoC: stm: stm32_i2s: request IRQ after regmap initialization")
--- sound/soc/stm/stm32_i2s.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
sound/soc/stm/stm32_i2s.c +2 -4
@@ -856,10 +856,8 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev, ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 ,dev_name (&pdev->dev), i2s); -if (ret) { -dev_err (&pdev->dev,"irq request returned %d\n" , ret); +if (ret)return ret; - }/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );
@@ -914,7 +912,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret) -return dev_err_probe (&pdev->dev, ret,"PCM DMA register error\n" ); +return ret; ret =snd_soc_register_component (&pdev->dev, &stm32_i2s_component, i2s->dai_drv,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 870/1848 ASoC: stm: stm32_i2s: request IRQ after regmap initialization
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 1b207c85551fd74854d632116849295b2305245f ]
The ISR accesses the managed regmap, but probe requests the IRQ before creating it. An early interrupt can reach an uninitialized regmap. Reverse-order cleanup can free the regmap while the IRQ remains active.
Request the IRQ after regmap initialization so probe unwind and removal free and synchronize it before releasing the regmap.
The teardown ordering issue was found by static analysis.
--- sound/soc/stm/stm32_i2s.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-)
sound/soc/stm/stm32_i2s.c +10 -12
@@ -810,7 +810,6 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,const struct of_device_id *of_id;struct reset_control *rst;struct resource *res; -int irq, ret;if (!np)return -ENODEV ;
@@ -849,16 +848,6 @@ static int stm32_i2s_parse_dt(struct platform_device *pdev,return dev_err_probe (&pdev->dev,PTR_ERR (i2s->x11kclk),"Could not get x11k parent clock\n" ); -/* Get irqs */ - irq =platform_get_irq (pdev,0 ); -if (irq <0 ) -return irq; - - ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , -dev_name (&pdev->dev), i2s); -if (ret) -return ret; -/* Reset */ rst =devm_reset_control_get_optional_exclusive (&pdev->dev,NULL );if (IS_ERR (rst))
@@ -884,7 +873,7 @@ static int stm32_i2s_probe(struct platform_device *pdev) {struct stm32_i2s_data *i2s;u32 val; -int ret; +int irq, ret; i2s =devm_kzalloc (&pdev->dev,sizeof (*i2s),GFP_KERNEL );if (!i2s)
@@ -910,6 +899,15 @@ static int stm32_i2s_probe(struct platform_device *pdev)return dev_err_probe (&pdev->dev,PTR_ERR (i2s->regmap),"Regmap init error\n" ); + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + + ret =devm_request_irq (&pdev->dev, irq, stm32_i2s_isr,0 , +dev_name (&pdev->dev), i2s); +if (ret) +return ret; + ret =snd_dmaengine_pcm_register (&pdev->dev, &stm32_i2s_pcm_config,0 );if (ret)return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 871/1848 media: vpif_capture: Fix i2c adapter reference leak in vpif_probe()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit b00fbdad64d4ea7d594bc67988c1722fe5b3be50 ]
vpif_probe() takes a reference to the i2c adapter with i2c_get_adapter() and passes it to v4l2_i2c_new_subdev_board(), which does not consume it, but the reference is never released, so it is leaked both when the probe succeeds and when it fails after the adapter has been acquired.
Release the reference with i2c_put_adapter() on the success path and in the probe_subdev_out cleanup, and initialise i2c_adap so that the cleanup is a no-op when the adapter was never acquired.
--- drivers/media/platform/davinci/vpif_capture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/davinci/vpif_capture.c +4 -1
@@ -1617,7 +1617,7 @@ vpif_capture_get_pdata(struct platform_device *pdev)static int vpif_probe (struct platform_device *pdev) {struct vpif_subdev_info *subdevdata; -struct i2c_adapter *i2c_adap; +struct i2c_adapter *i2c_adap =NULL ;struct resource *res;int subdev_count;int res_idx =0 ;
@@ -1701,9 +1701,12 @@ static int vpif_probe(struct platform_device *pdev) } } +i2c_put_adapter (i2c_adap); +return 0 ; probe_subdev_out: +i2c_put_adapter (i2c_adap);/* free sub devices memory */ kfree (vpif_obj.sd); vpif_unregister:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 872/1848 dm-writecache: report I/O error if flush failed
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
[ Upstream commit 78a6afc2999d26e5a30a56db77db34c22b88f5d5 ]
There was a bug that if writecache_flush fails due to I/O error, the error is not reported in the FUA bio. This commit fixes it.
--- drivers/md/dm-writecache.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/md/dm-writecache.c +5 -2
@@ -1454,10 +1454,13 @@ static int writecache_map(struct dm_target *ti, struct bio *bio) }while (bio->bi_iter.bi_size);if (unlikely (bio->bi_opf &REQ_FUA || - wc->uncommitted_blocks >= wc->autocommit_blocks)) + wc->uncommitted_blocks >= wc->autocommit_blocks)) {writecache_flush (wc); -else +if (writecache_has_error (wc)) + bio->bi_status =BLK_STS_IOERR ; + }else {writecache_schedule_autocommit (wc); + } goto unlock_submit; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 873/1848 ata: sata_inic162x: remove dangerous broken driver
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ethan Nelson-Moore <[email protected]>
[ Upstream commit 96fdeb7e3fd8d937f8351ed90824c9d904e590a1 ]
The sata_inic162x driver was labeled as "very experimental" in commit bb9696192826 ("libata: make it clear that sata_inic162x is experimental") due to data corruption issues, but not marked as broken. Since then, no changes have been made to it that could fix these issues. Since the driver was not marked as broken, and the message about potential data corruption is only visible in the code and dmesg, it is possible that someone could enable the driver without realizing its potential for data corruption. Remove the driver to protect users' data.
--- drivers/ata/Kconfig | 7 - drivers/ata/Makefile | 1 - drivers/ata/sata_inic162x.c | 906 ------------------------------------ 3 files changed, 914 deletions(-) delete mode 100644 drivers/ata/sata_inic162x.c
drivers/ata/Kconfig +0 -7
@@ -318,13 +318,6 @@ config SATA_AHCI_SEATTLE If unsure, say N -config SATA_INIC162X - tristate "Initio 162x SATA support (Very Experimental)" - depends on PCI - select SATA_HOST - help - This option enables support for Initio 162x Serial ATA. - config SATA_ACARD_AHCI tristate "ACard AHCI variant (ATP 8620)" depends on PCI
drivers/ata/Makefile +0 -1
@@ -9,7 +9,6 @@ obj-$(CONFIG_SATA_AHCI_SEATTLE) += ahci_seattle.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o obj-$(CONFIG_SATA_FSL) += sata_fsl.o obj-$(CONFIG_SATA_GEMINI) += sata_gemini.o -obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o obj-$(CONFIG_SATA_SIL24) += sata_sil24.o obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
drivers/ata/sata_inic162x.c deleted +0 -906
906 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 874/1848 mm/madvise: use folio_trylock() in the cold/pageout PMD split
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gregory Price <[email protected]>
[ Upstream commit 5a6c9cf117fca3c38a98fb2a2d5549795c8b0b73 ]
MADV_COLD or MADV_PAGEOUT over part of a PMD splits the THP in madvise_cold_or_pageout_pte_range(). Two threads doing that to the same THP create spurious failures.
CPU0 CPU1
---- ----
folio_get()
spin_unlock(ptl)
folio_lock()
folio_get() spin_unlock(ptl) folio_lock() <- blocks, keeps its ref
split_folio()
folio_expected_ref_count(folio) != folio_ref_count(folio) - 1
-EAGAINCPU1 cannot drop its reference until it gets the lock CPU0 holds, so CPU0's split always fails. folio_trylock() makes CPU1 leave without ever taking a reference. The PTE branch of this same function already does this, as do madvise_free_pte_range() and madvise_free_huge_pmd().
Reproducer: 400 rounds of eight threads calling MADV_COLD on half of each of eight THPs, re-formed with MADV_COLLAPSE between rounds. From /proc/vmstat:
thp_split_page thp_split_page_failed
before 3186 860
after 3200 0
The short before count is rounds where every thread failed and the advice was dropped for that THP entirely.
On failure the walker returns 0 and nothing retries. The PMD path becomes best effort when the folio lock is held elsewhere - same as the PTE path.
--- mm/madvise.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/madvise.c +2 -1
@@ -349,9 +349,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,if (next - addr !=HPAGE_PMD_SIZE ) {int err; +if (!trylock_page (page)) + goto huge_unlock;get_page (page);spin_unlock (ptl); -lock_page (page); err =split_huge_page (page);unlock_page (page);put_page (page);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 875/1848 ALSA: line6: Handle period elapsed calls outside the locks
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 443ed4edc2678cc51c5a01e7dffc4c890be40051 ]
LINE6 driver may call snd_pcm_period_elapsed() for both playback and capture substreams at processing the playback substream, and this may lead to a ABBA deadlock.
Move the actual calls of snd_pcm_period_elapsed() outside the locks for avoiding it. The capture period notification at submitting the initial playback URBs (only with the impulse mode) is simply skipped, as it's done in the lock context; it'll be caught up at the next period.
--- sound/usb/line6/capture.c | 17 +++++++++-------- sound/usb/line6/capture.h | 2 +- sound/usb/line6/playback.c | 31 +++++++++++++++++++++---------- 3 files changed, 31 insertions(+), 19 deletions(-)
sound/usb/line6/capture.c +9 -8
@@ -137,18 +137,15 @@ void line6_capture_copy(struct snd_line6_pcm *line6pcm, char *fbuf, int fsize) line6pcm->in.pos_done -= runtime->buffer_size; } -void line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) +/* update the capture position and check whether we need period_elapsed call */ +bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length) { -struct snd_pcm_substream *substream = -get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE ); - line6pcm->in.bytes += length;if (line6pcm->in.bytes >= line6pcm->in.period) { line6pcm->in.bytes %= line6pcm->in.period; -spin_unlock (&line6pcm->in.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->in.lock); +return true; } +return false; }/*
@@ -158,6 +155,7 @@ static void audio_in_callback(struct urb *urb) {int i, index, length =0 , shutdown =0 ;unsigned long flags; +bool capture_period_elapsed = false;struct snd_line6_pcm *line6pcm = (struct snd_line6_pcm *)urb->context;
@@ -221,10 +219,13 @@ static void audio_in_callback(struct urb *urb)if (!test_bit (LINE6_STREAM_IMPULSE , &line6pcm->in.running) &&test_bit (LINE6_STREAM_PCM , &line6pcm->in.running)) -line6_capture_check_period (line6pcm, length); + capture_period_elapsed =line6_capture_check_period (line6pcm, length); }spin_unlock_irqrestore (&line6pcm->in.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); }/* open capture callback */
sound/usb/line6/capture.h +1 -1
@@ -17,7 +17,7 @@ extern const struct snd_pcm_ops snd_line6_capture_ops;extern void line6_capture_copy (struct snd_line6_pcm *line6pcm,char *fbuf,int fsize); -extern void line6_capture_check_period (struct snd_line6_pcm *line6pcm, +extern bool line6_capture_check_period (struct snd_line6_pcm *line6pcm,int length);extern int line6_create_audio_in_urbs (struct snd_line6_pcm *line6pcm);extern int line6_submit_audio_in_all_urbs (struct snd_line6_pcm *line6pcm);
sound/usb/line6/playback.c +21 -10
@@ -136,6 +136,8 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,/* Find a free URB, prepare audio data, and submit URB. must be called in line6pcm->out.lock context +Returns 1 if snd_pcm_period_elapsed() needs to be called for the +capture stream after releasing the lock, 0 if not, or a negative error */ static int submit_audio_out_urb (struct snd_line6_pcm *line6pcm) {
@@ -151,6 +153,7 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) line6pcm->properties->rates.rats[0 ].den * (line6pcm->line6->intervals_per_second /LINE6_ISO_INTERVAL );struct urb *urb_out; +bool capture_period_elapsed = false; index =find_first_zero_bit (&line6pcm->out.active_urbs, line6pcm->line6->iso_buffers);
@@ -260,8 +263,9 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm) urb_out->transfer_buffer, urb_out-> transfer_buffer_length); -line6_capture_check_period (line6pcm, - urb_out->transfer_buffer_length); + capture_period_elapsed = +line6_capture_check_period (line6pcm, + urb_out->transfer_buffer_length); } }else { if (!(line6pcm->line6->properties->capabilities & LINE6_CAP_HWMON)
@@ -283,24 +287,26 @@ static int submit_audio_out_urb(struct snd_line6_pcm *line6pcm)dev_err (line6pcm->line6->ifcdev,"URB out #%d submission failed (%d)\n" , index, ret); -return 0 ; +return capture_period_elapsed; }/* Submit all currently available playback URBs. must be called in line6pcm->out.lock context +The capture period notification is skipped here since we can't call +snd_pcm_period_elapsed() in the lock; it'll be caught up at the next one. */ int line6_submit_audio_out_all_urbs (struct snd_line6_pcm *line6pcm) { -int ret =0 , i; +int ret, i;for (i =0 ; i < line6pcm->line6->iso_buffers; ++i) { ret =submit_audio_out_urb (line6pcm);if (ret <0 ) -break ; +return ret; } -return ret; +return 0 ; }/*
@@ -316,6 +322,8 @@ static void audio_out_callback(struct urb *urb)const int bytes_per_frame = line6pcm->properties->bytes_per_channel * line6pcm->properties->playback_hw.channels_max; +bool capture_period_elapsed = false; +bool playback_period_elapsed = false;#if USE_CLEAR_BUFFER_WORKAROUND memset (urb->transfer_buffer,0 , urb->transfer_buffer_length);
@@ -358,19 +366,22 @@ static void audio_out_callback(struct urb *urb) shutdown =1 ;if (!shutdown) { -submit_audio_out_urb (line6pcm); + capture_period_elapsed =submit_audio_out_urb (line6pcm) >0 ;if (test_bit (LINE6_STREAM_PCM , &line6pcm->out.running)) { line6pcm->out.bytes += length;if (line6pcm->out.bytes >= line6pcm->out.period) { line6pcm->out.bytes %= line6pcm->out.period; -spin_unlock (&line6pcm->out.lock); -snd_pcm_period_elapsed (substream); -spin_lock (&line6pcm->out.lock); + playback_period_elapsed = true; } } }spin_unlock_irqrestore (&line6pcm->out.lock, flags); + +if (capture_period_elapsed) +snd_pcm_period_elapsed (get_substream (line6pcm,SNDRV_PCM_STREAM_CAPTURE )); +if (playback_period_elapsed) +snd_pcm_period_elapsed (substream); }/* open playback callback */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 876/1848 PCI: rockchip-host: Do not attempt 5.0 GT/s retraining
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geraldo Nascimento <[email protected]>
[ Upstream commit 2a1e6c382fb7567679c07bd6a7060fefc7a5edc9 ]
Drop the 5.0 GT/s Link Speed retraining from Rockchip PCIe Root Complex Mode Operation, so-called host driver.
The reason is that Shawn Lin from Rockchip has reiterated that there may be danger of "catastrophic failure" in using their PCIe with 5.0GT/s speeds.
While Rockchip has done so informally without issuing a proper errata, and the particulars are thus unknown, this may cause data loss or worse.
This change is corroborated by RK3399 official datasheet [1], which states maximum link speed for this platform is 2.5 GT/s.
[1] https://opensource.rock-chips.com/images/d/d7/Rockchip_RK3399_Datasheet_V2.1-20200323.pdf
--- drivers/pci/controller/pcie-rockchip-host.c | 16 ---------------- 1 file changed, 16 deletions(-)
drivers/pci/controller/pcie-rockchip-host.c +0 -16
@@ -339,22 +339,6 @@ static int rockchip_pcie_host_init_port(struct rockchip_pcie *rockchip) goto err_power_off_phy; } -if (rockchip->link_gen ==2 ) { -/* -* Enable retrain for gen2. This should be configured only after -* gen1 finished. -*/ - status =rockchip_pcie_read (rockchip,PCIE_RC_CONFIG_LCS ); - status |=PCI_EXP_LNKCTL_RL ; -rockchip_pcie_write (rockchip, status,PCIE_RC_CONFIG_LCS ); - - err =readl_poll_timeout (rockchip->apb_base +PCIE_CORE_CTRL , - status,PCIE_LINK_IS_GEN2 (status),20 , -500 *USEC_PER_MSEC ); -if (err) -dev_dbg (dev,"PCIe link training gen2 timeout, fall back to gen1!\n" ); - } -/* Check the final link width from negotiated lane counter from MGMT */ status =rockchip_pcie_read (rockchip,PCIE_CORE_CTRL ); status = 0x1 << ((status & PCIE_CORE_PL_CONF_LANE_MASK) >>
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 877/1848 mfd: ab8500: Drop bm disable parameter
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linus Walleij <[email protected]>
[ Upstream commit a98688d2ddfe274cb7c7ca3c6b6afbe9f844ffc3 ]
Nobody is passing the module parameter to disable the battery management portions so just drop this parameter.
Stable-dep-of: 5bf2ae8b131d ("mfd: ab8500: Fix child device leaks on probe failure")
--- drivers/mfd/ab8500-core.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
drivers/mfd/ab8500-core.c +6 -14
@@ -122,12 +122,6 @@static DEFINE_SPINLOCK (on_stat_lock);static u8 turn_on_stat_mask =0xFF ;static u8 turn_on_stat_set; -static bool no_bm;/* No battery management */ -/* -* not really modular, but the easiest way to keep compat with existing -* bootargs behaviour is to continue using module_param here. -*/ -module_param (no_bm, bool,S_IRUGO );#define AB9540_MODEM_CTRL2_REG 0x23#define AB9540_MODEM_CTRL2_SWDBBRSTN_BIT BIT(2)
@@ -1256,14 +1250,12 @@ static int ab8500_probe(struct platform_device *pdev)if (ret)return ret; -if (!no_bm) { -/* Add battery management devices */ - ret =mfd_add_devices (ab8500->dev,0 , ab8500_bm_devs, -ARRAY_SIZE (ab8500_bm_devs),NULL , -0 , ab8500->domain); -if (ret) -dev_err (ab8500->dev,"error adding bm devices\n" ); - } +/* Add battery management devices */ + ret =mfd_add_devices (ab8500->dev,0 , ab8500_bm_devs, +ARRAY_SIZE (ab8500_bm_devs),NULL , +0 , ab8500->domain); +if (ret) +dev_err (ab8500->dev,"error adding bm devices\n" );if (((is_ab8505 (ab8500) ||is_ab9540 (ab8500)) && ab8500->chip_id >=AB8500_CUT2P0 ) ||is_ab8540 (ab8500))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 878/1848 mfd: ab8500: Fix child device leaks on probe failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 5bf2ae8b131d4ae9c0ed5f7aa02532645f512022 ]
ab8500_probe() registers MFD child devices before completing the remaining device initialization. If a later MFD registration or sysfs group creation fails, previously registered child devices are not removed.
Use devm_mfd_add_devices() so registered MFD child devices are removed when probe fails.
The issue was identified by a static analysis tool I developed and confirmed by manual review.
--- drivers/mfd/ab8500-core.c | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-)
drivers/mfd/ab8500-core.c +23 -21
@@ -1221,39 +1221,41 @@ static int ab8500_probe(struct platform_device *pdev)return ret;if (is_ab9540 (ab8500)) - ret =mfd_add_devices (ab8500->dev,0 , ab9540_devs, -ARRAY_SIZE (ab9540_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab9540_devs, +ARRAY_SIZE (ab9540_devs),NULL , +0 , ab8500->domain);else if (is_ab8540 (ab8500)) { - ret =mfd_add_devices (ab8500->dev,0 , ab8540_devs, -ARRAY_SIZE (ab8540_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8540_devs, +ARRAY_SIZE (ab8540_devs),NULL , +0 , ab8500->domain);if (ret)return ret;if (is_ab8540_1p2_or_earlier (ab8500)) - ret =mfd_add_devices (ab8500->dev,0 , ab8540_cut1_devs, -ARRAY_SIZE (ab8540_cut1_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , + ab8540_cut1_devs, +ARRAY_SIZE (ab8540_cut1_devs), +NULL ,0 , ab8500->domain);else /* ab8540 >= cut2 */ - ret =mfd_add_devices (ab8500->dev,0 , ab8540_cut2_devs, -ARRAY_SIZE (ab8540_cut2_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , + ab8540_cut2_devs, +ARRAY_SIZE (ab8540_cut2_devs), +NULL ,0 , ab8500->domain); }else if (is_ab8505 (ab8500)) - ret =mfd_add_devices (ab8500->dev,0 , ab8505_devs, -ARRAY_SIZE (ab8505_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8505_devs, +ARRAY_SIZE (ab8505_devs),NULL , +0 , ab8500->domain);else - ret =mfd_add_devices (ab8500->dev,0 , ab8500_devs, -ARRAY_SIZE (ab8500_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8500_devs, +ARRAY_SIZE (ab8500_devs),NULL , +0 , ab8500->domain);if (ret)return ret;/* Add battery management devices */ - ret =mfd_add_devices (ab8500->dev,0 , ab8500_bm_devs, -ARRAY_SIZE (ab8500_bm_devs),NULL , -0 , ab8500->domain); + ret =devm_mfd_add_devices (ab8500->dev,0 , ab8500_bm_devs, +ARRAY_SIZE (ab8500_bm_devs),NULL , +0 , ab8500->domain);if (ret)dev_err (ab8500->dev,"error adding bm devices\n" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 879/1848 mfd: twl: Remove platform data support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 4a346a03a63cb45f7766d9d6559cf3fee783e926 ]
There is no in-tree machine that provides a struct twl4030_platform_data since commit e92fc4f04a34 ("ARM: OMAP2+: Drop legacy board file for LDP"). So assume dev_get_platdata() returns NULL in twl_probe() and simplify accordingly.
Stable-dep-of: 3c5c55d979dd ("mfd: twl-core: Unregister the auxiliary platform device on unbind")
--- drivers/mfd/twl-core.c | 323 +--------------------------------------- include/linux/mfd/twl.h | 55 ------- 2 files changed, 5 insertions(+), 373 deletions(-)
drivers/mfd/twl-core.c +5 -318
@@ -656,309 +656,6 @@ static inline struct device *add_child(unsigned mod_no, const char *name, can_wakeup, irq0, irq1); } -static struct device * -add_regulator_linked (int num,struct regulator_init_data *pdata, -struct regulator_consumer_supply *consumers, -unsigned num_consumers,unsigned long features) -{ -struct twl_regulator_driver_data drv_data; - -/* regulator framework demands init_data ... */ -if (!pdata) -return NULL ; - -if (consumers) { - pdata->consumer_supplies = consumers; - pdata->num_consumer_supplies = num_consumers; - } - -if (pdata->driver_data) { -/* If we have existing drv_data, just add the flags */ -struct twl_regulator_driver_data *tmp; - tmp = pdata->driver_data; - tmp->features |= features; - }else { -/* add new driver data struct, used only during init */ - drv_data.features = features; - drv_data.set_voltage =NULL ; - drv_data.get_voltage =NULL ; - drv_data.data =NULL ; - pdata->driver_data = &drv_data; - } - -/* NOTE: we currently ignore regulator IRQs, e.g. for short circuits */ -return add_numbered_child (TWL_MODULE_PM_MASTER ,"twl_reg" , num, - pdata,sizeof (*pdata), false,0 ,0 ); -} - -static struct device * -add_regulator (int num,struct regulator_init_data *pdata, -unsigned long features) -{ -return add_regulator_linked (num, pdata,NULL ,0 , features); -} - -/* -* NOTE: We know the first 8 IRQs after pdata->base_irq are -* for the PIH, and the next are for the PWR_INT SIH, since -* that's how twl_init_irq() sets things up. -*/ - -static int -add_children (struct twl4030_platform_data *pdata,unsigned irq_base, -unsigned long features) -{ -struct device *child; - -if (IS_ENABLED (CONFIG_GPIO_TWL4030 ) && pdata->gpio) { - child =add_child (TWL4030_MODULE_GPIO ,"twl4030_gpio" , - pdata->gpio,sizeof (*pdata->gpio), - false, irq_base +GPIO_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_KEYBOARD_TWL4030 ) && pdata->keypad) { - child =add_child (TWL4030_MODULE_KEYPAD ,"twl4030_keypad" , - pdata->keypad,sizeof (*pdata->keypad), - true, irq_base +KEYPAD_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_TWL4030_MADC ) && pdata->madc && -twl_class_is_4030 ()) { - child =add_child (TWL4030_MODULE_MADC ,"twl4030_madc" , - pdata->madc,sizeof (*pdata->madc), - true, irq_base +MADC_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_RTC_DRV_TWL4030 )) { -/* -* REVISIT platform_data here currently might expose the -* "msecure" line ... but for now we just expect board -* setup to tell the chip "it's always ok to SET_TIME". -* Eventually, Linux might become more aware of such -* HW security concerns, and "least privilege". -*/ - child =add_child (TWL_MODULE_RTC ,"twl_rtc" ,NULL ,0 , - true, irq_base +RTC_INTR_OFFSET ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_PWM_TWL )) { - child =add_child (TWL_MODULE_PWM ,"twl-pwm" ,NULL ,0 , - false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_PWM_TWL_LED )) { - child =add_child (TWL_MODULE_LED ,"twl-pwmled" ,NULL ,0 , - false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_TWL4030_USB ) && pdata->usb && -twl_class_is_4030 ()) { - -static struct regulator_consumer_supply usb1v5 = { - .supply ="usb1v5" , - }; -static struct regulator_consumer_supply usb1v8 = { - .supply ="usb1v8" , - }; -static struct regulator_consumer_supply usb3v1 = { - .supply ="usb3v1" , - }; - -/* First add the regulators so that they can be used by transceiver */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 )) { -/* this is a template that gets copied */ -struct regulator_init_data usb_fixed = { - .constraints.valid_modes_mask = -REGULATOR_MODE_NORMAL - |REGULATOR_MODE_STANDBY , - .constraints.valid_ops_mask = -REGULATOR_CHANGE_MODE - |REGULATOR_CHANGE_STATUS , - }; - - child =add_regulator_linked (TWL4030_REG_VUSB1V5 , - &usb_fixed, &usb1v5,1 , - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator_linked (TWL4030_REG_VUSB1V8 , - &usb_fixed, &usb1v8,1 , - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator_linked (TWL4030_REG_VUSB3V1 , - &usb_fixed, &usb3v1,1 , - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - } - - child =add_child (TWL_MODULE_USB ,"twl4030_usb" , - pdata->usb,sizeof (*pdata->usb), true, -/* irq0 = USB_PRES, irq1 = USB */ - irq_base +USB_PRES_INTR_OFFSET , - irq_base +USB_INTR_OFFSET ); - -if (IS_ERR (child)) -return PTR_ERR (child); - -/* we need to connect regulators to this transceiver */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 ) && child) { - usb1v5.dev_name =dev_name (child); - usb1v8.dev_name =dev_name (child); - usb3v1.dev_name =dev_name (child); - } - } - -if (IS_ENABLED (CONFIG_TWL4030_WATCHDOG ) &&twl_class_is_4030 ()) { - child =add_child (TWL_MODULE_PM_RECEIVER ,"twl4030_wdt" ,NULL , -0 , false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_INPUT_TWL4030_PWRBUTTON ) &&twl_class_is_4030 ()) { - child =add_child (TWL_MODULE_PM_MASTER ,"twl4030_pwrbutton" , -NULL ,0 , true, irq_base +8 +0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_MFD_TWL4030_AUDIO ) && pdata->audio && -twl_class_is_4030 ()) { - child =add_child (TWL4030_MODULE_AUDIO_VOICE ,"twl4030-audio" , - pdata->audio,sizeof (*pdata->audio), - false,0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -/* twl4030 regulators */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 ) &&twl_class_is_4030 ()) { - child =add_regulator (TWL4030_REG_VPLL1 , pdata->vpll1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VIO , pdata->vio, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VDD1 , pdata->vdd1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VDD2 , pdata->vdd2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VMMC1 , pdata->vmmc1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VDAC , pdata->vdac, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator ((features &TWL4030_VAUX2 ) - ?TWL4030_REG_VAUX2_4030 - :TWL4030_REG_VAUX2 , - pdata->vaux2, features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VINTANA1 , pdata->vintana1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VINTANA2 , pdata->vintana2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VINTDIG , pdata->vintdig, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -/* maybe add LDOs that are omitted on cost-reduced parts */ -if (IS_ENABLED (CONFIG_REGULATOR_TWL4030 ) && !(features &TPS_SUBSET ) - &&twl_class_is_4030 ()) { - child =add_regulator (TWL4030_REG_VPLL2 , pdata->vpll2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VMMC2 , pdata->vmmc2, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VSIM , pdata->vsim, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VAUX1 , pdata->vaux1, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VAUX3 , pdata->vaux3, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - - child =add_regulator (TWL4030_REG_VAUX4 , pdata->vaux4, - features); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_CHARGER_TWL4030 ) && pdata->bci && - !(features & (TPS_SUBSET |TWL5031 ))) { - child =add_child (TWL_MODULE_MAIN_CHARGE ,"twl4030_bci" , - pdata->bci,sizeof (*pdata->bci), false, -/* irq0 = CHG_PRES, irq1 = BCI */ - irq_base +BCI_PRES_INTR_OFFSET , - irq_base +BCI_INTR_OFFSET ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -if (IS_ENABLED (CONFIG_TWL4030_POWER ) && pdata->power) { - child =add_child (TWL_MODULE_PM_MASTER ,"twl4030_power" , - pdata->power,sizeof (*pdata->power), false, -0 ,0 ); -if (IS_ERR (child)) -return PTR_ERR (child); - } - -return 0 ; -} -/*----------------------------------------------------------------------*/ /*
@@ -987,8 +684,7 @@ static inline int unprotect_pm_master(void)return e; } -static void clocks_init (struct device *dev, -struct twl4030_clock_init_data *clock) +static void clocks_init (struct device *dev) {int e =0 ;struct clk *osc;
@@ -1018,8 +714,6 @@ static void clocks_init(struct device *dev, } ctrl |=HIGH_PERF_SQ ; -if (clock && clock->ck32k_lowpwr_enable) - ctrl |=CK32K_LOWPWR_EN ; e |=unprotect_pm_master ();/* effect->MADC+USB ck en */
@@ -1067,7 +761,6 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = {static int twl_probe (struct i2c_client *client,const struct i2c_device_id *id) { -struct twl4030_platform_data *pdata =dev_get_platdata (&client->dev);struct device_node *node = client->dev.of_node;struct platform_device *pdev;const struct regmap_config *twl_regmap_config;
@@ -1075,7 +768,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)int status;unsigned i, num_slaves; -if (!node && !pdata) { +if (!node) {dev_err (&client->dev,"no platform data\n" );return -EINVAL ; }
@@ -1165,7 +858,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) twl_priv->ready = true;/* setup clock framework */ -clocks_init (&client->dev, pdata ? pdata->clock :NULL ); +clocks_init (&client->dev);/* read TWL IDCODE Register */ if (twl_class_is_4030 ()) {
@@ -1213,14 +906,8 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) TWL4030_DCDC_GLOBAL_CFG); } -if (node) { -if (pdata) - twl_auxdata_lookup[0 ].platform_data = pdata->gpio; - status =of_platform_populate (node,NULL , twl_auxdata_lookup, - &client->dev); - }else { - status =add_children (pdata, irq_base, id->driver_data); - } + status =of_platform_populate (node,NULL , twl_auxdata_lookup, + &client->dev); fail:if (status <0 )
include/linux/mfd/twl.h +0 -55
61 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 880/1848 mfd: twl-core: Use i2c_check_functionality as boolean value
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thorsten Blum <[email protected]>
[ Upstream commit 7ee4fa2674e51a0d100b9240cd8a50355141362f ]
i2c_check_functionality() returns a boolean status rather than an error code - directly use it as a boolean value.
Stable-dep-of: 3c5c55d979dd ("mfd: twl-core: Unregister the auxiliary platform device on unbind")
--- drivers/mfd/twl-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/twl-core.c +1 -1
@@ -791,7 +791,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)return status; } -if (i2c_check_functionality (client->adapter,I2C_FUNC_I2C ) ==0 ) { +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; goto free;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 881/1848 mfd: twl-core: Unregister the auxiliary platform device on unbind
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 3c5c55d979ddcb0765ce531bc7ba173c87c8712a ]
twl_probe() registers a standalone platform device named "twl", but keeps its pointer only in a local variable. Probe errors unregister the device, while successful probe leaves no way for twl_remove() to release it. The platform device therefore remains registered after the I2C driver unbinds.
Register a managed action on the I2C device immediately after adding the platform device. This unregisters it on probe failure and driver unbind, and also handles failure to register the action itself. Remove the manual error-path unregister to avoid releasing the device twice.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/mfd/twl-core.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/mfd/twl-core.c +14 -7
@@ -757,6 +757,11 @@ static struct of_dev_auxdata twl_auxdata_lookup[] = { { /* sentinel */ }, }; +static void twl_unregister_device (void *data) +{ +platform_device_unregister (data); +} +/* NOTE: This driver only handles a single twl4030/tps659x0 chip */ static int twl_probe (struct i2c_client *client,const struct i2c_device_id *id)
@@ -791,17 +796,22 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)return status; } + status =devm_add_action_or_reset (&client->dev, twl_unregister_device, + pdev); +if (status) +return status; +if (!i2c_check_functionality (client->adapter,I2C_FUNC_I2C )) {dev_dbg (&client->dev,"can't talk I2C?\n" ); status = -EIO ; - goto free; + goto out; } twl_priv =devm_kzalloc (&client->dev,sizeof (struct twl_private ),GFP_KERNEL );if (!twl_priv) { status = -ENOMEM ; - goto free; + goto out; }if ((id->driver_data) &TWL6030_CLASS ) {
@@ -825,7 +835,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) GFP_KERNEL);if (!twl_priv->twl_modules) { status = -ENOMEM ; - goto free; + goto out; }for (i =0 ; i < num_slaves; i++) {
@@ -912,10 +922,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) fail:if (status <0 )twl_remove (client); -free: -if (status <0 ) -platform_device_unregister (pdev); - +out:return status; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 882/1848 ALSA: hda/hdmi: clamp sad_count in ELD proc write handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit b3e7ddd694f8429217ba509b55b910a0e4361dfb ]
snd_hdmi_write_eld_info() parses a "sad_count N" line from the root-writable ELD proc interface and assigns N directly to e->sad_count with no upper bound, unlike the per-index "sadN_*" lines a few lines below which are already bounded to ELD_MAX_SAD.
snd_hdmi_eld_update_pcm_info() later iterates
"for (i = 0; i < e->sad_count; i++)" over the fixed e->sad[ELD_MAX_SAD] array, so an oversized sad_count read from the proc file causes it to walk past the array.
Reject sad_count values above ELD_MAX_SAD, matching the existing per-index guard.
--- sound/pci/hda/hda_eld.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/pci/hda/hda_eld.c +4 -2
@@ -521,9 +521,11 @@ void snd_hdmi_write_eld_info(struct hdmi_eld *eld, e->aud_synch_delay = val; else if (!strcmp(name, "speakers")) e->spk_alloc = val; - else if (!strcmp(name, "sad_count")) + else if (!strcmp(name, "sad_count")) { +if (val >ELD_MAX_SAD ) +continue ; e->sad_count = val; - else if (!strncmp(name, "sad", 3)) { + } else if (!strncmp(name, "sad", 3)) { sname = name +4 ; n = name[3 ] -'0' ;if (name[4 ] >='0' && name[4 ] <='9' ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 883/1848 Bluetooth: Move force_bredr_smp debugfs into hci_debugfs_create_bredr
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Claire Chang <[email protected]>
[ Upstream commit 82493316507a720b6faa2ec23971c0ca89c6dcb0 ]
Avoid multiple attempts to create the debugfs entry, force_bredr_smp, by moving it from the SMP registration to the BR/EDR controller init section. hci_debugfs_create_bredr is only called when HCI_SETUP and HCI_CONFIG is not set.
Stable-dep-of: 2a3e2287877b ("Bluetooth: hci_debugfs: Pin module for debugfs file operations")
--- net/bluetooth/hci_debugfs.c | 50 +++++++++++++++++++++++++++++++++++++ net/bluetooth/smp.c | 44 ++------------------------------ net/bluetooth/smp.h | 2 ++ 3 files changed, 54 insertions(+), 42 deletions(-)
net/bluetooth/hci_debugfs.c +50 -0
@@ -498,6 +498,45 @@ static int auto_accept_delay_get(void *data, u64 *val)DEFINE_SIMPLE_ATTRIBUTE (auto_accept_delay_fops, auto_accept_delay_get, auto_accept_delay_set,"%llu\n" ); +static ssize_t force_bredr_smp_read (struct file *file, +char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct hci_dev *hdev = file->private_data; +char buf[3 ]; + + buf[0 ] =hci_dev_test_flag (hdev,HCI_FORCE_BREDR_SMP ) ?'Y' :'N' ; + buf[1 ] ='\n' ; + buf[2 ] ='\0' ; +return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); +} + +static ssize_t force_bredr_smp_write (struct file *file, +const char __user *user_buf, +size_t count,loff_t *ppos) +{ +struct hci_dev *hdev = file->private_data; +bool enable; +int err; + + err =kstrtobool_from_user (user_buf, count, &enable); +if (err) +return err; + + err =smp_force_bredr (hdev, enable); +if (err) +return err; + +return count; +} + +static const struct file_operations force_bredr_smp_fops = { + .open = simple_open, + .read = force_bredr_smp_read, + .write = force_bredr_smp_write, + .llseek = default_llseek, +}; +static int idle_timeout_set (void *data,u64 val) {struct hci_dev *hdev = data;
@@ -597,6 +636,17 @@ void hci_debugfs_create_bredr(struct hci_dev *hdev)debugfs_create_file ("voice_setting" ,0444 , hdev->debugfs, hdev, &voice_setting_fops); +/* If the controller does not support BR/EDR Secure Connections +* feature, then the BR/EDR SMP channel shall not be present. +* +* To test this with Bluetooth 4.0 controllers, create a debugfs +* switch that allows forcing BR/EDR SMP support and accepting +* cross-transport pairing on non-AES encrypted connections. +*/ +if (!lmp_sc_capable (hdev)) +debugfs_create_file ("force_bredr_smp" ,0644 , hdev->debugfs, + hdev, &force_bredr_smp_fops); +if (lmp_ssp_capable (hdev)) {debugfs_create_file ("ssp_debug_mode" ,0444 , hdev->debugfs, hdev, &ssp_debug_mode_fops);
net/bluetooth/smp.c +2 -42
66 lines not on this page · raw message
net/bluetooth/smp.h +2 -0
@@ -194,6 +194,8 @@ bool smp_irk_matches(struct hci_dev *hdev, const u8 irk[16],int smp_generate_rpa (struct hci_dev *hdev,const u8 irk[16 ],bdaddr_t *rpa);int smp_generate_oob (struct hci_dev *hdev,u8 hash[16 ],u8 rand[16 ]); +int smp_force_bredr (struct hci_dev *hdev,bool enable); +int smp_register (struct hci_dev *hdev);void smp_unregister (struct hci_dev *hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 884/1848 Bluetooth: hci_core: Move all debugfs handling to hci_debugfs.c
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luiz Augusto von Dentz <[email protected]>
[ Upstream commit 8331dc487fc55963e853b6858af716907717e181 ]
This moves hci_debugfs_create_basic to hci_debugfs.c which is where all the others debugfs entries are handled.
Stable-dep-of: 2a3e2287877b ("Bluetooth: hci_debugfs: Pin module for debugfs file operations")
--- net/bluetooth/hci_core.c | 124 ------------------------------------ net/bluetooth/hci_debugfs.c | 123 +++++++++++++++++++++++++++++++++++ net/bluetooth/hci_debugfs.h | 5 ++ 3 files changed, 128 insertions(+), 124 deletions(-)
net/bluetooth/hci_core.c +0 -124
@@ -60,130 +60,6 @@ DEFINE_MUTEX(hci_cb_list_lock);/* HCI ID Numbering */ static DEFINE_IDA (hci_index_ida); -/* ---- HCI debugfs entries ---- */ - -static ssize_t dut_mode_read (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -char buf[3 ]; - - buf[0 ] =hci_dev_test_flag (hdev,HCI_DUT_MODE ) ?'Y' :'N' ; - buf[1 ] ='\n' ; - buf[2 ] ='\0' ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); -} - -static ssize_t dut_mode_write (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -struct sk_buff *skb; -bool enable; -int err; - -if (!test_bit (HCI_UP , &hdev->flags)) -return -ENETDOWN ; - - err =kstrtobool_from_user (user_buf, count, &enable); -if (err) -return err; - -if (enable ==hci_dev_test_flag (hdev,HCI_DUT_MODE )) -return -EALREADY ; - -hci_req_sync_lock (hdev); -if (enable) - skb =__hci_cmd_sync (hdev,HCI_OP_ENABLE_DUT_MODE ,0 ,NULL , -HCI_CMD_TIMEOUT ); -else - skb =__hci_cmd_sync (hdev,HCI_OP_RESET ,0 ,NULL , -HCI_CMD_TIMEOUT ); -hci_req_sync_unlock (hdev); - -if (IS_ERR (skb)) -return PTR_ERR (skb); - -kfree_skb (skb); - -hci_dev_change_flag (hdev,HCI_DUT_MODE ); - -return count; -} - -static const struct file_operations dut_mode_fops = { - .open = simple_open, - .read = dut_mode_read, - .write = dut_mode_write, - .llseek = default_llseek, -}; - -static ssize_t vendor_diag_read (struct file *file,char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -char buf[3 ]; - - buf[0 ] =hci_dev_test_flag (hdev,HCI_VENDOR_DIAG ) ?'Y' :'N' ; - buf[1 ] ='\n' ; - buf[2 ] ='\0' ; -return simple_read_from_buffer (user_buf, count, ppos, buf,2 ); -} - -static ssize_t vendor_diag_write (struct file *file,const char __user *user_buf, -size_t count,loff_t *ppos) -{ -struct hci_dev *hdev = file->private_data; -bool enable; -int err; - - err =kstrtobool_from_user (user_buf, count, &enable); -if (err) -return err; - -/* When the diagnostic flags are not persistent and the transport -* is not active or in user channel operation, then there is no need -* for the vendor callback. Instead just store the desired value and -* the setting will be programmed when the controller gets powered on. -*/ -if (test_bit (HCI_QUIRK_NON_PERSISTENT_DIAG , &hdev->quirks) && - (!test_bit (HCI_RUNNING , &hdev->flags) || -hci_dev_test_flag (hdev,HCI_USER_CHANNEL ))) - goto done; - -hci_req_sync_lock (hdev); - err = hdev->set_diag (hdev, enable); -hci_req_sync_unlock (hdev); - -if (err <0 ) -return err; - -done: -if (enable) -hci_dev_set_flag (hdev,HCI_VENDOR_DIAG ); -else -hci_dev_clear_flag (hdev,HCI_VENDOR_DIAG ); - -return count; -} - -static const struct file_operations vendor_diag_fops = { - .open = simple_open, - .read = vendor_diag_read, - .write = vendor_diag_write, - .llseek = default_llseek, -}; - -static void hci_debugfs_create_basic (struct hci_dev *hdev) -{ -debugfs_create_file ("dut_mode" ,0644 , hdev->debugfs, hdev, - &dut_mode_fops); - -if (hdev->set_diag) -debugfs_create_file ("vendor_diag" ,0644 , hdev->debugfs, hdev, - &vendor_diag_fops); -} -static int hci_reset_req (struct hci_request *req,unsigned long opt) {BT_DBG ("%s %ld" , req->hdev->name, opt);
net/bluetooth/hci_debugfs.c +123 -0
132 lines not on this page · raw message
net/bluetooth/hci_debugfs.h +5 -0
@@ -26,6 +26,7 @@ void hci_debugfs_create_common(struct hci_dev *hdev);void hci_debugfs_create_bredr (struct hci_dev *hdev);void hci_debugfs_create_le (struct hci_dev *hdev);void hci_debugfs_create_conn (struct hci_conn *conn); +void hci_debugfs_create_basic (struct hci_dev *hdev);#else
@@ -45,4 +46,8 @@ static inline void hci_debugfs_create_conn(struct hci_conn *conn) { } +static inline void hci_debugfs_create_basic (struct hci_dev *hdev) +{ +} +#endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 885/1848 Bluetooth: hci_debugfs: Pin module for debugfs file operations
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bui Viet Dung <[email protected]>
[ Upstream commit 2a3e2287877b1ee40ffb80b7d769b633866533f3 ]
An open debugfs file retains its file_operations pointer in the debugfs proxy state. However, the file_operations defined in hci_debugfs.c (use_debug_keys_fops, sc_only_mode_fops, ssp_debug_mode_fops, force_bredr_smp_fops, force_static_address_fops, force_no_mitm_fops, dut_mode_fops, vendor_diag_fops, and the DEFINE_QUIRK_ATTRIBUTE macro) have no .owner set to THIS_MODULE.
As a result, full_proxy_open_regular() calls fops_get() which succeeds without taking a reference to the bluetooth module. When a userspace process opens any of these debugfs files, a subsequent controller removal and module unload (rmmod bluetooth) can succeed while the file descriptor remains open.
When the userspace process subsequently closes the descriptor, full_proxy_release() accesses the already unmapped file_operations structure, triggering a kernel oops in full_proxy_release():
BUG: unable to handle page fault for address: fffffbfff8056f03 #PF: supervisor read access in kernel mode Oops: 0000 [#1] SMP KASAN NOPTI RIP: 0010:full_proxy_release+0x8e/0x140 Call Trace: <TASK> __fput+0x39f/0xa60 fput_close_sync+0xff/0x200 __x64_sys_close+0x8c/0xf0 do_syscall_64+0x115/0x6a0 entry_SYSCALL_64_after_hwframe+0x77/0x7f </TASK>
The issue was discovered via manual code audit of net/bluetooth/hci_debugfs.c and verified on a Linux 7.3-rc6 test VM with CONFIG_BT=m.
Set .owner = THIS_MODULE on all debugfs file_operations tables in hci_debugfs.c so that debugfs keeps the module loaded until close has finished.
--- net/bluetooth/hci_debugfs.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/bluetooth/hci_debugfs.c +9 -0
@@ -68,6 +68,7 @@ static ssize_t __name ## _write(struct file *file, \ } \ \ static const struct file_operations __name ## _fops = { \ + .owner =THIS_MODULE , \ .open = simple_open, \ .read = __name ## _read, \ .write = __name ## _write, \
@@ -286,6 +287,7 @@ static ssize_t use_debug_keys_read(struct file *file, char __user *user_buf, }static const struct file_operations use_debug_keys_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = use_debug_keys_read, .llseek = default_llseek,
@@ -304,6 +306,7 @@ static ssize_t sc_only_mode_read(struct file *file, char __user *user_buf, }static const struct file_operations sc_only_mode_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = sc_only_mode_read, .llseek = default_llseek,
@@ -440,6 +443,7 @@ static ssize_t ssp_debug_mode_read(struct file *file, char __user *user_buf, }static const struct file_operations ssp_debug_mode_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = ssp_debug_mode_read, .llseek = default_llseek,
@@ -532,6 +536,7 @@ static ssize_t force_bredr_smp_write(struct file *file, }static const struct file_operations force_bredr_smp_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_bredr_smp_read, .write = force_bredr_smp_write,
@@ -781,6 +786,7 @@ static ssize_t force_static_address_write(struct file *file, }static const struct file_operations force_static_address_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_static_address_read, .write = force_static_address_write,
@@ -1184,6 +1190,7 @@ static ssize_t force_no_mitm_write(struct file *file, }static const struct file_operations force_no_mitm_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = force_no_mitm_read, .write = force_no_mitm_write,
@@ -1322,6 +1329,7 @@ static ssize_t dut_mode_write(struct file *file, const char __user *user_buf, }static const struct file_operations dut_mode_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = dut_mode_read, .write = dut_mode_write,
@@ -1378,6 +1386,7 @@ static ssize_t vendor_diag_write(struct file *file, const char __user *user_buf, }static const struct file_operations vendor_diag_fops = { + .owner =THIS_MODULE , .open = simple_open, .read = vendor_diag_read, .write = vendor_diag_write,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 886/1848 iommu/dma: Catch scatterlist length overflows
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Karas <[email protected]>
[ Upstream commit 1c8f6308e557f32412e9d4678b3f029f47f6d9aa ]
It is possible, when a very large mapping uses only one scatterlist, that padding overflows scatterlist's length field. This results in:
1) silently wrapping the value
2) smaller than desired mappings produced by iommu_map_sg
3) leaving mapped bytes in memory (no iommu_unmap)
Address this issue by adding overflow detection for scatterlist length field.
--- drivers/iommu/dma-iommu.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
drivers/iommu/dma-iommu.c +13 -1
@@ -864,6 +864,8 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,sg_dma_len (s) = s_length; s->offset -= s_iova_off; s_length =iova_align (iovad, s_length + s_iova_off); +if (s_length != (unsigned int )s_length) + goto out_restore_sg; s->length = s_length;/*
@@ -880,7 +882,17 @@ static int iommu_dma_map_sg(struct device *dev, struct scatterlist *sg,* time through here (i.e. before it has a meaningful value). */ if (pad_len && pad_len < s_length -1 ) { - prev->length += pad_len; +unsigned int new_prev_len; + +/* +* For large mappings spanning multiple GBs we +* may not be able to fit all needed padding into +* sg->length. +*/ +if (check_add_overflow (prev->length, pad_len, &new_prev_len)) + goto out_restore_sg; + + prev->length = new_prev_len; iova_len += pad_len; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 887/1848 platform/x86: asus-wmi: Serialize WMI method evaluations with a mutex
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marco Scardovi <[email protected]>
[ Upstream commit b9428edaf4109e86a97254228d831767d0acc1f8 ]
Concurrent evaluations of ASUS WMI management methods (from ACPI notify, HID, userspace daemons, and debugfs) enter the BIOS ACPI/SMM interface simultaneously, triggering re-entrant SMIs or EC mailbox buffer corruption.
Fix this at the root by introducing a centralized evaluation helper (asus_wmi_evaluate_method_locked()) protected by a global mutex (asus_wmi_eval_lock) using guard(mutex). Route all evaluations of ASUS_WMI_MGMT_GUID (method3, method5, method_buf, and show_call) through this helper.
A static mutex is required because asus_wmi_evaluate_method() is an exported symbol used by external modules (such as hid-asus and asus-armoury) that lack access to struct asus_wmi drvdata, and the underlying ASUS ACPI/EC management method is a single physical platform resource.
The mutex is non-recursive: nested ACPI/WMI notify handlers must not call back into evaluate on the same task (defer via workqueue, as asus_rfkill_notify already does).
The sysfs-versus-notify race predates the later export of asus_wmi_evaluate_method(), so Fixes points at the original shared evaluate helper rather than that export.
--- drivers/platform/x86/asus-wmi.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/platform/x86/asus-wmi.c +11 -0
@@ -15,6 +15,7 @@#include <linux/kernel.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/init.h> #include <linux/types.h> #include <linux/slab.h>
@@ -236,6 +237,12 @@ struct asus_wmi {/* WMI ************************************************************************/ +/* +* Concurrent evaluations of ASUS WMI methods can re-enter firmware +* SMI/EC mailbox handling and corrupt the mailbox. +*/ +static DEFINE_MUTEX (asus_wmi_eval_lock); +static int asus_wmi_evaluate_method3 (u32 method_id,u32 arg0,u32 arg1,u32 arg2,u32 *retval) {
@@ -250,8 +257,10 @@ static int asus_wmi_evaluate_method3(u32 method_id,union acpi_object *obj;u32 tmp =0 ; +mutex_lock (&asus_wmi_eval_lock); status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , method_id, &input, &output); +mutex_unlock (&asus_wmi_eval_lock);if (ACPI_FAILURE (status))return -EIO ;
@@ -2605,9 +2614,11 @@ static int show_call(struct seq_file *m, void *data)union acpi_object *obj;acpi_status status; +mutex_lock (&asus_wmi_eval_lock); status =wmi_evaluate_method (ASUS_WMI_MGMT_GUID ,0 , asus->debug.method_id, &input, &output); +mutex_unlock (&asus_wmi_eval_lock);if (ACPI_FAILURE (status))return -EIO ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 888/1848 mm: disallow ioremaping ordinary RAM in generic_access_phys()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand (Arm) <[email protected]>
[ Upstream commit 4590752e20aa393cc0d4fe538c0747d14a98c97a ]
generic_access_phys() can end up getting called on CoW PFNMAP mappings, resulting in it trying to ioremap anonymous folios, which especially the x86 code doesn't enjoy, and which is in general just odd/wrong.
E.g., with a CoW mapping of a PCI BAR:
ioremap on RAM at 0x0000000045623000 - 0x0000000045623fff
WARNING: arch/x86/mm/ioremap.c:216 at __ioremap_caller.isra.0+0x4c2/0x5f0 Call Trace: generic_access_phys+0x130/0x4d0 mm/memory.c:7178 kernfs_vma_access+0x1ce/0x280 fs/kernfs/file.c:437 __access_remote_vm+0x58f/0x890 mm/memory.c:7256 mem_rw+0x2a1/0x670 fs/proc/base.c:912
But more generically, we should disallow access to anything that looks like ordinary RAM in the system: including allocating memory (e.g., alloc_pages) and mapping them in a VM_PFNMAP.
For pages with an online memmap, allow only pages marked as reserved (PageReserved). This also includes memblock allocations, however, distinguishing them from other MMIO is tricky, and nobody should really be mapping them in a PFNMAP (except someone abusing /dev/mem, which we do not care about).
So only allow access if there is no online memmap, or if the pages are marked reserved. Reject other pages with -EINVAL.
Note that, just like other pfn_to_online_page() users, we won't care about concurrent memory offlining; mapping memory that can concurrently get offlined is highly dubious.
--- mm/memory.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
mm/memory.c +11 -0
@@ -4985,11 +4985,22 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,resource_size_t phys_addr;unsigned long prot =0 ;void __iomem *maddr; +struct page *page;int offset = addr & (PAGE_SIZE -1 );if (follow_phys (vma, addr, write, &prot, &phys_addr))return -EINVAL ; +/* +* Reject anything that looks like ordinary RAM, including anonymous +* folios in CoW mappings or allocated kernel memory. Note that we +* cannot distinguish memblock allocations from non-RAM reliably, so +* we cannot easily reject them here. +*/ + page =pfn_to_online_page (phys_addr >>PAGE_SHIFT ); +if (page && !PageReserved (page)) +return -EINVAL ; + maddr =ioremap_prot (phys_addr,PAGE_ALIGN (len + offset), prot);if (!maddr)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 889/1848 xprtrdma: Remove the RPC/RDMA QP event handler
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit e1648eb23d839bd4b9f2999296d5e81dcd93311f ]
Clean up: The handler only recorded a trace event. If indeed no action is needed by the RPC/RDMA consumer, then the event can be ignored.
Stable-dep-of: 0b5bb4e586f7 ("xprtrdma: prevent disconnect feedback during endpoint teardown")
--- include/trace/events/rpcrdma.h | 32 -------------------------------- net/sunrpc/xprtrdma/verbs.c | 18 ------------------ 2 files changed, 50 deletions(-)
include/trace/events/rpcrdma.h +0 -32
@@ -485,38 +485,6 @@ TRACE_EVENT(xprtrdma_op_set_cto, ) ); -TRACE_EVENT (xprtrdma_qp_event, -TP_PROTO ( - const struct rpcrdma_ep *ep, - const struct ib_event *event - ), - -TP_ARGS (ep, event), - -TP_STRUCT__entry ( - __field(unsigned long, event) - __string(name, event->device->name) - __array(unsigned char, srcaddr, sizeof(struct sockaddr_in6)) - __array(unsigned char, dstaddr, sizeof(struct sockaddr_in6)) - ), - -TP_fast_assign ( - const struct rdma_cm_id *id = ep->re_id; - - __entry->event = event->event; - __assign_str(name, event->device->name); - memcpy(__entry->srcaddr, &id->route.addr.src_addr, - sizeof(struct sockaddr_in6)); -memcpy (__entry->dstaddr, &id->route.addr.dst_addr, - sizeof(struct sockaddr_in6)); - ), - -TP_printk ("%pISpc -> %pISpc device=%s %s (%lu)" , - __entry->srcaddr, __entry->dstaddr,__get_str (name), -rdma_show_ib_event (__entry->event), __entry->event - ) -); -/** ** Call events **/
net/sunrpc/xprtrdma/verbs.c +0 -18
@@ -114,22 +114,6 @@ static void rpcrdma_xprt_drain(struct rpcrdma_xprt *r_xprt)rpcrdma_ep_put (ep); } -/** -* rpcrdma_qp_event_handler - Handle one QP event (error notification) -* @event: details of the event -* @context: ep that owns QP where event occurred -* -* Called from the RDMA provider (device driver) possibly in an interrupt -* context. The QP is always destroyed before the ID, so the ID will be -* reliably available when this handler is invoked. -*/ -static void rpcrdma_qp_event_handler (struct ib_event *event,void *context) -{ -struct rpcrdma_ep *ep = context; - -trace_xprtrdma_qp_event (ep, event); -} -/* Ensure xprt_force_disconnect() is invoked exactly once when a * connection is closed or lost. (The important thing is it needs * to be invoked "at least" once).
@@ -428,8 +412,6 @@ static int rpcrdma_ep_create(struct rpcrdma_xprt *r_xprt) r_xprt->rx_buf.rb_max_requests =cpu_to_be32 (ep->re_max_requests); - ep->re_attr.event_handler = rpcrdma_qp_event_handler; - ep->re_attr.qp_context = ep; ep->re_attr.srq =NULL ; ep->re_attr.cap.max_inline_data =0 ; ep->re_attr.sq_sig_type =IB_SIGNAL_REQ_WR ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 890/1848 xprtrdma: prevent disconnect feedback during endpoint teardown
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tim Menninger <[email protected]>
[ Upstream commit 0b5bb4e586f7b0a449f4d90a524f76a3be5db355 ]
xprt_autoclose() clears XPRT_CLOSE_WAIT before invoking the transport's ->close() operation. For RPC/RDMA, ->close() calls rpcrdma_xprt_disconnect(), which disconnects the RDMA CM endpoint and drains its QP.
Since commit 31e62d25b5b8 ("xprtrdma: Simplify RPC wake-ups on connect"), RDMA_CM_EVENT_DISCONNECTED requests a SUNRPC transport disconnect. Today that path, along with failed completion handling, reaches xprt_force_disconnect() through rpcrdma_force_disconnect().
Commit c487eb7d8e41 ("xprtrdma: Clean up disconnect") later added re_force_disconnect to ensure that multiple failure indications request only one SUNRPC disconnect. However, the gate remains open when SUNRPC itself begins endpoint teardown.
If re_force_disconnect is still clear, either a CM disconnect event or a completion error can set XPRT_CLOSE_WAIT again while the current close is in progress. When the transport send lock is subsequently released, xprt_clear_locked() observes XPRT_CLOSE_WAIT and queues another autoclose.
Requesting a disconnect this way is necessary when a connection is lost unexpectedly, but not when the event was generated by rpcrdma_xprt_disconnect() itself. In that case SUNRPC is already committed to closing the transport.
Mark re_force_disconnect before initiating local endpoint teardown so that CM events and completion errors caused by that teardown cannot request another close. An unexpected error that wins the race before local endpoint teardown begins can still request a disconnect normally.
Use a fully ordered exchange so that the gate is globally closed before rdma_disconnect() can transition the QP to error and generate the callbacks that the gate suppresses.
In 30-second traces of a sustained recovery loop, without this change there were 7,693 xprt_force_disconnect() calls, 6,267 SUNRPC autocloses, and 172,892 receive-side IB_WC_WR_FLUSH_ERR completions. With this change, the same tracepoints recorded 3,512 xprt_force_disconnect() calls, 3,212 autocloses, and 131,287 receive-side flush completions. Thus QP teardown continues to produce flushed completions, but closing the disconnect gate before teardown substantially reduces their feedback into the SUNRPC close path.
--- net/sunrpc/xprtrdma/verbs.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
net/sunrpc/xprtrdma/verbs.c +6 -3
@@ -114,9 +114,9 @@ static void rpcrdma_xprt_drain(struct rpcrdma_xprt *r_xprt)rpcrdma_ep_put (ep); } -/* Ensure xprt_force_disconnect() is invoked exactly once when a -* connection is closed or lost. (The important thing is it needs -* to be invoked "at least" once). +/* Ensure xprt_force_disconnect() is invoked at most once for an +* unexpected endpoint failure. Local endpoint teardown closes this +* gate before it can generate CM events and flushed completions. */ static void rpcrdma_force_disconnect (struct rpcrdma_ep *ep) {
@@ -576,6 +576,9 @@ void rpcrdma_xprt_disconnect(struct rpcrdma_xprt *r_xprt)if (!ep)return ; +/* Prevent teardown-generated events from requesting another close. */ +atomic_xchg (&ep->re_force_disconnect,1 ); + id = ep->re_id; rc =rdma_disconnect (id);trace_xprtrdma_disconnect (r_xprt, rc);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 891/1848 KVM: arm64: Move IN_GUEST_MODE ahead of state being loaded
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marc Zyngier <[email protected]>
[ Upstream commit 22b6557ad05bf05c73246f62c19af3e04017270e ]
IN_GUEST_MODE is advertised too late, when state has already been moved onto CPU registers and cannot be observed by another CPU anymore.
Move the IN_GUEST_MODE publication ahead of the state being loaded, and immediately check for pending request. This ensures that there is no window of opportunity for another CPU to observe OUTSIDE_GUEST_MODE and yet for state to be loaded.
This also simplifies the "state rollback", which solely amounts to synchronising the timer when no irqchip is present.
--- arch/arm64/kvm/arm.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
arch/arm64/kvm/arm.c +8 -5
@@ -716,8 +716,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)local_irq_disable (); -kvm_vgic_flush_hwstate (vcpu); -/* * Exit if we have a signal pending so that we can deliver the * signal to user space.
@@ -747,22 +745,27 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)* interrupts and before the final VCPU requests check. * See the comment in kvm_vcpu_exiting_guest_mode() and * Documentation/virt/kvm/vcpu-requests.rst +* +* Requests to self must be posted before this point, or +* won't be taken into account until the next exit. No state +* loading other than what happens at vcpu_load() time can +* be done before we have checked for pending requests. */ smp_store_mb (vcpu->mode,IN_GUEST_MODE );if (ret <=0 ||need_new_vmid_gen (&vcpu->arch.hw_mmu->vmid) ||kvm_request_pending (vcpu)) { vcpu->mode =OUTSIDE_GUEST_MODE ; -isb ();/* Ensure work in x_flush_hwstate is committed */ -kvm_pmu_sync_hwstate (vcpu);if (static_branch_unlikely (&userspace_irqchip_in_use))kvm_timer_sync_user (vcpu); -kvm_vgic_sync_hwstate (vcpu);local_irq_enable ();preempt_enable ();continue ; } +/* From here onwards, we are commited to entering the guest */ +kvm_vgic_flush_hwstate (vcpu); +kvm_arm_setup_debug (vcpu);/**************************************************************
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 892/1848 media: rockchip: rga: fix clock cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
[ Upstream commit 254f3337ce2575bf94f1fb40cc40fdbc70371116 ]
Fix this smatch warning:
drivers/media/platform/rockchip/rga/rga.c:734 rga_enable_clocks() warn: 'rga->sclk' from clk_prepare_enable() not released on lines: 734.
The reason is that aclk should be disabled/unprepared before sclk, instead of the other way around.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +2 -2
@@ -717,10 +717,10 @@ static int rga_enable_clocks(struct rockchip_rga *rga)return 0 ; -err_disable_sclk: -clk_disable_unprepare (rga->sclk); err_disable_aclk:clk_disable_unprepare (rga->aclk); +err_disable_sclk: +clk_disable_unprepare (rga->sclk);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 893/1848 media: rockchip: rga: use clk_bulk api
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sven Püschel <[email protected]>
[ Upstream commit a2a4f69fd2e333bacd17d1788eb5211cb6f373cc ]
Use the clk_bulk API to avoid code duplication for each of the three clocks.
Stable-dep-of: a875c43dd95e ("media: rockchip: rga: quiesce IRQ before releasing m2m state")
--- drivers/media/platform/rockchip/rga/rga.c | 65 +++-------------------- drivers/media/platform/rockchip/rga/rga.h | 6 +-- 2 files changed, 11 insertions(+), 60 deletions(-)
drivers/media/platform/rockchip/rga/rga.c +8 -57
@@ -693,48 +693,10 @@ static const struct video_device rga_videodev = { .device_caps = V4L2_CAP_VIDEO_M2M | V4L2_CAP_STREAMING, }; -static int rga_enable_clocks (struct rockchip_rga *rga) -{ -int ret; - - ret =clk_prepare_enable (rga->sclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga sclk: %d\n" , ret); -return ret; - } - - ret =clk_prepare_enable (rga->aclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga aclk: %d\n" , ret); - goto err_disable_sclk; - } - - ret =clk_prepare_enable (rga->hclk); -if (ret) { -dev_err (rga->dev,"Cannot enable rga hclk: %d\n" , ret); - goto err_disable_aclk; - } - -return 0 ; - -err_disable_aclk: -clk_disable_unprepare (rga->aclk); -err_disable_sclk: -clk_disable_unprepare (rga->sclk); - -return ret; -} - -static void rga_disable_clocks (struct rockchip_rga *rga) -{ -clk_disable_unprepare (rga->sclk); -clk_disable_unprepare (rga->hclk); -clk_disable_unprepare (rga->aclk); -} -static int rga_parse_dt (struct rockchip_rga *rga) {struct reset_control *core_rst, *axi_rst, *ahb_rst; +int ret; core_rst =devm_reset_control_get (rga->dev,"core" );if (IS_ERR (core_rst)) {
@@ -766,23 +728,12 @@ static int rga_parse_dt(struct rockchip_rga *rga)udelay (1 );reset_control_deassert (ahb_rst); - rga->sclk =devm_clk_get (rga->dev,"sclk" ); -if (IS_ERR (rga->sclk)) { -dev_err (rga->dev,"failed to get sclk clock\n" ); -return PTR_ERR (rga->sclk); - } - - rga->aclk =devm_clk_get (rga->dev,"aclk" ); -if (IS_ERR (rga->aclk)) { -dev_err (rga->dev,"failed to get aclk clock\n" ); -return PTR_ERR (rga->aclk); - } - - rga->hclk =devm_clk_get (rga->dev,"hclk" ); -if (IS_ERR (rga->hclk)) { -dev_err (rga->dev,"failed to get hclk clock\n" ); -return PTR_ERR (rga->hclk); + ret =devm_clk_bulk_get_all (rga->dev, &rga->clks); +if (ret <0 ) { +dev_err (rga->dev,"failed to get clocks\n" ); +return ret; } + rga->num_clks = ret;return 0 ; }
@@ -949,7 +900,7 @@ static int __maybe_unused rga_runtime_suspend(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -rga_disable_clocks (rga); +clk_bulk_disable_unprepare (rga->num_clks, rga->clks);return 0 ; }
@@ -958,7 +909,7 @@ static int __maybe_unused rga_runtime_resume(struct device *dev) {struct rockchip_rga *rga =dev_get_drvdata (dev); -return rga_enable_clocks (rga); +return clk_bulk_prepare_enable (rga->num_clks, rga->clks); }static const struct dev_pm_ops rga_pm = {
drivers/media/platform/rockchip/rga/rga.h +3 -3
@@ -6,6 +6,7 @@#ifndef __RGA_H__#define __RGA_H__ +#include <linux/clk.h> #include <linux/platform_device.h> #include <media/videobuf2-v4l2.h> #include <media/v4l2-ctrls.h>
@@ -68,9 +69,8 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; -struct clk *sclk; -struct clk *aclk; -struct clk *hclk; +struct clk_bulk_data *clks; +int num_clks;struct rockchip_rga_version version;/* vfd lock */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 894/1848 media: rockchip: rga: quiesce IRQ before releasing m2m state
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fan Wu <[email protected]>
[ Upstream commit a875c43dd95ee4f9c4e3e5ae1cb8362cc6d7817d ]
rga_remove() releases the m2m state before the IRQ is freed. The IRQ is devm-managed and is only released once rga_remove() returns, so rga_isr() can still run while the m2m device state is being torn down.
Store the IRQ number in struct rockchip_rga, unregister the video device first, and free the IRQ before releasing the m2m state so the handler cannot run against the freed state.
--- drivers/media/platform/rockchip/rga/rga.c | 4 +++- drivers/media/platform/rockchip/rga/rga.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-)
drivers/media/platform/rockchip/rga/rga.c +3 -1
@@ -776,6 +776,7 @@ static int rga_probe(struct platform_device *pdev) ret = irq; goto err_put_clk; } + rga->irq = irq; ret =devm_request_irq (rga->dev, irq, rga_isr,0 ,dev_name (rga->dev), rga);
@@ -887,8 +888,9 @@ static int rga_remove(struct platform_device *pdev)v4l2_info (&rga->v4l2_dev,"Removing\n" ); -v4l2_m2m_release (rga->m2m_dev);video_unregister_device (rga->vfd); +devm_free_irq (rga->dev, rga->irq, rga); +v4l2_m2m_release (rga->m2m_dev);v4l2_device_unregister (&rga->v4l2_dev);pm_runtime_disable (rga->dev);
drivers/media/platform/rockchip/rga/rga.h +1 -0
@@ -69,6 +69,7 @@ struct rockchip_rga {struct device *dev;struct regmap *grf;void __iomem *regs; +int irq;struct clk_bulk_data *clks;int num_clks;struct rockchip_rga_version version;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 895/1848 fbdev: core: Initialize modelist in framebuffer_alloc()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Misiurov <[email protected]>
[ Upstream commit 0c9cb9321cb3863b52bdea4b8ae5a27705762c9e ]
framebuffer_alloc() returns zeroed memory, so info->modelist starts out with NULL next and prev pointers. The list head is initialized only later, by fb_videomode_to_modelist() or by do_register_framebuffer().
The "fix potential memory leak" commits listed below added fb_destroy_modelist(&info->modelist) to the probe error paths of s3fb, tdfxfb, tridentfb, i740fb and carminefb. These paths can run before the list head is initialized:
- s3fb, tdfxfb, tridentfb and i740fb call fb_videomode_to_modelist() only after a successful EDID read, and tridentfb can also hit the error path on an ioremap() or kmalloc() failure before that;
- carminefb jumps to the error path when fb_find_mode() fails, before its fb_videomode_to_modelist() call.
fb_destroy_modelist() then dereferences the NULL head. Reproduced on Debian 12 (6.1.180) by binding s3fb to a VGA device without EDID and forcing fb_alloc_cmap() to fail:
s3fb 0000:00:03.0: cannot allocate colormap
BUG: kernel NULL pointer dereference, address: 0000000000000000 RIP: 0010:fb_destroy_modelist+0x10/0x80 Call Trace: s3_pci_probe.cold+0x12b/0x2bf [s3fb] local_pci_probe+0x41/0x80 pci_device_probe+0xc3/0x240 really_probe+0xde/0x380 __driver_probe_device+0x84/0x150 driver_probe_device+0x1f/0x90 __driver_attach+0xce/0x1c0 bus_for_each_dev+0x87/0xd0 bus_add_driver+0x1ae/0x200 driver_register+0x89/0xe0 do_one_initcall+0x59/0x220 do_init_module+0x4a/0x1f0
Initialize the list head in framebuffer_alloc(), so info->modelist is always a valid, possibly empty, list and fb_destroy_modelist() is safe on every error path. Keep the lazy initialization in do_register_framebuffer(), as drivers that embed struct fb_info rather than calling framebuffer_alloc() still depend on it.
--- drivers/video/fbdev/core/fbsysfs.c | 1 + 1 file changed, 1 insertion(+)
drivers/video/fbdev/core/fbsysfs.c +1 -0
@@ -56,6 +56,7 @@ struct fb_info *framebuffer_alloc(size_t size, struct device *dev) info->device = dev; info->fbcon_rotate_hint =-1 ; +INIT_LIST_HEAD (&info->modelist);#if IS_ENABLED (CONFIG_FB_BACKLIGHT )mutex_init (&info->bl_curve_mutex);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 896/1848 s390/pci: Add error cleanup in zpci_directed_irq_init()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tobias Schumacher <[email protected]>
[ Upstream commit 769f66f595c11185c66913ea5d96420504bfebc3 ]
If per-CPU airq_iv allocation fails in the loop, previously allocated vectors and arrays leak. Add proper error path to release all resources on failure.
The error path frees zpci_sbv, but SIC_IRQ_MODE_DIRECT has already programmed its address into the hardware. Set the directed interrupt mode only after all allocations have succeeded, so a failed init leaves no freed memory registered with the hardware.
--- arch/s390/pci/pci_irq.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
arch/s390/pci/pci_irq.c +19 -7
@@ -391,15 +391,10 @@ static int __init zpci_directed_irq_init(void)if (!zpci_sbv)return -ENOMEM ; - iib.diib.isc =PCI_ISC ; - iib.diib.nr_cpus =num_possible_cpus (); - iib.diib.disb_addr = (u64 ) zpci_sbv->vector; -__zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib); - zpci_ibv =kcalloc (num_possible_cpus (),sizeof (*zpci_ibv),GFP_KERNEL );if (!zpci_ibv) -return -ENOMEM ; + goto out_free_sbv;for_each_possible_cpu (cpu) {/*
@@ -411,13 +406,30 @@ static int __init zpci_directed_irq_init(void)AIRQ_IV_CACHELINE | (!cpu ? AIRQ_IV_ALLOC : 0));if (!zpci_ibv[cpu]) -return -ENOMEM ; + goto out_free_ibv; } + + iib.diib.isc =PCI_ISC ; + iib.diib.nr_cpus =num_possible_cpus (); + iib.diib.disb_addr = (u64 ) zpci_sbv->vector; +__zpci_set_irq_ctrl (SIC_IRQ_MODE_DIRECT ,0 , &iib);on_each_cpu (cpu_enable_directed_irq,NULL ,1 ); zpci_irq_chip.irq_set_affinity = zpci_set_irq_affinity;return 0 ; + +out_free_ibv: +for_each_possible_cpu (cpu) { +if (zpci_ibv[cpu]) +airq_iv_release (zpci_ibv[cpu]); + } +kfree (zpci_ibv); + zpci_ibv =NULL ; +out_free_sbv: +airq_iv_release (zpci_sbv); + zpci_sbv =NULL ; +return -ENOMEM ; }static int __init zpci_floating_irq_init (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 897/1848 ALSA: mpu401: shut down timer before freeing MPU
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9332af5220d42341bb1446a62c545c0518e990ef ]
When an MPU401 interface has no usable IRQ, the driver polls raw-MIDI input and output with a timer. During raw-MIDI teardown, the timer callback can already be running when snd_mpu401_uart_remove_timer() clears the last mode bit and calls timer_delete(). That API neither waits for a running callback nor prevents it from rearming the timer, and free_irq() does not synchronize timer callbacks. snd_mpu401_uart_free() can therefore release mpu while the timer callback still uses it.
Initialize the timer once when the MPU object is created and only rearm it while a timer mode is active. Shut it down synchronously after freeing the IRQ so an in-flight callback completes before mpu and its resources are released.
--- sound/drivers/mpu401/mpu401_uart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
sound/drivers/mpu401/mpu401_uart.c +5 -3
@@ -161,14 +161,15 @@ static void snd_mpu401_uart_timer(struct timer_list *t)spin_lock_irqsave (&mpu->timer_lock, flags);/*mpu->mode |= MPU401_MODE_TIMER;*/ -mod_timer (&mpu->timer,1 + jiffies); +if (mpu->timer_invoked) +mod_timer (&mpu->timer,1 + jiffies);spin_unlock_irqrestore (&mpu->timer_lock, flags);if (mpu->rmidi)_snd_mpu401_uart_interrupt (mpu); }/* -* initialize the timer callback if not programmed yet +* arm the timer if it is not already active */ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu,int input) {
@@ -176,7 +177,6 @@ static void snd_mpu401_uart_add_timer (struct snd_mpu401 *mpu, int input)spin_lock_irqsave (&mpu->timer_lock, flags);if (mpu->timer_invoked ==0 ) { -timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 );mod_timer (&mpu->timer,1 + jiffies); } mpu->timer_invoked |= input ? MPU401_MODE_INPUT_TIMER :
@@ -484,6 +484,7 @@ static void snd_mpu401_uart_free(struct snd_rawmidi *rmidi)struct snd_mpu401 *mpu = rmidi->private_data;if (mpu->irq >=0 )free_irq (mpu->irq, (void *) mpu); +timer_delete_sync (&mpu->timer);release_and_free_resource (mpu->res);kfree (mpu); }
@@ -537,6 +538,7 @@ int snd_mpu401_uart_new(struct snd_card *card, int device,spin_lock_init (&mpu->input_lock);spin_lock_init (&mpu->output_lock);spin_lock_init (&mpu->timer_lock); +timer_setup (&mpu->timer, snd_mpu401_uart_timer,0 ); mpu->hardware = hardware; mpu->irq =-1 ;if (! (info_flags &MPU401_INFO_INTEGRATED )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 898/1848 net: skbuff: dont BUG() on a bad csum_start in skb_copy_and_csum_dev()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Josef Bacik <[email protected]>
[ Upstream commit 56453199d28f0072a8196fba14b2d702632e2219 ]
skb_copy_and_csum_dev() copies everything up to the checksum start out of the linear area, and BUG()s if the checksum start is past the end of the linear area. It misses the other direction: a CHECKSUM_PARTIAL skb that has been pulled past its csum_start gives a negative offset, which gets past the check and becomes a ~4GB copy. It also trusts csum_offset when it stores the folded checksum. So far skb_copy_and_csum_bits() BUG()ing on a short skb has covered for that, but once it returns instead, a bad csum_offset would write past the end of the caller's buffer.
The function returns void and its callers are drivers copying a frame into a bounce buffer just before handing it to the hardware. There's nothing for them to back out of, so check both ends of csum_start and that the checksum field fits in the frame, and if not, copy the whole frame with skb_copy_bits() without filling in the checksum, with a DEBUG_NET_WARN_ON_ONCE() for debug kernels. The frame
goes out with a bad checksum and is dropped by the receiver. If even that copy fails, zero the buffer so the driver doesn't send stale bytes.
--- net/core/skbuff.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
net/core/skbuff.c +12 -1
@@ -3149,7 +3149,18 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)else csstart =skb_headlen (skb); -BUG_ON (csstart >skb_headlen (skb)); +if (unlikely (csstart <0 || csstart >skb_headlen (skb) || + (skb->ip_summed ==CHECKSUM_PARTIAL && + csstart + skb->csum_offset +sizeof (__sum16) > + skb->len))) { +WARN_ON_ONCE (IS_ENABLED (CONFIG_DEBUG_NET )); +/* Send the frame without the checksum filled in, or send +* zeroes if we can't even copy it. +*/ +if (skb_copy_bits (skb,0 , to, skb->len)) +memset (to,0 , skb->len); +return ; + }skb_copy_from_linear_data (skb, to, csstart);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 899/1848 fbdev: smscufx: check for fb_deferred_io_init() error
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Stoakes (ARM) <[email protected]>
[ Upstream commit 8ea6c6e77ccf887f3e68c64f4c261071a345da1e ]
fb_deferred_io_init() allocates deferred I/O state, populating info->fbdefio_state, or leaving it NULL if an error occurs.
Currently ufx_ops_open() ignores its return value.
Therefore if an error arises in fb_deferred_io_init() (for instance, due to an allocation failure) info->fbdefio_state is left NULL.
fb_open() will then dereference a NULL pointer (calling fb_deferred_io_open()) as soon as ufx_ops_open() returns.
Additionally, if the allocation of info->fbdefio itself fails, ufx_ops_open() sets info->fbdefio to NULL and invokes fb_deferred_io_init() regardless, hitting BUG_ON(!fbdefio).
Fix this by only invoking fb_deferred_io_init() if the allocation succeeded, and checking for the error.
The driver already supports operating without deferred I/O, so in either case fall back to that by setting info->fbdefio to NULL.
The ignored return value was introduced in commit 56c134f7f1b5 ("fbdev:
Track deferred-I/O pages in pageref struct").
However, the BUG_ON() issue originates from the earlier commit 3c8a63e22a08 ("Add support for SMSC UFX6000/7000 USB display adapters"), so target that for the fix.
--- drivers/video/fbdev/smscufx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/video/fbdev/smscufx.c +3 -3
@@ -1096,10 +1096,10 @@ static int ufx_ops_open(struct fb_info *info, int user)if (fbdefio) { fbdefio->delay =UFX_DEFIO_WRITE_DELAY ; fbdefio->deferred_io = ufx_dpy_deferred_io; - } - info->fbdefio = fbdefio; -fb_deferred_io_init (info); + info->fbdefio = fbdefio; +fb_deferred_io_init (info); + } } pr_debug("open /dev/fb%d user=%d fb_info=%p count=%d",
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 900/1848 f2fs: remove mappedtodisk flag usage in mmap write path
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nanzhe Zhao <[email protected]>
[ Upstream commit b3c9843589257631bac18f30655e82d88970688a ]
PG_mappedtodisk was inherited from the nobh/buffer-head era. However, f2fs has no buffer heads and the flag is no longer meaningful. The only user of the flag is the "no holes" shortcut in f2fs_vm_page_mkwrite(), which makes mmap write faults skip marking the folio dirty. Moreover, it causes the following race condition with filesystem freezing:
CPU0 (write fault) CPU1 (freeze_super)
---- ----
f2fs_vm_page_mkwrite()
sb_start_pagefault()
/* shortcut: no dirty */
sb_end_pagefault()
sb_wait_write(SB_FREEZE_PAGEFAULT)
/* no waiter, passes */
sync_filesystem()
/* folio not dirty, skipped */ finish_fault()
/* PTE writable */
fault_dirty_shared_page()
folio_mark_dirty()
/* dirty folio on a frozen fs */
It will also skip APP_MAPPED_IO iostat/REQ_TIME updates and post-EOF folio zeroing.
Remove this shortcut in f2fs_vm_page_mkwrite() and stop setting it in f2fs_read_single_page().
--- fs/f2fs/data.c | 1 - fs/f2fs/file.c | 6 ------ 2 files changed, 7 deletions(-)
fs/f2fs/data.c +0 -1
@@ -2144,7 +2144,6 @@ static int f2fs_read_single_page(struct inode *inode, struct page *page, got_it:if ((map->m_flags &F2FS_MAP_MAPPED )) { block_nr = map->m_pblk + block_in_file - map->m_lblk; -SetPageMappedToDisk (page);if (!PageUptodate (page) && (!PageSwapCache (page) && !cleancache_get_page (page))) {
fs/f2fs/file.c +0 -6
@@ -133,12 +133,6 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)/* wait for GCed page writeback via META_MAPPING */ f2fs_wait_on_block_writeback (inode, dn.data_blkaddr); -/* -* check to see if the page is mapped already (no holes) -*/ -if (PageMappedToDisk (page)) - goto out_sem; -/* page is wholly or partially inside EOF */ if (((loff_t)(page->index +1 ) <<PAGE_SHIFT ) >i_size_read (inode)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 901/1848 serial: sc16is7xx: declare MCR and IER as volatile registers
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hugo Villeneuve <[email protected]>
[ Upstream commit 1c41d09dcd07ee9648e20aa8238e404c2e6a12fb ]
MCR register has the same address as XON1 register. IER register has the same address as DLH register.
Which register is accessed depends on bits configuration in some other registers.
To prevent potential access errors, declare MCR and IER as volatile registers.
--- drivers/tty/serial/sc16is7xx.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/serial/sc16is7xx.c +2 -0
@@ -467,7 +467,9 @@ static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) {switch (reg >>SC16IS7XX_REG_SHIFT ) {case SC16IS7XX_RHR_REG : +case SC16IS7XX_IER_REG :/* Shared address space with DLH */ case SC16IS7XX_IIR_REG : +case SC16IS7XX_MCR_REG :/* Shared address space with XON1 */ case SC16IS7XX_LSR_REG :case SC16IS7XX_MSR_REG :case SC16IS7XX_TXLVL_REG :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 902/1848 virtiofs: add FUSE protocol validation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuto Ohnuki <[email protected]>
[ Upstream commit 68b69fa0edb241a946cd4c850110990f30705164 ]
Add virtio_fs_verify_response() to validate that the server properly follows the FUSE protocol by checking:
- Response length is at least sizeof(struct fuse_out_header).
- oh.len matches the actual response length.
- oh.unique matches the request's unique identifier.
On validation failure, set error to -EIO and normalize oh.len to prevent underflow in copy_args_from_argbuf().
Addresses the TODO comment in virtio_fs_request_complete().
Stable-dep-of: 5364d081125a ("virtiofs: validate fixed-output response length")
--- fs/fuse/virtio_fs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-)
fs/fuse/virtio_fs.c +25 -4
@@ -556,6 +556,27 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req) req->argbuf =NULL ; } +/* Verify that the server properly follows the FUSE protocol */ +static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) +{ +struct fuse_out_header *oh = &req->out.h; + +if (len <sizeof (*oh)) { +pr_warn ("virtio-fs: response too short (%u)\n" , len); +return false; + } +if (oh->len != len) { +pr_warn ("virtio-fs: oh.len mismatch (%u != %u)\n" , oh->len, len); +return false; + } +if (oh->unique != req->in.h.unique) { +pr_warn ("virtio-fs: oh.unique mismatch (%llu != %llu)\n" , + oh->unique, req->in.h.unique); +return false; + } +return true; +} +/* Work function for request completion */ static void virtio_fs_request_complete (struct fuse_req *req,struct virtio_fs_vq *fsvq)
@@ -566,10 +587,6 @@ static void virtio_fs_request_complete(struct fuse_req *req,unsigned int len, i, thislen;struct page *page; -/* -* TODO verify that server properly follows FUSE protocol -* (oh.uniq, oh.len) -*/ args = req->args;copy_args_from_argbuf (args, req);
@@ -625,6 +642,10 @@ static void virtio_fs_requests_done_work(struct work_struct *work)virtqueue_disable_cb (vq);while ((req =virtqueue_get_buf (vq, &len)) !=NULL ) { +if (!virtio_fs_verify_response (req, len)) { + req->out.h.error = -EIO ; + req->out.h.len =sizeof (struct fuse_out_header ); + }spin_lock (&fpq->lock);list_move_tail (&req->list, &reqs);spin_unlock (&fpq->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 903/1848 virtiofs: validate fixed-output response length
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sung Byeongchan <[email protected]>
[ Upstream commit 5364d081125a34e90851fbb46ecc93f79339ce78 ]
A short successful virtiofs response can leave the fixed-output portion of the request argument buffer unwritten. The completion path nevertheless copies the full declared output to the request destination, allowing stale allocator contents to reach callers such as fuse_statfs().
Require successful fixed-output responses to contain their complete declared output. Continue to permit a shorter final argument only for out_argvar requests. Reject positive and internal restart error values and require valid error replies to be header-only. The error already stored in the FUSE output header is returned by fuse_request_end(), so do not copy output arguments from an error reply.
This was found by source review with AI assistance. A header-only successful FUSE_STATFS reply returned stale fields in nine of nine calls across three boots. The fixed kernel rejected the short response and preserved complete replies, valid negative-error replies, and variable-output replies.
--- fs/fuse/virtio_fs.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
fs/fuse/virtio_fs.c +30 -0
@@ -527,6 +527,10 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)unsigned int num_out;unsigned int i; +/* fuse_request_end() returns this error; there are no args to copy. */ +if (req->out.h.error) + goto out; + remaining = req->out.h.len -sizeof (req->out.h); num_in = args->in_numargs - args->in_pages; num_out = args->out_numargs - args->out_pages;
@@ -552,6 +556,7 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)if (args->out_argvar) args->out_args[args->out_numargs -1 ].size = remaining; +out:kfree (req->argbuf); req->argbuf =NULL ; }
@@ -559,7 +564,9 @@ static void copy_args_from_argbuf(struct fuse_args *args, struct fuse_req *req)/* Verify that the server properly follows the FUSE protocol */ static bool virtio_fs_verify_response (struct fuse_req *req,unsigned int len) { +struct fuse_args *args = req->args;struct fuse_out_header *oh = &req->out.h; +unsigned int expected;if (len <sizeof (*oh)) {pr_warn ("virtio-fs: response too short (%u)\n" , len);
@@ -574,6 +581,29 @@ static bool virtio_fs_verify_response(struct fuse_req *req, unsigned int len) oh->unique, req->in.h.unique);return false; } +if (oh->error <= -ERESTARTSYS || oh->error >0 ) { +pr_warn ("virtio-fs: invalid error value (%d)\n" , oh->error); +return false; + } + +if (oh->error) { +if (len !=sizeof (*oh)) { +pr_warn ("virtio-fs: error response too long (%u)\n" , len); +return false; + } +return true; + } + + expected =sizeof (*oh) + +fuse_len_args (args->out_numargs, args->out_args); +if (len > expected || + (len < expected && + (!args->out_argvar || + expected - len > args->out_args[args->out_numargs -1 ].size))) { +pr_warn ("virtio-fs: invalid response length (%u, expected %u)\n" , + len, expected); +return false; + }return true; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 904/1848 irqchip/imx-intmux: Convert to platform_driver::remove_new() callback
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 984e5c7b8d7bac9efd3818e06dcf1f7aab7701b2 ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks.
To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new(), which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove().
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: b167c1a30e9e ("irqchip/imx-intmux: Fix runtime PM teardown on remove")
--- drivers/irqchip/irq-imx-intmux.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/irqchip/irq-imx-intmux.c +6 -8
@@ -286,7 +286,7 @@ static int imx_intmux_probe(struct platform_device *pdev)return ret; } -static int imx_intmux_remove (struct platform_device *pdev) +static void imx_intmux_remove (struct platform_device *pdev) {struct intmux_data *data =platform_get_drvdata (pdev);int i;
@@ -302,8 +302,6 @@ static int imx_intmux_remove(struct platform_device *pdev) }pm_runtime_disable (&pdev->dev); - -return 0 ; }#ifdef CONFIG_PM
@@ -358,11 +356,11 @@ static const struct of_device_id imx_intmux_id[] = {static struct platform_driver imx_intmux_driver = { .driver = { - .name ="imx-intmux" , - .of_match_table = imx_intmux_id, - .pm = &imx_intmux_pm_ops, + .name ="imx-intmux" , + .of_match_table = imx_intmux_id, + .pm = &imx_intmux_pm_ops, }, - .probe = imx_intmux_probe, - .remove = imx_intmux_remove, + .probe = imx_intmux_probe, + .remove_new = imx_intmux_remove, };builtin_platform_driver (imx_intmux_driver);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 905/1848 irqchip/imx-intmux: Fix runtime PM teardown on remove
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit b167c1a30e9e020e4c5e102c7a555943742c024b ]
imx_intmux_probe() enables the IPG clock and then drops its runtime PM reference with pm_runtime_put(). With CONFIG_PM enabled, the runtime suspend callback disables the IPG clock. With CONFIG_PM disabled, the clock remains enabled after probe.
imx_intmux_remove() accesses the CHANIER registers without first making sure that the device is runtime active. The device may therefore be runtime suspended with the IPG clock disabled when these registers are accessed. In addition, the remove path only calls pm_runtime_disable() and does not balance the clock enable when CONFIG_PM is disabled.
Resume the device and acquire a runtime PM reference before accessing the registers. If resume fails, skip the register accesses but still tear down the chained handlers and IRQ domains. Disable runtime PM afterwards, drop the acquired reference without triggering another runtime suspend, and explicitly disable the IPG clock.
This keeps the clock enabled while the hardware registers are accessed and balances the clk_prepare_enable() performed during probe for both CONFIG_PM configurations.
This issue was found by manual code inspection.
--- drivers/irqchip/irq-imx-intmux.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/irqchip/irq-imx-intmux.c +12 -3
@@ -289,12 +289,16 @@ static int imx_intmux_probe(struct platform_device *pdev)static void imx_intmux_remove (struct platform_device *pdev) {struct intmux_data *data =platform_get_drvdata (pdev); -int i; +int i, ret; + + ret =pm_runtime_resume_and_get (&pdev->dev); +if (ret <0 ) +dev_warn (&pdev->dev,"failed to resume device: %d\n" , ret);for (i =0 ; i < data->channum; i++) {/* disable all interrupt sources of this channel */ -writel_relaxed (0 , data->regs +CHANIER (i)); - +if (ret >=0 ) +writel_relaxed (0 , data->regs +CHANIER (i));irq_set_chained_handler_and_data (data->irqchip_data[i].irq,NULL ,NULL );
@@ -302,6 +306,11 @@ static void imx_intmux_remove(struct platform_device *pdev) }pm_runtime_disable (&pdev->dev); +if (ret >=0 ) { +pm_runtime_put_noidle (&pdev->dev); +clk_disable_unprepare (data->ipg_clk); +pm_runtime_set_suspended (&pdev->dev); + } }#ifdef CONFIG_PM
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 906/1848 xen/pcifront: Drop pcifront_common_process() tests of pcidev, pdrv
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 34ab316d7287692bad41ce4a431b43d60a8bd20f ]
pcifront_common_process() exits early if pcidev or pcidev->driver are NULL, so simplify it by not checking them again.
Stable-dep-of: 3b4854b69ee7 ("xen/pcifront: check that an AER callback exists before calling it")
--- drivers/pci/xen-pcifront.c | 52 +++++++++++++------------------------- 1 file changed, 17 insertions(+), 35 deletions(-)
drivers/pci/xen-pcifront.c +17 -35
@@ -585,61 +585,43 @@ static pci_ers_result_t pcifront_common_process(int cmd, struct pcifront_device *pdev, pci_channel_state_t state) { -pci_ers_result_t result;struct pci_driver *pdrv;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; -int flag =0 ;dev_dbg (&pdev->xdev->dev,"pcifront AER process: cmd %x (bus:%x, devfn%x)" , cmd, bus, devfn); - result =PCI_ERS_RESULT_NONE ; pcidev =pci_get_domain_bus_and_slot (domain, bus, devfn);if (!pcidev || !pcidev->driver) {dev_err (&pdev->xdev->dev,"device or AER driver is NULL\n" );pci_dev_put (pcidev); -return result; +return PCI_ERS_RESULT_NONE ; } pdrv = pcidev->driver; -if (pdrv) { -if (pdrv->err_handler && pdrv->err_handler->error_detected) { -pci_dbg (pcidev,"trying to call AER service\n" ); -if (pcidev) { - flag =1 ; -switch (cmd) { -case XEN_PCI_OP_aer_detected: - result = pdrv->err_handler-> -error_detected (pcidev, state); -break ; -case XEN_PCI_OP_aer_mmio: - result = pdrv->err_handler-> -mmio_enabled (pcidev); -break ; -case XEN_PCI_OP_aer_slotreset: - result = pdrv->err_handler-> -slot_reset (pcidev); -break ; -case XEN_PCI_OP_aer_resume: - pdrv->err_handler->resume (pcidev); -break ; -default : -dev_err (&pdev->xdev->dev, -"bad request in aer recovery " -"operation!\n" ); - - } - } +if (pdrv->err_handler && pdrv->err_handler->error_detected) { +pci_dbg (pcidev,"trying to call AER service\n" ); +switch (cmd) { +case XEN_PCI_OP_aer_detected: +return pdrv->err_handler->error_detected (pcidev, state); +case XEN_PCI_OP_aer_mmio: +return pdrv->err_handler->mmio_enabled (pcidev); +case XEN_PCI_OP_aer_slotreset: +return pdrv->err_handler->slot_reset (pcidev); +case XEN_PCI_OP_aer_resume: + pdrv->err_handler->resume (pcidev); +return PCI_ERS_RESULT_NONE ; +default : +dev_err (&pdev->xdev->dev, +"bad request in aer recovery operation!\n" ); } } -if (!flag) - result =PCI_ERS_RESULT_NONE ; -return result; +return PCI_ERS_RESULT_NONE ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 907/1848 xen/pcifront: check that an AER callback exists before calling it
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yehyeong Lee <[email protected]>
[ Upstream commit 3b4854b69ee70fffb2fa7acac09e715a7efcbae1 ]
pcifront_common_process() handles an AER request from the backend by dispatching on aer_op.cmd to the bound driver's PCI error handler. It only checks that err_handler and err_handler->error_detected are present, then for the mmio_enabled, slot_reset and resume commands it calls the corresponding callback unconditionally. Those three callbacks are optional -- the PCI core NULL-checks each of them individually before use -- and many drivers (for example igb, igc, ice and ixgbevf) install error_detected without all of them.
aer_op.cmd comes from the shared ring, so a malicious or buggy backend can send XEN_PCI_OP_aer_mmio (or _slotreset/_resume) for a device whose driver leaves that callback NULL and make the frontend call through a NULL pointer, crashing the guest.
Check each callback before calling it. When mmio_enabled or slot_reset is absent, return PCI_ERS_RESULT_RECOVERED so recovery proceeds, as the PCI core does for a missing callback; returning PCI_ERS_RESULT_NONE would instead make xen-pciback tear the guest domain down.
Message-ID: <[email protected]>
--- drivers/pci/xen-pcifront.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pci/xen-pcifront.c +8 -3
@@ -609,11 +609,16 @@ static pci_ers_result_t pcifront_common_process(int cmd,case XEN_PCI_OP_aer_detected:return pdrv->err_handler->error_detected (pcidev, state);case XEN_PCI_OP_aer_mmio: -return pdrv->err_handler->mmio_enabled (pcidev); +if (pdrv->err_handler->mmio_enabled) +return pdrv->err_handler->mmio_enabled (pcidev); +return PCI_ERS_RESULT_RECOVERED ;case XEN_PCI_OP_aer_slotreset: -return pdrv->err_handler->slot_reset (pcidev); +if (pdrv->err_handler->slot_reset) +return pdrv->err_handler->slot_reset (pcidev); +return PCI_ERS_RESULT_RECOVERED ;case XEN_PCI_OP_aer_resume: - pdrv->err_handler->resume (pcidev); +if (pdrv->err_handler->resume) + pdrv->err_handler->resume (pcidev);return PCI_ERS_RESULT_NONE ;default : dev_err(&pdev->xdev->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 908/1848 PCI: rockchip: Drive at 2.5 GT/s, error other speeds
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geraldo Nascimento <[email protected]>
[ Upstream commit 84d08ff902f1ec01177fef1a21a38934927f5aee ]
Configure the core to be driven at 2.5 GT/s Link Speed and ignore any other speed with a warning. Also drop the 5.0 GT/s Link Speed defines from Rockchip PCIe header.
The reason is that Shawn Lin from Rockchip has reiterated that there may be danger of "catastrophic failure" in using their PCIe with 5.0 GT/s speeds.
While Rockchip has done so informally without issuing a proper errata, and the particulars are thus unknown, this may cause data loss or worse.
This change is corroborated by RK3399 official datasheet [1], which states maximum link speed for this platform is 2.5 GT/s.
[1] https://opensource.rock-chips.com/images/d/d7/Rockchip_RK3399_Datasheet_V2.1-20200323.pdf
--- drivers/pci/controller/pcie-rockchip.c | 14 ++++++-------- drivers/pci/controller/pcie-rockchip.h | 1 - 2 files changed, 6 insertions(+), 9 deletions(-)
drivers/pci/controller/pcie-rockchip.c +6 -8
@@ -65,8 +65,10 @@ int rockchip_pcie_parse_dt(struct rockchip_pcie *rockchip) } rockchip->link_gen =of_pci_get_max_link_speed (node); -if (rockchip->link_gen <0 || rockchip->link_gen >2 ) - rockchip->link_gen =2 ; +if (rockchip->link_gen <0 || rockchip->link_gen >=2 ) { + rockchip->link_gen =1 ; +dev_warn (dev,"invalid max-link-speed, limited to 2.5 GT/s\n" ); + } rockchip->core_rst =devm_reset_control_get_exclusive (dev,"core" );if (IS_ERR (rockchip->core_rst)) {
@@ -236,12 +238,8 @@ int rockchip_pcie_init_port(struct rockchip_pcie *rockchip) goto err_exit_phy; } -if (rockchip->link_gen ==2 ) -rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_2 , -PCIE_CLIENT_CONFIG ); -else -rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_1 , -PCIE_CLIENT_CONFIG ); +rockchip_pcie_write (rockchip,PCIE_CLIENT_GEN_SEL_1 , +PCIE_CLIENT_CONFIG ); regs =PCIE_CLIENT_LINK_TRAIN_ENABLE |PCIE_CLIENT_ARI_ENABLE |PCIE_CLIENT_CONF_LANE_NUM (rockchip->lanes);
drivers/pci/controller/pcie-rockchip.h +0 -1
@@ -36,7 +36,6 @@#define PCIE_CLIENT_MODE_RC HIWORD_UPDATE_BIT(0x0040)#define PCIE_CLIENT_MODE_EP HIWORD_UPDATE(0x0040, 0)#define PCIE_CLIENT_GEN_SEL_1 HIWORD_UPDATE(0x0080, 0) -#define PCIE_CLIENT_GEN_SEL_2 HIWORD_UPDATE_BIT(0x0080)#define PCIE_CLIENT_LEGACY_INT_CTRL (PCIE_CLIENT_BASE + 0x0c)#define PCIE_CLIENT_INT_IN_ASSERT HIWORD_UPDATE_BIT(0x0002)#define PCIE_CLIENT_INT_IN_DEASSERT HIWORD_UPDATE(0x0002, 0)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 909/1848 soc: fsl: dpio: Free the IRQ before releasing the I/O object
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit a7831c657c90e8f9165f6bbe0cc56262fee075e8 ]
The DPIO interrupt handler accesses priv->io, but dpaa2_dpio_remove() releases that object before tearing down the interrupts. The IRQ was requested with devm_request_irq(), and unregister_dpio_irq_handlers() only clears its affinity hint. fsl_mc_free_irqs() returns IRQ resources to the MC resource pool without freeing the handler. An interrupt can therefore access the freed I/O object before devres releases the IRQ.
Explicitly free the managed IRQ in unregister_dpio_irq_handlers() before returning its resource to the pool, and perform IRQ teardown before releasing the I/O object. This also waits for an in-flight handler while the object is still valid.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/soc/fsl/dpio/dpio-driver.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/soc/fsl/dpio/dpio-driver.c +3 -2
@@ -89,6 +89,7 @@ static void unregister_dpio_irq_handlers(struct fsl_mc_device *dpio_dev)/* clear the affinity hint */ irq_set_affinity_hint (irq->msi_desc->irq,NULL ); +devm_free_irq (&dpio_dev->dev, irq->msi_desc->irq, &dpio_dev->dev); }static int register_dpio_irq_handlers (struct fsl_mc_device *dpio_dev,int cpu)
@@ -280,10 +281,10 @@ static int dpaa2_dpio_remove(struct fsl_mc_device *dpio_dev) priv =dev_get_drvdata (dev); cpu =dpaa2_io_get_cpu (priv->io); -dpaa2_io_down (priv->io); -dpio_teardown_irqs (dpio_dev); +dpaa2_io_down (priv->io); +cpumask_set_cpu (cpu, cpus_unused_mask); err = dpio_open(dpio_dev->mc_io, 0, dpio_dev->obj_desc.id,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 910/1848 nilfs2: force clear dirty state when restoring from the shadow map
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiaming Zhang <[email protected]>
[ Upstream commit cb6702e63e0a16afd83875294e5ce53becdd1b1f ]
When garbage collection fails, nilfs2 rolls the DAT metadata file's page cache back to a shadow copy taken before GC started. nilfs_clear_dirty_pages() drops the dirty state of the folios in the DAT cache, then nilfs_copy_back_pages() overwrites them with the saved contents and warns if one is still dirty:
/* overwrite existing folio in the destination cache */ WARN_ON(folio_test_dirty(dfolio));
nilfs_clear_dirty_pages() used to clear the dirty state unconditionally, which is safe here because the rollback runs with the log writer stopped, so nothing else can dirty the cache while it runs. The same helper is also used when writeback finds dirty folios after the filesystem has degraded to read-only, where it does run concurrently with the log writer, so commit ca76bb226bf4 ("nilfs2: do not force clear folio if buffer is referenced") made nilfs_clear_folio_dirty() skip a folio if any of its buffer heads is busy. The rollback caller shares that helper, so its clearing step can now return with a folio still dirty.
A DAT folio can hold a busy buffer head without anyone modifying the
folio: nilfs_mdt_read_block() submits read-ahead for the blocks following the one it was asked for and waits only for the first, so the read-ahead buffers are still locked when it returns. With a block size smaller than the page size, a locked read-ahead buffer can share a folio with a block that GC dirtied and keep the whole folio dirty past the clearing step.
Add a force flag to nilfs_clear_dirty_pages() and nilfs_clear_folio_dirty() that skips the busy buffer check, and set it in the two calls from nilfs_mdt_restore_from_shadow_map(). The read-only fallback callers keep passing false, so that commit still protects them and the WARN_ON() is left alone.
--- fs/nilfs2/inode.c | 4 ++-- fs/nilfs2/mdt.c | 6 +++--- fs/nilfs2/page.c | 50 +++++++++++++++++++++++++++-------------------- fs/nilfs2/page.h | 4 ++-- 4 files changed, 36 insertions(+), 28 deletions(-)
fs/nilfs2/inode.c +2 -2
@@ -162,7 +162,7 @@ static int nilfs_writepages(struct address_space *mapping,int err =0 ;if (sb_rdonly (inode->i_sb)) { -nilfs_clear_dirty_pages (mapping); +nilfs_clear_dirty_pages (mapping, false);return -EROFS ; }
@@ -185,7 +185,7 @@ static int nilfs_writepage(struct page *page, struct writeback_control *wbc)* have dirty pages that try to be flushed in background. * So, here we simply discard this dirty page. */ -nilfs_clear_dirty_page (page); +nilfs_clear_dirty_page (page, false);unlock_page (page);return -EROFS ; }
fs/nilfs2/mdt.c +3 -3
@@ -410,7 +410,7 @@ nilfs_mdt_write_page(struct page *page, struct writeback_control *wbc)* have dirty pages that try to be flushed in background. * So, here we simply discard this dirty page. */ -nilfs_clear_dirty_page (page); +nilfs_clear_dirty_page (page, false);unlock_page (page);return -EROFS ; }
@@ -631,10 +631,10 @@ void nilfs_mdt_restore_from_shadow_map(struct inode *inode)if (mi->mi_palloc_cache)nilfs_palloc_clear_cache (inode); -nilfs_clear_dirty_pages (inode->i_mapping); +nilfs_clear_dirty_pages (inode->i_mapping, true);nilfs_copy_back_pages (inode->i_mapping, shadow->inode->i_mapping); -nilfs_clear_dirty_pages (ii->i_assoc_inode->i_mapping); +nilfs_clear_dirty_pages (ii->i_assoc_inode->i_mapping, true);nilfs_copy_back_pages (ii->i_assoc_inode->i_mapping,NILFS_I (shadow->inode)->i_assoc_inode->i_mapping);
fs/nilfs2/page.c +29 -21
81 lines not on this page · raw message
fs/nilfs2/page.h +2 -2
@@ -41,8 +41,8 @@ void nilfs_page_bug(struct page *);int nilfs_copy_dirty_pages (struct address_space *,struct address_space *);void nilfs_copy_back_pages (struct address_space *,struct address_space *); -void nilfs_clear_dirty_page (struct page *page); -void nilfs_clear_dirty_pages (struct address_space *mapping); +void nilfs_clear_dirty_page (struct page *page,bool force); +void nilfs_clear_dirty_pages (struct address_space *mapping,bool force);void nilfs_mapping_init (struct address_space *mapping,struct inode *inode);unsigned int nilfs_page_count_clean_buffers (struct page *,unsigned int ,unsigned int );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 911/1848 wifi: brcmfmac: cfg80211: Report port_authorized for 4-way HS offload
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Janne Grunau <[email protected]>
[ Upstream commit 6fff9de5c5b425817588eeed42bd56d665751c13 ]
Since commit 416386060 ("Mark authorization completed on driver indication during 4-way HS offload") [0] wpa_supplicant expects NL80211_CMD_PORT_AUTHORIZED to complete the authentication when the driver supports 4-way handshake offload.
This was apparently never tested with the upstream brcmfmac driver as it does not report this. This broke authentication on Apple silicon devices (BRCM4378, BRMC4387, BRMC4388) and other devices when wpa_supplicant 2.11 was released [1]. This was initially dealt with by reverting the commit in Fedora [2] and other Linux distributions.
Instead of carrying the revert over to wpa_supplicant 2.12 add the expected NL80211_CMD_PORT_AUTHORIZED when the connection is established.
The "Fixes:" tag is not fully accurate as this has only became an issue after userspace changes years after the change. Since the change is expected to be required in all active stable branches for wpa_supplicant 2.11 / 2.12 compatibility it is helpful even though BRCMF_PROFILE_FWSUP_SAE did not exists then.
--- drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +6 -0
@@ -5973,6 +5973,7 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg,struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;struct brcmf_cfg80211_connect_info *conn_info =cfg_to_conn (cfg);struct cfg80211_connect_resp_params conn_params; +bool authorized;brcmf_dbg (TRACE ,"Enter\n" );
@@ -5993,7 +5994,12 @@ brcmf_bss_connect_done(struct brcmf_cfg80211_info *cfg, conn_params.req_ie_len = conn_info->req_ie_len; conn_params.resp_ie = conn_info->resp_ie; conn_params.resp_ie_len = conn_info->resp_ie_len; + authorized = completed && + (profile->use_fwsup ==BRCMF_PROFILE_FWSUP_SAE || + profile->use_fwsup ==BRCMF_PROFILE_FWSUP_PSK );cfg80211_connect_done (ndev, &conn_params,GFP_KERNEL ); +if (authorized) +cfg80211_port_authorized (ndev, profile->bssid,GFP_KERNEL );brcmf_dbg (CONN ,"Report connect result - connection %s\n" , completed ?"succeeded" :"failed" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 912/1848 spi: jcore: Fix trailing statements should be on next line
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jay Fang <[email protected]>
[ Upstream commit 45793de7bf89fbd0fd1e2db9dda4e58a9c1395ee ]
Fix checkpatch error:
ERROR: trailing statements should be on next line #85: FILE: spi-jcore.c:85:
+ if (speed == hw->speed_hz) return;
Stable-dep-of: 7db773075501 ("spi: jcore: fix divide-by-zero when speed_hz is zero")
--- drivers/spi/spi-jcore.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-jcore.c +2 -1
@@ -82,7 +82,8 @@ static void jcore_spi_chipsel(struct spi_device *spi, bool value)static void jcore_spi_baudrate (struct jcore_spi *hw,int speed) { -if (speed == hw->speed_hz)return ; +if (speed == hw->speed_hz) +return ; hw->speed_hz = speed;if (speed >= hw->clock_freq /2 ) hw->speed_reg =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 913/1848 spi: jcore: fix divide-by-zero when speed_hz is zero
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weibin Liu <[email protected]>
[ Upstream commit 7db773075501248893c22b11bedc6745d6d0be45 ]
jcore_spi_baudrate() computes hw->clock_freq / 2 / speed without validating speed. The SPI core fills transfer.speed_hz from spi->max_speed_hz when it is zero, and jcore_spi_probe() never sets host->max_speed_hz, so the clamp in __spi_setup() is skipped. A spi_device created via the sysfs new_device interface (or a DT node without spi-max-frequency) therefore has max_speed_hz == 0, and any SPI_IOC_MESSAGE transfer reaches jcore_spi_baudrate() with speed == 0, causing a division by zero and a kernel panic.
Clamp speed to a minimum of 1 Hz before the division so the divisor is never zero. The computed divider then truncates to the register field width and the transfer simply runs at the slowest supported rate.
Verified by inspection of the __spi_setup() clamp and __spi_validate()'s speed_hz handling; the division-by-zero path requires the J-Core controller, which was not available.
--- drivers/spi/spi-jcore.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/spi/spi-jcore.c +2 -0
@@ -84,6 +84,8 @@ static void jcore_spi_baudrate(struct jcore_spi *hw, int speed) {if (speed == hw->speed_hz)return ; +if (speed <=0 ) + speed =1 ; hw->speed_hz = speed;if (speed >= hw->clock_freq /2 ) hw->speed_reg =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 914/1848 serial: 8250_exar: store the GPIO platform device in struct exar8250
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Slaby (SUSE) <[email protected]>
[ Upstream commit 33d337816e00994daaf670243186d9e537ee090d ]
The GPIO platform device is registered via platform->register_gpio() when port 0 is being set up. It is stored to port->port.private_data of the on-stack uart template (and from there it is copied into every registered port). pci_xr17v35x_exit() then fetches it back by serial8250_get_port(priv->line[0]).
But port 0 does not have to exist at that point. If serial8250_register_8250_port() fails for port 0, priv->line[0] holds a negative error code. The probe still succeeds (it only breaks the loop), so on unbind, priv->line[0] (a negative value) is passed to serial8250_get_port(). The GPIO device is never unregistered and a bogus port is accessed.
The same problem would also occur after the planned conversion of serial8250_register_8250_port() to return a uart port instead of a line. As Sashiko pointed out in that case:
If board->setup() fails for the first port (i=0) in exar_pci_probe(), priv->uport[0] remains NULL. If serial8250_register_8250_port() fails, it returns an ERR_PTR. In either case, the loop breaks and probe returns success. When the device is later unbound, pci_xr17v35x_exit() unconditionally passes priv->uport[0] to platform->unregister_gpio(), which will dereference it without checking for validity.
The GPIO device belongs to the PCI device, not to any particular port. So store it in a new struct exar8250::gpio member. Pass priv to both ->register_gpio() and ->unregister_gpio(), so that pci_xr17v35x_exit() does not need to look up any port at all.
--- drivers/tty/serial/8250/8250_exar.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-)
drivers/tty/serial/8250/8250_exar.c +14 -13
@@ -168,7 +168,8 @@ struct exar8250;struct exar8250_platform {int (*rs485_config)(struct uart_port *,struct serial_rs485 *);const struct serial_rs485 *rs485_supported; -int (*register_gpio)(struct pci_dev *,struct uart_8250_port *); +int (*register_gpio)(struct exar8250 *priv,struct pci_dev *pcidev, +struct uart_8250_port *port); };/**
@@ -190,6 +191,7 @@ struct exar8250 {unsigned int nr;struct exar8250_board *board;void __iomem *virt; +struct platform_device *gpio;int line[]; };
@@ -435,12 +437,11 @@ static const struct property_entry exar_gpio_properties[] = { { } }; -static int xr17v35x_register_gpio (struct pci_dev *pcidev, +static int xr17v35x_register_gpio (struct exar8250 *priv,struct pci_dev *pcidev,struct uart_8250_port *port) {if (pcidev->vendor ==PCI_VENDOR_ID_EXAR ) - port->port.private_data = -__xr17v35x_register_gpio (pcidev, exar_gpio_properties); + priv->gpio =__xr17v35x_register_gpio (pcidev, exar_gpio_properties);return 0 ; }
@@ -522,8 +523,9 @@ static const struct property_entry iot2040_gpio_properties[] = { { } }; -static int iot2040_register_gpio (struct pci_dev *pcidev, -struct uart_8250_port *port) +static int iot2040_register_gpio (struct exar8250 *priv, +struct pci_dev *pcidev, +struct uart_8250_port *port) {u8 __iomem *p = port->port.membase;
@@ -532,8 +534,7 @@ static int iot2040_register_gpio(struct pci_dev *pcidev,writeb (IOT2040_UARTS_ENABLE , p +UART_EXAR_MPIOLVL_15_8 );writeb (IOT2040_UARTS_GPIO_HI_MODE , p +UART_EXAR_MPIOSEL_15_8 ); - port->port.private_data = -__xr17v35x_register_gpio (pcidev, iot2040_gpio_properties); + priv->gpio =__xr17v35x_register_gpio (pcidev, iot2040_gpio_properties);return 0 ; }
@@ -602,7 +603,7 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,/* Setup Multipurpose Input/Output pins. */ setup_gpio (pcidev, p); - ret = platform->register_gpio (pcidev, port); + ret = platform->register_gpio (priv, pcidev, port); }return ret;
@@ -611,11 +612,11 @@ pci_xr17v35x_setup(struct exar8250 *priv, struct pci_dev *pcidev,static void pci_xr17v35x_exit (struct pci_dev *pcidev) {struct exar8250 *priv =pci_get_drvdata (pcidev); -struct uart_8250_port *port =serial8250_get_port (priv->line[0 ]); -struct platform_device *pdev = port->port.private_data; -platform_device_unregister (pdev); - port->port.private_data =NULL ; +if (priv->gpio) { +platform_device_unregister (priv->gpio); + priv->gpio =NULL ; + } }static inline void exar_misc_clear (struct exar8250 *priv)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 915/1848 scsi: ufs: bsg: Clear the reply buffer before use
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanley Jhu <[email protected]>
[ Upstream commit 2e63ac76cc08ea376ba61fef52f7b7849e35024d ]
The reply buffer is allocated once per tag and reused. Requests that complete with a positive status do not fill all of it, so user space receives bytes from an earlier request on the same tag.
Clear the whole reply buffer on entry to ufs_bsg_request().
--- drivers/scsi/ufs/ufs_bsg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ufs/ufs_bsg.c +1 -1
@@ -95,7 +95,7 @@ static int ufs_bsg_request(struct bsg_job *job)if (ret) goto out; - bsg_reply->reply_payload_rcv_len =0 ; +memset (job->reply,0 , job->reply_len);pm_runtime_get_sync (hba->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 916/1848 f2fs: bound the SIT/NAT bitmaps by the checkpoint pack
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kaixuan Li <[email protected]>
[ Upstream commit 080833a32fd5dc10b3acf2fa9af9b3213e6cb617 ]
sit_ver_bitmap_bytesize and nat_ver_bitmap_bytesize are used as memcpy lengths into and out of sbi->ckpt, which is sized from cp_payload alone, and nothing compares either length against that allocation.
sanity_check_ckpt() has checked these two fields since c77ec61ca0a4, which added them after a crafted image overran build_sit_info(). That check ties each length to a segment count; it never compares either against the allocation, which is the half this adds.
Mounting over-reads in build_sit_info() and build_node_manager(), and the first checkpoint writes the same lengths back through the same pointers, so the over-read's contents reach the on-disk checkpoint. An unmount is enough; the filesystem does not have to be used.
Bound both ends the way __bitmap_ptr() lays them out. The three branches differ, so a single sum of the two lengths would still admit a small overflow when cp_payload is non-zero.
--- fs/f2fs/super.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
fs/f2fs/super.c +24 -0
@@ -3030,6 +3030,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)block_t avail_node_count, valid_node_count;unsigned int nat_blocks, nat_bits_bytes, nat_bits_blocks;unsigned int sit_blk_cnt; +unsigned long long ckpt_size, sit_end, nat_end;int i, j; total =le32_to_cpu (raw_super->segment_count);
@@ -3148,6 +3149,29 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)return 1 ; } +/* +* Nothing above ties the bitmap lengths to sbi->ckpt, which is +* (1 + cp_payload) blocks. Bound both ends the way __bitmap_ptr() +* lays them out. +*/ + ckpt_size = (unsigned long long )(cp_payload +1 ) *F2FS_BLKSIZE ; +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG )) { + nat_end =CP_MIN_CHKSUM_OFFSET +sizeof (__le32) + nat_bitmap_size; + sit_end = nat_end + sit_bitmap_size; + }else if (cp_payload >0 ) { + nat_end =CP_MIN_CHKSUM_OFFSET + nat_bitmap_size; + sit_end =F2FS_BLKSIZE + sit_bitmap_size; + }else { + sit_end =CP_MIN_CHKSUM_OFFSET + sit_bitmap_size; + nat_end = sit_end + nat_bitmap_size; + } + +if (sit_end > ckpt_size || nat_end > ckpt_size) { +f2fs_err (sbi,"Bitmaps do not fit the checkpoint pack: sit ends at %llu, nat at %llu, pack is %llu bytes" , + sit_end, nat_end, ckpt_size); +return 1 ; + } +if (__is_set_ckpt_flags (ckpt,CP_LARGE_NAT_BITMAP_FLAG ) &&le32_to_cpu (ckpt->checksum_offset) !=CP_MIN_CHKSUM_OFFSET ) { f2fs_warn(sbi, "using deprecated layout of large_nat_bitmap, "
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 917/1848 fuse: dont launder folios of a bad inode
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joanne Koong <[email protected]>
[ Upstream commit 01d0f3d294af126f517d92c11e100525537f8be4 ]
fuse_flush() and fuse_writepages() reject writing back dirty data for any inode that has been marked bad, but fuse_launder_folio() doesn't.
This can cause the following warning in fuse_write_file_get() to trigger, as reported by syzbot:
WARNING: fs/fuse/file.c:2043 at fuse_write_file_get fs/fuse/file.c:2043 [inline]
WARNING: fs/fuse/file.c:2043 at fuse_iomap_writeback_range+0x7c8/0x18f0 fs/fuse/file.c:2227
Call Trace:
iomap_writeback_folio+0x1526/0x2490 fs/iomap/buffered-io.c:2022
fuse_launder_folio+0x17b/0x240 fs/fuse/file.c:2331
folio_unmap_invalidate+0x4cd/0x830 mm/truncate.c:634
invalidate_inode_pages2_range+0x629/0xb30 mm/truncate.c:726
fuse_open+0x5a6/0x770 fs/fuse/file.c:297This can be hit on a writeback cache mount:
1) a writeable file is open and a buffered write dirties some pages
2) another thread opens the same file read-only. fuse_open() passes the bad inode check and sends OPEN to the server.
3) a SETATTR reply with the wrong file type marks the inode bad
4) the writeable file is closed. Flush and release skip writeback because the inode is bad. The pages stay dirty but the file gets removed from write_files.
5) server replies to the OPEN. The reply has no FOPEN_KEEP_CACHE, so fuse_open() calls invalidate_inode_pages2().
6) the invalidation finds the dirty pages and calls fuse_launder_folio(), which finds no wriable file and hits the WARN_ON in fuse_write_file_get().
Instead of trying to write back dirty data for the bad inode, fuse_launder_folio() should return -EIO.
--- fs/fuse/file.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/fuse/file.c +4 -0
@@ -2345,6 +2345,10 @@ static int fuse_write_end(struct file *file, struct address_space *mapping,static int fuse_launder_page (struct page *page) {int err =0 ; + +if (fuse_is_bad (page->mapping->host)) +return -EIO ; +if (clear_page_dirty_for_io (page)) {struct inode *inode = page->mapping->host; err =fuse_writepage_locked (page);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 918/1848 block: amiflop: synchronize flush timer before track flush
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 9690943353cec1690a715e000ba6a74e5139f530 ]
The amiflop track buffer is shared with the timer callback. timer_delete() does not wait for an in-flight callback, and that callback can rearm itself when it cannot acquire the floppy controller. A synchronous track flush can therefore race with the callback.
Stop the timer before synchronous track writes and use timer_delete_sync() to wait for any callback already running. Keep callback rearming disabled until the write is complete. Apply this to the FDFMTTRK path as well.
FDFLUSH, FDFMTTRK and close-time flushes run outside the blk-mq request callback. Freeze their queues so an in-flight request cannot change the shared track buffer while it is encoded and written. Restart the timer if a track remains dirty after a failed flush.
--- drivers/block/amiflop.c | 69 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 8 deletions(-)
drivers/block/amiflop.c +61 -8
@@ -264,6 +264,8 @@ static struct fd_data_type data_types[] = {static struct amiga_floppy_struct unit[FD_MAX_UNITS ];static struct timer_list flush_track_timer[FD_MAX_UNITS ]; +static DEFINE_SPINLOCK (flush_track_timer_lock); +static bool flush_track_timer_stopped[FD_MAX_UNITS ];static struct timer_list post_write_timer;static unsigned long post_write_timer_drive;static struct timer_list motor_on_timer;
@@ -1369,11 +1371,22 @@ static void flush_track_callback(struct timer_list *timer)sizeof (flush_track_timer[0 ]); nr&=3 ; +spin_lock (&flush_track_timer_lock); +if (flush_track_timer_stopped[nr]) { +spin_unlock (&flush_track_timer_lock); +return ; + } +spin_unlock (&flush_track_timer_lock); + writefromint =1 ;if (!try_fdc (nr)) {/* we might block in an interrupt, so try again later */ - flush_track_timer[nr].expires = jiffies +1 ; -add_timer (flush_track_timer + nr); +spin_lock (&flush_track_timer_lock); +if (!flush_track_timer_stopped[nr]) { + flush_track_timer[nr].expires = jiffies +1 ; +add_timer (flush_track_timer + nr); + } +spin_unlock (&flush_track_timer_lock);return ; }get_fdc (nr);
@@ -1420,6 +1433,35 @@ static int non_int_flush_track (unsigned long nr)return 1 ; } +static void flush_track_timer_stop (unsigned int drive) +{ +unsigned long flags; + +spin_lock_irqsave (&flush_track_timer_lock, flags); + flush_track_timer_stopped[drive] = true; +spin_unlock_irqrestore (&flush_track_timer_lock, flags); + +timer_delete_sync (flush_track_timer + drive); +} + +static void flush_track_timer_start (unsigned int drive) +{ +unsigned long flags; + +spin_lock_irqsave (&flush_track_timer_lock, flags); + flush_track_timer_stopped[drive] = false; +if (unit[drive].dirty) +mod_timer (flush_track_timer + drive, jiffies +1 ); +spin_unlock_irqrestore (&flush_track_timer_lock, flags); +} + +static void flush_track_timer_sync (unsigned int drive) +{ +flush_track_timer_stop (drive); +non_int_flush_track (drive); +flush_track_timer_start (drive); +} +static int get_track (int drive,int track) {int error, errcnt;
@@ -1434,8 +1476,7 @@ static int get_track(int drive, int track) }if (unit[drive].dirty ==1 ) { -del_timer (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive); } errcnt =0 ;while (errcnt <MAX_ERRORS ) {
@@ -1562,6 +1603,12 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,case FDFMTTRK :if (param < p->type->tracks * p->type->heads) { +flush_track_timer_stop (drive); +if (unit[drive].dirty ==1 && + !non_int_flush_track (drive)) { +flush_track_timer_start (drive); +return -EIO ; + }get_fdc (drive);if (fd_seek (drive,param) !=0 ){ memset(p->trackbuf, FD_FILL_BYTE,
@@ -1570,6 +1617,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, }floppy_off (drive);rel_fdc (); +flush_track_timer_start (drive); }else return -EINVAL ;
@@ -1591,8 +1639,7 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode,case FDDEFPRM :return -EINVAL ;case FDFLUSH :/* unconditionally, even if not needed */ -del_timer (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive);break ;#ifdef RAW_IOCTL case IOCTL_RAW_TRACK :
@@ -1611,9 +1658,14 @@ static int fd_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd, unsigned long param) { int ret; +bool freeze_queue = cmd ==FDFMTTRK || cmd ==FDFLUSH ;mutex_lock (&amiflop_mutex); +if (freeze_queue) +blk_mq_freeze_queue (bdev->bd_disk->queue); ret =fd_locked_ioctl (bdev, mode, cmd, param); +if (freeze_queue) +blk_mq_unfreeze_queue (bdev->bd_disk->queue);mutex_unlock (&amiflop_mutex);return ret;
@@ -1710,9 +1762,9 @@ static void floppy_release(struct gendisk *disk, fmode_t mode)int drive = p - unit;mutex_lock (&amiflop_mutex); +blk_mq_freeze_queue (disk->queue);if (unit[drive].dirty ==1 ) { -del_timer (flush_track_timer + drive); -non_int_flush_track (drive); +flush_track_timer_sync (drive); }if (!fd_ref[drive]--) {
@@ -1722,6 +1774,7 @@ static void floppy_release(struct gendisk *disk, fmode_t mode)#ifdef MODULE floppy_off (drive);#endif +blk_mq_unfreeze_queue (disk->queue);mutex_unlock (&amiflop_mutex); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 919/1848 leds: ktd2692: Pass context to regulator cleanup
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit c73e9f04445f361d5f19ca2edfde742ce18348ef ]
regulator_disable_action() retrieves the driver context from device driver data. However, ktd2692_parse_dt() registers the action before ktd2692_probe() stores the context with platform_set_drvdata().
If devm_add_action_or_reset() cannot allocate the action, it invokes the callback immediately. A later probe failure also invokes it during managed-resource unwinding. Both paths dereference a NULL context.
Pass the already allocated context directly to the action and retain the device pointer in it for error reporting. The context is allocated before the action is registered, so reverse-order devres unwinding keeps it alive through the callback.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/leds/leds-ktd2692.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/leds/leds-ktd2692.c +6 -4
@@ -72,6 +72,8 @@ struct ktd2692_led_config_data { };struct ktd2692_context { +struct device *dev; +/* Related LED Flash class device */ struct led_classdev_flash fled_cdev;
@@ -258,13 +260,12 @@ static void ktd2692_setup(struct ktd2692_context *led)static void regulator_disable_action (void *_data) { -struct device *dev = _data; -struct ktd2692_context *led =dev_get_drvdata (dev); +struct ktd2692_context *led = _data;int ret; ret =regulator_disable (led->regulator);if (ret) -dev_err (dev,"Failed to disable supply: %d\n" , ret); +dev_err (led->dev,"Failed to disable supply: %d\n" , ret); } static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,
@@ -301,7 +302,7 @@ static int ktd2692_parse_dt(struct ktd2692_context *led, struct device *dev,dev_err (dev,"Failed to enable supply: %d\n" , ret); }else { ret =devm_add_action_or_reset (dev, - regulator_disable_action, dev); + regulator_disable_action, led);if (ret)return ret; }
@@ -359,6 +360,7 @@ static int ktd2692_probe(struct platform_device *pdev)if (!led)return -ENOMEM ; + led->dev = &pdev->dev; fled_cdev = &led->fled_cdev; led_cdev = &fled_cdev->led_cdev;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 920/1848 ALSA: emux: Fix UAF of soundfont zones at note-on
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 34e3e04b8a1731a773797542f0781e99ce7cd755 ]
snd_emux_note_on() looks up the matching zones via snd_soundfont_search_zone(), which takes sflist->lock only during the lookup and returns the raw zone pointers after releasing it. The caller then stores them in vp->zone without any protection. Meanwhile, a concurrent SNDRV_EMUX_IOCTL_REMOVE_LAST_SAMPLES ioctl may unlink and free those zones in snd_soundfont_remove_unlocked(); this leads to a use-after-free in snd_emux_note_on(), and later at accessing the cached vp->zone, e.g. in snd_emux_send_effect().
Fix it by holding sflist->lock in snd_emux_note_on() over the whole zone lookup and voice setup, and let snd_soundfont_search_zone() require the caller to hold the lock, instead. snd_soundfont_lock_preset() takes sflist->lock for setting presets_locked, so the removal path now syncs with the note-on finish.
--- sound/synth/emux/emux_synth.c | 9 +++++++-- sound/synth/emux/soundfont.c | 15 +++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-)
sound/synth/emux/emux_synth.c +7 -2
@@ -49,7 +49,7 @@ snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)int i, key, nvoices;struct snd_emux_voice *vp;struct snd_sf_zone *table[SNDRV_EMUX_MAX_MULTI_VOICES ]; -unsigned long flags; +unsigned long flags, sf_flags;struct snd_emux_port *port; port = p;
@@ -61,9 +61,12 @@ snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan)return ; key = note;/* remember the original note */ + +/* hold sflist->lock for protecting against concurrent free */ +spin_lock_irqsave (&emu->sflist->lock, sf_flags); nvoices =get_zone (emu, port, ¬e, vel, chan, table);if (! nvoices) -return ; + goto unlock;/* exclusive note off */ for (i =0 ; i < nvoices; i++) {
@@ -136,6 +139,8 @@ snd_emux_note_on(void *p, int note, int vel, struct snd_midi_channel *chan) } }#endif +unlock: +spin_unlock_irqrestore (&emu->sflist->lock, sf_flags); }/*
sound/synth/emux/soundfont.c +7 -8
@@ -1221,6 +1221,9 @@ delete_preset(struct snd_sf_list *sflist, struct snd_sf_zone *zp)* The found zones are stored on 'table' array. max_layers defines * the maximum number of elements in this array. * This function returns the number of found zones. 0 if not found. +* +* The caller must hold sflist->lock, and keep holding it as long as +* the returned zones are accessed. */ int snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel,
@@ -1229,17 +1232,14 @@ snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, struct snd_sf_zone **table, int max_layers) { int nvoices; -unsigned long flags; -/* this function is supposed to be called atomically, -* so we check the lock. if it's busy, just returns 0 to +lockdep_assert_held (&sflist->lock); + +/* if the presets are being modified, just returns 0 to * tell the caller the busy state */ -spin_lock_irqsave (&sflist->lock, flags); -if (sflist->presets_locked) { -spin_unlock_irqrestore (&sflist->lock, flags); +if (sflist->presets_locked)return 0 ; - } nvoices =search_zones (sflist, notep, vel, preset, bank, table, max_layers,0 );if (! nvoices) {
@@ -1248,7 +1248,6 @@ snd_soundfont_search_zone(struct snd_sf_list *sflist, int *notep, int vel, def_preset, def_bank, table, max_layers, 0); } -spin_unlock_irqrestore (&sflist->lock, flags);return nvoices; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 921/1848 ALSA: hda/hdmi: clamp num_cvts against cvt_nids[] in hdmi_read_pin_conn
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
[ Upstream commit 6cf3ab38b0d53d41f00fe594b2986849bdf994ae ]
hdmi_add_cvt() stores each converter's NID into the fixed-size spec->cvt_nids[] array (used only by the Intel Haswell pin-connection fixup), but only when spec->num_cvts is still within ARRAY_SIZE(cvt_nids); the num_cvts counter itself is incremented unconditionally regardless of whether the store happened. A codec that reports more converters than cvt_nids[] can hold therefore ends up with num_cvts > ARRAY_SIZE(cvt_nids).
hdmi_read_pin_conn(), on the intel_hsw_fixup path, copies num_cvts elements from cvt_nids[] with memcpy(), so once num_cvts exceeds the array size this reads past cvt_nids[] and writes the resulting garbage NIDs into per_pin->mux_nids[].
Clamp the copy length to the actual size of cvt_nids[] instead of trusting num_cvts, which is also used unbounded as the size of the separate, dynamically-sized spec->cvts array and must not be truncated at the source.
--- sound/pci/hda/patch_hdmi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
sound/pci/hda/patch_hdmi.c +2 -1
@@ -1341,7 +1341,8 @@ static int hdmi_read_pin_conn(struct hda_codec *codec, int pin_idx)snd_hda_set_dev_select (codec, pin_nid, dev_id);if (spec->intel_hsw_fixup) { - conns = spec->num_cvts; +/* spec->cvt_nids[] only has ARRAY_SIZE(spec->cvt_nids) slots */ + conns =min_t (int, spec->num_cvts,ARRAY_SIZE (spec->cvt_nids));memcpy (per_pin->mux_nids, spec->cvt_nids,sizeof (hda_nid_t) * conns); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 922/1848 drm/amd/display: Fix swap in median3() for DSC rate control
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keita Morisaki <[email protected]>
[ Upstream commit 7b23bf82ccbdb4cf0752f2b8686e7319a7ce497f ]
median3() is meant to return the median of three values, but its last compare-and-swap step swaps b and c instead of a and b. When c is smaller than both a and b, it returns max(a, b) instead of min(a, b). For example, median3(2, 3, 1) returns 3 instead of 2.
_do_calc_rc_params() always passes 0 as the first argument, and the second argument is never below 12. So whenever the third argument is negative, first_line_bpg_offset (and second_line_bpg_offset for 4:2:0) is set to the second argument instead of 0.
Fix this by swapping a and b in the last step, as intended.
Note that this change does not affect valid DSC configurations. The third argument is negative only when bits per pixel exceeds the uncompressed rate of the colour format:
- 3 * bpc for 4:4:4, 3 * bpc + 2 for RGB
- 2 * bpc for 4:2:2
- 1.5 * bpc for 4:2:0
--- drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c +1 -1
@@ -169,7 +169,7 @@ static int median3(int a, int b, int c)if (b > c)swap (b, c);if (a > b) -swap (b, c); +swap (a, b);return b; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 923/1848 fbcon: Retry rotated font allocation after failure
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Yiqi <[email protected]>
[ Upstream commit 7935db1a4a0f83a63590a222500e5016e2f6c85e ]
fbcon_rotate_font() records the font, its geometry and the rotation in par->rotated before calling font_data_rotate(). If the allocation fails, the error path clears par->rotated.buf, but the recorded key already looks up to date, so the next call takes the early-out and never retries. The rotated putcs/cursor ops keep returning early on the NULL buffer, and the console stays blank even after memory is available again.
Also test par->rotated.buf in the early-out, so a failed allocation is retried on the next call: at the next fbcon_switch(), fbcon_modechanged() or font change.
--- drivers/video/fbdev/core/fbcon_rotate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/video/fbdev/core/fbcon_rotate.c +2 -1
@@ -27,7 +27,8 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)u8 *dst;if (vc->vc_font.data == ops->fontdata && - ops->p->con_rotate == ops->cur_rotate) + ops->p->con_rotate == ops->cur_rotate && + ops->fontbuffer) goto finished; src = ops->fontdata = vc->vc_font.data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 924/1848 xen/gntdev: Fix gntdev_dmabuf ref leak in dmabuf_exp_wait_released()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Liang <[email protected]>
[ Upstream commit 6f165abe2b40ede71c98956cd74cd17c18505e75 ]
dmabuf_exp_wait_released() takes a reference on the exported gntdev_dmabuf with dmabuf_exp_wait_obj_get_dmabuf() and passes it to dmabuf_exp_wait_obj_new(), which drops that reference after adding the wait object to the wait list. When the wait object allocation fails, dmabuf_exp_wait_obj_new() returns ERR_PTR(-ENOMEM) early and the reference is never dropped, leaking a reference to the exported gntdev_dmabuf.
Drop the reference on the allocation failure path so the reference is consumed whether the wait object is created or not.
Message-ID: <[email protected]>
--- drivers/xen/gntdev-dmabuf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/xen/gntdev-dmabuf.c +3 -1
@@ -102,8 +102,10 @@ dmabuf_exp_wait_obj_new(struct gntdev_dmabuf_priv *priv,struct gntdev_dmabuf_wait_obj *obj; obj =kzalloc (sizeof (*obj),GFP_KERNEL ); -if (!obj) +if (!obj) { +kref_put (&gntdev_dmabuf->u.exp.refcount, dmabuf_exp_release);return ERR_PTR (-ENOMEM ); + }init_completion (&obj->completion); obj->gntdev_dmabuf = gntdev_dmabuf;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 925/1848 mm/mlock: use a long for the page count in mlock_fixup()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nickolai Zeldovich <[email protected]>
[ Upstream commit 3ae91e3079b1504ef162b2884454d5f1421f4eb9 ]
mlock_fixup() adjusts mm->locked_vm, an unsigned long, by the number of pages whose VM_LOCKED state it changes, but computes that number in an int:
int nr_pages; ... nr_pages = (end - start) >> PAGE_SHIFT; ... mm->locked_vm += nr_pages;
When a single VMA range of 2^31 pages (8 TiB with 4 KiB pages) or more is locked or unlocked, the count is truncated to 32 bits and then sign-extended, so locked_vm is changed by the wrong amount, while munmap(), mremap() and the other paths that maintain locked_vm use the full unsigned long page count.
Such a range is reachable on 64-bit architectures with a 47-bit or larger user address space (x86_64, arm64 with 48-bit VA, riscv64 Sv48) by a task with CAP_IPC_LOCK or a raised RLIMIT_MEMLOCK, which do_mlock() checks against the full untruncated length. It costs nothing with MAP_NORESERVE and MLOCK_ONFAULT/MCL_ONFAULT, since then no page is populated. On x86_64, after
p = mmap(NULL, 8UL << 40, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); mlock2(p, 8UL << 40, MLOCK_ONFAULT);
VmLck in /proc/self/status reads 18446744065119617024 kB instead of 8589934592 kB; munmap() of the region then subtracts the true size and leaves VmLck at 18446744056529682432 kB instead of 0. With 16 TiB, locked_vm is not changed at all, VmLck stays 0 kB, and after the task drops CAP_IPC_LOCK or lowers RLIMIT_MEMLOCK, mlock(), mmap(MAP_LOCKED) and the other mlock_future_ok() and account_locked_vm() users enforce RLIMIT_MEMLOCK against that count, so they let the task lock memory beyond its limit (or, in the 8 TiB case, refuse every further lock). The error persists for the life of the mm; unlocking the range in pieces skews it further. The wrong count is per-mm accounting only: it does not change which pages are locked.
The int has been there since before git history (the variable was named "pages" until it was renamed in 2.6.28); every other updater of locked_vm uses an unsigned long or long count. Make nr_pages a long, which holds the page count of any user range and its negation, so the existing sign handling is unchanged.
Found by formal verification of mm/mlock.c against the kernel binary.
--- mm/mlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mlock.c +1 -1
@@ -526,7 +526,7 @@ static int mlock_fixup(struct vm_area_struct *vma, struct vm_area_struct **prev, {struct mm_struct *mm = vma->vm_mm;pgoff_t pgoff; -int nr_pages; +long nr_pages;int ret =0 ;int lock = !!(newflags &VM_LOCKED );vm_flags_t old_flags = vma->vm_flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 926/1848 drm/amd/display: take a runtime PM reference only when a CRTC turns on
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luigi Lauro <[email protected]>
[ Upstream commit b456f591f925fbd6b33770d0eec1b51c2f9d41c1 ]
amdgpu_dm_commit_streams() takes a runtime PM reference for every active CRTC that needs a modeset and has a new stream, but amdgpu_dm_atomic_commit_tail() drops one only for each CRTC that goes from active to inactive. A modeset of a CRTC that is already active (a mode change, or anything else that needs a full modeset) therefore leaks one reference. Once that has happened, the usage count no longer returns to zero with every CRTC off, and the device cannot runtime suspend again until reboot. The two also disagree the other way when a CRTC turns on without a stream ("Failed to create new stream"): no reference is taken, but one is dropped when it turns off.
Take the reference in the loop that counts the disabled CRTCs, on the mirror condition: when the CRTC goes from inactive to active, which is what the commit that added it intended ("every time we enable a previously disabled CRTC"). Each active CRTC then holds exactly one reference.
Tested on an RX 9070 XT (Navi 48) over OCuLink, with the change backported to 7.2.9: an unplugged connector forced on, then mode A on a CRTC, mode B on the same active CRTC, and the CRTC off, three rounds in a row. The usage count rose by 3 with the stock module, by 0 with this patch, and by 3 again after reloading the stock module.
--- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -4
@@ -7825,8 +7825,6 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)if (dm_old_crtc_state->stream)remove_stream (adev, acrtc, dm_old_crtc_state->stream); -pm_runtime_get_noresume (dev->dev); - acrtc->enabled = true; acrtc->hw_mode = new_crtc_state->mode; crtc->hwmode = new_crtc_state->mode;
@@ -7979,10 +7977,15 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)mutex_unlock (&dm->dc_lock); } -/* Count number of newly disabled CRTCs for dropping PM refs later. */ for_each_oldnew_crtc_in_state (state, crtc, old_crtc_state, new_crtc_state, i) { -if (old_crtc_state->active && !new_crtc_state->active) +/* +* One runtime PM reference per active CRTC: take it when the +* CRTC turns on, count it when it turns off for dropping later. +*/ +if (!old_crtc_state->active && new_crtc_state->active) +pm_runtime_get_noresume (dev->dev); +else if (old_crtc_state->active && !new_crtc_state->active) crtc_disable_count++; dm_new_crtc_state =to_dm_crtc_state (new_crtc_state);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 927/1848 drm/amdgpu: reject CS chunks too large for kvmalloc()
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jesse Zhang <[email protected]>
[ Upstream commit ba4c3c202919405f461a393e823e4b72c8518494 ]
The CS ioctl copies every chunk with vmemdup_array_user() before it looks at it, for whatever length_dw userspace gives. kvmalloc() warns about allocations above INT_MAX when called without __GFP_NOWARN, so any process with the render node can trigger a warning. On navi31, a CS with a chunk of length_dw 0x20000000 returns -ENOMEM after:
WARNING: mm/slub.c:6841 at __kvmalloc_node_noprof+0x5a5/0x7d0
Reject such chunks with -EINVAL before trying to copy them.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -0
@@ -161,6 +161,12 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs size = p->chunks[i].length_dw; cdata =u64_to_user_ptr (user_chunk.chunk_data); +if (size >INT_MAX /sizeof (uint32_t )) { + ret = -EINVAL ; + i--; + goto free_partial_kdata; + } + p->chunks[i].kdata =kvmalloc_array (size,sizeof (uint32_t ),GFP_KERNEL );if (p->chunks[i].kdata ==NULL ) { ret = -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 928/1848 ALSA: emu10k1: prune vestiges of SNDRV_SFNT_SAMPLE_{BIDIR,REVERSE}_LOOP support
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oswald Buddenhagen <[email protected]>
[ Upstream commit 1edeac6555e9df008b1729ca445868c1177baa8b ]
This is required only to implement WAVE_BIDIR_LOOP and WAVE_LOOP_BACK in the GUS patch loader. It has not worked on emu10k1 since before ALSA hit mainline, yet nobody appears to have complained. And as it isn't super easy to implement, just admit defeat and clean up the code.
If somebody wanted to resurrect the feature, the emu8k driver could serve as a template, but the code would be quite different. But arguably, this should be done in user space in the first place, as this doesn't represent a hardware feature (somewhat ironically, the actual GUS driver has no synth support, and therefore no GUS patch loader).
Note that instead of properly rejecting affected samples, we continue to just pretend that the feature wasn't requested. This is extremely questionable behavior, but avoids that possibly unused instruments suddenly prevent loading the entire file, which would break backwards compatibility. But at least we log a warning now.
Message-ID: <[email protected]>
Stable-dep-of: 8a5d87c2ba30 ("ALSA: emux: Stop voices before freeing zones in all cases")
--- sound/pci/emu10k1/emu10k1_patch.c | 73 ++++--------------------------- 1 file changed, 8 insertions(+), 65 deletions(-)
sound/pci/emu10k1/emu10k1_patch.c +8 -65
@@ -28,8 +28,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp, {int offset;int truesize, size, blocksize; -__maybe_unused int loopsize; -int loopend, sampleend;unsigned int start_addr;struct snd_emu10k1 *emu;
@@ -43,32 +41,24 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,return 0 ; } +if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP |SNDRV_SFNT_SAMPLE_REVERSE_LOOP )) { +/* should instead return -ENOTSUPP; but compatibility */ +printk (KERN_WARNING "Emu10k1 wavetable patch %d with unsupported loop feature\n" , + sp->v.sample); + } +/* recalculate address offset */ sp->v.end -= sp->v.start; sp->v.loopstart -= sp->v.start; sp->v.loopend -= sp->v.start; sp->v.start =0 ; -/* some samples have invalid data. the addresses are corrected in voice info */ - sampleend = sp->v.end; -if (sampleend > sp->v.size) - sampleend = sp->v.size; - loopend = sp->v.loopend; -if (loopend > sampleend) - loopend = sampleend; -/* be sure loop points start < end */ if (sp->v.loopstart >= sp->v.loopend)swap (sp->v.loopstart, sp->v.loopend);/* compute true data size to be loaded */ truesize = sp->v.size +BLANK_HEAD_SIZE ; - loopsize =0 ; -#if 0 /* not supported */ -if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP |SNDRV_SFNT_SAMPLE_REVERSE_LOOP )) - loopsize = sp->v.loopend - sp->v.loopstart; - truesize += loopsize; -#endif if (sp->v.mode_flags &SNDRV_SFNT_SAMPLE_NO_BLANK ) truesize +=BLANK_LOOP_SIZE ;
@@ -96,8 +86,8 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,snd_emu10k1_synth_bzero (emu, sp->block, offset, size); offset += size; -/* copy start->loopend */ - size = loopend; +/* copy provided samples */ + size = sp->v.size;if (! (sp->v.mode_flags &SNDRV_SFNT_SAMPLE_8BITS )) size *=2 ;if (offset + size > blocksize)
@@ -108,53 +98,6 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,return -EFAULT ; } offset += size; - data += size; - -#if 0 /* not supported yet */ -/* handle reverse (or bidirectional) loop */ -if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP |SNDRV_SFNT_SAMPLE_REVERSE_LOOP )) { -/* copy loop in reverse */ -if (! (sp->v.mode_flags &SNDRV_SFNT_SAMPLE_8BITS )) { -int woffset; -unsigned short *wblock = (unsigned short *)block; - woffset = offset /2 ; -if (offset + loopsize *2 > blocksize) -return -EINVAL ; -for (i =0 ; i < loopsize; i++) - wblock[woffset + i] = wblock[woffset - i -1 ]; - offset += loopsize *2 ; - }else { -if (offset + loopsize > blocksize) -return -EINVAL ; -for (i =0 ; i < loopsize; i++) - block[offset + i] = block[offset - i -1 ]; - offset += loopsize; - } - -/* modify loop pointers */ -if (sp->v.mode_flags &SNDRV_SFNT_SAMPLE_BIDIR_LOOP ) { - sp->v.loopend += loopsize; - }else { - sp->v.loopstart += loopsize; - sp->v.loopend += loopsize; - } -/* add sample pointer */ - sp->v.end += loopsize; - } -#endif - -/* loopend -> sample end */ - size = sp->v.size - loopend; -if (size <0 ) -return -EINVAL ; -if (! (sp->v.mode_flags &SNDRV_SFNT_SAMPLE_8BITS )) - size *=2 ; -if (snd_emu10k1_synth_copy_from_user (emu, sp->block, offset, data, size)) { -snd_emu10k1_synth_free (emu, sp->block); - sp->block =NULL ; -return -EFAULT ; - } - offset += size;/* clear rest of samples (if any) */ if (offset < blocksize)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 929/1848 ALSA: emux: centralize & improve patch info validation
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oswald Buddenhagen <[email protected]>
[ Upstream commit de67aab120d4d5ba7d9e94ee5b25464ae0d1bd0e ]
This does several closely related things:
- Move the code from the drivers into the SoundFont loader, which de-duplicates it.
- Sort of explain the weird "recalculate address offset" feature. Note that I don't think it actually makes any sense - the calling user space code should do that. The background is certainly that the source data (the SoundFont format) uses pointers into a single wave block (and the API allows doing the same for on-board ROM), but the API expects the wave data from user space to be pre-chopped into individual patches anyway.
- Make sure that the specified offsets actually lie within the supplied wave data. Note that we don't validate ROM offsets, so one can play back anything within the sound card's address space.
- In load_guspatch(), don't call the sample_new callback anymore when the patch size is zero, as was already the case in load_data(). The callbacks would instantly return in that case anyway; these checks are now removed.
Message-ID: <[email protected]>
Stable-dep-of: 8a5d87c2ba30 ("ALSA: emux: Stop voices before freeing zones in all cases")
--- sound/isa/sb/emu8000_patch.c | 13 ----------- sound/pci/emu10k1/emu10k1_patch.c | 16 ------------- sound/synth/emux/soundfont.c | 37 ++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 30 deletions(-)
sound/isa/sb/emu8000_patch.c +0 -13
@@ -148,13 +148,6 @@ snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,if (snd_BUG_ON (!sp))return -EINVAL ; -if (sp->v.size ==0 ) -return 0 ; - -/* be sure loop points start < end */ -if (sp->v.loopstart > sp->v.loopend) -swap (sp->v.loopstart, sp->v.loopend); -/* compute true data size to be loaded */ truesize = sp->v.size;if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP |SNDRV_SFNT_SAMPLE_REVERSE_LOOP ))
@@ -177,12 +170,6 @@ snd_emu8000_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,return -EFAULT ; } -/* recalculate address offset */ - sp->v.end -= sp->v.start; - sp->v.loopstart -= sp->v.start; - sp->v.loopend -= sp->v.start; - sp->v.start =0 ; -/* dram position (in word) -- mem_offset is byte */ dram_offset =EMU8000_DRAM_OFFSET + (sp->block->offset >>1 ); dram_start = dram_offset;
sound/pci/emu10k1/emu10k1_patch.c +0 -16
@@ -35,28 +35,12 @@ snd_emu10k1_sample_new(struct snd_emux *rec, struct snd_sf_sample *sp,if (snd_BUG_ON (!sp || !hdr))return -EINVAL ; -if (sp->v.size ==0 ) { -dev_dbg (emu->card->dev, -"emu: rom font for sample %d\n" , sp->v.sample); -return 0 ; - } -if (sp->v.mode_flags & (SNDRV_SFNT_SAMPLE_BIDIR_LOOP |SNDRV_SFNT_SAMPLE_REVERSE_LOOP )) {/* should instead return -ENOTSUPP; but compatibility */ printk (KERN_WARNING "Emu10k1 wavetable patch %d with unsupported loop feature\n" , sp->v.sample); } -/* recalculate address offset */ - sp->v.end -= sp->v.start; - sp->v.loopstart -= sp->v.start; - sp->v.loopend -= sp->v.start; - sp->v.start =0 ; - -/* be sure loop points start < end */ -if (sp->v.loopstart >= sp->v.loopend) -swap (sp->v.loopstart, sp->v.loopend); -/* compute true data size to be loaded */ truesize = sp->v.size +BLANK_HEAD_SIZE ;if (sp->v.mode_flags &SNDRV_SFNT_SAMPLE_NO_BLANK )
sound/synth/emux/soundfont.c +36 -1
@@ -685,6 +685,21 @@ find_sample(struct snd_soundfont *sf, int sample_id) } +static int +validate_sample_info (struct soundfont_sample_info *si) +{ +if (si->end <0 || si->end > si->size) +return -EINVAL ; +if (si->loopstart <0 || si->loopstart > si->end) +return -EINVAL ; +if (si->loopend <0 || si->loopend > si->end) +return -EINVAL ; +/* be sure loop points start < end */ +if (si->loopstart > si->loopend) +swap (si->loopstart, si->loopend); +return 0 ; +} +/* * Load sample information, this can include data to be loaded onto * the soundcard. It can also just be a pointer into soundcard ROM.
@@ -725,6 +740,21 @@ load_data(struct snd_sf_list *sflist, const void __user *data, long count)return -EINVAL ; } +if (sample_info.size >0 ) { +if (sample_info.start <0 ) +return -EINVAL ; + +// Here we "rebase out" the start address, because the +// real start is the start of the provided sample data. + sample_info.end -= sample_info.start; + sample_info.loopstart -= sample_info.start; + sample_info.loopend -= sample_info.start; + sample_info.start =0 ; + +if (validate_sample_info (&sample_info) <0 ) +return -EINVAL ; + } +/* Allocate a new sample structure */ if ((sp =sf_sample_new (sflist, sf)) ==NULL )return -ENOMEM ;
@@ -973,6 +1003,11 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data, smp->v.loopend = patch.loop_end; smp->v.size = patch.len; +if (validate_sample_info (&smp->v) <0 ) { +sf_sample_delete (sflist, sf, smp); +return -EINVAL ; + } +/* set up mode flags */ smp->v.mode_flags =0 ;if (!(patch.mode &WAVE_16_BITS ))
@@ -1009,7 +1044,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,/* * load wave data */ -if (sflist->callback.sample_new) { +if (smp->v.size >0 && sflist->callback.sample_new) { rc = sflist->callback.sample_new (sflist->callback.private_data, smp, sflist->memhdr, data, count);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 930/1848 ALSA: emux: simplify snd_sf_list.callback handling
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Oswald Buddenhagen <[email protected]>
[ Upstream commit 4c4cbe66828f185903d2127aed6ac9b7302e9d3a ]
Both drivers provide both sample_new and sample_free, and it makes no sense to pretend that they could not. In fact, load_data() would already crash if sample_new was null. So remove the remaining null checks.
Contrary to that, the emu10k1 driver actually has a null sample_reset, though I'm not convinced that this inconsistency is justified.
Message-ID: <[email protected]>
Stable-dep-of: 8a5d87c2ba30 ("ALSA: emux: Stop voices before freeing zones in all cases")
--- sound/synth/emux/emux.c | 6 ++---- sound/synth/emux/soundfont.c | 12 +++++------- 2 files changed, 7 insertions(+), 11 deletions(-)
sound/synth/emux/emux.c +2 -4
@@ -94,10 +94,8 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch/* create soundfont list */ memset (&sf_cb,0 ,sizeof (sf_cb)); sf_cb.private_data = emu; -if (emu->ops.sample_new) - sf_cb.sample_new = sf_sample_new; -if (emu->ops.sample_free) - sf_cb.sample_free = sf_sample_free; + sf_cb.sample_new = sf_sample_new; + sf_cb.sample_free = sf_sample_free;if (emu->ops.sample_reset) sf_cb.sample_reset = sf_sample_reset; emu->sflist =snd_sf_new (&sf_cb, emu->memhdr);
sound/synth/emux/soundfont.c +5 -7
@@ -1044,7 +1044,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,/* * load wave data */ -if (smp->v.size >0 && sflist->callback.sample_new) { +if (smp->v.size >0 ) { rc = sflist->callback.sample_new (sflist->callback.private_data, smp, sflist->memhdr, data, count);
@@ -1405,9 +1405,8 @@ snd_sf_clear(struct snd_sf_list *sflist) }for (sp = sf->samples; sp; sp = nextsp) { nextsp = sp->next; -if (sflist->callback.sample_free) - sflist->callback.sample_free (sflist->callback.private_data, - sp, sflist->memhdr); + sflist->callback.sample_free (sflist->callback.private_data, + sp, sflist->memhdr);kfree (sp); }kfree (sf);
@@ -1508,9 +1507,8 @@ snd_soundfont_remove_unlocked(struct snd_sf_list *sflist) nextsp = sp->next; sf->samples = nextsp; sflist->mem_used -= sp->v.truesize; -if (sflist->callback.sample_free) - sflist->callback.sample_free (sflist->callback.private_data, - sp, sflist->memhdr); + sflist->callback.sample_free (sflist->callback.private_data, + sp, sflist->memhdr);kfree (sp); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 931/1848 ALSA: emux: Stop voices before freeing zones in all cases
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 8a5d87c2ba30e8de31cfbe888fd4d95f43c63db9 ]
The emux voice caches the soundfont zone pointer in vp->zone, which is referred to later, e.g. in snd_emux_send_effect(). For avoiding dangling pointers, the soundfont code calls the sample_reset callback to stop all voices before freeing zones. However, in a few cases (e.g. emu10k1's missing sample_reset or the call path via remove_info()), the sample reset isn't called properly, leaving the playing voices.
Fix it by always registering the sample_reset callback, falling back to snd_emux_terminate_all() when the driver has no own ops, and by calling sample_reset in remove_info() before freeing the zones.
--- sound/synth/emux/emux.c | 10 +++++++--- sound/synth/emux/soundfont.c | 9 +++++++++ 2 files changed, 16 insertions(+), 3 deletions(-)
sound/synth/emux/emux.c +7 -3
@@ -71,7 +71,12 @@ static int sf_sample_free(void *private_data, struct snd_sf_sample *sp,static void sf_sample_reset (void *private_data) {struct snd_emux *emu = private_data; - emu->ops.sample_reset (emu); + +/* stop all voices that might refer to zones and samples to be freed */ +if (emu->ops.sample_reset) + emu->ops.sample_reset (emu); +else +snd_emux_terminate_all (emu); }int snd_emux_register (struct snd_emux *emu,struct snd_card *card,int index,char *name)
@@ -96,8 +101,7 @@ int snd_emux_register(struct snd_emux *emu, struct snd_card *card, int index, ch sf_cb.private_data = emu; sf_cb.sample_new = sf_sample_new; sf_cb.sample_free = sf_sample_free; -if (emu->ops.sample_reset) - sf_cb.sample_reset = sf_sample_reset; + sf_cb.sample_reset = sf_sample_reset; emu->sflist =snd_sf_new (&sf_cb, emu->memhdr);if (emu->sflist ==NULL )return -ENOMEM ;
sound/synth/emux/soundfont.c +9 -0
@@ -480,6 +480,15 @@ remove_info(struct snd_sf_list *sflist, struct snd_soundfont *sf,struct snd_sf_zone *prev, *next, *p;int removed =0 ; +/* stop voices before freeing the zones they might refer to */ +for (p = sf->zones; p; p = p->next) { +if (!p->mapped && p->bank == bank && p->instr == instr) { +if (sflist->callback.sample_reset) + sflist->callback.sample_reset (sflist->callback.private_data); +break ; + } + } + prev =NULL ;for (p = sf->zones; p; p = next) { next = p->next;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 932/1848 nvmem: rockchip-otp: Serialize reads
In reply to Greg Kroah-Hartman5.10-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Charkov <[email protected]>
[ Upstream commit 9fc6a1592d844c0397f115ee8cbd935169b9a71e ]
The OTP controller is driven through a single set of registers holding a state machine which has to be stepped through for every word read, yet nothing keeps two readers out of each other's way. Concurrent reads interleave, and the outcome is either a reader bailing out:
rockchip-otp 2a580000.otp: timeout during read setup
or, worse, one of them silently taking delivery of the other's data.
Reading two cells in parallel from userspace on RK3576 reproduces both within 150 iterations - 53 read errors and 9 corrupted results, the latter either losing their first word or, in one case, ending in the two bytes which belong to the other reader's cell - whereas the same reads issued sequentially never fail. Concurrency is not hypothetical here, as six thermal sensors source their trim values from the OTP and reach the driver straight from asynchronous driver probing.
Guard the read path with a mutex. Reads are the only way into the hardware, as the driver registers no write callback, and they always run in process context, so a plain mutex spanning the whole clock-enable, read, clock-disable sequence is enough.
--- drivers/nvmem/rockchip-otp.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
drivers/nvmem/rockchip-otp.c +12 -1
@@ -12,6 +12,7 @@#include <linux/io.h> #include <linux/iopoll.h> #include <linux/module.h> +#include <linux/mutex.h> #include <linux/nvmem-provider.h> #include <linux/reset.h> #include <linux/slab.h>
@@ -60,6 +61,8 @@ struct rockchip_otp {struct clk_bulk_data *clks;int num_clks;struct reset_control *rst; +/* Serializes access to the OTP controller state machine */ +struct mutex mutex; };/* list of required clocks */
@@ -139,10 +142,12 @@ static int rockchip_otp_read(void *context, unsigned int offset,u8 *buf = val;int ret =0 ; +mutex_lock (&otp->mutex); + ret =clk_bulk_prepare_enable (otp->num_clks, otp->clks);if (ret <0 ) {dev_err (otp->dev,"failed to prepare/enable clks\n" ); -return ret; + goto unlock; } ret =rockchip_otp_reset (otp);
@@ -177,6 +182,9 @@ static int rockchip_otp_read(void *context, unsigned int offset, disable_clks:clk_bulk_disable_unprepare (otp->num_clks, otp->clks); +unlock: +mutex_unlock (&otp->mutex); +return ret; }
@@ -226,6 +234,9 @@ static int rockchip_otp_probe(struct platform_device *pdev)return -ENOMEM ; otp->dev = dev; + +mutex_init (&otp->mutex); + otp->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (otp->base))return PTR_ERR (otp->base);
Signature · 1 line
2.53.0