7.3.6-rc1 review
Subsystems (4)
Greg Kroah-Hartman
maintainerPATCH 207/2651 wifi: mac80211: dont seed an S1G stas last_rate
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lachlan Hodges <[email protected]>
[ Upstream commit 00f623647c331d31df8629af958f7582a7fc874c ]
When initialising the rate control system, ieee80211_s1g_sta_rate_init() is called for S1G stations during association where it initialises a last rate of type STA_STATS_RATE_TYPE_S1G but does not initialise nss, mcs bw etc. Since the last_rate no longer has a value equivalent to STA_STATS_RATE_INVALID, the invalid rate will be decoded and the NL80211_STA_INFO_RX_BITRATE flag will be set.
As a result, there is a period during association before the first data frame is rx'ed where the seeded value is overwritten by ieee80211_rx_h_sta_process() while this invalid last_rate lives. If the sta is desroyed during this process, nl80211_put_sta_rate() will call into cfg80211_calculate_bitrate() and attempt to calculate the bitrate using the invalid last_rate leading to a WARN:
4,336,675067400,-;------------[ cut here ]------------
4,337,675067524,-;WARNING: net/wireless/util.c:1960 at cfg80211_calculate_bitrate+0x4d8/0x8b0 [cfg80211], CPU#3: kworker/u16:3/874 4,338,675068176,-;invalid rate bw=0, mcs=0, nss=0
[snip loaded modules]
4,341,675068954,-;Hardware name: BCM2711
4,342,675068961,-;Workqueue: events_unbound cfg80211_wiphy_work [cfg80211]
4,343,675069386,-;Call trace:
4,344,675069392,-; unwind_backtrace from show_stack+0x10/0x14
4,345,675069440,-; show_stack from dump_stack_lvl+0xa8/0xb8
4,346,675069475,-; dump_stack_lvl from __warn+0x90/0x224
4,347,675069517,-; __warn from warn_slowpath_fmt+0x130/0x1a8
4,348,675069559,-; warn_slowpath_fmt from cfg80211_calculate_bitrate+0x4d8/0x8b0 [cfg80211] 4,349,675070005,-; cfg80211_calculate_bitrate [cfg80211] from nl80211_put_sta_rate+0x48/0x590 [cfg80211] 4,350,675070819,-; nl80211_put_sta_rate [cfg80211] from nl80211_put_sta_info_common+0x4f4/0xd50 [cfg80211] 4,351,675071616,-; nl80211_put_sta_info_common [cfg80211] from nl80211_send_station.constprop.0+0x114/0x424 [cfg80211] 4,352,675072427,-; nl80211_send_station.constprop.0 [cfg80211] from cfg80211_del_sta_sinfo+0xc4/0x368 [cfg80211] 4,353,675073222,-; cfg80211_del_sta_sinfo [cfg80211] from __sta_info_destroy_part2+0x108/0x2c0 [mac80211] 4,354,675074178,-; __sta_info_destroy_part2 [mac80211] from sta_info_destroy_addr+0x4c/0x88 [mac80211] 4,355,675075243,-; sta_info_destroy_addr [mac80211] from ieee80211_destroy_assoc_data+0x194/0x2d8 [mac80211] 4,356,675075920,-; ieee80211_destroy_assoc_data [mac80211] from ieee80211_rx_mgmt_assoc_resp+0x220/0x1d4c [mac80211] 4,357,675076558,-; ieee80211_rx_mgmt_assoc_resp [mac80211] from ieee80211_iface_work+0x1c0/0x5d0 [mac80211] 4,358,675077187,-; ieee80211_iface_work [mac80211] from cfg80211_wiphy_work+0x110/0x368 [cfg80211] 4,359,675077763,-; cfg80211_wiphy_work [cfg80211] from process_one_work+0x260/0x868
4,360,675078022,-; process_one_work from worker_thread+0x1bc/0x3ec
4,361,675078042,-; worker_thread from kthread+0x120/0x154
4,362,675078060,-; kthread from ret_from_fork+0x14/0x20
4,363,675078074,-;Exception stack(0xf0ac1fb0 to 0xf0ac1ff8)
4,364,675078081,-;1fa0: 00000000 00000000 00000000 00000000
4,365,675078088,-;1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 4,366,675078093,-;1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
4,367,675080226,-;irq event stamp: 15780967
4,368,675080287,-;hardirqs last enabled at (15780975): [<c050c154>] __up_console_sem+0x50/0x60 4,369,675080395,-;hardirqs last disabled at (15780982): [<c050c140>] __up_console_sem+0x3c/0x60 4,370,675080497,-;softirqs last enabled at (15780966): [<c0476f14>] handle_softirqs+0x398/0x650 4,371,675080608,-;softirqs last disabled at (15780939): [<c0477388>] __irq_exit_rcu+0x150/0x1f0 4,372,675080715,-;---[ end trace 0000000000000000 ]---
To fix, we can simply not seed this psuedo rate. It was originally implemented to avoid errornous paths that S1G shouldn't take, but those have since been fixed / cleaned up. While we are here, we also don't need to initialise the tx side's last rate with IEEE80211_TX_RC_S1G_MCS (which is equivalent to IEEE80211_TX_RC_VHT_MCS). The entire tx reporting side does not support S1G widths and is assumed to be handled by the driver so we can just remove the entire function.
--- net/mac80211/ieee80211_i.h | 1 - net/mac80211/mlme.c | 14 +++++--------- net/mac80211/rate.c | 1 - net/mac80211/s1g.c | 8 -------- 4 files changed, 5 insertions(+), 19 deletions(-)
net/mac80211/ieee80211_i.h +0 -1
@@ -2388,7 +2388,6 @@ ieee80211_he_op_ie_to_bss_conf(struct ieee80211_vif *vif, const struct ieee80211_he_operation *he_op_ie_elem);/* S1G */ -void ieee80211_s1g_sta_rate_init (struct sta_info *sta);bool ieee80211_s1g_is_twt_setup (struct sk_buff *skb);void ieee80211_s1g_rx_twt_action (struct ieee80211_sub_if_data *sdata,struct sk_buff *skb);
net/mac80211/mlme.c +5 -9
@@ -6347,7 +6347,6 @@ static bool ieee80211_assoc_config_link(struct ieee80211_link_data *link, }static int ieee80211_mgd_setup_link_sta (struct ieee80211_link_data *link, -struct sta_info *sta,struct link_sta_info *link_sta,struct cfg80211_bss *cbss) {
@@ -6362,11 +6361,9 @@ static int ieee80211_mgd_setup_link_sta(struct ieee80211_link_data *link,memcpy (link_sta->addr, cbss->bssid,ETH_ALEN );memcpy (link_sta->pub->addr, cbss->bssid,ETH_ALEN ); -/* TODO: S1G Basic Rate Set is expressed elsewhere */ -if (cbss->channel->band ==NL80211_BAND_S1GHZ ) { -ieee80211_s1g_sta_rate_init (sta); +/* S1G does not use basic rates */ +if (cbss->channel->band ==NL80211_BAND_S1GHZ )return 0 ; - } sband = local->hw.wiphy->bands[cbss->channel->band];
@@ -7107,7 +7104,7 @@ static bool ieee80211_assoc_success(struct ieee80211_sub_if_data *sdata, } } - err =ieee80211_mgd_setup_link_sta (link, sta, link_sta, + err =ieee80211_mgd_setup_link_sta (link, link_sta, assoc_data->link[link_id].bss);if (err) goto out_err;
@@ -9699,8 +9696,7 @@ static int ieee80211_prep_connection(struct ieee80211_sub_if_data *sdata, goto out_err; } - err =ieee80211_mgd_setup_link_sta (link, new_sta, - link_sta, cbss); + err =ieee80211_mgd_setup_link_sta (link, link_sta, cbss);if (err) {rcu_read_unlock ();sta_info_free (local, new_sta);
@@ -11090,7 +11086,7 @@ ieee80211_process_ml_reconf_resp(struct ieee80211_sub_if_data *sdata, goto disconnect; } -if (ieee80211_mgd_setup_link_sta (link, sta, link_sta, +if (ieee80211_mgd_setup_link_sta (link, link_sta, add_links_data->link[link_id].bss)) goto disconnect;
net/mac80211/rate.c +0 -1
@@ -57,7 +57,6 @@ void rate_control_rate_init(struct link_sta_info *link_sta)/* TODO: check for minstrel_s1g ? */ if (sband->band ==NL80211_BAND_S1GHZ ) { -ieee80211_s1g_sta_rate_init (sta);rcu_read_unlock ();return ; }
net/mac80211/s1g.c +0 -8
@@ -9,14 +9,6 @@#include "ieee80211_i.h" #include "driver-ops.h" -void ieee80211_s1g_sta_rate_init (struct sta_info *sta) -{ -/* avoid indicating legacy bitrates for S1G STAs */ - sta->deflink.tx_stats.last_rate.flags |=IEEE80211_TX_RC_S1G_MCS ; - sta->deflink.rx_stats.last_rate = -STA_STATS_FIELD (TYPE ,STA_STATS_RATE_TYPE_S1G ); -} -bool ieee80211_s1g_is_twt_setup (struct sk_buff *skb) {struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)skb->data;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 208/2651 wifi: mac80211: fix unauthorised port check for encap offload
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit d59b9bf7df49367e01b06e82dd0f6e7ad3be493c ]
The check in ieee80211_tx_dequeue() reads frame_control, addr1 and addr2 out of the skb, but for encapsulation offload that's just a random part of the ethernet addresses, so dropping depends on bits in the destination address. This is obviously wrong.
Refactor the check and short-circuit for ethernet format frames, it only needs the port-control flag check since those are locally generated and not forwarded frames.
--- net/mac80211/tx.c | 48 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-)
net/mac80211/tx.c +34 -14
@@ -3923,6 +3923,38 @@ static bool ieee80211_xmit_fast(struct ieee80211_sub_if_data *sdata,return true; } +static bool ieee80211_drop_unauth_port (struct ieee80211_tx_data *tx) +{ +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb); +struct ieee80211_hdr *hdr; + +if (likely (test_sta_flag (tx->sta,WLAN_STA_AUTHORIZED ))) +return false; + +if (info->flags &IEEE80211_TX_CTL_INJECTED ) +return false; + +if (ieee80211_vif_is_mesh (&tx->sdata->vif) || + tx->sdata->vif.type ==NL80211_IFTYPE_OCB ) +return false; + +/* no need to check forwarding here */ +if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) +return !(info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO ); + + hdr = (struct ieee80211_hdr *)tx->skb->data; + +if (!ieee80211_is_data_present (hdr->frame_control) || +is_multicast_ether_addr (hdr->addr1)) +return false; + +if ((info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO ) && +ieee80211_is_our_addr (tx->sdata, hdr->addr2,NULL )) +return false; + +return true; +} +struct sk_buff *ieee80211_tx_dequeue (struct ieee80211_hw *hw,struct ieee80211_txq *txq) {
@@ -3989,20 +4021,8 @@ struct sk_buff *ieee80211_tx_dequeue(struct ieee80211_hw *hw,if (txq->sta) { tx.sta = container_of(txq->sta, struct sta_info, sta); -/* -* Drop unicast frames to unauthorised stations unless they are -* injected frames or EAPOL frames from the local station. -*/ -if (unlikely (!(info->flags &IEEE80211_TX_CTL_INJECTED ) && -ieee80211_is_data_present (hdr->frame_control) && - !ieee80211_vif_is_mesh (&tx.sdata->vif) && - tx.sdata->vif.type !=NL80211_IFTYPE_OCB && - !is_multicast_ether_addr (hdr->addr1) && - !test_sta_flag (tx.sta,WLAN_STA_AUTHORIZED ) && - (!(info->control.flags & -IEEE80211_TX_CTRL_PORT_CTRL_PROTO ) || - !ieee80211_is_our_addr (tx.sdata, hdr->addr2, -NULL )))) { + +if (unlikely (ieee80211_drop_unauth_port (&tx))) {I802_DEBUG_INC (local->tx_handlers_drop_unauth_port);ieee80211_free_txskb (&local->hw, skb); goto begin;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 209/2651 wifi: mac80211: fix key selection for encap offload frames
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit 0e80db08668b560b3522849cb705623148bcd4b5 ]
ieee80211_tx_h_select_key() assumes the frame is in 802.11 format for picking the key, at least when there's no pairwise TK for the STA to transmit with.
For unicast this is likely not relevant because if there's no pairwise TK for the STA there's probably not going to be any other key either. But multicast encapsulation offload frames have no STA, so it looks at the ethernet header as if it was 802.11. This may not matter very much since multicast encapsulation offload is likely to ignore the key selection, but it's still wrong.
Create a separate selection function that doesn't (need to) look at the frame header - it's data anyway, so either unicast to a station (with sta pointer) or multicast. For MLO, the driver has to duplicate the frame and select the key anyway, so just skip it in that case entirely.
--- net/mac80211/tx.c | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-)
net/mac80211/tx.c +31 -6
@@ -574,6 +574,34 @@ ieee80211_select_link_key(struct ieee80211_tx_data *tx)return NULL ; } +/* +* An 802.3 frame is always a data frame, so there are no 802.11 addresses to +* look at: with a station the pairwise key is all that can apply, without one +* the frame is group addressed. On an MLD the driver has to pick the group key +* itself, as the same frame goes out on several links that each have their own. +*/ +static ieee80211_tx_result +ieee80211_select_key_8023 (struct ieee80211_tx_data *tx) +{ +struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb); + +if (unlikely (info->flags &IEEE80211_TX_INTFL_DONT_ENCRYPT )) +return TX_CONTINUE ; + +if (tx->sta) { + tx->key =rcu_dereference (tx->sta->ptk[tx->sta->ptk_idx]); +if (!tx->key) + tx->key =rcu_dereference (tx->sdata->default_unicast_key); + }else if (!ieee80211_vif_is_mld (&tx->sdata->vif)) { + tx->key =rcu_dereference (tx->sdata->deflink.default_multicast_key); + } + +if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) + info->control.hw_key = &tx->key->conf; + +return TX_CONTINUE ; +} + static ieee80211_tx_result debug_noinlineieee80211_tx_h_select_key (struct ieee80211_tx_data *tx) {
@@ -581,6 +609,9 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb);struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; +if (info->control.flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) +return ieee80211_select_key_8023 (tx); +if (unlikely (info->flags &IEEE80211_TX_INTFL_DONT_ENCRYPT )) { tx->key =NULL ;return TX_CONTINUE ;
@@ -597,12 +628,6 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)else tx->key =NULL ; -if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) { -if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) - info->control.hw_key = &tx->key->conf; -return TX_CONTINUE ; - } -if (tx->key) {bool skip_hw = false;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 210/2651 wifi: mac80211: dont send encap offload frames unencrypted
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit a48daf145fed445d41ef422573411500785415c8 ]
For 802.11 frames, ieee80211_tx_h_select_key() drops a data frame that ended up without a key if the station requires encryption, so that traffic can never leak out unprotected. Encapsulation offload erroneously didn't get this code path. Fix that.
--- net/mac80211/tx.c | 3 +++ 1 file changed, 3 insertions(+)
net/mac80211/tx.c +3 -0
@@ -592,6 +592,9 @@ ieee80211_select_key_8023(struct ieee80211_tx_data *tx) tx->key =rcu_dereference (tx->sta->ptk[tx->sta->ptk_idx]);if (!tx->key) tx->key =rcu_dereference (tx->sdata->default_unicast_key); + +if (!tx->key &&test_sta_flag (tx->sta,WLAN_STA_USES_ENCRYPTION )) +return TX_DROP ; }else if (!ieee80211_vif_is_mld (&tx->sdata->vif)) { tx->key =rcu_dereference (tx->sdata->deflink.default_multicast_key); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 211/2651 wifi: mac80211: drop encap offload frames with a tainted key
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit c8ddbe1e8c43f6d008591c50f8be8de39cdce267 ]
When a key is tainted, which happens in some WoWLAN and extended key ID scenarios, frames that would use it should be dropped. Fix that for encapsulation offload frames.
--- net/mac80211/tx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
net/mac80211/tx.c +7 -1
@@ -599,7 +599,13 @@ ieee80211_select_key_8023(struct ieee80211_tx_data *tx) tx->key =rcu_dereference (tx->sdata->deflink.default_multicast_key); } -if (tx->key && tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) +if (!tx->key) +return TX_CONTINUE ; + +if (unlikely (tx->key->flags &KEY_FLAG_TAINTED )) +return TX_DROP ; + +if (tx->key->flags &KEY_FLAG_UPLOADED_TO_HARDWARE ) info->control.hw_key = &tx->key->conf;return TX_CONTINUE ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 212/2651 wifi: mac80211: fix IEEE80211_TX_CTL_REQ_TX_STATUS mixup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit e035900ffe9e8978f7c0d7b61811b6b578751697 ]
In ieee80211_build_hdr(), IEEE80211_TX_CTL_REQ_TX_STATUS is checked in ctrl_flags, which is wrong - IEEE80211_TX_CTL_REQ_TX_STATUS is in info->flags, so the check is for IEEE80211_TX_CTRL_PORT_CTRL_PROTO instead. This works out OK because the only place setting _that_ at a point before this gets called is in fact ieee80211_tx_control_port() which was intended here. This is actually needed for correctness, if jt were checking info->flags instead, TDLS would fill/leak the status frames created here.
However, we can just fix it by using the cookie instead, that'll be set for PREAUTH frames via ieee80211_tx_control_port() as well, and no other frames.
Additionally, the code also erroneously set it, but that just caused preauth frames to get it set, since storing the ACK SKB will also set the correct flag. Drop this assignment entirely.
--- net/mac80211/tx.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
net/mac80211/tx.c +1 -5
@@ -3023,8 +3023,7 @@ static struct sk_buff *ieee80211_build_hdr(struct ieee80211_sub_if_data *sdata, }if (unlikely (!multicast && - (sk_requests_wifi_status (skb->sk) || - ctrl_flags &IEEE80211_TX_CTL_REQ_TX_STATUS ))) + (sk_requests_wifi_status (skb->sk) || cookie))) info_id =ieee80211_store_ack_skb (local, skb, &info_flags, cookie);
@@ -6662,9 +6661,6 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev,if (unencrypted) flags |=IEEE80211_TX_INTFL_DONT_ENCRYPT ; -if (cookie) - ctrl_flags |=IEEE80211_TX_CTL_REQ_TX_STATUS ; - flags |=IEEE80211_TX_INTFL_NL80211_FRAME_TX ; skb = dev_alloc_skb(local->hw.extra_tx_headroom +
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 213/2651 wifi: wfx: fix possible device hang during init
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jérôme Pouiller <[email protected]>
[ Upstream commit 102f54dc47be198e9310b18d41305a78d70a0796 ]
The WFxxx device provides an SDIO interface. In addition to the usual in-band SDIO IRQ, the device also supports out-of-band IRQ line. OOB IRQ requires a specific initialization described in commit f00dc1d789e1c ("staging: wfx: poll IRQ during init"):
When the chip starts in SDIO mode, the external IRQ (aka Out-Of-Band IRQ) cannot be used before to configure it. Therefore, the first exchanges with the chip have to be done without the OOB IRQ.
This patch allow to poll the data until the OOB IRQ is correctly setup. In order to keep the code simpler, this patch also poll data even if OOB IRQ is not used.
Commit 57aa557f110d9 ("staging: wfx: introduce a way to poll IRQ") announce some limitation about the data polling mechanism:
This function [wfx_bh_poll_irq()] must used with care: if an IRQ fires while the host reads control register, the IRQ can be lost.
However, with last analysis, it seems it does not only impact the IRQ. When this condition happen the hardware is lost and won't reply the next commands. The only way to recover the error is to pull the reset pin and bind the device again.
Currently wfx_bh_poll_irq() is only used during the two first exchanges with the hardware. Therefore, it has been reported to only happen after a few hours of bind/rebind in a loop. This explain why it has not been reported before.
Fortunately, wfx_bh_poll_irq() is only required for OOB IRQ, which is probably very marginal. The In-Band IRQ case also uses this function, but only to simplify the code.
This patch limits the use of wfx_bh_poll_irq() to the OOB IRQ. The bus driver now tells wfx_probe() whether polling is necessary. When it is not (in-band SDIO IRQ and SPI), the IRQ is subscribed before the first exchange with the device and wfx_bh_poll_irq() is never called. When it is (SDIO with OOB IRQ), the behavior is unchanged: the control register is polled until the PDS file has configured the IRQ line.
To conclude, In-Band users are now safe. Users of OOB IRQ will be still impacted by the bug, but there is nothing we can do (and nobody complained during the last 6 years).
--- drivers/net/wireless/silabs/wfx/bh.c | 6 ++-- drivers/net/wireless/silabs/wfx/bus_sdio.c | 1 + drivers/net/wireless/silabs/wfx/main.c | 34 ++++++++++++++-------- 3 files changed, 26 insertions(+), 15 deletions(-)
drivers/net/wireless/silabs/wfx/bh.c +3 -3
@@ -284,10 +284,10 @@ void wfx_bh_request_tx(struct wfx_dev *wdev) }/* If IRQ is not available, this function allow to manually poll the control register and simulate -* an IRQ ahen an event happened. +* an IRQ when an event happened. * -* Note that the device has a bug: If an IRQ raise while host read control register, the IRQ is -* lost. So, use this function carefully (only duing device initialisation). +* Note that the device has a bug: If an IRQ raise while host read control register, the device is +* lost. Unfortunately, this is the only way to initialize the SDIO with out-of-band IRQ. */ void wfx_bh_poll_irq (struct wfx_dev *wdev) {
drivers/net/wireless/silabs/wfx/bus_sdio.c +1 -0
@@ -279,6 +279,7 @@ static int wfx_sdio_probe(struct sdio_func *func, const struct sdio_device_id *i goto sdio_release; } + bus->core->poll_irq = !!bus->of_irq; ret =wfx_probe (bus->core);if (ret) goto sdio_release;
drivers/net/wireless/silabs/wfx/main.c +22 -12
@@ -362,7 +362,6 @@ int wfx_probe(struct wfx_dev *wdev)*/ gpio_saved = wdev->pdata.gpio_wakeup; wdev->pdata.gpio_wakeup =NULL ; - wdev->poll_irq = true; wdev->bh_wq =alloc_workqueue ("wfx_bh_wq" ,WQ_HIGHPRI |WQ_PERCPU ,0 );if (!wdev->bh_wq)
@@ -370,16 +369,24 @@ int wfx_probe(struct wfx_dev *wdev)wfx_bh_register (wdev); +if (!wdev->poll_irq) { + err = wdev->hwbus_ops->irq_subscribe (wdev->hwbus_priv); +if (err) + goto bh_unregister; + } + err =wfx_init_device (wdev);if (err) - goto bh_unregister; + goto irq_unsubscribe; + +if (wdev->poll_irq) +wfx_bh_poll_irq (wdev); -wfx_bh_poll_irq (wdev); err =wait_for_completion_timeout (&wdev->firmware_ready,1 *HZ );if (err ==0 ) {dev_err (wdev->dev,"timeout while waiting for startup indication\n" ); err = -ETIMEDOUT ; - goto bh_unregister; + goto irq_unsubscribe; }/* FIXME: fill wiphy::hw_version */
@@ -399,12 +406,12 @@ int wfx_probe(struct wfx_dev *wdev)dev_err (wdev->dev,"unsupported firmware API version (expect 1 while firmware returns %d)\n" , wdev->hw_caps.api_version_major); err = -EOPNOTSUPP ; - goto bh_unregister; + goto irq_unsubscribe; }if (wdev->hw_caps.link_mode ==SEC_LINK_ENFORCED ) {dev_err (wdev->dev,"chip require secure_link, but can't negotiate it\n" ); - goto bh_unregister; + goto irq_unsubscribe; }if (wdev->hw_caps.region_sel_mode) {
@@ -420,12 +427,14 @@ int wfx_probe(struct wfx_dev *wdev)dev_dbg (wdev->dev,"sending configuration file %s\n" , wdev->pdata.file_pds); err =wfx_send_pdata_pds (wdev);if (err <0 && err != -ENOENT ) - goto bh_unregister; + goto irq_unsubscribe; - wdev->poll_irq = false; - err = wdev->hwbus_ops->irq_subscribe (wdev->hwbus_priv); -if (err) - goto bh_unregister; +if (wdev->poll_irq) { + err = wdev->hwbus_ops->irq_subscribe (wdev->hwbus_priv); +if (err) + goto bh_unregister; + wdev->poll_irq = false; + } err =wfx_hif_use_multi_tx_conf (wdev, true);if (err)
@@ -474,7 +483,8 @@ int wfx_probe(struct wfx_dev *wdev) ieee80211_unregister:ieee80211_unregister_hw (wdev->hw); irq_unsubscribe: - wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv); +if (!wdev->poll_irq) + wdev->hwbus_ops->irq_unsubscribe (wdev->hwbus_priv); bh_unregister:wfx_bh_unregister (wdev);destroy_workqueue (wdev->bh_wq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 214/2651 hwrng: cctrng - Fix runtime PM usage counter leak
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 58d27c41542be6c40edac4f91f35a1dd8bf0d2c2 ]
pm_runtime_get_sync() increments the device usage counter even when runtime resume fails. cctrng_read() propagates errors from cc_trng_pm_get() without scheduling the work that later drops the counter, so a clock or reset-completion failure in cctrng_resume() leaves the counter elevated.
Use pm_runtime_resume_and_get(), which drops the usage counter when resume fails and returns zero on success. This preserves the existing success path while balancing the error path.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/char/hw_random/cctrng.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/char/hw_random/cctrng.c +1 -6
@@ -86,12 +86,7 @@ static inline u32 cc_ioread(struct cctrng_drvdata *drvdata, u32 reg)static int cc_trng_pm_get (struct device *dev) { -int rc =0 ; - - rc =pm_runtime_get_sync (dev); - -/* pm_runtime_get_sync() can return 1 as a valid return code */ -return (rc ==1 ?0 : rc); +return pm_runtime_resume_and_get (dev); }static void cc_trng_pm_put_suspend (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 215/2651 crypto: asymmetric_keys - fix OOB read in pefile_parse_binary
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabrice Derepas <[email protected]>
[ Upstream commit 37d550172c2d3cdb3a5ace3e6cb0625967d86349 ]
pefile_parse_binary() reads the size field of the certificate table's data-directory entry, which sits at fixed index 4 of the PE optional header's data directory:
ctx->certs_size = ddir->certs.size;
but nothing ensures index 4 is present. n_data_dirents (the untrusted NumberOfRvaAndSizes) is only upper-bounded against header_size and may be 0, and header_size need only satisfy cursor < header_size < datalen. A crafted PE with n_data_dirents = 0 and a tiny header_size therefore causes the ddir->certs.size read to land past the end of the image (CWE-125). The chkaddr() that bounds the certificate blob runs only after this read.
verify_pefile_signature() is reached from kexec_file_load() (the lockdown/secure-boot enforced PE-image signature path), and the image is parsed before its signature is checked. The trigger needs CAP_SYS_BOOT and the access is out-of-bounds read only (no write).
Require the certificate table's data-directory entry (index 4) to be present; the existing upper-bound check then keeps ddir->certs within [cursor, header_size).
--- crypto/asymmetric_keys/verify_pefile.c | 5 +++++ 1 file changed, 5 insertions(+)
crypto/asymmetric_keys/verify_pefile.c +5 -0
@@ -87,6 +87,11 @@ static int pefile_parse_binary(const void *pebuf, unsigned int pelen,if (ctx->n_data_dirents > (ctx->header_size - cursor) /sizeof (*dde))return -ELIBBAD ; +/* the certificate table entry must be present in the data directory */ +if (ctx->n_data_dirents <= + offsetof(struct data_directory , certs) /sizeof (*dde)) +return -ELIBBAD ; + ddir = pebuf + cursor; cursor +=sizeof (*dde) * ctx->n_data_dirents;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 216/2651 wifi: mac80211: fix swapped fq_overlimit/fq_overmemory in aqm debugfs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julius Bairaktaris <[email protected]>
[ Upstream commit 25f3f2ff88ae604a3b473b501fc55d58fcb0f5eb ]
The two scnprintf arguments for fq_overlimit and fq_overmemory are in the wrong order, which results in the aqm debugfs file showing the overmemory count under the fq_overlimit label and vice versa.
--- net/mac80211/debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/debugfs.c +1 -1
@@ -96,8 +96,8 @@ static ssize_t aqm_read(struct file *file,"RW fq_quantum %u\n" , fq->flows_cnt, fq->backlog, - fq->overmemory, fq->overlimit, + fq->overmemory, fq->collisions, fq->memory_usage, fq->memory_limit,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 217/2651 irqchip/riscv-imsic: Use GENMASK for base address masks
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit bd7d57a03c4b0fa3b0291ec64d688ebfed5edffc ]
The IMSIC DT binding allows riscv,guest-index-bits up to 7 and riscv,hart-index-bits up to 15. On RV32, guest-index-bits=7 and hart-index-bits=13, together with the 12-bit IMSIC page offset, is a binding-valid layout that consumes a 32-bit low-address mask.
The parser accepts this equality case because it rejects only values larger than the remaining bit budget. The base address canonicalization then builds the low-address mask with BIT(sum) - 1. When sum is 32 on RV32, that expression shifts an unsigned long by its full width.
Keep the legal equality layout and express the mask with GENMASK(sum - 1,
0) instead. The existing parser bounds guarantee that sum - 1 is below BITS_PER_LONG at both mask sites.
--- drivers/irqchip/irq-riscv-imsic-state.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/irqchip/irq-riscv-imsic-state.c +7 -6
@@ -7,6 +7,7 @@#define pr_fmt (fmt) "riscv-imsic: " fmt#include <linux/acpi.h> #include <linux/cpu.h> +#include <linux/bits.h> #include <linux/bitmap.h> #include <linux/interrupt.h> #include <linux/irq.h>
@@ -769,9 +770,9 @@ static int __init imsic_parse_fwnode(struct fwnode_handle *fwnode,return -EINVAL ; } global->base_addr = res.start; - global->base_addr &= ~(BIT (global->guest_index_bits + - global->hart_index_bits + -IMSIC_MMIO_PAGE_SHIFT ) -1 ); + global->base_addr &= ~GENMASK (global->guest_index_bits + + global->hart_index_bits + +IMSIC_MMIO_PAGE_SHIFT -1 ,0 ); global->base_addr &= ~((BIT (global->group_index_bits) -1 ) << global->group_index_shift);
@@ -850,9 +851,9 @@ int __init imsic_setup_state(struct fwnode_handle *fwnode, void *opaque) } base_addr = mmios[i].start; - base_addr &= ~(BIT (global->guest_index_bits + - global->hart_index_bits + -IMSIC_MMIO_PAGE_SHIFT ) -1 ); + base_addr &= ~GENMASK (global->guest_index_bits + + global->hart_index_bits + +IMSIC_MMIO_PAGE_SHIFT -1 ,0 ); base_addr &= ~((BIT (global->group_index_bits) -1 ) << global->group_index_shift);if (base_addr != global->base_addr) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 218/2651 memory: brcmstb_dpfe: validate firmware section sizes
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit e61c1a1103e2617e8f86288368911a8591e35c1e ]
The firmware header is read before the image has been shown to contain a complete header. In addition, the final size check adds two firmware-provided u32 section lengths before comparing the result with fw->size, so the addition can wrap.
Reject images shorter than the fixed header and checksum before reading the header. Then derive the available payload length with subtraction and require the two declared sections to fill it exactly.
--- drivers/memory/brcmstb_dpfe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/memory/brcmstb_dpfe.c +9 -8
@@ -533,9 +533,15 @@ static int __verify_firmware(struct init_data *init, const struct firmware *fw) {const struct dpfe_firmware_header *header = (void *)fw->data; -unsigned int dmem_size, imem_size, total_size; +unsigned int dmem_size, imem_size;bool is_big_endian = false;const u32 *chksum_ptr; +size_t payload_size; + +if (fw->size <sizeof (*header) +sizeof (*chksum_ptr)) +return ERR_INVALID_SIZE ; + + payload_size = fw->size -sizeof (*header) -sizeof (*chksum_ptr);if (header->magic ==DPFE_BE_MAGIC ) is_big_endian = true;
@@ -554,13 +560,8 @@ static int __verify_firmware(struct init_data *init,if ((dmem_size %sizeof (u32)) !=0 || (imem_size %sizeof (u32)) !=0 )return ERR_INVALID_SIZE ; -/* -* The header + the data section + the instruction section + the -* checksum must be equal to the total firmware size. -*/ - total_size = dmem_size + imem_size +sizeof (*header) + -sizeof (*chksum_ptr); -if (total_size != fw->size) +/* The data and instruction sections must fill the payload exactly. */ +if (dmem_size > payload_size || imem_size != payload_size - dmem_size)return ERR_INVALID_SIZE ;/* The checksum comes at the very end. */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 219/2651 arm64: dts: qcom: purwa: Drop the Hamoa workaround for PDC
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maulik Shah <[email protected]>
[ Upstream commit 13ca1c0b7d8a3ab1e59cb3e780c1dd7441e22515 ]
X1P42100 (Purwa) shares the X1E80100 (Hamoa) PDC device, but the hardware register bug addressed in commit e9a48ea4d90b ("irqchip/qcom-pdc:
Workaround hardware register bug on X1E80100") is already fixed in X1P42100 silicon.
X1E80100 compatible forces the software workaround. Use the X1P42100 specific compatible string for the PDC node to remove the workaround.
--- arch/arm64/boot/dts/qcom/purwa.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/boot/dts/qcom/purwa.dtsi +5 -0
@@ -224,6 +224,11 @@ &pcie6a_phy { compatible = "qcom,x1p42100-qmp-gen4x4-pcie-phy"; }; +/* X1P42100 PDC is same as X1E80100, but without hardware register bug */ +&pdc { + compatible = "qcom,x1p42100-pdc", "qcom,pdc"; +}; + &qfprom { gpu_speed_bin: gpu-speed-bin@119 { reg = <0x119 0x2>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 220/2651 arm64: dts: ti: k3-j722s-evm: Switch audio codec clock from audio_refclk1 to external clock
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jared McArthur <[email protected]>
[ Upstream commit 432bfc86fe62b654c74d9376b03cbe4d3513ac5f ]
In revision PROC170E1 of the J722SXH01EVM [0], the audio codec's (TLV320AIC3106IRGZT [1]) MCLK was provided by the AUDIO_EXT_REFCLK1 (96MHz). Revisions PROC170E2 and later switched the MCLK's source to an external LMK6CE012288CDLFT [2] oscillator (12.288MHz). The PROC170E1 revision of the board is not publicly available.
Fix the audio codec's clock by creating a new fixed clock node with a frequency of 12.288MHz, and switch the audio codec's clock from the audio_refclk1 to the new fixed clock. Remove pinmuxing and clock muxing for the audio_refclk1.
[0] https://www.ti.com/lit/zip/SPRR495
[1] https://www.ti.com/lit/gpn/TLV320AIC3106
[2] https://www.ti.com/lit/gpn/lmk6c
--- arch/arm64/boot/dts/ti/k3-j722s-evm.dts | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-)
arch/arm64/boot/dts/ti/k3-j722s-evm.dts +7 -18
@@ -162,6 +162,12 @@ vsys_io_1v2: regulator-vsys-io-1v2 { regulator-boot-on; }; + tlv320_mclk: clock-12288000 { + compatible = "fixed-clock"; + clock-frequency = <12288000>; + #clock-cells = <0>; + }; + codec_audio: sound { compatible = "simple-audio-card"; simple-audio-card,name = "J722S-EVM";
@@ -187,7 +193,7 @@ simple-audio-card,cpu { sound_master: simple-audio-card,codec { sound-dai = <&tlv320aic3106>; - clocks = <&audio_refclk1>; + clocks = <&tlv320_mclk>; }; };
@@ -228,11 +234,6 @@ csi23_mux: mux-controller-1 { }; }; -&audio_refclk1 { - assigned-clocks = <&k3_clks 157 0>; - assigned-clock-parents = <&k3_clks 157 15>; -}; - &cpsw_mac_syscon { bootph-all; };
@@ -358,12 +359,6 @@ J722S_IOPAD(0x0084, PIN_INPUT, 2) /* (N21) GPMC0_ADVn_ALE.MCASP1_AXR2 */ >; }; - audio_ext_refclk1_pins_default: audio-ext-refclk1-default-pins { - pinctrl-single,pins = < - J722S_IOPAD(0x00a0, PIN_OUTPUT, 1) /* (N24) GPMC0_WPn.AUDIO_EXT_REFCLK1 */ - >; - }; - pmic_irq_pins_default: pmic-irq-default-pins { pinctrl-single,pins = < J722S_IOPAD(0x030, PIN_INPUT, 7) /* (K23) GPIO0_12 */
@@ -562,12 +557,6 @@ ldo3: ldo3 { }; }; -&k3_clks { - /* Configure AUDIO_EXT_REFCLK1 pin as output */ - pinctrl-names = "default"; - pinctrl-0 = <&audio_ext_refclk1_pins_default>; -}; - &main_i2c0 { pinctrl-names = "default"; pinctrl-0 = <&main_i2c0_pins_default>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 221/2651 cxl/features: Reject feature offset that overflows 16-bit field
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Cheng <[email protected]>
[ Upstream commit 3eb3376944ace574bf7ae299e944a2a3c30c93ba ]
cxl_get_feature() and cxl_set_feature() build each mailbox command's offset from the starting offset plus the amount of data already transferred, then store it in a 16-bit field. A user-controlled fwctl offset and transfer size can exceed the feature extent, allowing a later offset to be truncated by cpu_to_le16() and target the wrong feature data.
Reject requests whose transfer size exceeds the remaining 16-bit feature range. Express the check as "size > U16_MAX - offset" so the validation itself cannot wrap on 32-bit systems.
Change cxl_get_feature() to return ssize_t so invalid input and mailbox failures are reported as negative errno rather than being conflated with a zero-byte result. Update the EDAC callers to handle negative results. Keep fwctl behavior unchanged by translating helper failures to the same header-only RPC response carrying the CXL mailbox return code.
--- drivers/cxl/core/core.h | 8 ++++---- drivers/cxl/core/edac.c | 20 +++++++++++++++----- drivers/cxl/core/features.c | 28 ++++++++++++++++++---------- 3 files changed, 37 insertions(+), 19 deletions(-)
drivers/cxl/core/core.h +4 -4
@@ -217,10 +217,10 @@ int cxl_port_get_possible_dports(struct cxl_port *port);#ifdef CONFIG_CXL_FEATURES struct cxl_feat_entry *cxl_feature_info (struct cxl_features_state *cxlfs,const uuid_t *uuid); -size_t cxl_get_feature (struct cxl_mailbox *cxl_mbox,const uuid_t *feat_uuid, -enum cxl_get_feat_selection selection, -void *feat_out,size_t feat_out_size,u16 offset, -u16 *return_code); +ssize_t cxl_get_feature (struct cxl_mailbox *cxl_mbox,const uuid_t *feat_uuid, +enum cxl_get_feat_selection selection, +void *feat_out,size_t feat_out_size,u16 offset, +u16 *return_code); int cxl_set_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, u8 feat_version, const void *feat_data, size_t feat_data_size, u32 feat_flag, u16 offset,
drivers/cxl/core/edac.c +15 -5
@@ -78,7 +78,7 @@ static int cxl_mem_scrub_get_attrbs(struct cxl_mailbox *cxl_mbox, u8 *cap, u16 *cycle, u8 *flags, u8 *min_cycle) {size_t rd_data_size =sizeof (struct cxl_scrub_rd_attrbs ); -size_t data_size; +ssize_t data_size; struct cxl_scrub_rd_attrbs *rd_attrbs __free(kfree) =kzalloc (rd_data_size,GFP_KERNEL );if (!rd_attrbs)
@@ -87,6 +87,8 @@ static int cxl_mem_scrub_get_attrbs(struct cxl_mailbox *cxl_mbox, u8 *cap, data_size =cxl_get_feature (cxl_mbox, &CXL_FEAT_PATROL_SCRUB_UUID ,CXL_GET_FEAT_SEL_CURRENT_VALUE , rd_attrbs, rd_data_size,0 ,NULL ); +if (data_size <0 ) +return data_size;if (!data_size)return -EIO ;
@@ -551,7 +553,7 @@ static int cxl_mem_ecs_get_attrbs(struct device *dev,struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;struct cxl_ecs_fru_rd_attrbs *fru_rd_attrbs;size_t rd_data_size; -size_t data_size; +ssize_t data_size; rd_data_size = cxl_ecs_ctx->get_feat_size;
@@ -563,6 +565,8 @@ static int cxl_mem_ecs_get_attrbs(struct device *dev, data_size =cxl_get_feature (cxl_mbox, &CXL_FEAT_ECS_UUID ,CXL_GET_FEAT_SEL_CURRENT_VALUE , rd_attrbs, rd_data_size,0 ,NULL ); +if (data_size <0 ) +return data_size;if (!data_size)return -EIO ;
@@ -583,7 +587,7 @@ static int cxl_mem_ecs_set_attrbs(struct device *dev,struct cxl_ecs_fru_wr_attrbs *fru_wr_attrbs;size_t rd_data_size, wr_data_size;u16 num_media_frus, count; -size_t data_size; +ssize_t data_size; num_media_frus = cxl_ecs_ctx->num_media_frus; rd_data_size = cxl_ecs_ctx->get_feat_size;
@@ -596,6 +600,8 @@ static int cxl_mem_ecs_set_attrbs(struct device *dev, data_size =cxl_get_feature (cxl_mbox, &CXL_FEAT_ECS_UUID ,CXL_GET_FEAT_SEL_CURRENT_VALUE , rd_attrbs, rd_data_size,0 ,NULL ); +if (data_size <0 ) +return data_size;if (!data_size)return -EIO ;
@@ -1264,7 +1270,7 @@ cxl_mem_sparing_get_attrbs(struct cxl_mem_sparing_context *cxl_sparing_ctx)struct cxl_memdev *cxlmd = cxl_sparing_ctx->cxlmd;struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;u16 restriction_flags; -size_t data_size; +ssize_t data_size;u16 return_code; struct cxl_memdev_sparing_rd_attrbs *rd_attrbs __free(kfree) =kzalloc (rd_data_size,GFP_KERNEL );
@@ -1274,6 +1280,8 @@ cxl_mem_sparing_get_attrbs(struct cxl_mem_sparing_context *cxl_sparing_ctx) data_size =cxl_get_feature (cxl_mbox, &cxl_sparing_ctx->repair_uuid,CXL_GET_FEAT_SEL_CURRENT_VALUE , rd_attrbs, rd_data_size,0 , &return_code); +if (data_size <0 ) +return data_size;if (!data_size)return -EIO ;
@@ -1750,7 +1758,7 @@ static int cxl_mem_ppr_get_attrbs(struct cxl_ppr_context *cxl_ppr_ctx)struct cxl_memdev *cxlmd = cxl_ppr_ctx->cxlmd;struct cxl_mailbox *cxl_mbox = &cxlmd->cxlds->cxl_mbox;u16 restriction_flags; -size_t data_size; +ssize_t data_size;u16 return_code; struct cxl_memdev_ppr_rd_attrbs *rd_attrbs __free(kfree) =
@@ -1761,6 +1769,8 @@ static int cxl_mem_ppr_get_attrbs(struct cxl_ppr_context *cxl_ppr_ctx) data_size =cxl_get_feature (cxl_mbox, &cxl_ppr_ctx->repair_uuid,CXL_GET_FEAT_SEL_CURRENT_VALUE , rd_attrbs, rd_data_size,0 , &return_code); +if (data_size <0 ) +return data_size;if (!data_size)return -EIO ;
drivers/cxl/core/features.c +18 -10
@@ -220,10 +220,10 @@ int devm_cxl_setup_features(struct cxl_dev_state *cxlds) }EXPORT_SYMBOL_NS_GPL (devm_cxl_setup_features,"CXL" ); -size_t cxl_get_feature (struct cxl_mailbox *cxl_mbox,const uuid_t *feat_uuid, -enum cxl_get_feat_selection selection, -void *feat_out,size_t feat_out_size,u16 offset, -u16 *return_code) +ssize_t cxl_get_feature (struct cxl_mailbox *cxl_mbox,const uuid_t *feat_uuid, +enum cxl_get_feat_selection selection, +void *feat_out,size_t feat_out_size,u16 offset, +u16 *return_code) {size_t data_to_rd_size;struct cxl_mbox_get_feat_in pi;
@@ -235,7 +235,10 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, *return_code =CXL_MBOX_CMD_RC_INPUT ;if (!feat_out || !feat_out_size) -return 0 ; +return -EINVAL ; + +if (feat_out_size >U16_MAX - offset) +return -EINVAL ;uuid_copy (&pi.uuid, feat_uuid); pi.selection = selection;
@@ -259,7 +262,7 @@ size_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,if (rc <0 || !mbox_cmd.size_out) {if (return_code) *return_code = mbox_cmd.return_code; -return 0 ; +return rc <0 ? rc : -EIO ; } data_rcvd_size += mbox_cmd.size_out; }while (data_rcvd_size < feat_out_size);
@@ -288,6 +291,9 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox,if (return_code) *return_code =CXL_MBOX_CMD_RC_INPUT ; +if (feat_data_size >U16_MAX - offset) +return -EINVAL ; + struct cxl_mbox_set_feat_in *pi __free(kfree) =kzalloc (cxl_mbox->payload_size,GFP_KERNEL );if (!pi)
@@ -462,6 +468,7 @@ static void *cxlctl_get_feature(struct cxl_features_state *cxlfs,const struct cxl_mbox_get_feat_in *feat_in;u16 offset, count, return_code;size_t out_size = *out_len; +ssize_t data_size;if (rpc_in->op_size !=sizeof (*feat_in))return ERR_PTR (-EINVAL );
@@ -482,16 +489,17 @@ static void *cxlctl_get_feature(struct cxl_features_state *cxlfs,if (!rpc_out)return ERR_PTR (-ENOMEM ); - out_size =cxl_get_feature (cxl_mbox, &feat_in->uuid, - feat_in->selection, rpc_out->payload, - count, offset, &return_code); + data_size =cxl_get_feature (cxl_mbox, &feat_in->uuid, + feat_in->selection, rpc_out->payload, + count, offset, &return_code); *out_len =sizeof (struct fwctl_rpc_cxl_out ); -if (!out_size) { +if (data_size <=0 ) { rpc_out->size =0 ; rpc_out->retval = return_code;return no_free_ptr (rpc_out); } + out_size = data_size; rpc_out->size = out_size; rpc_out->retval =CXL_MBOX_CMD_RC_SUCCESS ; *out_len += out_size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 222/2651 cxl/fwctl: Propagate feature RPC delivery errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Cheng <[email protected]>
[ Upstream commit 51493ff66ad6b1c8e904cf3ab8c69e9c59aaba0f ]
FWCTL_RPC requires delivery failures to be returned as ioctl errors, while device errors are reported in the output. Get and Set Feature instead converted all failures into normal responses, sometimes with a SUCCESS device status.
Initialize the return code to SUCCESS. When the helper fails without a device error code, return its errno. Continue reporting actual device errors through rpc_out->retval.
CXL permits Get Feature to return a nonzero short payload when Offset + Count runs past the end of the Feature. cxl_internal_send_cmd() reports that response as -EIO, so preserve the returned bytes as a successful partial transfer. Fixed-format EDAC callers still require complete attribute structures, so reject partial payloads before consuming them.
Map an unexpected zero-length result with a SUCCESS device status to -EIO.
--- drivers/cxl/core/edac.c | 10 +++++----- drivers/cxl/core/features.c | 28 +++++++++++++++++++--------- 2 files changed, 24 insertions(+), 14 deletions(-)
drivers/cxl/core/edac.c +5 -5
@@ -89,7 +89,7 @@ static int cxl_mem_scrub_get_attrbs(struct cxl_mailbox *cxl_mbox, u8 *cap, rd_data_size, 0, NULL);if (data_size <0 )return data_size; -if (!data_size) +if ((size_t )data_size != rd_data_size)return -EIO ; *cap = rd_attrbs->scrub_cycle_cap;
@@ -567,7 +567,7 @@ static int cxl_mem_ecs_get_attrbs(struct device *dev, rd_data_size, 0, NULL);if (data_size <0 )return data_size; -if (!data_size) +if ((size_t )data_size != rd_data_size)return -EIO ; fru_rd_attrbs = rd_attrbs->fru_attrbs;
@@ -602,7 +602,7 @@ static int cxl_mem_ecs_set_attrbs(struct device *dev, rd_data_size, 0, NULL);if (data_size <0 )return data_size; -if (!data_size) +if ((size_t )data_size != rd_data_size)return -EIO ; struct cxl_ecs_wr_attrbs *wr_attrbs __free(kvfree) =
@@ -1282,7 +1282,7 @@ cxl_mem_sparing_get_attrbs(struct cxl_mem_sparing_context *cxl_sparing_ctx) rd_data_size, 0, &return_code);if (data_size <0 )return data_size; -if (!data_size) +if ((size_t )data_size != rd_data_size)return -EIO ; cxl_sparing_ctx->op_class = rd_attrbs->hdr.op_class;
@@ -1771,7 +1771,7 @@ static int cxl_mem_ppr_get_attrbs(struct cxl_ppr_context *cxl_ppr_ctx) rd_data_size, 0, &return_code);if (data_size <0 )return data_size; -if (!data_size) +if ((size_t )data_size != rd_data_size)return -EIO ; cxl_ppr_ctx->op_class = rd_attrbs->hdr.op_class;
drivers/cxl/core/features.c +19 -9
@@ -232,7 +232,7 @@ ssize_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid,int rc;if (return_code) - *return_code =CXL_MBOX_CMD_RC_INPUT ; + *return_code =CXL_MBOX_CMD_RC_SUCCESS ;if (!feat_out || !feat_out_size)return -EINVAL ;
@@ -259,6 +259,17 @@ ssize_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, .min_out = data_to_rd_size, }; rc =cxl_internal_send_cmd (cxl_mbox, &mbox_cmd); +/* +* Per CXL r4.0 8.2.10.6.2, when Offset + Count runs past the +* end of the Feature the device returns only the bytes up to +* the Feature size. cxl_internal_send_cmd() reports that as +* -EIO with a short payload, so stop and return what arrived. +*/ +if (rc == -EIO && mbox_cmd.size_out && + mbox_cmd.size_out < data_to_rd_size) { + data_rcvd_size += mbox_cmd.size_out; +break ; + }if (rc <0 || !mbox_cmd.size_out) {if (return_code) *return_code = mbox_cmd.return_code;
@@ -267,9 +278,6 @@ ssize_t cxl_get_feature(struct cxl_mailbox *cxl_mbox, const uuid_t *feat_uuid, data_rcvd_size += mbox_cmd.size_out; }while (data_rcvd_size < feat_out_size); -if (return_code) - *return_code =CXL_MBOX_CMD_RC_SUCCESS ; -return data_rcvd_size; }
@@ -289,7 +297,7 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox,size_t hdr_size;if (return_code) - *return_code =CXL_MBOX_CMD_RC_INPUT ; + *return_code =CXL_MBOX_CMD_RC_SUCCESS ;if (feat_data_size >U16_MAX - offset)return -EINVAL ;
@@ -340,11 +348,8 @@ int cxl_set_feature(struct cxl_mailbox *cxl_mbox, } data_sent_size += data_in_size; -if (data_sent_size >= feat_data_size) { -if (return_code) - *return_code =CXL_MBOX_CMD_RC_SUCCESS ; +if (data_sent_size >= feat_data_size)return 0 ; - }if ((feat_data_size - data_sent_size) <= (cxl_mbox->payload_size - hdr_size)) { data_in_size = feat_data_size - data_sent_size;
@@ -492,6 +497,9 @@ static void *cxlctl_get_feature(struct cxl_features_state *cxlfs, data_size =cxl_get_feature (cxl_mbox, &feat_in->uuid, feat_in->selection, rpc_out->payload, count, offset, &return_code); +if (data_size <=0 && + return_code ==CXL_MBOX_CMD_RC_SUCCESS ) +return ERR_PTR (data_size ?: -EIO ); *out_len =sizeof (struct fwctl_rpc_cxl_out );if (data_size <=0 ) { rpc_out->size =0 ;
@@ -544,6 +552,8 @@ static void *cxlctl_set_feature(struct cxl_features_state *cxlfs, rc =cxl_set_feature (cxl_mbox, &feat_in->uuid, feat_in->version, feat_in->feat_data, data_size, flags, offset, &return_code); +if (rc && return_code ==CXL_MBOX_CMD_RC_SUCCESS ) +return ERR_PTR (rc); *out_len =sizeof (*rpc_out);if (rc) { rpc_out->retval = return_code;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 223/2651 selftests/bpf: make cmdline_contains stricter
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexis Lothoré (eBPF Foundation) <[email protected]>
[ Upstream commit 040ef1f8b02e57b78081581d490ceec04ef5f7c0 ]
cmdline_contains is used by BPF selftests to check the presence of specific kernel commandline parameters, but it currently suffers from two issues:
- the read commandline isn't NULL terminated right after the read data but only at the end of the buffer, leaving uninitialized bytes that are then possibly tokenized
- the comparison of found tokens is done based on the size of found token. This could lead to too-short-but-matching tokens to wrongly match the search pattern.
Enforce stricter checks in cmdline_contains to avoid accidental matches.
--- tools/testing/selftests/bpf/unpriv_helpers.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/unpriv_helpers.c +5 -4
@@ -72,8 +72,8 @@ static int config_contains(const char *pat)static bool cmdline_contains (const char *pat) { +int fd, cnt, ret = false;char cmdline[4096 ], *c; -int fd, ret = false; fd =open ("/proc/cmdline" ,O_RDONLY );if (fd <0 ) {
@@ -81,14 +81,15 @@ static bool cmdline_contains(const char *pat)return false; } -if (read (fd, cmdline,sizeof (cmdline) -1 ) <0 ) { + cnt =read (fd, cmdline,sizeof (cmdline) -1 ); +if (cnt <0 ) {perror ("read /proc/cmdline" ); goto out; } - cmdline[sizeof (cmdline) -1 ] ='\0' ; + cmdline[cnt] ='\0' ;for (c =strtok (cmdline," \n" ); c; c =strtok (NULL ," \n" )) { -if (strncmp (c, pat,strlen (c))) +if (strcmp (c, pat))continue ; ret = true;break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 224/2651 spi: amlogic: spisg: Fix transfer size limit and timeout handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xianwei Zhao <[email protected]>
[ Upstream commit 754d2bbd92f5ecef0eb4f5b1ac7b1417320a56ca ]
The CFG_BLOCK_NUM field can encode at most 20 bits, so reduce SPISG_BLOCK_MAX to 0xfffff to avoid programming a zero-length transfer.
Perform the delay calculation in 64-bit arithmetic to avoid overflow when converting nanoseconds to SPI clock cycles.
Stop the controller on transfer timeout by clearing the descriptor list register before returning an error.
--- drivers/spi/spi-amlogic-spisg.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/spi/spi-amlogic-spisg.c +7 -4
@@ -95,7 +95,7 @@#define SPISG_MAX_REG 0x40 -#define SPISG_BLOCK_MAX 0x100000 +#define SPISG_BLOCK_MAX 0xFFFFF#define SPISG_OP_MODE_WRITE_CMD 0#define SPISG_OP_MODE_READ_STS 1
@@ -175,7 +175,7 @@ static int spi_delay_to_sclk(u32 slck_speed_hz, struct spi_delay *delay)if (ns <0 )return 0 ; -return DIV_ROUND_UP_ULL (slck_speed_hz * ns,NSEC_PER_SEC ); +return DIV_ROUND_UP_ULL ((u64 )slck_speed_hz * ns,NSEC_PER_SEC ); }static inline u32 aml_spisg_sem_down_read (struct spisg_device *spisg)
@@ -565,10 +565,13 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr,aml_spisg_pending (spisg, descs_paddr, false, true);if (wait_for_completion_timeout (&spisg->completion,spi_controller_is_target (spisg->controller) ? -MAX_SCHEDULE_TIMEOUT :msecs_to_jiffies (ms))) +MAX_SCHEDULE_TIMEOUT :msecs_to_jiffies (ms))) { ret = spisg->status ? -EIO :0 ; -else + }else { +/* stop transfer */ +regmap_write (spisg->map,SPISG_REG_DESC_LIST_H ,0 ); ret = -ETIMEDOUT ; + }dma_unmap_single (dev, descs_paddr, descs_len,DMA_TO_DEVICE ); end:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 225/2651 spi: amlogic: spisg: Fix the incorrect keep_ss of the last descriptor
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sunny Luo <[email protected]>
[ Upstream commit 253dfb1839c6bc357aebe8aac4f1b4dcc20ee322 ]
The driver currently unconditionally clears CFG_KEEP_SS on the last descriptor, causing the last transfer's cs_change setting to be ignored.
Record the cs_change value of the last SPI transfer and use it to program CFG_KEEP_SS on the final descriptor. When a null descriptor is inserted to implement the cs-hold delay, keep CFG_KEEP_SS set on the preceding transfer descriptor and apply the recorded value to the final descriptor instead.
This ensures the controller handles chip select correctly for the last transfer regardless of whether a cs-hold delay is required.
--- drivers/spi/spi-amlogic-spisg.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/spi/spi-amlogic-spisg.c +11 -4
@@ -489,6 +489,7 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr,struct spisg_descriptor_extra *exdescs, *exdesc;dma_addr_t descs_paddr;int desc_num =1 , descs_len; +bool last_xfer_keep_ss = false;u32 cs_hold_in_sclk =0 ;int ret = -EIO ;
@@ -529,9 +530,11 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr, spi_delay_to_sclk(xfer->effective_speed_hz, &msg->spi->cs_setup));/* calculate cs-hold delay with the last xfer speed */ -if (list_is_last (&xfer->transfer_list, &msg->transfers)) +if (list_is_last (&xfer->transfer_list, &msg->transfers)) { cs_hold_in_sclk =spi_delay_to_sclk (xfer->effective_speed_hz, &msg->spi->cs_hold); + last_xfer_keep_ss = xfer->cs_change; + } desc++; exdesc++;
@@ -539,13 +542,17 @@ static int aml_spisg_transfer_one_message(struct spi_controller *ctlr, xfer->effective_speed_hz); } -if (cs_hold_in_sclk) +if (cs_hold_in_sclk) {/* additional null-descriptor to achieve the cs-hold delay */ aml_spisg_setup_null_desc (spisg, desc, cs_hold_in_sclk); -else desc--; + desc->cfg_bus |=FIELD_PREP (CFG_KEEP_SS ,1 ); + desc++; + }else { + desc--; + } - desc->cfg_bus |=FIELD_PREP (CFG_KEEP_SS ,0 ); +FIELD_MODIFY (CFG_KEEP_SS , &desc->cfg_bus, last_xfer_keep_ss); desc->cfg_start |=FIELD_PREP (CFG_EOC ,1 );/* some tolerances */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 226/2651 mtd: rawnand: sunxi: propagate user-data allocation errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit 8696502b0aa96bcbb1f1e78ae117726378823ae8 ]
sunxi_nfc_maximize_user_data() returns -ENOMEM when its per-step length array cannot be allocated, but the caller ignores that error. The NULL array then makes sunxi_nfc_user_data_sz() report the fixed four-byte fallback, which is not the layout that the variable-length setup calculated.
Return the setup error so an allocation failure cannot silently select and validate a different OOB layout.
--- drivers/mtd/nand/raw/sunxi_nand.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +7 -3
@@ -2072,6 +2072,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,int total_user_data_sz =0 ;int nsectors;int ecc_mode; +int ret;int i;if (nanddev->ecc.user_conf.flags &NAND_ECC_MAXIMIZE_STRENGTH ) {
@@ -2172,9 +2173,12 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand,* The rationale for variable data length is to prioritize maximum ECC * strength, and then use the remaining space for user data. */ -if (nfc->caps->reg_user_data_len) -sunxi_nfc_maximize_user_data (nand, mtd->oobsize, ecc->bytes, - nsectors); +if (nfc->caps->reg_user_data_len) { + ret =sunxi_nfc_maximize_user_data (nand, mtd->oobsize, + ecc->bytes, nsectors); +if (ret) +return ret; + }if (total_user_data_sz ==0 )for (i =0 ; i < nsectors; i++)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 227/2651 mtd: rawnand: sunxi: reserve a full user-data word for BBM
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit bde8fd880d84627072c224729c818306c4b30d58 ]
H6/H616 protected user-data lengths are encoded in four-byte units, but ECC maximization reserves only the two bad block marker bytes. A strength leaving fewer than four bytes therefore selects a zero-byte first user-data section.
The OOB layout then subtracts the two marker bytes from that unsigned zero length, and the controller has no protected user-data word in which to store the marker.
Reserve one complete user-data word while maximizing ECC, reject configurations which produce no ECC sectors or a shorter first section, and make the OOB iterator bounds-safe.
--- drivers/mtd/nand/raw/sunxi_nand.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +12 -5
@@ -1991,7 +1991,7 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,struct nand_chip *nand =mtd_to_nand (mtd);struct nand_ecc_ctrl *ecc = &nand->ecc;struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand); -unsigned int user_data_sz =sunxi_nfc_user_data_sz (sunxi_nand, section); +unsigned int user_data_sz;/* * The controller does not provide access to OOB bytes
@@ -2000,6 +2000,8 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,if (section >= ecc->steps)return -ERANGE ; + user_data_sz =sunxi_nfc_user_data_sz (sunxi_nand, section); +/* * The first 2 bytes are used for BB markers, hence we * only have user_data_sz - 2 bytes available in the first user data
@@ -2007,7 +2009,7 @@ static int sunxi_nand_ooblayout_free(struct mtd_info *mtd, int section,*/ if (section ==0 ) { oobregion->offset =2 ; - oobregion->length = user_data_sz -2 ; + oobregion->length = user_data_sz >2 ? user_data_sz -2 :0 ;return 0 ; }
@@ -2041,6 +2043,9 @@ static int sunxi_nfc_maximize_user_data(struct nand_chip *nand, uint32_t oobsizeint remaining_bytes = oobsize - (ecc_bytes * nsectors);int i, step; +if (nsectors <=0 ) +return -EINVAL ; + sunxi_nand->user_data_bytes =devm_kzalloc (nfc->dev, nsectors,GFP_KERNEL );if (!sunxi_nand->user_data_bytes)
@@ -2056,6 +2061,8 @@ static int sunxi_nfc_maximize_user_data(struct nand_chip *nand, uint32_t oobsizeif (sunxi_nand->user_data_bytes[step] ==0 )break ; } +if (sunxi_nand->user_data_bytes[0 ] <USER_DATA_SZ ) +return -EINVAL ;return 0 ; }
@@ -2106,10 +2113,10 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_chip *nand, bytes -= total_user_data_sz; }else {/* -* remove at least the BBM size before computing the -* max ECC +* User-data lengths are encoded in four-byte units. Reserve +* the first word because it contains the two BBM bytes. */ - bytes -=2 ; + bytes -=USER_DATA_SZ ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 228/2651 mtd: rawnand: sunxi: use a stack buffer for BBM randomization
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Hilliard <[email protected]>
[ Upstream commit a8596bb7148136b9e83980900d508d0ef86507ef ]
Variable protected user-data lengths replaced the original four-byte stack buffer with a heap allocation before compensating the bad block marker. The allocation is unchecked, and a zero length returns ZERO_SIZE_PTR which sunxi_nfc_randomize_bbm() dereferences.
The controller supports at most 32 protected user-data bytes per ECC step, so use a zero-initialized buffer of that bounded size. This removes the allocation failure path and keeps zero-sized invalid layouts from dereferencing ZERO_SIZE_PTR.
--- drivers/mtd/nand/raw/sunxi_nand.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/mtd/nand/raw/sunxi_nand.c +2 -3
@@ -222,6 +222,7 @@* USER_DATA_LEN registers. */ #define USER_DATA_SZ 4 +#define SUNXI_NFC_MAX_USER_DATA_SZ 32/** * struct sunxi_nand_chip_sel - stores information related to NAND Chip Select
@@ -1003,11 +1004,10 @@ static void sunxi_nfc_hw_ecc_set_prot_oob_bytes(struct nand_chip *nand,struct sunxi_nfc *nfc =to_sunxi_nfc (nand->controller);struct sunxi_nand_chip *sunxi_nand =to_sunxi_nand (nand);unsigned int user_data_sz =sunxi_nfc_user_data_sz (sunxi_nand, step); -u8 *user_data =NULL ; +u8 user_data[SUNXI_NFC_MAX_USER_DATA_SZ ] = {};/* Randomize the Bad Block Marker. */ if (bbm && (nand->options &NAND_NEED_SCRAMBLING )) { - user_data =kmalloc (user_data_sz,GFP_KERNEL );memcpy (user_data, oob, user_data_sz);sunxi_nfc_randomize_bbm (nand, page, user_data); oob = user_data;
@@ -1040,7 +1040,6 @@ static void sunxi_nfc_hw_ecc_set_prot_oob_bytes(struct nand_chip *nand, } } -kfree (user_data); } static void sunxi_nfc_hw_ecc_update_stats(struct nand_chip *nand,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 229/2651 regulator: mp886x: fix vsel_mask
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jisheng Zhang <[email protected]>
[ Upstream commit 24fa0eadc2e3c7e9397924197dca7777ec08b8d7 ]
The MP886X vsel is 7bits, fix the vsel_mask.
--- drivers/regulator/mp886x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/mp886x.c +1 -1
@@ -267,7 +267,7 @@ static int mp886x_regulator_register(struct mp886x_device_info *di, rdesc->min_uV =600000 ; rdesc->uV_step =10000 ; rdesc->vsel_reg =MP886X_VSEL ; - rdesc->vsel_mask =0x3f ; + rdesc->vsel_mask =0x7f ; rdesc->ramp_reg =MP886X_SYSCNTLREG1 ; rdesc->ramp_mask =MP886X_SLEW_MASK ; rdesc->ramp_delay_table = di->ci->slew_rates;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 230/2651 spi: ma35d1-qspi: assert reset on probe error paths
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit 8992169e7ac6b216f881cb373bb2c6bff0c6162a ]
nuvoton_qspi_probe() pulses the exclusive reset and leaves it deasserted for normal operation. Later probe failures returned without re-asserting the reset, leaving the controller out of reset after a failed probe. Assert the reset on those error paths.
--- drivers/spi/spi-ma35d1-qspi.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/spi/spi-ma35d1-qspi.c +18 -8
@@ -633,12 +633,16 @@ static int nuvoton_qspi_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"failed to deassert reset\n" ); ret =device_property_read_u32 (dev,"num-cs" , &num_cs); -if (ret && ret != -EINVAL ) -return dev_err_probe (dev, ret,"failed to read num-cs\n" ); +if (ret && ret != -EINVAL ) { + ret =dev_err_probe (dev, ret,"failed to read num-cs\n" ); + goto err_assert; + } -if (!num_cs || num_cs >NUVOTON_QSPI_MAX_NUM_CS ) -return dev_err_probe (dev, -EINVAL ,"invalid num-cs %u\n" , +if (!num_cs || num_cs >NUVOTON_QSPI_MAX_NUM_CS ) { + ret =dev_err_probe (dev, -EINVAL ,"invalid num-cs %u\n" , num_cs); + goto err_assert; + } ctlr->num_chipselect = num_cs; ctlr->max_transfer_size = nuvoton_qspi_max_transfer_size;
@@ -655,14 +659,20 @@ static int nuvoton_qspi_probe(struct platform_device *pdev) ret =nuvoton_qspi_hw_init (qspi);if (ret) -return ret; + goto err_assert; ret =devm_spi_register_controller (dev, ctlr); -if (ret) -return dev_err_probe (dev, ret, -"failed to register spi controller\n" ); +if (ret) { + ret =dev_err_probe (dev, ret, +"failed to register spi controller\n" ); + goto err_assert; + }return 0 ; + +err_assert: +reset_control_assert (rst); +return ret; }static const struct of_device_id nuvoton_qspi_of_match[] = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 231/2651 efi/cper: Reject CPER records with an out-of-range error_data_length
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit a5a612cd3eecbadf135df1e9b2b40bc9f4c28f1c ]
cper_estatus_check() sizes each section with acpi_hest_get_record_size(), which adds the firmware-controlled u32 error_data_length to the header size as a signed int (see <acpi/ghes.h>). A value in the top sizeof(*gdata) bytes of the u32 range wraps the sum small rather than large, so it slips past the "record_size > data_len" check: against the 72-byte v300 header, 0xffffffb9 sizes the record at 1 and acpi_hest_get_next() walks it a byte at a time, off the end. 0xffffffb8 sizes it at 0 and loops forever.
Use check_add_overflow() to reject a sum that will not fit the int those helpers return, since the walk advances by that value. That subsumes the "acpi_hest_get_size(gdata) > data_len" test above it, because record_size is never smaller than the header.
The later "len < sizeof(*foo)" guards rely on this per-section upper bound; they are lower bounds only.
--- drivers/firmware/efi/cper.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/firmware/efi/cper.c +11 -3
@@ -752,7 +752,7 @@ EXPORT_SYMBOL_GPL(cper_estatus_check_header);int cper_estatus_check (const struct acpi_hest_generic_status *estatus) {struct acpi_hest_generic_data *gdata; -unsigned int data_len, record_size; +unsigned int data_len;int rc; rc =cper_estatus_check_header (estatus);
@@ -762,10 +762,18 @@ int cper_estatus_check(const struct acpi_hest_generic_status *estatus) data_len = estatus->data_length;apei_estatus_for_each_section (estatus, gdata) { -if (acpi_hest_get_size (gdata) > data_len) +int record_size; + +/* +* The <acpi/ghes.h> helpers sum these as a signed int, so a +* huge error_data_length wraps small rather than large and the +* walk then advances by that wrapped value. Reject a size an +* int cannot carry. +*/ +if (check_add_overflow (acpi_hest_get_size (gdata), + gdata->error_data_length, &record_size))return -EINVAL ; - record_size =acpi_hest_get_record_size (gdata);if (record_size > data_len)return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 232/2651 efi/cper: Reject an error status block length that wraps a u32
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 41e25ef5e417c62eb7bf39b187242b283b3ef9f1 ]
cper_estatus_len() sums the firmware-controlled data_length (or raw_data_offset plus raw_data_length) into a u32. A data_length of 0xffffffec wraps that sum to 0, and a length that reads back short defeats every bound built on it: bert_print_all() passes its "remain < estatus_len" check, then advances "estatus += estatus_len" by zero and loops forever. GHES survives only because __ghes_check_estatus() rejects a length below sizeof(*estatus) first.
Reject a length that cannot be expressed in a u32 in cper_estatus_check_header(), which both of today's callers reach: GHES via __ghes_check_estatus() and BERT via cper_estatus_check(). extlog reaches neither yet; a later patch routes it through cper_estatus_check(), whose ELOG_ENTRY_LEN bound needs this to hold.
--- drivers/firmware/efi/cper.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/firmware/efi/cper.c +11 -0
@@ -745,6 +745,17 @@ int cper_estatus_check_header(const struct acpi_hest_generic_status *estatus) estatus->raw_data_offset < sizeof(*estatus) + estatus->data_length) return -EINVAL; +/* +* cper_estatus_len() sums these into a u32, and a wrapped sum reads +* back smaller than the record. Reject a length that cannot be +* expressed so no caller is handed the short value. +*/ +if ((u64 )sizeof (*estatus) + estatus->data_length >U32_MAX ) +return -EINVAL ; +if (estatus->raw_data_length && + (u64 )estatus->raw_data_offset + estatus->raw_data_length >U32_MAX ) +return -EINVAL ; +return 0 ; }EXPORT_SYMBOL_GPL (cper_estatus_check_header);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 233/2651 ACPI: extlog: Validate elog record length before walking sections
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit e1fd582a8134150aa10c1f0286dbce00cf63b086 ]
extlog_print() copies a fixed ELOG_ENTRY_LEN (4096) bytes from the elog record into elog_buf, then walks the sections using the firmware-controlled data_length. Nothing keeps data_length inside the buffer, so a malformed record walks the section pointer past elog_buf and reads adjacent memory. Unlike the GHES paths, extlog never calls cper_estatus_check().
Reject a record longer than ELOG_ENTRY_LEN and run cper_estatus_check() before walking the sections. The length test alone is not enough: a wrapped length reads back short and passes it, which cper_estatus_check() catches via the header check added earlier. Drop a malformed record with NOTIFY_DONE and without MCE_HANDLED_EXTLOG, since extlog did not consume it.
--- drivers/acpi/acpi_extlog.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/acpi/acpi_extlog.c +9 -0
@@ -208,6 +208,15 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, tmp = (struct acpi_hest_generic_status *)elog_buf; +/* +* Bound the length before cper_estatus_check() walks the sections: it +* iterates over data_length, which is not yet known to fit elog_buf. +* cper_estatus_check_header() then rejects a length that wrapped, which +* the bound cannot see. +*/ +if (cper_estatus_len (tmp) >ELOG_ENTRY_LEN ||cper_estatus_check (tmp)) +return NOTIFY_DONE ; +if (!ras_userspace_consumers ()) {print_extlog_rcd (NULL , tmp, cpu); goto out;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 234/2651 ACPI: extlog: Avoid populating software AER metadata from raw hardware buffer
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 31333d134afb13e3942867d48efbcf8d6b88c849 ]
extlog_print_pcie() casts pcie_err->aer_info straight to struct aer_capability_regs *. That struct embeds struct pcie_tlp_log, whose software-only header_len and flit fields sit at offset 84 - inside the 96-byte aer_info buffer - so the cast fills them with raw firmware bytes. pcie_print_tlp_log() uses both to bound a loop over dw[], and a large header_len walks past the end of the array.
Copy into a zeroed local struct, and only as far as aer_info maps onto it:
the leading registers and the four Header Log DWORDs. Place the TLP Prefix Log separately, from the offset the hardware keeps it at. The rest stays zero, which covers header_len and flit and keeps the Root Error registers out of the prefix log, where pcie_print_tlp_log() would print them as end-to-end prefixes.
--- drivers/acpi/acpi_extlog.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-)
drivers/acpi/acpi_extlog.c +17 -3
@@ -137,7 +137,7 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err, int severity) {#ifdef ACPI_APEI_PCIEAER -struct aer_capability_regs *aer; +struct aer_capability_regs aer_regs = {};struct pci_dev *pdev;unsigned int devfn;unsigned int bus;
@@ -149,7 +149,21 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,return ; aer_severity =cper_severity_to_aer (severity); - aer = (struct aer_capability_regs *)pcie_err->aer_info; + +/* +* struct pcie_tlp_log is larger than the hardware layout, so aer_info +* only maps onto the struct up to the four Header Log DWORDs. Copy that +* much, then place the TLP Prefix Log from where the hardware keeps it. +* Everything else stays zero: nothing reads root_command, root_status or +* the error source IDs, and header_len and flit are software-only. +*/ +memcpy (&aer_regs, pcie_err->aer_info, + offsetof(struct aer_capability_regs , header_log) + +PCIE_STD_NUM_TLP_HEADERLOG *sizeof (u32)); +memcpy (aer_regs.header_log.prefix, + pcie_err->aer_info +PCI_ERR_PREFIX_LOG , +sizeof (aer_regs.header_log.prefix)); + domain = pcie_err->device_id.segment; bus = pcie_err->device_id.bus; devfn = PCI_DEVFN(pcie_err->device_id.device,
@@ -158,7 +172,7 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,if (!pdev)return ; -pci_print_aer (pdev, aer_severity, aer); +pci_print_aer (pdev, aer_severity, &aer_regs);pci_dev_put (pdev);#endif }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 235/2651 ACPI: extlog: Validate PCIe error section length before payload access
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 5eefd849e26506170552e614496d094230650e78 ]
extlog_print_pcie() reads pcie_err->validation_bits and device_id and copies the 96-byte aer_info buffer without checking that gdata->error_data_length is big enough for a struct cper_sec_pcie. The cper_estatus_check() call added earlier keeps the read inside the estatus block, but a short section still gets stale adjacent bytes treated as PCIe error data.
Reject a section too small to hold the record before touching any field, and warn: a truncated section means firmware is emitting malformed records.
--- drivers/acpi/acpi_extlog.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/acpi/acpi_extlog.c +9 -2
@@ -134,7 +134,7 @@ static int print_extlog_rcd(const char *pfx, }static void extlog_print_pcie (struct cper_sec_pcie *pcie_err, -int severity) +int severity,u32 len) {#ifdef ACPI_APEI_PCIEAER struct aer_capability_regs aer_regs = {};
@@ -144,6 +144,12 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,int aer_severity;int domain; +if (len <sizeof (*pcie_err)) { +pr_warn_ratelimited (FW_WARN +"PCIe error section too small (%u)\n" , len); +return ; + } +if (!(pcie_err->validation_bits &CPER_PCIE_VALID_DEVICE_ID && pcie_err->validation_bits &CPER_PCIE_VALID_AER_INFO ))return ;
@@ -263,7 +269,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val, }else if (guid_equal (sec_type, &CPER_SEC_PCIE )) {struct cper_sec_pcie *pcie_err =acpi_hest_get_payload (gdata); -extlog_print_pcie (pcie_err, gdata->error_severity); +extlog_print_pcie (pcie_err, gdata->error_severity, + gdata->error_data_length); }else {void *err =acpi_hest_get_payload (gdata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 236/2651 ACPI: extlog: Fix CONFIG_ACPI_APEI_PCIEAER guard typo
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 44a8d464d79b60883f7bd386049a1ffff32ca690 ]
The guard reads "#ifdef ACPI_APEI_PCIEAER" rather than "#ifdef CONFIG_ACPI_APEI_PCIEAER". That symbol is never defined, so the extlog PCIe AER handling is always compiled out.
Use the CONFIG_ prefixed symbol.
--- drivers/acpi/acpi_extlog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_extlog.c +1 -1
@@ -136,7 +136,7 @@ static int print_extlog_rcd(const char *pfx,static void extlog_print_pcie (struct cper_sec_pcie *pcie_err,int severity,u32 len) { -#ifdef ACPI_APEI_PCIEAER +#ifdef CONFIG_ACPI_APEI_PCIEAER struct aer_capability_regs aer_regs = {};struct pci_dev *pdev;unsigned int devfn;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 237/2651 ACPI: APEI: GHES: Bound CXL event record copy to the firmware section length
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit b7a4915a2b43d47f0bbb0b2a4c30e722fa0d3191 ]
cxl_cper_post_event() copies a fixed sizeof(struct cxl_cper_event_rec) out of the firmware CPER section without checking how long the section actually is, so a short one reads past the record.
Pass gdata->error_data_length in and reject a section too small to hold the record before the copy.
--- drivers/acpi/apei/ghes.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/acpi/apei/ghes.c +12 -4
@@ -823,10 +823,15 @@ static DEFINE_RAW_SPINLOCK(cxl_cper_work_lock);struct work_struct *cxl_cper_work;static void cxl_cper_post_event (enum cxl_event_type event_type, -struct cxl_cper_event_rec *rec) +struct cxl_cper_event_rec *rec,u32 len) {struct cxl_cper_work_data wd; +if (len <sizeof (*rec)) { +pr_err (FW_WARN "CXL CPER section too small (%u)\n" , len); +return ; + } +if (rec->hdr.length <=sizeof (rec->hdr) || rec->hdr.length >sizeof (*rec)) { pr_err(FW_WARN "CXL CPER Invalid section length (%u)\n",
@@ -963,15 +968,18 @@ static void ghes_do_proc(struct ghes *ghes, }else if (guid_equal (sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID )) {struct cxl_cper_event_rec *rec =acpi_hest_get_payload (gdata); -cxl_cper_post_event (CXL_CPER_EVENT_GEN_MEDIA , rec); +cxl_cper_post_event (CXL_CPER_EVENT_GEN_MEDIA , rec, + gdata->error_data_length); }else if (guid_equal (sec_type, &CPER_SEC_CXL_DRAM_GUID )) {struct cxl_cper_event_rec *rec =acpi_hest_get_payload (gdata); -cxl_cper_post_event (CXL_CPER_EVENT_DRAM , rec); +cxl_cper_post_event (CXL_CPER_EVENT_DRAM , rec, + gdata->error_data_length); }else if (guid_equal (sec_type, &CPER_SEC_CXL_MEM_MODULE_GUID )) {struct cxl_cper_event_rec *rec =acpi_hest_get_payload (gdata); -cxl_cper_post_event (CXL_CPER_EVENT_MEM_MODULE , rec); +cxl_cper_post_event (CXL_CPER_EVENT_MEM_MODULE , rec, + gdata->error_data_length); }else {void *err =acpi_hest_get_payload (gdata);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 238/2651 ACPI: extlog: Defer CXL protocol error handling to avoid lock inversion
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 179ef6d7f971d72a0f54b7c499daed1b244ee1a5 ]
extlog_print() calls cxl_cper_handle_prot_err() synchronously while the MCE notifier chain rwsem is held, and that path takes the PCI device_lock via guard(device)(). The probe path takes the two in the opposite order, holding device_lock while mce_register_decode_chain() takes the rwsem, so they can deadlock AB-BA.
ghes.c already avoids this by posting protocol errors to a kfifo and handling them from a workqueue via cxl_cper_post_prot_err(). Export that function and call it instead.
Declare it with the other CONFIG_ACPI_APEI_GHES exports rather than at the end of the header. No #else stub: ACPI_EXTLOG selects ACPI_APEI_GHES, so the only caller cannot exist without it.
Stable-dep-of: 8bf58815315a ("ACPI: APEI: GHES: Validate CXL protocol error section length before RAS cap copy")
--- drivers/acpi/acpi_extlog.c | 21 ++------------------- drivers/acpi/apei/ghes.c | 5 +++-- include/acpi/ghes.h | 4 ++++ 3 files changed, 9 insertions(+), 21 deletions(-)
drivers/acpi/acpi_extlog.c +2 -19
@@ -183,23 +183,6 @@ static void extlog_print_pcie(struct cper_sec_pcie *pcie_err,#endif } -static void -extlog_cxl_cper_handle_prot_err (struct cxl_cper_sec_prot_err *prot_err, -int severity) -{ -#ifdef ACPI_APEI_PCIEAER -struct cxl_cper_prot_err_work_data wd; - -if (cxl_cper_sec_prot_err_valid (prot_err)) -return ; - -if (cxl_cper_setup_prot_err_work_data (&wd, prot_err, severity)) -return ; - -cxl_cper_handle_prot_err (&wd); -#endif -} -static int extlog_print (struct notifier_block *nb,unsigned long val,void *data) {
@@ -264,8 +247,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,struct cxl_cper_sec_prot_err *prot_err =acpi_hest_get_payload (gdata); -extlog_cxl_cper_handle_prot_err (prot_err, - gdata->error_severity); +cxl_cper_post_prot_err (prot_err, + gdata->error_severity); }else if (guid_equal (sec_type, &CPER_SEC_PCIE )) {struct cper_sec_pcie *pcie_err =acpi_hest_get_payload (gdata);
drivers/acpi/apei/ghes.c +3 -2
@@ -752,8 +752,8 @@ static DEFINE_KFIFO(cxl_cper_prot_err_fifo, struct cxl_cper_prot_err_work_data,static DEFINE_RAW_SPINLOCK (cxl_cper_prot_err_work_lock);struct work_struct *cxl_cper_prot_err_work; -static void cxl_cper_post_prot_err (struct cxl_cper_sec_prot_err *prot_err, -int severity) +void cxl_cper_post_prot_err (struct cxl_cper_sec_prot_err *prot_err, +int severity) {#ifdef CONFIG_ACPI_APEI_PCIEAER struct cxl_cper_prot_err_work_data wd;
@@ -777,6 +777,7 @@ static void cxl_cper_post_prot_err(struct cxl_cper_sec_prot_err *prot_err,schedule_work (cxl_cper_prot_err_work);#endif } +EXPORT_SYMBOL_FOR_MODULES (cxl_cper_post_prot_err,"acpi_extlog" );void cxl_cper_register_prot_err_work (struct work_struct *work) {
include/acpi/ghes.h +4 -0
@@ -85,6 +85,10 @@ int devm_ghes_register_vendor_record_notifier(struct device *dev,struct list_head *ghes_get_devices (void );void ghes_estatus_pool_region_free (unsigned long addr,u32 size); + +struct cxl_cper_sec_prot_err ; +void cxl_cper_post_prot_err (struct cxl_cper_sec_prot_err *prot_err, +int severity);#else static inline struct list_head *ghes_get_devices (void ) {return NULL ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 239/2651 ACPI: APEI: GHES: Validate CXL protocol error section length before RAS cap copy
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 8bf58815315aeb60125d26404d6fa7d576d5d518 ]
cxl_cper_setup_prot_err_work_data() locates the RAS Capability block at prot_err + sizeof(*prot_err) + dvsec_len and copies it, but dvsec_len is firmware controlled and never validated, so it can point the copy outside the section.
Extend cxl_cper_sec_prot_err_valid() to check that the section can hold the header, and that the header, DVSEC and RAS Capability block together fit the reported section length.
--- drivers/acpi/acpi_extlog.c | 3 ++- drivers/acpi/apei/ghes.c | 7 ++++--- drivers/acpi/apei/ghes_helpers.c | 18 +++++++++++++++++- include/acpi/ghes.h | 2 +- include/cxl/event.h | 4 ++-- 5 files changed, 26 insertions(+), 8 deletions(-)
drivers/acpi/acpi_extlog.c +2 -1
@@ -248,7 +248,8 @@ static int extlog_print(struct notifier_block *nb, unsigned long val,acpi_hest_get_payload (gdata);cxl_cper_post_prot_err (prot_err, - gdata->error_severity); + gdata->error_severity, + gdata->error_data_length); }else if (guid_equal (sec_type, &CPER_SEC_PCIE )) {struct cper_sec_pcie *pcie_err =acpi_hest_get_payload (gdata);
drivers/acpi/apei/ghes.c +4 -3
@@ -753,12 +753,12 @@ static DEFINE_RAW_SPINLOCK(cxl_cper_prot_err_work_lock);struct work_struct *cxl_cper_prot_err_work;void cxl_cper_post_prot_err (struct cxl_cper_sec_prot_err *prot_err, -int severity) +int severity,u32 len) {#ifdef CONFIG_ACPI_APEI_PCIEAER struct cxl_cper_prot_err_work_data wd; -if (cxl_cper_sec_prot_err_valid (prot_err)) +if (cxl_cper_sec_prot_err_valid (prot_err, len))return ;guard (raw_spinlock_irqsave)(&cxl_cper_prot_err_work_lock);
@@ -965,7 +965,8 @@ static void ghes_do_proc(struct ghes *ghes, }else if (guid_equal (sec_type, &CPER_SEC_CXL_PROT_ERR )) {struct cxl_cper_sec_prot_err *prot_err =acpi_hest_get_payload (gdata); -cxl_cper_post_prot_err (prot_err, gdata->error_severity); +cxl_cper_post_prot_err (prot_err, gdata->error_severity, + gdata->error_data_length); }else if (guid_equal (sec_type, &CPER_SEC_CXL_GEN_MEDIA_GUID )) {struct cxl_cper_event_rec *rec =acpi_hest_get_payload (gdata);
drivers/acpi/apei/ghes_helpers.c +17 -1
@@ -5,8 +5,15 @@#include <linux/aer.h> #include <cxl/event.h> -int cxl_cper_sec_prot_err_valid (struct cxl_cper_sec_prot_err *prot_err) +int cxl_cper_sec_prot_err_valid (struct cxl_cper_sec_prot_err *prot_err,u32 len) { +if (len <sizeof (*prot_err)) { +pr_err_ratelimited (FW_WARN +"CXL CPER prot err section too small (%u)\n" , + len); +return -EINVAL ; + } +if (!(prot_err->valid_bits &PROT_ERR_VALID_AGENT_ADDRESS )) {pr_err_ratelimited ("CXL CPER invalid agent type\n" );return -EINVAL ;
@@ -23,6 +30,15 @@ int cxl_cper_sec_prot_err_valid(struct cxl_cper_sec_prot_err *prot_err)return -EINVAL ; } +/* The RAS Capability block sits after a firmware-sized DVSEC. */ +if (sizeof (*prot_err) + prot_err->dvsec_len + +sizeof (struct cxl_ras_capability_regs ) > len) { +pr_err_ratelimited (FW_WARN +"CXL CPER prot err DVSEC (%u) overruns section (%u)\n" , + prot_err->dvsec_len, len); +return -EINVAL ; + } +if ((prot_err->agent_type ==RCD || prot_err->agent_type ==DEVICE || prot_err->agent_type ==LD || prot_err->agent_type ==FMLD ) && !(prot_err->valid_bits &PROT_ERR_VALID_SERIAL_NUMBER ))
include/acpi/ghes.h +1 -1
@@ -88,7 +88,7 @@ void ghes_estatus_pool_region_free(unsigned long addr, u32 size);struct cxl_cper_sec_prot_err ;void cxl_cper_post_prot_err (struct cxl_cper_sec_prot_err *prot_err, -int severity); +int severity,u32 len);#else static inline struct list_head *ghes_get_devices (void ) {return NULL ; }
include/cxl/event.h +2 -2
@@ -312,13 +312,13 @@ static inline int cxl_cper_prot_err_kfifo_get(struct cxl_cper_prot_err_work_data#endif #ifdef CONFIG_ACPI_APEI_PCIEAER -int cxl_cper_sec_prot_err_valid (struct cxl_cper_sec_prot_err *prot_err); +int cxl_cper_sec_prot_err_valid (struct cxl_cper_sec_prot_err *prot_err,u32 len);int cxl_cper_setup_prot_err_work_data (struct cxl_cper_prot_err_work_data *wd,struct cxl_cper_sec_prot_err *prot_err,int severity);#else static inline int -cxl_cper_sec_prot_err_valid (struct cxl_cper_sec_prot_err *prot_err) +cxl_cper_sec_prot_err_valid (struct cxl_cper_sec_prot_err *prot_err,u32 len) {return -EOPNOTSUPP ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 240/2651 efi/cper: Read only validated fields in cper_mem_err_pack()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 92480a2b00a15b0add512b6fc474151ec5340a8e ]
cper_mem_err_pack() copies extended, rank, mem_array_handle and mem_dev_handle unconditionally. Those live at offsets 73 to 79, past the end of struct cper_sec_mem_err_old, the 73-byte UEFI 2.1/2.2 layout that older firmware still emits and that cper_estatus_print_section() admits. On such a record the copy reads up to seven bytes past the payload, and off the end of the error status block when that section is the last one.
Copy each of the four only when its validation bit is set, and zero it otherwise. Nothing is lost: a 2.1/2.2 record leaves those bits clear, and every consumer of struct cper_mem_err_compact already gates the fields on the same bits. Zeroing also stops callers reading them back out of the uninitialised on-stack struct they pass in.
--- drivers/firmware/efi/cper.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/firmware/efi/cper.c +22 -4
@@ -389,10 +389,28 @@ void cper_mem_err_pack(const struct cper_sec_mem_err *mem, cmem->requestor_id = mem->requestor_id; cmem->responder_id = mem->responder_id; cmem->target_id = mem->target_id; - cmem->extended = mem->extended; - cmem->rank = mem->rank; - cmem->mem_array_handle = mem->mem_array_handle; - cmem->mem_dev_handle = mem->mem_dev_handle; + +/* +* These four sit past the end of the UEFI 2.1/2.2 layout, which older +* firmware still emits, so reading them unconditionally runs off a +* short record. Every consumer of the compact record gates them on the +* same validation bits, so leave them zero when firmware does not +* claim them. +*/ + cmem->extended =0 ; + cmem->rank =0 ; + cmem->mem_array_handle =0 ; + cmem->mem_dev_handle =0 ; + +if (mem->validation_bits & + (CPER_MEM_VALID_ROW_EXT |CPER_MEM_VALID_CHIP_ID )) + cmem->extended = mem->extended; +if (mem->validation_bits &CPER_MEM_VALID_RANK_NUMBER ) + cmem->rank = mem->rank; +if (mem->validation_bits &CPER_MEM_VALID_CARD_HANDLE ) + cmem->mem_array_handle = mem->mem_array_handle; +if (mem->validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) + cmem->mem_dev_handle = mem->mem_dev_handle; }EXPORT_SYMBOL_GPL (cper_mem_err_pack);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 241/2651 ACPI: APEI: GHES: Validate memory error section length before payload access
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 10338c9085b4939a428a8dc78d2bbf62c161278b ]
ghes_do_proc() hands the CPER_SEC_PLATFORM_MEM payload to the report chain, arch_apei_report_mem_error() and ghes_handle_memory_failure() without checking gdata->error_data_length. All three read validation_bits and physical_addr, at offsets 0 and 16, so a shorter section reads past the record.
Check the length once in ghes_do_proc(), before any consumer runs. Take the 73-byte struct cper_sec_mem_err_old as the floor: older firmware legitimately emits that UEFI 2.1/2.2 layout, and it makes validation_bits safe to read.
The fields from "extended" on are absent from that layout, so also require whatever length the validation bits claim. Derive it per field rather than demanding the full 80 bytes: rank needs only 76, and the BANK_GROUP and BANK_ADDRESS bits describe "bank" at offset 38, which every record carries. Testing the whole mask against one size, as cper_print_mem() does, gets it wrong both ways.
--- drivers/acpi/apei/ghes.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
drivers/acpi/apei/ghes.c +41 -0
@@ -929,6 +929,28 @@ static void ghes_log_hwerr(int sev, guid_t *sec_type)hwerr_log_error_type (HWERR_RECOV_OTHERS ); } +/* +* The fields from "extended" on are absent from the 73-byte UEFI 2.1/2.2 +* layout that older firmware still emits. Return the length needed for the +* fields the validation bits claim, so over-claiming is rejected without +* rejecting an honest short record. +*/ +static u32 ghes_mem_err_min_len (u64 validation_bits) +{ +u32 len =sizeof (struct cper_sec_mem_err_old ); + +if (validation_bits & (CPER_MEM_VALID_ROW_EXT |CPER_MEM_VALID_CHIP_ID )) + len = offsetof(struct cper_sec_mem_err , rank); +if (validation_bits &CPER_MEM_VALID_RANK_NUMBER ) + len = offsetof(struct cper_sec_mem_err , mem_array_handle); +if (validation_bits &CPER_MEM_VALID_CARD_HANDLE ) + len = offsetof(struct cper_sec_mem_err , mem_dev_handle); +if (validation_bits &CPER_MEM_VALID_MODULE_HANDLE ) + len =sizeof (struct cper_sec_mem_err ); + +return len; +} +static void ghes_do_proc (struct ghes *ghes,const struct acpi_hest_generic_status *estatus) {
@@ -954,6 +976,25 @@ static void ghes_do_proc(struct ghes *ghes,if (guid_equal (sec_type, &CPER_SEC_PLATFORM_MEM )) {struct cper_sec_mem_err *mem_err =acpi_hest_get_payload (gdata); +/* +* Check once for all three consumers below. The 73-byte +* UEFI 2.1/2.2 layout is the floor, matching +* cper_estatus_print_section() and making +* validation_bits safe to read. +*/ +if (gdata->error_data_length < +sizeof (struct cper_sec_mem_err_old )) +continue ; + +/* Then require what the claimed fields actually need. */ +if (gdata->error_data_length < +ghes_mem_err_min_len (mem_err->validation_bits)) { + pr_warn_ratelimited(FW_WARN GHES_PFX +"memory error section too small (%u) for the fields it claims\n" , + gdata->error_data_length); +continue ; + } +atomic_notifier_call_chain (&ghes_report_chain, sev, mem_err);arch_apei_report_mem_error (sev, mem_err);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 242/2651 ACPI: APEI: GHES: Bound AER info copy and sanitize software metadata
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 9c3ad3bfff20d2d7a0c9614db2a58e78123bf0ce ]
ghes_handle_aer() copies sizeof(struct aer_capability_regs) out of the fixed 96-byte pcie_err->aer_info. The struct is larger, so the copy reads past the section, and it fills the software-only header_len and flit fields of the embedded struct pcie_tlp_log from firmware bytes. pcie_print_tlp_log() uses both to bound a loop over dw[], so a large value walks past the array. Nothing checks the section can hold a struct cper_sec_pcie either.
Validate error_data_length, zero the destination, and map aer_info onto the struct as extlog_print_pcie() does: copy up to the four Header Log DWORDs, then place the TLP Prefix Log from its own offset. The rest stays zero, covering header_len and flit.
--- drivers/acpi/apei/ghes.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
drivers/acpi/apei/ghes.c +20 -5
@@ -642,11 +642,14 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)#ifdef CONFIG_ACPI_APEI_PCIEAER struct cper_sec_pcie *pcie_err =acpi_hest_get_payload (gdata); +if (gdata->error_data_length <sizeof (*pcie_err)) +return ; +if (pcie_err->validation_bits &CPER_PCIE_VALID_DEVICE_ID && pcie_err->validation_bits &CPER_PCIE_VALID_AER_INFO ) { +struct aer_capability_regs *aer_info;unsigned int devfn;int aer_severity; -u8 *aer_info; devfn =PCI_DEVFN (pcie_err->device_id.device, pcie_err->device_id.function);
@@ -664,13 +667,25 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata) sizeof(struct aer_capability_regs));if (!aer_info)return ; -memcpy (aer_info, pcie_err->aer_info,sizeof (struct aer_capability_regs )); + +/* +* Map aer_info onto the struct as extlog_print_pcie() does: +* copy up to the four Header Log DWORDs, then place the TLP +* Prefix Log from where the hardware keeps it. The rest stays +* zero, so firmware cannot drive the pcie_print_tlp_log() loop +* over dw[] out of bounds. +*/ +memset (aer_info,0 ,sizeof (struct aer_capability_regs )); +memcpy (aer_info, pcie_err->aer_info, + offsetof(struct aer_capability_regs , header_log) + +PCIE_STD_NUM_TLP_HEADERLOG *sizeof (u32)); +memcpy (aer_info->header_log.prefix, + pcie_err->aer_info +PCI_ERR_PREFIX_LOG , +sizeof (aer_info->header_log.prefix));aer_recover_queue (pcie_err->device_id.segment, pcie_err->device_id.bus, - devfn, aer_severity, - (struct aer_capability_regs *) - aer_info); + devfn, aer_severity, aer_info); }#endif }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 243/2651 spi: mtk-nor: fix runtime PM usage count leak in probe error path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 4cee1ed13e2687f1a9fec7dd50e31eb179506d75 ]
mtk_nor_probe() takes a runtime PM reference with pm_runtime_get_noresume() before registering the controller, but the error path never drops it.
Balance the get with pm_runtime_put_noidle() in the error path.
--- drivers/spi/spi-mtk-nor.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-mtk-nor.c +1 -0
@@ -929,6 +929,7 @@ static int mtk_nor_probe(struct platform_device *pdev)return 0 ; err_probe: +pm_runtime_put_noidle (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);pm_runtime_dont_use_autosuspend (&pdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 244/2651 remoteproc: imx_rproc: Allow mappings ending at region boundary
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Marcel Hofmann <[email protected]>
[ Upstream commit 749eed0c7178c8d53ce4c9acdda4a545721c494b ]
The address range checks in imx_rproc_da_to_sys() and imx_rproc_da_to_va() use a strict comparison for the exclusive end address of the requested range.
As a result, a valid request that ends exactly at the end of an address translation or mapped memory region is rejected. For a region [start, start + size), a request [addr, addr + len) is contained when:
addr >= start && addr + len <= start + size
This occurs when a loadable ELF segment fills an entire mapped memory region. This can be produced by a linker script that extends the resource table section to the end of its designated region:
.resource_table :
{
. = ALIGN(8);
KEEP(*(.resource_table)) /* Resource table */
. = ALIGN(8);
. = ORIGIN(m_rsc_tbl) + LENGTH(m_rsc_tbl);
} > m_rsc_tbl =0x00This produces a ELF program header like:
LOAD 0x010000 0xa4220000 0xa4220000 0x01000 0x01000 R 0x1000
In this case, the segment size matches the mapped region size exactly, causing the address translation to fail with:
bad phdr da 0xa4220000 mem 0x1000
Rework the upper-bound checks to allow ranges ending exactly at the region boundary while guarding against integer overflow.
--- drivers/remoteproc/imx_rproc.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/remoteproc/imx_rproc.c +13 -5
@@ -540,6 +540,7 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,/* parse address translation table */ for (i =0 ; i < dcfg->att_size; i++) {const struct imx_rproc_att *att = &dcfg->att[i]; +u64 offset;/* * Ignore entries not belong to current core:
@@ -552,9 +553,11 @@ static int imx_rproc_da_to_sys(struct imx_rproc *priv, u64 da,continue ; } -if (da >= att->da && da + len < att->da + att->size) { -unsigned int offset = da - att->da; +if (da < att->da) +continue ; + offset = da - att->da; +if (offset <= att->size && len <= att->size - offset) { *sys = att->sa + offset;if (is_iomem) *is_iomem = att->flags &ATT_IOMEM ;
@@ -585,9 +588,14 @@ static void *imx_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *ireturn NULL ;for (i =0 ; i <IMX_RPROC_MEM_MAX ; i++) { -if (sys >= priv->mem[i].sys_addr && sys + len < - priv->mem[i].sys_addr + priv->mem[i].size) { -unsigned int offset = sys - priv->mem[i].sys_addr; +u64 offset; + +if (sys < priv->mem[i].sys_addr) +continue ; + + offset = sys - priv->mem[i].sys_addr; +if (offset <= priv->mem[i].size && + len <= priv->mem[i].size - offset) {/* __force to make sparse happy with type conversion */ va = (__force void *)(priv->mem[i].cpu_addr + offset);break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 245/2651 perf trace: Fix error checking in btf_struct_scnprintf()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 02241f791aa28802cc05223a740e163e14cd5ea2 ]
btf_dump__dump_type_data() returns the positive number of bytes dumped on success, or a negative error code (e.g., -EINVAL) on failure.
Currently, btf_struct_scnprintf() checks if btf_dump__dump_type_data() returns 0. When a negative error code is returned on failure, this check evaluates to false, causing the function to proceed down the success path and advance arg->augmented.args past the unprinted struct data before returning 0.
Consequently, when syscall__scnprintf_args() falls back to the default argument beautifier upon receiving 0 from trace__btf_scnprintf(), the fallback beautifier or subsequent arguments read from an erroneously advanced augmented arguments buffer.
Fix this by checking for '<= 0' ensuring that on any failure or 0-byte dump, 0 is returned without modifying the augmented arguments pointer.
--- tools/perf/builtin-trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
@@ -1066,7 +1066,7 @@ static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf,return 0 ;/* pretty print the struct data here */ -if (btf_dump__dump_type_data (btf_dump, type_id, arg->augmented.args->value, type->size, &dump_data_opts) ==0 ) +if (btf_dump__dump_type_data (btf_dump, type_id, arg->augmented.args->value, type->size, &dump_data_opts) <=0 )return 0 ; consumed =sizeof (*augmented_arg) + augmented_arg->size;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 246/2651 perf evsel: Validate branch stack before byte swapping
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Amirkan <[email protected]>
[ Upstream commit 2148e094671b0f6a44f033787b7da4ed14e96c27 ]
When perf reads an opposite-endian branch stack, __evsel__parse_sample() swaps each entry before checking whether all entries fit in the event. A truncated sample can therefore make the swap loop read and write past the event boundary.
A truncated perf.data file makes perf report crash with SIGSEGV. ASan reports an out-of-bounds read. A regression test puts an entry just past the declared end and shows that its flags are changed before the parser returns -EFAULT.
Move the bounds check before the byte-swap loop. Valid samples are handled as before.
--- tools/perf/tests/sample-parsing.c | 48 +++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 3 +- 2 files changed, 50 insertions(+), 1 deletion(-)
tools/perf/tests/sample-parsing.c +48 -0
@@ -1,5 +1,6 @@// SPDX-License-Identifier: GPL-2.0 #include <stdbool.h> +#include <errno.h> #include <inttypes.h> #include <stdlib.h> #include <string.h>
@@ -417,6 +418,49 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)return ret; } +static int test_truncated_branch_stack (void ) +{ +struct perf_event_attr attr = { + .sample_type =PERF_SAMPLE_BRANCH_STACK , + }; +struct { +struct perf_event_header header; +u64 nr; +struct branch_entry entry; + } input = { + .header = { + .type =PERF_RECORD_SAMPLE , + .size =sizeof (input.header) +sizeof (input.nr), + }, + .nr =1 , + }; +struct perf_sample sample; +struct evsel *evsel; +u64 flags =1 ; +int err; + + input.entry.flags.value = flags; + evsel =evsel__new (&attr); +if (!evsel) +return -1 ; + + evsel->sample_size =__evsel__sample_size (attr.sample_type); + err =__evsel__parse_sample (evsel, (union perf_event *)&input, + &sample,/*needs_swap=*/ true); +perf_sample__exit (&sample); +evsel__put (evsel); + +if (err != -EFAULT ) { +pr_debug ("truncated branch stack returned %d, expected -EFAULT\n" , err); +return -1 ; + } +if (input.entry.flags.value != flags) { +pr_debug ("truncated branch stack modified data past the event\n" ); +return -1 ; + } +return 0 ; +} +/** * test__sample_parsing - test sample parsing. *
@@ -433,6 +477,10 @@ static int test__sample_parsing(struct test_suite *test __maybe_unused, int subtsize_t i;int err; + err =test_truncated_branch_stack (); +if (err) +return err; +/* * Fail the test if it has not been updated when new sample format bits * were added. Please actually update the test rather than just change
tools/perf/util/evsel.c +2 -1
@@ -3651,6 +3651,8 @@ int __evsel__parse_sample(struct evsel *evsel, union perf_event *event, e = (struct branch_entry *)&data->branch_stack->hw_idx; } +OVERFLOW_CHECK (array, sz, max_size); +if (swapped) {/* * struct branch_flag does not have endian
@@ -3666,7 +3668,6 @@ int __evsel__parse_sample(struct evsel *evsel, union perf_event *event, e->flags.value =evsel__bitfield_swap_branch_flags (e->flags.value); } -OVERFLOW_CHECK (array, sz, max_size); array = (void *)array + sz;if (evsel__has_branch_counters (evsel)) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 247/2651 perf evsel: Validate RAW sample before byte swapping
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Amirkan <[email protected]>
[ Upstream commit 02f6847e1822714a4201b87e42f92b0d43e8549d ]
For an opposite-endian RAW sample, __evsel__parse_sample() passes the input-controlled size to mem_bswap_64() before checking whether the payload fits in the event. A truncated record can therefore make the helper read and write past the event boundary.
A crafted perf.data file makes perf report crash with SIGSEGV. ASan reports the out-of-bounds access. A regression test puts backed data past the declared end and shows that it is changed before the parser returns -EFAULT.
Move the bounds checks before mem_bswap_64(). Check the rounded length too, because the helper accesses complete 64-bit words. Complete records are handled as before.
--- tools/perf/tests/sample-parsing.c | 61 +++++++++++++++++++++++++++++++ tools/perf/util/evsel.c | 17 +++++---- 2 files changed, 70 insertions(+), 8 deletions(-)
tools/perf/tests/sample-parsing.c +61 -0
@@ -461,6 +461,55 @@ static int test_truncated_branch_stack(void)return 0 ; } +static int test_truncated_swapped_raw (u16 event_size,u32 raw_size) +{ +struct perf_event_attr attr = { + .sample_type =PERF_SAMPLE_RAW , + }; +struct { +struct perf_event_header header; +union { +u64 value; +u32 words[2 ]; + } raw; +u64 canary; + } input = { + .header = { + .type =PERF_RECORD_SAMPLE , + .size = event_size, + }, +/* Parsing a pre-swapped word exchanges these two u32 values. */ + .raw.words = {0x12345678 , raw_size }, + .canary =0x8877665544332211ULL , + }; +struct perf_sample sample; +struct evsel *evsel; +u64 raw = input.raw.value; +u64 canary = input.canary; +int err; + + evsel =evsel__new (&attr); +if (!evsel) +return -1 ; + + evsel->sample_size =__evsel__sample_size (attr.sample_type); + err =__evsel__parse_sample (evsel, (union perf_event *)&input, + &sample,/*needs_swap=*/ true); +perf_sample__exit (&sample); +evsel__put (evsel); + +if (err != -EFAULT ) { +pr_debug ("truncated swapped RAW sample (size %u, raw %u) returned %d, expected -EFAULT\n" , + event_size, raw_size, err); +return -1 ; + } +if (input.raw.value != raw || input.canary != canary) { +pr_debug ("truncated swapped RAW sample modified data before validation\n" ); +return -1 ; + } +return 0 ; +} +/** * test__sample_parsing - test sample parsing. *
@@ -481,6 +530,18 @@ static int test__sample_parsing(struct test_suite *test __maybe_unused, int subtif (err)return err; +/* The declared RAW payload extends past an otherwise aligned event. */ + err =test_truncated_swapped_raw (sizeof (struct perf_event_header ) + +sizeof (u64),16 ); +if (err) +return err; + +/* The final complete word touched by mem_bswap_64() extends past it. */ + err =test_truncated_swapped_raw (sizeof (struct perf_event_header ) + +sizeof (u32) +9 ,9 ); +if (err) +return err; +/* * Fail the test if it has not been updated when new sample format bits * were added. Please actually update the test rather than just change
tools/perf/util/evsel.c +9 -8
@@ -3596,7 +3596,10 @@ int __evsel__parse_sample(struct evsel *evsel, union perf_event *event, }if (type &PERF_SAMPLE_RAW ) { +const __u64 *raw; +OVERFLOW_CHECK_u64 (array); + raw = array; u.val64 = *array;/*
@@ -3612,16 +3615,14 @@ int __evsel__parse_sample(struct evsel *evsel, union perf_event *event, } data->raw_size = u.val32[0 ]; -/* -* The raw data is aligned on 64bits including the -* u32 size, so it's safe to use mem_bswap_64. -*/ -if (swapped) -mem_bswap_64 ((void *) array, data->raw_size); - array = (void *)array +sizeof (u32); -OVERFLOW_CHECK (array, data->raw_size, max_size); +if (swapped) { +/* mem_bswap_64() accesses complete 64-bit words. */ + sz =roundup ((u64 )data->raw_size,sizeof (u64)); +OVERFLOW_CHECK (raw, sz, max_size); +mem_bswap_64 ((void *)raw, data->raw_size); + } data->raw_data = (void *)array; array = (void *)array + data->raw_size; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 248/2651 RDMA/nldev: Put the device when dellink fails
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li RongQing <[email protected]>
[ Upstream commit 0ff7fcd6aac16dd149ad322687a10c8ea7d806b2 ]
nldev_dellink() takes a device reference through ib_device_get_by_index() and normally hands it over to ib_unregister_device_and_put(). The error path of the ->dellink callback returns without releasing it, so the reference is leaked.
Once that happens, any later unregistration of the device blocks forever, because disable_device() drops its own reference and then waits for the refcount to drain. No in-tree driver returns an error from ->dellink today, so the leak is currently latent.
Put the device before returning the error.
--- drivers/infiniband/core/nldev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/core/nldev.c +3 -1
@@ -1895,8 +1895,10 @@ static int nldev_dellink(struct sk_buff *skb, struct nlmsghdr *nlh,mutex_lock (&nldev_dellink_mutex); err = device->link_ops->dellink (device);mutex_unlock (&nldev_dellink_mutex); -if (err) +if (err) { +ib_device_put (device);return err; + } }ib_unregister_device_and_put (device);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 249/2651 RDMA/irdma: Preserve fast-registration IOVA on 32-bit
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit c470050f2a7a7748ce35367e828885a8e658d712 ]
ib_mr::iova is u64, but the fast-registration path passes it through void * and uintptr_t. These conversions truncate the upper 32 bits on 32-bit kernels before the WQE is built.
Store the IOVA as u64 and write it directly to the WQE. The sole caller always uses VA-based addressing, so remove the unused FBO selection and set the VA-based bit unconditionally.
--- drivers/infiniband/hw/irdma/ctrl.c | 6 ++---- drivers/infiniband/hw/irdma/type.h | 4 +--- drivers/infiniband/hw/irdma/verbs.c | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-)
drivers/infiniband/hw/irdma/ctrl.c +2 -4
@@ -1723,9 +1723,7 @@ int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp, info->wr_id, wqe_idx, &qp->qp_uk.sq_wrtrk_array[wqe_idx].wrid); - temp = (info->addr_type ==IRDMA_ADDR_TYPE_VA_BASED ) ? - (uintptr_t )info->va : info->fbo; -set_64bit_val (wqe,0 , temp); +set_64bit_val (wqe,0 , info->va); temp =FIELD_GET (IRDMAQPSQ_FIRSTPMPBLIDXHI , info->first_pm_pbl_index >>16 );
@@ -1742,7 +1740,7 @@ int irdma_sc_mr_fast_register(struct irdma_sc_qp *qp,FIELD_PREP (IRDMAQPSQ_LPBLSIZE , info->chunk_size) |FIELD_PREP (IRDMAQPSQ_HPAGESIZE , page_size) |FIELD_PREP (IRDMAQPSQ_STAGRIGHTS , info->access_rights) | -FIELD_PREP (IRDMAQPSQ_VABASEDTO , info->addr_type) | +IRDMAQPSQ_VABASEDTO |FIELD_PREP (IRDMAQPSQ_READFENCE , info->read_fence) |FIELD_PREP (IRDMAQPSQ_LOCALFENCE , info->local_fence) | FIELD_PREP(IRDMAQPSQ_SIGCOMPL, info->signaled) |
drivers/infiniband/hw/irdma/type.h +1 -3
@@ -1173,13 +1173,11 @@ struct irdma_reg_ns_stag_info {struct irdma_fast_reg_stag_info {u64 wr_id;u64 reg_addr_pa; -u64 fbo; -void *va; +u64 va;u64 total_len;u32 page_size;u32 chunk_size;u32 first_pm_pbl_index; -enum irdma_addressing_type addr_type;irdma_stag_index stag_idx;u16 access_rights;u32 pd_id;
drivers/infiniband/hw/irdma/verbs.c +1 -2
@@ -4276,8 +4276,7 @@ static int irdma_post_send(struct ib_qp *ibqp, stag_info.stag_idx =reg_wr (ib_wr)->key >>8 ; stag_info.page_size =reg_wr (ib_wr)->mr->page_size; stag_info.wr_id = ib_wr->wr_id; - stag_info.addr_type =IRDMA_ADDR_TYPE_VA_BASED ; - stag_info.va = (void *)(uintptr_t )iwmr->ibmr.iova; + stag_info.va = iwmr->ibmr.iova; stag_info.total_len = iwmr->ibmr.length; stag_info.reg_addr_pa = *palloc->level1.addr; stag_info.first_pm_pbl_index = palloc->level1.idx;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 250/2651 gpio: crystalcove: add missing MODULE_ALIAS()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
[ Upstream commit 32c7f7f80e5f7f2764682fd456054478fc11c8d9 ]
The crystalcove GPIO driver lacks a MODULE_ALIAS() to allow it to be auto-loaded.
Fix this by adding the missing platform alias.
--- drivers/gpio/gpio-crystalcove.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpio/gpio-crystalcove.c +1 -0
@@ -396,3 +396,4 @@ module_platform_driver(crystalcove_gpio_driver);MODULE_AUTHOR ("Yang, Bin <[email protected]>" );MODULE_DESCRIPTION ("Intel Crystal Cove GPIO Driver" );MODULE_LICENSE ("GPL v2" ); +MODULE_ALIAS ("platform:crystal_cove_gpio" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 251/2651 ABI: sysfs-class-infiniband: Drop the entries of the removed qib driver
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 63367df6e7255067ad6a83abe0d2799dfa491876 ]
Commit 24baad32b710 ("RDMA/qib: Remove outdated driver") removed the qib driver but left its /sys/class/infiniband/qibX/* entries in the stable ABI file. Nothing creates those files any more.
Remove the block.
--- .../ABI/stable/sysfs-class-infiniband | 118 ------------------ 1 file changed, 118 deletions(-)
Documentation/ABI/stable/sysfs-class-infiniband +0 -118
@@ -422,124 +422,6 @@ Description: information) =============== ============================================= - -sysfs interface for Intel IB driver qib ---------------------------------------- - -What: /sys/class/infiniband/qibX/version -What: /sys/class/infiniband/qibX/hw_rev -What: /sys/class/infiniband/qibX/hca_type -What: /sys/class/infiniband/qibX/board_id -What: /sys/class/infiniband/qibX/boardversion -What: /sys/class/infiniband/qibX/nctxts -What: /sys/class/infiniband/qibX/localbus_info -What: /sys/class/infiniband/qibX/tempsense -What: /sys/class/infiniband/qibX/serial -What: /sys/class/infiniband/qibX/nfreectxts -What: /sys/class/infiniband/qibX/chip_reset -Date: May, 2010 -KernelVersion: v2.6.35 -Contact: [email protected] -Description: - =============== ====================================================== - version: (RO) Display version information of installed software - and drivers. - - hw_rev: (RO) Hardware revision number - - hca_type: (RO) Host channel adapter type - - board_id: (RO) Manufacturing board id - - boardversion: (RO) Current version of the chip architecture - - nctxts: (RO) Return the number of user ports (contexts) - available - - localbus_info: (RO) Human readable localbus info - - tempsense: (RO) Display temp sense registers in decimal - - serial: (RO) Serial number of the HCA - - nfreectxts: (RO) The number of free user ports (contexts) - available. - - chip_reset: (WO) Reset the chip if possible by writing - "reset" to this file. Only allowed if no user - contexts are open that use chip resources. - =============== ====================================================== - - -What: /sys/class/infiniband/qibX/ports/<N>/sl2vl/[0-15] -Date: May, 2010 -KernelVersion: v2.6.35 -Contact: [email protected] -Description: - (RO) The directory contains 16 files numbered 0-15 that specify - the Service Level (SL). Listing the SL files returns the Virtual - Lane (VL) as programmed by the SL. - -What: /sys/class/infiniband/qibX/ports/<N>/CCMgtA/cc_settings_bin -What: /sys/class/infiniband/qibX/ports/<N>/CCMgtA/cc_table_bin -Date: May, 2010 -KernelVersion: v2.6.35 -Contact: [email protected] -Description: - Per-port congestion control. Both are binary attributes. - - =============== ================================================ - cc_table_bin (RO) Congestion control table size followed by - table entries. - - cc_settings_bin (RO) Congestion settings: port control, control - map and an array of 16 entries for the - congestion entries - increase, timer, event log - trigger threshold and the minimum injection rate - delay. - =============== ================================================ - -What: /sys/class/infiniband/qibX/ports/<N>/linkstate/loopback -What: /sys/class/infiniband/qibX/ports/<N>/linkstate/led_override -What: /sys/class/infiniband/qibX/ports/<N>/linkstate/hrtbt_enable -What: /sys/class/infiniband/qibX/ports/<N>/linkstate/status -What: /sys/class/infiniband/qibX/ports/<N>/linkstate/status_str -Date: May, 2010 -KernelVersion: v2.6.35 -Contact: [email protected] -Description: - [to be documented] - - =============== =============================================== - loopback: (WO) - led_override: (WO) - hrtbt_enable: (RW) - status: (RO) - - status_str: (RO) Displays information about the link state, - possible cable/switch problems, and hardware - errors. Possible states are- "Initted", - "Present", "IB_link_up", "IB_configured" or - "Fatal_Hardware_Error". - =============== =============================================== - -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/rc_resends -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/seq_naks -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/rdma_seq -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/rnr_naks -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/other_naks -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/rc_timeouts -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/look_pkts -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/pkt_drops -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/dma_wait -What: /sys/class/infiniband/qibX/ports/<N>/diag_counters/unaligned -Date: May, 2010 -KernelVersion: v2.6.35 -Contact: [email protected] -Description: - [to be documented] - - sysfs interface for Mellanox Connect-IB HCA driver mlx5 -------------------------------------------------------
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 252/2651 riscv: dts: spacemit: k3: Drop guest properties from M-level IMSIC
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junhui Liu <[email protected]>
[ Upstream commit 01e2f07c44fc46180bdb10e70506f8acf44a53dd ]
The mimsic node describes the machine-level IMSIC, whose MMIO region is 0x10000 (64 KiB) for all 8 harts. However, the node also specifies riscv,guest-index-bits = <6>, and per the AIA specification the per-hart stride is 2^(guest-index-bits + 12) bytes when guest interrupt files exist, i.e. 2^(6 + 12) = 256 KiB per hart and 2 MiB for all 8 harts. The described region cannot hold even a single hart's files, so the node contradicts itself. OpenSBI enforces exactly this constraint in imsic_data_check() and rejects the node with -EINVAL, preventing the M-level IMSIC from initializing:
fdt_driver_init_by_offset: interrupt-controller@f1000000 (riscv,imsics) init failed: -3
init_coldboot: irqchip init failed (error -3)
Moreover, guest interrupt files exist to act as the supervisor-level interrupt files of virtual harts; there is no machine-level counterpart. riscv,num-guest-ids is equally meaningless for the machine-level IMSIC.
Drop both "riscv,guest-index-bits" and "riscv,num-guest-ids" properties from the mimsic node so the node matches the actual hardware layout.
--- arch/riscv/boot/dts/spacemit/k3.dtsi | 2 -- 1 file changed, 2 deletions(-)
arch/riscv/boot/dts/spacemit/k3.dtsi +0 -2
@@ -1287,9 +1287,7 @@ mimsic: interrupt-controller@f1000000 { <&cpu4_intc 11>, <&cpu5_intc 11>, <&cpu6_intc 11>, <&cpu7_intc 11>; msi-controller; - riscv,guest-index-bits = <6>; riscv,hart-index-bits = <4>; - riscv,num-guest-ids = <511>; riscv,num-ids = <511>; status = "reserved"; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 253/2651 pwm: loongson: Reload PWM configuration through counter reset
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keguang Zhang <[email protected]>
[ Upstream commit 0de9b836a3bc1cd30578ae2c4463d09afd85ed3d ]
The Loongson PWM controller latches the LOW and PERIOD registers only at the start of each PWM period. After disabling and re-enabling the PWM, the controller resumes from the previous counter value and completes the current period before re-latching the updated LOW and PERIOD values.
Reset the PWM counter when disabling the PWM and release it when enabling the PWM so that the updated LOW and PERIOD values are latched before the PWM starts running again.
[ukleinek: Note LOW refers to the register currently named LOONGSON_PWM_REG_DUTY. That name is wrong, the fix is still under discussion.]
--- drivers/pwm/pwm-loongson.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pwm/pwm-loongson.c +2 -0
@@ -99,6 +99,7 @@ static void pwm_loongson_disable(struct pwm_chip *chip, struct pwm_device *pwm)struct pwm_loongson_ddata *ddata =to_pwm_loongson_ddata (chip); val =pwm_loongson_readl (ddata,LOONGSON_PWM_REG_CTRL ); + val |=LOONGSON_PWM_CTRL_REG_RST ; val &= ~LOONGSON_PWM_CTRL_REG_EN ;pwm_loongson_writel (ddata, val,LOONGSON_PWM_REG_CTRL ); }
@@ -109,6 +110,7 @@ static int pwm_loongson_enable(struct pwm_chip *chip, struct pwm_device *pwm)struct pwm_loongson_ddata *ddata =to_pwm_loongson_ddata (chip); val =pwm_loongson_readl (ddata,LOONGSON_PWM_REG_CTRL ); + val &= ~LOONGSON_PWM_CTRL_REG_RST ; val |=LOONGSON_PWM_CTRL_REG_EN ;pwm_loongson_writel (ddata, val,LOONGSON_PWM_REG_CTRL );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 254/2651 pwm: ipq: Prevent potential 32-bit integer overflow in hi_div calculation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Surendra Singh Chouhan <[email protected]>
[ Upstream commit a662d944da1e9236a99355aa3e8a93735d8b3521 ]
In ipq_pwm_get_state(), hi_div was calculated as:
hi_div = hi_dur * (pre_div + 1);
hi_dur and (pre_div + 1) are both unsigned int (32-bit) values. Evaluating their multiplication using 32-bit arithmetic before assigning to the 64-bit u64 hi_div variable can overflow 32-bit unsigned math.
While effective_div explicitly uses (u64)(pwm_div + 1) * (pre_div + 1) to prevent overflow, hi_div was missing the (u64) cast.
Fix this by casting hi_dur to (u64) before multiplication, matching the precision used for effective_div.
--- drivers/pwm/pwm-ipq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pwm/pwm-ipq.c +1 -1
@@ -186,7 +186,7 @@ static int ipq_pwm_get_state(struct pwm_chip *chip, struct pwm_device *pwm, state->period =DIV64_U64_ROUND_UP (effective_div *NSEC_PER_SEC , ipq_chip->clk_rate); - hi_div = hi_dur * (pre_div +1 ); + hi_div = (u64 )hi_dur * (pre_div +1 ); state->duty_cycle =DIV64_U64_ROUND_UP (hi_div *NSEC_PER_SEC , ipq_chip->clk_rate);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 255/2651 drm/xe: Guard page-fault worker with runtime PM check
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Varun Gupta <[email protected]>
[ Upstream commit fcc2431d2213dc4d04250c4f1ae87d9c3ae0d455 ]
During VM teardown, the VM's runtime PM reference is dropped asynchronously, allowing the device to autosuspend while stale page faults belonging to the now-dead VM are still queued. When the page-fault worker later tries to ack one of these, it calls into guc_ct_send_locked() on an already-suspended device, tripping:
Assertion !xe_pm_runtime_suspended(xe) failed!
WARNING at xe_device.c:1267 xe_device_assert_mem_access+0x11c/0x140 [xe]
A live VM/exec queue always holds a PM reference while it has outstanding work, so if the device is suspended at ack time, the owning context is already gone and the fault is stale.
Take a runtime PM reference across the entire pagefault queue worker to safely deliver acks for torn-down VMs.
v3:
- Move PM ref to the generic xe_pagefault_queue_work using guard(xe_pm_runtime)(xe) instead of tracking it in the GuC backend(Matt Brost).
v2:
- Hold PM ref across the entire batch (begin/end) instead of per-ack. This prevents the device from autosuspending mid-batch, which would leave write_only acks written but the end flush skipped, and skip counter++, desyncing the cadence check.(Himal)
- Add a comment explaining stale faults.(Himal)
--- drivers/gpu/drm/xe/xe_pagefault.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/gpu/drm/xe/xe_pagefault.c +7 -0
@@ -304,6 +304,13 @@ static void xe_pagefault_queue_work(struct work_struct *w)*/ guard (xe_pm_runtime)(xe); +/* +* A live VM holds a PM reference, but a torn-down VM does not. +* Guard the entire worker loop to safely drain stale faults and +* prevent autosuspends from desyncing batched CT flushes. +*/ +guard (xe_pm_runtime)(xe); +#define USM_QUEUE_MAX_RUNTIME_MS 20 threshold = jiffies +msecs_to_jiffies (USM_QUEUE_MAX_RUNTIME_MS );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 256/2651 spi: ma35d1-qspi: Allow DTR operations with the regular SPI API
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miquel Raynal <[email protected]>
[ Upstream commit 2448f25cc839739fe576d31d85c7d0df4844bb3a ]
The feature was implemented but not actually enabled for regular SPI operations (as opposed to spi-mem operations). Make sure the missing capability is actually set.
--- drivers/spi/spi-ma35d1-qspi.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-ma35d1-qspi.c +1 -0
@@ -649,6 +649,7 @@ static int nuvoton_qspi_probe(struct platform_device *pdev) ctlr->max_message_size = nuvoton_qspi_max_message_size; ctlr->mem_ops = &nuvoton_qspi_mem_ops; ctlr->mem_caps = &nuvoton_qspi_mem_caps; + ctlr->dtr_caps = true; ctlr->set_cs = nuvoton_qspi_set_cs; ctlr->transfer_one = nuvoton_qspi_transfer_one; ctlr->bits_per_word_mask =SPI_BPW_MASK (8 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 257/2651 drivers/base/node: fix UAF on device_register() failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linkai Gong <[email protected]>
[ Upstream commit 6d7e9bc51d8f2d73b3403c759c769f880082f9ae ]
node_init_node_access() frees the access node with kfree() if device_register() fails. After device_register() the embedded device is initialized and must be released with put_device() so that node_access_release() can free it.
--- drivers/base/node.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
drivers/base/node.c +8 -9
@@ -167,20 +167,19 @@ static struct node_access_nodes *node_init_node_access(struct node *node, dev->parent = &node->dev; dev->release = node_access_release; dev->groups = node_access_node_groups; -if (dev_set_name (dev,"access%u" , access)) - goto free; +if (dev_set_name (dev,"access%u" , access)) { +kfree (access_node); +return NULL ; + } -if (device_register (dev)) - goto free_name; +if (device_register (dev)) { +put_device (dev); +return NULL ; + }pm_runtime_no_callbacks (dev);list_add_tail (&access_node->list_node, &node->access_list);return access_node; -free_name: -kfree_const (dev->kobj.name); -free: -kfree (access_node); -return NULL ; }#ifdef CONFIG_HMEM_REPORTING
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 258/2651 irqchip/gic-v3-its: Dont WARN on LPI free allocation failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 135d9e67f7ab4f261c2157ee2de1f93a4de39a41 ]
free_lpi_range() cannot give LPIs back to the allocator without allocating a struct lpi_range to describe the freed range, so it returns -ENOMEM (its only failure mode) when that allocation fails, and its_lpi_free() turns this into a WARN_ON().
syzbot triggers the WARN_ON() by injecting a slab allocation failure on device teardown, which with panic_on_warn becomes a panic:
WARNING: drivers/irqchip/irq-gic-v3-its.c:2251 at its_msi_teardown+0x3a4/0x424 its_msi_teardown+0x3a4/0x424 msi_remove_device_irq_domain+0x16c/0x27c msi_device_data_release+0x38/0x9c
The failure is transient and the consequence benign: the freed range is simply never returned to the allocator. This does not warrant a WARN_ON() backtrace, so log a rate-limited error instead.
--- drivers/irqchip/irq-gic-v3-its.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/irqchip/irq-gic-v3-its.c +2 -1
@@ -2248,7 +2248,8 @@ static unsigned long *its_lpi_alloc(int nr_irqs, u32 *base, int *nr_ids)static void its_lpi_free (unsigned long *bitmap,u32 base,u32 nr_ids) { -WARN_ON (free_lpi_range (base, nr_ids)); +if (free_lpi_range (base, nr_ids)) +pr_err_ratelimited ("ITS: failed to free LPI range %u:%u\n" , base, nr_ids);bitmap_free (bitmap); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 259/2651 ASoC: es8326: report resume restore errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 349e94679968785803cc32c1d2e41e000e8afd5f ]
es8326_resume() ignores the status-register read, the direct clock-state write and the register-cache replay. A read failure can also leave reg uninitialized before it selects the reset path, and a cache failure is followed by jack IRQ processing.
Return these errors before later resume work. The ASoC component wrapper reports the callback failure while retaining its best-effort resume contract.
The issue was found by our static-analysis tool and manually reviewed.
--- sound/soc/codecs/es8326.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
sound/soc/codecs/es8326.c +15 -5
@@ -1130,18 +1130,28 @@ static int es8326_resume(struct snd_soc_component *component) {struct es8326_priv *es8326 =snd_soc_component_get_drvdata (component);unsigned int reg; +int ret;regcache_cache_only (es8326->regmap, false);regcache_cache_bypass (es8326->regmap, true); -regmap_read (es8326->regmap,ES8326_CLK_RESAMPLE , ®); + ret =regmap_read (es8326->regmap,ES8326_CLK_RESAMPLE , ®);regcache_cache_bypass (es8326->regmap, false); +if (ret) +return ret; +/* reset internal clock state */ -if (reg ==0x05 ) -regmap_write (es8326->regmap,ES8326_CLK_CTL ,ES8326_CLK_ON ); -else +if (reg ==0x05 ) { + ret =regmap_write (es8326->regmap,ES8326_CLK_CTL , +ES8326_CLK_ON ); +if (ret) +return ret; + }else {es8326_init (component); + } -regcache_sync (es8326->regmap); + ret =regcache_sync (es8326->regmap); +if (ret) +return ret;es8326_irq (es8326->irq, es8326);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 260/2651 ASoC: es8375: report resume restore errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 8f43acfd3addf10fbde8d21dd44b1a61e1936ba7 ]
es8375_resume() ignores the clock-status read, bias restoration and register-cache replay. A read failure can leave reg uninitialized before it selects the initialization path, and later resume processing cannot observe a failed restore.
Return the fallible operation results to the ASoC component wrapper, which reports callback failures while retaining its best-effort resume contract.
The issue was found by our static-analysis tool and manually reviewed.
--- sound/soc/codecs/es8375.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
sound/soc/codecs/es8375.c +11 -7
@@ -577,20 +577,24 @@ static int es8375_resume(struct snd_soc_component *component) {struct es8375_priv *es8375 =snd_soc_component_get_drvdata (component);unsigned int reg; +int ret;regcache_cache_only (es8375->regmap, false);regcache_cache_bypass (es8375->regmap, true); -regmap_read (es8375->regmap,ES8375_CLK_MGR2 , ®); + ret =regmap_read (es8375->regmap,ES8375_CLK_MGR2 , ®);regcache_cache_bypass (es8375->regmap, false); +if (ret) +return ret; -if (reg ==0x00 ) +if (reg ==0x00 ) {es8375_init (component); -else -es8375_set_bias_level (component,SND_SOC_BIAS_ON ); - -regcache_sync (es8375->regmap); + }else { + ret =es8375_set_bias_level (component,SND_SOC_BIAS_ON ); +if (ret) +return ret; + } -return 0 ; +return regcache_sync (es8375->regmap); }static int es8375_codec_probe (struct snd_soc_component *component)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 261/2651 ASoC: es8389: report resume restore errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 8f7d23eb8ffb817ba69049577ab8ca55b93c77cf ]
es8389_resume() ignores the reset-register read, bias restoration and register-cache replay. A failed read can leave regv uninitialized before it selects the initialization path.
Check those operations and always leave cache bypass before returning an error. The ASoC component wrapper reports callback failures while retaining its best-effort resume contract.
The issue was found by our static-analysis tool and manually reviewed.
--- sound/soc/codecs/es8389.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-)
sound/soc/codecs/es8389.c +14 -6
@@ -1032,20 +1032,28 @@ static int es8389_resume(struct snd_soc_component *component) {struct es8389_private *es8389 =snd_soc_component_get_drvdata (component);unsigned int regv; +int ret;regcache_cache_only (es8389->regmap, false);regcache_cache_bypass (es8389->regmap, true); -regmap_read (es8389->regmap,ES8389_RESET , ®v); + ret =regmap_read (es8389->regmap,ES8389_RESET , ®v); +if (ret) + goto disable_bypass; -if (regv ==0xff ) +if (regv ==0xff ) {es8389_init (component); -else -es8389_set_bias_level (component,SND_SOC_BIAS_ON ); + }else { + ret =es8389_set_bias_level (component,SND_SOC_BIAS_ON ); +if (ret) + goto disable_bypass; + } +disable_bypass:regcache_cache_bypass (es8389->regmap, false); -regcache_sync (es8389->regmap); +if (ret) +return ret; -return 0 ; +return regcache_sync (es8389->regmap); }static int es8389_probe (struct snd_soc_component *component)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 262/2651 ASoC: fs210x: report register restore errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit aa7d985d85529049fc8c39c168b300f59de4fdf8 ]
fs210x_init_chip() marks the register cache dirty and replays it after reset and scene setup, but ignores a replay failure and publishes is_inited. Its resume caller already returns the helper status.
Keep is_inited clear and return a cache replay failure so the ASoC component wrapper can report the incomplete restoration.
The issue was found by our static-analysis tool and manually reviewed.
--- sound/soc/codecs/fs210x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
sound/soc/codecs/fs210x.c +3 -2
@@ -610,8 +610,9 @@ static int fs210x_init_chip(struct fs210x_priv *fs210x)if (!ret) {regcache_cache_only (fs210x->regmap, false);regcache_mark_dirty (fs210x->regmap); -regcache_sync (fs210x->regmap); - fs210x->is_inited = true; + ret =regcache_sync (fs210x->regmap); +if (!ret) + fs210x->is_inited = true; }return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 263/2651 arm64: dts: mediatek: Add #{address,size}-cells to Chromium-based /firmware
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Brian Norris <[email protected]>
[ Upstream commit 69c1a4fd5272df1d745d6bcc3c613843ebecec61 ]
Chromium/Depthcharge bootloaders may dynamically add a few device nodes to a system's DTB under a /firmware node. A typical DT looks something like the following:
/ {
firmware {
ranges;
coreboot {
compatible = "coreboot";
reg = <...>;
...;
};
};
};Notably, the /firmware node has an empty 'ranges', but does not have address/size-cells.
Commit 6e5773d52f4a ("of/address: Fix WARN when attempting translating non-translatable addresses") started requiring #address-cells for a device's parent if we want to use the reg resource in a device node. This leads to errors like the following:
[ 7.763870] coreboot_table firmware:coreboot: probe with driver coreboot_table failed with error -22
Add appropriate #{address,size}-cells to work around the problem.
Note that Google has also patched the Depthcharge bootloader source to add {address,size}-cells [1], but bootloader updates are typically delivered only via Google OS updates. Not all users install Google software updates, and even if they do, Google may not produce updated binaries for all/older devices.
[1] https://lore.kernel.org/all/[email protected]/
https://crrev.com/c/6051580 ("coreboot: Insert #address-cells and #size-cells for firmware node")
--- arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi | 5 +++++ arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 5 +++++ arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi | 5 +++++ arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi | 5 +++++ arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi | 5 +++++ arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi | 5 +++++ 6 files changed, 30 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173-elm.dtsi +5 -0
@@ -16,6 +16,11 @@ aliases { mmc2 = &mmc3; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + memory@40000000 { device_type = "memory"; reg = <0 0x40000000 0 0x80000000>;
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +5 -0
@@ -22,6 +22,11 @@ chosen { stdout-path = "serial0:115200n8"; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + backlight_lcd0: backlight_lcd0 { compatible = "pwm-backlight"; pwms = <&pwm0 0 500000>;
arch/arm64/boot/dts/mediatek/mt8186-corsola.dtsi +5 -0
@@ -26,6 +26,11 @@ chosen { stdout-path = "serial0:115200n8"; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + memory@40000000 { device_type = "memory"; /* The size should be filled in by the bootloader. */
arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi +5 -0
@@ -41,6 +41,11 @@ dmic-codec { wakeup-delay-ms = <100>; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + memory@40000000 { device_type = "memory"; /* The size will be filled in by the bootloader */
arch/arm64/boot/dts/mediatek/mt8192-asurada.dtsi +5 -0
@@ -25,6 +25,11 @@ chosen { stdout-path = "serial0:115200n8"; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + memory@40000000 { device_type = "memory"; reg = <0 0x40000000 0 0x80000000>;
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +5 -0
@@ -42,6 +42,11 @@ dmic-codec { wakeup-delay-ms = <50>; }; + firmware { + #address-cells = <2>; + #size-cells = <2>; + }; + memory@40000000 { device_type = "memory"; reg = <0 0x40000000 0 0x80000000>;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 264/2651 arm64: dts: mediatek: mt6878-pinfunc: Fix pinctrl header path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Belwon <[email protected]>
[ Upstream commit 9b9c33336d2c25b6ef8758af3ce3c1802d26ca25 ]
The header resides in the dt-bindings directory and not in the dts/mediatek directory. Fix it as to avoid a build failure.
--- arch/arm64/boot/dts/mediatek/mt6878-pinfunc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt6878-pinfunc.h +1 -1
@@ -9,7 +9,7 @@#ifndef __MT6878_PINFUNC_H#define __MT6878_PINFUNC_H -#include "mt65xx.h" +#include <dt-bindings/pinctrl/mt65xx.h> #define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)#define PINMUX_GPIO0__FUNC_TP_GPIO0_AO (MTK_PIN_NO(0) | 1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 265/2651 arm64: dts: mediatek: mt6893-pinfunc: Fix pinctrl header path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Igor Belwon <[email protected]>
[ Upstream commit 863d48714194bfcdb917b2ec35531e40df40cb87 ]
The header resides in the dt-bindings directory and not in the dts/mediatek directory. Fix it as to avoid a build failure.
--- arch/arm64/boot/dts/mediatek/mt6893-pinfunc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt6893-pinfunc.h +1 -1
@@ -7,7 +7,7 @@#ifndef __MT6893_PINFUNC_H#define __MT6893_PINFUNC_H -#include "mt65xx.h" +#include <dt-bindings/pinctrl/mt65xx.h> #define PINMUX_GPIO0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)#define PINMUX_GPIO0__FUNC_SPI6_CLK (MTK_PIN_NO(0) | 1)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 266/2651 virtio_ccw: fix synchronize_cbs() after interrupt fallback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 6e484b870b71eb6acb3fa7a10b8e71098e242033 ]
virtio_ccw_synchronize_cbs() assumes the device uses adapter interrupts when vcdev->airq_info is not NULL. If registering adapter indicators fails, virtio_ccw_find_vqs() falls back to classic interrupts but can leave airq_info set.
With VIRTIO_HARDEN_NOTIFICATION enabled, virtio_ccw_int_handler() invokes callbacks under vcdev->irq_lock. synchronize_cbs() instead takes the indicator area lock, so it does not synchronize with those callbacks.
Use vcdev->is_thinint, which the fallback clears, to select the lock. Keep the airq_info check because is_thinint can be set before the first find_vqs() call, when airq_info is still NULL.
Message-ID: <[email protected]>
--- drivers/s390/virtio/virtio_ccw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/virtio/virtio_ccw.c +1 -1
@@ -1062,7 +1062,7 @@ static void virtio_ccw_synchronize_cbs(struct virtio_device *vdev)struct virtio_ccw_device *vcdev =to_vc_device (vdev);struct airq_info *info = vcdev->airq_info; -if (info) { +if (vcdev->is_thinint && info) {/* * This device uses adapter interrupts: synchronize with * vring_interrupt() called by virtio_airq_handler()
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 267/2651 virtio_ccw: always take irq_lock in the classic interrupt handler
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 48a355cf5b382570975e60857450ff3d42f268e9 ]
virtio_ccw_int_handler() takes vcdev->irq_lock around its vring_interrupt() calls only when VIRTIO_HARDEN_NOTIFICATION is enabled.
The virtio shutdown path calls synchronize_cbs() even when notification hardening is disabled. virtio_reset_device() now does so after the transport reset too.
For classic interrupts, synchronize_cbs() takes vcdev->irq_lock for writing, but the interrupt handler does not take the matching read lock in that configuration. synchronize_cbs() can return while a callback is still running.
Take the read lock unconditionally so the write side can synchronize with the callbacks.
Message-ID: <[email protected]>
--- drivers/s390/virtio/virtio_ccw.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/s390/virtio/virtio_ccw.c +0 -4
@@ -1204,13 +1204,11 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev, vcdev->err = -EIO ; }virtio_ccw_check_activity (vcdev, activity); -#ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION /* * Paired with virtio_ccw_synchronize_cbs() and interrupts are * disabled here. */ read_lock (&vcdev->irq_lock); -#endif for_each_set_bit (i,indicators (vcdev),sizeof (*indicators (vcdev)) *BITS_PER_BYTE ) {/* The bit clear must happen before the vring kick. */
@@ -1219,9 +1217,7 @@ static void virtio_ccw_int_handler(struct ccw_device *cdev, vq =virtio_ccw_vq_by_ind (vcdev, i);vring_interrupt (0 , vq); } -#ifdef CONFIG_VIRTIO_HARDEN_NOTIFICATION read_unlock (&vcdev->irq_lock); -#endif if (test_bit (0 ,indicators2 (vcdev))) {virtio_config_changed (&vcdev->vdev);clear_bit (0 ,indicators2 (vcdev));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 268/2651 pwm: mtk-disp: Fix period readback
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chen-Yu Tsai <[email protected]>
[ Upstream commit c5b29baad42b2b02389cc6a716697a8a63209930 ]
The period value stored in the register is the number of clock cycles - 1.
Account for the offset when calculating the period in nanoseconds. This fixes the discrepancy reported by the pwm core when CONFIG_PWM_DEBUG=1:
mediatek-disp-pwm 1100e000.pwm: .apply is not idempotent
(ena=1 pol=0 281500/499875) -> (ena=1 pol=0 281500/499750)
Calculation discrepancy in the driver was found by AI run by a colleague while debugging another PWM related issue. Check against SoC datasheet and fix done by the author.
--- drivers/pwm/pwm-mtk-disp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pwm/pwm-mtk-disp.c +2 -2
@@ -210,9 +210,9 @@ static int mtk_disp_pwm_get_state(struct pwm_chip *chip, period =FIELD_GET (PWM_PERIOD_MASK , con1);/* * period has 12 bits, clk_div 11 and NSEC_PER_SEC has 30, -* so period * (clk_div + 1) * NSEC_PER_SEC doesn't overflow. +* so (period + 1) * (clk_div + 1) * NSEC_PER_SEC doesn't overflow. */ - state->period =DIV64_U64_ROUND_UP (period * (clk_div +1 ) *NSEC_PER_SEC , rate); + state->period =DIV64_U64_ROUND_UP ((period +1 ) * (clk_div +1 ) *NSEC_PER_SEC , rate); high_width =FIELD_GET (PWM_HIGH_WIDTH_MASK , con1); state->duty_cycle =DIV64_U64_ROUND_UP (high_width * (clk_div +1 ) *NSEC_PER_SEC , rate);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 269/2651 mac80211: tx: Use info->flags in ieee80211_tx_h_select_key()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bert Karwatzki <[email protected]>
[ Upstream commit 5f2530a4df8e0573e54cc0f4175c06ecb810a4dd ]
Without this ieee80211_select_key_8023() is never called and wifi never connects.
--- net/mac80211/tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/tx.c +1 -1
@@ -618,7 +618,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx)struct ieee80211_tx_info *info =IEEE80211_SKB_CB (tx->skb);struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; -if (info->control.flags &IEEE80211_TX_CTL_HW_80211_ENCAP ) +if (info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP )return ieee80211_select_key_8023 (tx);if (unlikely (info->flags &IEEE80211_TX_INTFL_DONT_ENCRYPT )) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 270/2651 ASoC: mediatek: mt8186: Fix APLL mux setting error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 5ee5987fadf6ae15678a654b4d909225c97f0299 ]
The APLL mux setup functions return immediately when a clock operation fails, without undoing the clock changes already made. This can leave clocks enabled or muxes configured to an unexpected parent.
Restore the affected muxes to CLK26M and disable previously enabled clocks on error before propagating the original error.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 50 ++++++++++++++++------ 1 file changed, 38 insertions(+), 12 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +38 -12
@@ -98,7 +98,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_1; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], afe_priv->clk[CLK_TOP_APLL1_CK ]);
@@ -106,7 +106,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_TOP_APLL1_CK ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_1; }/* 180.6336 / 8 = 22.5792MHz */
@@ -114,7 +114,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_ENG1; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], afe_priv->clk[CLK_TOP_APLL1_D8 ]);
@@ -122,7 +122,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_TOP_APLL1_D8 ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_ENG1; } }else { ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUD_ENG1],
@@ -131,7 +131,7 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]);
@@ -141,12 +141,25 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); }return 0 ; + +ERR_SELECT_CLK_TOP_MUX_AUD_ENG1: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_ENG1: +ERR_SELECT_CLK_TOP_MUX_AUD_1: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_1 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_1: +EXIT: +return ret; }static int apll2_mux_setting (struct mtk_base_afe *afe,bool enable)
@@ -159,7 +172,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_2; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], afe_priv->clk[CLK_TOP_APLL2_CK ]);
@@ -167,7 +180,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_TOP_APLL2_CK ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_2; }/* 196.608 / 8 = 24.576MHz */
@@ -175,7 +188,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], ret); -return ret; + goto ERR_ENABLE_CLK_TOP_MUX_AUD_ENG2; } ret =clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], afe_priv->clk[CLK_TOP_APLL2_D8 ]);
@@ -183,7 +196,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_TOP_APLL2_D8 ], ret); -return ret; + goto ERR_SELECT_CLK_TOP_MUX_AUD_ENG2; } }else { ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUD_ENG2],
@@ -192,7 +205,7 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]);
@@ -202,12 +215,25 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_CLK26M ], ret); -return ret; + goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); }return 0 ; + +ERR_SELECT_CLK_TOP_MUX_AUD_ENG2: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_ENG2: +ERR_SELECT_CLK_TOP_MUX_AUD_2: +clk_set_parent (afe_priv->clk[CLK_TOP_MUX_AUD_2 ], + afe_priv->clk[CLK_CLK26M ]); +clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); +ERR_ENABLE_CLK_TOP_MUX_AUD_2: +EXIT: +return ret; }int mt8186_afe_enable_cgs (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 271/2651 ASoC: mediatek: mt8186: Fix clock handling in mux disable path
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit d70109f5510b423e72894dadfbab27087a7b26b0 ]
In the disable path of the appl*_mux_setting() functions, clk_disable_unprepare() is called after clk_set_parent(). If clk_set_parent() fails, clk_disable_unprepare() is skipped, potentially leaving one of the clocks enabled.
Remove the goto exit paths so that all teardown steps are attempted and any errors are only reported.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 6 ------ 1 file changed, 6 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +0 -6
@@ -131,7 +131,6 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG1 ]);
@@ -141,7 +140,6 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_1 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); }
@@ -158,7 +156,6 @@ static int apll1_mux_setting(struct mtk_base_afe *afe, bool enable) afe_priv->clk[CLK_CLK26M]);clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_1 ]); ERR_ENABLE_CLK_TOP_MUX_AUD_1: -EXIT:return ret; }
@@ -205,7 +202,6 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_ENG2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_ENG2 ]);
@@ -215,7 +211,6 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_2 ], aud_clks[CLK_CLK26M ], ret); - goto EXIT; }clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); }
@@ -232,7 +227,6 @@ static int apll2_mux_setting(struct mtk_base_afe *afe, bool enable) afe_priv->clk[CLK_CLK26M]);clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_2 ]); ERR_ENABLE_CLK_TOP_MUX_AUD_2: -EXIT:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 272/2651 ASoC: mediatek: mt8186: Fix AFE clock error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit eb72060a1966baf9a6ed753186621ee6e39dc889 ]
The error paths in mt8186_afe_enable_clock() do not consistently undo the clock operations performed before an error.
Fix the goto targets and cleanup order so that the audio internal bus parent is restored to CLK26M and all previously enabled clocks are disabled before returning the error.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +8 -10
@@ -288,7 +288,7 @@ int mt8186_afe_enable_clock(struct mtk_base_afe *afe)dev_err (afe->dev,"%s clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[CLK_MUX_AUDIO ], aud_clks[CLK_CLK26M ], ret); - goto clk_mux_audio_err; + goto clk_mux_audio_intbus_err; } ret =clk_prepare_enable (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]);
@@ -315,24 +315,22 @@ int mt8186_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_AFE ], ret); - goto clk_afe_err; + goto clk_mux_audio_h_parent_err; }return 0 ; -clk_afe_err: -clk_disable_unprepare (afe_priv->clk[CLK_AFE ]); clk_mux_audio_h_parent_err: -clk_mux_audio_intbus_parent_err:mt8186_set_audio_int_bus_parent (afe,CLK_CLK26M ); -clk_mux_audio_intbus_err: +clk_mux_audio_intbus_parent_err:clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIOINTBUS ]); -clk_mux_audio_err: +clk_mux_audio_intbus_err:clk_disable_unprepare (afe_priv->clk[CLK_MUX_AUDIO ]); -clk_infra_sys_audio_err: -clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]); -clk_infra_audio_26m_err: +clk_mux_audio_err:clk_disable_unprepare (afe_priv->clk[CLK_INFRA_AUDIO_26M ]); +clk_infra_audio_26m_err: +clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUDIO ]); +clk_infra_sys_audio_err:return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 273/2651 ASoC: mediatek: mt8186: Fix APLL enable error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit cb552c6b9abe02f254d44d8c29d0dce1ae21f69f ]
Currently, the mt8186_apll*_enable() functions call mux_setting(afe, true) but do not check its return value to handle failures.
In addition, the cleanup paths of mt8186_apll*_enable() do not call mux_setting(afe, false) when the enable operation fails, while the mt8186_apll*_disable() functions do.
Add error handling for apll*_mux_setting() and call mux_setting(afe, false) in the cleanup paths when mt8186_apll*_enable() fails.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +10 -6
@@ -353,7 +353,9 @@ int mt8186_apll1_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll1_mux_setting (afe, true); + ret =apll1_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL22M ]);if (ret) {
@@ -378,9 +380,9 @@ int mt8186_apll1_enable(struct mtk_base_afe *afe)return 0 ; err_clk_apll1_tuner: -clk_disable_unprepare (afe_priv->clk[CLK_APLL1_TUNER ]); -err_clk_apll22m:clk_disable_unprepare (afe_priv->clk[CLK_APLL22M ]); +err_clk_apll22m: +apll1_mux_setting (afe, false);return ret; }
@@ -406,7 +408,9 @@ int mt8186_apll2_enable(struct mtk_base_afe *afe)int ret;/* setting for APLL */ -apll2_mux_setting (afe, true); + ret =apll2_mux_setting (afe, true); +if (ret) +return ret; ret =clk_prepare_enable (afe_priv->clk[CLK_APLL24M ]);if (ret) {
@@ -431,9 +435,9 @@ int mt8186_apll2_enable(struct mtk_base_afe *afe)return 0 ; err_clk_apll2_tuner: -clk_disable_unprepare (afe_priv->clk[CLK_APLL2_TUNER ]); -err_clk_apll24m:clk_disable_unprepare (afe_priv->clk[CLK_APLL24M ]); +err_clk_apll24m: +apll2_mux_setting (afe, false);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 274/2651 ASoC: mediatek: mt8186: Fix MCK error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit 996469c1092e8fa81fac98d819174ce56baff821 ]
The mt8186_mck_enable() function returns immediately when a clock operation fails, leaving previously enabled clocks active.
Add error paths to disable previously enabled clocks before returning the error.
--- sound/soc/mediatek/mt8186/mt8186-afe-clk.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +13 -4
@@ -520,7 +520,7 @@ int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[m_sel_id], ret); -return ret; + goto ERR_ENABLE_MCLK; } ret =clk_set_parent (afe_priv->clk[m_sel_id], afe_priv->clk[apll_clk_id]);
@@ -528,7 +528,7 @@ int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)dev_err (afe->dev,"%s(), clk_set_parent %s-%s fail %d\n" , __func__, aud_clks[m_sel_id], aud_clks[apll_clk_id], ret); -return ret; + goto ERR_SELECT_MCLK; } }
@@ -537,16 +537,25 @@ int mt8186_mck_enable(struct mtk_base_afe *afe, int mck_id, int rate)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[div_clk_id], ret); -return ret; + goto ERR_ENABLE_MCLK_DIV; } ret =clk_set_rate (afe_priv->clk[div_clk_id], rate);if (ret) {dev_err (afe->dev,"%s(), clk_set_rate %s, rate %d, fail %d\n" , __func__, aud_clks[div_clk_id], rate, ret); -return ret; + goto ERR_SET_MCLK_RATE; }return 0 ; + +ERR_SET_MCLK_RATE: +clk_disable_unprepare (afe_priv->clk[div_clk_id]); +ERR_ENABLE_MCLK_DIV: +ERR_SELECT_MCLK: +if (m_sel_id >=0 ) +clk_disable_unprepare (afe_priv->clk[m_sel_id]); +ERR_ENABLE_MCLK: +return ret; }void mt8186_mck_disable (struct mtk_base_afe *afe,int mck_id)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 275/2651 ASoC: mediatek: mt6797: fix wrong unwind order and error code in enable_clock
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: bui duc phuc <[email protected]>
[ Upstream commit e967d479b65c778cd2394ab185e289beefcf996d ]
The error paths in mt6797_afe_enable_clock() use incorrect goto labels, causing clocks that failed to enable to be disabled during cleanup.
Fix the goto labels to only unwind clocks that were successfully enabled, and return the actual error code.
--- sound/soc/mediatek/mt6797/mt6797-afe-clk.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
sound/soc/mediatek/mt6797/mt6797-afe-clk.c +6 -8
@@ -63,21 +63,21 @@ int mt6797_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_SYS_AUD ], ret); - goto CLK_INFRA_SYS_AUDIO_ERR; +return ret; } ret =clk_prepare_enable (afe_priv->clk[CLK_INFRA_SYS_AUD_26M ]);if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_INFRA_SYS_AUD_26M ], ret); - goto CLK_INFRA_SYS_AUD_26M_ERR; + goto CLK_INFRA_SYS_AUDIO_ERR; } ret =clk_prepare_enable (afe_priv->clk[CLK_TOP_MUX_AUD ]);if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD ], ret); - goto CLK_MUX_AUDIO_ERR; + goto CLK_INFRA_SYS_AUD_26M_ERR; } ret = clk_set_parent(afe_priv->clk[CLK_TOP_MUX_AUD],
@@ -93,13 +93,11 @@ int mt6797_afe_enable_clock(struct mtk_base_afe *afe)if (ret) {dev_err (afe->dev,"%s(), clk_prepare_enable %s fail %d\n" , __func__, aud_clks[CLK_TOP_MUX_AUD_BUS ], ret); - goto CLK_MUX_AUDIO_INTBUS_ERR; + goto CLK_MUX_AUDIO_ERR; } -return ret; +return 0 ; -CLK_MUX_AUDIO_INTBUS_ERR: -clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD_BUS ]); CLK_MUX_AUDIO_ERR:clk_disable_unprepare (afe_priv->clk[CLK_TOP_MUX_AUD ]); CLK_INFRA_SYS_AUD_26M_ERR:
@@ -107,7 +105,7 @@ int mt6797_afe_enable_clock(struct mtk_base_afe *afe) CLK_INFRA_SYS_AUDIO_ERR:clk_disable_unprepare (afe_priv->clk[CLK_INFRA_SYS_AUD ]); -return 0 ; +return ret; }int mt6797_afe_disable_clock (struct mtk_base_afe *afe)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 276/2651 pwm: lp3943: fix NULL pointer dereference for an unconfigured channel
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Manush Prajwal <[email protected]>
[ Upstream commit 17dbb6938d3ab444cd6be1c95506450595a8800d ]
lp3943_pwm_probe() unconditionally registers a pwmchip with LP3943_NUM_PWMS(2) hwpwm channels, but lp3943_pwm_parse_dt() only populates pdata->pwms[i] for the channels whose ti,pwm0/ti,pwm1 property is actually present in the devicetree (the binding explicitly allows each PWM generator to drive zero or more outputs, and lp3943_pwm_parse_dt() only fails outright with -ENODATA if *neither* property is present). A devicetree that configures only one of the two channels leaves pdata->pwms[] NULL for the other.
lp3943_pwm_request_map() dereferences pdata->pwms[hwpwm] with no NULL check:
pwm_map->output = pdata->pwms[hwpwm]->output; pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs;
so requesting the unconfigured channel (e.g. exporting it from sysfs) crashes with a NULL pointer dereference instead of failing cleanly.
Return -ENODEV from lp3943_pwm_request_map() when the channel was never configured, before the pointer is dereferenced. The caller, lp3943_pwm_request(), already propagates an ERR_PTR return correctly (it does so today for the existing -EBUSY case).
--- drivers/pwm/pwm-lp3943.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/pwm/pwm-lp3943.c +3 -0
@@ -38,6 +38,9 @@ lp3943_pwm_request_map(struct lp3943_pwm *lp3943_pwm, int hwpwm)struct lp3943_pwm_map *pwm_map = &lp3943_pwm->pwm_map[hwpwm];int i, offset; +if (!pdata->pwms[hwpwm]) +return ERR_PTR (-ENODEV ); + pwm_map->output = pdata->pwms[hwpwm]->output; pwm_map->num_outputs = pdata->pwms[hwpwm]->num_outputs;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 277/2651 selftests/sched_ext: Fail interrupted test runs
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Chen <[email protected]>
[ Upstream commit 7036264dcd46ab641768ef97ab74f91bce5701c8 ]
SIGINT and SIGTERM set exit_req, causing the runner to stop before executing the remaining tests. However, the exit status only reflects the number of failed tests, so an interrupted run returns success when none of the completed tests failed.
Include exit_req in the failure condition so callers can distinguish an interrupted run from a successful run. Keep the result counts limited to the tests that actually ran.
Tested the actual runner under GDB, delivering each signal before the first test and after the example test passed. The original runner returns 0 in all four cases; the fixed runner returns 1. Normal -h, -l and -t example invocations still return 0.
--- tools/testing/selftests/sched_ext/runner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/sched_ext/runner.c +1 -1
@@ -243,7 +243,7 @@ int main(int argc, char **argv)printf (" - %s\n" , failed_tests[i]); } -return failed >0 ?1 :0 ; +return failed >0 || exit_req ?1 :0 ; }void scx_test_register (struct scx_test *test)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 278/2651 selftests/sched_ext: Handle CPU hotplug write failures
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tianyi Chen <[email protected]>
[ Upstream commit 49c64ffb2fd996af4c82007196c61e17d74cb1ab ]
toggle_online_status() logs failed CPU state changes but discards the write result. The hotplug tests can consequently wait indefinitely for a scheduler exit that the failed operation never triggered.
Return the write result and stop both hotplug tests when a required CPU state change fails. Release the acquired scheduler resources on these paths and let the existing cleanup callback retry restoring CPU1. Also fail the test when its normal CPU restoration fails.
Tested in a two-vCPU VM running a kernel built from the same source as the selftests. Injecting EIO with strace into each of the ten CPU state writes makes the fixed test return 1, with CPU1 online and sched_ext disabled after cleanup. The original test does not finish within three seconds when either of the first two writes fails. Normal hotplug tests pass before and after the change. Making the online file read-only also produces a failure without hanging.
--- tools/testing/selftests/sched_ext/hotplug.c | 34 ++++++++++++++------- 1 file changed, 23 insertions(+), 11 deletions(-)
tools/testing/selftests/sched_ext/hotplug.c +23 -11
@@ -21,15 +21,17 @@ static bool is_cpu_online(void)return file_read_long (online_path) >0 ; } -static void toggle_online_status (bool online) +static int toggle_online_status (bool online) {long val = online ?1 :0 ;int ret; ret =file_write_long (online_path, val);if (ret !=0 ) -fprintf (stderr,"Failed to bring CPU %s (%s)" , +fprintf (stderr,"Failed to bring CPU %s (%s)\n" , online ?"online" :"offline" ,strerror (errno)); + +return ret; }static enum scx_test_status setup (void **ctx)
@@ -44,6 +46,7 @@ static enum scx_test_status test_hotplug(bool onlining, bool cbs_defined) {struct hotplug *skel;struct bpf_link *link; +enum scx_test_status status =SCX_TEST_FAIL ;long kind, code;SCX_ASSERT (is_cpu_online ());
@@ -54,8 +57,8 @@ static enum scx_test_status test_hotplug(bool onlining, bool cbs_defined)SCX_FAIL_IF (hotplug__load (skel),"Failed to load skel" );/* Testing the offline -> online path, so go offline before starting */ -if (onlining) -toggle_online_status (0 ); +if (onlining &&toggle_online_status (0 )) + goto out_destroy_skel;if (cbs_defined) { kind =SCX_KIND_VAL (SCX_EXIT_UNREG_BPF );
@@ -79,7 +82,8 @@ static enum scx_test_status test_hotplug(bool onlining, bool cbs_defined)return SCX_TEST_FAIL ; } -toggle_online_status (onlining ?1 :0 ); +if (toggle_online_status (onlining ?1 :0 )) + goto out_destroy_link;while (!UEI_EXITED (skel, uei))sched_yield ();
@@ -87,20 +91,23 @@ static enum scx_test_status test_hotplug(bool onlining, bool cbs_defined)SCX_EQ (skel->data->uei.kind, kind);SCX_EQ (UEI_REPORT (skel, uei), code); -if (!onlining) -toggle_online_status (1 ); +if (!onlining &&toggle_online_status (1 )) + goto out_destroy_link; + status =SCX_TEST_PASS ; +out_destroy_link:bpf_link__destroy (link); +out_destroy_skel:hotplug__destroy (skel); -return SCX_TEST_PASS ; +return status; }static enum scx_test_status test_hotplug_attach (void ) {struct hotplug *skel;struct bpf_link *link; -enum scx_test_status status =SCX_TEST_PASS ; +enum scx_test_status status =SCX_TEST_FAIL ;long kind, code;SCX_ASSERT (is_cpu_online ());
@@ -115,10 +122,12 @@ static enum scx_test_status test_hotplug_attach(void)* Take the CPU offline to increment the global hotplug seq, which * should cause attach to fail due to us setting the hotplug seq above */ -toggle_online_status (0 ); +if (toggle_online_status (0 )) + goto out_destroy_skel; link =bpf_map__attach_struct_ops (skel->maps.hotplug_nocb_ops); -toggle_online_status (1 ); +if (toggle_online_status (1 )) + goto out_destroy_link;SCX_ASSERT (link);while (!UEI_EXITED (skel, uei))
@@ -130,7 +139,10 @@ static enum scx_test_status test_hotplug_attach(void)SCX_EQ (skel->data->uei.kind, kind);SCX_EQ (UEI_REPORT (skel, uei), code); + status =SCX_TEST_PASS ; +out_destroy_link:bpf_link__destroy (link); +out_destroy_skel:hotplug__destroy (skel);return status;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 279/2651 cgroup: Return -ENODEV consistently for a dead cgroup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit 22098e3b6f7260860d61523a8dc2964b40559763 ]
cgroup_kn_lock_live() returns NULL when the cgroup behind a kernfs node has already been removed. Most callers turn that into -ENODEV, but the cgroup.type, cgroup.max.descendants, cgroup.max.depth, cgroup.pressure, cgroup.freeze and cgroup.kill writers return -ENOENT. The divergence is accidental. Return -ENODEV from all of them, matching cgroup.procs and cgroup.subtree_control.
Stable-dep-of: c367ce5b31ff ("cgroup: Make the offline drain interruptible")
--- kernel/cgroup/cgroup.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
kernel/cgroup/cgroup.c +6 -6
@@ -3791,7 +3791,7 @@ static ssize_t cgroup_type_write(struct kernfs_open_file *of, char *buf,/* drain dying csses before we re-apply (threaded) subtree control */ cgrp =cgroup_kn_lock_live (of->kn, true);if (!cgrp) -return -ENOENT ; +return -ENODEV ;/* threaded can only be enabled */ ret =cgroup_enable_threaded (cgrp);
@@ -3834,7 +3834,7 @@ static ssize_t cgroup_max_descendants_write(struct kernfs_open_file *of, cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp) -return -ENOENT ; +return -ENODEV ;WRITE_ONCE (cgrp->max_descendants, descendants);
@@ -3877,7 +3877,7 @@ static ssize_t cgroup_max_depth_write(struct kernfs_open_file *of, cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp) -return -ENOENT ; +return -ENODEV ;WRITE_ONCE (cgrp->max_depth, depth);
@@ -4193,7 +4193,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp) -return -ENOENT ; +return -ENODEV ; psi =cgroup_psi (cgrp);if (psi->enabled != enable) {
@@ -4269,7 +4269,7 @@ static ssize_t cgroup_freeze_write(struct kernfs_open_file *of, cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp) -return -ENOENT ; +return -ENODEV ;cgroup_freeze (cgrp, freeze);
@@ -4331,7 +4331,7 @@ static ssize_t cgroup_kill_write(struct kernfs_open_file *of, char *buf, cgrp =cgroup_kn_lock_live (of->kn, false);if (!cgrp) -return -ENOENT ; +return -ENODEV ;/* * Killing is a process directed operation, i.e. the whole thread-group
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 280/2651 cgroup: Return ERR_PTR from cgroup_kn_lock_live()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit 67499cd07ba93dc643ca5624b7dc947f0354ace2 ]
cgroup_kn_lock_live() returns NULL when the cgroup is dead and the callers translate that into an errno themselves. Return ERR_PTR(-ENODEV) instead and have the callers pass the errno through, so that failures other than a dead cgroup can be reported through the same return value. No functional change.
Stable-dep-of: c367ce5b31ff ("cgroup: Make the offline drain interruptible")
--- kernel/cgroup/cgroup-v1.c | 8 +++---- kernel/cgroup/cgroup.c | 50 +++++++++++++++++++-------------------- kernel/cgroup/debug.c | 10 ++++---- 3 files changed, 34 insertions(+), 34 deletions(-)
kernel/cgroup/cgroup-v1.c +4 -4
@@ -506,8 +506,8 @@ static ssize_t __cgroup1_procs_write(struct kernfs_open_file *of,enum cgroup_attach_lock_mode lock_mode; cgrp =cgroup_kn_lock_live (of->kn, false); -if (!cgrp) -return -ENODEV ; +if (IS_ERR (cgrp)) +return PTR_ERR (cgrp); task =cgroup_procs_write_start (buf, threadgroup, &lock_mode); ret =PTR_ERR_OR_ZERO (task);
@@ -569,8 +569,8 @@ static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,return -EPERM ; cgrp =cgroup_kn_lock_live (of->kn, false); -if (!cgrp) -return -ENODEV ; +if (IS_ERR (cgrp)) +return PTR_ERR (cgrp);spin_lock (&release_agent_path_lock);strscpy (cgrp->root->release_agent_path,strstrip (buf),sizeof (cgrp->root->release_agent_path));
kernel/cgroup/cgroup.c +25 -25
134 lines not on this page · raw message
kernel/cgroup/debug.c +5 -5
@@ -45,7 +45,7 @@ static int current_css_set_read(struct seq_file *seq, void *v)struct cgroup_subsys_state *css;int i, refcnt; -if (!cgroup_kn_lock_live (of->kn, false)) +if (IS_ERR (cgroup_kn_lock_live (of->kn, false)))return -ENODEV ;spin_lock_irq (&css_set_lock);
@@ -206,8 +206,8 @@ static int cgroup_subsys_states_read(struct seq_file *seq, void *v)int i; cgrp =cgroup_kn_lock_live (of->kn, false); -if (!cgrp) -return -ENODEV ; +if (IS_ERR (cgrp)) +return PTR_ERR (cgrp);for_each_subsys (ss, i) { css =rcu_dereference_check (cgrp->subsys[ss->id], true);
@@ -254,8 +254,8 @@ static int cgroup_masks_read(struct seq_file *seq, void *v)struct cgroup *cgrp; cgrp =cgroup_kn_lock_live (of->kn, false); -if (!cgrp) -return -ENODEV ; +if (IS_ERR (cgrp)) +return PTR_ERR (cgrp);cgroup_masks_read_one (seq,"subtree_control" , cgrp->subtree_control);cgroup_masks_read_one (seq,"subtree_ss_mask" , cgrp->subtree_ss_mask);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 281/2651 cgroup: Make the offline drain interruptible
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
[ Upstream commit c367ce5b31ffd4d958f3f6c5fe1c9e820dc9f526 ]
cgroup_subtree_control_write() and cgroup_type_write() drain dying csses from the subtree before re-applying control, so that a controller being re-enabled gets a fresh css instead of adopting one that is still dying. The drain waits for offline_css() in TASK_UNINTERRUPTIBLE.
Since 1dffd95575eb ("cgroup: Defer kill_css_finish() in cgroup_apply_control_disable()"), a disabled css offlines only after every task that still pins it has finished exiting. The root cause of the hang is an indefinite wait in a place where indefinite waits should not happen: a task past exit_signals() can block in its exit path for as long as, say, a FUSE daemon takes to answer a flush, and nothing can interrupt it because prepare_signal() drops every signal for an exiting group. The drain then escalated that into an uninterruptible wait for the writer, which sits in D state for as long as the exiting task does. That is the hang syzbot reports as "task hung in cgroup_subtree_control_write".
Make the drain interruptible. Nothing has been modified when it runs, so the write restarts or fails with EINTR without side effects. cgroup1 mount and remount drain the same way and become interruptible too. cgroup_destroy_root() drains from a workqueue where no signal is ever pending and keeps waiting as before.
This only stops the escalation. The write still waits for the exiting tasks, and the indefinite wait in the exit path remains a separate problem.
--- kernel/cgroup/cgroup-internal.h | 2 +- kernel/cgroup/cgroup-v1.c | 8 ++++-- kernel/cgroup/cgroup.c | 48 ++++++++++++++++++++++----------- 3 files changed, 40 insertions(+), 18 deletions(-)
kernel/cgroup/cgroup-internal.h +1 -1
@@ -254,7 +254,7 @@ void cgroup_procs_write_finish(struct task_struct *task, enum cgroup_attach_lock_mode lock_mode) __releases(&cgroup_threadgroup_rwsem); -void cgroup_lock_and_drain_offline (struct cgroup *cgrp); +int cgroup_lock_and_drain_offline (struct cgroup *cgrp);int cgroup_mkdir (struct kernfs_node *parent_kn,const char *name,umode_t mode);int cgroup_rmdir (struct kernfs_node *kn);
kernel/cgroup/cgroup-v1.c +6 -2
@@ -1097,7 +1097,9 @@ int cgroup1_reconfigure(struct fs_context *fc)int ret =0 ;u32 added_mask, removed_mask; -cgroup_lock_and_drain_offline (&cgrp_dfl_root.cgrp); + ret =cgroup_lock_and_drain_offline (&cgrp_dfl_root.cgrp); +if (unlikely (ret)) +return ret;/* See what subsystems are wanted */ ret =check_cgroupfs_options (fc);
@@ -1262,7 +1264,9 @@ int cgroup1_get_tree(struct fs_context *fc)if (!ns_capable (ctx->ns->user_ns,CAP_SYS_ADMIN ))return -EPERM ; -cgroup_lock_and_drain_offline (&cgrp_dfl_root.cgrp); + ret =cgroup_lock_and_drain_offline (&cgrp_dfl_root.cgrp); +if (unlikely (ret)) +return ret; ret =cgroup1_root_to_use (fc);if (!ret && !percpu_ref_tryget_live (&ctx->root->cgrp.self.refcnt))
kernel/cgroup/cgroup.c +33 -15
96 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 282/2651 EDAC/i10nm: Fix Granite Rapids ADXL MC mapping
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qiuxu Zhuo <[email protected]>
[ Upstream commit ba71d9b4e9dd83c1614b3b5cec6c82a39d290f7e ]
ADXL reports memory errors using memory-controller physical indices, while the EDAC driver identifies memory controllers using logical indices. On Granite Rapids systems, BIOS may disable some memory controllers, causing the physical and logical indices to differ.
As a result, ADXL memory errors may be associated with the wrong memory controller, preventing EDAC from reporting errors for some DIMMs.
Maintain a physical-to-logical MC mapping so that ADXL memory errors are decoded correctly regardless of the BIOS memory-controller configuration.
--- drivers/edac/i10nm_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/edac/i10nm_base.c +1 -0
@@ -479,6 +479,7 @@ static struct pci_dev *get_gnr_mdev(struct skx_dev *d, int logical_idx, int *phyif (mdev) {if (logical == logical_idx) { *physical_idx = i; +skx_set_mc_mapping (d, i, logical_idx);return mdev; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 283/2651 perf test: perf stat tests fails on s390
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richter <[email protected]>
[ Upstream commit 454e049a3f6528a04f96afb4cbef1fcbb49c2d0f ]
The test case 'perf stat tests' fails on s390 z/VM machines. The root cause is the unsupported CPU measurement facility on z/VM. Therefore the events cycles and instructions do not exist and are unsupported. This cause the subtest
Hide zero events stat test
to fail.
Output before:
# perf test 116 116: perf stat tests : FAILED!
=== Test Summary ===
Passed main tests : 0
Passed subtests : 0 Skipped tests : 0 Failed tests : 1
List of failed tests:
116: perf stat tests
#
Output after:
# ./perf test 116 116: perf stat tests : Ok
=== Test Summary ===
Passed main tests : 1
Passed subtests : 0 Skipped tests : 0 Failed tests : 0
#
--- tools/perf/tests/shell/stat.sh | 5 +++++ 1 file changed, 5 insertions(+)
tools/perf/tests/shell/stat.sh +5 -0
@@ -583,6 +583,11 @@ test_hide_zero_events_stat() { # Check that --metric-only works with --hide-zero-events if ! perf stat --hide-zero-events --metric-only -e instructions,cycles true > "${stat_output}" 2>&1 then + if grep -sq 'No supported events found' "${stat_output}" + then + echo "Hide zero events stat test [Skipped - events not supported]" + return + fi echo "Hide zero events stat test [Failed - metric-only command failed]" err=1 return
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 284/2651 perf thread: Fix live-session detection in thread__e_machine()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matt Turner <[email protected]>
[ Upstream commit 15917a3a1ce0695f824892c8f9d0dc51408ee580 ]
When the per-thread e_machine cannot be determined from the DSOs in the thread's maps, thread__e_machine_endian() decides between reading /proc/<pid>/exe and falling back to the recorded session environment:
bool is_live = machine->machines == NULL;
if (!is_live) {
/* Check if the session has a data file. */
struct perf_session *session = container_of(...);
is_live = !!session->data;
}Neither half of that works.
The back pointer added by commit a088031c4998 ("perf tools: Add machine to machines back pointer") is set by machines__add(), which only ever adds guests; the host machine never gets one. Host-machine threads, which is to say almost all of them, therefore see machine->machines == NULL and are declared live before the session is consulted at all.
The session test is also inverted. A session with a perf_data attached is one being read from a perf.data file, i.e. exactly the case that is not live, while a live session such as 'perf top' passes data=NULL to __perf_session__new().
So a file-based session takes the live path and reads /proc/<pid>/exe on the analysing host, which at best describes an unrelated process that has since been given the recorded pid, and normally just fails, leaving e_machine as EM_NONE. The perf_env fallback that would have supplied the recorded architecture is never reached, and thread__e_machine() returns EM_HOST.
For a same-architecture recording this is invisible, since EM_HOST is the right answer anyway. Cross-architecture it is not: annotating an Alpha perf.data on an x86_64 host selects the x86 struct arch, so the Alpha disassembly is matched against the x86 instruction table. Alpha's 'ret' collides with x86's and gets ret_ops, while its calls and branches match nothing and are left unparsed, so no call target is resolved and no jump arrows are drawn.
Set the back pointer for the host machine and correct the session test. The new back pointer does not disturb the other reader of the field, machine__findnew_guest_code(), which machine__resolve() only calls when !machine__is_host(machine).
--- tools/perf/util/machine.c | 1 + tools/perf/util/thread.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/machine.c +1 -0
@@ -237,6 +237,7 @@ int machines__init(struct machines *machines) {int err =machine__init (&machines->host,"" ,HOST_KERNEL_ID ); + machines->host.machines = machines; machines->guests =RB_ROOT_CACHED ;return err; }
tools/perf/util/thread.c +1 -1
@@ -536,7 +536,7 @@ uint16_t thread__e_machine_endian(struct thread *thread, struct machine *machine struct perf_session, machines); - is_live = !!session->data; + is_live = !session->data; }/* Read from /proc/pid/exe if live. */ if (is_live) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 285/2651 perf test: Avoid call to missing cleanup function
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 4bbcb0fb9b866d05a2dd2db8bccd78be9d0476a9 ]
Cleanup function was removed by writing to /dev/null rather than temporary files. The exit path still had a call.
--- tools/perf/tests/shell/test_event_open_fallback.sh | 2 -- 1 file changed, 2 deletions(-)
tools/perf/tests/shell/test_event_open_fallback.sh +0 -2
@@ -57,8 +57,6 @@ ret=0 test_decrease_precise_ip || ret=$? ; count_result $ret ; ret=0 test_decrease_precise_ip_complicated || ret=$? ; count_result $ret ; ret=0 -cleanup - if [ ${err_cnt} -gt 0 ] ; then exit 1 fi
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 286/2651 perf trace: Enhance BTF type formatting to symbolise kernel function pointers
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit c6dd6161815d0c10ed24ad13fdad847bec63d961 ]
When BTF (BPF Type Format) metadata is loaded from vmlinux, 'perf trace' can inspect the precise C types of tracepoint and system call parameters. However, function pointer arguments are currently not recognised during BTF pretty-printing and default to hexadecimal output.
Introduce btf_is_func_ptr() to inspect BTF type hierarchies (i.e., traversing pointers, typedefs, and type modifiers) to determine whether a parameter resolves to a function prototype (BTF_KIND_FUNC_PROTO).
Generalise BTF type caching via syscall_arg_fmt__cache_btf_type() to handle structs, unions, enums, and function pointers alike. When a field is identified as a kernel function pointer, trace__btf_scnprintf() routes its value to syscall_arg__scnprintf_ksym(), enabling automatic zero-config symbolisation of kernel function pointers whenever BTF is available.
Stable-dep-of: 024b219744a9 ("perf trace: Add upper bound checks for augmented BTF struct printing")
--- tools/perf/builtin-trace.c | 106 +++++++++++++++++++++++++++++-------- 1 file changed, 85 insertions(+), 21 deletions(-)
tools/perf/builtin-trace.c +85 -21
@@ -122,6 +122,7 @@ struct syscall_arg_fmt {#ifdef HAVE_LIBBPF_SUPPORT const struct btf_type *type;int type_id;/* used in btf_dump */ +bool btf_type_cached;#endif };
@@ -950,21 +951,68 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,#define SCA_GETRANDOM_FLAGS syscall_arg__scnprintf_getrandom_flags#ifdef HAVE_LIBBPF_SUPPORT -static void syscall_arg_fmt__cache_btf_enum (struct syscall_arg_fmt *arg_fmt,struct btf *btf,char *type) +static bool btf_is_func_ptr (const struct btf *btf,const struct btf_type *type) { +int nr_ptrs =0 ; + +while (type) { +if (btf_is_ptr (type)) { +if (++nr_ptrs >1 ) +return false; + type =btf__type_by_id (btf, type->type); + }else if (btf_is_typedef (type) ||btf_is_mod (type)) { + type =btf__type_by_id (btf, type->type); + }else { +break ; + } + } +return nr_ptrs ==1 && type &&btf_is_func_proto (type); +} + +static void syscall_arg_fmt__cache_btf_type (struct syscall_arg_fmt *arg_fmt, +struct btf *btf,const char *type) +{ +char name[128 ]; +const char *pos; +size_t len =0 ;int id; - type =strstr (type,"enum " ); + arg_fmt->btf_type_cached = true; +if (type ==NULL )return ; - type +=5 ;// skip "enum " to get the enumeration name +/* Pointers to enums are memory addresses, not scalar enums */ +if (strstr (type,"enum " ) &&strchr (type,'*' )) +return ; + +if ((pos =strstr (type,"enum " )) !=NULL ) + pos +=5 ; +else if ((pos =strstr (type,"struct " )) !=NULL ) + pos +=7 ; +else if ((pos =strstr (type,"union " )) !=NULL ) + pos +=6 ; +else + pos = type; + +while (isspace (*pos)) + pos++; + +while ((isalnum (pos[len]) || pos[len] =='_' ) && len <sizeof (name) -1 ) { + name[len] = pos[len]; + len++; + } + name[len] ='\0' ; + +if (len ==0 ) +return ; - id =btf__find_by_name (btf, type); + id =btf__find_by_name (btf, name);if (id <0 )return ; arg_fmt->type =btf__type_by_id (btf, id); + arg_fmt->type_id = id; }static bool syscall_arg__strtoul_btf_enum (char *bf,size_t size,struct syscall_arg *arg,u64 *val)
@@ -998,10 +1046,8 @@ static bool syscall_arg__strtoul_btf_type(char *bf, size_t size, struct syscall_if (btf ==NULL )return false; -if (arg->fmt->type ==NULL ) { -// See if this is an enum -syscall_arg_fmt__cache_btf_enum (arg->fmt, btf, type); - } +if (!arg->fmt->btf_type_cached) +syscall_arg_fmt__cache_btf_type (arg->fmt, btf, type);// Now let's see if we have a BTF type resolved bt = arg->fmt->type;
@@ -1009,19 +1055,22 @@ static bool syscall_arg__strtoul_btf_type(char *bf, size_t size, struct syscall_return false;// If it is an enum: -if (btf_is_enum (arg->fmt->type)) +if (btf_is_enum (arg->fmt->type)) { +if (type &&strchr (type,'*' )) +return false;return syscall_arg__strtoul_btf_enum (bf, size, arg, val); + }return false; } -static size_t btf_enum_scnprintf (const struct btf_type *type,struct btf *btf,char *bf,size_t size,int val) +static size_t btf_enum_scnprintf (const struct btf_type *type,struct btf *btf,char *bf,size_t size,unsigned long val) {struct btf_enum *be =btf_enum (type);const unsigned int nr_entries =btf_vlen (type);for (unsigned int i =0 ; i < nr_entries; ++i, ++be) { -if (be->val == val) { +if ((unsigned long )(__u32 )be->val == val || (unsigned long )be->val == val) {return scnprintf (bf, size,"%s" ,btf__name_by_offset (btf, be->name_off)); }
@@ -1048,14 +1097,19 @@ static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf, .bf = bf, .size = size, }; -struct augmented_arg *augmented_arg = arg->augmented.args; +struct augmented_arg *augmented_arg;int type_id = arg->fmt->type_id, consumed;struct btf_dump *btf_dump;LIBBPF_OPTS (btf_dump_opts, dump_opts);LIBBPF_OPTS (btf_dump_type_data_opts, dump_data_opts); -if (arg ==NULL || arg->augmented.args ==NULL ) +if (arg ==NULL || arg->augmented.args ==NULL || arg->augmented.size <=0 || + arg->fmt ==NULL || !arg->fmt->from_user) +return 0 ; + + augmented_arg = arg->augmented.args; +if (augmented_arg->size <=0 )return 0 ; dump_data_opts.compact = true;
@@ -1066,8 +1120,10 @@ static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf,return 0 ;/* pretty print the struct data here */ -if (btf_dump__dump_type_data (btf_dump, type_id, arg->augmented.args->value, type->size, &dump_data_opts) <=0 ) +if (btf_dump__dump_type_data (btf_dump, type_id, arg->augmented.args->value, type->size, &dump_data_opts) <=0 ) { +btf_dump__free (btf_dump);return 0 ; + } consumed =sizeof (*augmented_arg) + augmented_arg->size; arg->augmented.args = ((void *)arg->augmented.args) + consumed;
@@ -1079,33 +1135,40 @@ static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf, }static size_t trace__btf_scnprintf (struct trace *trace,struct syscall_arg *arg,char *bf, -size_t size,int val,char *type) +size_t size,unsigned long val,char *type) {struct syscall_arg_fmt *arg_fmt = arg->fmt;if (trace->btf ==NULL )return 0 ; -if (arg_fmt->type ==NULL ) { -// Check if this is an enum and if we have the BTF type for it. -syscall_arg_fmt__cache_btf_enum (arg_fmt, trace->btf, type); - } +if (!arg_fmt->btf_type_cached) +syscall_arg_fmt__cache_btf_type (arg_fmt, trace->btf, type);// Did we manage to find a BTF type for the syscall/tracepoint argument? if (arg_fmt->type ==NULL )return 0 ; +if (type &&strchr (type,'*' )) { +if (btf_is_enum (arg_fmt->type) ||btf_is_func_ptr (trace->btf, arg_fmt->type)) +return 0 ; + } +if (btf_is_enum (arg_fmt->type))return btf_enum_scnprintf (arg_fmt->type, trace->btf, bf, size, val);else if (btf_is_struct (arg_fmt->type) ||btf_is_union (arg_fmt->type))return btf_struct_scnprintf (arg_fmt->type, trace->btf, bf, size, arg); +else if (btf_is_func_ptr (trace->btf, arg_fmt->type)) { + arg->val = val; +return syscall_arg__scnprintf_ksym (bf, size, arg); + }return 0 ; }#else // HAVE_LIBBPF_SUPPORT static size_t trace__btf_scnprintf (struct trace *trace__maybe_unused ,struct syscall_arg *arg__maybe_unused , -char *bf__maybe_unused ,size_t size__maybe_unused ,int val__maybe_unused , +char *bf__maybe_unused ,size_t size__maybe_unused ,unsigned long val__maybe_unused ,char *type__maybe_unused ) {return 0 ;
@@ -2529,7 +2592,8 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, default_scnprintf = sc->arg_fmt[arg.idx].scnprintf; -if (trace->force_btf || default_scnprintf ==NULL || default_scnprintf ==SCA_PTR ) { +if (trace->force_btf || default_scnprintf ==NULL || + default_scnprintf ==SCA_PTR || default_scnprintf ==SCA_KSYM ) { btf_printed =trace__btf_scnprintf (trace, &arg, bf + printed, size - printed, val, field->type);if (btf_printed) {
Signature · 1 line
2.53.0
Re: [PATCH 7.3 0286/2651] perf trace: Enhance BTF type formatting to symbolise kernel function pointers
Quoted 7 lines · Greg Kroah-Hartman
7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit
c6dd6161815d0c10ed24ad13fdad847bec63d961]
...
This does not build on i386:
Quoted 2 lines
tools/perf/builtin-trace.c +0
-0
...
Quoted 25 lines
tools/perf/builtin-trace.c +5
-5@@ -1079,33 +1135,40 @@ static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf, }static size_t trace__btf_scnprintf (struct trace *trace,struct syscall_arg *arg,char *bf, -size_t size,int val,char *type) +size_t size,unsigned long val,char *type) {struct syscall_arg_fmt *arg_fmt = arg->fmt;if (trace->btf ==NULL )return 0 ; -if (arg_fmt->type ==NULL ) { -// Check if this is an enum and if we have the BTF type for it. -syscall_arg_fmt__cache_btf_enum (arg_fmt, trace->btf, type); - } +if (!arg_fmt->btf_type_cached) +syscall_arg_fmt__cache_btf_type (arg_fmt, trace->btf, type);// Did we manage to find a BTF type for the syscall/tracepoint argument? if (arg_fmt->type ==NULL )return 0 ; +if (type &&strchr (type,'*' )) { +if (btf_is_enum (arg_fmt->type) ||btf_is_func_ptr (trace->btf, arg_fmt->type))
tools/perf/builtin-trace.c static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf, · line 1163
Quoted 10 lines
tools/perf/builtin-trace.c +6
-0+return 0 ; + } +if (btf_is_enum (arg_fmt->type))return btf_enum_scnprintf (arg_fmt->type, trace->btf, bf, size, val);else if (btf_is_struct (arg_fmt->type) ||btf_is_union (arg_fmt->type))return btf_struct_scnprintf (arg_fmt->type, trace->btf, bf, size, arg); +else if (btf_is_func_ptr (trace->btf, arg_fmt->type)) { + arg->val = val; +return syscall_arg__scnprintf_ksym (bf, size, arg);
builtin-trace.c:1164:24: error: implicit declaration of function ‘syscall_arg__scnprintf_ksym’; did you mean ‘syscall_arg__scnprintf_buf’? [-Wimplicit-function-declaration]
Quoted 13 lines
tools/perf/builtin-trace.c +2
-1+ }return 0 ; }#else // HAVE_LIBBPF_SUPPORT static size_t trace__btf_scnprintf (struct trace *trace__maybe_unused ,struct syscall_arg *arg__maybe_unused , -char *bf__maybe_unused ,size_t size__maybe_unused ,int val__maybe_unused , +char *bf__maybe_unused ,size_t size__maybe_unused ,unsigned long val__maybe_unused ,char *type__maybe_unused ) {return 0 ;
tools/perf/builtin-trace.c static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, · line 2596
Quoted 6 lines
tools/perf/builtin-trace.c +2
-1@@ -2529,7 +2592,8 @@ static size_t syscall__scnprintf_args(struct syscall *sc, char *bf, size_t size, default_scnprintf = sc->arg_fmt[arg.idx].scnprintf; -if (trace->force_btf || default_scnprintf ==NULL || default_scnprintf ==SCA_PTR ) { +if (trace->force_btf || default_scnprintf ==NULL || + default_scnprintf ==SCA_PTR || default_scnprintf ==SCA_KSYM ) {
builtin-trace.c:2597:82: error: ‘SCA_KSYM’ undeclared (first use in this function)
Quoted 3 lines
tools/perf/builtin-trace.c +0
-0btf_printed =trace__btf_scnprintf (trace, &arg, bf + printed, size - printed, val, field->type);if (btf_printed) {
Signature · 2 lines
js suse labs
Greg Kroah-Hartman
maintainerPATCH 287/2651 perf trace: Add upper bound checks for augmented BTF struct printing
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Tomlin <[email protected]>
[ Upstream commit 024b219744a949419b3c9e8aa23031c04428d9d6 ]
When pretty-printing augmented struct payloads using BTF via btf_struct_scnprintf(), augmented_arg->size is currently only validated against values <= 0.
However, several edge cases can result in size mismatches or buffer over-reads:
1. If arg->augmented.size is smaller than sizeof(*augmented_arg), dereferencing augmented_arg->size reads past the available buffer.
2. If augmented_arg->size exceeds arg->augmented.size - sizeof(*augmented_arg), calculating consumed = sizeof(*augmented_arg) + augmented_arg->size can overflow signed integer limits (e.g., with crafted INT_MAX values in an untrusted perf.data file) or cause arg->augmented.size to underflow. This advances arg->augmented.args out of bounds, corrupting the parsing state for subsequent arguments in multi-argument syscalls.
3. If the captured payload is truncated (e.g., short reads in BPF, or during cross-architecture analysis such as replaying a 32-bit perf.data on a 64-bit host where host BTF type->size exceeds the 32-bit target payload), passing type->size to btf_dump__dump_type_data() causes libbpf to read past the end of the payload buffer.
Enforce an upper bound on augmented_arg->size against the remaining buffer (arg->augmented.size - sizeof(*augmented_arg)) and verify that the captured payload contains at least type->size bytes before passing it to btf_dump__dump_type_data().
--- tools/perf/builtin-trace.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/builtin-trace.c +3 -2
@@ -1104,12 +1104,13 @@ static size_t btf_struct_scnprintf(const struct btf_type *type, struct btf *btf,LIBBPF_OPTS (btf_dump_opts, dump_opts);LIBBPF_OPTS (btf_dump_type_data_opts, dump_data_opts); -if (arg ==NULL || arg->augmented.args ==NULL || arg->augmented.size <=0 || +if (arg ==NULL || arg->augmented.args ==NULL || arg->augmented.size < (int )sizeof (*augmented_arg) || arg->fmt ==NULL || !arg->fmt->from_user)return 0 ; augmented_arg = arg->augmented.args; -if (augmented_arg->size <=0 ) +if (augmented_arg->size <=0 || augmented_arg->size > arg->augmented.size - (int )sizeof (*augmented_arg) || + (size_t )augmented_arg->size < type->size)return 0 ; dump_data_opts.compact = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 288/2651 libbpf: Fix array comparison in BTF dedup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mingpei CAO <[email protected]>
[ Upstream commit e62c5b97d6c4c657d6fad7dd3523fda33a936979 ]
btf_dedup_identical_types() reads both array descriptors from t1, skipping comparisons of their referenced types. This can incorrectly merge distinct structs and corrupt CO-RE relocation metadata.
Read the second descriptor from t2.
--- tools/lib/bpf/btf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/btf.c +1 -1
@@ -4831,7 +4831,7 @@ static bool btf_dedup_identical_types(struct btf_dedup *d, __u32 id1, __u32 id2,return false; a1 =btf_array (t1); - a2 =btf_array (t1); + a2 =btf_array (t2);if (a1->index_type != a2->index_type && !btf_dedup_identical_types (d, a1->index_type, a2->index_type, depth -1 ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 289/2651 mtd: spinand: Fix spinand_manufacturer_ops kernel-doc
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 7e874b1750a40f3dc9a629aeb72eba09c77f77e9 ]
The kernel-doc heading for struct spinand_manufacturer_ops misspells and truncates its name as manufacurer_ops. As a result, kernel-doc cannot match the comment to the structure declaration.
Use the structure's actual name.
--- include/linux/mtd/spinand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/spinand.h +1 -1
@@ -399,7 +399,7 @@ struct spinand_devid { };/** -* struct manufacurer_ops - SPI NAND manufacturer specific operations +* struct spinand_manufacturer_ops - SPI NAND manufacturer specific operations * @init: initialize a SPI NAND device * @cleanup: cleanup a SPI NAND device *
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 290/2651 perf stat: Avoid uninitialized memory read on error
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 93fd7adf1a47c61ef81b33c8fdd9cb4e4ea0bdcb ]
If has_supported_counters fails then msg was passed to ui__error regardless of whether an error was written into msg leading to reading uninitialized memory. Avoid this by always terminating msg at initialization.
Opportunistically reduce the scope of msg to make its use clearer.
--- tools/perf/builtin-stat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/builtin-stat.c +3 -1
@@ -777,7 +777,6 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx)int interval = stat_config.interval;int times = stat_config.times;int timeout = stat_config.timeout; -char msg[BUFSIZ ];unsigned long long t0, t1;struct evsel *counter;size_t l;
@@ -908,6 +907,9 @@ static int __run_perf_stat(int argc, const char **argv, int run_idx) } }if (!has_supported_counters && !stat_config.null_run) { +char msg[BUFSIZ ]; + + msg[0 ] ='\0' ;if (open_err) {evsel__open_strerror (evlist__first (evsel_list), &target, open_err, msg,sizeof (msg));
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 291/2651 ASoC: codecs: sma1307: validate setting firmware layout
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit af0f4f7a042e39bf70fa7406351b26efead18dff ]
sma1307_setting_loaded() checks a byte count against an element count, then reads an eight-int header and a fixed default table from the firmware. It also trusts the mode count while indexing a five-entry mode_set array.
Validate the byte-to-int conversion, fixed header/default extent, mode count, and exact mode table layout before parsing the setting file.
--- sound/soc/codecs/sma1307.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
sound/soc/codecs/sma1307.c +12 -2
@@ -1701,7 +1701,9 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil __func__, setting_file, ERR_PTR(ret)); sma1307->set.status = false;return ; - }else if ((fw->size) <SMA1307_SETTING_HEADER_SIZE ) { + }else if (fw->size %sizeof (int ) || + fw->size < (SMA1307_SETTING_HEADER_SIZE + +SMA1307_SETTING_DEFAULT_SIZE ) *sizeof (int )) {dev_err (sma1307->dev,"%s: Invalid file\n" , __func__); sma1307->set.status = false;return ;
@@ -1720,6 +1722,10 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil sma1307->set.checksum = data[sma1307->set.header_size -2 ]; sma1307->set.num_mode = data[sma1307->set.header_size -1 ]; num_mode = sma1307->set.num_mode; +if (num_mode <0 || num_mode >ARRAY_SIZE (sma1307->set.mode_set)) { + sma1307->set.status = false; +return ; + } sma1307->set.header = devm_kmalloc_array(sma1307->dev, sma1307->set.header_size, sizeof(int),
@@ -1755,7 +1761,11 @@ static void sma1307_setting_loaded(struct sma1307_priv *sma1307, const char *fil/* MODE */ offset = sma1307->set.header_size + sma1307->set.def_size; - sma1307->set.mode_size =DIV_ROUND_CLOSEST (size - offset, num_mode +1 ); +if ((size - offset) % (num_mode +1 )) { + sma1307->set.status = false; +return ; + } + sma1307->set.mode_size = (size - offset) / (num_mode +1 );for (int i =0 ; i < num_mode; i++) { sma1307->set.mode_set[i] = devm_kzalloc(sma1307->dev,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 292/2651 ASoC: sta32x: make power restoration transactional
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 3e71dc4508bc84862dc3644e3b6a5b966bff22ad ]
sta32x_set_bias_level() enables the codec supplies, restores the coefficient and register state, and then starts the watchdog. Register access errors in the mute and coefficient helpers and the cache replay are discarded, allowing DAPM to publish STANDBY for a partially restored codec.
Propagate every operation in the local restore transaction, including the final standby-state write. Start the watchdog only after that write succeeds. On failure, hold reset, mark the cache dirty, disable the supplies and report a cleanup failure while preserving the primary error. The DAPM bias callback consumes the returned error independently of component resume handling.
--- sound/soc/codecs/sta32x.c | 101 +++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 24 deletions(-)
sound/soc/codecs/sta32x.c +77 -24
@@ -342,27 +342,48 @@ static int sta32x_sync_coef_shadow(struct snd_soc_component *component) {struct sta32x_priv *sta32x =snd_soc_component_get_drvdata (component);unsigned int cfud; -int i; +int i, ret;/* preserve reserved bits in STA32X_CFUD */ -regmap_read (sta32x->regmap,STA32X_CFUD , &cfud); + ret =regmap_read (sta32x->regmap,STA32X_CFUD , &cfud); +if (ret) +return ret; + cfud &=0xf0 ;for (i =0 ; i <STA32X_COEF_COUNT ; i++) { -regmap_write (sta32x->regmap,STA32X_CFADDR2 , i); -regmap_write (sta32x->regmap,STA32X_B1CF1 , - (sta32x->coef_shadow[i] >>16 ) &0xff ); -regmap_write (sta32x->regmap,STA32X_B1CF2 , - (sta32x->coef_shadow[i] >>8 ) &0xff ); -regmap_write (sta32x->regmap,STA32X_B1CF3 , - (sta32x->coef_shadow[i]) &0xff ); + ret =regmap_write (sta32x->regmap,STA32X_CFADDR2 , i); +if (ret) +return ret; + + ret =regmap_write (sta32x->regmap,STA32X_B1CF1 , + (sta32x->coef_shadow[i] >>16 ) &0xff ); +if (ret) +return ret; + + ret =regmap_write (sta32x->regmap,STA32X_B1CF2 , + (sta32x->coef_shadow[i] >>8 ) &0xff ); +if (ret) +return ret; + + ret =regmap_write (sta32x->regmap,STA32X_B1CF3 , + sta32x->coef_shadow[i] &0xff ); +if (ret) +return ret; +/* * chip documentation does not say if the bits are * self-clearing, so do it explicitly */ -regmap_write (sta32x->regmap,STA32X_CFUD , cfud); -regmap_write (sta32x->regmap,STA32X_CFUD , cfud |0x01 ); + ret =regmap_write (sta32x->regmap,STA32X_CFUD , cfud); +if (ret) +return ret; + + ret =regmap_write (sta32x->regmap,STA32X_CFUD , cfud |0x01 ); +if (ret) +return ret; } +return 0 ; }
@@ -370,15 +391,24 @@ static int sta32x_cache_sync(struct snd_soc_component *component) {struct sta32x_priv *sta32x =snd_soc_component_get_drvdata (component);unsigned int mute; -int rc; +int restore_ret, ret;/* mute during register sync */ -regmap_read (sta32x->regmap,STA32X_MMUTE , &mute); -regmap_write (sta32x->regmap,STA32X_MMUTE , mute |STA32X_MMUTE_MMUTE ); -sta32x_sync_coef_shadow (component); - rc =regcache_sync (sta32x->regmap); -regmap_write (sta32x->regmap,STA32X_MMUTE , mute); -return rc; + ret =regmap_read (sta32x->regmap,STA32X_MMUTE , &mute); +if (ret) +return ret; + + ret =regmap_write (sta32x->regmap,STA32X_MMUTE , + mute |STA32X_MMUTE_MMUTE ); +if (ret) +return ret; + + ret =sta32x_sync_coef_shadow (component); +if (!ret) + ret =regcache_sync (sta32x->regmap); + + restore_ret =regmap_write (sta32x->regmap,STA32X_MMUTE , mute); +return ret ?: restore_ret; }/* work around ESD issue where sta32x resets and loses all configuration */
@@ -794,9 +824,9 @@ static int sta32x_startup_sequence(struct sta32x_priv *sta32x)static int sta32x_set_bias_level (struct snd_soc_component *component,enum snd_soc_bias_level level) { -int ret;struct sta32x_priv *sta32x =snd_soc_component_get_drvdata (component);struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component); +int cleanup_ret, ret;dev_dbg (component->dev,"level = %d\n" , level);switch (level) {
@@ -820,15 +850,28 @@ static int sta32x_set_bias_level(struct snd_soc_component *component,return ret; } -sta32x_startup_sequence (sta32x); -sta32x_cache_sync (component); + ret =sta32x_startup_sequence (sta32x); +if (!ret) + ret =sta32x_cache_sync (component); +if (ret) + goto restore_failed; + + ret =regmap_update_bits (sta32x->regmap,STA32X_CONFF , +STA32X_CONFF_PWDN |STA32X_CONFF_EAPD , +0 ); +if (ret) + goto restore_failed; +sta32x_watchdog_start (sta32x); +break ; }/* Power down */ -regmap_update_bits (sta32x->regmap,STA32X_CONFF , -STA32X_CONFF_PWDN |STA32X_CONFF_EAPD , -0 ); + ret =regmap_update_bits (sta32x->regmap,STA32X_CONFF , +STA32X_CONFF_PWDN |STA32X_CONFF_EAPD , +0 ); +if (ret) +return ret;break ;
@@ -846,6 +889,16 @@ static int sta32x_set_bias_level(struct snd_soc_component *component,break ; }return 0 ; + +restore_failed: +gpiod_set_value (sta32x->gpiod_nreset,0 ); +regcache_mark_dirty (sta32x->regmap); + cleanup_ret =regulator_bulk_disable (ARRAY_SIZE (sta32x->supplies), + sta32x->supplies); +if (cleanup_ret) +dev_warn (component->dev,"Failed to disable supplies: %d\n" , + cleanup_ret); +return ret; }static const struct snd_soc_dai_ops sta32x_dai_ops = {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 293/2651 spi: amlogic-spisg: check clk_prepare_enable() return value
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Youhong <[email protected]>
[ Upstream commit c595dcbce20f55c98cd9b0003c26db3787e0ddee ]
The driver ignored clk_prepare_enable() failures for sclk during probe and for core/sclk during runtime resume. Propagate the errors and, on resume, disable core if enabling sclk fails, so probe/resume do not continue with clocks disabled or report success falsely.
--- drivers/spi/spi-amlogic-spisg.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-)
drivers/spi/spi-amlogic-spisg.c +14 -3
@@ -714,7 +714,9 @@ static int aml_spisg_clk_init(struct spisg_device *spisg, void __iomem *base)return PTR_ERR (spisg->sclk); } -clk_prepare_enable (spisg->sclk); + ret =clk_prepare_enable (spisg->sclk); +if (ret) +return ret;return 0 ; }
@@ -851,9 +853,18 @@ static int spisg_suspend_runtime(struct device *dev)static int spisg_resume_runtime (struct device *dev) {struct spisg_device *spisg =dev_get_drvdata (dev); +int ret; + + ret =clk_prepare_enable (spisg->core); +if (ret) +return ret; + + ret =clk_prepare_enable (spisg->sclk); +if (ret) { +clk_disable_unprepare (spisg->core); +return ret; + } -clk_prepare_enable (spisg->core); -clk_prepare_enable (spisg->sclk);pinctrl_pm_select_default_state (&spisg->pdev->dev);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 294/2651 dmaengine: sun6i-dma: Fix use-after-free in error handling paths
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit f472919f4c0650d7fb22bb230eacaada0c6ee951 ]
In error handling paths, the for loop frees v_lli in the loop body, then accesses v_lli->v_lli_next and v_lli->p_lli_next in the increment expression, which is use-after-free.
Fix by refactoring the cleanup into a helper function sun6i_dma_free_desc() that saves both the next virtual and physical pointers before freeing the current node, preventing the use-after-free.
--- drivers/dma/sun6i-dma.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/dma/sun6i-dma.c +16 -15
@@ -408,16 +408,12 @@ static inline void sun6i_dma_dump_lli(struct sun6i_vchan *vchan, v_lli->len, v_lli->para, v_lli->p_lli_next); } -static void sun6i_dma_free_desc (struct virt_dma_desc *vd) +static void sun6i_dma_free_desc (struct sun6i_dma_dev *sdev, +struct sun6i_desc *txd) { -struct sun6i_desc *txd =to_sun6i_desc (&vd->tx); -struct sun6i_dma_dev *sdev =to_sun6i_dma_dev (vd->tx.chan->device);struct sun6i_dma_lli *v_lli, *v_next;dma_addr_t p_lli, p_next; -if (unlikely (!txd)) -return ; - p_lli = txd->p_lli; v_lli = txd->v_lli;
@@ -434,6 +430,17 @@ static void sun6i_dma_free_desc(struct virt_dma_desc *vd)kfree (txd); } +static void sun6i_dma_free_desc_virt (struct virt_dma_desc *vd) +{ +struct sun6i_desc *txd =to_sun6i_desc (&vd->tx); +struct sun6i_dma_dev *sdev =to_sun6i_dma_dev (vd->tx.chan->device); + +if (unlikely (!txd)) +return ; + +sun6i_dma_free_desc (sdev, txd); +} +static int sun6i_dma_start_desc (struct sun6i_vchan *vchan) {struct sun6i_dma_dev *sdev =to_sun6i_dma_dev (vchan->vc.chan.device);
@@ -790,10 +797,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(return vchan_tx_prep (&vchan->vc, &txd->vd, flags); err_lli_free: -for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli; - p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next) -dma_pool_free (sdev->pool, v_lli, p_lli); -kfree (txd); +sun6i_dma_free_desc (sdev, txd);return NULL ; }
@@ -871,10 +875,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(return vchan_tx_prep (&vchan->vc, &txd->vd, flags); err_lli_free: -for (p_lli = txd->p_lli, v_lli = txd->v_lli; v_lli; - p_lli = v_lli->p_lli_next, v_lli = v_lli->v_lli_next) -dma_pool_free (sdev->pool, v_lli, p_lli); -kfree (txd); +sun6i_dma_free_desc (sdev, txd);return NULL ; }
@@ -1429,7 +1430,7 @@ static int sun6i_dma_probe(struct platform_device *pdev)struct sun6i_vchan *vchan = &sdc->vchans[i];INIT_LIST_HEAD (&vchan->node); - vchan->vc.desc_free = sun6i_dma_free_desc; + vchan->vc.desc_free = sun6i_dma_free_desc_virt;vchan_init (&vchan->vc, &sdc->slave); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 295/2651 dmaengine: at_hdmac: Fix use-after-free by proper tasklet cleanup
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 13f2d32a09609d083ace2d589fbdc68e970ae34c ]
Current cleanup paths have a use-after-free vulnerability:
- vchan_init() creates tasklets that access at_dma_chan memory
- free_irq() only waits for IRQ handler, NOT tasklets
- atdma is devm-managed and freed after probe/remove
- Running tasklets accessing freed memory → Use-After-Free!
The fix requires careful ordering:
- free_irq() FIRST to synchronize with running IRQ handlers and prevent them from scheduling new tasklets
- Then kill tasklets to wait for already-scheduled ones to complete
- Only then free other resources
--- drivers/dma/at_hdmac.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-)
drivers/dma/at_hdmac.c +19 -9
@@ -1940,6 +1940,20 @@ static void at_dma_off(struct at_dma *atdma)cpu_relax (); } +static void at_dma_cleanup_channels (struct at_dma *atdma) +{ +struct dma_chan *chan, *_chan; +int i =0 ; + +list_for_each_entry_safe (chan, _chan, &atdma->dma_device.channels, + device_node) { +/* Disable interrupts */ +atc_disable_chan_irq (atdma, i++); +tasklet_kill (&to_at_dma_chan (chan)->vc.task); +list_del (&chan->device_node); + } +} +static int __init at_dma_probe (struct platform_device *pdev) {struct at_dma *atdma;
@@ -2105,6 +2119,8 @@ static int __init at_dma_probe(struct platform_device *pdev) err_of_dma_controller_register:dma_async_device_unregister (&atdma->dma_device); err_dma_async_device_register: +disable_irq (platform_get_irq (pdev,0 )); +at_dma_cleanup_channels (atdma);dma_pool_destroy (atdma->memset_pool); err_memset_pool_create:dma_pool_destroy (atdma->lli_pool);
@@ -2118,23 +2134,17 @@ static int __init at_dma_probe(struct platform_device *pdev)static void at_dma_remove (struct platform_device *pdev) {struct at_dma *atdma =platform_get_drvdata (pdev); -struct dma_chan *chan, *_chan;at_dma_off (atdma);if (pdev->dev.of_node)of_dma_controller_free (pdev->dev.of_node);dma_async_device_unregister (&atdma->dma_device); -dma_pool_destroy (atdma->memset_pool); -dma_pool_destroy (atdma->lli_pool);free_irq (platform_get_irq (pdev,0 ), atdma); -list_for_each_entry_safe (chan, _chan, &atdma->dma_device.channels, - device_node) { -/* Disable interrupts */ -atc_disable_chan_irq (atdma, chan->chan_id); -list_del (&chan->device_node); - } +at_dma_cleanup_channels (atdma); +dma_pool_destroy (atdma->memset_pool); +dma_pool_destroy (atdma->lli_pool);clk_disable_unprepare (atdma->clk); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 296/2651 dmaengine: mediatek: hsdma: fix runtime PM leak on init failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit f10d96b1c549a2f43506e9bf847196839808b8dc ]
mtk_hsdma_hw_init() enables runtime PM and gets a runtime PM reference before enabling the HSDMA clock. It currently ignores failures from pm_runtime_get_sync(); if runtime resume fails, the usage count remains held. If clk_prepare_enable() then fails, the usage count remains held.
Use devm_pm_runtime_enable() to manage runtime PM enablement, and use pm_runtime_resume_and_get() so resume failures do not leak the usage count. If clk_prepare_enable() fails after a successful runtime resume, drop the runtime PM reference before returning.
The probe path also ignores the return value from mtk_hsdma_hw_init(), so a failed hardware init can continue as a successful probe. Propagate mtk_hsdma_hw_init() failures from probe, while keeping a separate unwind label so mtk_hsdma_hw_deinit() is only called after hardware init succeeds.
--- drivers/dma/mediatek/mtk-hsdma.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/dma/mediatek/mtk-hsdma.c +19 -7
@@ -848,17 +848,27 @@ static int mtk_hsdma_hw_init(struct mtk_hsdma_device *hsdma) {int err; -pm_runtime_enable (hsdma2dev (hsdma)); -pm_runtime_get_sync (hsdma2dev (hsdma)); + err =devm_pm_runtime_enable (hsdma2dev (hsdma)); +if (err) +return err; + + err =pm_runtime_resume_and_get (hsdma2dev (hsdma)); +if (err <0 ) +return err; err =clk_prepare_enable (hsdma->clk);if (err) -return err; + goto err_put_pm;mtk_dma_write (hsdma,MTK_HSDMA_INT_ENABLE ,0 );mtk_dma_write (hsdma,MTK_HSDMA_GLO ,MTK_HSDMA_GLO_DEFAULT );return 0 ; + +err_put_pm: +pm_runtime_put_sync (hsdma2dev (hsdma)); + +return err; }static int mtk_hsdma_hw_deinit (struct mtk_hsdma_device *hsdma)
@@ -868,7 +878,6 @@ static int mtk_hsdma_hw_deinit(struct mtk_hsdma_device *hsdma)clk_disable_unprepare (hsdma->clk);pm_runtime_put_sync (hsdma2dev (hsdma)); -pm_runtime_disable (hsdma2dev (hsdma));return 0 ; }
@@ -983,7 +992,9 @@ static int mtk_hsdma_probe(struct platform_device *pdev) goto err_unregister; } -mtk_hsdma_hw_init (hsdma); + err =mtk_hsdma_hw_init (hsdma); +if (err) + goto err_free; err = devm_request_irq(&pdev->dev, hsdma->irq, mtk_hsdma_irq, 0,
@@ -991,7 +1002,7 @@ static int mtk_hsdma_probe(struct platform_device *pdev)if (err) {dev_err (&pdev->dev,"request_irq failed with err %d\n" , err); - goto err_free; + goto err_deinit; }platform_set_drvdata (pdev, hsdma);
@@ -1000,8 +1011,9 @@ static int mtk_hsdma_probe(struct platform_device *pdev)return 0 ; -err_free: +err_deinit:mtk_hsdma_hw_deinit (hsdma); +err_free:of_dma_controller_free (pdev->dev.of_node); err_unregister:dma_async_device_unregister (dd);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 297/2651 dmaengine: img-mdc: Fix runtime PM usage counter leak
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 4a1a2d8b8529cc569b769b92fcd71c53805cbeb2 ]
pm_runtime_get_sync() leaves the IMG MDC device's usage counter incremented when runtime resume fails. mdc_alloc_chan_resources() returns that error to the DMA core, so the channel's client count is not incremented and mdc_free_chan_resources() is not called to drop the reference. Repeated allocation attempts can therefore accumulate usage references and prevent runtime suspend.
Use pm_runtime_resume_and_get() so a failed resume does not retain a usage reference while successful allocations remain paired with mdc_free_chan_resources(). DMA core only treats negative return values as allocation failures, so the helper's zero success return preserves behavior.
This issue was found by a static analysis checker and confirmed by manual source review.
--- drivers/dma/img-mdc-dma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/img-mdc-dma.c +1 -1
@@ -738,7 +738,7 @@ static int mdc_alloc_chan_resources(struct dma_chan *chan)struct mdc_chan *mchan =to_mdc_chan (chan);struct device *dev =mdma2dev (mchan->mdma); -return pm_runtime_get_sync (dev); +return pm_runtime_resume_and_get (dev); }static void mdc_free_chan_resources (struct dma_chan *chan)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 298/2651 dmaengine: zynqmp_dma: Fix PM rollback on sw_desc_pool alloc failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Golla Nagendra <[email protected]>
[ Upstream commit f2f44b952ea6e0c600e92ea21fcaa83cafeedf6e ]
If sw_desc_pool allocation fails after pm_runtime_resume_and_get() succeeds in zynqmp_dma_alloc_chan_resources(), the error path returns without dropping the runtime PM reference.
Route that failure path through err_pm so the runtime PM reference is balanced before returning the error.
--- drivers/dma/xilinx/zynqmp_dma.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/dma/xilinx/zynqmp_dma.c +8 -2
@@ -483,8 +483,10 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)return ret; chan->sw_desc_pool =kzalloc_objs (*desc,ZYNQMP_DMA_NUM_DESCS ); -if (!chan->sw_desc_pool) -return -ENOMEM ; +if (!chan->sw_desc_pool) { + ret = -ENOMEM ; + goto err_pm; + } chan->idle = true; chan->desc_free_cnt =ZYNQMP_DMA_NUM_DESCS ;
@@ -516,6 +518,10 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan) }return ZYNQMP_DMA_NUM_DESCS ; + +err_pm: +pm_runtime_put_autosuspend (chan->dev); +return ret; }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 299/2651 dmaengine: zynqmp_dma: Free sw_desc_pool on desc_pool_v alloc failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Golla Nagendra <[email protected]>
[ Upstream commit 4ea99b14b3bd955d768666941e2e03ba186b52f5 ]
In zynqmp_dma_alloc_chan_resources(), sw_desc_pool is allocated before desc_pool_v. If dma_alloc_coherent() for desc_pool_v fails, the function currently exits through the runtime PM rollback path but leaves the already allocated sw_desc_pool behind.
Add a dedicated err_free_sw_desc_pool label for the desc_pool_v failure path, free sw_desc_pool there, then fall through to err_pm for pm_runtime_put_autosuspend().
This keeps the error unwind symmetric and avoids leaking the software descriptor pool on coherent descriptor allocation failure.
--- drivers/dma/xilinx/zynqmp_dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/dma/xilinx/zynqmp_dma.c +7 -2
@@ -504,8 +504,10 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan) (2 *ZYNQMP_DMA_DESC_SIZE (chan) *ZYNQMP_DMA_NUM_DESCS ), &chan->desc_pool_p, GFP_KERNEL); -if (!chan->desc_pool_v) -return -ENOMEM ; +if (!chan->desc_pool_v) { + ret = -ENOMEM ; + goto err_free_sw_desc_pool; + }for (i =0 ; i <ZYNQMP_DMA_NUM_DESCS ; i++) { desc = chan->sw_desc_pool + i;
@@ -519,6 +521,9 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)return ZYNQMP_DMA_NUM_DESCS ; +err_free_sw_desc_pool: +kfree (chan->sw_desc_pool); + chan->sw_desc_pool =NULL ; err_pm:pm_runtime_put_autosuspend (chan->dev);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 300/2651 dmaengine: zynqmp_dma: Fix chan probe/remove error handling
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Golla Nagendra <[email protected]>
[ Upstream commit 0266dac57019201a14a81245d22750ab221d6c66 ]
Keep the real platform_get_irq() error by returning ret directly, stage IRQ setup via a local ret variable, and assign chan->irq only after devm_request_irq() succeeds.
Initialize chan->irq to -1 and initialize chan->common.device_node before it may be touched by teardown. In channel remove, free IRQ only for valid IRQ numbers and delete the channel node only when it is linked.
Register the channel node only after successful IRQ setup. On channel probe failure in zynqmp_dma_probe(), route cleanup through the existing free_chan_resources teardown path.
--- drivers/dma/xilinx/zynqmp_dma.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-)
drivers/dma/xilinx/zynqmp_dma.c +17 -11
@@ -205,7 +205,7 @@ struct zynqmp_dma_desc_sw {* @desc_pool_p: Physical allocated descriptor base * @desc_free_cnt: Descriptor available count * @dev: The dma device -* @irq: Channel IRQ +* @irq: Linux IRQ number, or -1 when not registered * @is_dmacoherent: Tells whether dma operations are coherent or not * @tasklet: Cleanup work after irq * @idle : Channel status;
@@ -896,10 +896,11 @@ static void zynqmp_dma_chan_remove(struct zynqmp_dma_chan *chan)if (!chan)return ; -if (chan->irq) +if (chan->irq >=0 )devm_free_irq (chan->zdev->dev, chan->irq, chan);tasklet_kill (&chan->tasklet); -list_del (&chan->common.device_node); +if (!list_empty (&chan->common.device_node)) +list_del (&chan->common.device_node); }/**
@@ -915,13 +916,14 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev,struct zynqmp_dma_chan *chan;struct device_node *node = pdev->dev.of_node;const struct zynqmp_dma_config *match_data; -int err; +int err, ret; chan =devm_kzalloc (zdev->dev,sizeof (*chan),GFP_KERNEL );if (!chan)return -ENOMEM ; chan->dev = zdev->dev; chan->zdev = zdev; + chan->irq =-1 ; chan->regs =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (chan->regs))
@@ -954,22 +956,26 @@ static int zynqmp_dma_chan_probe(struct zynqmp_dma_device *zdev,INIT_LIST_HEAD (&chan->pending_list);INIT_LIST_HEAD (&chan->done_list);INIT_LIST_HEAD (&chan->free_list); +INIT_LIST_HEAD (&chan->common.device_node);dma_cookie_init (&chan->common); chan->common.device = &zdev->common; -list_add_tail (&chan->common.device_node, &zdev->common.channels); -zynqmp_dma_init (chan); - chan->irq =platform_get_irq (pdev,0 ); -if (chan->irq <0 ) -return -ENXIO ; - err =devm_request_irq (&pdev->dev, chan->irq, zynqmp_dma_irq_handler,0 , + ret =platform_get_irq (pdev,0 ); +if (ret <0 ) +return ret; + + err =devm_request_irq (&pdev->dev, ret, zynqmp_dma_irq_handler,0 ,"zynqmp-dma" , chan);if (err)return err; + chan->irq = ret; + chan->desc_size =sizeof (struct zynqmp_dma_desc_ll ); chan->idle = true; +list_add_tail (&chan->common.device_node, &zdev->common.channels); +return 0 ; }
@@ -1134,7 +1140,7 @@ static int zynqmp_dma_probe(struct platform_device *pdev) ret =zynqmp_dma_chan_probe (zdev, pdev);if (ret) {dev_err_probe (&pdev->dev, ret,"Probing channel failed\n" ); - goto err_disable_pm; + goto free_chan_resources; } p->dst_addr_widths =BIT (zdev->chan->bus_width /8 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 301/2651 dmaengine: dw-axi-dmac: convert clock handling to clk_bulk API
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chaithanya Lagisetty <[email protected]>
[ Upstream commit c843417e6d6b55e24318e2edf405566e70786d3b ]
The driver managed its two mandatory clocks (core-clk and cfgr-clk) individually. This was error prone: axi_dma_resume() enabled cfgr_clk and then core_clk, and if enabling core_clk failed it returned the error without disabling cfgr_clk, leaving the clock refcount unbalanced.
Convert the driver to the clk_bulk API. The two clocks are always acquired, enabled and disabled together, so a clk_bulk_data array expresses this naturally and shrinks the get/enable/disable paths. clk_bulk_prepare_enable() also unwinds any clock it already enabled when a later one fails, which fixes the resume imbalance.
--- .../dma/dw-axi-dmac/dw-axi-dmac-platform.c | 28 ++++++++----------- drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 3 +- 2 files changed, 13 insertions(+), 18 deletions(-)
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +12 -16
@@ -1320,8 +1320,7 @@ static int axi_dma_suspend(struct axi_dma_chip *chip)axi_dma_irq_disable (chip);axi_dma_disable (chip); -clk_disable_unprepare (chip->core_clk); -clk_disable_unprepare (chip->cfgr_clk); +clk_bulk_disable_unprepare (ARRAY_SIZE (chip->clks), chip->clks);return 0 ; }
@@ -1330,11 +1329,7 @@ static int axi_dma_resume(struct axi_dma_chip *chip) {int ret; - ret =clk_prepare_enable (chip->cfgr_clk); -if (ret <0 ) -return ret; - - ret =clk_prepare_enable (chip->core_clk); + ret =clk_bulk_prepare_enable (ARRAY_SIZE (chip->clks), chip->clks);if (ret <0 )return ret;
@@ -1524,13 +1519,11 @@ static int dw_probe(struct platform_device *pdev) chip->dw->hdata->use_cfg2 = !!(flags &AXI_DMA_FLAG_USE_CFG2 ); - chip->core_clk =devm_clk_get (chip->dev,"core-clk" ); -if (IS_ERR (chip->core_clk)) -return PTR_ERR (chip->core_clk); - - chip->cfgr_clk =devm_clk_get (chip->dev,"cfgr-clk" ); -if (IS_ERR (chip->cfgr_clk)) -return PTR_ERR (chip->cfgr_clk); + chip->clks[0 ].id ="core-clk" ; + chip->clks[1 ].id ="cfgr-clk" ; + ret =devm_clk_bulk_get (chip->dev,ARRAY_SIZE (chip->clks), chip->clks); +if (ret) +return dev_err_probe (chip->dev, ret,"failed to get clocks\n" ); ret =parse_device_properties (chip);if (ret)
@@ -1640,10 +1633,13 @@ static void dw_remove(struct platform_device *pdev)struct dw_axi_dma *dw = chip->dw;struct axi_dma_chan *chan, *_chan;u32 i; +int ret;/* Enable clk before accessing to registers */ -clk_prepare_enable (chip->cfgr_clk); -clk_prepare_enable (chip->core_clk); + ret =clk_bulk_prepare_enable (ARRAY_SIZE (chip->clks), chip->clks); +if (ret) +dev_warn (chip->dev,"failed to enable clocks before remove: %d\n" , + ret);axi_dma_irq_disable (chip);for (i =0 ; i < dw->hdata->nr_channels; i++) {axi_chan_disable (&chip->dw->chan[i]);
drivers/dma/dw-axi-dmac/dw-axi-dmac.h +1 -2
@@ -69,8 +69,7 @@ struct axi_dma_chip {int irq[DMAC_MAX_CHANNELS ];void __iomem *regs;void __iomem *apb_regs; -struct clk *core_clk; -struct clk *cfgr_clk; +struct clk_bulk_data clks[2 ];struct dw_axi_dma *dw; };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 302/2651 dmaengine: xilinx_dma: Fix MCDMA descriptor fields based on DMA direction
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Neeli <[email protected]>
[ Upstream commit b70ab341088b2114dcbc7be868588f3e97893e6a ]
The MCDMA BD format differs between memory-to-device (MM2S) and device-to-memory (S2MM) directions, but the driver was using generic 'status' and 'sideband_status' fields for both. This led to incorrect residue calculations when the hardware updates direction-specific fields.
Refactor the descriptor structure to use unions with direction-specific field mappings, and update the residue calculation logic to select the correct status field based on DMA direction.
This matches the hardware descriptor layout and fixes incorrect residue reporting.
--- drivers/dma/xilinx/xilinx_dma.c | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
drivers/dma/xilinx/xilinx_dma.c +19 -7
@@ -223,6 +223,7 @@#define XILINX_MCDMA_IRQ_ERR_MASK BIT(7)#define XILINX_MCDMA_BD_EOP BIT(30)#define XILINX_MCDMA_BD_SOP BIT(31) +#define XILINX_MCDMA_BD_HW_SIZE 64/** * struct xilinx_vdma_desc_hw - Hardware Descriptor
@@ -277,8 +278,10 @@ struct xilinx_axidma_desc_hw {* @buf_addr_msb: MSB of Buffer address @0x0C * @rsvd: Reserved field @0x10 * @control: Control Information field @0x14 -* @status: Status field @0x18 -* @sideband_status: Status of sideband signals @0x1C +* @mm2s_ctrl_sideband: Sideband control info for mm2s @0x18 +* @s2mm_status: Status field for s2mm @0x18 +* @mm2s_status: Status field for mm2s @0x1C +* @s2mm_sideband_status: Sideband status for s2mm @0x1C * @app: APP Fields @0x20 - 0x30 */ struct xilinx_aximcdma_desc_hw {
@@ -288,10 +291,17 @@ struct xilinx_aximcdma_desc_hw {u32 buf_addr_msb;u32 rsvd;u32 control; -u32 status; -u32 sideband_status; +union { +u32 mm2s_ctrl_sideband; +u32 s2mm_status; + }; +union { +u32 mm2s_status; +u32 s2mm_sideband_status; + };u32 app[XILINX_DMA_NUM_APP_WORDS ]; }__aligned(64) ; +static_assert (sizeof (struct xilinx_aximcdma_desc_hw ) ==XILINX_MCDMA_BD_HW_SIZE );/** * struct xilinx_cdma_desc_hw - Hardware Descriptor
@@ -1025,9 +1035,11 @@ static u32 xilinx_dma_get_residue(struct xilinx_dma_chan *chan, struct xilinx_aximcdma_tx_segment, node); aximcdma_hw = &aximcdma_seg->hw; - residue += - (aximcdma_hw->control & chan->xdev->max_buffer_len) - - (aximcdma_hw->status & chan->xdev->max_buffer_len); + residue += aximcdma_hw->control & chan->xdev->max_buffer_len; +if (chan->direction ==DMA_DEV_TO_MEM ) + residue -= aximcdma_hw->s2mm_status & chan->xdev->max_buffer_len; +else + residue -= aximcdma_hw->mm2s_status & chan->xdev->max_buffer_len; } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 303/2651 dmaengine: xilinx_dma: Move descriptors to done list based on completion bit
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Neeli <[email protected]>
[ Upstream commit 5b585cc8778185ae7a7c9903f8cd70d562b91282 ]
In AXI MCDMA, xilinx_dma_complete_descriptor() walks the channel's active_list and unconditionally moves every entry to the done_list. The MCDMA IOC interrupt handler invokes this function on every interrupt-on-completion, but with interrupt coalescing (IRQThreshold > 1) an IOC interrupt may fire after only a subset of the queued descriptors have actually been processed by the hardware. As a result, descriptors whose completion bit is not yet set in the BD status were being reported as completed to client drivers.
Add a check for the descriptor completion bit before moving entries from the active list to the done list, using the appropriate direction- specific status field (s2mm_status for DMA_DEV_TO_MEM, mm2s_status for DMA_MEM_TO_DEV).
This mirrors the AXIDMA fix in commit 7bcdaa658102 ("dmaengine:xilinx_dma: Freeup active list based on descriptor completion bit").
--- drivers/dma/xilinx/xilinx_dma.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/dma/xilinx/xilinx_dma.c +11 -0
@@ -1794,6 +1794,17 @@ static void xilinx_dma_complete_descriptor(struct xilinx_dma_chan *chan) struct xilinx_axidma_tx_segment, node);if (!(seg->hw.status &XILINX_DMA_BD_COMP_MASK ) && chan->has_sg)break ; + }else if (chan->xdev->dma_config->dmatype ==XDMA_TYPE_AXIMCDMA ) { +struct xilinx_aximcdma_tx_segment *seg; +u32 status; + + seg =list_last_entry (&desc->segments, + struct xilinx_aximcdma_tx_segment, + node); + status = (chan->direction ==DMA_DEV_TO_MEM ) ? + seg->hw.s2mm_status : seg->hw.mm2s_status; +if (!(status &XILINX_DMA_BD_COMP_MASK )) +break ; }if (chan->has_sg && chan->xdev->dma_config->dmatype !=XDMA_TYPE_VDMA )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 304/2651 dmaengine: zynqmp_dma: drop redundant label
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vinod Koul <[email protected]>
[ Upstream commit 08f04d5ab868bc28d3115f7406499e8e5d1d1765 ]
Commit 3f30db282c28 ("dmaengine: zynqmp_dma: Fix chan probe/remove error handling") dropped the use of err_disable_pm label causing warning:
drivers/dma/xilinx/zynqmp_dma.c: In function ‘zynqmp_dma_probe’:drivers/dma/xilinx/zynqmp_dma.c:1171:1: error: label ‘err_disable_pm’ defined but not used [-Werror=unused-label]
1171 | err_disable_pm:
Drop it
--- drivers/dma/xilinx/zynqmp_dma.c | 1 - 1 file changed, 1 deletion(-)
drivers/dma/xilinx/zynqmp_dma.c +0 -1
@@ -1166,7 +1166,6 @@ static int zynqmp_dma_probe(struct platform_device *pdev) free_chan_resources:zynqmp_dma_chan_remove (zdev->chan); -err_disable_pm:if (!pm_runtime_enabled (zdev->dev))zynqmp_dma_runtime_suspend (zdev->dev);pm_runtime_disable (zdev->dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 305/2651 ASoC: nau8822: keep regcache offline while supplies are off
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pengpeng Hou <[email protected]>
[ Upstream commit 9c343445b349422bddebb4cb9668c246bc6f08de ]
nau8822_suspend() disables all codec supplies and marks the register cache dirty, but leaves regmap in live I/O mode. Resume then attempts the cache replay without first leaving a corresponding cache-only state.
Enter cache-only mode after the regulators have been disabled successfully, leave it after the supplies are restored, and stop the local resume sequence if cache replay fails. Do not power the codec back down on a resume error, because deferred component resume remains best effort and continues after the callback.
regulator_bulk_disable() restores regulators already disabled by the same bulk operation if a later disable fails. Only publish cache-only state after the whole power-off operation succeeds, so the regmap state continues to match the hardware state on either outcome.
--- sound/soc/codecs/nau8822.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
sound/soc/codecs/nau8822.c +12 -3
@@ -1059,10 +1059,14 @@ static int nau8822_suspend(struct snd_soc_component *component) {struct nau8822 *nau8822 =snd_soc_component_get_drvdata (component);struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component); +int ret;snd_soc_dapm_force_bias_level (dapm,SND_SOC_BIAS_OFF ); -regulator_bulk_disable (NAU8822_NUM_SUPPLIES , nau8822->supplies); + ret =regulator_bulk_disable (NAU8822_NUM_SUPPLIES , nau8822->supplies); +if (ret) +return ret; +regcache_cache_only (nau8822->regmap, true);regcache_mark_dirty (nau8822->regmap);return 0 ;
@@ -1072,7 +1076,9 @@ static int nau8822_resume(struct snd_soc_component *component) {struct nau8822 *nau8822 =snd_soc_component_get_drvdata (component);struct snd_soc_dapm_context *dapm =snd_soc_component_to_dapm (component); -int ret =regulator_bulk_enable (NAU8822_NUM_SUPPLIES , nau8822->supplies); +int ret; + + ret =regulator_bulk_enable (NAU8822_NUM_SUPPLIES , nau8822->supplies);if (ret) { dev_err(component->dev,
@@ -1082,7 +1088,10 @@ static int nau8822_resume(struct snd_soc_component *component)fsleep (100 ); -regcache_sync (nau8822->regmap); +regcache_cache_only (nau8822->regmap, false); + ret =regcache_sync (nau8822->regmap); +if (ret) +return ret;snd_soc_dapm_force_bias_level (dapm,SND_SOC_BIAS_STANDBY );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 306/2651 ACPI: button: Add lid_init_state quirk for Razer Blade Stealth 13 (Early 2020) RZ09-0310
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Gallagher <[email protected]>
[ Upstream commit f16c512a07b954aa3b0b3c580e7abb5dd4f5e703 ]
This patch adds a quirk mapping for the "Blade Stealth 13 (Early 2020) - RZ09-0310" laptop, which exhibits the same issue as the following two related products already accounted for in this file.
- Razer Blade Stealth 13 Late 2019
- Blade Pro 17 (Early 2020) - RZ09-0329
Summary of the issue this fixes:
The firmware's _LID method still returns "closed" after resume when the lid was opened during S3, causing systemd-logind to suspend the system again within several seconds (15-40) after waking.
--- drivers/acpi/button.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/acpi/button.c +12 -0
@@ -144,6 +144,18 @@ static const struct dmi_system_id dmi_lid_quirks[] = { }, .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, }, + { +/* +* Razer Blade Stealth 13 early 2020, when the lid is opened +* while suspended the open notification is lost and _LID keeps +* returning closed after resume, causing spurious re-suspends. +*/ + .matches = { +DMI_MATCH (DMI_SYS_VENDOR ,"Razer" ), + DMI_MATCH(DMI_PRODUCT_NAME, "Blade Stealth 13 (Early 2020) - RZ09-0310"), + }, + .driver_data = (void *)(long)ACPI_BUTTON_LID_INIT_OPEN, + }, {/* * Samsung galaxybook2 ,initial _LID device notification returns
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 307/2651 ACPI: PM: Drop parent state update from acpi_device_get_power()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 5636eebb7bb1c6f06f0058d48353686304d4bb47 ]
The parent state update in acpi_device_get_power(), that occurs when the child device turns out to be in D0 and the parent's power state is still unknown, is highly questionable because it may cause the reference counters of the power resources used by the parent in D0 (if any) to underflow when the parent goes into a low-power state later. Moreover, there is no reason to do it on reads from the real_power_state sysfs attribute of the child.
That check had been added by commit 8f7412a792bc ("ACPI / PM: Infer parent power state from child if unknown, v2") before starting to handle the "missing _PSC and no power resources" case directly in acpi_bus_init_power(), as of commit b3785492268f ("ACPI / PM: Do not power manage devices in unknown initial states"). It is not necessary any more and commit b3785492268f should have removed it.
Drop it now.
--- drivers/acpi/device_pm.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/acpi/device_pm.c +2 -13
@@ -75,15 +75,14 @@ static int acpi_dev_pm_explicit_get(struct acpi_device *device, int *state)int acpi_device_get_power (struct acpi_device *device,int *state) {int result =ACPI_STATE_UNKNOWN ; -struct acpi_device *parent;int error;if (!device || !state)return -EINVAL ; - parent =acpi_dev_parent (device); -if (!device->flags.power_manageable) { +struct acpi_device *parent =acpi_dev_parent (device); +/* TBD: Non-recursive algorithm for walking up hierarchy. */ *state = parent ? parent->power.state :ACPI_STATE_D0 ; goto out;
@@ -119,16 +118,6 @@ int acpi_device_get_power(struct acpi_device *device, int *state) result = psc >ACPI_STATE_D2 ?ACPI_STATE_D3_HOT : psc; } -/* -* If we were unsure about the device parent's power state up to this -* point, the fact that the device is in D0 implies that the parent has -* to be in D0 too, except if ignore_parent is set. -*/ -if (!device->power.flags.ignore_parent && parent && - parent->power.state ==ACPI_STATE_UNKNOWN && - result ==ACPI_STATE_D0 ) - parent->power.state =ACPI_STATE_D0 ; - *state = result; out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 308/2651 ACPI: scan: Stop calling acpi_bus_init_power() early
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 2f4ddf2bd1baf0ee3c8542ec6f382a3585cae607 ]
There is a problem, introduced by commit 9d9bcae47fd5 ("ACPI: delay enumeration of devices with a _DEP pointing to an INT3472 device") inadvertently, that devices with missing dependencies may be put into power state D0 prematurely [1].
Namely, acpi_bus_init_power() called by acpi_bus_get_power_flags() during the early initialization of ACPI device objects, may discover that all of the power resources needed by the given device to be in power state D0 are initially on, so it will reference count those power resources and transition the device into D0. Later, if acpi_bus_attach() running for that device notices that it has missing dependencies, the enumeration of it will be deferred and its power_manageable flag will be cleared, even though it is still in D0 at that point.
After the dependencies in question have been met, acpi_bus_attach() runs again for the device and now it calls acpi_bus_init_power() that takes additional references to the power resources used by the device in D0. These additional references prevent the power resources from being turned off when the device goes into D3hot/D3cold.
Another problem, related to the previous one, is that ACPI power state initialization may be carried out for devices whose parents are not ready for enumeration which may lead to initialization ordering issues.
To address both, stop calling acpi_bus_init_power() from acpi_bus_get_power_flags(), but also take the initialization of PCI devices into account, which needs to be done because they are initialized and bound to their ACPI companions before acpi_bus_attach() is called for the latter.
To that end, notice that acpi_power_up_if_adr_present() is used for powering-up PCI devices in D3cold before walking the bus in order to discover them and the initial ACPI power state of those devices needs to be known for this purpose, so add an acpi_bus_init_power() invocation to that function. [The debug statement printed by it duplicates the debug statements printed during the acpi_bus_init_power() execution, so drop it.]
Moreover, since the ACPI companions of PCI devices are associated with the corresponding PCI devices found on the bus before acpi_bus_attach() is called for them, it is not necessary or even useful to skip them in acpi_bus_attach() due to an ACPI status mismatch, so avoid doing that and complain if the ACPI status does not match the observed situation.
Also use the ACPI power state tracking to decide whether or not the device's power state needs to be initialized in acpi_bus_attach() instead of using the "initialized" flag of the ACPI device object for this purpose, which is fragile and inconvenient, and clear the power_manageable flag on failure in acpi_bus_init_power() (additionally, poison the device ACPI power state as "invalid" if the initialization of it fails). That allows the clearing of the power_manageable flag for devices with unmet dependencies to be dropped.
While at it, add a debug message pringing statement to acpi_bus_init_power() to facilitate diagnostics.
--- drivers/acpi/device_pm.c | 62 ++++++++++++++++++++++++++++++++-------- drivers/acpi/scan.c | 40 +++++++++++++++++--------- 2 files changed, 76 insertions(+), 26 deletions(-)
drivers/acpi/device_pm.c +50 -12
@@ -23,6 +23,8 @@#include "fan.h" #include "internal.h" +#define ACPI_D_STATE_INVALID ACPI_D_STATE_COUNT +/** * acpi_power_state_string - String representation of ACPI device power state. * @state: ACPI device power state to return the string representation of.
@@ -293,24 +295,28 @@ int acpi_bus_set_power(acpi_handle handle, int state) }EXPORT_SYMBOL (acpi_bus_set_power); -int acpi_bus_init_power (struct acpi_device *device) +static int acpi_device_init_power (struct acpi_device *device) {int state;int result; -if (!device) -return -EINVAL ; - - device->power.state =ACPI_STATE_UNKNOWN ; -if (!acpi_device_is_present (device)) { - device->flags.initialized = false; -return -ENXIO ; - } - result =acpi_device_get_power (device, &state);if (result)return result; +/* +* If the current power state of the device is D0 and it has a parent +* whose power state is not ignored, and the parent's power state +* initialization has failed, the parent's power state can be updated to +* D0 for consistency. +*/ +if (!device->power.flags.ignore_parent && state ==ACPI_STATE_D0 ) { +struct acpi_device *parent =acpi_dev_parent (device); + +if (parent && parent->power.state ==ACPI_D_STATE_INVALID ) + parent->power.state =ACPI_STATE_D0 ; + } +if (state <ACPI_STATE_D3_COLD && device->power.flags.power_resources) {/* Reference count the power resources. */ result =acpi_power_on_resources (device, state);
@@ -340,9 +346,36 @@ int acpi_bus_init_power(struct acpi_device *device) state =ACPI_STATE_D0 ; } device->power.state = state; + +acpi_handle_debug (device->handle,"Initial power state: %s\n" , +acpi_power_state_string (state)); +return 0 ; } +int acpi_bus_init_power (struct acpi_device *device) +{ +int result; + +if (device->power.state !=ACPI_STATE_UNKNOWN ) +return 0 ; + +/* +* The ACPI device power state can be only initialized once. If this +* fails, ACPI power management will not be used for the device going +* forward. +*/ + result =acpi_device_init_power (device); +if (result) { + device->flags.power_manageable =0 ; + device->power.state =ACPI_D_STATE_INVALID ; +acpi_handle_info (device->handle, +"Initial power state undetermined, ACPI PM disabled\n" ); + } + +return result; +} +/** * acpi_device_fix_up_power - Force device with missing _PSC into D0. * @device: Device object whose power state is to be fixed up.
@@ -464,8 +497,13 @@ static int acpi_power_up_if_adr_present(struct acpi_device *adev, void *not_usedif (!(adev->flags.power_manageable && adev->pnp.type.bus_address))return 0 ; -acpi_handle_debug (adev->handle,"Power state: %s\n" , -acpi_power_state_string (adev->power.state)); +/* +* This is done during the PCI root initialization which occurs before +* acpi_bus_attach() is called for the device, so the ACPI power state +* of the device needs to be initialized here. +*/ +if (acpi_bus_init_power (adev)) +return 0 ;if (adev->power.state ==ACPI_STATE_D3_COLD )return acpi_device_set_power (adev,ACPI_STATE_D0 );
drivers/acpi/scan.c +26 -14
@@ -20,6 +20,7 @@#include <linux/kthread.h> #include <linux/dmi.h> #include <linux/dma-map-ops.h> +#include <linux/pci.h> #include <linux/platform_data/x86/apple.h> #include <linux/pgtable.h> #include <linux/crc32.h>
@@ -1143,8 +1144,7 @@ static void acpi_bus_get_power_flags(struct acpi_device *device) device->power.states[ACPI_STATE_D3_COLD ].flags.valid =1 ; } -if (acpi_bus_init_power (device)) - device->flags.power_manageable =0 ; + device->power.state =ACPI_STATE_UNKNOWN ; }static void acpi_bus_get_flags (struct acpi_device *device)
@@ -2338,38 +2338,50 @@ static int acpi_scan_attach_handler(struct acpi_device *device)static int acpi_bus_attach (struct acpi_device *device,void *first_pass) {bool skip = !first_pass && device->flags.visited; +struct pci_dev *pci;acpi_handle ejd;int ret;if (skip) goto ok; + device->flags.initialized = true; +if (ACPI_SUCCESS (acpi_bus_get_ejd (device->handle, &ejd)))register_dock_dependent_device (device, ejd);acpi_bus_get_status (device); -/* Skip devices that are not ready for enumeration (e.g. not present) */ -if (!acpi_dev_ready_for_enumeration (device)) { - device->flags.initialized = false; +/* +* If the given ACPI device object has been already associated with a +* PCI device found on the bus, its status is effectively "present and +* enabled", and dependencies are not tracked for PCI devices, so it is +* not necessary or even useful to check the device's readiness in that +* case. +*/ + pci =acpi_dev_get_pci_dev (device); +if (pci) { +acpi_handle_debug (device->handle,"PCI companion %s found\n" , +pci_name (pci)); + +if (!acpi_device_is_present (device)) +pci_info (pci,FW_BUG "ACPI status differs from reality\n" ); + +pci_dev_put (pci); + }else if (!acpi_dev_ready_for_enumeration (device)) { +/* The device is not ready (e.g. not present), so skip it. */ acpi_device_clear_enumerated (device); - device->flags.power_manageable =0 ;return 0 ; } +if (device->handler) goto ok;acpi_ec_register_opregions (device); -if (!device->flags.initialized) { - device->flags.power_manageable = - device->power.states[ACPI_STATE_D0 ].flags.valid; -if (acpi_bus_init_power (device)) - device->flags.power_manageable =0 ; +acpi_bus_init_power (device); - device->flags.initialized = true; - }else if (device->flags.visited) { +if (device->flags.visited) goto ok; - } ret =acpi_scan_attach_handler (device);if (ret <0 )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 309/2651 ACPI: glue: Reduce debug noise from acpi_device_notify()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 5bc1e72f80da4c20ce8b57851be4fad67e855ebd ]
When debug is enabled in the ACPI glue code that handles binding devices to ACPI companions, acpi_device_notify() produces a lot of message noise related to devices that have no ACPI companions.
Reduce that noise by checking the most obvious case, ACPI device objects, directly and returning from acpi_device_notify() in that case without printing any debug messages. Also avoid printing a debug message when there is no matching ACPI bus type definition for the given device, which is the case for the vast majority of devices.
Additionally, make the debug messages that get printed more informative.
Stable-dep-of: aef7792cddca ("ACPI: glue: Rework the success message in acpi_device_notify()")
--- drivers/acpi/glue.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/acpi/glue.c +10 -10
@@ -354,22 +354,27 @@ void acpi_device_notify(struct device *dev)struct acpi_device *adev;int ret; +/* ACPI devices have no ACPI companions. */ +if (dev->bus == &acpi_bus_type) +return ; + ret =acpi_bind_one (dev,NULL );if (ret) {struct acpi_bus_type *type =acpi_get_bus_type (dev);if (!type) - goto err; +return ; adev = type->find_companion (dev);if (!adev) {dev_dbg (dev,"ACPI companion not found\n" ); - goto err; +return ; } ret =acpi_bind_one (dev, adev); -if (ret) - goto err; - +if (ret) { +dev_dbg (dev,"Binding to ACPI companion failed\n" ); +return ; + }if (type->setup) { type->setup (dev); goto done;
@@ -391,11 +396,6 @@ void acpi_device_notify(struct device *dev) done:acpi_handle_debug (ACPI_HANDLE (dev),"Bound to device %s\n" ,dev_name (dev)); - -return ; - -err: -dev_dbg (dev,"No ACPI support\n" ); }void acpi_device_notify_remove (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 310/2651 ACPI: glue: Rework the success message in acpi_device_notify()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit aef7792cddcac7ab400912c2947a595401d4a7e8 ]
Using an ACPI handle in the acpi_device_notify() success message is somewhat misleading because the "physical" device is not bound to an ACPI namespace object in that function, but to an ACPI device object attached to it. Moreover, the message is outright confusing for the "physical" devices bound to ACPI devices without ACPI namespace objects (for example, fixed event buttons).
Address this by turning that message into a dev_dbg() one printed for the "physical" device and mentioning the name of the ACPI companion.
--- drivers/acpi/glue.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/glue.c +1 -2
@@ -394,8 +394,7 @@ void acpi_device_notify(struct device *dev) adev->handler->bind (dev); done: -acpi_handle_debug (ACPI_HANDLE (dev),"Bound to device %s\n" , -dev_name (dev)); +dev_dbg (dev,"Bound to ACPI device %s\n" ,acpi_dev_name (adev)); }void acpi_device_notify_remove (struct device *dev)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 311/2651 ACPI: utils: Adjust message printing macros for ACPI objects
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rafael J. Wysocki <[email protected]>
[ Upstream commit 78ddbfaa72d68acc98cd5ba12eca071d452702c4 ]
The majority of acpi_handle_<level>() macros use neither pr_fmt() nor dev_fmt() and acpi_handle_debug() uses pr_fmt() like dev_fmt(), but only if dynamic debug is compiled in.
For more consistency, redefine all of the macros in question to use dev_fmt() because they are more similar to the analogous dev_*() family of macros than to the pr_*() ones and make all of them use it in the same way.
While at it, rephrase the comment documenting those macros for more clarity.
--- include/linux/acpi.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
include/linux/acpi.h +12 -12
@@ -1305,34 +1305,34 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c#endif /* -* acpi_handle_<level>: Print message with ACPI prefix and object path +* acpi_handle_<level> - Print a message with ACPI prefix and object path * -* These interfaces acquire the global namespace mutex to obtain an object -* path. In interrupt context, it shows the object path as <n/a>. +* In thread context, the global namespace mutex is acquired to obtain the +* object path. In interrupt context, the object path is shown as <n/a>. */ #define acpi_handle_emerg (handle, fmt, ...) \ - acpi_handle_printk(KERN_EMERG, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_EMERG, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_alert (handle, fmt, ...) \ - acpi_handle_printk(KERN_ALERT, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_ALERT, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_crit (handle, fmt, ...) \ - acpi_handle_printk(KERN_CRIT, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_CRIT, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_err (handle, fmt, ...) \ - acpi_handle_printk(KERN_ERR, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_ERR, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_warn (handle, fmt, ...) \ - acpi_handle_printk(KERN_WARNING, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_WARNING, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_notice (handle, fmt, ...) \ - acpi_handle_printk(KERN_NOTICE, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_NOTICE, handle, dev_fmt(fmt), ##__VA_ARGS__)#define acpi_handle_info (handle, fmt, ...) \ - acpi_handle_printk(KERN_INFO, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_INFO, handle, dev_fmt(fmt), ##__VA_ARGS__)#if defined(DEBUG )#define acpi_handle_debug (handle, fmt, ...) \ - acpi_handle_printk(KERN_DEBUG, handle, fmt, ##__VA_ARGS__) + acpi_handle_printk(KERN_DEBUG, handle, dev_fmt(fmt), ##__VA_ARGS__)#else #if defined(CONFIG_DYNAMIC_DEBUG )#define acpi_handle_debug (handle, fmt, ...) \ _dynamic_func_call(fmt, __acpi_handle_debug, \ - handle, pr_fmt(fmt), ##__VA_ARGS__) + handle, dev_fmt(fmt), ##__VA_ARGS__)#else #define acpi_handle_debug (handle, fmt, ...) \ ({ \
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 312/2651 iommufd/selftest: Return dmabuf fd from IOMMU_TEST_OP_DMABUF_GET again
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qinyun Tan <[email protected]>
[ Upstream commit 1d56f4d6db3d2b2c93017a80c4f9c4cfffa9d193 ]
The selftest helper reads the new dmabuf fd from the ioctl return value:
*out_fd = ioctl(fd, IOMMU_TEST_CMD, &cmd);
Commit dba4254e216d ("iommufd/selftest: Fix dmabuf leak in iommufd_test_dmabuf_get()") fixed the dmabuf leak on dma_buf_fd() failure, but the applied version also changed the success path to return 0, so userspace no longer receives the fd. Note the patch as posted on the list returned rc here; the change to return 0 appeared when it was applied:
https://lore.kernel.org/all/[email protected]/
Every test using test_cmd_get_dmabuf() then operates on fd 0 instead of the dmabuf, and the dmabuf_simple and dmabuf_revoke selftests fail across all fixtures:
# iommufd.c:1595:dmabuf_simple:Expected -1 (-1) ==
_test_ioctl_ioas_map_file(...) (0)
Keep the dma_buf_put() on failure but return the fd on success.
--- drivers/iommu/iommufd/selftest.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/iommu/iommufd/selftest.c +2 -4
@@ -2056,11 +2056,9 @@ static int iommufd_test_dmabuf_get(struct iommufd_ucmd *ucmd, } rc =dma_buf_fd (dmabuf, open_flags); -if (rc <0 ) { +if (rc <0 )dma_buf_put (dmabuf); -return rc; - } -return 0 ; +return rc; err_free:kfree (priv->memory);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 313/2651 ASoC: rt1320: avoid re-initialize in advanced mode
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shuming Fan <[email protected]>
[ Upstream commit 04c3ee0f5d158f6e2027c7ef617044cb649ab4ab ]
On some machines, speaker protection is enabled.
We call this advanced mode, which loads the DSP firmware and changes settings based on the basic mode, including blind writes.
The amplifier can retain the advanced mode settings until a POR or power loss occurs. Therefore, the driver does not need to switch from basic mode to advanced mode when the system performs a warm reboot.
We only need to check the function_status to determine
whether the system has undergone a cold or warm reboot.
--- sound/soc/codecs/rt1320-sdw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/rt1320-sdw.c +1 -1
@@ -2470,7 +2470,7 @@ static int rt1320_io_init(struct device *dev, struct sdw_slave *slave)dev_dbg (dev,"%s amp func_status=0x%x\n" , __func__, amp_func_status);/* initialization write */ -if ((amp_func_status &FUNCTION_NEEDS_INITIALIZATION ) || !rt1320->first_hw_init) { +if ((amp_func_status &FUNCTION_NEEDS_INITIALIZATION )) {switch (rt1320->dev_id) {case RT1320_DEV_ID :if (rt1320->version_id <RT1320_VC )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 314/2651 wifi: ath11k: modify null check logic in ath11k_ce_rx_post_pipe()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Lobanov <[email protected]>
[ Upstream commit 52953d149ab4da0432d54b09f3c8add42b4d4a82 ]
The previous logic in ath11k_ce_rx_post_pipe() incorrectly required both dest_ring and status_ring to be NULL in order to exit the function. This caused the function to continue even if only one of the pointers was NULL, potentially leading to null pointer dereferences in ath11k_ce_rx_buf_enqueue_pipe().
Fix the condition by modifying the logic so that the function returns early if either dest_ring or status_ring is NULL.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
--- drivers/net/wireless/ath/ath11k/ce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath11k/ce.c +1 -1
@@ -325,7 +325,7 @@ static int ath11k_ce_rx_post_pipe(struct ath11k_ce_pipe *pipe)dma_addr_t paddr;int ret =0 ; -if (!(pipe->dest_ring || pipe->status_ring)) +if (!pipe->dest_ring || !pipe->status_ring)return 0 ;spin_lock_bh (&ab->ce.ce_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 315/2651 wifi: ath11k: fix locking problem in ath11k_dp_rx_tid_del_func()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolas Escande <[email protected]>
[ Upstream commit c7555d47b1d051e0406474349deccf74b491ae01 ]
In this function, we iterate over dp->reo_cmd_cache_flush_list using list_for_each_entry_safe(), under dp->reo_cmd_lock for concurrent access, and for each expired entries we :
- drop the lock
- call ath11k_dp_reo_cache_flush()
- kfree() the entry
- retake the lock to keep on iterating
list_for_each_entry_safe() protects us from deleting the entry during iteration but doesn't protect for concurrent access. So another thread can take the lock and modify the list in between and crash like below.
To fix the issue, move all entries that needs to be freed to a local list while under the lock and then iterate over the list to free the entries without holding the lock.
BUG: Unable to handle kernel paging request at virtual address 00000010ddbeef8c Call trace: ath11k_dp_rx_tid_del_func+0x164/0x3c8 ath11k_dp_process_reo_status+0x1d4/0x2fc ath11k_dp_service_srng+0x334/0x338 ath11k_pcic_ext_grp_napi_poll+0x30/0xc0 __napi_poll+0x34/0x184 napi_threaded_poll+0xb4/0x1d8 kthread+0xdc/0xe0 ret_from_fork+0x10/0x20
Tested-on: QCN9074 hw1.0 PCI WLAN.HK.2.9.0.1-01977-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath11k/dp_rx.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
drivers/net/wireless/ath/ath11k/dp_rx.c +12 -7
@@ -762,6 +762,9 @@ static void ath11k_dp_rx_tid_del_func(struct ath11k_dp *dp, void *ctx,struct ath11k_base *ab = dp->ab;struct dp_rx_tid *rx_tid = ctx;struct dp_reo_cache_flush_elem *elem, *tmp; +struct list_head flush_list; + +INIT_LIST_HEAD (&flush_list);if (status ==HAL_REO_CMD_DRAIN ) { goto free_desc;
@@ -783,23 +786,25 @@ static void ath11k_dp_rx_tid_del_func(struct ath11k_dp *dp, void *ctx,list_add_tail (&elem->list, &dp->reo_cmd_cache_flush_list); dp->reo_cmd_cache_flush_count++; -/* Flush and invalidate aged REO desc from HW cache */ +/* identify aged REO desc that needs removal */ list_for_each_entry_safe (elem, tmp, &dp->reo_cmd_cache_flush_list, list) {if (dp->reo_cmd_cache_flush_count >DP_REO_DESC_FREE_THRESHOLD ||time_after (jiffies, elem->ts +msecs_to_jiffies (DP_REO_DESC_FREE_TIMEOUT_MS ))) { -list_del (&elem->list); +list_move_tail (&elem->list, &flush_list); dp->reo_cmd_cache_flush_count--; -spin_unlock_bh (&dp->reo_cmd_lock); - -ath11k_dp_reo_cache_flush (ab, &elem->data); -kfree (elem); -spin_lock_bh (&dp->reo_cmd_lock); } }spin_unlock_bh (&dp->reo_cmd_lock); +/* remove aged REO desc from HW */ +list_for_each_entry_safe (elem, tmp, &flush_list, list) { +ath11k_dp_reo_cache_flush (ab, &elem->data); +list_del (&elem->list); +kfree (elem); + } +return ; free_desc: dma_free_noncoherent(ab->dev, rx_tid->unaligned_size,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 316/2651 wifi: ath12k: fix DMA unwind for ext MSDU descriptor retry
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rameshkumar Sundaram <[email protected]>
[ Upstream commit 4de5a8a0edddc453f1a4c93b6d9f09013a23b72e ]
ath12k_wifi7_dp_tx() maps the original MSDU into ti.paddr and stores the address in skb_cb->paddr. When an extended MSDU descriptor is used, the function later maps the ext descriptor and overwrites ti.paddr and ti.data_len with the ext-desc DMA address and length.
If TCL ring allocation then fails, the error path first unmaps the ext-desc DMA address from skb_cb->paddr_ext_desc. It then falls through to fail_unmap_dma, which uses ti.paddr/ti.data_len for the original MSDU unmap. At that point ti.paddr still refers to the ext-desc mapping, so the ext descriptor is unmapped twice and the original MSDU mapping is left mapped.
Fix the original MSDU unwind to use skb_cb->paddr and skb->len instead of ti.paddr/ti.data_len. The ti fields cannot be used after the ext descriptor is mapped because they are intentionally reused for the buffer submitted to TCL. Also clear skb_cb->paddr_ext_desc after the ext-desc unmap so a TCL ring retry cannot observe stale ext-desc DMA state from the previous attempt.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c +4 -2
@@ -449,15 +449,17 @@ int ath12k_wifi7_dp_tx(struct ath12k_pdev_dp *dp_pdev, struct ath12k_link_vif *areturn 0 ; fail_unmap_dma_ext: -if (skb_cb->paddr_ext_desc) +if (skb_cb->paddr_ext_desc) {dma_unmap_single (dp->dev, skb_cb->paddr_ext_desc, skb_ext_desc->len,DMA_TO_DEVICE ); + skb_cb->paddr_ext_desc =0 ; + } fail_free_ext_skb:kfree_skb (skb_ext_desc); fail_unmap_dma: -dma_unmap_single (dp->dev, ti.paddr, ti.data_len,DMA_TO_DEVICE ); +dma_unmap_single (dp->dev, skb_cb->paddr, skb->len,DMA_TO_DEVICE ); fail_remove_tx_buf:ath12k_dp_tx_release_txbuf (dp, tx_desc, pool_id);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 317/2651 wifi: ath12k: fix stale skb pointers after aligned TX payload shift
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 6c40719489c8d799798989b15bc07b0700c132f8 ]
ath12k_wifi7_dp_tx() caches hdr, eth, and skb_cb from the skb before calling ath12k_dp_tx_align_payload(). That function may shift skb->data in place (when headroom or tailroom is sufficient) or reallocate the buffer entirely via skb_realloc_headroom(), freeing the original skb. In either case hdr, eth, and skb_cb are left pointing into stale memory.
After alignment, only hdr is refreshed, leaving eth and skb_cb stale. skb_cb is written immediately after (storing DMA addresses), and eth is re-read on every TCL ring retry via the tcl_ring_sel goto, so both accesses are use-after-free or stale-pointer bugs depending on which alignment path was taken.
Refresh eth (conditionally, to preserve the encap-mode distinction) and skb_cb alongside hdr after ath12k_dp_tx_align_payload() returns, so all three point into the live skb for all subsequent accesses.
Issue found during code review, compile tested only.
--- drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c +7 -2
@@ -313,10 +313,15 @@ int ath12k_wifi7_dp_tx(struct ath12k_pdev_dp *dp_pdev, struct ath12k_link_vif *a goto map; } -/* hdr is pointing to a wrong place after alignment, -* so refresh it for later use. +/* +* The payload may have been shifted or even the entire buffer may have +* been reallocated for alignment. In that case, hdr, eth and skb_cb +* are stale pointers. Refresh them now for later dereference. */ hdr = (void *)skb->data; +if (eth) + eth = (struct ethhdr *)skb->data; + skb_cb =ATH12K_SKB_CB (skb); } map: ti.paddr =dma_map_single (dp->dev, skb->data, skb->len,DMA_TO_DEVICE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 318/2651 wifi: ath12k: fix truncated TX buffer DMA address in MSDU ext descriptor
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Baochen Qiang <[email protected]>
[ Upstream commit 979ecb88ed3528e08dd7f87b90b029374226ca84 ]
ath12k_wifi7_hal_tx_cmd_ext_desc_setup() programs the low 32 bits of the TX buffer physical address into HAL_TX_MSDU_EXT_INFO0_BUF_PTR_LO but hardcodes the high bits field HAL_TX_MSDU_EXT_INFO1_BUF_PTR_HI to 0x0.
dma_addr_t is 64-bit on platforms with CONFIG_ARCH_DMA_ADDR_T_64BIT, so whenever a TX buffer is mapped above the 4 GB boundary the upper bits of paddr are dropped and the firmware is handed a truncated address, leading to potential TX failures.
Write the upper bits of paddr into BUF_PTR_HI to fix this issue.
Issue found during code review, compile tested only.
--- drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath12k/wifi7/dp_tx.c +1 -1
@@ -63,7 +63,7 @@ ath12k_wifi7_hal_tx_cmd_ext_desc_setup(struct ath12k_base *ab, { tcl_ext_cmd->info0 =le32_encode_bits (ti->paddr,HAL_TX_MSDU_EXT_INFO0_BUF_PTR_LO ); - tcl_ext_cmd->info1 =le32_encode_bits (0x0 , + tcl_ext_cmd->info1 =le32_encode_bits ((u64 )ti->paddr >>HAL_ADDR_MSB_REG_SHIFT ,HAL_TX_MSDU_EXT_INFO1_BUF_PTR_HI ) |le32_encode_bits (ti->data_len,HAL_TX_MSDU_EXT_INFO1_BUF_LEN );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 319/2651 wifi: ath12k: Free allocated CE IRQs on request_irq() failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit 12ca935af2e68447e9218a615ebbb5ff7faf1554 ]
When CE IRQ configuration fails, the driver does not release all IRQs that were successfully requested before the failure. This can leak IRQ resources during probe failure.
Free the previously requested CE IRQs before returning from the error path to ensure that partially initialized IRQ resources are properly cleaned up during probe failure.
Factor out the CE IRQ cleanup into a helper to reuse the cleanup logic during both error handling and driver teardown.
Also free CE IRQs when external IRQ configuration fails, before returning from the error path.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/pci.c | 29 ++++++++++++++++++--------- 1 file changed, 19 insertions(+), 10 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +19 -10
@@ -313,6 +313,19 @@ static void ath12k_pci_sw_reset(struct ath12k_base *ab, bool power_on)ath12k_mhi_set_mhictrl_reset (ab); } +static void ath12k_pci_free_ce_irq (struct ath12k_base *ab,int num_ce) +{ +int i, irq_idx; + +for (i =0 ; i < num_ce; i++) { +if (ath12k_ce_get_attr_flags (ab, i) &CE_ATTR_DIS_INTR ) +continue ; + + irq_idx =ATH12K_PCI_IRQ_CE0_OFFSET + i; +free_irq (ab->irq_num[irq_idx], &ab->ce.ce_pipe[i]); + } +} +static void ath12k_pci_free_ext_irq (struct ath12k_base *ab) {int i, j;
@@ -330,15 +343,7 @@ static void ath12k_pci_free_ext_irq(struct ath12k_base *ab)static void ath12k_pci_free_irq (struct ath12k_base *ab) { -int i, irq_idx; - -for (i =0 ; i < ab->hw_params->ce_count; i++) { -if (ath12k_ce_get_attr_flags (ab, i) &CE_ATTR_DIS_INTR ) -continue ; - irq_idx =ATH12K_PCI_IRQ_CE0_OFFSET + i; -free_irq (ab->irq_num[irq_idx], &ab->ce.ce_pipe[i]); - } - +ath12k_pci_free_ce_irq (ab, ab->hw_params->ce_count);ath12k_pci_free_ext_irq (ab); }
@@ -671,6 +676,8 @@ static int ath12k_pci_config_irq(struct ath12k_base *ab)if (ret) {ath12k_err (ab,"failed to request irq %d: %d\n" , irq_idx, ret); + +ath12k_pci_free_ce_irq (ab, i);return ret; }
@@ -681,8 +688,10 @@ static int ath12k_pci_config_irq(struct ath12k_base *ab) } ret =ath12k_pci_ext_irq_config (ab); -if (ret) +if (ret) { +ath12k_pci_free_ce_irq (ab, ab->hw_params->ce_count);return ret; + }return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 320/2651 wifi: ath12k: Free allocated external IRQs on request_irq() failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaradhana Sahu <[email protected]>
[ Upstream commit 9a78703ec4a895bd2e99bf43bd18d76683126c19 ]
When external IRQ configuration fails, the driver does not release all IRQs that were successfully requested before the failure. This can leak IRQ resources during probe failure.
Free previously requested external IRQs when external IRQ configuration fails.
Also remove the NAPI instance with netif_napi_del() before freeing the associated netdev to properly clean up the NAPI resources.
Store the IRQ number only after request_irq() succeeds to avoid recording an IRQ that was not successfully requested.
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.6-01243-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/pci.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/net/wireless/ath/ath12k/pci.c +13 -13
@@ -326,11 +326,11 @@ static void ath12k_pci_free_ce_irq(struct ath12k_base *ab, int num_ce) } } -static void ath12k_pci_free_ext_irq (struct ath12k_base *ab) +static void ath12k_pci_free_ext_irq (struct ath12k_base *ab,int num_ext_irq_grp) {int i, j; -for (i =0 ; i <ATH12K_EXT_IRQ_GRP_NUM_MAX ; i++) { +for (i =0 ; i < num_ext_irq_grp; i++) {struct ath12k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i];for (j =0 ; j < irq_grp->num_irq; j++)
@@ -344,7 +344,7 @@ static void ath12k_pci_free_ext_irq(struct ath12k_base *ab)static void ath12k_pci_free_irq (struct ath12k_base *ab) {ath12k_pci_free_ce_irq (ab, ab->hw_params->ce_count); -ath12k_pci_free_ext_irq (ab); +ath12k_pci_free_ext_irq (ab,ATH12K_EXT_IRQ_GRP_NUM_MAX ); }static void ath12k_pci_ce_irq_enable (struct ath12k_base *ab,u16 ce_id)
@@ -600,8 +600,6 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab) irq =ath12k_pci_get_msi_irq (ab->dev, vector); - ab->irq_num[irq_idx] = irq; -ath12k_dbg (ab,ATH12K_DBG_PCI ,"irq:%d group:%d\n" , irq, i);
@@ -612,22 +610,24 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)if (ret) {ath12k_err (ab,"failed request irq %d: %d\n" , vector, ret); - goto fail_request; + +for (n =0 ; n < j; n++) +free_irq (ab->irq_num[irq_grp->irqs[n]], irq_grp); + +netif_napi_del (&ab->ext_irq_grp[i].napi); +free_netdev (ab->ext_irq_grp[i].napi_ndev); + goto fail_allocate; } + + ab->irq_num[irq_idx] = irq; }ath12k_pci_ext_grp_disable (irq_grp); }return 0 ; -fail_request: -/* i ->napi_ndev was properly allocated. Free it also */ - i +=1 ; fail_allocate: -for (n =0 ; n < i; n++) { - irq_grp = &ab->ext_irq_grp[n]; -free_netdev (irq_grp->napi_ndev); - } +ath12k_pci_free_ext_irq (ab, i);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 321/2651 wifi: ath12k: preserve PPDU state across monitor status buffers
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kang Yang <[email protected]>
[ Upstream commit 69b2d06dafa4a61b718704d655dd370ba660052a ]
A monitor PPDU may span multiple status buffers. However, __ath12k_wifi7_dp_mon_process_ring() clears mon_ppdu_info before processing every buffer.
As a result, continuation buffers lose PPDU state collected from earlier buffers, including ppdu_id and PHY metadata.
This can cause monitor RX processing to fail when ath12k_wifi7_dp_rx_mon_dest_process() observes a PPDU ID mismatch between status and destination rings, preventing MSDUs from being delivered. It can also produce incomplete EHT metadata that triggers warnings from mac80211:
Rate marked as an EHT rate but data is invalid: MCS:0, NSS:0
ath12k_wifi7_dp_mon_srng_process() already tracks status TLV continuations via ppdu_continuation. Apply the same logic here and only reinitialize mon_ppdu_info when starting a new PPDU.
mon_ppdu_info persists across ar->monitor_started transitions. If monitor mode stops while a PPDU is mid-continuation, ppdu_continuation stays set and could leak into the next monitor session. Reset it when monitor mode starts.
Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c7-00108-QCAHMTSWPL_V1.0_V2.0_SILICONZ_UPSTREAM-3
--- drivers/net/wireless/ath/ath12k/mac.c | 7 ++++++ .../net/wireless/ath/ath12k/wifi7/dp_mon.c | 23 +++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-)
drivers/net/wireless/ath/ath12k/mac.c +7 -0
@@ -1506,6 +1506,13 @@ static int ath12k_mac_monitor_start(struct ath12k *ar)return ret; } +/* +* A previous monitor session may have stopped mid-PPDU, leaving +* ppdu_continuation set. Clear it so the first status buffer of +* this session is not merged with stale state from before. +*/ + ar->dp.mon_data.mon_ppdu_info.ppdu_continuation = false; + ar->monitor_started = true; ar->num_started_vdevs++;
drivers/net/wireless/ath/ath12k/wifi7/dp_mon.c +14 -9
@@ -3211,18 +3211,23 @@ __ath12k_wifi7_dp_mon_process_ring(struct ath12k *ar, int mac_id, goto exit;while ((skb =__skb_dequeue (&skb_list))) { -memset (ppdu_info,0 ,sizeof (*ppdu_info)); - ppdu_info->peer_id =HAL_INVALID_PEERID ; +if (!ppdu_info->ppdu_continuation) +ath12k_wifi7_dp_mon_rx_memset_ppdu_info (ppdu_info); hal_status =ath12k_wifi7_dp_mon_parse_rx_dest (&ar->dp, pmon, skb); -if (ar->monitor_started && - pmon->mon_ppdu_status ==DP_PPDU_STATUS_START && - hal_status ==HAL_TLV_STATUS_PPDU_DONE ) { - rx_mon_stats->status_ppdu_done++; - pmon->mon_ppdu_status =DP_PPDU_STATUS_DONE ; -ath12k_wifi7_dp_rx_mon_dest_process (ar, mac_id, *budget, napi); - pmon->mon_ppdu_status =DP_PPDU_STATUS_START ; +if (hal_status ==HAL_TLV_STATUS_PPDU_DONE ) { + ppdu_info->ppdu_continuation = false; +if (ar->monitor_started && + pmon->mon_ppdu_status ==DP_PPDU_STATUS_START ) { + rx_mon_stats->status_ppdu_done++; + pmon->mon_ppdu_status =DP_PPDU_STATUS_DONE ; +ath12k_wifi7_dp_rx_mon_dest_process (ar, mac_id, + *budget, napi); + pmon->mon_ppdu_status =DP_PPDU_STATUS_START ; + } + }else { + ppdu_info->ppdu_continuation = true; }dev_kfree_skb_any (skb);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 322/2651 selftests: net: csum: filter packets by source address and port
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Willem de Bruijn <[email protected]>
[ Upstream commit 8342c68435dd34b1ecd65b02fff9745cadab2616 ]
Add source address and port verification in recv_verify_packet_* andrecv_udp: non-matching packets are skipped.
The receiver reads from PF_PACKET and UDP sockets to verify incoming packets to test hardware checksum offload. It did not validate the packet source address or source port.
During tests expecting an invalid checksum (-E) or zero checksum (-Z), background packets can fail the test.
For -Z, build_packet_udp chooses a specific source port that causes the checksum to sum to zero. When running in receive-only mode (-R), call build_packet in do_rx to compute the expected source port so that source port filtering can be applied to -Z as well.
Also
- add an inter-packet delay to avoid drops from bursts.
- remove a comment that is no longer correct.
--- tools/testing/selftests/net/lib/csum.c | 55 +++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 5 deletions(-)
tools/testing/selftests/net/lib/csum.c +50 -5
@@ -2,8 +2,7 @@/* Test hardware checksum offload: Rx + Tx, IPv4 + IPv6, TCP + UDP. * -* The test runs on two machines to exercise the NIC. For this reason it -* is not integrated in kselftests. +* The test runs on two machines to exercise the NIC. * * CMD=$((./csum -[46] -[tu] -S $SADDR -D $DADDR -[RT] -r 1 $EXTRA_ARGS)) *
@@ -236,7 +235,8 @@ static void *build_packet_udp(void *_uh) uh->source =0 ; uh->source =checksum (uh,IPPROTO_UDP ,sizeof (*uh) + cfg_payload_len); -fprintf (stderr,"tx: changing sport: %hu -> %hu\n" , +fprintf (stderr,"%s: changing sport: %hu -> %hu\n" , + cfg_do_tx ?"tx" :"rx" , cfg_port_src,ntohs (uh->source)); cfg_port_src =ntohs (uh->source); }
@@ -249,7 +249,8 @@ static void *build_packet_udp(void *_uh)if (cfg_bad_csum) uh->check = ~uh->check; -fprintf (stderr,"tx: sending checksum: 0x%x\n" , uh->check); +if (cfg_do_tx) +fprintf (stderr,"tx: sending checksum: 0x%x\n" , uh->check);return uh +1 ; }
@@ -571,15 +572,36 @@ static int recv_prepare_packet(void)static int recv_udp (int fd) {static char buf[MAX_PAYLOAD_LEN ]; +struct sockaddr_storage addr; +socklen_t addrlen;int ret, count =0 ;while (1 ) { - ret =recv (fd, buf,sizeof (buf),MSG_DONTWAIT ); + addrlen =sizeof (addr); + ret =recvfrom (fd, buf,sizeof (buf),MSG_DONTWAIT , + (struct sockaddr *)&addr, &addrlen);if (ret ==-1 && errno ==EAGAIN )break ;if (ret ==-1 )error (1 , errno,"recv r" ); +if (cfg_family ==PF_INET ) { +struct sockaddr_in *sin = (void *)&addr; + +if (sin->sin_addr.s_addr != cfg_saddr4.sin_addr.s_addr) +continue ; +if (sin->sin_port !=htons (cfg_port_src)) +continue ; + }else { +struct sockaddr_in6 *sin6 = (void *)&addr; + +if (memcmp (&sin6->sin6_addr, &cfg_saddr6.sin6_addr, +sizeof (sin6->sin6_addr))) +continue ; +if (sin6->sin6_port !=htons (cfg_port_src)) +continue ; + } +fprintf (stderr,"rx: udp: len=%u\n" , ret); count++; }
@@ -620,6 +642,9 @@ static int recv_verify_packet_tcp(void *th, int len)if (len <sizeof (*tcph) || tcph->dest !=htons (cfg_port_dst))return -1 ; +if (tcph->source !=htons (cfg_port_src)) +return -1 ; +return recv_verify_csum (th, len,ntohs (tcph->source), tcph->check); }
@@ -647,6 +672,9 @@ static int recv_verify_packet_udp(void *th, int len)return recv_verify_packet_udp_encap (udph +1 , len -sizeof (*udph)); +if (udph->source !=htons (cfg_port_src)) +return -1 ; +return recv_verify_csum (th, len,ntohs (udph->source), udph->check); }
@@ -659,6 +687,9 @@ static int recv_verify_packet_ipv4(void *nh, int len)if (len <sizeof (*iph) || iph->protocol != proto)return -1 ; +if (iph->saddr != cfg_saddr4.sin_addr.s_addr) +return -1 ; + ip_len =ntohs (iph->tot_len);if (ip_len > len || ip_len <sizeof (*iph))return -1 ;
@@ -680,6 +711,9 @@ static int recv_verify_packet_ipv6(void *nh, int len)if (len <sizeof (*ip6h) || ip6h->nexthdr != proto)return -1 ; +if (memcmp (&ip6h->saddr, &cfg_saddr6.sin6_addr,sizeof (ip6h->saddr))) +return -1 ; + payload_len =ntohs (ip6h->payload_len);if (payload_len > len -sizeof (*ip6h))return -1 ;
@@ -940,6 +974,9 @@ static void do_tx(void) cfg_payload_len =rand () %MAX_PAYLOAD_LEN ; buf =build_packet (_buf,sizeof (_buf), &len); } + +/* avoid bursting */ +usleep (20 ); }if (close (fd))
@@ -952,6 +989,14 @@ static void do_rx(int fdp, int fdr)long tleft, tstop;struct pollfd pfd; +if (!cfg_do_tx && cfg_zero_sum) { +static char _buf[MAX_HEADER_LEN +MAX_PAYLOAD_LEN ]; +int len; + +/* calculate source port that causes csum to add up to zero */ +build_packet (_buf,sizeof (_buf), &len); + } + tstop =gettimeofday_ms () + cfg_timeout_ms; tleft = cfg_timeout_ms;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 323/2651 cpufreq/amd-pstate-ut: Fix amd_pstate_ut_check_freq failure with Requested CPU Min frequency BIOS option
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: K Prateek Nayak <[email protected]>
[ Upstream commit a23fca4ae137ec8e7620cc4f00b468b89cf5a7bd ]
Since commit 608a76b65288 ("cpufreq/amd-pstate: Add support for the "Requested CPU Min frequency" BIOS option"), amd-pstate driver sets policy->min to frequency corresponding to bios_min_perf if a valid BIOS programmed min frequency value is detected.
amd_pstate_ut_check_freq expects policy->min to always match lowest_nonlinear_freq which does not hold true on platforms with user configured BIOS min freq.
Update the test case to compare policy->min to bios_min_freq on platforms that set it. Final comparison is adjusted to account for insane values by clamping the result within the supported frequency range.
While at it, move freq_to_perf() and perf_to_freq() helpers to internal header to allow their use from amd-pstate-ut.
--- drivers/cpufreq/amd-pstate-ut.c | 23 ++++++++++++++++++++++- drivers/cpufreq/amd-pstate.c | 13 ------------- drivers/cpufreq/amd-pstate.h | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 14 deletions(-)
drivers/cpufreq/amd-pstate-ut.c +22 -1
@@ -226,11 +226,14 @@ static int amd_pstate_ut_check_freq(u32 index)for_each_online_cpu (cpu) { struct cpufreq_policy *policy __free(put_cpufreq_policy) = NULL;struct amd_cpudata *cpudata; +union perf_cached perf; policy =cpufreq_cpu_get (cpu);if (!policy)continue ; + cpudata = policy->driver_data; + perf =READ_ONCE (cpudata->perf); if (!((policy->cpuinfo.max_freq >= cpudata->nominal_freq) && (cpudata->nominal_freq > cpudata->lowest_nonlinear_freq) &&
@@ -242,7 +245,25 @@ static int amd_pstate_ut_check_freq(u32 index)return -EINVAL ; } -if (cpudata->lowest_nonlinear_freq != policy->min) { +if (perf.bios_min_perf) { +u32 bios_min_freq =perf_to_freq (perf, cpudata->nominal_freq, + perf.bios_min_perf); + +/* +* User set bios_min_freq cannot be trusted to +* be within the driver limits. Clamp it similar +* to cpufreq_verify_within_cpu_limits(). +*/ + bios_min_freq =clamp_t (u32, bios_min_freq, + policy->cpuinfo.min_freq, + policy->cpuinfo.max_freq); + +if (bios_min_freq != policy->min) { +pr_err ("%s cpu%d bios_min_freq=%d policy_min=%d, they should be equal!\n" , + __func__, cpu, bios_min_freq, policy->min); +return -EINVAL ; + } + }else if (cpudata->lowest_nonlinear_freq != policy->min) {pr_err ("%s cpu%d cpudata_lowest_nonlinear_freq=%d policy_min=%d, they should be equal!\n" , __func__, cpu, cpudata->lowest_nonlinear_freq, policy->min);return -EINVAL ;
drivers/cpufreq/amd-pstate.c +0 -13
@@ -145,19 +145,6 @@ static struct quirk_entry quirk_amd_7k62 = { .lowest_freq = 550, }; -static inline u8 freq_to_perf (union perf_cached perf,u32 nominal_freq,unsigned int freq_val) -{ -u32 perf_val =DIV_ROUND_UP_ULL ((u64 )freq_val * perf.nominal_perf, nominal_freq); - -return (u8 )clamp (perf_val, perf.lowest_perf, perf.highest_perf); -} - -static inline u32 perf_to_freq (union perf_cached perf,u32 nominal_freq,u8 perf_val) -{ -return DIV_ROUND_UP_ULL ((u64 )nominal_freq * perf_val, - perf.nominal_perf); -} -static int __init dmi_matched_7k62_bios_bug (const struct dmi_system_id *dmi) {/**
drivers/cpufreq/amd-pstate.h +14 -0
@@ -159,6 +159,20 @@ enum amd_pstate_mode {AMD_PSTATE_GUIDED , AMD_PSTATE_MAX, }; + +static inline u8 freq_to_perf (union perf_cached perf,u32 nominal_freq,unsigned int freq_val) +{ +u32 perf_val =DIV_ROUND_UP_ULL ((u64 )freq_val * perf.nominal_perf, nominal_freq); + +return (u8 )clamp (perf_val, perf.lowest_perf, perf.highest_perf); +} + +static inline u32 perf_to_freq (union perf_cached perf,u32 nominal_freq,u8 perf_val) +{ +return DIV_ROUND_UP_ULL ((u64 )nominal_freq * perf_val, + perf.nominal_perf); +} +const char *amd_pstate_get_mode_string (enum amd_pstate_mode mode);int amd_pstate_get_status (void );int amd_pstate_update_status (const char *buf,size_t size);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 324/2651 power: supply: s2mu005-battery: return errors from dev_err_probe() in probe
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zongmin Zhou <[email protected]>
[ Upstream commit 38c8b37600b63db724c9c21d18d9989359353cc4 ]
s2mu005_fg_i2c_probe() calls dev_err_probe() when devm_mutex_init() or devm_request_threaded_irq() fails, but drops the return value and carries on, finally returning 0. A failed probe is then reported as a
success: the device stays registered with an uninitialized mutex and without its IRQ handler installed.
Return the error from dev_err_probe() in both places so that the probe fails and the driver core logs the error state properly.
--- drivers/power/supply/s2mu005-battery.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/s2mu005-battery.c +2 -2
@@ -262,7 +262,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client) ret =devm_mutex_init (dev, &priv->monout_mutex);if (ret) -dev_err_probe (dev, ret,"failed to initialize MONOUT mutex\n" ); +return dev_err_probe (dev, ret,"failed to initialize MONOUT mutex\n" ); psy_desc =device_get_match_data (dev);
@@ -277,7 +277,7 @@ static int s2mu005_fg_i2c_probe(struct i2c_client *client) s2mu005_handle_irq,IRQF_ONESHOT , psy_desc->name, priv);if (ret) -dev_err_probe (dev, ret,"failed to request IRQ\n" ); +return dev_err_probe (dev, ret,"failed to request IRQ\n" );return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 325/2651 power: supply: mp2629: Use the full batt_impedance_compensation name in the ABI document
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit 1101833121a447999309a01f03d5b35bc1652e09 ]
drivers/power/supply/mp2629_charger.c creates the attribute with DEVICE_ATTR_RW(batt_impedance_compensation). The ABI file documents it under the truncated name batt_impedance_compen, which does not exist in sysfs.
Use the full name.
--- Documentation/ABI/testing/sysfs-class-power-mp2629 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-class-power-mp2629 +1 -1
@@ -1,4 +1,4 @@ -What: /sys/class/power_supply/mp2629_battery/batt_impedance_compen +What: /sys/class/power_supply/mp2629_battery/batt_impedance_compensation Date: April 2020 KernelVersion: 5.7 Description:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 326/2651 power: supply: mm8013: Publish the OF module alias
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: hpp.iscas <[email protected]>
[ Upstream commit f265940e54d749c77507da083a3c16a481f5f5c5 ]
The MM8013 driver matches mitsumi,mm8013 Device Tree clients, but exports only its legacy I2C ID table. The I2C core emits an OF modalias for these clients rather than i2c:mm8013.
Publish the existing OF match table without changing gauge operations.
--- drivers/power/supply/mm8013.c | 1 + 1 file changed, 1 insertion(+)
drivers/power/supply/mm8013.c +1 -0
@@ -293,6 +293,7 @@ static const struct of_device_id mm8013_match_table[] = { { .compatible = "mitsumi,mm8013" }, {} }; +MODULE_DEVICE_TABLE (of, mm8013_match_table);static struct i2c_driver mm8013_i2c_driver = { .probe = mm8013_probe,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 327/2651 power: supply: bq24190_charger: use the wake irq API
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryan Brue <[email protected]>
[ Upstream commit ece9baab2a6e79224d3f591893be23b540b1625f ]
bq24190_probe() calls enable_irq_wake() on the charger interrupt and never calls disable_irq_wake(). That is wrong in three ways.
It is unbalanced. free_irq() does not touch desc->wake_depth -- only irq_set_irq_wake() does -- so after the driver is unbound the descriptor is still one wake reference deep and the irqchip is still configured for wake, forever, for an interrupt nobody owns any more.
It ignores the device's wakeup policy. The chip is made a system wake source whether or not anyone asked for it, and because device_init_wakeup() is never called there is no power/wakeup attribute for userspace to say otherwise. A board that would rather not be woken by its charger has no way to express that.
And it arms the interrupt for wake permanently, from probe onwards, rather than for the sleep it is meant to cover.
Use the wake irq API instead: devm_device_init_wakeup() to make the device wakeup-capable and enabled -- preserving today's behaviour -- and devm_pm_set_wake_irq() to hand the interrupt to the PM core, which arms it in dpm_suspend_noirq() (only if device_may_wakeup(), immediately before suspend_device_irqs()) and disarms it on resume. Both are unwound by devm, so the reference is balanced on unbind, and userspace gets the power/wakeup control it should have had.
No intended change in behaviour: charger events still wake the system by default.
The same conversion was made to another charger driver for the same reason, in commit 6c5393771c50 ("power: supply: qcom_pmi8998_charger: fix wakeirq").
--- drivers/power/supply/bq24190_charger.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/power/supply/bq24190_charger.c +8 -1
@@ -10,6 +10,7 @@#include <linux/delay.h> #include <linux/devm-helpers.h> #include <linux/pm_runtime.h> +#include <linux/pm_wakeirq.h> #include <linux/power_supply.h> #include <linux/power/bq24190_charger.h> #include <linux/regulator/driver.h>
@@ -2168,7 +2169,13 @@ static int bq24190_probe(struct i2c_client *client)if (ret <0 ) goto out_charger; -enable_irq_wake (client->irq); + ret =devm_device_init_wakeup (dev); +if (ret <0 ) + goto out_charger; + + ret =devm_pm_set_wake_irq (dev, client->irq); +if (ret <0 ) + goto out_charger;pm_runtime_put_autosuspend (dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 328/2651 dt-bindings: power: bq27xxx: bq27z561: allow interrupts property
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henrik Grimler <[email protected]>
[ Upstream commit c3a6ff174c98f2c7ea213765ff6969140c381e90 ]
According to the technical reference manual for bq27z561 it has support for an interrupt on an INT pin. Remove it from the list of devices without interrupt support to better describe the hardware.
--- Documentation/devicetree/bindings/power/supply/bq27xxx.yaml | 1 - 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/power/supply/bq27xxx.yaml +0 -1
@@ -91,7 +91,6 @@ allOf: - ti,bq27742 - ti,bq27545 - ti,bq27411 - - ti,bq27z561 - ti,bq28z610 - ti,bq34z100 - ti,bq78z100
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 329/2651 power: supply: bq2515x: Propagate charge-enable read errors
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Linmao Li <[email protected]>
[ Upstream commit 4a35810a847411c466a15d1737d11e8e818dc197 ]
bq2515x_get_charge_disable() returns bool even though reading the charger-disable state can fail. A negative error is therefore converted to true, so POWER_SUPPLY_PROP_STATUS reports NOT_CHARGING with success instead of propagating the failure. The GPIO read is not checked for errors either.
Return an int from the helper, check both reads, and only convert a valid charger-disable state to the charging-status boolean.
--- drivers/power/supply/bq2515x_charger.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/power/supply/bq2515x_charger.c +9 -6
@@ -420,7 +420,7 @@ static int bq2515x_get_battery_current_now(struct bq2515x_device *bq2515x) BQ2515X_ICHG_DIVISOR); } -static bool bq2515x_get_charge_disable (struct bq2515x_device *bq2515x) +static int bq2515x_get_charge_disable (struct bq2515x_device *bq2515x) {int ret;int ce_pin;
@@ -428,6 +428,8 @@ static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x)int charger_disable; ce_pin =gpiod_get_value_cansleep (bq2515x->ce_gpio); +if (ce_pin <0 ) +return ce_pin; ret =regmap_read (bq2515x->regmap,BQ2515X_ICCTRL2 , &icctrl2);if (ret)
@@ -435,10 +437,7 @@ static bool bq2515x_get_charge_disable(struct bq2515x_device *bq2515x) charger_disable = icctrl2 &BQ2515X_CHARGER_DISABLE ; -if (charger_disable || ce_pin) -return true; - -return false; +return charger_disable || ce_pin; }static int bq2515x_set_charge_disable (struct bq2515x_device *bq2515x,int val)
@@ -615,7 +614,11 @@ static int bq2515x_charging_status(struct bq2515x_device *bq2515x,else status1_no_fault = false; - ce_status = (!bq2515x_get_charge_disable (bq2515x)); + ret =bq2515x_get_charge_disable (bq2515x); +if (ret <0 ) +return ret; + + ce_status = !ret;/* * If there are no faults and charging is enabled, then status is
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 330/2651 scsi: mpi3mr: Fix buffer overflow in BSG passthrough request copy
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 896abdd4d81f40575b05d593f7fe004935a6cf97 ]
The size of an incoming BSG request is checked using a variable that is narrower than the field it is read from, so large values wrap and pass the check. The copy that follows then uses the full value and writes past the request buffer.
Widen the variable and copy only the amount that was checked.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -2
@@ -2384,7 +2384,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)long rval = -EINVAL ;struct mpi3mr_ioc *mrioc =NULL ;u8 *mpi_req =NULL , *sense_buff_k =NULL ; -u8 mpi_msg_size =0 ; +u32 mpi_msg_size =0 ;struct mpi3mr_bsg_packet *bsg_req =NULL ;struct mpi3mr_bsg_mptcmd *karg;struct mpi3mr_buf_entry *buf_entries =NULL ;
@@ -2538,7 +2538,7 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) rval = -EINVAL ; goto out; } -memcpy (mpi_req, sgl_iter, buf_entries->buf_len); +memcpy (mpi_req, sgl_iter, mpi_msg_size);break ;default : invalid_be =1 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 331/2651 scsi: mpi3mr: Fix out-of-bounds read when copying BSG MPI requests
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9fac4cbd66d852958e8a8d0952eb57f8554ce83b ]
The MPI request is copied out of the caller supplied payload without first checking that the requested amount is actually present, so the copy can read past the end of the payload buffer.
Check the range before copying.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +8 -0
@@ -2538,6 +2538,14 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) rval = -EINVAL ; goto out; } +if (sgl_iter + mpi_msg_size > + dout_buf + job->request_payload.payload_len) { +dprint_bsg_err (mrioc,"%s: MPI request buf exceeds dout_buf\n" , + __func__); +mutex_unlock (&mrioc->bsg_cmds.mutex); + rval = -EINVAL ; + goto out; + }memcpy (mpi_req, sgl_iter, mpi_msg_size);break ;default :
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 332/2651 scsi: mpi3mr: Fix I/O block counter leak on admin request post failure
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 37e7d274272bc5e545e2d5f9261afa7f33f1cf49 ]
The per device I/O block counter is raised before a task management request is posted and only lowered once the request completes. If the post itself fails the counter stays raised and I/O to that device remains blocked.
Lower it on the failure path as well.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_app.c +2 -0
@@ -2782,6 +2782,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)dprint_bsg_err (mrioc,"%s: posting bsg request is failed\n" , __func__); rval = -EAGAIN ; +if (block_io && stgt_priv) +atomic_dec (&stgt_priv->block_io); goto out_unlock; } wait_for_completion_timeout(&mrioc->bsg_cmds.done,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 333/2651 scsi: mpi3mr: Fix target device reference leak in BSG task management
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit f0ec04bdf6156ed2ae7d86a8819dafdd9383b705 ]
The target device lookup takes a reference, but it is only dropped inside a branch that also requires the SCSI target data to be set up. When it is not, the reference is leaked.
Drop the reference whenever the lookup succeeded.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +6 -4
@@ -2745,10 +2745,12 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job) }if (block_io) { tgtdev =mpi3mr_get_tgtdev_by_handle (mrioc, dev_handle); -if (tgtdev && tgtdev->starget && tgtdev->starget->hostdata) { - stgt_priv = (struct mpi3mr_stgt_priv_data *) - tgtdev->starget->hostdata; -atomic_inc (&stgt_priv->block_io); +if (tgtdev) { +if (tgtdev->starget && tgtdev->starget->hostdata) { + stgt_priv = (struct mpi3mr_stgt_priv_data *) + tgtdev->starget->hostdata; +atomic_inc (&stgt_priv->block_io); + }mpi3mr_tgtdev_put (tgtdev); } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 334/2651 scsi: mpi3mr: Fix buffer overflow when caching log data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9ff1af19c488efad66f2b803eefa0abd5fdac8f4 ]
Each log data slot holds a header followed by the payload, but the copy was sized against the whole slot and so wrote one header length past the end of it. Subtracting the header on its own is not enough either, because the entry size is derived from the controller reply size and can be smaller than the header.
Work out the payload room first and clamp the copy to it.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +8 -2
@@ -2947,7 +2947,8 @@ static long mpi3mr_bsg_process_mpt_cmds(struct bsg_job *job)void mpi3mr_app_save_logdata_th (struct mpi3mr_ioc *mrioc,char *event_data,u16 event_data_size) { -u32 index = mrioc->logdata_buf_idx, sz; +u32 index = mrioc->logdata_buf_idx; +size_t entry_payload_len, sz;struct mpi3mr_logdata_entry *entry;if (!(mrioc->logdata_buf))
@@ -2956,7 +2957,12 @@ void mpi3mr_app_save_logdata_th(struct mpi3mr_ioc *mrioc, char *event_data, entry = (struct mpi3mr_logdata_entry *) (mrioc->logdata_buf + (index * mrioc->logdata_entry_sz)); entry->valid_entry =1 ; - sz =min (mrioc->logdata_entry_sz, event_data_size); +if (mrioc->logdata_entry_sz >MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ ) + entry_payload_len = (size_t )mrioc->logdata_entry_sz - +MPI3MR_BSG_LOGDATA_ENTRY_HEADER_SZ ; +else + entry_payload_len =0 ; + sz =min_t (size_t, entry_payload_len, event_data_size);memcpy (entry->data, event_data, sz); mrioc->logdata_buf_idx = ((++index) %MPI3MR_BSG_LOGDATA_MAX_ENTRIES );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 335/2651 scsi: mpi3mr: Fix out-of-bounds reply frame access
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit bcf0a5bed59acd5ae19d80e1f617c1a5b355af0b ]
The reply frame address reported on completion is only checked against the start and the end of the pool. An address near the top can pass the check while leaving less than a full frame, and an unaligned one resolves into the middle of a frame instead of the start of one.
Require a whole frame to fit and the address to be frame aligned.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_fw.c +6 -1
@@ -124,11 +124,16 @@ void mpi3mr_build_zero_len_sge(void *paddr)void *mpi3mr_get_reply_virt_addr (struct mpi3mr_ioc *mrioc,dma_addr_t phys_addr) { +u64 offset; +if (!phys_addr)return NULL ; + offset = phys_addr - mrioc->reply_buf_dma; +if ((phys_addr < mrioc->reply_buf_dma) || - (phys_addr > mrioc->reply_buf_dma_max_address)) + (phys_addr > mrioc->reply_buf_dma_max_address - mrioc->reply_sz) || +do_div (offset, mrioc->reply_sz))return NULL ;return mrioc->reply_buf + (phys_addr - mrioc->reply_buf_dma);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 336/2651 scsi: mpi3mr: Fix out-of-bounds sense buffer access
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 7fea128f6b829ad834f21834d2605d28a45b903d ]
The sense buffer address reported on completion is turned into a virtual address with no range check, so an address outside the pool resolves to memory that does not belong to it.
Check that it lies within the pool and is correctly aligned.
--- drivers/scsi/mpi3mr/mpi3mr_fw.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_fw.c +10 -0
@@ -142,9 +142,19 @@ void *mpi3mr_get_reply_virt_addr(struct mpi3mr_ioc *mrioc,void *mpi3mr_get_sensebuf_virt_addr (struct mpi3mr_ioc *mrioc,dma_addr_t phys_addr) { +u64 offset; +if (!phys_addr)return NULL ; + offset = phys_addr - mrioc->sense_buf_dma; + +if (phys_addr < mrioc->sense_buf_dma || + (phys_addr > mrioc->sense_buf_dma + + (mrioc->num_sense_bufs *MPI3MR_SENSE_BUF_SZ ) -MPI3MR_SENSE_BUF_SZ ) || +do_div (offset,MPI3MR_SENSE_BUF_SZ )) +return NULL ; +return mrioc->sense_buf + (phys_addr - mrioc->sense_buf_dma); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 337/2651 scsi: mpi3mr: Fix out-of-bounds bitmap access during device removal
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 5dade59551d344d0308256edfef6bc3fb4202eb3 ]
Device handles reported by the controller are used to index the remove pending bitmap and to build a task management request without being compared against the maximum handle the controller reported.
Check the handle before using it.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +16 -1
@@ -2426,7 +2426,8 @@ static void mpi3mr_dev_rmhs_complete_iou(struct mpi3mr_ioc *mrioc,ioc_info (mrioc,"%s :dev removal handshake completed successfully: handle(0x%04x)\n" , __func__, drv_cmd->dev_handle); -clear_bit (drv_cmd->dev_handle, mrioc->removepend_bitmap); +if (drv_cmd->dev_handle < mrioc->facts.max_devhandle) +clear_bit (drv_cmd->dev_handle, mrioc->removepend_bitmap); }if (!list_empty (&mrioc->delayed_rmhs_list)) {
@@ -2540,6 +2541,20 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle,struct mpi3mr_tgt_dev *tgtdev =NULL ;unsigned long flags; +if (handle >= mrioc->facts.max_devhandle) { +ioc_err (mrioc,"dev_remove_hs: handle(0x%04x) >= max_devhandle(0x%04x)\n" , + handle, mrioc->facts.max_devhandle); +if (drv_cmd) { + cmd_idx = drv_cmd->host_tag -MPI3MR_HOSTTAG_DEVRMCMD_MIN ; + drv_cmd->state =MPI3MR_CMD_NOTUSED ; + drv_cmd->callback =NULL ; + drv_cmd->dev_handle =MPI3MR_INVALID_DEV_HANDLE ; + drv_cmd->retry_count =0 ; +clear_bit (cmd_idx, mrioc->devrem_bitmap); + } +return ; + } +spin_lock_irqsave (&mrioc->tgtdev_lock, flags); tgtdev =__mpi3mr_get_tgtdev_by_handle (mrioc, handle);if (tgtdev && (iou_rc ==MPI3_CTRL_OP_REMOVE_DEVICE ))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 338/2651 scsi: mpi3mr: Fix target device reference leak in device removal handshake
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit a04b0f3a17e32aa449fd896163a7b40efc29c4f5 ]
The device removal handshake looks up the target device to update its state but never drops the reference that the lookup takes.
Drop it once the state has been updated.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_os.c +3 -0
@@ -2561,6 +2561,9 @@ static void mpi3mr_dev_rmhs_send_tm(struct mpi3mr_ioc *mrioc, u16 handle, tgtdev->state =MPI3MR_DEV_REMOVE_HS_STARTED ;spin_unlock_irqrestore (&mrioc->tgtdev_lock, flags); +if (tgtdev) +mpi3mr_tgtdev_put (tgtdev); +if (drv_cmd) goto issue_cmd; do {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 339/2651 scsi: mpi3mr: Fix out-of-bounds read in SAS topology change events
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 9e220ce4bd0468e47cc9eea07e40799ebae6eda8 ]
The number of entries in a SAS topology change event is used to walk the entry array without being compared against the amount of event data that was received, so the walk can run past the end of the buffer.
Work out how many entries the payload can hold and skip the event if it claims more.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +19 -3
@@ -2852,12 +2852,28 @@ static void mpi3mr_sastopochg_evt_th(struct mpi3mr_ioc *mrioc,struct mpi3_event_data_sas_topology_change_list *topo_evt = (struct mpi3_event_data_sas_topology_change_list *)event_reply->event_data;int i; -u16 handle; -u8 reason_code; +u16 handle, avail_len; +u8 reason_code, max_entries, num_entries;struct mpi3mr_tgt_dev *tgtdev =NULL ;struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data =NULL ; -for (i =0 ; i < topo_evt->num_entries; i++) { + avail_len = event_reply->event_data_length *4 ; +if (avail_len < offsetof(struct mpi3_event_data_sas_topology_change_list , phy_entry)) { +ioc_err (mrioc,"SAS topology event: event data too small (%u bytes)\n" , + avail_len); +return ; + } + max_entries = (avail_len - + offsetof(struct mpi3_event_data_sas_topology_change_list , phy_entry)) / +sizeof (struct mpi3_event_sas_topo_phy_entry ); + num_entries = topo_evt->num_entries; +if (num_entries > max_entries) { +ioc_err (mrioc,"SAS topology event: num_entries(%d) exceeds max(%d)\n" , + num_entries, max_entries); +return ; + } + +for (i =0 ; i < num_entries; i++) { handle =le16_to_cpu (topo_evt->phy_entry[i].attached_dev_handle);if (!handle)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 340/2651 scsi: mpi3mr: Fix out-of-bounds read of event data
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 77554f01187d91c20f04d2a8e28270943ed64cca ]
The event data length from the reply is used as is, both when caching log data and when sizing the buffer handed to the bottom half. A length larger than the frame makes both of them read past the end of it.
Clamp the length to what the frame can hold.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +13 -3
@@ -3143,7 +3143,7 @@ void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc)void mpi3mr_os_handle_events (struct mpi3mr_ioc *mrioc,struct mpi3_event_notification_reply *event_reply) { -u16 evt_type, sz; +u16 evt_type, sz, avail_reply_room;struct mpi3mr_fwevt *fwevt =NULL ;bool ack_req =0 , process_evt_bh =0 ;
@@ -3204,7 +3204,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,case MPI3_EVENT_DEVICE_INFO_CHANGED :case MPI3_EVENT_LOG_DATA : - sz = event_reply->event_data_length *4 ; +if (mrioc->reply_sz > offsetof(struct mpi3_event_notification_reply , event_data)) + avail_reply_room = mrioc->reply_sz - + offsetof(struct mpi3_event_notification_reply , event_data); +else + avail_reply_room =0 ; + sz =min_t (u16, event_reply->event_data_length *4 , avail_reply_room);mpi3mr_app_save_logdata_th (mrioc, (char *)event_reply->event_data, sz);break ;
@@ -3238,7 +3243,12 @@ void mpi3mr_os_handle_events(struct mpi3mr_ioc *mrioc,dprint_event_th (mrioc,"scheduling bottom half handler for event(0x%02x) - (0x%08x), ack_required=%d\n" , evt_type,le32_to_cpu (event_reply->event_context), ack_req); - sz = event_reply->event_data_length *4 ; +if (mrioc->reply_sz > offsetof(struct mpi3_event_notification_reply , event_data)) + avail_reply_room = mrioc->reply_sz - + offsetof(struct mpi3_event_notification_reply , event_data); +else + avail_reply_room =0 ; + sz =min_t (u16, event_reply->event_data_length *4 , avail_reply_room); fwevt =mpi3mr_alloc_fwevt (sz);if (!fwevt) { dprint_event_th(mrioc,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 341/2651 scsi: mpi3mr: Fix out-of-bounds phy array access on link change
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit f67caaa2521a3c8f931d1e679d831ba5ca654794 ]
The phy number that comes with a link change is used to index the node's phy array without being compared against the number of phys allocated for that node.
Check it first.
--- drivers/scsi/mpi3mr/mpi3mr_transport.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/scsi/mpi3mr/mpi3mr_transport.c +7 -0
@@ -1090,6 +1090,13 @@ void mpi3mr_update_links(struct mpi3mr_ioc *mrioc,return ; } +if (phy_number >= mr_sas_node->num_phys) { +spin_unlock_irqrestore (&mrioc->sas_node_lock, flags); +ioc_err (mrioc,"%s: phy_number(%d) >= num_phys(%d)\n" , + __func__, phy_number, mr_sas_node->num_phys); +return ; + } + mr_sas_phy = &mr_sas_node->phy[phy_number]; mr_sas_phy->attached_handle = handle;spin_unlock_irqrestore (&mrioc->sas_node_lock, flags);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 342/2651 scsi: mpi3mr: Fix buffer overflow in the BSG target device map
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 203b3072e7aa10d98b3f2b766693ea925cfc571d ]
The size of the target device map buffer is held in a u16 while the number of devices it is derived from is not bounded to fit. With enough devices the size wraps, a short buffer is allocated, and the loop that fills it writes past the end.
Do the calculation in size_t.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +4 -3
@@ -1466,7 +1466,8 @@ static long mpi3mr_bsg_pel_enable(struct mpi3mr_ioc *mrioc,static long mpi3mr_get_all_tgt_info (struct mpi3mr_ioc *mrioc,struct bsg_job *job) { -u16 num_devices =0 , i =0 , size; +u16 num_devices =0 , i =0 ; +size_t size;unsigned long flags;struct mpi3mr_tgt_dev *tgtdev;struct mpi3mr_device_map_info *devmap_info =NULL ;
@@ -1492,8 +1493,8 @@ static long mpi3mr_get_all_tgt_info(struct mpi3mr_ioc *mrioc,return 0 ; } - kern_entrylen = num_devices *sizeof (*devmap_info); - size =sizeof (u64) + kern_entrylen; + kern_entrylen = (uint32_t )num_devices *sizeof (*devmap_info); + size =sizeof (u64) + (size_t )kern_entrylen; alltgt_info =kzalloc (size,GFP_KERNEL );if (!alltgt_info)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 343/2651 scsi: mpi3mr: Fix out-of-bounds read in PCIe topology change events
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 7d572b4dc4ed0494e67097d4b7368666655f5c99 ]
The number of entries in a PCIe topology change event is used to walk the entry array without being compared against the amount of event data that was received.
Bound the entry count to the received event data before use.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +19 -3
@@ -2786,12 +2786,28 @@ static void mpi3mr_pcietopochg_evt_th(struct mpi3mr_ioc *mrioc,struct mpi3_event_data_pcie_topology_change_list *topo_evt = (struct mpi3_event_data_pcie_topology_change_list *)event_reply->event_data;int i; -u16 handle; -u8 reason_code; +u16 handle, avail_len; +u8 reason_code, max_entries, num_entries;struct mpi3mr_tgt_dev *tgtdev =NULL ;struct mpi3mr_stgt_priv_data *scsi_tgt_priv_data =NULL ; -for (i =0 ; i < topo_evt->num_entries; i++) { + avail_len = event_reply->event_data_length *4 ; +if (avail_len < offsetof(struct mpi3_event_data_pcie_topology_change_list , port_entry)) { +ioc_err (mrioc,"PCIe topology event: event data too small (%u bytes)\n" , + avail_len); +return ; + } + max_entries = (avail_len - + offsetof(struct mpi3_event_data_pcie_topology_change_list , port_entry)) / +sizeof (struct mpi3_event_pcie_topo_port_entry ); + num_entries = topo_evt->num_entries; +if (num_entries > max_entries) { +ioc_err (mrioc,"PCIe topology event: num_entries(%d) exceeds max(%d)\n" , + num_entries, max_entries); +return ; + } + +for (i =0 ; i < num_entries; i++) { handle =le16_to_cpu (topo_evt->port_entry[i].attached_dev_handle);if (!handle)continue ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 344/2651 scsi: mpi3mr: zero out diagnostic buffer status memory
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 052aea807cfbcefaf5b6ed8202f65da1fc65f4a0 ]
Memory allocated for the BSG diagnostic buffer status is not zeroed before it is copied back to user space. Several fields in this structure are reserved and never written by the driver. Use kzalloc() instead of kmalloc() to zero out the allocated memory.
--- drivers/scsi/mpi3mr/mpi3mr_app.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/mpi3mr/mpi3mr_app.c +1 -1
@@ -1244,7 +1244,7 @@ static long mpi3mr_bsg_query_hdb(struct mpi3mr_ioc *mrioc, length = (sizeof (*hbd_status) + ((MPI3MR_MAX_NUM_HDB -1 ) *sizeof (*hbd_status_entry))); - hbd_status =kmalloc (length,GFP_KERNEL ); + hbd_status =kzalloc (length,GFP_KERNEL );if (!hbd_status)return -ENOMEM ; hbd_status_entry = &hbd_status->entry[0 ];
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 345/2651 scsi: mpi3mr: Fix use-after-free of the firmware event workqueue
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit c94c746e6c80439a4a9a0e1e20f2dae62a4d57ef ]
The enqueue path reads the workqueue pointer before taking the event lock, while the remove path clears that pointer and destroys the workqueue while holding it. The enqueue can therefore reach queue_work() after the workqueue is gone.
Move the check inside the lock.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +4 -3
@@ -233,10 +233,11 @@ static void mpi3mr_fwevt_add_to_list(struct mpi3mr_ioc *mrioc, {unsigned long flags; -if (!mrioc->fwevt_worker_thread) -return ; -spin_lock_irqsave (&mrioc->fwevt_lock, flags); +if (!mrioc->fwevt_worker_thread) { +spin_unlock_irqrestore (&mrioc->fwevt_lock, flags); +return ; + }/* get fwevt reference count while adding it to fwevt_list */ mpi3mr_fwevt_get (fwevt);INIT_LIST_HEAD (&fwevt->list);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 346/2651 scsi: mpi3mr: Fix NULL pointer dereference on PCI error recovery
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chandrakanth Patil <[email protected]>
[ Upstream commit 2ba1d12b2629827fdb1116eb3c9f8566911f2034 ]
On a frozen PCI channel the driver unmaps the register window and frees the interrupts, but leaves the firmware event workqueue running. An event handler that is already in flight can still reach the register window after it has been unmapped.
Stop event processing and drain the queue first, and start it again when the channel resumes.
--- drivers/scsi/mpi3mr/mpi3mr_os.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/mpi3mr/mpi3mr_os.c +5 -3
@@ -2155,9 +2155,11 @@ static void mpi3mr_fwevt_bh(struct mpi3mr_ioc *mrioc,mpi3mr_fwevt_del_from_list (mrioc, fwevt); mrioc->current_event = fwevt; -if (mrioc->stop_drv_processing) { -dprint_event_bh (mrioc,"ignoring event(0x%02x) in the bottom half handler\n" -"due to stop_drv_processing\n" , fwevt->event_id); +if (mrioc->stop_drv_processing || mrioc->pci_err_recovery) { +dprint_event_bh (mrioc, +"ignoring event(0x%02x) in the bottom half handler\n" +"due to stop_drv_processing or pci_err_recovery\n" , + fwevt->event_id); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 347/2651 iio: accel: kionix-kx022a: Fix IPOL macro name
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matti Vaittinen <[email protected]>
[ Upstream commit 4a4b0d75622f7d911c96045b328fe2e88be05072 ]
The "interrupt polarity high"-macro for KX022A variant is defined as:
"#define KX022A_MASK_IPOL KX022A_MASK_IPOL1"
However, the KX022A_MASK_IPOL1 is not defined anywhere, so actually using the KX022A_IPOL_HIGH would produce a compile error.
Fix the define by using correct mask.
--- drivers/iio/accel/kionix-kx022a.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/kionix-kx022a.h +1 -1
@@ -65,7 +65,7 @@#define KX022A_MASK_IEN BIT(5)#define KX022A_MASK_IPOL BIT(4)#define KX022A_IPOL_LOW 0 -#define KX022A_IPOL_HIGH KX022A_MASK_IPOL1 +#define KX022A_IPOL_HIGH KX022A_MASK_IPOL#define KX022A_MASK_ITYP BIT(3)#define KX022A_ITYP_PULSE KX022A_MASK_ITYP#define KX022A_ITYP_LEVEL 0
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 348/2651 iio: imu: adis16400: Check return value of spi_setup()
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Salah Triki <[email protected]>
[ Upstream commit a7c07602e00596a45de8a4a700af96392953ed38 ]
In adis16400_initial_setup(), the return value of spi_setup() was ignored. If SPI configuration fails, the driver would proceed with the initialization anyway, leading to undefined behavior or silent failures during device setup.
Check the return value of spi_setup() and return the error code immediately if it fails.
--- drivers/iio/imu/adis16400.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/iio/imu/adis16400.c +4 -1
@@ -420,7 +420,10 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)else st->adis.spi->max_speed_hz =ADIS16400_SPI_FAST ; st->adis.spi->mode =SPI_MODE_3 ; -spi_setup (st->adis.spi); + + ret =spi_setup (st->adis.spi); +if (ret) +return ret; ret =__adis_initial_startup (&st->adis);if (ret)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 349/2651 efi/libstub: Fix efi_set_event_at() parameter documentation
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Karl Mehltretter <[email protected]>
[ Upstream commit c12a3a4b35e47fd511fbd550d3637318be41c4eb ]
efi_set_event_at() documents ids although its array index argument is named idx. This produces missing and excess parameter warnings.
Match the argument name and fix the adjacent spelling of array.
--- drivers/firmware/efi/libstub/efistub.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/firmware/efi/libstub/efistub.h +2 -2
@@ -224,8 +224,8 @@ typedef void (__efiapi *efi_event_notify_t)(efi_event_t, void *);* efi_set_event_at() - add event to events array * * @events: array of UEFI events -* @ids: index where to put the event in the array -* @event: event to add to the aray +* @idx: index where to put the event in the array +* @event: event to add to the array * * boottime->wait_for_event() takes an array of events as input. * Provide a helper to set it up correctly for mixed mode.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 350/2651 kernfs: fix up the unlocked attribute reads on the creation paths
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shakeel Butt <[email protected]>
[ Upstream commit 81bdc85b4c086502f4446a58eb5d25f29bb5e9f7 ]
Two creation paths read a live node's attributes without holding kernfs_iattr_rwsem, which kernfs_iop_setattr() takes for writing. They need different fixes.
kernfs_create_link() copies the target's ia_uid and then its ia_gid into the new link. A chown of the target between the two reads leaves the link with the old uid and the new gid, an owner the target never had. Read both under the rwsem.
kernfs_new_node() reads the parent's mode and ia_gid for S_ISGID inheritance. Either value is fine there: the node does not exist yet, so nothing orders a racing chmod or chown against the creation. Taking the rwsem would only pick between two answers that are both right. Mark the reads with READ_ONCE() instead.
The pointer that leads to them is already fine: __kernfs_iattrs() publishes kernfs_node::iattr with try_cmpxchg(), and both sides read it with READ_ONCE(), like the rest of fs/kernfs.
The Fixes tag is for the symlink half. kernfs_create_link() has read the pair unlocked since it started copying the target's owner; only the name of the lock its writer takes has changed. The READ_ONCE() markings are not a fix.
--- fs/kernfs/dir.c | 12 +++++++++--- fs/kernfs/symlink.c | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-)
fs/kernfs/dir.c +9 -3
@@ -736,13 +736,19 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, {struct kernfs_node *kn; -if (parent->mode &S_ISGID ) { +/* +* The mode and the gid below are read unlocked on purpose: they feed +* a node that does not exist yet, so nothing orders a racing chmod or +* chown against this creation. +*/ +if (READ_ONCE (parent->mode) &S_ISGID ) {/* this code block imitates inode_init_owner() for * kernfs */ +struct kernfs_iattrs *attrs =READ_ONCE (parent->iattr); -if (parent->iattr) - gid = parent->iattr->ia_gid; +if (attrs) + gid =READ_ONCE (attrs->ia_gid);if (flags &KERNFS_DIR ) mode |=S_ISGID ;
fs/kernfs/symlink.c +14 -3
@@ -31,9 +31,20 @@ struct kernfs_node *kernfs_create_link(struct kernfs_node *parent,kuid_t uid =GLOBAL_ROOT_UID ;kgid_t gid =GLOBAL_ROOT_GID ; -if (target->iattr) { - uid = target->iattr->ia_uid; - gid = target->iattr->ia_gid; +/* +* A symlink takes its owner from its target, so both fields have to +* come from the same moment: read them under kernfs_iattr_rwsem, or +* a chown of the target racing this could leave the link with the +* old uid and the new gid. The section ends before kernfs_add_one() +* takes kernfs_rwsem. +*/ + scoped_guard(rwsem_read, &kernfs_root(target)->kernfs_iattr_rwsem) { +struct kernfs_iattrs *attrs =READ_ONCE (target->iattr); + +if (attrs) { + uid = attrs->ia_uid; + gid = attrs->ia_gid; + } } kn =kernfs_new_node (parent, name,S_IFLNK |0777 , uid, gid,KERNFS_LINK );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 351/2651 arm64: dts: mediatek: mt8188-geralt: Enlarge SCP core0 memory region
In reply to Greg Kroah-Hartman7.3-stable review patch. If anyone has any objections, please let me know.
------------------
From: Justin Yeh <[email protected]>
[ Upstream commit 868297e3ebcc5c9b0e7cada19c82b11068faf4bf ]
The SCP firmware in linux-firmware for this platform (mediatek/mt8188/scp_c0.img) supports MDP, which the mdp3-rdma node drives through scp_c0. On top of the segments it loads, the firmware allocates a 1 MiB DMA region at 0x50800000 at run time. That lies outside the 8 MiB reserved for SCP core0, so Linux is free to allocate over memory the firmware uses.
Enlarge the region to 9 MiB. apu_mem starts at 0x55000000, so no other reserved region has to move.
--- arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/boot/dts/mediatek/mt8188-geralt.dtsi +1 -1
@@ -171,7 +171,7 @@ reserved_memory: reserved-memory { scp_mem_reserved: memory@50000000 { compatible = "shared-dma-pool"; - reg = <0 0x50000000 0 0x800000>; + reg = <0 0x50000000 0 0x900000>; no-map; };
Signature · 1 line
2.53.0