6.18.40-rc1 review
Subsystems (13)
Greg Kroah-Hartman
maintainerPATCH 397/1611 hwspinlock: qcom: avoid uninitialized struct members
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wolfram Sang <[email protected]>
[ Upstream commit 8752c396ce3b2136b3d4c906fe103f6efb6782d9 ]
The reg_field is allocated on stack, so using the REG_FIELD macro will ensure that unused members do not have uninitialized values.
--- drivers/hwspinlock/qcom_hwspinlock.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/hwspinlock/qcom_hwspinlock.c +1 -4
@@ -202,7 +202,6 @@ static struct regmap *qcom_hwspinlock_probe_mmio(struct platform_device *pdev,static int qcom_hwspinlock_probe (struct platform_device *pdev) {struct hwspinlock_device *bank; -struct reg_field field;struct regmap *regmap;size_t array_size;u32 stride;
@@ -224,9 +223,7 @@ static int qcom_hwspinlock_probe(struct platform_device *pdev)platform_set_drvdata (pdev, bank);for (i =0 ; i <QCOM_MUTEX_NUM_LOCKS ; i++) { - field.reg = base + i * stride; - field.lsb =0 ; - field.msb =31 ; +struct reg_field field =REG_FIELD (base + i * stride,0 ,31 ); bank->lock[i].priv =devm_regmap_field_alloc (&pdev->dev, regmap, field);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 398/1611 sched/fair: Fix cpu_util runnable_avg arithmetic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongyan Xia <[email protected]>
[ Upstream commit 29922fdfc2a4008d66418bedd0ebf5038fc54efa ]
If we take runnable_avg in max(runnable_avg, util_avg) in cpu_util(), we should then add or subtract task runnable_avg, but the arithmetic below is still with task util_avg. This mixes runnable_avg with util_avg which is incorrect.
Fix by always doing arithmetic with runnable_avg and only take max(runnable_avg, util_avg) at the last step.
--- kernel/sched/fair.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
kernel/sched/fair.c +15 -8
@@ -8047,25 +8047,32 @@ static int select_idle_sibling(struct task_struct *p, int prev, int target)static unsigned long cpu_util (int cpu,struct task_struct *p,int dst_cpu,int boost) { +bool add_task = p &&task_cpu (p) != cpu && dst_cpu == cpu; +bool sub_task = p &&task_cpu (p) == cpu && dst_cpu != cpu;struct cfs_rq *cfs_rq = &cpu_rq (cpu)->cfs;unsigned long util =READ_ONCE (cfs_rq->avg.util_avg);unsigned long runnable; -if (boost) { - runnable =READ_ONCE (cfs_rq->avg.runnable_avg); - util =max (util, runnable); - } -/* * If @dst_cpu is -1 or @p migrates from @cpu to @dst_cpu remove its * contribution. If @p migrates from another CPU to @cpu add its * contribution. In all the other cases @cpu is not impacted by the * migration so its util_avg is already correct. */ -if (p &&task_cpu (p) == cpu && dst_cpu != cpu) -lsub_positive (&util,task_util (p)); -else if (p &&task_cpu (p) != cpu && dst_cpu == cpu) +if (add_task) util +=task_util (p); +else if (sub_task) +lsub_positive (&util,task_util (p)); + +if (boost) { + runnable =READ_ONCE (cfs_rq->avg.runnable_avg); +if (add_task) + runnable +=READ_ONCE (p->se.avg.runnable_avg); +else if (sub_task) +lsub_positive (&runnable, +READ_ONCE (p->se.avg.runnable_avg)); + util =max (util, runnable); + }if (sched_feat (UTIL_EST )) {unsigned long util_est;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 399/1611 ARM: configs: Drop duplicated CONFIG_EXT4_FS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit ae371a58117d30a496e3be27cce8d9d13acdd740 ]
Remove redundant, duplicated CONFIG_EXT4_FS to fix warnings like:
axm55xx_defconfig:198:warning: override: reassigning to symbol EXT4_FS
--- arch/arm/configs/axm55xx_defconfig | 1 - arch/arm/configs/dove_defconfig | 1 - arch/arm/configs/ep93xx_defconfig | 1 - arch/arm/configs/mmp2_defconfig | 1 - arch/arm/configs/mv78xx0_defconfig | 1 - 5 files changed, 5 deletions(-)
arch/arm/configs/axm55xx_defconfig +0 -1
@@ -195,7 +195,6 @@ CONFIG_PL320_MBOX=y # CONFIG_IOMMU_SUPPORT is not set CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y -CONFIG_EXT4_FS=y CONFIG_AUTOFS_FS=y CONFIG_FUSE_FS=y CONFIG_CUSE=y
arch/arm/configs/dove_defconfig +0 -1
@@ -97,7 +97,6 @@ CONFIG_MV_XOR=y CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y # CONFIG_EXT4_FS_XATTR is not set -CONFIG_EXT4_FS=y CONFIG_ISO9660_FS=y CONFIG_JOLIET=y CONFIG_UDF_FS=m
arch/arm/configs/ep93xx_defconfig +0 -1
@@ -105,7 +105,6 @@ CONFIG_EP93XX_DMA=y CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y # CONFIG_EXT4_FS_XATTR is not set -CONFIG_EXT4_FS=y CONFIG_VFAT_FS=y CONFIG_TMPFS=y CONFIG_JFFS2_FS=y
arch/arm/configs/mmp2_defconfig +0 -1
@@ -54,7 +54,6 @@ CONFIG_RTC_DRV_MAX8925=y # CONFIG_RESET_CONTROLLER is not set CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y -CONFIG_EXT4_FS=y # CONFIG_DNOTIFY is not set CONFIG_MSDOS_FS=y CONFIG_FAT_DEFAULT_CODEPAGE=437
arch/arm/configs/mv78xx0_defconfig +0 -1
@@ -93,7 +93,6 @@ CONFIG_RTC_DRV_M41T80=y CONFIG_EXT2_FS=y CONFIG_EXT4_FS=y # CONFIG_EXT4_FS_XATTR is not set -CONFIG_EXT4_FS=m CONFIG_ISO9660_FS=m CONFIG_JOLIET=y CONFIG_UDF_FS=m
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 400/1611 wifi: mt76: mt7925: clean up DMA on probe failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Myeonghun Pak <[email protected]>
[ Upstream commit 9629f31f505d74e76ac0d7a9492fd06c0316fc5d ]
mt7925_pci_probe() initializes DMA before registering the device. If mt7925_register_device() fails, probe returns through err_free_irq without tearing down DMA state.
That leaves the TX NAPI instance enabled and skips the DMA queue cleanup that the normal remove path performs through mt7925e_unregister_device(). Add a dedicated unwind label for failures after mt7925_dma_init() succeeds.
--- drivers/net/wireless/mediatek/mt76/mt7925/pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7925/pci.c +3 -1
@@ -414,10 +414,12 @@ static int mt7925_pci_probe(struct pci_dev *pdev, ret =mt7925_register_device (dev);if (ret) - goto err_free_irq; + goto err_free_dma;return 0 ; +err_free_dma: +mt792x_dma_cleanup (dev); err_free_irq:devm_free_irq (&pdev->dev, pdev->irq, dev); err_free_dev:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 401/1611 wifi: mt76: use kfree_rcu for offchannel link in mt76_put_vif_phy_link
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rajat Gupta <[email protected]>
[ Upstream commit 7fae097aa9a56c30febf539d72ef3773165d3aa3 ]
mt76_put_vif_phy_link() frees the offchannel mlink with plain kfree() after rcu_assign_pointer(NULL). However, rcu_assign_pointer only prevents future RCU readers from obtaining the pointer -- it does not wait for existing readers that already hold it via rcu_dereference.
The TX datapath (e.g. mt7996_mac_write_txwi) dereferences mlink->wcid and mlink->idx under rcu_read_lock. If a TX softirq obtained the pointer via rcu_dereference just before the NULL assignment, it will dereference freed memory after the kfree.
struct mt76_vif_link already contains an rcu_head field that is unused at this free site -- a developer oversight, since the adjacent kfree_rcu_mightsleep call for rx_sc in the same function shows the pattern was understood.
Replace kfree(mlink) with kfree_rcu(mlink, rcu_head).
--- drivers/net/wireless/mediatek/mt76/channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/channel.c +1 -1
@@ -311,7 +311,7 @@ void mt76_put_vif_phy_link(struct mt76_phy *phy, struct ieee80211_vif *vif,rcu_assign_pointer (mvif->offchannel_link,NULL ); dev->drv->vif_link_remove (phy, vif, &vif->bss_conf, mlink); -kfree (mlink); +kfree_rcu (mlink, rcu_head); }void mt76_roc_complete (struct mt76_phy *phy)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 402/1611 wifi: mt76: mt7996: add missing max_remain_on_channel_duration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Fietkau <[email protected]>
[ Upstream commit ac41612e0044fa29cf9bc45b6808dda6d87ac2da ]
Having this unset breaks remain-on-channel and mgmt TX. Move setting it to mt76 core to keep it in one place.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 ++ drivers/net/wireless/mediatek/mt76/mt7615/init.c | 1 - drivers/net/wireless/mediatek/mt76/mt792x_core.c | 1 - 3 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -0
@@ -449,6 +449,8 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw)wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_AIRTIME_FAIRNESS );wiphy_ext_feature_set (wiphy,NL80211_EXT_FEATURE_AQL ); +if (!wiphy->max_remain_on_channel_duration) + wiphy->max_remain_on_channel_duration =5000 ;if (!wiphy->available_antennas_tx) wiphy->available_antennas_tx = phy->antenna_mask;if (!wiphy->available_antennas_rx)
drivers/net/wireless/mediatek/mt76/mt7615/init.c +0 -1
@@ -195,7 +195,6 @@ mt7615_check_offload_capability(struct mt7615_dev *dev)ieee80211_hw_set (hw,SUPPORTS_DYNAMIC_PS ); wiphy->flags &= ~WIPHY_FLAG_4ADDR_STATION ; - wiphy->max_remain_on_channel_duration =5000 ; wiphy->features |=NL80211_FEATURE_SCHED_SCAN_RANDOM_MAC_ADDR |NL80211_FEATURE_SCAN_RANDOM_MAC_ADDR | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL |
drivers/net/wireless/mediatek/mt76/mt792x_core.c +0 -1
@@ -657,7 +657,6 @@ int mt792x_init_wiphy(struct ieee80211_hw *hw)BIT (NL80211_IFTYPE_P2P_CLIENT ) |BIT (NL80211_IFTYPE_P2P_GO ) |BIT (NL80211_IFTYPE_P2P_DEVICE ); - wiphy->max_remain_on_channel_duration =5000 ; wiphy->max_scan_ie_len =MT76_CONNAC_SCAN_IE_LEN ; wiphy->max_scan_ssids =4 ; wiphy->max_sched_scan_plan_interval =
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 403/1611 wifi: mt76: mt7925: fix stale pointer comparisons in change_vif_links
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Javier Tia <[email protected]>
[ Upstream commit 9f1accf3069a0cd42c14ca6c7d44d5b17cc48a80 ]
In the error path of mt7925_change_vif_links(), the free: label iterates over link_ids to clean up, but compares against mconf and mlink which hold stale values from the last loop iteration rather than the current link_id being freed.
Use array-indexed access (mconfs[link_id] / mlinks[link_id]) to compare against the correct per-link pointers.
--- drivers/net/wireless/mediatek/mt76/mt7925/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/main.c +2 -2
@@ -2066,9 +2066,9 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif,rcu_assign_pointer (mvif->link_conf[link_id],NULL );rcu_assign_pointer (mvif->sta.link[link_id],NULL ); -if (mconf != &mvif->bss_conf) +if (mconfs[link_id] != &mvif->bss_conf)devm_kfree (dev->mt76.dev, mconfs[link_id]); -if (mlink != &mvif->sta.deflink) +if (mlinks[link_id] != &mvif->sta.deflink)devm_kfree (dev->mt76.dev, mlinks[link_id]); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 404/1611 wifi: mt76: mt7925: keep TX BA state in the primary WCID
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit d3c854068bad22a25db6515f12784f64c663fed2 ]
For MLO, the same TID can run over different links. Keeping TX BA state in a link WCID makes the state depend on which link starts aggregation first.
Store it in the primary WCID instead, so the BA state stays stable across links.
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +7 -8
@@ -840,7 +840,6 @@ static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb, {struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);struct ieee80211_link_sta *link_sta; -struct mt792x_link_sta *mlink;struct mt792x_sta *msta;bool is_8023;u16 fc, tid;
@@ -879,14 +878,14 @@ static void mt7925_tx_check_aggr(struct ieee80211_sta *sta, struct sk_buff *skb, msta = (struct mt792x_sta *)sta->drv_priv; -if (sta->mlo && msta->deflink_id !=IEEE80211_LINK_UNSPECIFIED ) - mlink =rcu_dereference (msta->link[msta->deflink_id]); -else - mlink = &msta->deflink; - -if (!test_and_set_bit (tid, &mlink->wcid.ampdu_state)) { +/* Packets belonging to the same TID can be transmitted over multiple +* links. Keep the TX BA session state in the primary link so all links +* share the same AMPDU bookkeeping. +*/ +if (!test_and_set_bit (tid, &msta->deflink.wcid.ampdu_state)) {if (ieee80211_start_tx_ba_session (sta, tid,0 )) -clear_bit (tid, &mlink->wcid.ampdu_state); +clear_bit (tid, &msta->deflink.wcid.ampdu_state); + } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 405/1611 wifi: mt76: mt792x: skip MLD header rewrite for 802.3 encap TX
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sean Wang <[email protected]>
[ Upstream commit a1152244702bb31b64650e5ca8308142286c0e4a ]
mt792x_tx() rewrites addr1/addr2/addr3 by treating skb->data as an 802.11 header for MLD traffic.
That is only valid for native 802.11 frames. Direct 802.3 TX can also reach this path with IEEE80211_TX_CTL_HW_80211_ENCAP set, where skb->data is not an 802.11 header.
Skip the MLD header rewrite for HW-encap packets to avoid corrupting 802.3 frame contents.
--- drivers/net/wireless/mediatek/mt76/mt792x_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt792x_core.c +2 -1
@@ -105,7 +105,8 @@ void mt792x_tx(struct ieee80211_hw *hw, struct ieee80211_tx_control *control, wcid = &mvif->sta.deflink.wcid; } -if (vif && control->sta &&ieee80211_vif_is_mld (vif)) { +if (vif && control->sta &&ieee80211_vif_is_mld (vif) && + !(info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP )) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;struct ieee80211_link_sta *link_sta;struct ieee80211_bss_conf *conf;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 406/1611 wifi: mt76: mt7925: validate skb length in testmode query
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aviel Zohar <[email protected]>
[ Upstream commit c7369a00860a0704461d440e7c3bf9b49bfdbaee ]
In mt7925_tm_query(), the response skb from mt76_mcu_send_and_get_msg() is used in a memcpy without validating its length:
memcpy(evt_resp, skb->data + 8, MT7925_EVT_RSP_LEN);
where MT7925_EVT_RSP_LEN is 512. If the firmware returns a response shorter than 520 bytes (8 + 512), this reads beyond the skb data buffer. The over-read data is then returned to userspace via nla_put() in mt7925_testmode_dump().
Add a length check before the memcpy to ensure the skb contains sufficient data.
--- drivers/net/wireless/mediatek/mt76/mt7925/testmode.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7925/testmode.c +5 -0
@@ -105,6 +105,11 @@ mt7925_tm_query(struct mt792x_dev *dev, struct mt7925_tm_cmd *req,if (ret) goto out; +if (skb->len <MT7925_EVT_RSP_LEN +8 ) { + ret = -EINVAL ; + goto out; + } +memcpy ((char *)evt_resp, (char *)skb->data +8 ,MT7925_EVT_RSP_LEN ); out:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 407/1611 wifi: mt76: mt7996: Fix possible token leak in mt7996_tx_prepare_skb()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 831074096d0450308357271fc0ffd3f600a2487e ]
If link_conf or link_sta lookup fails in mt7996_tx_prepare_skb routine, mt7996 driver leaks an already allocated tx token. Fix the issue releasing the token in case of error.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 8 ++++++-- drivers/net/wireless/mediatek/mt76/tx.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +6 -2
@@ -1106,11 +1106,11 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, link_conf =rcu_dereference (vif->link_conf[wcid->link_id]);if (!link_conf) -return -EINVAL ; + goto error_release_token; link_sta =rcu_dereference (sta->link[wcid->link_id]);if (!link_sta) -return -EINVAL ; + goto error_release_token;dma_sync_single_for_cpu (mdev->dma_dev, tx_info->buf[1 ].addr, tx_info->buf[1 ].len,DMA_TO_DEVICE );
@@ -1215,6 +1215,10 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, tx_info->nbuf =MT_CT_DMA_BUF_NUM ;return 0 ; + +error_release_token: +mt76_token_release (mdev, id,NULL ); +return -EINVAL ; }u32 mt7996_wed_init_buf (void *ptr,dma_addr_t phys,int token_id)
drivers/net/wireless/mediatek/mt76/tx.c +1 -1
@@ -903,7 +903,7 @@ mt76_token_release(struct mt76_dev *dev, int token, bool *wake)#endif } -if (dev->token_count < dev->token_size -MT76_TOKEN_FREE_THR && +if (wake && dev->token_count < dev->token_size -MT76_TOKEN_FREE_THR && dev->phy.q_tx[0 ]->blocked) *wake = true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 408/1611 wifi: mt76: mt7996: Fix possible NULL pointer dereference in mt7996_mac_write_txwi_80211()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 61370e6674b5253de5686813ceeceebc35a7d3e5 ]
For injected frames (e.g. via radiotap), mac80211 can pass info->control.vif = NULL, as explicitly noted in struct ieee80211_tx_info. Check vif pointer before executing ieee80211_vif_is_mld() in mt7996_mac_write_txwi_80211 routine in order to avoid a possible NULL pointer dereference.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +4 -3
@@ -796,6 +796,7 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi,bool multicast =is_multicast_ether_addr (hdr->addr1);u8 tid = skb->priority &IEEE80211_QOS_CTL_TID_MASK ;__le16 fc = hdr->frame_control, sc = hdr->seq_ctrl; +struct ieee80211_vif *vif = info->control.vif;u16 seqno =le16_to_cpu (sc);bool hw_bigtk = false;u8 fc_type, fc_stype;
@@ -858,7 +859,7 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi, txwi[3 ] |=cpu_to_le32 (MT_TXD3_REM_TX_COUNT ); } -if (multicast &&ieee80211_vif_is_mld (info->control.vif)) { +if (multicast && vif &&ieee80211_vif_is_mld (vif)) { val =MT_TXD3_SN_VALID |FIELD_PREP (MT_TXD3_SEQ ,IEEE80211_SEQ_TO_SN (seqno)); txwi[3 ] |=cpu_to_le32 (val);
@@ -878,12 +879,12 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi, txwi[3 ] &= ~cpu_to_le32 (MT_TXD3_HW_AMSDU ); } -if (ieee80211_vif_is_mld (info->control.vif) && +if (vif &&ieee80211_vif_is_mld (vif) && (multicast ||unlikely (skb->protocol ==cpu_to_be16 (ETH_P_PAE )))) txwi[5 ] |=cpu_to_le32 (MT_TXD5_FL );if (ieee80211_is_nullfunc (fc) &&ieee80211_has_a4 (fc) && -ieee80211_vif_is_mld (info->control.vif)) { + vif &&ieee80211_vif_is_mld (vif)) { txwi[5 ] |=cpu_to_le32 (MT_TXD5_FL ); txwi[6 ] |=cpu_to_le32 (MT_TXD6_DIS_MAT ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 409/1611 wifi: mt76: mt7996: fix reading zeroed info->control.flags after mt76_tx_status_skb_add()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lorenzo Bianconi <[email protected]>
[ Upstream commit 729c83a3330c0a56662cd0d8e40db96d41c00a54 ]
mt76_tx_status_skb_add() zeroes the mt76_tx_cb struct stored at info->status.status_driver_data via memset(). Since info->control and info->status are members of the same union in ieee80211_tx_info, this overwrites info->control.flags.
In mt7996_tx_prepare_skb(), mt76_tx_status_skb_add() is called before mt7996_mac_write_txwi(), which re-reads info->control.flags to extract IEEE80211_TX_CTRL_MLO_LINK. Because the field has been zeroed, the link_id always resolves to 0 for frames using global_wcid, leading to incorrect TXWI configuration.
Fix this by passing link_id as an explicit parameter to mt7996_mac_write_txwi(). In mt7996_tx_prepare_skb(), the link_id is already extracted from info->control.flags before the destructive mt76_tx_status_skb_add() call. For the beacon and inband discovery callers in mcu.c, use link_conf->link_id directly.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 14 ++++---------- drivers/net/wireless/mediatek/mt76/mt7996/mcu.c | 5 +++-- drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h | 3 ++- 3 files changed, 9 insertions(+), 13 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +4 -10
@@ -896,7 +896,8 @@ mt7996_mac_write_txwi_80211(struct mt7996_dev *dev, __le32 *txwi,void mt7996_mac_write_txwi (struct mt7996_dev *dev,__le32 *txwi,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_key_conf *key,int pid, -enum mt76_txq_id qid,u32 changed) +enum mt76_txq_id qid,u32 changed, +unsigned int link_id) {struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;struct ieee80211_tx_info *info =IEEE80211_SKB_CB (skb);
@@ -906,7 +907,6 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,bool is_8023 = info->flags &IEEE80211_TX_CTL_HW_80211_ENCAP ;struct mt76_vif_link *mlink =NULL ;struct mt7996_vif *mvif; -unsigned int link_id;u16 tx_count =15 ;u32 val; bool inband_disc = !!(changed & (BSS_CHANGED_UNSOL_BCAST_PROBE_RESP |
@@ -914,17 +914,11 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,bool beacon = !!(changed & (BSS_CHANGED_BEACON |BSS_CHANGED_BEACON_ENABLED )) && (!inband_disc); -if (wcid != &dev->mt76.global_wcid) - link_id = wcid->link_id; -else - link_id =u32_get_bits (info->control.flags, -IEEE80211_TX_CTRL_MLO_LINK ); - mvif = vif ? (struct mt7996_vif *)vif->drv_priv :NULL ;if (mvif) {if (wcid->offchannel) mlink =rcu_dereference (mvif->mt76.offchannel_link); -if (!mlink) +if (!mlink && link_id !=IEEE80211_LINK_UNSPECIFIED ) mlink =rcu_dereference (mvif->mt76.link[link_id]); }
@@ -1136,7 +1130,7 @@ int mt7996_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,/* Transmit non qos data by 802.11 header and need to fill txd by host*/ if (!is_8023 || pid >=MT_PACKET_ID_FIRST )mt7996_mac_write_txwi (dev, txwi_ptr, tx_info->skb, wcid, key, - pid, qid,0 ); + pid, qid,0 , link_id);/* MT7996 and MT7992 require driver to provide the MAC TXP for AddBA * req
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c +3 -2
@@ -2763,7 +2763,7 @@ mt7996_mcu_beacon_cont(struct mt7996_dev *dev, buf = (u8 *)bcn +sizeof (*bcn);mt7996_mac_write_txwi (dev, (__le32 *)buf, skb, wcid,NULL ,0 ,0 , -BSS_CHANGED_BEACON ); +BSS_CHANGED_BEACON , link_conf->link_id);memcpy (buf +MT_TXD_SIZE , skb->data, skb->len); }
@@ -2906,7 +2906,8 @@ int mt7996_mcu_beacon_inband_discov(struct mt7996_dev *dev, buf = (u8 *)tlv +sizeof (*discov); -mt7996_mac_write_txwi (dev, (__le32 *)buf, skb, wcid,NULL ,0 ,0 , changed); +mt7996_mac_write_txwi (dev, (__le32 *)buf, skb, wcid,NULL ,0 ,0 , + changed, link_conf->link_id);memcpy (buf +MT_TXD_SIZE , skb->data, skb->len);
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h +2 -1
@@ -813,7 +813,8 @@ void mt7996_mac_enable_nf(struct mt7996_dev *dev, u8 band);void mt7996_mac_write_txwi (struct mt7996_dev *dev,__le32 *txwi,struct sk_buff *skb,struct mt76_wcid *wcid,struct ieee80211_key_conf *key,int pid, -enum mt76_txq_id qid,u32 changed); +enum mt76_txq_id qid,u32 changed, +unsigned int link_id);void mt7996_mac_update_beacons (struct mt7996_phy *phy);void mt7996_mac_set_coverage_class (struct mt7996_phy *phy);void mt7996_mac_work (struct work_struct *work);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 410/1611 wifi: mt76: mt7996: limit work in set_bitrate_mask
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dylan Eskew <[email protected]>
[ Upstream commit 5fd3385505600934f5faa9635e5b30fa38e548b9 ]
Calls to mt7996_set_bitrate_mask() would propagate work for all stations on the ieee80211_hw regardless of the vif specified in the call. To prevent unnecessary work in FW, limit setting the sta_rate to only the specified vif in mt7996_sta_rate_ctrl_update().
--- drivers/net/wireless/mediatek/mt76/mt7996/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/main.c +6 -3
@@ -1795,7 +1795,11 @@ static void mt7996_sta_rate_ctrl_update(void *data, struct ieee80211_sta *sta) {struct mt7996_sta *msta = (struct mt7996_sta *)sta->drv_priv;struct mt7996_sta_link *msta_link; -u32 *changed = data; +struct mt7996_vif *mvif = data; +u32 changed =IEEE80211_RC_SUPP_RATES_CHANGED ; + +if (msta->vif != mvif) +return ; msta_link =rcu_dereference (msta->link[msta->deflink_id]);if (msta_link)
@@ -1808,7 +1812,6 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif, {struct mt7996_dev *dev =mt7996_hw_dev (hw);struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv; -u32 changed =IEEE80211_RC_SUPP_RATES_CHANGED ; mvif->deflink.bitrate_mask = *mask;
@@ -1821,7 +1824,7 @@ mt7996_set_bitrate_mask(struct ieee80211_hw *hw, struct ieee80211_vif *vif,* then multiple MCS setting (MCS 4,5,6) is not supported. */ ieee80211_iterate_stations_atomic (hw, mt7996_sta_rate_ctrl_update, - &changed); + mvif);ieee80211_queue_work (hw, &dev->rc_work);return 0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 411/1611 wifi: mt76: fix argument to ieee80211_is_first_frag()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjoern A. Zeeb <[email protected]>
[ Upstream commit 5832743279da8c6ae72f715bad2f7141eca6f4b8 ]
ieee80211_is_first_frag() operates on the seq_ctrl not the frame_control header field. Pass the correct one in; otherwise the results may vary.
Sponsored by: The FreeBSD Foundation
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +1 -1
@@ -1316,7 +1316,7 @@ mt76_check_ccmp_pn(struct sk_buff *skb)* All further fragments will be validated by mac80211 only. */ if (ieee80211_is_frag (hdr) && - !ieee80211_is_first_frag (hdr->frame_control)) + !ieee80211_is_first_frag (hdr->seq_ctrl))return ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 412/1611 wifi: mt76: mt7915: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 05e72b6167970043348bfbe8f72a3b67a38a9f1c ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +5 -5
@@ -912,16 +912,16 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) }if (!mtk_wed_device_active (&mdev->mmio.wed) && wcid) { -u32 tx_retries =0 , tx_failed =0 ; +u32 tx_retries =0 , tx_failed =0 , count;if (v3 && (info &MT_TX_FREE_MPDU_HEADER_V3 )) { - tx_retries = -FIELD_GET (MT_TX_FREE_COUNT_V3 , info) -1 ; + count =FIELD_GET (MT_TX_FREE_COUNT_V3 , info); + tx_retries = count ? count -1 :0 ; tx_failed = tx_retries + !!FIELD_GET (MT_TX_FREE_STAT_V3 , info); }else if (!v3 && (info &MT_TX_FREE_MPDU_HEADER )) { - tx_retries = -FIELD_GET (MT_TX_FREE_COUNT , info) -1 ; + count =FIELD_GET (MT_TX_FREE_COUNT , info); + tx_retries = count ? count -1 :0 ; tx_failed = tx_retries + !!FIELD_GET (MT_TX_FREE_STAT , info); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 413/1611 wifi: mt76: mt7921: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 3c5671ed81b1fff97fa868dae771690599db94f7 ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +3 -2
@@ -530,8 +530,9 @@ static void mt7921_mac_tx_free(struct mt792x_dev *dev, void *data, int len) stat =FIELD_GET (MT_TX_FREE_STATUS , info);if (wcid) { - wcid->stats.tx_retries += -FIELD_GET (MT_TX_FREE_COUNT , info) -1 ; +u32 count =FIELD_GET (MT_TX_FREE_COUNT , info); + + wcid->stats.tx_retries += count ? count -1 :0 ; wcid->stats.tx_failed += !!stat; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 414/1611 wifi: mt76: mt7925: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 1e1fd84571e62a2961cea44c053340ec5c99b2cb ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7925/mac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7925/mac.c +3 -2
@@ -1139,8 +1139,9 @@ mt7925_mac_tx_free(struct mt792x_dev *dev, void *data, int len)if (info &MT_TXFREE_INFO_HEADER ) {if (wcid) { - wcid->stats.tx_retries += -FIELD_GET (MT_TXFREE_INFO_COUNT , info) -1 ; +u32 count =FIELD_GET (MT_TXFREE_INFO_COUNT , info); + + wcid->stats.tx_retries += count ? count -1 :0 ; wcid->stats.tx_failed += !!FIELD_GET (MT_TXFREE_INFO_STAT , info); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 415/1611 wifi: mt76: mt7996: fix potential tx_retries underflow
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ryder Lee <[email protected]>
[ Upstream commit 4d8bba99d645bcb46a442b18eb42402610cba03a ]
When FIELD_GET returns 0 for the retry count, subtracting 1 causes an unsigned integer underflow, resulting in tx_retries becoming a very large value (0xFFFFFFFF for u32).
Fix by checking if count is non-zero before subtracting 1.
--- drivers/net/wireless/mediatek/mt76/mt7996/mac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7996/mac.c +3 -3
@@ -1398,13 +1398,13 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) cur_info++;continue ; }else if (info &MT_TXFREE_INFO_HEADER ) { -u32 tx_retries =0 , tx_failed =0 ; +u32 tx_retries =0 , tx_failed =0 , count;if (!wcid)continue ; - tx_retries = -FIELD_GET (MT_TXFREE_INFO_COUNT , info) -1 ; + count =FIELD_GET (MT_TXFREE_INFO_COUNT , info); + tx_retries = count ? count -1 :0 ; tx_failed = tx_retries + !!FIELD_GET (MT_TXFREE_INFO_STAT , info);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 416/1611 btrfs: fix invalid pointer dereference in __btrfs_run_delayed_refs()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 486f8298b6188ff11ef1f4be7f1d5d2e4d1b1fae ]
In the beginning of the loop, we try to obtain a locked delayed ref head, if 'locked_ref' is currently NULL, by calling btrfs_select_ref_head(), which can return an error pointer. If the error pointer is -EAGAIN we do a continue and go back to the beginning of the loop, which will not try again to call btrfs_select_ref_head() since 'locked_ref' is no longer NULL but it's ERR_PTR(-EAGAIN), and then we do:
spin_lock(&locked_ref->lock);
against a ERR_PTR(-EAGAIN) value, generating an invalid pointer dereference.
Fix this by ensuring that 'locked_ref' is set to NULL when btrfs_select_ref_head() returns ERR_PTR(-EAGAIN) and incrementing 'count' as well, to prevent infinite looping. We do this by doing a goto to the bottom of the loop that already sets 'locked_ref' to NULL and does a cond_resched(), with an increment to 'count' right before the goto. These measures were in place before the refactoring in commit 0110a4c43451 ("btrfs: refactor __btrfs_run_delayed_refs loop") but were unintentionally lost afterwards.
--- fs/btrfs/extent-tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/btrfs/extent-tree.c +3 -2
@@ -2022,7 +2022,8 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, locked_ref =btrfs_select_ref_head (fs_info, delayed_refs);if (IS_ERR_OR_NULL (locked_ref)) {if (PTR_ERR (locked_ref) == -EAGAIN ) { -continue ; + count++; + goto again; }else {break ; }
@@ -2070,7 +2071,7 @@ static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans,* Either success case or btrfs_run_delayed_refs_for_head * returned -EAGAIN, meaning we need to select another head */ - +again: locked_ref =NULL ;cond_resched (); } while ((min_bytes != U64_MAX && bytes_processed < min_bytes) ||
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 417/1611 ALSA: aloop: Drop superfluous break
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit 123fd13f35ccaf7d2b98f5a8cc6c8a3de378568d ]
At converting the spinlock to guard(), a break statement was put in the scoped_guard block in loopback_jiffies_timer_function(), but it's obviously superfluous (although it's harmless). Better to drop it for avoiding confusion.
--- sound/drivers/aloop.c | 1 - 1 file changed, 1 deletion(-)
sound/drivers/aloop.c +0 -1
@@ -728,7 +728,6 @@ static void loopback_jiffies_timer_function(struct timer_list *t)if (dpcm->period_update_pending) { dpcm->period_update_pending =0 ; period_elapsed = true; -break ; } } }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 418/1611 gpio: mt7621: fix interrupt banks mapping on gpio chips
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergio Paracuellos <[email protected]>
[ Upstream commit a46f2e5720f5670feda145709d1f0d20be5c7263 ]
The GPIO controller's registers are organized as sets of eight 32-bit registers with each set controlling a bank of up to 32 pins. A single interrupt is shared for all of the banks handled by the controller. The driver implements this using three gpio chip instances every one with its own irq chip. Every single pin can generate interrupts having a total of 96 possible interrupts here. It looks like there is a problem with interrupts being properly mapped to the gpio bank using this solution. This problem report is in the following lore's link [0].
Device tree is using two cells for this, so only the interrupt pin and the interrupt type are described there. Changing to have three cells to setup also the bank and implement 'of_node_instance_match()' would also work but this would be an ABI breakage and also a bit incoherent since gpios itself are also using two cells and properly mapped in desired bank using through its pin number on 'of_xlate()'.
That said, register a linear IRQ domain of the total of 96 interrupts shared with the three gpio chip instances so the bank and the interrupt is properly decoded and devices using gpio IRQs properly work.
--- drivers/gpio/gpio-mt7621.c | 282 ++++++++++++++++++++++++++++--------- 1 file changed, 216 insertions(+), 66 deletions(-)
drivers/gpio/gpio-mt7621.c +216 -66
@@ -29,8 +29,8 @@#define GPIO_REG_EDGE 0xA0struct mtk_gc { -struct irq_chip irq_chip;struct gpio_generic_chip chip; +struct mtk *parent_priv;int bank;u32 rising;u32 falling;
@@ -41,20 +41,32 @@ struct mtk_gc {/** * struct mtk - state container for * data of the platform driver. It is 3 -* separate gpio-chip each one with its -* own irq_chip. -* @dev: device instance +* separate gpio-chip having an IRQ +* linear domain shared for all of them +* @pdev: platform device instance * @base: memory base address +* @irq_domain: IRQ linear domain shared across the three gpio chips * @gpio_irq: irq number from the device tree +* @num_gpios: total number of gpio pins on the three gpio chips * @gc_map: array of the gpio chips */ struct mtk { -struct device *dev; +struct platform_device *pdev;void __iomem *base; +struct irq_domain *irq_domain;int gpio_irq; +int num_gpios;struct mtk_gc gc_map[MTK_BANK_CNT ]; }; +static inline struct mtk * +mt7621_gpio_gc_to_priv (struct gpio_chip *gc) +{ +struct mtk_gc *bank =gpiochip_get_data (gc); + +return bank->parent_priv; +} +static inline struct mtk_gc *to_mediatek_gpio (struct gpio_chip *chip) {
@@ -67,7 +79,7 @@ static inline void mtk_gpio_w32(struct mtk_gc *rg, u32 offset, u32 val) { struct gpio_chip *gc = &rg->chip.gc; -struct mtk *mtk =gpiochip_get_data (gc); +struct mtk *mtk =mt7621_gpio_gc_to_priv (gc); offset = (rg->bank *GPIO_BANK_STRIDE ) + offset;gpio_generic_write_reg (&rg->chip, mtk->base + offset, val);
@@ -77,41 +89,62 @@ static inline u32 mtk_gpio_r32(struct mtk_gc *rg, u32 offset) {struct gpio_chip *gc = &rg->chip.gc; -struct mtk *mtk =gpiochip_get_data (gc); +struct mtk *mtk =mt7621_gpio_gc_to_priv (gc); offset = (rg->bank *GPIO_BANK_STRIDE ) + offset;return gpio_generic_read_reg (&rg->chip, mtk->base + offset); } -static irqreturn_t -mediatek_gpio_irq_handler (int irq,void *data) +static void +mt7621_gpio_irq_bank_handler (struct mtk_gc *bank) { -struct gpio_chip *gc = data; -struct mtk_gc *rg =to_mediatek_gpio (gc); -irqreturn_t ret =IRQ_NONE ; +struct mtk *priv = bank->parent_priv; +struct irq_domain *domain = priv->irq_domain; +int hwbase = bank->chip.gc.offset;unsigned long pending; -int bit; +unsigned int offset; + + pending =mtk_gpio_r32 (bank,GPIO_REG_STAT ); +if (!pending) +return ; + +mtk_gpio_w32 (bank,GPIO_REG_STAT , pending); + +for_each_set_bit (offset, &pending,MTK_BANK_WIDTH ) +generic_handle_domain_irq (domain, hwbase + offset); +} + +static void +mt7621_gpio_irq_handler (struct irq_desc *desc) +{ +struct mtk *priv =irq_desc_get_handler_data (desc); +struct irq_chip *chip =irq_desc_get_chip (desc); +int i; - pending =mtk_gpio_r32 (rg,GPIO_REG_STAT ); +chained_irq_enter (chip, desc); +for (i =0 ; i <MTK_BANK_CNT ; i++) { +struct mtk_gc *bank = &priv->gc_map[i]; -for_each_set_bit (bit, &pending,MTK_BANK_WIDTH ) { -generic_handle_domain_irq (gc->irq.domain, bit); -mtk_gpio_w32 (rg,GPIO_REG_STAT ,BIT (bit)); - ret |=IRQ_HANDLED ; +mt7621_gpio_irq_bank_handler (bank); } +chained_irq_exit (chip, desc); +} -return ret; +static int +mt7621_gpio_hwirq_to_offset (irq_hw_number_t hwirq,struct mtk_gc *bank) +{ +return hwirq - bank->chip.gc.offset; }static void mediatek_gpio_irq_unmask (struct irq_data *d) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -struct mtk_gc *rg =to_mediatek_gpio (gc); -int pin = d->hwirq; +struct mtk_gc *rg =gpiochip_get_data (gc); +u32 mask =mt7621_gpio_hwirq_to_offset (d->hwirq, rg);u32 rise, fall, high, low; -gpiochip_enable_irq (gc, d->hwirq); +gpiochip_enable_irq (gc, mask);guard (gpio_generic_lock_irqsave)(&rg->chip);
@@ -119,18 +152,18 @@ mediatek_gpio_irq_unmask(struct irq_data *d) fall =mtk_gpio_r32 (rg,GPIO_REG_FEDGE ); high =mtk_gpio_r32 (rg,GPIO_REG_HLVL ); low =mtk_gpio_r32 (rg,GPIO_REG_LLVL ); -mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise | (BIT (pin) & rg->rising)); -mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall | (BIT (pin) & rg->falling)); -mtk_gpio_w32 (rg,GPIO_REG_HLVL , high | (BIT (pin) & rg->hlevel)); -mtk_gpio_w32 (rg,GPIO_REG_LLVL , low | (BIT (pin) & rg->llevel)); +mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise | (BIT (mask) & rg->rising)); +mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall | (BIT (mask) & rg->falling)); +mtk_gpio_w32 (rg,GPIO_REG_HLVL , high | (BIT (mask) & rg->hlevel)); +mtk_gpio_w32 (rg,GPIO_REG_LLVL , low | (BIT (mask) & rg->llevel)); }static void mediatek_gpio_irq_mask (struct irq_data *d) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -struct mtk_gc *rg =to_mediatek_gpio (gc); -int pin = d->hwirq; +struct mtk_gc *rg =gpiochip_get_data (gc); +u32 mask =mt7621_gpio_hwirq_to_offset (d->hwirq, rg);u32 rise, fall, high, low; scoped_guard(gpio_generic_lock_irqsave, &rg->chip) {
@@ -138,22 +171,21 @@ mediatek_gpio_irq_mask(struct irq_data *d) fall =mtk_gpio_r32 (rg,GPIO_REG_FEDGE ); high =mtk_gpio_r32 (rg,GPIO_REG_HLVL ); low =mtk_gpio_r32 (rg,GPIO_REG_LLVL ); -mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall & ~BIT (pin)); -mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise & ~BIT (pin)); -mtk_gpio_w32 (rg,GPIO_REG_HLVL , high & ~BIT (pin)); -mtk_gpio_w32 (rg,GPIO_REG_LLVL , low & ~BIT (pin)); +mtk_gpio_w32 (rg,GPIO_REG_FEDGE , fall & ~BIT (mask)); +mtk_gpio_w32 (rg,GPIO_REG_REDGE , rise & ~BIT (mask)); +mtk_gpio_w32 (rg,GPIO_REG_HLVL , high & ~BIT (mask)); +mtk_gpio_w32 (rg,GPIO_REG_LLVL , low & ~BIT (mask)); } -gpiochip_disable_irq (gc, d->hwirq); +gpiochip_disable_irq (gc, mask); }static int mediatek_gpio_irq_type (struct irq_data *d,unsigned int type) {struct gpio_chip *gc =irq_data_get_irq_chip_data (d); -struct mtk_gc *rg =to_mediatek_gpio (gc); -int pin = d->hwirq; -u32 mask =BIT (pin); +struct mtk_gc *rg =gpiochip_get_data (gc); +u32 mask =BIT (mt7621_gpio_hwirq_to_offset (d->hwirq, rg));if (type ==IRQ_TYPE_PROBE ) { if ((rg->rising | rg->falling |
@@ -190,6 +222,26 @@ mediatek_gpio_irq_type(struct irq_data *d, unsigned int type)return 0 ; } +static int +mt7621_gpio_irq_reqres (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct mtk_gc *rg =gpiochip_get_data (gc); +unsigned int irq =mt7621_gpio_hwirq_to_offset (d->hwirq, rg); + +return gpiochip_reqres_irq (gc, irq); +} + +static void +mt7621_gpio_irq_relres (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); +struct mtk_gc *rg =gpiochip_get_data (gc); +unsigned int irq =mt7621_gpio_hwirq_to_offset (d->hwirq, rg); + +gpiochip_relres_irq (gc, irq); +} +static int mediatek_gpio_xlate (struct gpio_chip *chip,const struct of_phandle_args *spec,u32 *flags)
@@ -208,14 +260,123 @@ mediatek_gpio_xlate(struct gpio_chip *chip,static const struct irq_chip mt7621_irq_chip = { .name ="mt7621-gpio" , + .irq_request_resources = mt7621_gpio_irq_reqres, + .irq_release_resources = mt7621_gpio_irq_relres, .irq_mask_ack = mediatek_gpio_irq_mask, .irq_mask = mediatek_gpio_irq_mask, .irq_unmask = mediatek_gpio_irq_unmask, .irq_set_type = mediatek_gpio_irq_type, .flags =IRQCHIP_IMMUTABLE , -GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; + +static void +mt7621_gpio_remove (struct platform_device *pdev) +{ +struct mtk *priv =platform_get_drvdata (pdev); +int offset, virq; + +if (priv->gpio_irq >0 ) +irq_set_chained_handler_and_data (priv->gpio_irq,NULL ,NULL ); + +/* Remove all IRQ mappings and delete the domain */ +if (priv->irq_domain) { +for (offset =0 ; offset < priv->num_gpios; offset++) { + virq =irq_find_mapping (priv->irq_domain, offset); +irq_dispose_mapping (virq); + } +irq_domain_remove (priv->irq_domain); + } +} + +static struct mtk_gc * +mt7621_gpio_hwirq_to_bank (struct mtk *priv,irq_hw_number_t hwirq) +{ +int i; + +for (i =0 ; i <MTK_BANK_CNT ; i++) { +struct mtk_gc *bank = &priv->gc_map[i]; + +if (hwirq >= bank->chip.gc.offset && + hwirq < (bank->chip.gc.offset + bank->chip.gc.ngpio)) +return bank; + } + +return NULL ; +} + +static int +mt7621_gpio_irq_map (struct irq_domain *d,unsigned int irq, +irq_hw_number_t hwirq) +{ +struct mtk *priv = d->host_data; +struct mtk_gc *bank =mt7621_gpio_hwirq_to_bank (priv, hwirq); +struct platform_device *pdev = priv->pdev; +int ret; + +if (!bank) +return -EINVAL ; + +dev_dbg (&pdev->dev,"Mapping irq %d for gpio line %d (bank %d)\n" , + irq, (int )hwirq, bank->bank); + + ret =irq_set_chip_data (irq, &bank->chip.gc); +if (ret <0 ) +return ret; + +irq_set_chip_and_handler (irq, &mt7621_irq_chip, handle_simple_irq); +irq_set_noprobe (irq); + +return 0 ; +} + +static void +mt7621_gpio_irq_unmap (struct irq_domain *d,unsigned int irq) +{ +irq_set_chip_and_handler (irq,NULL ,NULL ); +irq_set_chip_data (irq,NULL ); +} + +static const struct irq_domain_ops mt7621_gpio_irq_domain_ops = { + .map = mt7621_gpio_irq_map, + .unmap = mt7621_gpio_irq_unmap, + .xlate = irq_domain_xlate_twocell, }; +static int +mt7621_gpio_irq_setup (struct platform_device *pdev, +struct mtk *priv) +{ +struct device *dev = &pdev->dev; + + priv->irq_domain =irq_domain_create_linear (dev_fwnode (dev), + priv->num_gpios, + &mt7621_gpio_irq_domain_ops, + priv); +if (!priv->irq_domain) { +dev_err (dev,"Couldn't allocate IRQ domain\n" ); +return -ENXIO ; + } + +irq_set_chained_handler_and_data (priv->gpio_irq, + mt7621_gpio_irq_handler, priv); +irq_set_status_flags (priv->gpio_irq,IRQ_DISABLE_UNLAZY ); + +return 0 ; +} + +static int +mt7621_gpio_to_irq (struct gpio_chip *gc,unsigned int offset) +{ +struct mtk *priv =mt7621_gpio_gc_to_priv (gc); +/* gc_offset is relative to this gpio_chip; want real offset */ +int hwirq = offset + gc->offset; + +if (hwirq >= priv->num_gpios) +return -ENXIO ; + +return irq_create_mapping (priv->irq_domain, hwirq); +} +static int mediatek_gpio_bank_probe (struct device *dev,int bank) {
@@ -228,6 +389,7 @@ mediatek_gpio_bank_probe(struct device *dev, int bank) rg = &mtk->gc_map[bank];memset (rg,0 ,sizeof (*rg)); + rg->parent_priv = mtk; rg->bank = bank; dat = mtk->base +GPIO_REG_DATA + (rg->bank *GPIO_BANK_STRIDE );
@@ -253,41 +415,17 @@ mediatek_gpio_bank_probe(struct device *dev, int bank) rg->chip.gc.of_gpio_n_cells =2 ; rg->chip.gc.of_xlate = mediatek_gpio_xlate; + rg->chip.gc.ngpio =MTK_BANK_WIDTH ; rg->chip.gc.label =devm_kasprintf (dev,GFP_KERNEL ,"%s-bank%d" ,dev_name (dev), bank);if (!rg->chip.gc.label)return -ENOMEM ; rg->chip.gc.offset = bank *MTK_BANK_WIDTH ; +if (mtk->gpio_irq >0 ) + rg->chip.gc.to_irq = mt7621_gpio_to_irq; -if (mtk->gpio_irq) { -struct gpio_irq_chip *girq; - -/* -* Directly request the irq here instead of passing -* a flow-handler because the irq is shared. -*/ - ret =devm_request_irq (dev, mtk->gpio_irq, - mediatek_gpio_irq_handler,IRQF_SHARED , - rg->chip.gc.label, &rg->chip.gc); - -if (ret) { -dev_err (dev,"Error requesting IRQ %d: %d\n" , - mtk->gpio_irq, ret); -return ret; - } - - girq = &rg->chip.gc.irq; -gpio_irq_chip_set_chip (girq, &mt7621_irq_chip); -/* This will let us handle the parent IRQ in the driver */ - girq->parent_handler =NULL ; - girq->num_parents =0 ; - girq->parents =NULL ; - girq->default_type =IRQ_TYPE_NONE ; - girq->handler = handle_simple_irq; - } - - ret =devm_gpiochip_add_data (dev, &rg->chip.gc, mtk); + ret =devm_gpiochip_add_data (dev, &rg->chip.gc, rg);if (ret <0 ) {dev_err (dev,"Could not register gpio %d, ret=%d\n" , rg->chip.gc.ngpio, ret);
@@ -322,7 +460,8 @@ mediatek_gpio_probe(struct platform_device *pdev)if (mtk->gpio_irq <0 )return mtk->gpio_irq; - mtk->dev = dev; + mtk->pdev = pdev; + mtk->num_gpios =MTK_BANK_WIDTH *MTK_BANK_CNT ;platform_set_drvdata (pdev, mtk);for (i =0 ; i <MTK_BANK_CNT ; i++) {
@@ -331,7 +470,17 @@ mediatek_gpio_probe(struct platform_device *pdev)return ret; } +if (mtk->gpio_irq >0 ) { + ret =mt7621_gpio_irq_setup (pdev, mtk); +if (ret) + goto fail; + } +return 0 ; + +fail: +mt7621_gpio_remove (pdev); +return ret; }static const struct of_device_id mediatek_gpio_match[] = {
@@ -342,6 +491,7 @@ MODULE_DEVICE_TABLE(of, mediatek_gpio_match);static struct platform_driver mediatek_gpio_driver = { .probe = mediatek_gpio_probe, + .remove = mt7621_gpio_remove, .driver = { .name ="mt7621_gpio" , .of_match_table = mediatek_gpio_match,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 419/1611 wifi: ath12k: enable IEEE80211_VHT_EXT_NSS_BW_CAPABLE when NSS ratio is reported
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wen Gong <[email protected]>
[ Upstream commit 63abe299b12b317dfee5bcd09037da4668a4431a ]
When firmware reports NSS ratio support, SUPPORTS_VHT_EXT_NSS_BW is enabled in ath12k. However, IEEE80211_VHT_EXT_NSS_BW_CAPABLE must also be set to make the advertisement valid.
According to IEEE Std 802.11-2024, Subclause 9.4.2.156.3 (Supported VHT-MCS and NSS Set subfields), the VHT Extended NSS BW Capable bit indicates whether a STA is capable of interpreting the Extended NSS BW Support subfield of the VHT capabilities information field. Advertising extended NSS BW support without setting this capability bit is therefore invalid.
Without this change, mac80211 detects the inconsistency and logs:
ieee80211 phy0: copying sband (band 1) due to VHT EXT NSS BW flag
This indicates that mac80211 implicitly aligns IEEE80211_VHT_EXT_NSS_BW_CAPABLE during ieee80211_register_hw(). Explicitly setting the bit in ath12k avoids this fixup and ensures capabilities are advertised correctly by the driver.
This change follows the same approach as the existing ath11k fix.
https://lore.kernel.org/all/[email protected]/
Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.5-01651-QCAHKSWPL_SILICONZ-1
--- drivers/net/wireless/ath/ath12k/mac.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/wireless/ath/ath12k/mac.c +4 -0
@@ -7672,6 +7672,10 @@ ath12k_create_vht_cap(struct ath12k *ar, u32 rate_cap_tx_chainmask, vht_cap.vht_supported =1 ; vht_cap.cap = ar->pdev->cap.vht_cap; +if (ar->pdev->cap.nss_ratio_enabled) + vht_cap.vht_mcs.tx_highest |= +cpu_to_le16 (IEEE80211_VHT_EXT_NSS_BW_CAPABLE ); +ath12k_set_vht_txbf_cap (ar, &vht_cap.cap);/* 80P80 is not supported */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 420/1611 fbdev: sm501fb: Fix buffer errors in OF binding code
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Laight <[email protected]>
[ Upstream commit d8421e09382cfe0bd2a044c8b0a822f64855dd4e ]
The code that gets the frame buffer mode from OF has 'use after free', 'buffer overrun' and memory leaks.
info->edid_data isn't free if the probe functions fail or if pd->def_mode is set.
If both the CRT and PANEL are enabled info->edid_data is used after being freed and is freed twice.
The string returned by of_get_property(np, "mode", &len) is just written over either the static "640x480-16@60" or the module parameter string without any regard for the length (which is most likely longer).
Use kstrump() for the OF mode and free everything before freeing 'info.
--- drivers/video/fbdev/sm501fb.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/video/fbdev/sm501fb.c +12 -4
@@ -96,6 +96,7 @@ struct sm501fb_info {void __iomem *fbmem;/* remapped framebuffer */ size_t fbmem_len;/* length of remapped region */ u8 *edid_data; +char *fb_mode; };/* per-framebuffer private data */
@@ -1793,12 +1794,11 @@ static int sm501fb_init_fb(struct fb_info *fb, enum sm501_controller head, fb->var.yres_virtual = fb->var.yres; }else {if (info->edid_data) { - ret =fb_find_mode (&fb->var, fb, fb_mode, + ret =fb_find_mode (&fb->var, fb, + info->fb_mode ?: fb_mode, fb->monspecs.modedb, fb->monspecs.modedb_len, &sm501_default_mode, default_bpp); -/* edid_data is no longer needed, free it */ -kfree (info->edid_data); }else { ret =fb_find_mode (&fb->var, fb,NULL ,NULL ,0 ,NULL ,8 );
@@ -1974,7 +1974,7 @@ static int sm501fb_probe(struct platform_device *pdev)/* Get EDID */ cp =of_get_property (np,"mode" , &len);if (cp) -strcpy (fb_mode, cp); + info->fb_mode =kstrdup (cp,GFP_KERNEL ); prop =of_get_property (np,"edid" , &len);if (prop && len ==EDID_LENGTH ) { info->edid_data = kmemdup(prop, EDID_LENGTH,
@@ -2031,6 +2031,12 @@ static int sm501fb_probe(struct platform_device *pdev) goto err_started_crt; } +/* These aren't needed any more */ +kfree (info->edid_data); +kfree (info->fb_mode); + info->edid_data =NULL ; + info->fb_mode =NULL ; +/* we registered, return ok */ return 0 ;
@@ -2048,6 +2054,8 @@ static int sm501fb_probe(struct platform_device *pdev)framebuffer_release (info->fb[HEAD_CRT ]); err_alloc: +kfree (info->edid_data); +kfree (info->fb_mode);kfree (info);return ret;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 421/1611 vfs: add FS_USERNS_DELEGATABLE flag and set it for NFS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeff Layton <[email protected]>
[ Upstream commit c5d6cac28646b0d5d81ef632be748ae93c1f36c7 ]
Commit e1c5ae59c0f2 ("fs: don't allow non-init s_user_ns for filesystems without FS_USERNS_MOUNT") prevents the mount of any filesystem inside a container that doesn't have FS_USERNS_MOUNT set.
This broke NFS mounts in our containerized environment. We have a daemon somewhat like systemd-mountfsd running in the init_ns. A process does a fsopen() inside the container and passes it to the daemon via unix socket.
The daemon then vets that the request is for an allowed NFS server and performs the mount. This now fails because the fc->user_ns is set to the value in the container and NFS doesn't set FS_USERNS_MOUNT. We don't want to add FS_USERNS_MOUNT to NFS since that would allow the container to mount any NFS server (even malicious ones).
Add a new FS_USERNS_DELEGATABLE flag, and enable it on NFS.
--- fs/nfs/fs_context.c | 8 ++++++-- fs/super.c | 11 ++++++----- include/linux/fs.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-)
fs/nfs/fs_context.c +6 -2
@@ -1768,7 +1768,9 @@ struct file_system_type nfs_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags =FS_RENAME_DOES_D_MOVE | +FS_BINARY_MOUNTDATA | + FS_USERNS_DELEGATABLE, };MODULE_ALIAS_FS ("nfs" );EXPORT_SYMBOL_GPL (nfs_fs_type);
@@ -1780,7 +1782,9 @@ struct file_system_type nfs4_fs_type = { .init_fs_context = nfs_init_fs_context, .parameters = nfs_fs_parameters, .kill_sb = nfs_kill_super, - .fs_flags = FS_RENAME_DOES_D_MOVE|FS_BINARY_MOUNTDATA, + .fs_flags =FS_RENAME_DOES_D_MOVE | +FS_BINARY_MOUNTDATA | + FS_USERNS_DELEGATABLE, };MODULE_ALIAS_FS ("nfs4" );MODULE_ALIAS ("nfs4" );
fs/super.c +6 -5
@@ -737,12 +737,13 @@ struct super_block *sget_fc(struct fs_context *fc,int err;/* -* Never allow s_user_ns != &init_user_ns when FS_USERNS_MOUNT is -* not set, as the filesystem is likely unprepared to handle it. -* This can happen when fsconfig() is called from init_user_ns with -* an fs_fd opened in another user namespace. +* Never allow s_user_ns != &init_user_ns when FS_USERNS_MOUNT or +* FS_USERNS_DELEGATABLE is not set, as the filesystem is likely +* unprepared to handle it. This can happen when fsconfig() is called +* from init_user_ns with an fs_fd opened in another user namespace. */ -if (user_ns != &init_user_ns && !(fc->fs_type->fs_flags &FS_USERNS_MOUNT )) { +if (user_ns != &init_user_ns && + !(fc->fs_type->fs_flags & (FS_USERNS_MOUNT |FS_USERNS_DELEGATABLE ))) {errorfc (fc,"VFS: Mounting from non-initial user namespace is not allowed" );return ERR_PTR (-EPERM ); }
include/linux/fs.h +1 -0
@@ -2693,6 +2693,7 @@ struct file_system_type {#define FS_MGTIME 64/* FS uses multigrain timestamps */ #define FS_LBS 128/* FS supports LBS */ #define FS_POWER_FREEZE 256/* Always freeze on suspend/hibernate */ +#define FS_USERNS_DELEGATABLE 1024/* Can be mounted inside userns from outside */ #define FS_RENAME_DOES_D_MOVE 32768/* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *);const struct fs_parameter_spec *parameters;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 422/1611 hwmon: (it87) Clamp negative values to zero in set_fan()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nikita Zhandarovich <[email protected]>
[ Upstream commit 7f8581c70a3bd50a932d3d2d253e99c5ec3eda74 ]
set_fan() parses user input with kstrtol() and passes the resulting value to FAN16_TO_REG() on chips with 16-bit fan support.
Negative fan speeds are not meaningful and should be rejected before conversion. Worst scenario, one may be able to abuse undefined behaviour of signed overflow to possibly induce rpm * 2 == 0 in FAN16_TO_REG(), thus causing a division by zero.
Instead, clamp val < 0 to zero and keep the conversion in its valid input domain, avoiding unsafe arithmetic in the register conversion path.
Found by Linux Verification Center (linuxtesting.org) with static analysis tool SVACE.
--- drivers/hwmon/it87.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/hwmon/it87.c +3 -0
@@ -1401,6 +1401,9 @@ static ssize_t set_fan(struct device *dev, struct device_attribute *attr,if (kstrtol (buf,10 , &val) <0 )return -EINVAL ; +if (val <0 ) + val =0 ; + err =it87_lock (data);if (err)return err;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 423/1611 btrfs: zoned: dont account data relocation space-info in statfs free space
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 52416a27aabc43eab3792fd0ca9f5dabeab58f31 ]
Don't account the free space in a data relocation space-info sub-group as usable free space in statfs.
This is misleading as no user allocations can be made in this space-info sub-group. It is only a target for relocation.
--- fs/btrfs/super.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/super.c +2 -1
@@ -1741,7 +1741,8 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)int mixed =0 ;list_for_each_entry (found, &fs_info->space_info, list) { -if (found->flags &BTRFS_BLOCK_GROUP_DATA ) { +if (found->flags &BTRFS_BLOCK_GROUP_DATA && + found->subgroup_id !=BTRFS_SUB_GROUP_DATA_RELOC ) {int i; total_free_data += found->disk_total - found->disk_used;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 424/1611 Revert "btrfs: fix the file offset calculation inside btrfs_decompress_buf2page()"
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthew Wilcox (Oracle) <[email protected]>
[ Upstream commit 0279bed34c22dd5ebff12e5af8ef940de93c5523 ]
It seems that af566bdaff54 was tested against a tree which did not contain commit 12851bd921d4 ("fs: Turn page_offset() into a wrapper around folio_pos()). Unfortunately it has a bug of its own; on 32-bit systems, shifting by PAGE_SHIFT will overflow on files larger than 4GiB. Since page_offset() is now fixed, just revert af566bdaff54.
--- fs/btrfs/compression.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
fs/btrfs/compression.c +1 -17
@@ -1187,22 +1187,6 @@ void __cold btrfs_exit_compress(void)bioset_exit (&btrfs_compressed_bioset); } -/* -* The bvec is a single page bvec from a bio that contains folios from a filemap. -* -* Since the folio may be a large one, and if the bv_page is not a head page of -* a large folio, then page->index is unreliable. -* -* Thus we need this helper to grab the proper file offset. -*/ -static u64 file_offset_from_bvec (const struct bio_vec *bvec) -{ -const struct page *page = bvec->bv_page; -const struct folio *folio =page_folio (page); - -return (page_pgoff (folio, page) <<PAGE_SHIFT ) + bvec->bv_offset; -} -/* * Copy decompressed data from working buffer to pages. *
@@ -1255,7 +1239,7 @@ int btrfs_decompress_buf2page(const char *buf, u32 buf_len,* cb->start may underflow, but subtracting that value can still * give us correct offset inside the full decompressed extent. */ - bvec_offset =file_offset_from_bvec (&bvec) - cb->start; + bvec_offset =page_offset (bvec.bv_page) + bvec.bv_offset - cb->start;/* Haven't reached the bvec range, exit */ if (decompressed + buf_len <= bvec_offset)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 425/1611 btrfs: zoned: always set max_active_zones for zoned devices
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Thumshirn <[email protected]>
[ Upstream commit 21a3533b99b8a53a026cc9f5041b10795c1f3ae8 ]
When a block device does not report a maximum number of open or active zones, currently assign BTRFS_DEFAULT_MAX_ACTIVE_ZONES (128) to the internal limit, if the device has more than BTRFS_DEFAULT_MAX_ACTIVE_ZONES zones.
But if the device has less than BTRFS_DEFAULT_MAX_ACTIVE_ZONES the internal max_active_zones limit will stay at 0, even if the device has zone resource limits. Furthermore, if the device has a total number of zones that is less than BTRFS_DEFAULT_MAX_ACTIVE_ZONE, max_active_zones should be set to at most the number of zones.
Also move the max_active_zone calculation and setting into a dedicated helper, to shrink btrfs_get_dev_zone_info().
--- fs/btrfs/zoned.c | 64 +++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 25 deletions(-)
fs/btrfs/zoned.c +39 -25
@@ -352,12 +352,33 @@ int btrfs_get_dev_zone_info_all_devices(struct btrfs_fs_info *fs_info)return ret; } +static int btrfs_get_max_active_zones (struct btrfs_device *device, +struct btrfs_zoned_device_info *zone_info) +{ +struct block_device *bdev = device->bdev; +int max_active_zones; + +if (unlikely (zone_info->nr_zones <BTRFS_MIN_ACTIVE_ZONES )) { +btrfs_err (device->fs_info,"zoned: not enough zones to mount filesystem: %u < %d" , + zone_info->nr_zones,BTRFS_MIN_ACTIVE_ZONES ); +return -EINVAL ; + } + + max_active_zones =min_not_zero (bdev_max_active_zones (bdev), +bdev_max_open_zones (bdev)); +if (max_active_zones ==0 ) + max_active_zones =min (zone_info->nr_zones /4 , +BTRFS_DEFAULT_MAX_ACTIVE_ZONES ); + + zone_info->max_active_zones =max (max_active_zones,BTRFS_MIN_ACTIVE_ZONES ); +return 0 ; +} +int btrfs_get_dev_zone_info (struct btrfs_device *device,bool populate_cache) {struct btrfs_fs_info *fs_info = device->fs_info;struct btrfs_zoned_device_info *zone_info =NULL ;struct block_device *bdev = device->bdev; -unsigned int max_active_zones;unsigned int nactive;sector_t nr_sectors;sector_t sector =0 ;
@@ -422,19 +443,9 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)if (!IS_ALIGNED (nr_sectors, zone_sectors)) zone_info->nr_zones++; - max_active_zones =min_not_zero (bdev_max_active_zones (bdev), -bdev_max_open_zones (bdev)); -if (!max_active_zones && zone_info->nr_zones >BTRFS_DEFAULT_MAX_ACTIVE_ZONES ) - max_active_zones =BTRFS_DEFAULT_MAX_ACTIVE_ZONES ; -if (max_active_zones && max_active_zones <BTRFS_MIN_ACTIVE_ZONES ) { -btrfs_err (fs_info, -"zoned: %s: max active zones %u is too small, need at least %u active zones" , -rcu_dereference (device->name), max_active_zones, -BTRFS_MIN_ACTIVE_ZONES ); - ret = -EINVAL ; + ret =btrfs_get_max_active_zones (device, zone_info); +if (ret) goto out; - } - zone_info->max_active_zones = max_active_zones; zone_info->seq_zones =bitmap_zalloc (zone_info->nr_zones,GFP_KERNEL );if (!zone_info->seq_zones) {
@@ -514,26 +525,29 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache) goto out; } -if (max_active_zones) { -if (unlikely (nactive > max_active_zones)) { -if (bdev_max_active_zones (bdev) ==0 ) { - max_active_zones =0 ; - zone_info->max_active_zones =0 ; - goto validate; - } +if (unlikely (nactive > zone_info->max_active_zones)) { +if (bdev_max_active_zones (bdev) >0 ) {btrfs_err (device->fs_info, -"zoned: %u active zones on %s exceeds max_active_zones %u" , - nactive,rcu_dereference (device->name), - max_active_zones); +"zoned: %u active zones on %s exceeds max_active_zones %u" , + nactive,rcu_dereference (device->name), + zone_info->max_active_zones); ret = -EIO ; goto out; } + +/* +* This is for backward compatibility with old filesystems that +* have a lot of active zones because the device doesn't report +* a maximum number of zones and we previously didn't care for +* the limit. +*/ + zone_info->max_active_zones =0 ; + }else {atomic_set (&zone_info->active_zones_left, - max_active_zones - nactive); + zone_info->max_active_zones - nactive);set_bit (BTRFS_FS_ACTIVE_ZONE_TRACKING , &fs_info->flags); } -validate:/* Validate superblock log */ nr_zones =BTRFS_NR_SB_LOG_ZONES ;for (i =0 ; i <BTRFS_SUPER_MIRROR_MAX ; i++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 426/1611 btrfs: annotate lockless read of defrag_bytes in should_nocow()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 89c0dc3de7a73e8aba5e9bfef543eee047a3d0d2 ]
should_nocow() reads inode->defrag_bytes without holding inode->lock, while btrfs_set_delalloc_extent() and btrfs_clear_delalloc_extent() update it under that spinlock.
This is a data race. The read is a quick check used to decide whether to fall back to COW for a NOCOW inode: if defrag_bytes is non-zero and the range is tagged EXTENT_DEFRAG, we force COW so that defragmentation can rewrite the extent. Reading a stale value is harmless because:
- A missed increment may skip COW once, but the defrag pass will redo the extent later.
- A stale non-zero may force an unnecessary COW, which is a minor efficiency loss, not a correctness issue.
On 64-bit platforms an aligned u64 load is naturally atomic so tearing cannot happen. On 32-bit platforms u64 may tear, but we only test for zero vs non-zero, so the heuristic stays correct regardless. Use data_race() annotation.
--- fs/btrfs/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
@@ -2332,7 +2332,7 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,static bool should_nocow (struct btrfs_inode *inode,u64 start,u64 end) {if (inode->flags & (BTRFS_INODE_NODATACOW |BTRFS_INODE_PREALLOC )) { -if (inode->defrag_bytes && +if (data_race (inode->defrag_bytes) &&btrfs_test_range_bit_exists (&inode->io_tree, start, end,EXTENT_DEFRAG ))return false;return true;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 427/1611 btrfs: fix deadlock cloning inline extent when using flushoncommit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filipe Manana <[email protected]>
[ Upstream commit 532085d00eb54c074bdeae648b194765239f4d11 ]
In commit b48c980b6a7e ("btrfs: fix deadlock between reflink and transaction commit when using flushoncommit") a deadlock was fixed between reflinks and transaction commits when the fs is mounted with the flushoncommit option. This happened when we had to copy an inline extent's data to the destination file. However the issue was fixed only for the case where the destination offset is 0, it missed the case when the offset is greater than zero.
Fix this by ensuring we get i_size update whenever we copied an inline extent's data into the destination file.
Syzbot reported this with the following trace:
INFO: task kworker/u8:3:57 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:kworker/u8:3 state:D stack:21600 pid:57 tgid:57 ppid:2 task_flags:0x4208160 flags:0x00080000
Workqueue: writeback wb_workfn (flush-btrfs-129)
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5402 [inline]
__schedule+0x16f9/0x5500 kernel/sched/core.c:7204
__schedule_loop kernel/sched/core.c:7283 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7298
wait_extent_bit fs/btrfs/extent-io-tree.c:905 [inline]
btrfs_lock_extent_bits+0x59c/0x700 fs/btrfs/extent-io-tree.c:2008
btrfs_lock_extent fs/btrfs/extent-io-tree.h:152 [inline]
btrfs_invalidate_folio+0x440/0xc00 fs/btrfs/inode.c:7718
extent_writepage fs/btrfs/extent_io.c:1848 [inline]
extent_write_cache_pages fs/btrfs/extent_io.c:2552 [inline]
btrfs_writepages+0x12f3/0x2410 fs/btrfs/extent_io.c:2684
do_writepages+0x32e/0x550 mm/page-writeback.c:2571
__writeback_single_inode+0x133/0x10e0 fs/fs-writeback.c:1764
writeback_sb_inodes+0x97f/0x1980 fs/fs-writeback.c:2056
wb_writeback+0x445/0xb00 fs/fs-writeback.c:2241
wb_do_writeback fs/fs-writeback.c:2388 [inline]
wb_workfn+0x3fd/0xf20 fs/fs-writeback.c:2428
process_one_work+0x98b/0x1630 kernel/workqueue.c:3318
process_scheduled_works kernel/workqueue.c:3401 [inline]
worker_thread+0xb49/0x1140 kernel/workqueue.c:3482
kthread+0x388/0x470 kernel/kthread.c:436
ret_from_fork+0x514/0xb70 arch/x86/kernel/process.c:158
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
INFO: task syz.0.145:8523 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.0.145 state:D stack:22752 pid:8523 tgid:8522 ppid:5850 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5402 [inline]
__schedule+0x16f9/0x5500 kernel/sched/core.c:7204
__schedule_loop kernel/sched/core.c:7283 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7298
wb_wait_for_completion+0x3e8/0x790 fs/fs-writeback.c:227
__writeback_inodes_sb_nr+0x24c/0x2d0 fs/fs-writeback.c:2847
try_to_writeback_inodes_sb+0x9a/0xc0 fs/fs-writeback.c:2895
btrfs_start_delalloc_flush fs/btrfs/transaction.c:2182 [inline]
btrfs_commit_transaction+0x813/0x2fc0 fs/btrfs/transaction.c:2371
btrfs_sync_file+0xdf4/0x1230 fs/btrfs/file.c:1822
generic_write_sync include/linux/fs.h:2663 [inline]
btrfs_do_write_iter+0x6a9/0x840 fs/btrfs/file.c:1473
new_sync_write fs/read_write.c:595 [inline]
vfs_write+0x629/0xba0 fs/read_write.c:688
ksys_write+0x156/0x270 fs/read_write.c:740
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0x560 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5a0bdece59
RSP: 002b:00007f5a0b446028 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 00007f5a0c065fa0 RCX: 00007f5a0bdece59
RDX: 000000000000029f RSI: 0000200000000200 RDI: 0000000000000004
RBP: 00007f5a0be82d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5a0c066038 R14: 00007f5a0c065fa0 R15: 00007ffe149206b8
</TASK>
INFO: task syz.0.145:8539 blocked for more than 143 seconds.
Not tainted syzkaller #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
task:syz.0.145 state:D stack:23704 pid:8539 tgid:8522 ppid:5850 task_flags:0x400140 flags:0x00080002
Call Trace:
<TASK>
context_switch kernel/sched/core.c:5402 [inline]
__schedule+0x16f9/0x5500 kernel/sched/core.c:7204
__schedule_loop kernel/sched/core.c:7283 [inline]
schedule+0x164/0x360 kernel/sched/core.c:7298
wait_current_trans+0x39f/0x590 fs/btrfs/transaction.c:536
start_transaction+0xbd8/0x1820 fs/btrfs/transaction.c:716
clone_copy_inline_extent fs/btrfs/reflink.c:299 [inline]
btrfs_clone+0x1316/0x2540 fs/btrfs/reflink.c:574
btrfs_clone_files+0x271/0x3f0 fs/btrfs/reflink.c:795
btrfs_remap_file_range+0x76b/0x1320 fs/btrfs/reflink.c:948
vfs_clone_file_range+0x435/0x7b0 fs/remap_range.c:403
ioctl_file_clone fs/ioctl.c:239 [inline]
ioctl_file_clone_range fs/ioctl.c:257 [inline]
do_vfs_ioctl+0xe15/0x1540 fs/ioctl.c:544
__do_sys_ioctl fs/ioctl.c:595 [inline]
__se_sys_ioctl+0x82/0x170 fs/ioctl.c:583
do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
do_syscall_64+0x15f/0x560 arch/x86/entry/syscall_64.c:94
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f5a0bdece59
RSP: 002b:00007f5a0b425028 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f5a0c066090 RCX: 00007f5a0bdece59
RDX: 00002000000000c0 RSI: 000000004020940d RDI: 0000000000000004
RBP: 00007f5a0be82d6f R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007f5a0c066128 R14: 00007f5a0c066090 R15: 00007ffe149206b8
</TASK>--- fs/btrfs/reflink.c | 101 +++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 44 deletions(-)
fs/btrfs/reflink.c +57 -44
@@ -178,10 +178,12 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,struct btrfs_drop_extents_args drop_args = {0 };int ret;struct btrfs_key key; +bool copied_inline_to_page = false;if (new_key->offset >0 ) { ret =copy_inline_to_page (inode, new_key->offset, inline_data, size, datal, comp_type); + copied_inline_to_page = (ret ==0 ); goto out; }
@@ -287,6 +289,60 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode,btrfs_abort_transaction (trans, ret); out:if (!ret && !trans) { +if (copied_inline_to_page && + new_key->offset + datal >i_size_read (&inode->vfs_inode)) { +/* +* If we copied the inline extent data to a page/folio +* beyond the i_size of the destination inode, then we +* need to increase the i_size before we start a +* transaction to update the inode item. This is to +* prevent a deadlock when the flushoncommit mount +* option is used, which happens like this: +* +* 1) Task A clones an inline extent from inode X to an +* offset of inode Y that is beyond Y's current +* i_size. This means we copied the inline extent's +* data to a folio of inode Y that is beyond its EOF, +* using the call above to copy_inline_to_page(); +* +* 2) Task B starts a transaction commit and calls +* btrfs_start_delalloc_flush() to flush delalloc; +* +* 3) The delalloc flushing sees the new dirty folio of +* inode Y and when it attempts to flush it, it ends +* up at extent_writepage() and sees that the offset +* of the folio is beyond the i_size of inode Y, so +* it attempts to invalidate the folio by calling +* folio_invalidate(), which ends up at btrfs' folio +* invalidate callback - btrfs_invalidate_folio(). +* There it tries to lock the folio's range in inode +* Y's extent io tree, but it blocks since it's +* currently locked by task A - during reflink we +* lock the inodes and the source and destination +* ranges after flushing all delalloc and waiting for +* ordered extent completion - after that we don't +* expect to have dirty folios in the ranges, the +* exception is if we have to copy an inline extent's +* data (because the destination offset is not zero); +* +* 4) Task A then does the 'goto out' below and attempts +* to start a transaction to update the inode item, +* and then it's blocked since the current +* transaction is in the TRANS_STATE_COMMIT_START +* state. Therefore task A has to wait for the +* current transaction to become unblocked (its +* state >= TRANS_STATE_UNBLOCKED). +* +* This leads to a deadlock - the task committing the +* transaction waiting for the delalloc flushing which +* is blocked during folio invalidation on the inode's +* extent lock and the reflink task waiting for the +* current transaction to be unblocked so that it can +* start a new one to update the inode item (while +* holding the extent lock). +*/ +i_size_write (&inode->vfs_inode, new_key->offset + datal); + }/* * No transaction here means we copied the inline extent into a * page of the destination inode.
@@ -319,50 +375,7 @@ static int clone_copy_inline_extent(struct btrfs_inode *inode, ret =copy_inline_to_page (inode, new_key->offset, inline_data, size, datal, comp_type); - -/* -* If we copied the inline extent data to a page/folio beyond the i_size -* of the destination inode, then we need to increase the i_size before -* we start a transaction to update the inode item. This is to prevent a -* deadlock when the flushoncommit mount option is used, which happens -* like this: -* -* 1) Task A clones an inline extent from inode X to an offset of inode -* Y that is beyond Y's current i_size. This means we copied the -* inline extent's data to a folio of inode Y that is beyond its EOF, -* using the call above to copy_inline_to_page(); -* -* 2) Task B starts a transaction commit and calls -* btrfs_start_delalloc_flush() to flush delalloc; -* -* 3) The delalloc flushing sees the new dirty folio of inode Y and when -* it attempts to flush it, it ends up at extent_writepage() and sees -* that the offset of the folio is beyond the i_size of inode Y, so -* it attempts to invalidate the folio by calling folio_invalidate(), -* which ends up at btrfs' folio invalidate callback - -* btrfs_invalidate_folio(). There it tries to lock the folio's range -* in inode Y's extent io tree, but it blocks since it's currently -* locked by task A - during reflink we lock the inodes and the -* source and destination ranges after flushing all delalloc and -* waiting for ordered extent completion - after that we don't expect -* to have dirty folios in the ranges, the exception is if we have to -* copy an inline extent's data (because the destination offset is -* not zero); -* -* 4) Task A then does the 'goto out' below and attempts to start a -* transaction to update the inode item, and then it's blocked since -* the current transaction is in the TRANS_STATE_COMMIT_START state. -* Therefore task A has to wait for the current transaction to become -* unblocked (its state >= TRANS_STATE_UNBLOCKED). -* -* This leads to a deadlock - the task committing the transaction -* waiting for the delalloc flushing which is blocked during folio -* invalidation on the inode's extent lock and the reflink task waiting -* for the current transaction to be unblocked so that it can start a -* a new one to update the inode item (while holding the extent lock). -*/ -if (ret ==0 && new_key->offset + datal >i_size_read (&inode->vfs_inode)) -i_size_write (&inode->vfs_inode, new_key->offset + datal); + copied_inline_to_page = (ret ==0 ); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 428/1611 igc: skip RX timestamp header for frame preemption verification
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: KhaiWenTan <[email protected]>
[ Upstream commit 38b7a274cf84af9b1f4b602b8e2741565b81947b ]
When RX hardware timestamping is enabled, a 16-byte inline timestamp header is added to the start of the packet buffer, causing FPE handshake verification to fail.
Because an incorrect packet buffer is passed to igc_fpe_handle_mpacket(), the mem_is_zero() check inspects the timestamp metadata instead of the actual mPacket payload. As a result, valid Verify/Response mPackets can be missed when inline RX timestamps are present.
Pass pktbuf + pkt_offset to igc_fpe_handle_mpacket() so it inspects the actual mPacket payload instead of the timestamp header.
--- drivers/net/ethernet/intel/igc/igc_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/igc/igc_main.c +1 -1
@@ -2649,7 +2649,7 @@ static int igc_clean_rx_irq(struct igc_q_vector *q_vector, const int budget) }if (igc_fpe_is_pmac_enabled (adapter) && -igc_fpe_handle_mpacket (adapter, rx_desc, size, pktbuf)) { +igc_fpe_handle_mpacket (adapter, rx_desc, size, pktbuf + pkt_offset)) {/* Advance the ring next-to-clean */ igc_is_non_eop (rx_ring, rx_desc); cleaned_count++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 429/1611 ASoC: sma1307: Fix uevent string leaks in fault worker
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit a750ca72af72dde9744468fdca6eda0b698a1cfc ]
sma1307_check_fault_worker() stores dynamically allocated uevent strings in envp[0]. Several fault conditions are checked in sequence, so a later fault can overwrite envp[0] before the final kfree() and leak the previous allocation.
The same flow can leave an OT1 volume entry in envp[1] while envp[0] has been overwritten by a later non-OT1 fault, causing an inconsistent uevent payload.
Use static STATUS strings and a stack buffer for the optional VOLUME entry. This removes the allocations from the worker and keeps VOLUME tied only to the OT1 events that produce it.
--- sound/soc/codecs/sma1307.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-)
sound/soc/codecs/sma1307.c +21 -14
@@ -1612,6 +1612,7 @@ static void sma1307_check_fault_worker(struct work_struct *work)struct sma1307_priv *sma1307 = container_of(work, struct sma1307_priv, check_fault_work.work);unsigned int status1_val, status2_val; +char volume[sizeof ("VOLUME=0x12345678" )];char *envp[3 ] = {NULL ,NULL ,NULL };if (sma1307->tsdw_cnt)
@@ -1627,7 +1628,7 @@ static void sma1307_check_fault_worker(struct work_struct *work)if (~status1_val &SMA1307_OT1_OK_STATUS ) {dev_crit (sma1307->dev,"%s: OT1(Over Temperature Level 1)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OT1" ); + envp[0 ] ="STATUS=OT1" ;if (sma1307->sw_ot1_prot) {/* Volume control (Current Volume -3dB) */ if ((sma1307->cur_vol +6 ) <=0xFA ) {
@@ -1635,8 +1636,9 @@ static void sma1307_check_fault_worker(struct work_struct *work)regmap_write (sma1307->regmap,SMA1307_0A_SPK_VOL , sma1307->cur_vol); - envp[1 ] =kasprintf (GFP_KERNEL , -"VOLUME=0x%02X" , sma1307->cur_vol); +snprintf (volume,sizeof (volume), +"VOLUME=0x%02X" , sma1307->cur_vol); + envp[1 ] = volume; } } sma1307->tsdw_cnt++;
@@ -1645,48 +1647,53 @@ static void sma1307_check_fault_worker(struct work_struct *work) SMA1307_0A_SPK_VOL, sma1307->init_vol); sma1307->tsdw_cnt =0 ; sma1307->cur_vol = sma1307->init_vol; - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OT1_CLEAR" ); - envp[1 ] =kasprintf (GFP_KERNEL , -"VOLUME=0x%02X" , sma1307->cur_vol); + envp[0 ] ="STATUS=OT1_CLEAR" ; +snprintf (volume,sizeof (volume),"VOLUME=0x%02X" , + sma1307->cur_vol); + envp[1 ] = volume; }if (~status1_val &SMA1307_OT2_OK_STATUS ) {dev_crit (sma1307->dev,"%s: OT2(Over Temperature Level 2)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OT2" ); + envp[0 ] ="STATUS=OT2" ; + envp[1 ] =NULL ; }if (status1_val &SMA1307_UVLO_STATUS ) {dev_crit (sma1307->dev,"%s: UVLO(Under Voltage Lock Out)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=UVLO" ); + envp[0 ] ="STATUS=UVLO" ; + envp[1 ] =NULL ; }if (status1_val &SMA1307_OVP_BST_STATUS ) {dev_crit (sma1307->dev,"%s: OVP_BST(Over Voltage Protection)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OVP_BST" ); + envp[0 ] ="STATUS=OVP_BST" ; + envp[1 ] =NULL ; }if (status2_val &SMA1307_OCP_SPK_STATUS ) {dev_crit (sma1307->dev,"%s: OCP_SPK(Over Current Protect SPK)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OCP_SPK" ); + envp[0 ] ="STATUS=OCP_SPK" ; + envp[1 ] =NULL ; }if (status2_val &SMA1307_OCP_BST_STATUS ) {dev_crit (sma1307->dev,"%s: OCP_BST(Over Current Protect Boost)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=OCP_BST" ); + envp[0 ] ="STATUS=OCP_BST" ; + envp[1 ] =NULL ; }if (status2_val &SMA1307_CLK_MON_STATUS ) {dev_crit (sma1307->dev,"%s: CLK_FAULT(No clock input)\n" , __func__); - envp[0 ] =kasprintf (GFP_KERNEL ,"STATUS=CLK_FAULT" ); + envp[0 ] ="STATUS=CLK_FAULT" ; + envp[1 ] =NULL ; }if (envp[0 ] !=NULL ) {if (kobject_uevent_env (sma1307->kobj,KOBJ_CHANGE , envp))dev_err (sma1307->dev,"%s: Error sending uevent\n" , __func__); -kfree (envp[0 ]); -kfree (envp[1 ]); }if (sma1307->check_fault_status) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 430/1611 IB/mlx4: Fill in the access_flags if IB_MR_REREG_ACCESS is not specified
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Gunthorpe <[email protected]>
[ Upstream commit bade9a3150d44ed20b8c6484c4c8a943b7289abb ]
Sashiko noticed mlx4 was using whatever random access flags were provided when IB_MR_REREG_ACCESS is not used. Since IB_MR_REREG_TRANS needs access_flags it used the random ones which means it doesn't work sensibly if userspace provides only IB_MR_REREG_TRANS.
Keep track of the current access_flag of the MR and use it if the user does not specify one.
Also fixup a little confusion around mmr.access, it is the HW access flags so the convert_access() was missing. But nothing reads this by the time rereg_mr can happen.
--- drivers/infiniband/hw/mlx4/mlx4_ib.h | 1 + drivers/infiniband/hw/mlx4/mr.c | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-)
drivers/infiniband/hw/mlx4/mlx4_ib.h +1 -0
@@ -137,6 +137,7 @@ struct mlx4_ib_mr {dma_addr_t page_map;u32 npages;u32 max_pages; +int access_flags;struct mlx4_mr mmr;struct ib_umem *umem;size_t page_map_size;
drivers/infiniband/hw/mlx4/mr.c +7 -2
@@ -181,6 +181,7 @@ struct ib_mr *mlx4_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,if (err) goto err_mr; + mr->access_flags = access_flags; mr->ibmr.rkey = mr->ibmr.lkey = mr->mmr.key; mr->ibmr.page_size =1U << shift;
@@ -241,6 +242,8 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,if (err) goto release_mpt_entry; + }else { + mr_access_flags = mmr->access_flags; }if (flags &IB_MR_REREG_TRANS ) {
@@ -282,8 +285,10 @@ struct ib_mr *mlx4_ib_rereg_user_mr(struct ib_mr *mr, int flags, u64 start,* return a failure. But dereg_mr will free the resources. */ err =mlx4_mr_hw_write_mpt (dev->dev, &mmr->mmr, pmpt_entry); -if (!err && flags &IB_MR_REREG_ACCESS ) - mmr->mmr.access = mr_access_flags; +if (!err && flags &IB_MR_REREG_ACCESS ) { + mmr->access_flags = mr_access_flags; + mmr->mmr.access =convert_access (mr_access_flags); + } release_mpt_entry:mlx4_mr_hw_put_mpt (dev->dev, pmpt_entry);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 431/1611 NFSD: Handle layout stid in nfsd4_drop_revoked_stid()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 86b9898920a6d02b4149f4fef9efd77b8aa3b9ca ]
nfsd4_drop_revoked_stid() has no SC_TYPE_LAYOUT case, so when a client sends FREE_STATEID for an admin-revoked layout stid, the default branch releases cl_lock and returns without unhashing or releasing the stid. The stid remains in the IDR and on the per-client list until the client is destroyed.
Remove the layout stid from the per-client list and call nfs4_put_stid() to drop the creation reference. When the refcount reaches zero, nfsd4_free_layout_stateid() handles the remaining cleanup: cancelling the fence worker, removing from the per-file list, and freeing the slab object.
--- fs/nfsd/nfs4state.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/nfsd/nfs4state.c +7 -0
@@ -5049,6 +5049,7 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s) {struct nfs4_client *cl = s->sc_client;LIST_HEAD (reaplist); +struct nfs4_layout_stateid *ls;struct nfs4_ol_stateid *stp;struct nfs4_delegation *dp;bool unhashed;
@@ -5074,6 +5075,12 @@ static void nfsd4_drop_revoked_stid(struct nfs4_stid *s)spin_unlock (&cl->cl_lock);nfs4_put_stid (s);break ; +case SC_TYPE_LAYOUT : + ls =layoutstateid (s); +list_del_init (&ls->ls_perclnt); +spin_unlock (&cl->cl_lock); +nfs4_put_stid (s); +break ;default :spin_unlock (&cl->cl_lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 432/1611 spi: meson-spifc: fix runtime PM leak on remove
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 606c0826bd90384a54571c0c5475ca41f50164ea ]
pm_runtime_get_sync() increments the runtime PM usage counter even when it returns an error. meson_spifc_remove() uses it to resume the controller before disabling runtime PM, but never drops the usage counter again.
Balance the get with pm_runtime_put_noidle() after disabling runtime PM, matching the teardown pattern used by other SPI controller drivers.
Found by static analysis. I do not have hardware to test this.
--- drivers/spi/spi-meson-spifc.c | 1 + 1 file changed, 1 insertion(+)
drivers/spi/spi-meson-spifc.c +1 -0
@@ -352,6 +352,7 @@ static void meson_spifc_remove(struct platform_device *pdev) {pm_runtime_get_sync (&pdev->dev);pm_runtime_disable (&pdev->dev); +pm_runtime_put_noidle (&pdev->dev); }#ifdef CONFIG_PM_SLEEP
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 433/1611 ASoC: codecs: aw88261: fix incorrect masks for boost regs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Val Packett <[email protected]>
[ Upstream commit 79c053a1ff9d3ab31cefbc791e8d7816ba830491 ]
The boost-related register fields used in aw88261_reg_force_set use the exact same definitions as the rest of the fields, where the mask must be inverted when passing it to regmap_update_bits, but they weren't inverted here.
--- sound/soc/codecs/aw88261.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
sound/soc/codecs/aw88261.c +6 -6
@@ -283,22 +283,22 @@ static void aw88261_reg_force_set(struct aw88261 *aw88261)if (aw88261->frcset_en ==AW88261_FRCSET_ENABLE ) {/* set FORCE_PWM */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL3_REG , -AW88261_FORCE_PWM_MASK ,AW88261_FORCE_PWM_FORCEMINUS_PWM_VALUE ); + ~AW88261_FORCE_PWM_MASK ,AW88261_FORCE_PWM_FORCEMINUS_PWM_VALUE );/* set BOOST_OS_WIDTH */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL5_REG , -AW88261_BST_OS_WIDTH_MASK ,AW88261_BST_OS_WIDTH_50NS_VALUE ); + ~AW88261_BST_OS_WIDTH_MASK ,AW88261_BST_OS_WIDTH_50NS_VALUE );/* set BURST_LOOPR */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL6_REG , -AW88261_BST_LOOPR_MASK ,AW88261_BST_LOOPR_340K_VALUE ); + ~AW88261_BST_LOOPR_MASK ,AW88261_BST_LOOPR_340K_VALUE );/* set RSQN_DLY */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL7_REG , -AW88261_RSQN_DLY_MASK ,AW88261_RSQN_DLY_35NS_VALUE ); + ~AW88261_RSQN_DLY_MASK ,AW88261_RSQN_DLY_35NS_VALUE );/* set BURST_SSMODE */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL8_REG , -AW88261_BURST_SSMODE_MASK ,AW88261_BURST_SSMODE_FAST_VALUE ); + ~AW88261_BURST_SSMODE_MASK ,AW88261_BURST_SSMODE_FAST_VALUE );/* set BST_BURST */ regmap_update_bits (aw88261->regmap,AW88261_BSTCTRL9_REG , -AW88261_BST_BURST_MASK ,AW88261_BST_BURST_30MA_VALUE ); + ~AW88261_BST_BURST_MASK ,AW88261_BST_BURST_30MA_VALUE ); }else {dev_dbg (aw88261->aw_pa->dev,"needn't set reg value" ); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 434/1611 vduse: hold vduse_lock across IDR lookup in open path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang Tang <[email protected]>
[ Upstream commit e440e077748939839d9f76e24383b76b785f80ce ]
vduse_dev_open() looks up struct vduse_dev through the IDR and then acquires dev->lock only after vduse_lock has been dropped.
This leaves a window where a concurrent VDUSE_DESTROY_DEV can remove the same object from the IDR and free it before the open path locks the device, leading to a use-after-free.
Close this race by keeping vduse_lock held until dev->lock has been acquired in the open path, matching the lock ordering already used by the destroy path.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/vdpa/vdpa_user/vduse_dev.c +7 -14
@@ -1438,26 +1438,18 @@ static int vduse_dev_release(struct inode *inode, struct file *file)return 0 ; } -static struct vduse_dev *vduse_dev_get_from_minor (int minor) +static int vduse_dev_open (struct inode *inode,struct file *file) { +int ret = -EBUSY ;struct vduse_dev *dev;mutex_lock (&vduse_lock); - dev =idr_find (&vduse_idr, minor); -mutex_unlock (&vduse_lock); - -return dev; -} - -static int vduse_dev_open (struct inode *inode,struct file *file) -{ -int ret; -struct vduse_dev *dev =vduse_dev_get_from_minor (iminor (inode)); - -if (!dev) + dev =idr_find (&vduse_idr,iminor (inode)); +if (!dev) { +mutex_unlock (&vduse_lock);return -ENODEV ; + } - ret = -EBUSY ;mutex_lock (&dev->lock);if (dev->connected) goto unlock;
@@ -1467,6 +1459,7 @@ static int vduse_dev_open(struct inode *inode, struct file *file) file->private_data = dev; unlock:mutex_unlock (&dev->lock); +mutex_unlock (&vduse_lock);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 435/1611 vhost/vdpa: validate virtqueue index in mmap and fault paths
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qihang Tang <[email protected]>
[ Upstream commit 929e4f044621c8cc30b612fb74e1410bef09e41b ]
vhost_vdpa_mmap() and vhost_vdpa_fault() use vma->vm_pgoff as a virtqueue index for get_vq_notification(), but they do not validate that the index is smaller than v->nvqs.
The ioctl path already performs both a bounds check and array_index_nospec(), but the mmap/fault path only checks that the index fits in u16. This allows an out-of-range queue index to reach driver-specific get_vq_notification() callbacks.
Fix this by extracting a unified vhost_vdpa_get_vq_notification() helper that validates the queue index against v->nvqs and applies array_index_nospec() before calling the driver callback. Both the mmap and fault paths use this helper, and the bounds checking is consolidated into a single location.
Quoted 1 line
From source inspection, the most defensible impact is out-of-bounds
access in the callback path, potentially leading to invalid PFN remaps and crash/DoS.
Message-ID: <[email protected]>
--- drivers/vhost/vdpa.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/vhost/vdpa.c +22 -7
@@ -1480,16 +1480,32 @@ static int vhost_vdpa_release(struct inode *inode, struct file *filep) }#ifdef CONFIG_MMU -static vm_fault_t vhost_vdpa_fault (struct vm_fault *vmf) +static int +vhost_vdpa_get_vq_notification (struct vhost_vdpa *v,unsigned long index, +struct vdpa_notification_area *notify) { -struct vhost_vdpa *v = vmf->vma->vm_file->private_data;struct vdpa_device *vdpa = v->vdpa;const struct vdpa_config_ops *ops = vdpa->config; + +if (index >65535 || index >= v->nvqs) +return -EINVAL ; + + index =array_index_nospec (index, v->nvqs); + + *notify = ops->get_vq_notification (vdpa, index); + +return 0 ; +} + +static vm_fault_t vhost_vdpa_fault (struct vm_fault *vmf) +{ +struct vhost_vdpa *v = vmf->vma->vm_file->private_data;struct vdpa_notification_area notify;struct vm_area_struct *vma = vmf->vma; -u16 index = vma->vm_pgoff; +unsigned long index = vma->vm_pgoff; - notify = ops->get_vq_notification (vdpa, index); +if (vhost_vdpa_get_vq_notification (v, index, ¬ify)) +return VM_FAULT_SIGBUS ;return vmf_insert_pfn (vma, vmf->address &PAGE_MASK ,PFN_DOWN (notify.addr)); }
@@ -1512,8 +1528,6 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)return -EINVAL ;if (vma->vm_flags &VM_READ )return -EINVAL ; -if (index >65535 ) -return -EINVAL ;if (!ops->get_vq_notification)return -ENOTSUPP ;
@@ -1521,7 +1535,8 @@ static int vhost_vdpa_mmap(struct file *file, struct vm_area_struct *vma)* support the doorbell which sits on the page boundary and * does not share the page with other registers. */ - notify = ops->get_vq_notification (vdpa, index); +if (vhost_vdpa_get_vq_notification (v, index, ¬ify)) +return -EINVAL ;if (notify.addr & (PAGE_SIZE -1 ))return -EINVAL ;if (vma->vm_end - vma->vm_start != notify.size)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 436/1611 virtio: rtc: tear down old virtqueues before restore
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jia Jia <[email protected]>
[ Upstream commit 548d2208455f14e6121404c6e30e997bfe0cd264 ]
virtio_device_restore() resets the device and restores the negotiated features before calling ->restore(). viortc_freeze() intentionally leaves the existing virtqueues in place so the alarm queue can still wake the system, but viortc_restore() immediately calls viortc_init_vqs() without first deleting those old queues.
If virtqueue reinitialization fails on virtio-pci, the transport error path can run vp_del_vqs() against a newly allocated vp_dev->vqs array while vdev->vqs still contains the old virtqueues. vp_del_vqs() then looks up queue state through the new array and can dereference a NULL info pointer in vp_del_vq(), crashing the guest kernel during restore.
This can also happen during a non-faulty reinitialization, when one of the vp_find_vqs_msix() attempts is unsuccessful before a later attempt would succeed.
Delete the stale virtqueues before rebuilding them. If restore fails before virtio_device_ready(), reuse the remove path to stop the device. Once the device is ready, return errors directly instead of deleting the virtqueues again.
Message-ID: <[email protected]>
--- drivers/virtio/virtio_rtc_driver.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
drivers/virtio/virtio_rtc_driver.c +20 -8
@@ -1257,6 +1257,15 @@ static int viortc_init_vqs(struct viortc_dev *viortc)return 0 ; } +static void __viortc_remove (struct viortc_dev *viortc) +{ +struct virtio_device *vdev = viortc->vdev; + +viortc_clocks_deinit (viortc); +virtio_reset_device (vdev); + vdev->config->del_vqs (vdev); +} +/** * viortc_probe() - probe a virtio_rtc virtio device * @vdev: virtio device
@@ -1282,7 +1291,7 @@ static int viortc_probe(struct virtio_device *vdev) ret =viortc_init_vqs (viortc);if (ret) -return ret; + goto err_reset_vdev;virtio_device_ready (vdev);
@@ -1329,10 +1338,7 @@ static void viortc_remove(struct virtio_device *vdev) {struct viortc_dev *viortc = vdev->priv; -viortc_clocks_deinit (viortc); - -virtio_reset_device (vdev); - vdev->config->del_vqs (vdev); +__viortc_remove (viortc); }static int viortc_freeze (struct virtio_device *dev)
@@ -1353,9 +1359,11 @@ static int viortc_restore(struct virtio_device *dev)bool notify = false;int ret; + dev->config->del_vqs (dev); + ret =viortc_init_vqs (viortc);if (ret) -return ret; + goto err_remove; alarm_viortc_vq = &viortc->vqs[VIORTC_ALARMQ ]; alarm_vq = alarm_viortc_vq->vq;
@@ -1364,7 +1372,7 @@ static int viortc_restore(struct virtio_device *dev) ret =viortc_populate_vq (viortc, alarm_viortc_vq,VIORTC_ALARMQ_BUF_CAP , false);if (ret) -return ret; + goto err_remove; notify =virtqueue_kick_prepare (alarm_vq); }
@@ -1372,8 +1380,12 @@ static int viortc_restore(struct virtio_device *dev)virtio_device_ready (dev);if (notify && !virtqueue_notify (alarm_vq)) - ret = -EIO ; +return -EIO ; + +return 0 ; +err_remove: +__viortc_remove (viortc);return ret; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 437/1611 virtio_console: read size from config space during device init
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Filip Hejsek <[email protected]>
[ Upstream commit b3592a32b34f37874dc94aa1a0d15c4334ed86ca ]
Previously, the size was only read upon receiving the config interrupt. This interrupt is sent when the size changes. However, we also need to read the initial size.
Also make sure to only read the size from config if F_SIZE is enabled.
Message-ID: <[email protected]>
--- drivers/char/virtio_console.c | 52 +++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-)
drivers/char/virtio_console.c +31 -21
@@ -1771,32 +1771,40 @@ static void config_intr(struct virtio_device *vdev)schedule_work (&portdev->config_work); } -static void config_work_handler (struct work_struct *work) +static void update_size_from_config (struct ports_device *portdev) { -struct ports_device *portdev; +struct virtio_device *vdev; +struct port *port; +u16 rows, cols; - portdev = container_of(work, struct ports_device, config_work); -if (!use_multiport (portdev)) { -struct virtio_device *vdev; -struct port *port; -u16 rows, cols; + vdev = portdev->vdev; - vdev = portdev->vdev; - virtio_cread(vdev, struct virtio_console_config, cols, &cols); - virtio_cread(vdev, struct virtio_console_config, rows, &rows); +/* +* We'll use this way of resizing only for legacy support. +* For multiport devices, use control messages to indicate +* console size changes so that it can be done per-port. +* +* Don't test F_SIZE at all if we're rproc: not a valid feature. +*/ +if (is_rproc_serial (vdev) || +use_multiport (portdev) || + !virtio_has_feature (vdev,VIRTIO_CONSOLE_F_SIZE )) +return ; - port =find_port_by_id (portdev,0 ); -set_console_size (port, rows, cols); + virtio_cread(vdev, struct virtio_console_config, cols, &cols); + virtio_cread(vdev, struct virtio_console_config, rows, &rows); -/* -* We'll use this way of resizing only for legacy -* support. For newer userspace -* (VIRTIO_CONSOLE_F_MULTPORT+), use control messages -* to indicate console size changes so that it can be -* done per-port. -*/ -resize_console (port); - } + port =find_port_by_id (portdev,0 ); +set_console_size (port, rows, cols); +resize_console (port); +} + +static void config_work_handler (struct work_struct *work) +{ +struct ports_device *portdev; + + portdev = container_of(work, struct ports_device, config_work); +update_size_from_config (portdev); }static int init_vqs (struct ports_device *portdev)
@@ -2054,6 +2062,8 @@ static int virtcons_probe(struct virtio_device *vdev)__send_control_msg (portdev,VIRTIO_CONSOLE_BAD_ID ,VIRTIO_CONSOLE_DEVICE_READY ,1 ); +update_size_from_config (portdev); +return 0 ; free_chrdev:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 438/1611 vduse: Requeue failed read to send_list head
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Tianci <[email protected]>
[ Upstream commit 373ec43ded742b2f3aecf14731ffe1a57f438f38 ]
When copy_to_iter() fails in vduse_dev_read_iter(), put the message back at the head of send_list to preserve FIFO ordering and retry the oldest pending request first.
Message-ID: <[email protected]>
--- drivers/vdpa/vdpa_user/vduse_dev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/vdpa/vdpa_user/vduse_dev.c +7 -1
@@ -194,6 +194,12 @@ static void vduse_enqueue_msg(struct list_head *head,list_add_tail (&msg->list, head); } +static void vduse_enqueue_msg_head (struct list_head *head, +struct vduse_dev_msg *msg) +{ +list_add (&msg->list, head); +} +static void vduse_dev_broken (struct vduse_dev *dev) {struct vduse_dev_msg *msg, *tmp;
@@ -354,7 +360,7 @@ static ssize_t vduse_dev_read_iter(struct kiocb *iocb, struct iov_iter *to)spin_lock (&dev->msg_lock);if (ret != size) { ret = -EFAULT ; -vduse_enqueue_msg (&dev->send_list, msg); +vduse_enqueue_msg_head (&dev->send_list, msg); goto unlock; }vduse_enqueue_msg (&dev->recv_list, msg);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 439/1611 vhost/net: complete zerocopy ubufs only once
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qing Ming <[email protected]>
[ Upstream commit 8f6898fe80794f2d7c3d38c1158c806e4074a1c4 ]
vhost-net initializes one ubuf_info per outstanding zerocopy TX descriptor and hands it to the backend socket. The networking stack may then clone a zerocopy skb before all skb references are released. For example, batman-adv fragmentation reaches skb_split(), which calls skb_zerocopy_clone() and increments the same ubuf_info refcount.
vhost_zerocopy_complete() currently treats every ubuf callback as a completed vhost descriptor. It dereferences ubuf->ctx, writes the descriptor completion state, and drops the vhost_net_ubuf_ref even when the callback only releases a cloned skb reference. A backend reset can therefore wait for and free the vhost_net_ubuf_ref while another cloned skb still carries the same ubuf_info. A later completion then dereferences the freed ubufs pointer.
KASAN reports the stale completion as:
BUG: KASAN: slab-use-after-free in vhost_zerocopy_complete+0x1d7/0x1f0 BUG: KASAN: slab-use-after-free in vhost_zerocopy_complete+0x101/0x1f0 vhost_zerocopy_complete skb_copy_ubufs __dev_forward_skb2 veth_xmit
The freed object was allocated from vhost_net_ioctl() while setting the backend and freed through kfree_rcu()/kvfree_rcu_bulk after backend removal, while delayed skb completion still reached vhost_zerocopy_complete().
Honor the generic ubuf_info refcount before touching vhost state, and run the vhost descriptor completion only for the final ubuf reference. This matches the msg_zerocopy_complete() ownership rule for cloned zerocopy skbs.
Message-ID: <[email protected]>
--- drivers/vhost/net.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/vhost/net.c +11 -4
@@ -392,13 +392,20 @@ static void vhost_zerocopy_signal_used(struct vhost_net *net,static void vhost_zerocopy_complete (struct sk_buff *skb,struct ubuf_info *ubuf_base,bool success) { -struct ubuf_info_msgzc *ubuf =uarg_to_msgzc (ubuf_base); -struct vhost_net_ubuf_ref *ubufs = ubuf->ctx; -struct vhost_virtqueue *vq = ubufs->vq; +struct ubuf_info_msgzc *ubuf; +struct vhost_net_ubuf_ref *ubufs; +struct vhost_virtqueue *vq;int cnt; -rcu_read_lock_bh (); +/* Only the final cloned skb reference completes the vhost descriptor. */ +if (!refcount_dec_and_test (&ubuf_base->refcnt)) +return ; + + ubuf =uarg_to_msgzc (ubuf_base); + ubufs = ubuf->ctx; + vq = ubufs->vq; +rcu_read_lock_bh ();/* set len to mark this desc buffers done DMA */ vq->heads[ubuf->desc].len = success ?VHOST_DMA_DONE_LEN :VHOST_DMA_FAILED_LEN ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 440/1611 tools/virtio: check mmap return value in vringh_test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: longlong yan <[email protected]>
[ Upstream commit ec6177dfe98b9be1c3ede6c0dfe4394ea2a76959 ]
In parallel_test(), the return values of mmap() for both host_map and guest_map are not checked against MAP_FAILED. If mmap() fails, the subsequent code will dereference the invalid pointer, leading to a segmentation fault.
Add MAP_FAILED checks after both mmap() calls, using err() to report the error and exit, consistent with the existing error handling style in this file (e.g., the open() call on line 149).
Message-ID: <[email protected]>
--- tools/virtio/vringh_test.c | 5 +++++ 1 file changed, 5 insertions(+)
tools/virtio/vringh_test.c +5 -0
@@ -159,7 +159,12 @@ static int parallel_test(u64 features,/* Parent and child use separate addresses, to check our mapping logic! */ host_map =mmap (NULL , mapsize,PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 ); +if (host_map ==MAP_FAILED ) +err (1 ,"mmap host_map" ); + guest_map =mmap (NULL , mapsize,PROT_READ |PROT_WRITE ,MAP_SHARED , fd,0 ); +if (guest_map ==MAP_FAILED ) +err (1 ,"mmap guest_map" ); pipe_ret =pipe (to_guest);assert (!pipe_ret);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 441/1611 vdpa/octeon_ep: Fix PF->VF mailbox data address calculation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srujana Challa <[email protected]>
[ Upstream commit 74dc530f4c505d61f0f3620e59fe56c325ae3437 ]
The mailbox address was computed assuming 1 ring per VF. Read the actual rings-per-VF from OCTEP_EPF_RINFO and use it when calculating OCTEP_PF_MBOX_DATA offsets, fixing VF initialization when rings per VF > 1.
Message-ID: <[email protected]>
--- drivers/vdpa/octeon_ep/octep_vdpa_main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/vdpa/octeon_ep/octep_vdpa_main.c +6 -1
@@ -1,6 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only /* Copyright (C) 2024 Marvell. */ +#include <linux/bitfield.h> #include <linux/interrupt.h> #include <linux/io-64-nonatomic-lo-hi.h> #include <linux/module.h>
@@ -722,6 +723,8 @@ static int octep_sriov_enable(struct pci_dev *pdev, int num_vfs)bool done = false;int index =0 ;int ret, i; +u8 rpvf; +u64 val; ret =pci_enable_sriov (pdev, num_vfs);if (ret)
@@ -741,9 +744,11 @@ static int octep_sriov_enable(struct pci_dev *pdev, int num_vfs) } } + val =readq (addr +OCTEP_EPF_RINFO (0 )); + rpvf =FIELD_GET (GENMASK_ULL (35 ,32 ), val);if (done) {for (i =0 ; i < pf->enabled_vfs; i++) -writeq (OCTEP_DEV_READY_SIGNATURE , addr +OCTEP_PF_MBOX_DATA (i)); +writeq (OCTEP_DEV_READY_SIGNATURE , addr +OCTEP_PF_MBOX_DATA (i * rpvf)); }return num_vfs;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 442/1611 vdpa/octeon_ep: fix IRQ-to-ring mapping in interrupt handler
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srujana Challa <[email protected]>
[ Upstream commit 0d21a1d6375a05274291e32c1ab7cd57dbb69513 ]
Look up the IRQ index in oct_hw->irqs instead of assuming irq - irqs[0]. This supports non-contiguous IRQ numbers and avoids incorrect ring indexing when irqs[0] is not the base.
Message-ID: <[email protected]>
--- drivers/vdpa/octeon_ep/octep_vdpa_main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/vdpa/octeon_ep/octep_vdpa_main.c +11 -2
@@ -48,7 +48,7 @@ static struct octep_hw *vdpa_to_octep_hw(struct vdpa_device *vdpa_dev)static irqreturn_t octep_vdpa_intr_handler (int irq,void *data) {struct octep_hw *oct_hw = data; -int i; +int i, start_ring_idx =-1 ;/* Each device has multiple interrupts (nb_irqs) shared among rings * (nr_vring). Device interrupts are mapped to the rings in a
@@ -61,7 +61,16 @@ static irqreturn_t octep_vdpa_intr_handler(int irq, void *data)* 7 -> 7, 15, 23, 31, 39, 47, 55, 63; */ -for (i = irq - oct_hw->irqs[0 ]; i < oct_hw->nr_vring; i += oct_hw->nb_irqs) { +for (i =0 ; i < oct_hw->nb_irqs; i++) { +if (oct_hw->irqs[i] == irq) { + start_ring_idx = i; +break ; + } + } +if (start_ring_idx ==-1 ) +return IRQ_NONE ; + +for (i = start_ring_idx; i < oct_hw->nr_vring; i += oct_hw->nb_irqs) {if (ioread8 (oct_hw->vqs[i].cb_notify_addr)) {/* Acknowledge the per ring notification to the device */ iowrite8 (0 , oct_hw->vqs[i].cb_notify_addr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 443/1611 ASoC: cs35l56: Fix missing calls to wm_adsp2_remove()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 85f7bf03632bfcdd6cedfb3945b7e387d9487d73 ]
Call wm_adsp2_remove() in cs35l56_remove() and the error path of cs35l56_common_probe().
Depends on commit 7d3fb78b5503 ("ASoC: wm_adsp: Fix NULL dereference when removing firmware controls").
The call to wm_halo_init() during driver probe should be paired with a call to wm_adsp2_remove() but this was missing. The consequence would be a memory leak of the control lists in the cs_dsp driver.
--- sound/soc/codecs/cs35l56.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/codecs/cs35l56.c +6 -1
@@ -1437,11 +1437,14 @@ int cs35l56_common_probe(struct cs35l56_private *cs35l56) cs35l56_dai, ARRAY_SIZE(cs35l56_dai));if (ret <0 ) {dev_err_probe (cs35l56->base.dev, ret,"Register codec failed\n" ); - goto err; + goto err_remove_wm_adsp; }return 0 ; +err_remove_wm_adsp: +wm_adsp2_remove (&cs35l56->dsp); + err:gpiod_set_value_cansleep (cs35l56->base.reset_gpio,0 );regulator_bulk_disable (ARRAY_SIZE (cs35l56->supplies), cs35l56->supplies);
@@ -1544,6 +1547,8 @@ void cs35l56_remove(struct cs35l56_private *cs35l56)destroy_workqueue (cs35l56->dsp_wq); +wm_adsp2_remove (&cs35l56->dsp); +pm_runtime_dont_use_autosuspend (cs35l56->base.dev);pm_runtime_suspend (cs35l56->base.dev);pm_runtime_disable (cs35l56->base.dev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 444/1611 ASoC: cs35l56: Dont leave parent IRQ disabled if system_suspend fails
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 53cebeb017164254cde5e31c94d8deef9e4fff97 ]
In cs35l56_system_suspend() re-enable the parent IRQ if the call to pm_runtime_force_suspend() returns an error.
--- sound/soc/codecs/cs35l56.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
sound/soc/codecs/cs35l56.c +6 -1
@@ -1057,6 +1057,7 @@ static int __maybe_unused cs35l56_runtime_resume_i2c_spi(struct device *dev)int cs35l56_system_suspend (struct device *dev) {struct cs35l56_private *cs35l56 =dev_get_drvdata (dev); +int ret;dev_dbg (dev,"system_suspend\n" );
@@ -1072,7 +1073,11 @@ int cs35l56_system_suspend(struct device *dev)if (cs35l56->base.irq)disable_irq (cs35l56->base.irq); -return pm_runtime_force_suspend (dev); + ret =pm_runtime_force_suspend (dev); +if ((ret <0 ) && cs35l56->base.irq) +enable_irq (cs35l56->base.irq); + +return ret; }EXPORT_SYMBOL_GPL (cs35l56_system_suspend);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 445/1611 ext4: fix ERR_PTR(0) in ext4_mkdir()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hongling Zeng <[email protected]>
[ Upstream commit 8e1c43af7cf5091d99db38b7c8129e394d7f45b5 ]
When mkdir succeeds, ext4_mkdir() returns ERR_PTR(0) which is incorrect. It should return NULL instead for success and ERR_PTR() only with negative error codes for failure.
--- fs/ext4/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/namei.c +1 -1
@@ -3049,7 +3049,7 @@ static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir, out_retry:if (err == -ENOSPC &&ext4_should_retry_alloc (dir->i_sb, &retries)) goto retry; -return ERR_PTR (err); +return err ?ERR_PTR (err) :NULL ; }/*
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 446/1611 tools: missed broadcast_neigh if_link uapi header
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 0134432215f0e0d4526544ac63dabe20e8a6951e ]
Add missing IFLA_BOND_BROADCAST_NEIGH in if_link uapi header.
Stable-dep-of: 32b0b8953343 ("bonding: 3ad: add lacp_strict configuration knob")
--- tools/include/uapi/linux/if_link.h | 1 + 1 file changed, 1 insertion(+)
tools/include/uapi/linux/if_link.h +1 -0
@@ -1526,6 +1526,7 @@ enum {IFLA_BOND_MISSED_MAX ,IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL , +IFLA_BOND_BROADCAST_NEIGH , __IFLA_BOND_MAX, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 447/1611 netlink: specs: rt-link: missed broadcast-neigh
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 363037983cc503eb0b5a5c0ab80bf1434cfd168a ]
Add missed broadcast-neigh.
Stable-dep-of: 32b0b8953343 ("bonding: 3ad: add lacp_strict configuration knob")
--- Documentation/netlink/specs/rt-link.yaml | 3 +++ 1 file changed, 3 insertions(+)
Documentation/netlink/specs/rt-link.yaml +3 -0
@@ -1336,6 +1336,9 @@ attribute-sets: - name: coupled-control type: u8 + - + name: broadcast-neigh + type: u8 - name: bond-ad-info-attrs name-prefix: ifla-bond-ad-info-
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 448/1611 bonding: 3ad: add lacp_strict configuration knob
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 32b0b8953343eaceaa816a9ead3b6bb66355c64e ]
When an 802.3ad (LACP) bonding interface has no slaves in the collecting/distributing state, the bonding master still reports carrier as up as long as at least 'min_links' slaves have carrier.
In this situation, only one slave is effectively used for TX/RX, while traffic received on other slaves is dropped. Upper-layer daemons therefore consider the interface operational, even though traffic may be blackholed if the lack of LACP negotiation means the partner is not ready to deal with traffic.
Introduce a configuration knob to control this behavior. It allows the bonding master to assert carrier only when at least 'min_links' slaves are in Collecting_Distributing state.
The default mode preserves the existing behavior. This patch only introduces the knob; its behavior is implemented in the subsequent commit.
--- Documentation/netlink/specs/rt-link.yaml | 3 +++ Documentation/networking/bonding.rst | 23 +++++++++++++++++++++ drivers/net/bonding/bond_main.c | 1 + drivers/net/bonding/bond_netlink.c | 16 +++++++++++++++ drivers/net/bonding/bond_options.c | 26 ++++++++++++++++++++++++ include/net/bond_options.h | 1 + include/net/bonding.h | 1 + include/uapi/linux/if_link.h | 1 + tools/include/uapi/linux/if_link.h | 1 + 9 files changed, 73 insertions(+)
Documentation/netlink/specs/rt-link.yaml +3 -0
@@ -1339,6 +1339,9 @@ attribute-sets: - name: broadcast-neigh type: u8 + - + name: lacp-strict + type: u8 - name: bond-ad-info-attrs name-prefix: ifla-bond-ad-info-
Documentation/networking/bonding.rst +23 -0
@@ -619,6 +619,29 @@ min_links aggregator cannot be active without at least one available link, setting this option to 0 or to 1 has the exact same effect. +lacp_strict + + Specifies the fallback behavior of a bonding when LACP negotiation + fails on all slave links, i.e. when no slave is in the + Collecting_Distributing state, while at least `min_links` link still + reports carrier up. + + This option is only applicable to 802.3ad mode (mode 4). + + Valid values are: + + off or 0 + One interface of the bond is selected to be active, in order to + facilitate communication with peer devices that do not implement + LACP. + + on or 1 + Interfaces are only permitted to be made active if they have an + active LACP partner and have successfully reached + Collecting_Distributing state. + + The default value is 0 (off). + mode Specifies one of the bonding policies. The default is
drivers/net/bonding/bond_main.c +1 -0
@@ -6422,6 +6422,7 @@ static int __init bond_check_params(struct bond_params *params) params->ad_user_port_key = ad_user_port_key; params->coupled_control =1 ; params->broadcast_neighbor =0 ; + params->lacp_strict =0 ;if (packets_per_slave >0 ) { params->reciprocal_packets_per_slave =reciprocal_value (packets_per_slave);
drivers/net/bonding/bond_netlink.c +16 -0
@@ -143,6 +143,7 @@ static const struct nla_policy bond_policy[IFLA_BOND_MAX + 1] = { [IFLA_BOND_NS_IP6_TARGET] = { .type = NLA_NESTED }, [IFLA_BOND_COUPLED_CONTROL] = { .type = NLA_U8 }, [IFLA_BOND_BROADCAST_NEIGH] = { .type = NLA_U8 }, + [IFLA_BOND_LACP_STRICT] = { .type = NLA_U8 }, };static const struct nla_policy bond_slave_policy[IFLA_BOND_SLAVE_MAX +1 ] = {
@@ -599,6 +600,16 @@ static int bond_changelink(struct net_device *bond_dev, struct nlattr *tb[],return err; } +if (data[IFLA_BOND_LACP_STRICT ]) { +int fallback_mode =nla_get_u8 (data[IFLA_BOND_LACP_STRICT ]); + +bond_opt_initval (&newval, fallback_mode); + err =__bond_opt_set (bond,BOND_OPT_LACP_STRICT , &newval, + data[IFLA_BOND_LACP_STRICT ], extack); +if (err) +return err; + } +return 0 ; }
@@ -671,6 +682,7 @@ static size_t bond_get_size(const struct net_device *bond_dev)nla_total_size (sizeof (struct in6_addr )) *BOND_MAX_NS_TARGETS +nla_total_size (sizeof (u8)) +/* IFLA_BOND_COUPLED_CONTROL */ nla_total_size (sizeof (u8)) +/* IFLA_BOND_BROADCAST_NEIGH */ +nla_total_size (sizeof (u8)) +/* IFLA_BOND_LACP_STRICT */ 0 ; }
@@ -838,6 +850,10 @@ static int bond_fill_info(struct sk_buff *skb, bond->params.broadcast_neighbor)) goto nla_put_failure; +if (nla_put_u8 (skb,IFLA_BOND_LACP_STRICT , + bond->params.lacp_strict)) + goto nla_put_failure; +if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info;
drivers/net/bonding/bond_options.c +26 -0
@@ -67,6 +67,8 @@ static int bond_option_lacp_active_set(struct bonding *bond, const struct bond_opt_value *newval);static int bond_option_lacp_rate_set (struct bonding *bond,const struct bond_opt_value *newval); +static int bond_option_lacp_strict_set (struct bonding *bond, +const struct bond_opt_value *newval);static int bond_option_ad_select_set (struct bonding *bond,const struct bond_opt_value *newval); static int bond_option_queue_id_set(struct bonding *bond,
@@ -161,6 +163,12 @@ static const struct bond_opt_value bond_lacp_rate_tbl[] = { { NULL, -1, 0}, }; +static const struct bond_opt_value bond_lacp_strict_tbl[] = { + {"off" ,0 ,BOND_VALFLAG_DEFAULT }, + {"on" ,1 ,0 }, + {NULL ,-1 ,0 } +}; +static const struct bond_opt_value bond_ad_select_tbl[] = { {"stable" ,BOND_AD_STABLE ,BOND_VALFLAG_DEFAULT }, { "bandwidth", BOND_AD_BANDWIDTH, 0},
@@ -362,6 +370,14 @@ static const struct bond_option bond_opts[BOND_OPT_LAST] = { .values = bond_lacp_rate_tbl, .set = bond_option_lacp_rate_set }, + [BOND_OPT_LACP_STRICT] = { + .id = BOND_OPT_LACP_STRICT, + .name = "lacp_strict", + .desc = "Define the LACP fallback mode when no slaves have negotiated", + .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_8023AD)), + .values = bond_lacp_strict_tbl, + .set = bond_option_lacp_strict_set + }, [BOND_OPT_MINLINKS] = { .id = BOND_OPT_MINLINKS, .name = "min_links",
@@ -1683,6 +1699,16 @@ static int bond_option_lacp_rate_set(struct bonding *bond,return 0 ; } +static int bond_option_lacp_strict_set (struct bonding *bond, +const struct bond_opt_value *newval) +{ +netdev_dbg (bond->dev,"Setting LACP fallback to %s (%llu)\n" , + newval->string, newval->value); + bond->params.lacp_strict = newval->value; + +return 0 ; +} +static int bond_option_ad_select_set (struct bonding *bond,const struct bond_opt_value *newval) {
include/net/bond_options.h +1 -0
@@ -79,6 +79,7 @@ enum {BOND_OPT_COUPLED_CONTROL ,BOND_OPT_BROADCAST_NEIGH ,BOND_OPT_ACTOR_PORT_PRIO , +BOND_OPT_LACP_STRICT , BOND_OPT_LAST };
include/net/bonding.h +1 -0
@@ -132,6 +132,7 @@ struct bond_params {int peer_notif_delay;int lacp_active;int lacp_fast; +int lacp_strict;unsigned int min_links;int ad_select;char primary[IFNAMSIZ ];
include/uapi/linux/if_link.h +1 -0
@@ -1538,6 +1538,7 @@ enum {IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL ,IFLA_BOND_BROADCAST_NEIGH , +IFLA_BOND_LACP_STRICT , __IFLA_BOND_MAX, };
tools/include/uapi/linux/if_link.h +1 -0
@@ -1527,6 +1527,7 @@ enum {IFLA_BOND_NS_IP6_TARGET ,IFLA_BOND_COUPLED_CONTROL ,IFLA_BOND_BROADCAST_NEIGH , +IFLA_BOND_LACP_STRICT , __IFLA_BOND_MAX, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 449/1611 bonding: 3ad: fix carrier when no usable slaves
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 0bd695db23c6262e9cb980017a6273925172ec5b ]
Apply the "lacp_strict" configuration from the previous commit.
"lacp_strict" mode "on" asserts that the bonding master carrier is up only when at least 'min_links' slaves are in the Collecting_Distributing state.
--- drivers/net/bonding/bond_3ad.c | 26 +++++++++++++++++++++++--- drivers/net/bonding/bond_options.c | 1 + 2 files changed, 24 insertions(+), 3 deletions(-)
drivers/net/bonding/bond_3ad.c +23 -3
@@ -733,6 +733,21 @@ static void __set_agg_ports_ready(struct aggregator *aggregator, int val) } } +static int __agg_usable_ports (struct aggregator *agg) +{ +struct port *port; +int valid =0 ; + +for (port = agg->lag_ports; port; + port = port->next_port_in_aggregator) { +if (port->actor_oper_port_state &LACP_STATE_COLLECTING && + port->actor_oper_port_state &LACP_STATE_DISTRIBUTING ) + valid++; + } + +return valid; +} +static int __agg_active_ports (struct aggregator *agg) {struct port *port;
@@ -1164,10 +1179,10 @@ static void ad_mux_machine(struct port *port, bool *update_slave_arr)switch (port->sm_mux_state) {case AD_MUX_DETACHED : port->actor_oper_port_state &= ~LACP_STATE_SYNCHRONIZATION ; -ad_disable_collecting_distributing (port, - update_slave_arr); port->actor_oper_port_state &= ~LACP_STATE_COLLECTING ; port->actor_oper_port_state &= ~LACP_STATE_DISTRIBUTING ; +ad_disable_collecting_distributing (port, + update_slave_arr); port->ntt = true;break ;case AD_MUX_WAITING :
@@ -2090,6 +2105,7 @@ static void ad_disable_distributing(struct port *port, bool *update_slave_arr) port->actor_port_number, aggregator->aggregator_identifier);__disable_distributing_port (port); +bond_3ad_set_carrier (port->slave->bond);/* Slave array needs an update */ *update_slave_arr = true; }
@@ -2113,6 +2129,7 @@ static void ad_enable_collecting_distributing(struct port *port, port->actor_port_number, aggregator->aggregator_identifier);__enable_port (port); +bond_3ad_set_carrier (port->slave->bond);/* Slave array needs update */ *update_slave_arr = true;/* Should notify peers if possible */
@@ -2136,6 +2153,7 @@ static void ad_disable_collecting_distributing(struct port *port, port->actor_port_number, aggregator->aggregator_identifier);__disable_port (port); +bond_3ad_set_carrier (port->slave->bond);/* Slave array needs an update */ *update_slave_arr = true; }
@@ -2815,7 +2833,9 @@ int bond_3ad_set_carrier(struct bonding *bond) active =__get_active_agg (&(SLAVE_AD_INFO (first_slave)->aggregator));if (active) {/* are enough slaves available to consider link up? */ -if (__agg_active_ports (active) < bond->params.min_links) { +if ((bond->params.lacp_strict ?__agg_usable_ports (active) + :__agg_active_ports (active)) < + bond->params.min_links) {if (netif_carrier_ok (bond->dev)) {netif_carrier_off (bond->dev); goto out;
drivers/net/bonding/bond_options.c +1 -0
@@ -1705,6 +1705,7 @@ static int bond_option_lacp_strict_set(struct bonding *bond,netdev_dbg (bond->dev,"Setting LACP fallback to %s (%llu)\n" , newval->string, newval->value); bond->params.lacp_strict = newval->value; +bond_3ad_set_carrier (bond);return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 450/1611 bonding: 3ad: fix mux port state on oper down
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Louis Scalbert <[email protected]>
[ Upstream commit 807afc7544b865d4d09068a415fd5b71bf5665cc ]
When the bonding interface has carrier down due to the absence of usable slaves and a slave transitions from down to up, the bonding interface briefly goes carrier up, then down again, and finally up once LACP negotiates collecting and distributing on the port.
When lacp_strict mode is on, the interface should not transition to carrier up until LACP negotiation is complete.
This happens because the actor and partner port states remain in Collecting_Distributing when the port goes down. When the port comes back up, it temporarily remains in this state until LACP renegotiation occurs.
Previously this was mostly cosmetic, but since the bonding carrier state may depend on the LACP negotiation state, it causes the interface to flap.
According to IEEE 802.3ad-2000 and IEEE 802.1ax-2014, Collecting and Distributing should be reset when a port goes down:
- In the Receive state machine, port_enabled == FALSE causes a transition to the PORT_DISABLED state, which is expected to clear Partner_Oper_Port_State.Synchronization.
- In the Mux state machine, Partner_Oper_Port_State.Synchronization == FALSE causes a transition to the ATTACHED state, which disables Collecting and Distributing.
However, Partner_Oper_Port_State.Synchronization is not cleared in the PORT_DISABLED state.
Clear Partner_Oper_Port_State.Synchronization in the Receive PORT_DISABLED state.
--- drivers/net/bonding/bond_3ad.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/bonding/bond_3ad.c +1 -0
@@ -1322,6 +1322,7 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) fallthrough;case AD_RX_PORT_DISABLED : port->sm_vars &= ~AD_PORT_MATCHED ; + port->partner_oper.port_state &= ~LACP_STATE_SYNCHRONIZATION ;break ;case AD_RX_LACP_DISABLED : port->sm_vars &= ~AD_PORT_SELECTED ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 451/1611 ext4: fix kernel BUG in ext4_write_inline_data_end
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Prakash Srivastava <[email protected]>
[ Upstream commit ad09aa45965d3fafaf9963bc78109b73c0f9ac8d ]
When the data=journal mount option is used, the ext4_journalled_write_end() function incorrectly calls ext4_write_inline_data_end() without checking if the EXT4_STATE_MAY_INLINE_DATA flag is still set on the inode.
If a previous attempt to convert the inline data to an extent failed (e.g. due to ENOSPC), the EXT4_STATE_MAY_INLINE_DATA flag is cleared, but the EXT4_INODE_INLINE_DATA flag remains set. In this scenario, the next call to ext4_write_begin() will not prepare the inline data xattr for writing, but ext4_journalled_write_end() will incorrectly attempt to write to it, triggering a BUG_ON(pos + len > EXT4_I(inode)->i_inline_size) in ext4_write_inline_data() since i_inline_size was not expanded.
Fix this by ensuring that ext4_journalled_write_end() only calls ext4_write_inline_data_end() if the EXT4_STATE_MAY_INLINE_DATA flag is set, mirroring the behavior of ext4_write_end() and ext4_da_write_end().
--- fs/ext4/inode.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ext4/inode.c +2 -1
@@ -1561,7 +1561,8 @@ static int ext4_journalled_write_end(const struct kiocb *iocb,BUG_ON (!ext4_handle_valid (handle)); -if (ext4_has_inline_data (inode)) +if (ext4_has_inline_data (inode) && +ext4_test_inode_state (inode,EXT4_STATE_MAY_INLINE_DATA ))return ext4_write_inline_data_end (inode, pos, len, copied, folio);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 452/1611 selftests/bpf: Fix bpf_iter/task_vma test
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yonghong Song <[email protected]>
[ Upstream commit 2e8ad1ff712d2a397e407c9fde60901f68d077dc ]
For selftest bpf_iter/task_vma, I got a failure like below on my qemu run:
test_task_vma_common:FAIL:compare_output unexpected compare_output:
actual
'561593546000-561593585000r--p0000000000:241256579534/root/devshare/bpf-next/tools/testing/selftests/bpf/test_progs'
!= expected
'561593546000-561593585000r--p0000000000:245551546830/root/devshare/bpf-next/tools/testing/selftests/bpf/test_progs'Further debugging found out file->f_inode->i_ino value may exceed 32bit, e.g., i_ino = 0x14c2eae35, but the format string is '%u'. This caused inode mismatch between bpf iter and proc result.
Fix the issue by using format string '%llu' to accommodate 64bit i_ino.
--- tools/testing/selftests/bpf/progs/bpf_iter_task_vmas.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/progs/bpf_iter_task_vmas.c +1 -1
@@ -52,7 +52,7 @@ SEC("iter/task_vma") int proc_maps(struct bpf_iter__task_vma *ctx)bpf_d_path (&file->f_path, d_path_buf,D_PATH_BUF_SIZE );BPF_SEQ_PRINTF (seq,"%08llx " , vma->vm_pgoff <<12 ); -BPF_SEQ_PRINTF (seq,"%02x:%02x %u" ,MAJOR (dev),MINOR (dev), +BPF_SEQ_PRINTF (seq,"%02x:%02x %llu" ,MAJOR (dev),MINOR (dev), file->f_inode->i_ino);BPF_SEQ_PRINTF (seq,"\t%s\n" , d_path_buf); }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 453/1611 cxl/test: Fix integer overflow in mock LSA bounds checks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 81eafcada109b653977c4dfbd2b6a72470025a01 ]
Pre-existing issue discovered by sashiko-bot.
mock_get_lsa() and mock_set_lsa() validate the requested LSA range with "offset + length > LSA_SIZE". Both offset and length are u32 and, in mock_get_lsa(), both are taken directly from the user-supplied payload. The addition is evaluated modulo 2^32, so a large offset combined with a small length wraps around and passes the check.
Rewrite the checks to first bound offset, then compare length against the remaining LSA size.
--- tools/testing/cxl/test/mem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/cxl/test/mem.c +2 -2
@@ -1054,7 +1054,7 @@ static int mock_get_lsa(struct cxl_mockmem_data *mdata,return -EINVAL ; offset =le32_to_cpu (get_lsa->offset); length =le32_to_cpu (get_lsa->length); -if (offset + length >LSA_SIZE ) +if (offset >LSA_SIZE || length >LSA_SIZE - offset)return -EINVAL ;if (length > cmd->size_out)return -EINVAL ;
@@ -1074,7 +1074,7 @@ static int mock_set_lsa(struct cxl_mockmem_data *mdata,return -EINVAL ; offset =le32_to_cpu (set_lsa->offset); length = cmd->size_in -sizeof (*set_lsa); -if (offset + length >LSA_SIZE ) +if (offset >LSA_SIZE || length >LSA_SIZE - offset)return -EINVAL ;memcpy (lsa + offset, &set_lsa->data[0 ], length);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 454/1611 cxl/test: Zero out LSA backing memory to avoid leaking to user
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 60f065dbaf46e65830da62a0041761f0c039e086 ]
Memory through vmalloc() is not zeroed out. When this memory is copied into output payload, it leaks memory content to user. Use vzalloc() instead to zero out the memory.
--- tools/testing/cxl/test/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/cxl/test/mem.c +1 -1
@@ -1701,7 +1701,7 @@ static int cxl_mock_mem_probe(struct platform_device *pdev)return -ENOMEM ;dev_set_drvdata (dev, mdata); - mdata->lsa =vmalloc (LSA_SIZE ); + mdata->lsa =vzalloc (LSA_SIZE );if (!mdata->lsa)return -ENOMEM ; mdata->fw =vmalloc (FW_SIZE );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 455/1611 of: cpu: add check in __of_find_n_match_cpu_property()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sergey Shtylyov <[email protected]>
[ Upstream commit 5901eda2ed99ba0d3661da6eb265970559323bb3 ]
In __of_find_n_match_cpu_property(), checking the variable ac for 0 won't prevent a possible overflow when multiplying it by sizeof(*cell). Besides, of_read_number() (called in the *for* loop) can't return correct result if that variable (which equals the #address-cells prop's value) exceeds 2, so additionally checking for that seems logical...
Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool.
--- drivers/of/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/of/cpu.c +1 -1
@@ -60,7 +60,7 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun, cell =of_get_property (cpun, prop_name, &prop_len);if (!cell && !ac &&arch_match_cpu_phys_id (cpu,0 ))return true; -if (!cell || !ac) +if (!cell || !ac || ac >2 )return false; prop_len /=sizeof (*cell) * ac;for (tid =0 ; tid < prop_len; tid++) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 456/1611 vfio/qat: fix f_pos race in qat_vf_resume_write()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Giovanni Cabiddu <[email protected]>
[ Upstream commit 4ec5e932e636896e97e4c6a8205b0ac76d52421a ]
qat_vf_resume_write() checks filp->f_pos before taking migf->lock, but copies into the migration-state buffer after taking the lock and re-reading the shared file position.
Two concurrent writers could therefore pass the bounds check with the old offset, then have the second writer copy after the first advanced f_pos, writing past the end of the migration-state buffer.
Take migf->lock before doing the boundary checks.
--- drivers/vfio/pci/qat/main.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)
drivers/vfio/pci/qat/main.c +10 -6
@@ -303,14 +303,18 @@ static ssize_t qat_vf_resume_write(struct file *filp, const char __user *buf,return -ESPIPE ; offs = &filp->f_pos; -if (*offs <0 || -check_add_overflow (len, *offs, &end)) -return -EOVERFLOW ; +mutex_lock (&migf->lock); -if (end > mig_dev->state_size) -return -ENOMEM ; +if (*offs <0 ||check_add_overflow (len, *offs, &end)) { + done = -EOVERFLOW ; + goto out_unlock; + } + +if (end > mig_dev->state_size) { + done = -ENOMEM ; + goto out_unlock; + } -mutex_lock (&migf->lock);if (migf->disabled) { done = -ENODEV ; goto out_unlock;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 457/1611 bpf: Tighten cgroup storage cookie checks for prog arrays
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
[ Upstream commit 10627ddc0167aab5c1c390a10ef461e9937aba08 ]
The fix in commit abad3d0bad72 ("bpf: Fix oob access in cgroup local storage") is still incomplete. The prog-array compatibility check treats a program with no cgroup storage as compatible with any stored storage cookie. This allows a storage-less program to bridge a tail call chain between an entry program and a storage-using callee even though cgroup local storage at runtime still follows the caller's context, that is, A -> B(no storage) -> C(storage) path.
Requiring exact cookie equality would break the legitimate case of a storage-less leaf program being tail called from a storage-using one. Instead, only accept a zero storage cookie if the program cannot perform tail calls itself. This keeps A -> B(no storage) working while rejecting the A -> B(no storage) -> C(storage) bridge.
--- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/bpf/core.c +1 -1
@@ -2468,7 +2468,7 @@ static bool __bpf_prog_map_compatible(struct bpf_map *map, cookie = aux->cgroup_storage[i] ? aux->cgroup_storage[i]->cookie :0 ; ret = map->owner->storage_cookie[i] == cookie || - !cookie; + (!cookie && !aux->tail_call_reachable); }if (ret && map->owner->attach_func_proto != aux->attach_func_proto) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 458/1611 pinctrl: sunxi: a523: Remove unneeded IRQ remuxing flag
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit eaf84ff673409fa3dfc390c6afb53b641ee5acba ]
The Allwinner A10 and H3 SoCs cannot read the state of a GPIO line when that line is muxed for IRQ triggering (muxval 6), but only if it's explicitly muxed for GPIO input (muxval 0). Other SoCs do not show this behaviour, so we added a optional workaround, triggered by a quirk bit, which triggers remuxing the pin when it's configured for IRQ, while we need to read its value.
For some reasons this quirk flag was copied over to newer SoCs, even though they don't show this behaviour, and the GPIO data register reflects the true GPIO state even with a pin muxed to IRQ trigger.
Remove the unneeded quirk from the A523 family, where it's definitely not needed (confirmed by experiments), and where it actually breaks, because the workaround is not compatible with the newer generation pinctrl IP used in that chip.
Together with a DT change this fixes GPIO IRQ operation on the A523 family of SoCs, as for instance used for the SD card detection.
--- drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c | 1 - drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c | 1 - 2 files changed, 2 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sun55i-a523-r.c +0 -1
@@ -26,7 +26,6 @@ static const u8 a523_r_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =static struct sunxi_pinctrl_desc a523_r_pinctrl_data = { .irq_banks =ARRAY_SIZE (a523_r_irq_bank_map), .irq_bank_map = a523_r_irq_bank_map, - .irq_read_needs_mux = true, .io_bias_cfg_variant =BIAS_VOLTAGE_PIO_POW_MODE_SEL , .pin_base =PL_BASE , };
drivers/pinctrl/sunxi/pinctrl-sun55i-a523.c +0 -1
@@ -26,7 +26,6 @@ static const u8 a523_irq_bank_muxes[SUNXI_PINCTRL_MAX_BANKS] =static struct sunxi_pinctrl_desc a523_pinctrl_data = { .irq_banks =ARRAY_SIZE (a523_irq_bank_map), .irq_bank_map = a523_irq_bank_map, - .irq_read_needs_mux = true, .io_bias_cfg_variant =BIAS_VOLTAGE_PIO_POW_MODE_SEL , };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 459/1611 pinctrl: airoha: generalize pins/group/function/confs handling
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Marangi <[email protected]>
[ Upstream commit 4043b0c45f8555a079bdac69a19ed08695a47a7b ]
In preparation for support of Airoha AN7583, generalize pins/group/function/confs handling and move them in match_data. Inner function will base the values on the pinctrl priv struct instead of relying on hardcoded struct.
This permits to use different PIN data while keeping the same logic.
Stable-dep-of: bdc95d7e8de3 ("pinctrl: airoha: an7581: add missed gpio32 pin group")
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 567 ++++++++++++---------- 1 file changed, 318 insertions(+), 249 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +318 -249
@@ -30,15 +30,15 @@#include "../pinconf.h" #include "../pinmux.h" -#define PINCTRL_PIN_GROUP (id) \ - PINCTRL_PINGROUP(#id, id##_pins, ARRAY_SIZE(id##_pins)) +#define PINCTRL_PIN_GROUP (id, table) \ + PINCTRL_PINGROUP(id, table##_pins, ARRAY_SIZE(table##_pins)) -#define PINCTRL_FUNC_DESC (id) \ +#define PINCTRL_FUNC_DESC (id, table) \ { \ - .desc = PINCTRL_PINFUNCTION(#id, id##_groups, \ - ARRAY_SIZE(id##_groups)), \ - .groups = id##_func_group, \ - .group_size = ARRAY_SIZE(id##_func_group), \ + .desc = PINCTRL_PINFUNCTION(#id, table##_groups, \ + ARRAY_SIZE(table##_groups)),\ + .groups = table##_func_group, \ + .group_size = ARRAY_SIZE(table##_func_group), \ }#define PINCTRL_CONF_DESC (p, offset, mask) \
@@ -357,16 +357,46 @@ struct airoha_pinctrl_gpiochip {u32 irq_type[AIROHA_NUM_PINS ]; }; +struct airoha_pinctrl_confs_info { +const struct airoha_pinctrl_conf *confs; +unsigned int num_confs; +}; + +enum airoha_pinctrl_confs_type { +AIROHA_PINCTRL_CONFS_PULLUP , +AIROHA_PINCTRL_CONFS_PULLDOWN , +AIROHA_PINCTRL_CONFS_DRIVE_E2 , +AIROHA_PINCTRL_CONFS_DRIVE_E4 , +AIROHA_PINCTRL_CONFS_PCIE_RST_OD , + +AIROHA_PINCTRL_CONFS_MAX , +}; +struct airoha_pinctrl {struct pinctrl_dev *ctrl; +struct pinctrl_desc desc; +const struct pingroup *grps; +const struct airoha_pinctrl_func *funcs; +const struct airoha_pinctrl_confs_info *confs_info; +struct regmap *chip_scu;struct regmap *regmap;struct airoha_pinctrl_gpiochip gpiochip; }; -static struct pinctrl_pin_desc airoha_pinctrl_pins[] = { +struct airoha_pinctrl_match_data { +const struct pinctrl_pin_desc *pins; +const unsigned int num_pins; +const struct pingroup *grps; +const unsigned int num_grps; +const struct airoha_pinctrl_func *funcs; +const unsigned int num_funcs; +const struct airoha_pinctrl_confs_info confs_info[AIROHA_PINCTRL_CONFS_MAX ]; +}; + +static struct pinctrl_pin_desc en7581_pinctrl_pins[] = {PINCTRL_PIN (0 ,"uart1_txd" ),PINCTRL_PIN (1 ,"uart1_rxd" ),PINCTRL_PIN (2 ,"i2c_scl" ),
@@ -427,172 +457,172 @@ static struct pinctrl_pin_desc airoha_pinctrl_pins[] = { PINCTRL_PIN(63, "pcie_reset2"), }; -static const int pon_pins[] = {49 ,50 ,51 ,52 ,53 ,54 }; -static const int pon_tod_1pps_pins[] = {46 }; -static const int gsw_tod_1pps_pins[] = {46 }; -static const int sipo_pins[] = {16 ,17 }; -static const int sipo_rclk_pins[] = {16 ,17 ,43 }; -static const int mdio_pins[] = {14 ,15 }; -static const int uart2_pins[] = {48 ,55 }; -static const int uart2_cts_rts_pins[] = {46 ,47 }; -static const int hsuart_pins[] = {28 ,29 }; -static const int hsuart_cts_rts_pins[] = {26 ,27 }; -static const int uart4_pins[] = {38 ,39 }; -static const int uart5_pins[] = {18 ,19 }; -static const int i2c0_pins[] = {2 ,3 }; -static const int i2c1_pins[] = {14 ,15 }; -static const int jtag_udi_pins[] = {16 ,17 ,18 ,19 ,20 }; -static const int jtag_dfd_pins[] = {16 ,17 ,18 ,19 ,20 }; -static const int i2s_pins[] = {26 ,27 ,28 ,29 }; -static const int pcm1_pins[] = {22 ,23 ,24 ,25 }; -static const int pcm2_pins[] = {18 ,19 ,20 ,21 }; -static const int spi_quad_pins[] = {32 ,33 }; -static const int spi_pins[] = {4 ,5 ,6 ,7 }; -static const int spi_cs1_pins[] = {34 }; -static const int pcm_spi_pins[] = {18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 }; -static const int pcm_spi_int_pins[] = {14 }; -static const int pcm_spi_rst_pins[] = {15 }; -static const int pcm_spi_cs1_pins[] = {43 }; -static const int pcm_spi_cs2_pins[] = {40 }; -static const int pcm_spi_cs2_p128_pins[] = {40 }; -static const int pcm_spi_cs2_p156_pins[] = {40 }; -static const int pcm_spi_cs3_pins[] = {41 }; -static const int pcm_spi_cs4_pins[] = {42 }; -static const int emmc_pins[] = {4 ,5 ,6 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 }; -static const int pnand_pins[] = {4 ,5 ,6 ,7 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 }; -static const int gpio0_pins[] = {13 }; -static const int gpio1_pins[] = {14 }; -static const int gpio2_pins[] = {15 }; -static const int gpio3_pins[] = {16 }; -static const int gpio4_pins[] = {17 }; -static const int gpio5_pins[] = {18 }; -static const int gpio6_pins[] = {19 }; -static const int gpio7_pins[] = {20 }; -static const int gpio8_pins[] = {21 }; -static const int gpio9_pins[] = {22 }; -static const int gpio10_pins[] = {23 }; -static const int gpio11_pins[] = {24 }; -static const int gpio12_pins[] = {25 }; -static const int gpio13_pins[] = {26 }; -static const int gpio14_pins[] = {27 }; -static const int gpio15_pins[] = {28 }; -static const int gpio16_pins[] = {29 }; -static const int gpio17_pins[] = {30 }; -static const int gpio18_pins[] = {31 }; -static const int gpio19_pins[] = {32 }; -static const int gpio20_pins[] = {33 }; -static const int gpio21_pins[] = {34 }; -static const int gpio22_pins[] = {35 }; -static const int gpio23_pins[] = {36 }; -static const int gpio24_pins[] = {37 }; -static const int gpio25_pins[] = {38 }; -static const int gpio26_pins[] = {39 }; -static const int gpio27_pins[] = {40 }; -static const int gpio28_pins[] = {41 }; -static const int gpio29_pins[] = {42 }; -static const int gpio30_pins[] = {43 }; -static const int gpio31_pins[] = {44 }; -static const int gpio33_pins[] = {46 }; -static const int gpio34_pins[] = {47 }; -static const int gpio35_pins[] = {48 }; -static const int gpio36_pins[] = {49 }; -static const int gpio37_pins[] = {50 }; -static const int gpio38_pins[] = {51 }; -static const int gpio39_pins[] = {52 }; -static const int gpio40_pins[] = {53 }; -static const int gpio41_pins[] = {54 }; -static const int gpio42_pins[] = {55 }; -static const int gpio43_pins[] = {56 }; -static const int gpio44_pins[] = {57 }; -static const int gpio45_pins[] = {58 }; -static const int gpio46_pins[] = {59 }; -static const int pcie_reset0_pins[] = {61 }; -static const int pcie_reset1_pins[] = {62 }; -static const int pcie_reset2_pins[] = {63 }; - -static const struct pingroup airoha_pinctrl_groups[] = { -PINCTRL_PIN_GROUP (pon), -PINCTRL_PIN_GROUP (pon_tod_1pps), -PINCTRL_PIN_GROUP (gsw_tod_1pps), -PINCTRL_PIN_GROUP (sipo), -PINCTRL_PIN_GROUP (sipo_rclk), -PINCTRL_PIN_GROUP (mdio), -PINCTRL_PIN_GROUP (uart2), -PINCTRL_PIN_GROUP (uart2_cts_rts), -PINCTRL_PIN_GROUP (hsuart), -PINCTRL_PIN_GROUP (hsuart_cts_rts), -PINCTRL_PIN_GROUP (uart4), -PINCTRL_PIN_GROUP (uart5), -PINCTRL_PIN_GROUP (i2c0), -PINCTRL_PIN_GROUP (i2c1), -PINCTRL_PIN_GROUP (jtag_udi), -PINCTRL_PIN_GROUP (jtag_dfd), -PINCTRL_PIN_GROUP (i2s), -PINCTRL_PIN_GROUP (pcm1), -PINCTRL_PIN_GROUP (pcm2), -PINCTRL_PIN_GROUP (spi), -PINCTRL_PIN_GROUP (spi_quad), -PINCTRL_PIN_GROUP (spi_cs1), -PINCTRL_PIN_GROUP (pcm_spi), -PINCTRL_PIN_GROUP (pcm_spi_int), -PINCTRL_PIN_GROUP (pcm_spi_rst), -PINCTRL_PIN_GROUP (pcm_spi_cs1), -PINCTRL_PIN_GROUP (pcm_spi_cs2_p128), -PINCTRL_PIN_GROUP (pcm_spi_cs2_p156), -PINCTRL_PIN_GROUP (pcm_spi_cs2), -PINCTRL_PIN_GROUP (pcm_spi_cs3), -PINCTRL_PIN_GROUP (pcm_spi_cs4), -PINCTRL_PIN_GROUP (emmc), -PINCTRL_PIN_GROUP (pnand), -PINCTRL_PIN_GROUP (gpio0), -PINCTRL_PIN_GROUP (gpio1), -PINCTRL_PIN_GROUP (gpio2), -PINCTRL_PIN_GROUP (gpio3), -PINCTRL_PIN_GROUP (gpio4), -PINCTRL_PIN_GROUP (gpio5), -PINCTRL_PIN_GROUP (gpio6), -PINCTRL_PIN_GROUP (gpio7), -PINCTRL_PIN_GROUP (gpio8), -PINCTRL_PIN_GROUP (gpio9), -PINCTRL_PIN_GROUP (gpio10), -PINCTRL_PIN_GROUP (gpio11), -PINCTRL_PIN_GROUP (gpio12), -PINCTRL_PIN_GROUP (gpio13), -PINCTRL_PIN_GROUP (gpio14), -PINCTRL_PIN_GROUP (gpio15), -PINCTRL_PIN_GROUP (gpio16), -PINCTRL_PIN_GROUP (gpio17), -PINCTRL_PIN_GROUP (gpio18), -PINCTRL_PIN_GROUP (gpio19), -PINCTRL_PIN_GROUP (gpio20), -PINCTRL_PIN_GROUP (gpio21), -PINCTRL_PIN_GROUP (gpio22), -PINCTRL_PIN_GROUP (gpio23), -PINCTRL_PIN_GROUP (gpio24), -PINCTRL_PIN_GROUP (gpio25), -PINCTRL_PIN_GROUP (gpio26), -PINCTRL_PIN_GROUP (gpio27), -PINCTRL_PIN_GROUP (gpio28), -PINCTRL_PIN_GROUP (gpio29), -PINCTRL_PIN_GROUP (gpio30), -PINCTRL_PIN_GROUP (gpio31), -PINCTRL_PIN_GROUP (gpio33), -PINCTRL_PIN_GROUP (gpio34), -PINCTRL_PIN_GROUP (gpio35), -PINCTRL_PIN_GROUP (gpio36), -PINCTRL_PIN_GROUP (gpio37), -PINCTRL_PIN_GROUP (gpio38), -PINCTRL_PIN_GROUP (gpio39), -PINCTRL_PIN_GROUP (gpio40), -PINCTRL_PIN_GROUP (gpio41), -PINCTRL_PIN_GROUP (gpio42), -PINCTRL_PIN_GROUP (gpio43), -PINCTRL_PIN_GROUP (gpio44), -PINCTRL_PIN_GROUP (gpio45), -PINCTRL_PIN_GROUP (gpio46), -PINCTRL_PIN_GROUP (pcie_reset0), -PINCTRL_PIN_GROUP (pcie_reset1), -PINCTRL_PIN_GROUP (pcie_reset2), +static const int en7581_pon_pins[] = {49 ,50 ,51 ,52 ,53 ,54 }; +static const int en7581_pon_tod_1pps_pins[] = {46 }; +static const int en7581_gsw_tod_1pps_pins[] = {46 }; +static const int en7581_sipo_pins[] = {16 ,17 }; +static const int en7581_sipo_rclk_pins[] = {16 ,17 ,43 }; +static const int en7581_mdio_pins[] = {14 ,15 }; +static const int en7581_uart2_pins[] = {48 ,55 }; +static const int en7581_uart2_cts_rts_pins[] = {46 ,47 }; +static const int en7581_hsuart_pins[] = {28 ,29 }; +static const int en7581_hsuart_cts_rts_pins[] = {26 ,27 }; +static const int en7581_uart4_pins[] = {38 ,39 }; +static const int en7581_uart5_pins[] = {18 ,19 }; +static const int en7581_i2c0_pins[] = {2 ,3 }; +static const int en7581_i2c1_pins[] = {14 ,15 }; +static const int en7581_jtag_udi_pins[] = {16 ,17 ,18 ,19 ,20 }; +static const int en7581_jtag_dfd_pins[] = {16 ,17 ,18 ,19 ,20 }; +static const int en7581_i2s_pins[] = {26 ,27 ,28 ,29 }; +static const int en7581_pcm1_pins[] = {22 ,23 ,24 ,25 }; +static const int en7581_pcm2_pins[] = {18 ,19 ,20 ,21 }; +static const int en7581_spi_quad_pins[] = {32 ,33 }; +static const int en7581_spi_pins[] = {4 ,5 ,6 ,7 }; +static const int en7581_spi_cs1_pins[] = {34 }; +static const int en7581_pcm_spi_pins[] = {18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 }; +static const int en7581_pcm_spi_int_pins[] = {14 }; +static const int en7581_pcm_spi_rst_pins[] = {15 }; +static const int en7581_pcm_spi_cs1_pins[] = {43 }; +static const int en7581_pcm_spi_cs2_pins[] = {40 }; +static const int en7581_pcm_spi_cs2_p128_pins[] = {40 }; +static const int en7581_pcm_spi_cs2_p156_pins[] = {40 }; +static const int en7581_pcm_spi_cs3_pins[] = {41 }; +static const int en7581_pcm_spi_cs4_pins[] = {42 }; +static const int en7581_emmc_pins[] = {4 ,5 ,6 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 }; +static const int en7581_pnand_pins[] = {4 ,5 ,6 ,7 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 }; +static const int en7581_gpio0_pins[] = {13 }; +static const int en7581_gpio1_pins[] = {14 }; +static const int en7581_gpio2_pins[] = {15 }; +static const int en7581_gpio3_pins[] = {16 }; +static const int en7581_gpio4_pins[] = {17 }; +static const int en7581_gpio5_pins[] = {18 }; +static const int en7581_gpio6_pins[] = {19 }; +static const int en7581_gpio7_pins[] = {20 }; +static const int en7581_gpio8_pins[] = {21 }; +static const int en7581_gpio9_pins[] = {22 }; +static const int en7581_gpio10_pins[] = {23 }; +static const int en7581_gpio11_pins[] = {24 }; +static const int en7581_gpio12_pins[] = {25 }; +static const int en7581_gpio13_pins[] = {26 }; +static const int en7581_gpio14_pins[] = {27 }; +static const int en7581_gpio15_pins[] = {28 }; +static const int en7581_gpio16_pins[] = {29 }; +static const int en7581_gpio17_pins[] = {30 }; +static const int en7581_gpio18_pins[] = {31 }; +static const int en7581_gpio19_pins[] = {32 }; +static const int en7581_gpio20_pins[] = {33 }; +static const int en7581_gpio21_pins[] = {34 }; +static const int en7581_gpio22_pins[] = {35 }; +static const int en7581_gpio23_pins[] = {36 }; +static const int en7581_gpio24_pins[] = {37 }; +static const int en7581_gpio25_pins[] = {38 }; +static const int en7581_gpio26_pins[] = {39 }; +static const int en7581_gpio27_pins[] = {40 }; +static const int en7581_gpio28_pins[] = {41 }; +static const int en7581_gpio29_pins[] = {42 }; +static const int en7581_gpio30_pins[] = {43 }; +static const int en7581_gpio31_pins[] = {44 }; +static const int en7581_gpio33_pins[] = {46 }; +static const int en7581_gpio34_pins[] = {47 }; +static const int en7581_gpio35_pins[] = {48 }; +static const int en7581_gpio36_pins[] = {49 }; +static const int en7581_gpio37_pins[] = {50 }; +static const int en7581_gpio38_pins[] = {51 }; +static const int en7581_gpio39_pins[] = {52 }; +static const int en7581_gpio40_pins[] = {53 }; +static const int en7581_gpio41_pins[] = {54 }; +static const int en7581_gpio42_pins[] = {55 }; +static const int en7581_gpio43_pins[] = {56 }; +static const int en7581_gpio44_pins[] = {57 }; +static const int en7581_gpio45_pins[] = {58 }; +static const int en7581_gpio46_pins[] = {59 }; +static const int en7581_pcie_reset0_pins[] = {61 }; +static const int en7581_pcie_reset1_pins[] = {62 }; +static const int en7581_pcie_reset2_pins[] = {63 }; + +static const struct pingroup en7581_pinctrl_groups[] = { +PINCTRL_PIN_GROUP ("pon" , en7581_pon), +PINCTRL_PIN_GROUP ("pon_tod_1pps" , en7581_pon_tod_1pps), +PINCTRL_PIN_GROUP ("gsw_tod_1pps" , en7581_gsw_tod_1pps), +PINCTRL_PIN_GROUP ("sipo" , en7581_sipo), +PINCTRL_PIN_GROUP ("sipo_rclk" , en7581_sipo_rclk), +PINCTRL_PIN_GROUP ("mdio" , en7581_mdio), +PINCTRL_PIN_GROUP ("uart2" , en7581_uart2), +PINCTRL_PIN_GROUP ("uart2_cts_rts" , en7581_uart2_cts_rts), +PINCTRL_PIN_GROUP ("hsuart" , en7581_hsuart), +PINCTRL_PIN_GROUP ("hsuart_cts_rts" , en7581_hsuart_cts_rts), +PINCTRL_PIN_GROUP ("uart4" , en7581_uart4), +PINCTRL_PIN_GROUP ("uart5" , en7581_uart5), +PINCTRL_PIN_GROUP ("i2c0" , en7581_i2c0), +PINCTRL_PIN_GROUP ("i2c1" , en7581_i2c1), +PINCTRL_PIN_GROUP ("jtag_udi" , en7581_jtag_udi), +PINCTRL_PIN_GROUP ("jtag_dfd" , en7581_jtag_dfd), +PINCTRL_PIN_GROUP ("i2s" , en7581_i2s), +PINCTRL_PIN_GROUP ("pcm1" , en7581_pcm1), +PINCTRL_PIN_GROUP ("pcm2" , en7581_pcm2), +PINCTRL_PIN_GROUP ("spi" , en7581_spi), +PINCTRL_PIN_GROUP ("spi_quad" , en7581_spi_quad), +PINCTRL_PIN_GROUP ("spi_cs1" , en7581_spi_cs1), +PINCTRL_PIN_GROUP ("pcm_spi" , en7581_pcm_spi), +PINCTRL_PIN_GROUP ("pcm_spi_int" , en7581_pcm_spi_int), +PINCTRL_PIN_GROUP ("pcm_spi_rst" , en7581_pcm_spi_rst), +PINCTRL_PIN_GROUP ("pcm_spi_cs1" , en7581_pcm_spi_cs1), +PINCTRL_PIN_GROUP ("pcm_spi_cs2_p128" , en7581_pcm_spi_cs2_p128), +PINCTRL_PIN_GROUP ("pcm_spi_cs2_p156" , en7581_pcm_spi_cs2_p156), +PINCTRL_PIN_GROUP ("pcm_spi_cs2" , en7581_pcm_spi_cs2), +PINCTRL_PIN_GROUP ("pcm_spi_cs3" , en7581_pcm_spi_cs3), +PINCTRL_PIN_GROUP ("pcm_spi_cs4" , en7581_pcm_spi_cs4), +PINCTRL_PIN_GROUP ("emmc" , en7581_emmc), +PINCTRL_PIN_GROUP ("pnand" , en7581_pnand), +PINCTRL_PIN_GROUP ("gpio0" , en7581_gpio0), +PINCTRL_PIN_GROUP ("gpio1" , en7581_gpio1), +PINCTRL_PIN_GROUP ("gpio2" , en7581_gpio2), +PINCTRL_PIN_GROUP ("gpio3" , en7581_gpio3), +PINCTRL_PIN_GROUP ("gpio4" , en7581_gpio4), +PINCTRL_PIN_GROUP ("gpio5" , en7581_gpio5), +PINCTRL_PIN_GROUP ("gpio6" , en7581_gpio6), +PINCTRL_PIN_GROUP ("gpio7" , en7581_gpio7), +PINCTRL_PIN_GROUP ("gpio8" , en7581_gpio8), +PINCTRL_PIN_GROUP ("gpio9" , en7581_gpio9), +PINCTRL_PIN_GROUP ("gpio10" , en7581_gpio10), +PINCTRL_PIN_GROUP ("gpio11" , en7581_gpio11), +PINCTRL_PIN_GROUP ("gpio12" , en7581_gpio12), +PINCTRL_PIN_GROUP ("gpio13" , en7581_gpio13), +PINCTRL_PIN_GROUP ("gpio14" , en7581_gpio14), +PINCTRL_PIN_GROUP ("gpio15" , en7581_gpio15), +PINCTRL_PIN_GROUP ("gpio16" , en7581_gpio16), +PINCTRL_PIN_GROUP ("gpio17" , en7581_gpio17), +PINCTRL_PIN_GROUP ("gpio18" , en7581_gpio18), +PINCTRL_PIN_GROUP ("gpio19" , en7581_gpio19), +PINCTRL_PIN_GROUP ("gpio20" , en7581_gpio20), +PINCTRL_PIN_GROUP ("gpio21" , en7581_gpio21), +PINCTRL_PIN_GROUP ("gpio22" , en7581_gpio22), +PINCTRL_PIN_GROUP ("gpio23" , en7581_gpio23), +PINCTRL_PIN_GROUP ("gpio24" , en7581_gpio24), +PINCTRL_PIN_GROUP ("gpio25" , en7581_gpio25), +PINCTRL_PIN_GROUP ("gpio26" , en7581_gpio26), +PINCTRL_PIN_GROUP ("gpio27" , en7581_gpio27), +PINCTRL_PIN_GROUP ("gpio28" , en7581_gpio28), +PINCTRL_PIN_GROUP ("gpio29" , en7581_gpio29), +PINCTRL_PIN_GROUP ("gpio30" , en7581_gpio30), +PINCTRL_PIN_GROUP ("gpio31" , en7581_gpio31), +PINCTRL_PIN_GROUP ("gpio33" , en7581_gpio33), +PINCTRL_PIN_GROUP ("gpio34" , en7581_gpio34), +PINCTRL_PIN_GROUP ("gpio35" , en7581_gpio35), +PINCTRL_PIN_GROUP ("gpio36" , en7581_gpio36), +PINCTRL_PIN_GROUP ("gpio37" , en7581_gpio37), +PINCTRL_PIN_GROUP ("gpio38" , en7581_gpio38), +PINCTRL_PIN_GROUP ("gpio39" , en7581_gpio39), +PINCTRL_PIN_GROUP ("gpio40" , en7581_gpio40), +PINCTRL_PIN_GROUP ("gpio41" , en7581_gpio41), +PINCTRL_PIN_GROUP ("gpio42" , en7581_gpio42), +PINCTRL_PIN_GROUP ("gpio43" , en7581_gpio43), +PINCTRL_PIN_GROUP ("gpio44" , en7581_gpio44), +PINCTRL_PIN_GROUP ("gpio45" , en7581_gpio45), +PINCTRL_PIN_GROUP ("gpio46" , en7581_gpio46), +PINCTRL_PIN_GROUP ("pcie_reset0" , en7581_pcie_reset0), +PINCTRL_PIN_GROUP ("pcie_reset1" , en7581_pcie_reset1), +PINCTRL_PIN_GROUP ("pcie_reset2" , en7581_pcie_reset2), };static const char *const pon_groups[] = {"pon" };
@@ -1955,33 +1985,33 @@ static const struct airoha_pinctrl_func_group phy4_led1_func_group[] = { }, }; -static const struct airoha_pinctrl_func airoha_pinctrl_funcs[] = { -PINCTRL_FUNC_DESC (pon), -PINCTRL_FUNC_DESC (tod_1pps), -PINCTRL_FUNC_DESC (sipo), -PINCTRL_FUNC_DESC (mdio), -PINCTRL_FUNC_DESC (uart), -PINCTRL_FUNC_DESC (i2c), -PINCTRL_FUNC_DESC (jtag), -PINCTRL_FUNC_DESC (pcm), -PINCTRL_FUNC_DESC (spi), -PINCTRL_FUNC_DESC (pcm_spi), -PINCTRL_FUNC_DESC (i2s), -PINCTRL_FUNC_DESC (emmc), -PINCTRL_FUNC_DESC (pnand), -PINCTRL_FUNC_DESC (pcie_reset), -PINCTRL_FUNC_DESC (pwm), -PINCTRL_FUNC_DESC (phy1_led0), -PINCTRL_FUNC_DESC (phy2_led0), -PINCTRL_FUNC_DESC (phy3_led0), -PINCTRL_FUNC_DESC (phy4_led0), -PINCTRL_FUNC_DESC (phy1_led1), -PINCTRL_FUNC_DESC (phy2_led1), -PINCTRL_FUNC_DESC (phy3_led1), -PINCTRL_FUNC_DESC (phy4_led1), +static const struct airoha_pinctrl_func en7581_pinctrl_funcs[] = { +PINCTRL_FUNC_DESC ("pon" , pon), +PINCTRL_FUNC_DESC ("tod_1pps" , tod_1pps), +PINCTRL_FUNC_DESC ("sipo" , sipo), +PINCTRL_FUNC_DESC ("mdio" , mdio), +PINCTRL_FUNC_DESC ("uart" , uart), +PINCTRL_FUNC_DESC ("i2c" , i2c), +PINCTRL_FUNC_DESC ("jtag" , jtag), +PINCTRL_FUNC_DESC ("pcm" , pcm), +PINCTRL_FUNC_DESC ("spi" , spi), +PINCTRL_FUNC_DESC ("pcm_spi" , pcm_spi), +PINCTRL_FUNC_DESC ("i2s" , i2s), +PINCTRL_FUNC_DESC ("emmc" , emmc), +PINCTRL_FUNC_DESC ("pnand" , pnand), +PINCTRL_FUNC_DESC ("pcie_reset" , pcie_reset), +PINCTRL_FUNC_DESC ("pwm" , pwm), +PINCTRL_FUNC_DESC ("phy1_led0" , phy1_led0), +PINCTRL_FUNC_DESC ("phy2_led0" , phy2_led0), +PINCTRL_FUNC_DESC ("phy3_led0" , phy3_led0), +PINCTRL_FUNC_DESC ("phy4_led0" , phy4_led0), +PINCTRL_FUNC_DESC ("phy1_led1" , phy1_led1), +PINCTRL_FUNC_DESC ("phy2_led1" , phy2_led1), +PINCTRL_FUNC_DESC ("phy3_led1" , phy3_led1), +PINCTRL_FUNC_DESC ("phy4_led1" , phy4_led1), }; -static const struct airoha_pinctrl_conf airoha_pinctrl_pullup_conf[] = { +static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PU ,UART1_TXD_PU_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PU ,UART1_RXD_PU_MASK ),PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PU ,I2C_SDA_PU_MASK ),
@@ -2042,7 +2072,7 @@ static const struct airoha_pinctrl_conf airoha_pinctrl_pullup_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_PU, PCIE2_RESET_PU_MASK), }; -static const struct airoha_pinctrl_conf airoha_pinctrl_pulldown_conf[] = { +static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_PD ,UART1_TXD_PD_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_PD ,UART1_RXD_PD_MASK ),PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_PD ,I2C_SDA_PD_MASK ),
@@ -2103,7 +2133,7 @@ static const struct airoha_pinctrl_conf airoha_pinctrl_pulldown_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_PD, PCIE2_RESET_PD_MASK), }; -static const struct airoha_pinctrl_conf airoha_pinctrl_drive_e2_conf[] = { +static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E2 ,UART1_TXD_E2_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E2 ,UART1_RXD_E2_MASK ),PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E2 ,I2C_SDA_E2_MASK ),
@@ -2164,7 +2194,7 @@ static const struct airoha_pinctrl_conf airoha_pinctrl_drive_e2_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_E2, PCIE2_RESET_E2_MASK), }; -static const struct airoha_pinctrl_conf airoha_pinctrl_drive_e4_conf[] = { +static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (0 ,REG_I2C_SDA_E4 ,UART1_TXD_E4_MASK ),PINCTRL_CONF_DESC (1 ,REG_I2C_SDA_E4 ,UART1_RXD_E4_MASK ),PINCTRL_CONF_DESC (2 ,REG_I2C_SDA_E4 ,I2C_SDA_E4_MASK ),
@@ -2225,7 +2255,7 @@ static const struct airoha_pinctrl_conf airoha_pinctrl_drive_e4_conf[] = { PINCTRL_CONF_DESC(63, REG_I2C_SDA_E4, PCIE2_RESET_E4_MASK), }; -static const struct airoha_pinctrl_conf airoha_pinctrl_pcie_rst_od_conf[] = { +static const struct airoha_pinctrl_conf en7581_pinctrl_pcie_rst_od_conf[] = {PINCTRL_CONF_DESC (61 ,REG_PCIE_RESET_OD ,PCIE0_RESET_OD_MASK ),PINCTRL_CONF_DESC (62 ,REG_PCIE_RESET_OD ,PCIE1_RESET_OD_MASK ),PINCTRL_CONF_DESC (63 ,REG_PCIE_RESET_OD ,PCIE2_RESET_OD_MASK ),
@@ -2546,12 +2576,17 @@ airoha_pinctrl_get_conf_reg(const struct airoha_pinctrl_conf *conf, }static int airoha_pinctrl_get_conf (struct airoha_pinctrl *pinctrl, -const struct airoha_pinctrl_conf *conf, -int conf_size,int pin,u32 *val) +enum airoha_pinctrl_confs_type conf_type, +int pin,u32 *val) { +const struct airoha_pinctrl_confs_info *confs_info;const struct airoha_pinctrl_reg *reg; - reg =airoha_pinctrl_get_conf_reg (conf, conf_size, pin); + confs_info = &pinctrl->confs_info[conf_type]; + + reg =airoha_pinctrl_get_conf_reg (confs_info->confs, + confs_info->num_confs, + pin);if (!reg)return -EINVAL ;
@@ -2564,12 +2599,17 @@ static int airoha_pinctrl_get_conf(struct airoha_pinctrl *pinctrl, }static int airoha_pinctrl_set_conf (struct airoha_pinctrl *pinctrl, -const struct airoha_pinctrl_conf *conf, -int conf_size,int pin,u32 val) +enum airoha_pinctrl_confs_type conf_type, +int pin,u32 val) { +const struct airoha_pinctrl_confs_info *confs_info;const struct airoha_pinctrl_reg *reg =NULL ; - reg =airoha_pinctrl_get_conf_reg (conf, conf_size, pin); + confs_info = &pinctrl->confs_info[conf_type]; + + reg =airoha_pinctrl_get_conf_reg (confs_info->confs, + confs_info->num_confs, + pin);if (!reg)return -EINVAL ;
@@ -2582,44 +2622,34 @@ static int airoha_pinctrl_set_conf(struct airoha_pinctrl *pinctrl, }#define airoha_pinctrl_get_pullup_conf (pinctrl, pin, val) \ - airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_pullup_conf, \ - ARRAY_SIZE(airoha_pinctrl_pullup_conf), \ + airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLUP, \ (pin), (val))#define airoha_pinctrl_get_pulldown_conf (pinctrl, pin, val) \ - airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_pulldown_conf, \ - ARRAY_SIZE(airoha_pinctrl_pulldown_conf), \ + airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLDOWN, \ (pin), (val))#define airoha_pinctrl_get_drive_e2_conf (pinctrl, pin, val) \ - airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_drive_e2_conf, \ - ARRAY_SIZE(airoha_pinctrl_drive_e2_conf), \ + airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E2, \ (pin), (val))#define airoha_pinctrl_get_drive_e4_conf (pinctrl, pin, val) \ - airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_drive_e4_conf, \ - ARRAY_SIZE(airoha_pinctrl_drive_e4_conf), \ + airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E4, \ (pin), (val))#define airoha_pinctrl_get_pcie_rst_od_conf (pinctrl, pin, val) \ - airoha_pinctrl_get_conf((pinctrl), airoha_pinctrl_pcie_rst_od_conf, \ - ARRAY_SIZE(airoha_pinctrl_pcie_rst_od_conf), \ + airoha_pinctrl_get_conf((pinctrl), AIROHA_PINCTRL_CONFS_PCIE_RST_OD, \ (pin), (val))#define airoha_pinctrl_set_pullup_conf (pinctrl, pin, val) \ - airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_pullup_conf, \ - ARRAY_SIZE(airoha_pinctrl_pullup_conf), \ + airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLUP, \ (pin), (val))#define airoha_pinctrl_set_pulldown_conf (pinctrl, pin, val) \ - airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_pulldown_conf, \ - ARRAY_SIZE(airoha_pinctrl_pulldown_conf), \ + airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_PULLDOWN, \ (pin), (val))#define airoha_pinctrl_set_drive_e2_conf (pinctrl, pin, val) \ - airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_drive_e2_conf, \ - ARRAY_SIZE(airoha_pinctrl_drive_e2_conf), \ + airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E2, \ (pin), (val))#define airoha_pinctrl_set_drive_e4_conf (pinctrl, pin, val) \ - airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_drive_e4_conf, \ - ARRAY_SIZE(airoha_pinctrl_drive_e4_conf), \ + airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_DRIVE_E4, \ (pin), (val))#define airoha_pinctrl_set_pcie_rst_od_conf (pinctrl, pin, val) \ - airoha_pinctrl_set_conf((pinctrl), airoha_pinctrl_pcie_rst_od_conf, \ - ARRAY_SIZE(airoha_pinctrl_pcie_rst_od_conf), \ + airoha_pinctrl_set_conf((pinctrl), AIROHA_PINCTRL_CONFS_PCIE_RST_OD, \ (pin), (val))static int airoha_pinconf_get_direction (struct pinctrl_dev *pctrl_dev,u32 p)
@@ -2796,12 +2826,13 @@ static int airoha_pinconf_set(struct pinctrl_dev *pctrl_dev,static int airoha_pinconf_group_get (struct pinctrl_dev *pctrl_dev,unsigned int group,unsigned long *config) { +struct airoha_pinctrl *pinctrl =pinctrl_dev_get_drvdata (pctrl_dev);u32 cur_config =0 ;int i; -for (i =0 ; i < airoha_pinctrl_groups[group].npins; i++) { +for (i =0 ; i < pinctrl->grps[group].npins; i++) {if (airoha_pinconf_get (pctrl_dev, - airoha_pinctrl_groups[group].pins[i], + pinctrl->grps[group].pins[i], config))return -ENOTSUPP ;
@@ -2818,13 +2849,14 @@ static int airoha_pinconf_group_set(struct pinctrl_dev *pctrl_dev, unsigned int group, unsigned long *configs, unsigned int num_configs) { + struct airoha_pinctrl *pinctrl = pinctrl_dev_get_drvdata(pctrl_dev);int i; -for (i =0 ; i < airoha_pinctrl_groups[group].npins; i++) { +for (i =0 ; i < pinctrl->grps[group].npins; i++) {int err; err =airoha_pinconf_set (pctrl_dev, - airoha_pinctrl_groups[group].pins[i], + pinctrl->grps[group].pins[i], configs, num_configs);if (err)return err;
@@ -2850,23 +2882,16 @@ static const struct pinctrl_ops airoha_pctlops = { .dt_free_map = pinconf_generic_dt_free_map, }; -static const struct pinctrl_desc airoha_pinctrl_desc = { - .name =KBUILD_MODNAME , - .owner =THIS_MODULE , - .pctlops = &airoha_pctlops, - .pmxops = &airoha_pmxops, - .confops = &airoha_confops, - .pins = airoha_pinctrl_pins, - .npins =ARRAY_SIZE (airoha_pinctrl_pins), -}; -static int airoha_pinctrl_probe (struct platform_device *pdev) { +const struct airoha_pinctrl_match_data *data;struct device *dev = &pdev->dev;struct airoha_pinctrl *pinctrl;struct regmap *map;int err, i; + data =device_get_match_data (dev); + pinctrl =devm_kzalloc (dev,sizeof (*pinctrl),GFP_KERNEL );if (!pinctrl)return -ENOMEM ;
@@ -2881,14 +2906,23 @@ static int airoha_pinctrl_probe(struct platform_device *pdev) pinctrl->chip_scu = map; - err =devm_pinctrl_register_and_init (dev, &airoha_pinctrl_desc, +/* Init pinctrl desc struct */ + pinctrl->desc.name =KBUILD_MODNAME ; + pinctrl->desc.owner =THIS_MODULE , + pinctrl->desc.pctlops = &airoha_pctlops, + pinctrl->desc.pmxops = &airoha_pmxops, + pinctrl->desc.confops = &airoha_confops, + pinctrl->desc.pins = data->pins, + pinctrl->desc.npins = data->num_pins, + + err =devm_pinctrl_register_and_init (dev, &pinctrl->desc, pinctrl, &pinctrl->ctrl);if (err)return err;/* build pin groups */ -for (i =0 ; i <ARRAY_SIZE (airoha_pinctrl_groups); i++) { -const struct pingroup *grp = &airoha_pinctrl_groups[i]; +for (i =0 ; i < data->num_grps; i++) { +const struct pingroup *grp = &data->grps[i]; err = pinctrl_generic_add_group(pinctrl->ctrl, grp->name, grp->pins, grp->npins,
@@ -2901,10 +2935,10 @@ static int airoha_pinctrl_probe(struct platform_device *pdev) }/* build functions */ -for (i =0 ; i <ARRAY_SIZE (airoha_pinctrl_funcs); i++) { +for (i =0 ; i < data->num_funcs; i++) {const struct airoha_pinctrl_func *func; - func = &airoha_pinctrl_funcs[i]; + func = &data->funcs[i]; err =pinmux_generic_add_pinfunction (pinctrl->ctrl, &func->desc, (void *)func);
@@ -2915,6 +2949,10 @@ static int airoha_pinctrl_probe(struct platform_device *pdev) } } + pinctrl->grps = data->grps; + pinctrl->funcs = data->funcs; + pinctrl->confs_info = data->confs_info; + err =pinctrl_enable (pinctrl->ctrl);if (err)return err;
@@ -2923,8 +2961,39 @@ static int airoha_pinctrl_probe(struct platform_device *pdev)return airoha_pinctrl_add_gpiochip (pinctrl, pdev); } +static const struct airoha_pinctrl_match_data en7581_pinctrl_match_data = { + .pins = en7581_pinctrl_pins, + .num_pins =ARRAY_SIZE (en7581_pinctrl_pins), + .grps = en7581_pinctrl_groups, + .num_grps =ARRAY_SIZE (en7581_pinctrl_groups), + .funcs = en7581_pinctrl_funcs, + .num_funcs =ARRAY_SIZE (en7581_pinctrl_funcs), + .confs_info = { + [AIROHA_PINCTRL_CONFS_PULLUP ] = { + .confs = en7581_pinctrl_pullup_conf, + .num_confs =ARRAY_SIZE (en7581_pinctrl_pullup_conf), + }, + [AIROHA_PINCTRL_CONFS_PULLDOWN ] = { + .confs = en7581_pinctrl_pulldown_conf, + .num_confs =ARRAY_SIZE (en7581_pinctrl_pulldown_conf), + }, + [AIROHA_PINCTRL_CONFS_DRIVE_E2 ] = { + .confs = en7581_pinctrl_drive_e2_conf, + .num_confs =ARRAY_SIZE (en7581_pinctrl_drive_e2_conf), + }, + [AIROHA_PINCTRL_CONFS_DRIVE_E4 ] = { + .confs = en7581_pinctrl_drive_e4_conf, + .num_confs =ARRAY_SIZE (en7581_pinctrl_drive_e4_conf), + }, + [AIROHA_PINCTRL_CONFS_PCIE_RST_OD ] = { + .confs = en7581_pinctrl_pcie_rst_od_conf, + .num_confs =ARRAY_SIZE (en7581_pinctrl_pcie_rst_od_conf), + }, + }, +}; +static const struct of_device_id airoha_pinctrl_of_match[] = { - { .compatible ="airoha,en7581-pinctrl" }, + { .compatible ="airoha,en7581-pinctrl" , .data = &en7581_pinctrl_match_data }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, airoha_pinctrl_of_match);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 460/1611 pinctrl: airoha: an7581: add missed gpio32 pin group
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit bdc95d7e8de3eefa9fc062302625259c0b79136d ]
gpio32 pin group is missed for an7581 SoC. This patch add it.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/pinctrl/mediatek/pinctrl-airoha.c +2 -0
@@ -522,6 +522,7 @@ static const int en7581_gpio28_pins[] = { 41 };static const int en7581_gpio29_pins[] = {42 };static const int en7581_gpio30_pins[] = {43 };static const int en7581_gpio31_pins[] = {44 }; +static const int en7581_gpio32_pins[] = {45 };static const int en7581_gpio33_pins[] = {46 };static const int en7581_gpio34_pins[] = {47 };static const int en7581_gpio35_pins[] = {48 };
@@ -606,6 +607,7 @@ static const struct pingroup en7581_pinctrl_groups[] = {PINCTRL_PIN_GROUP ("gpio29" , en7581_gpio29),PINCTRL_PIN_GROUP ("gpio30" , en7581_gpio30),PINCTRL_PIN_GROUP ("gpio31" , en7581_gpio31), +PINCTRL_PIN_GROUP ("gpio32" , en7581_gpio32),PINCTRL_PIN_GROUP ("gpio33" , en7581_gpio33),PINCTRL_PIN_GROUP ("gpio34" , en7581_gpio34), PINCTRL_PIN_GROUP("gpio35", en7581_gpio35),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 461/1611 pinctrl: airoha: an7581: fix misprint in gpio19 pinconf
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikhail Kshevetskiy <[email protected]>
[ Upstream commit 08a39a0617ff32a7c3962bbc38a9eee41b14659a ]
Pin 32 (gpio19) duplicate pinconf settings of pin 31. Fix it using a proper bit number in the configuration register.
--- drivers/pinctrl/mediatek/pinctrl-airoha.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/pinctrl/mediatek/pinctrl-airoha.c +4 -4
@@ -2041,7 +2041,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pullup_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_PU ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_PU ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_PU ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PU ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PU ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_PU ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_PU ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_PU, BIT(22)),
@@ -2102,7 +2102,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_pulldown_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_PD ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_PD ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_PD ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PD ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_PD ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_PD ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_PD ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_PD, BIT(22)),
@@ -2163,7 +2163,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e2_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_E2 ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_E2 ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_E2 ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E2 ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E2 ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_E2 ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_E2 ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_E2, BIT(22)),
@@ -2224,7 +2224,7 @@ static const struct airoha_pinctrl_conf en7581_pinctrl_drive_e4_conf[] = {PINCTRL_CONF_DESC (29 ,REG_GPIO_L_E4 ,BIT (16 )),PINCTRL_CONF_DESC (30 ,REG_GPIO_L_E4 ,BIT (17 )),PINCTRL_CONF_DESC (31 ,REG_GPIO_L_E4 ,BIT (18 )), -PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E4 ,BIT (18 )), +PINCTRL_CONF_DESC (32 ,REG_GPIO_L_E4 ,BIT (19 )),PINCTRL_CONF_DESC (33 ,REG_GPIO_L_E4 ,BIT (20 )),PINCTRL_CONF_DESC (34 ,REG_GPIO_L_E4 ,BIT (21 )), PINCTRL_CONF_DESC(35, REG_GPIO_L_E4, BIT(22)),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 462/1611 arm64: dts: allwinner: a523: Add missing GPIO interrupt
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andre Przywara <[email protected]>
[ Upstream commit 6b81aa0c8a4f038712fa549e4d44d8279eeb0440 ]
Even though the Allwinner A523 SoC implements 10 GPIO banks, it has actually registers for 11 IRQ banks, and even an interrupt assigned to the first, non-implemented IRQ bank.
Add that first interrupt to the list of GPIO interrupts, to correct the association between IRQs and GPIO banks.
This fixes GPIO IRQ operation on boards with A523 SoCs, as seen by broken SD card detect functionality, for instance.
--- arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/allwinner/sun55i-a523.dtsi +2 -1
@@ -128,7 +128,8 @@ gpu: gpu@1800000 { pio: pinctrl@2000000 { compatible = "allwinner,sun55i-a523-pinctrl"; reg = <0x2000000 0x800>; - interrupts = <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>, + interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>, <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 463/1611 ASoC: cs35l56: Fix possible uninitialized value in cs35l56_spi_system_reset()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Fitzgerald <[email protected]>
[ Upstream commit 007699d278a655871b07d45a1268761260d03124 ]
In cs35l56_spi_system_reset() initialize val to zero before using it in the read_poll_timeout(). This prevents testing an uninitialized value if the regmap_read_bypassed() returns an error.
Read errors are intentionally ignored during this loop because the device is resetting (though SPI can't really detect that so shouldn't fail because of that, it's safer to ignore errors and keep polling). Because of this, val must be initialized to something in case the first read fails. The polling loop is looking for a non-zero value, so initializing val to 0 will ensure that the loop continues until a valid state is read from the device or it times out.
--- sound/soc/codecs/cs35l56-shared.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/cs35l56-shared.c +1 -0
@@ -515,6 +515,7 @@ static void cs35l56_spi_system_reset(struct cs35l56_base *cs35l56_base)* The regmap must remain in cache-only until the chip has * booted, so use a bypassed read. */ + val =0 ; ret = read_poll_timeout(regmap_read_bypassed, read_ret, (val > 0) && (val < 0xffffffff), CS35L56_HALO_STATE_POLL_US,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 464/1611 s390/process: Fix kernel thread function pointer type
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Heiko Carstens <[email protected]>
[ Upstream commit d0478f5d3cba1095bfdeb43a9b063c10cdebef14 ]
In case of a kernel thread __ret_from_fork() calls the specified function indirectly. Fix the kernel thread function pointer, since kernel threads return an int instead of void.
--- arch/s390/kernel/process.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/kernel/process.c +1 -1
@@ -51,7 +51,7 @@ void ret_from_fork(void) asm("ret_from_fork");void __ret_from_fork (struct task_struct *prev,struct pt_regs *regs) { -void (*func)(void *arg); +int (*func)(void *arg);schedule_tail (prev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 465/1611 Bluetooth: hci_qca: fix NULL pointer dereference in qca_dmp_hdr() for non-serdev device
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zijun Hu <[email protected]>
[ Upstream commit 6b8cbcf08de0db62254d1981f83db0f94681ccd9 ]
hu->serdev is NULL for hci_uart attached via non-serdev paths, but qca_dmp_hdr() unconditionally dereferences hu->serdev->dev.driver->name, causing a NULL pointer dereference.
Fix by guarding the dereference with a NULL check and falling back to "hci_ldisc_qca" for the non-serdev case.
--- drivers/bluetooth/hci_qca.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/bluetooth/hci_qca.c +1 -1
@@ -1023,7 +1023,7 @@ static void qca_dmp_hdr(struct hci_dev *hdev, struct sk_buff *skb)skb_put_data (skb, buf,strlen (buf));snprintf (buf,sizeof (buf),"Driver: %s\n" , - hu->serdev->dev.driver->name); + hu->serdev ? hu->serdev->dev.driver->name :"hci_ldisc_qca" );skb_put_data (skb, buf,strlen (buf)); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 466/1611 Bluetooth: eir: Fix stack OOB write when prepending the Flags AD
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 6f5fb689fdf80bdd143f22a502f9eb1f3c85e286 ]
eir_create_adv_data() builds the advertising data into a fixed-size buffer ("size", 31 for the legacy path). It may prepend a 3-byte "Flags" AD structure (LE_AD_NO_BREDR on an LE-only controller) and then copies the per-instance data without checking that it still fits:
memcpy(ptr, adv->adv_data, adv->adv_data_len);
tlv_data_max_len() only reserves those 3 bytes when the user-supplied flags carry a managed-flags bit, so an instance added with flags == 0 is accepted with adv_data_len up to the full buffer. At advertise time the flags are still prepended, and the memcpy() writes 3 + adv_data_len bytes into the size-byte buffer:
BUG: KASAN: stack-out-of-bounds in eir_create_adv_data (net/bluetooth/eir.c:301) Write of size 31 at addr ffff88800a547bdc by task kworker/u9:0/65 Workqueue: hci0 hci_cmd_sync_work __asan_memcpy (mm/kasan/shadow.c:106) eir_create_adv_data (net/bluetooth/eir.c:301) hci_update_adv_data_sync (net/bluetooth/hci_sync.c:1310) hci_schedule_adv_instance_sync (net/bluetooth/hci_sync.c:1817) hci_cmd_sync_work (net/bluetooth/hci_sync.c:332) This frame has 1 object: [32, 64) 'cp'
The "Flags" structure is added by the kernel, not requested by userspace, so only prepend it when it fits together with the instance advertising data; when there is no room for both, drop the flags rather than the user-provided data.
Reachable by a local user with CAP_NET_ADMIN owning an LE-only controller on the legacy advertising path.
--- net/bluetooth/eir.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
net/bluetooth/eir.c +5 -3
@@ -283,10 +283,12 @@ u8 eir_create_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr, u8 size)if (!flags) flags |=mgmt_get_adv_discov_flags (hdev); -/* If flags would still be empty, then there is no need to -* include the "Flags" AD field". +/* Only add the "Flags" if it fits together with the instance +* advertising data; drop it rather than overflow the buffer. */ -if (flags && (ad_len +eir_precalc_len (1 ) <= size)) { +if (flags && + (ad_len +eir_precalc_len (1 ) + + (adv ? adv->adv_data_len :0 ) <= size)) { ptr[0 ] =0x02 ; ptr[1 ] =EIR_FLAGS ; ptr[2 ] = flags;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 467/1611 Bluetooth: hci_event: fix simultaneous discovery stuck in FINDING
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiajia Liu <[email protected]>
[ Upstream commit 96d006ae6445679436b945593950fd465eba7e76 ]
When hci_inquiry_complete_evt is called between le_scan_disable and le_set_scan_enable_complete and no remote name needs to be resolved, the interleaved discovery with SIMULTANEOUS quirk gets stuck in DISCOVERY_FINDING. le_set_scan_enable_complete does not check inquiry state. No one sets DISCOVERY_STOPPED in this process.
Add state check in le_set_scan_enable_complete and change state if the state is DISCOVERY_FINDING. Tested with AX201 (8087:0026) in Dell Vostro 13. Discovering disabled MGMT Event below is reported when running into the above condition.
@ MGMT Command: Start Discovery (0x0023) {0x0001} [hci0] 10885.970873
Address type: 0x07
BR/EDR
LE Public
LE Random
...
< HCI Command: LE Set Extended Scan Enable #38205 [hci0] 10886.131438
Extended scan: Enabled (0x01)
Filter duplicates: Enabled (0x01)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #38206 [hci0] 10886.133295
LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
Status: Success (0x00)
@ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 10886.133414
Address type: 0x07
BR/EDR
LE Public
LE Random
Discovery: Enabled (0x01)
< HCI Command: Inquiry (0x01|0x0001) plen 5 #38207 [hci0] 10886.133528
Access code: 0x9e8b33 (General Inquiry)
Length: 10.24s (0x08)
Num responses: 0Quoted 1 line
HCI Event: Command Status (
0x0f) plen 4 #38208 [hci0] 10886.141333
Inquiry (0x01|0x0001) ncmd 2
Status: Success (0x00)
...
< HCI Command: LE Set Extended Scan Enable #38242 [hci0] 10896.381802
Extended scan: Disabled (0x00)
Filter duplicates: Disabled (0x00)
Duration: 0 msec (0x0000)
Period: 0.00 sec (0x0000)Quoted 1 line
HCI Event: Inquiry Complete (
0x01) plen 1 #38243 [hci0] 10896.383419
Status: Success (0x00)
Quoted 1 line
HCI Event: Command Complete (
0x0e) plen 4 #38244 [hci0] 10896.394378
LE Set Extended Scan Enable (0x08|0x0042) ncmd 2
Status: Success (0x00)
@ MGMT Event: Device Found (0x0012) plen 22 {0x0001} [hci0] 10896.394497
LE Address: 88:12:AC:92:43:69
RSSI: -101 dBm (0x9b)
Flags: 0x00000004
Not Connectable
Data length: 8
Company: Xiaomi Inc. (911)
Data[0]:
16-bit Service UUIDs (complete): 1 entry
Xiaomi Inc. (0xfdaa)
@ MGMT Event: Discovering (0x0013) plen 2 {0x0001} [hci0] 10896.394506
Address type: 0x07
BR/EDR
LE Public
LE Random
Discovery: Disabled (0x00)--- net/bluetooth/hci_event.c | 7 +++++++ 1 file changed, 7 insertions(+)
net/bluetooth/hci_event.c +7 -0
@@ -1765,6 +1765,13 @@ static void le_set_scan_enable_complete(struct hci_dev *hdev, u8 enable)hci_dev_clear_flag (hdev,HCI_LE_SCAN ); +if (hdev->discovery.type ==DISCOV_TYPE_INTERLEAVED && +hci_test_quirk (hdev,HCI_QUIRK_SIMULTANEOUS_DISCOVERY ) && + !test_bit (HCI_INQUIRY , &hdev->flags) && + hdev->discovery.state ==DISCOVERY_FINDING ) { +hci_discovery_set_state (hdev,DISCOVERY_STOPPED ); + } +/* The HCI_LE_SCAN_INTERRUPTED flag indicates that we * interrupted scanning due to a connect request. Mark * therefore discovery as stopped.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 468/1611 Bluetooth: hci_core: Fix UAF in hci_unregister_dev()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jordan Walters <[email protected]>
[ Upstream commit 5edcc018fa6e80b2c478454a4a8229c23d67c181 ]
hci_unregister_dev() does not disable cmd_timer and ncmd_timer before the hci_dev structure is freed. If a timeout fires during device teardown, the callback dereferences freed memory (including the hdev->reset function pointer), leading to a use-after-free.
Add disable_delayed_work_sync() calls alongside the existing disable_work_sync() calls to ensure both timers are fully quiesced before teardown proceeds.
--- net/bluetooth/hci_core.c | 2 ++ 1 file changed, 2 insertions(+)
net/bluetooth/hci_core.c +2 -0
@@ -2707,6 +2707,8 @@ void hci_unregister_dev(struct hci_dev *hdev)disable_work_sync (&hdev->tx_work);disable_work_sync (&hdev->power_on);disable_work_sync (&hdev->error_reset); +disable_delayed_work_sync (&hdev->cmd_timer); +disable_delayed_work_sync (&hdev->ncmd_timer);hci_cmd_sync_clear (hdev);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 469/1611 Bluetooth: btmtk: fix URB leak in alloc_mtk_intr_urb error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhao Dongdong <[email protected]>
[ Upstream commit f396f4005180928cd9e15e352a6512865d3bc908 ]
When btmtk_isopkt_pad() fails, the previously allocated URB is not freed, leaking the urb structure. Add usb_free_urb() before returning the error.
--- drivers/bluetooth/btmtk.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/btmtk.c +3 -1
@@ -1051,8 +1051,10 @@ struct urb *alloc_mtk_intr_urb(struct hci_dev *hdev, struct sk_buff *skb,if (!urb)return ERR_PTR (-ENOMEM ); -if (btmtk_isopkt_pad (hdev, skb)) +if (btmtk_isopkt_pad (hdev, skb)) { +usb_free_urb (urb);return ERR_PTR (-EINVAL ); + } pipe =usb_sndintpipe (btmtk_data->udev, btmtk_data->isopkt_tx_ep->bEndpointAddress);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 470/1611 Bluetooth: hci: validate codec capability element length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit c38fbcdc407925c7088f7e5f11c1fff73d2d35a2 ]
Read Local Codec Capabilities returns a sequence of capability elements. Each element starts with a one-byte length followed by that many payload bytes.
hci_read_codec_capabilities() checks that the skb contains the length byte, but then validates only caps->len against the remaining skb length. A malformed controller response with one remaining byte and caps->len set to one passes that check even though the element needs two bytes. The parser then records a two-byte capability and copies one byte beyond the advertised response payload into the codec list.
Validate the full element size, including the length byte, before adding it to the accumulated capability length. This preserves all well-formed capability elements and drops only truncated controller responses.
--- net/bluetooth/hci_codec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bluetooth/hci_codec.c +1 -1
@@ -100,7 +100,7 @@ static void hci_read_codec_capabilities(struct hci_dev *hdev, __u8 transport, caps = (void *)skb->data;if (skb->len <sizeof (*caps)) goto error; -if (skb->len < caps->len) +if (skb->len <sizeof (caps->len) + caps->len) goto error; len +=sizeof (caps->len) + caps->len;skb_pull (skb,sizeof (caps->len) + caps->len);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 471/1611 Bluetooth: vhci: validate devcoredump state before side effects
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit 88c2404a3c59c3126453919388dbd5ed98ed01bd ]
The VHCI force_devcoredump debugfs hook accepts a small test record from userspace. It validates the requested terminal state only after registering, initializing and appending a Bluetooth devcoredump.
As a result, an invalid state returns -EINVAL but still leaves queued devcoredump work behind. With a non-zero timeout field, the rejected write can still emit a devcoredump after the timeout expires.
Reject unsupported states before allocating the skb or changing the HCI devcoredump state machine.
--- drivers/bluetooth/hci_vhci.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/bluetooth/hci_vhci.c +10 -0
@@ -337,7 +337,17 @@ static ssize_t force_devcd_write(struct file *file, const char __user *user_buf,if (copy_from_user (&dump_data, user_buf, count))return -EFAULT ; +switch (dump_data.state) { +case HCI_DEVCOREDUMP_DONE : +case HCI_DEVCOREDUMP_ABORT : +case HCI_DEVCOREDUMP_TIMEOUT : +break ; +default : +return -EINVAL ; + } + data_size = count - offsetof(struct devcoredump_test_data , data); + skb =alloc_skb (data_size,GFP_ATOMIC );if (!skb)return -ENOMEM ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 472/1611 fs: efs: remove unneeded debug prints
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maxwell Doose <[email protected]>
[ Upstream commit 89009392c80da5da00876c8334ff20028e6e3eb6 ]
The current code uses debug prints conditionally compiled with #ifdef DEBUG. However, that code, when compiled, causes compiler errors due to incompatible formatters and undefined variables, notably:
fs/efs/file.c: In function `efs_get_block':fs/efs/file.c:26:35: error: block' undeclared (first use in this function); did you mean iblock'?
26 | __func__, block, inode->i_blocks, inode->i_size);
| ^~~~~
and:
fs/efs/file.c: In function `efs_bmap':./include/linux/kern_levels.h:5:25: error: format %ld' expects argument of type long int', but argument 4 has type blkcnt_t' {aka long long unsigned int'} [-Werror=format=]
5 | #define KERN_SOH "\001" /* ASCII Start Of Header */
| ^~~~~~which also extends to the other formatters. As this part of the code has been dead for just about 14 years now, it has not been modernized to stay compatible with the most recent gcc compilers. Fix these issues by removing the debug prints.
--- fs/efs/file.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
fs/efs/file.c +3 -18
@@ -18,16 +18,9 @@ int efs_get_block(struct inode *inode, sector_t iblock,if (create)return error; -if (iblock >= inode->i_blocks) { -#ifdef DEBUG -/* -* i have no idea why this happens as often as it does -*/ -pr_warn ("%s(): block %d >= %ld (filesize %ld)\n" , - __func__, block, inode->i_blocks, inode->i_size); -#endif +if (iblock >= inode->i_blocks)return 0 ; - } + phys =efs_map_block (inode, iblock);if (phys)map_bh (bh_result, inode->i_sb, phys);
@@ -42,16 +35,8 @@ int efs_bmap(struct inode *inode, efs_block_t block) { }/* are we about to read past the end of a file ? */ -if (!(block < inode->i_blocks)) { -#ifdef DEBUG -/* -* i have no idea why this happens as often as it does -*/ -pr_warn ("%s(): block %d >= %ld (filesize %ld)\n" , - __func__, block, inode->i_blocks, inode->i_size); -#endif +if (!(block < inode->i_blocks))return 0 ; - }return efs_map_block (inode, block); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 473/1611 RDMA/mlx5: Remove DCT restrack tracking
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit b136a7af41f796a48665afc6a55907488a3d5500 ]
DCT restrack tracking wasn't working to begin with as it was only tracking the first DCT which was added, since at creation the DCT number isn't yet initialized because the DCT FW object is only created during modify. The following DCT additions were failing silently.
Since the fix isn't trivial and there were no users that required or complained about this issue we are dropping this for now instead of fixing.
--- drivers/infiniband/hw/mlx5/qp.c | 1 + drivers/infiniband/hw/mlx5/restrack.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +1 -0
@@ -3111,6 +3111,7 @@ static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,switch (qp->type) {case MLX5_IB_QPT_DCT : +rdma_restrack_no_track (&qp->ibqp.res); err =create_dct (dev, pd, qp, params);break ;case MLX5_IB_QPT_DCI :
drivers/infiniband/hw/mlx5/restrack.c +0 -3
@@ -178,9 +178,6 @@ static int fill_res_qp_entry(struct sk_buff *msg, struct ib_qp *ibqp) ret =nla_put_string (msg,RDMA_NLDEV_ATTR_RES_SUBTYPE ,"REG_UMR" );break ; -case MLX5_IB_QPT_DCT : - ret =nla_put_string (msg,RDMA_NLDEV_ATTR_RES_SUBTYPE ,"DCT" ); -break ;case MLX5_IB_QPT_DCI : ret =nla_put_string (msg,RDMA_NLDEV_ATTR_RES_SUBTYPE ,"DCI" );break ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 474/1611 RDMA/mlx5: Remove raw RSS QP restrack tracking
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrisious Haddad <[email protected]>
[ Upstream commit 666031fed8f0fdfc29b20d125a628c1b0a04cdaf ]
Raw RSS QP restrack tracking wasn't working to begin with as it was only tracking the first raw RSS QP which was added, since at creation the raw RSS QP number is reserved so the QP number for this qp type was always zero.
The following raw RSS QP additions were always failing silently.
Since the fix isn't trivial and there were no users that required or complained about this issue we are dropping this for now instead of fixing.
--- drivers/infiniband/hw/mlx5/qp.c | 1 + 1 file changed, 1 insertion(+)
drivers/infiniband/hw/mlx5/qp.c +1 -0
@@ -3105,6 +3105,7 @@ static int create_qp(struct mlx5_ib_dev *dev, struct ib_pd *pd,int err;if (params->is_rss_raw) { +rdma_restrack_no_track (&qp->ibqp.res); err =create_rss_raw_qp_tir (dev, pd, qp, params); goto out; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 475/1611 RDMA/mlx5: Fix undefined shift of user RQ WQE size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Maher Sanalla <[email protected]>
[ Upstream commit d881d60223aac8fdc12b227d89c76e131e92a9cd ]
set_rq_size() computes the RQ WQE size as "1 << rq_wqe_shift" based on the user-provided rq_wqe_shift, which is only checked to be greater than 32, so shifts of 32 are still accepted. A shift of 31 also overflows a signed integer, leading to undefined behavior.
Use check_shl_overflow() to compute the RQ WQE size and reject any invalid values.
--- drivers/infiniband/hw/mlx5/qp.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/infiniband/hw/mlx5/qp.c +4 -7
@@ -451,16 +451,13 @@ static int set_rq_size(struct mlx5_ib_dev *dev, struct ib_qp_cap *cap,if (ucmd) { qp->rq.wqe_cnt = ucmd->rq_wqe_count; -if (ucmd->rq_wqe_shift >BITS_PER_BYTE *sizeof (ucmd->rq_wqe_shift)) -return -EINVAL ; qp->rq.wqe_shift = ucmd->rq_wqe_shift; -if ((1 << qp->rq.wqe_shift) / -sizeof (struct mlx5_wqe_data_seg ) < - wq_sig) +if (check_shl_overflow (1 , qp->rq.wqe_shift, &wqe_size)) +return -EINVAL ; +if (wqe_size /sizeof (struct mlx5_wqe_data_seg ) < wq_sig)return -EINVAL ; qp->rq.max_gs = - (1 << qp->rq.wqe_shift) / -sizeof (struct mlx5_wqe_data_seg ) - + wqe_size /sizeof (struct mlx5_wqe_data_seg ) - wq_sig; qp->rq.max_post = qp->rq.wqe_cnt; }else {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 476/1611 RDMA/mlx5: Release the HW‑provided UAR index rather than the SW one
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 449ae7927152e46acbe5f19f97eafdae6d3a96b1 ]
Free the UAR index returned by the hardware.
--- drivers/infiniband/hw/mlx5/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/main.c +1 -1
@@ -2460,7 +2460,7 @@ static int uar_mmap(struct mlx5_ib_dev *dev, enum mlx5_ib_mmap_cmd cmd,if (!dyn_uar)return err; -mlx5_cmd_uar_dealloc (dev->mdev, idx, context->devx_uid); +mlx5_cmd_uar_dealloc (dev->mdev, uar_index, context->devx_uid); free_bfreg:mlx5_ib_free_bfreg (dev, bfregi, bfreg_dyn_idx);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 477/1611 ASoC: SOF: Intel: hda-sdw-bpt: select SND_SOF_SOF_HDA_SDW_BPT properly
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit 999ec4c29d73ac85b639a31bbc85ad2ec00eb9d7 ]
When SND_SOC_SOF_INTEL_LNL is set, SND_SOF_SOF_HDA_SDW_BPT must also be enabled, in order to let the soundwire support call into it.
However, there are configurations with SND_SOF_SOF_HDA_SDW_BPT=m and SND_SOF_SOF_HDA_SDW_BPT=m but SOUNDWIRE_INTEL=y, which still lead to a link failure:
aarch64-linux-ld: drivers/soundwire/intel_ace2x.o: in function `intel_ace2x_bpt_wait':
intel_ace2x.c:(.text+0xfc8): undefined reference to `hda_sdw_bpt_wait'
aarch64-linux-ld: drivers/soundwire/intel_ace2x.o: in function `intel_ace2x_bpt_send_async':
intel_ace2x.c:(.text+0x1ff8): undefined reference to `hda_sdw_bpt_get_buf_size_alignment'
Address this by moving the 'select SND_SOF_SOF_HDA_SDW_BPT' into SND_SOC_SOF_HDA_GENERIC.
--- sound/soc/sof/intel/Kconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/sof/intel/Kconfig +2 -2
@@ -266,10 +266,8 @@ config SND_SOC_SOF_METEORLAKE config SND_SOC_SOF_INTEL_LNL tristate - select SOUNDWIRE_INTEL if SND_SOC_SOF_INTEL_SOUNDWIRE != n select SND_SOC_SOF_HDA_GENERIC select SND_SOC_SOF_INTEL_SOUNDWIRE_LINK_BASELINE - select SND_SOF_SOF_HDA_SDW_BPT if SND_SOC_SOF_INTEL_SOUNDWIRE != n select SND_SOC_SOF_IPC4 select SND_SOC_SOF_INTEL_MTL
@@ -312,6 +310,8 @@ config SND_SOC_SOF_HDA_GENERIC select SND_SOC_SOF_HDA_LINK_BASELINE select SND_SOC_SOF_HDA_PROBES select SND_SOC_SOF_HDA_MLINK if SND_SOC_SOF_HDA_LINK + select SND_SOF_SOF_HDA_SDW_BPT if SND_SOC_SOF_INTEL_LNL != n && \ + SND_SOC_SOF_INTEL_SOUNDWIRE !=n help This option is not user-selectable but automagically handled by 'select' statements at a higher level.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 478/1611 ASoC: codecs: hdac_hdmi: Validate written enum value
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 0b08baeccdcf52fad328ad645f5b4fbee04eea34 ]
hdac_hdmi_set_pin_port_mux() uses the written enum value to index the texts array before calling snd_soc_dapm_put_enum_double(), which validates that the value is within the enum item range.
An out-of-range value can therefore make the driver read past the texts array before the helper rejects the write. Move the lookup after the helper has accepted the value.
--- sound/soc/codecs/hdac_hdmi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/codecs/hdac_hdmi.c +3 -1
@@ -907,12 +907,14 @@ static int hdac_hdmi_set_pin_port_mux(struct snd_kcontrol *kcontrol,struct hdac_device *hdev =dev_to_hdac_dev (dapm->dev);struct hdac_hdmi_priv *hdmi =hdev_to_hdmi_priv (hdev);struct hdac_hdmi_pcm *pcm; -const char *cvt_name = e->texts[ucontrol->value.enumerated.item[0 ]]; +const char *cvt_name; ret =snd_soc_dapm_put_enum_double (kcontrol, ucontrol);if (ret <0 )return ret; + cvt_name = e->texts[ucontrol->value.enumerated.item[0 ]]; +if (port ==NULL )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 479/1611 ASoC: fsl: fsl_audmix: Validate written enum values
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 3cd17e4e2871114d5579fa7bc8da66faf7fc1930 ]
fsl_audmix_put_mix_clk_src() and fsl_audmix_put_out_src() convert the user-provided enum item with snd_soc_enum_item_to_val() before checking whether the item is within the enum's item count.
The generic snd_soc_put_enum_double() helper performs that validation, but these callbacks use the converted value first: the clock-source path tests it with BIT(), and the output-source path indexes the prms transition table with it.
Reject out-of-range enum items before converting them.
--- sound/soc/fsl/fsl_audmix.c | 6 ++++++ 1 file changed, 6 insertions(+)
sound/soc/fsl/fsl_audmix.c +6 -0
@@ -117,6 +117,9 @@ static int fsl_audmix_put_mix_clk_src(struct snd_kcontrol *kcontrol,unsigned int *item = ucontrol->value.enumerated.item;unsigned int reg_val, val, mix_clk; +if (item[0 ] >= e->items) +return -EINVAL ; +/* Get current state */ reg_val =snd_soc_component_read (comp,FSL_AUDMIX_CTR ); mix_clk = ((reg_val & FSL_AUDMIX_CTR_MIXCLK_MASK)
@@ -157,6 +160,9 @@ static int fsl_audmix_put_out_src(struct snd_kcontrol *kcontrol,unsigned int reg_val, val, mask =0 , ctr =0 ;int ret; +if (item[0 ] >= e->items) +return -EINVAL ; +/* Get current state */ reg_val =snd_soc_component_read (comp,FSL_AUDMIX_CTR );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 480/1611 ASoC: tegra: tegra210_ahub: Validate written enum value
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: HyeongJun An <[email protected]>
[ Upstream commit 1d8aabb413b5638670dfd1162169edc0ba276a2e ]
tegra_ahub_put_value_enum() reads e->values[item[0]] before checking whether item[0] is within the enum item range. The existing check therefore happens too late to prevent an out-of-range read of the values array.
Move the check before the array access.
--- sound/soc/tegra/tegra210_ahub.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/tegra/tegra210_ahub.c +3 -1
@@ -60,13 +60,15 @@ static int tegra_ahub_put_value_enum(struct snd_kcontrol *kctl,struct soc_enum *e = (struct soc_enum *)kctl->private_value;struct snd_soc_dapm_update update[TEGRA_XBAR_UPDATE_MAX_REG ] = { };unsigned int *item = uctl->value.enumerated.item; -unsigned int value = e->values[item[0 ]]; +unsigned int value;unsigned int i, bit_pos, reg_idx =0 , reg_val =0 ;int change =0 ;if (item[0 ] >= e->items)return -EINVAL ; + value = e->values[item[0 ]]; +if (value) {/* Get the register index and value to set */ reg_idx = (value -1 ) / (8 * cmpnt->val_bytes);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 481/1611 net: dsa: qca8k: fix led devicename when using external mdio bus
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: George Moussalem <[email protected]>
[ Upstream commit 0b7b378ce6cafbb948786cb6f17f406d94016c8c ]
The qca8k dsa switch can use either an external or internal mdio bus. This depends on whether the mdio node is defined under the switch node itself. Upon registering the internal mdio bus, the internal_mdio_bus of the dsa switch is assigned to this bus. When an external mdio bus is used, the driver still uses the internal_mdio_bus id which is used to create the device names of the leds.
This leads to the leds being prefixed with '(efault)' as the internal_mii_bus is null. So let's fix this by adding a null check and use the devicename of the external bus instead when an external bus is configured.
--- drivers/net/dsa/qca/qca8k-leds.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/dsa/qca/qca8k-leds.c +2 -1
@@ -429,7 +429,8 @@ qca8k_parse_port_leds(struct qca8k_priv *priv, struct fwnode_handle *port, int p init_data.fwnode = led; init_data.devname_mandatory = true; init_data.devicename =kasprintf (GFP_KERNEL ,"%s:0%d" , - priv->internal_mdio_bus->id, + priv->internal_mdio_bus ? + priv->internal_mdio_bus->id : priv->bus->id, port_num);if (!init_data.devicename) {fwnode_handle_put (led);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 482/1611 net/sched: cls_flow: Dont expose folded kernel pointers
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jamal Hadi Salim <[email protected]>
[ Upstream commit f294fc71c4a0fa4964f6428a1b4e7929c1d83125 ]
The flow classifier falls back to addr_fold() for fields that are missing from packet headers. In map mode, userspace controls mask, xor, rshift, addend and divisor, and can observe the resulting classid through class statistics. This allows a tc classifier in a user/network namespace to recover the 32-bit folded value of skb->sk, skb_dst() or skb_nfct().
Align with standard kernel practices for pointer hashing and replace the XOR folding with a keyed siphash (which is cryptographically secure)
--- net/sched/cls_flow.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
net/sched/cls_flow.c +9 -3
@@ -21,6 +21,7 @@#include <net/inet_sock.h> #include <net/pkt_cls.h> +#include <linux/siphash.h> #include <net/ip.h> #include <net/route.h> #include <net/flow_dissector.h>
@@ -57,11 +58,15 @@ struct flow_filter {struct rcu_work rwork; }; +static siphash_aligned_key_t flow_keys_secret__read_mostly ; +static inline u32 addr_fold (void *addr) { -unsigned long a = (unsigned long )addr; - -return (a &0xFFFFFFFF ) ^ (BITS_PER_LONG >32 ? a >>32 :0 ); +#ifdef CONFIG_64BIT +return (u32 )siphash_1u64 ((u64 )addr, &flow_keys_secret); +#else +return (u32 )siphash_1u32 ((u32 )addr, &flow_keys_secret); +#endif }static u32 flow_get_src (const struct sk_buff *skb,const struct flow_keys *flow)
@@ -596,6 +601,7 @@ static int flow_init(struct tcf_proto *tp)return -ENOBUFS ;INIT_LIST_HEAD (&head->filters);rcu_assign_pointer (tp->root, head); +net_get_random_once (&flow_keys_secret,sizeof (flow_keys_secret));return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 483/1611 net: fib_rules: Dont dump dying fib_rule in fib_rules_dump().
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 2821e85c058f81c9948a2fb1a634f7b47457d51c ]
rocker_router_fib_event() calls fib_rule_get() during RCU dump.
If the fib_rule is dying, refcount_inc() will complain about it.
Let's call refcount_inc_not_zero() in fib_rules_dump().
--- include/net/fib_rules.h | 5 +++++ net/core/fib_rules.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-)
include/net/fib_rules.h +5 -0
@@ -111,6 +111,11 @@ static inline void fib_rule_get(struct fib_rule *rule)refcount_inc (&rule->refcnt); } +static inline bool fib_rule_get_safe (struct fib_rule *rule) +{ +return refcount_inc_not_zero (&rule->refcnt); +} +static inline void fib_rule_put (struct fib_rule *rule) {if (refcount_dec_and_test (&rule->refcnt))
net/core/fib_rules.c +5 -1
@@ -349,7 +349,7 @@ int fib_rules_lookup(struct fib_rules_ops *ops, struct flowi *fl,if (err != -EAGAIN ) {if ((arg->flags &FIB_LOOKUP_NOREF ) || -likely (refcount_inc_not_zero (&rule->refcnt))) { +likely (fib_rule_get_safe (rule))) { arg->rule = rule; goto out; }
@@ -410,8 +410,12 @@ int fib_rules_dump(struct net *net, struct notifier_block *nb, int family,if (!ops)return -EAFNOSUPPORT ;list_for_each_entry_rcu (rule, &ops->rules_list, list) { +if (!fib_rule_get_safe (rule)) +continue ; + err =call_fib_rule_notifier (nb,FIB_EVENT_RULE_ADD , rule, family, extack); +fib_rule_put (rule);if (err)break ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 484/1611 bridge: cfm: reject invalid CCM interval at configuration time
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiang Mei <[email protected]>
[ Upstream commit f3e02edd8322b31b8e6517faa6ba053bf29d1e26 ]
ccm_tx_work_expired() re-arms itself via queue_delayed_work() using the configured exp_interval converted by interval_to_us(). When exp_interval is BR_CFM_CCM_INTERVAL_NONE or out of range, interval_to_us() returns 0, causing the worker to fire immediately in a tight loop that allocates skbs until OOM.
Fix this by validating exp_interval at configuration time:
- Constrain IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL to the valid range [BR_CFM_CCM_INTERVAL_3_3_MS, BR_CFM_CCM_INTERVAL_10_MIN] in the netlink policy so userspace cannot set an invalid value.
- Reject starting CCM TX in br_cfm_cc_ccm_tx() when exp_interval has not yet been configured (defaults to 0 from kzalloc).
--- net/bridge/br_cfm.c | 6 ++++++ net/bridge/br_cfm_netlink.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-)
net/bridge/br_cfm.c +6 -0
@@ -805,6 +805,12 @@ int br_cfm_cc_ccm_tx(struct net_bridge *br, const u32 instance, goto save; } +if (!interval_to_us (mep->cc_config.exp_interval)) { +NL_SET_ERR_MSG_MOD (extack, +"Invalid CCM interval" ); +return -EINVAL ; + } +/* Start delayed work to transmit CCM frames. It is done with zero delay * to send first frame immediately */
net/bridge/br_cfm_netlink.c +3 -1
@@ -34,7 +34,9 @@ br_cfm_cc_config_policy[IFLA_BRIDGE_CFM_CC_CONFIG_MAX + 1] = { [IFLA_BRIDGE_CFM_CC_CONFIG_UNSPEC] = { .type = NLA_REJECT }, [IFLA_BRIDGE_CFM_CC_CONFIG_INSTANCE] = { .type = NLA_U32 }, [IFLA_BRIDGE_CFM_CC_CONFIG_ENABLE] = { .type = NLA_U32 }, - [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL] = { .type = NLA_U32 }, + [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL ] = +NLA_POLICY_RANGE (NLA_U32 ,BR_CFM_CCM_INTERVAL_3_3_MS , + BR_CFM_CCM_INTERVAL_10_MIN), [IFLA_BRIDGE_CFM_CC_CONFIG_EXP_MAID ] = { .type = NLA_BINARY, .len = CFM_MAID_LENGTH }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 485/1611 sctp: validate embedded address parameter length
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xin Long <[email protected]>
[ Upstream commit e9361d0ca55c4af12aac09e2572852fa91046229 ]
sctp_verify_asconf() and sctp_verify_param() only validate ADD_IP, DEL_IP, and SET_PRIMARY parameters against a fixed minimum size of sizeof(struct sctp_addip_param) + sizeof(struct sctp_paramhdr). This ensures the outer parameter is large enough to contain an embedded address parameter header, but does not verify that the embedded address parameter's declared length fits within the bounds of the outer parameter.
Later, sctp_process_param() and sctp_process_asconf_param() extract the embedded address parameter and pass it to af->from_addr_param(), which uses the address parameter length to parse the variable-length address payload. A malformed peer can therefore advertise an embedded address parameter length that exceeds the remaining bytes in the enclosing parameter.
Validate that addr_param->p.length does not exceed the space available after the sctp_addip_param header before processing the embedded address parameter. Reject malformed parameters when the embedded address length extends beyond the enclosing parameter bounds.
This prevents out-of-bounds reads when parsing malformed parameters carried in INIT or ASCONF processing paths.
--- net/sctp/sm_make_chunk.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
net/sctp/sm_make_chunk.c +8 -2
@@ -2641,6 +2641,9 @@ static int sctp_process_param(struct sctp_association *asoc, goto fall_through; addr_param = param.v +sizeof (struct sctp_addip_param ); +if (ntohs (addr_param->p.length) > +ntohs (param.p->length) -sizeof (struct sctp_addip_param )) +break ; af =sctp_get_af_specific (param_type2af (addr_param->p.type));if (!af)
@@ -3039,13 +3042,16 @@ static __be16 sctp_process_asconf_param(struct sctp_association *asoc,union sctp_addr addr;struct sctp_af *af; - addr_param = (void *)asconf_param +sizeof (*asconf_param); -if (asconf_param->param_hdr.type !=SCTP_PARAM_ADD_IP && asconf_param->param_hdr.type !=SCTP_PARAM_DEL_IP && asconf_param->param_hdr.type !=SCTP_PARAM_SET_PRIMARY )return SCTP_ERROR_UNKNOWN_PARAM ; + addr_param = (void *)asconf_param +sizeof (*asconf_param); +if (ntohs (addr_param->p.length) > +ntohs (asconf_param->param_hdr.length) -sizeof (*asconf_param)) +return SCTP_ERROR_PROTO_VIOLATION ; +switch (addr_param->p.type) {case SCTP_PARAM_IPV6_ADDRESS :if (!asoc->peer.ipv6_address)
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 486/1611 net: pfcp: allocate per-cpu tstats for PFCP netdevs
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Moelius <[email protected]>
[ Upstream commit 24041543da8cd84eb5d8ae738c534372fff54820 ]
PFCP uses dev_get_tstats64() as its ndo_get_stats64 callback, but pfcp_link_setup() does not request NETDEV_PCPU_STAT_TSTATS. The net core therefore leaves dev->tstats NULL for PFCP devices.
Creating a PFCP rtnetlink device can immediately ask the new netdev for stats while building the RTM_NEWLINK notification. That reaches dev_get_tstats64() and dereferences the NULL dev->tstats pointer.
Set pcpu_stat_type to NETDEV_PCPU_STAT_TSTATS during PFCP link setup so the net core allocates the storage expected by dev_get_tstats64().
--- drivers/net/pfcp.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/pfcp.c +1 -0
@@ -148,6 +148,7 @@ static void pfcp_link_setup(struct net_device *dev) dev->flags =IFF_POINTOPOINT |IFF_NOARP |IFF_MULTICAST ; dev->priv_flags |=IFF_NO_QUEUE ; + dev->pcpu_stat_type =NETDEV_PCPU_STAT_TSTATS ;netif_keep_dst (dev); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 487/1611 net/sched: sch_hfsc: Dont make class passive twice
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 90b662ea25f5e83bb3b8ccec5b93ced810b92fb8 ]
update_vf() is called from two places for the same class during a single dequeue when the class's child qdisc (e.g. codel/fq_codel) drops its last packets while dequeuing:
1. The child calls qdisc_tree_reduce_backlog(), which, now that the child is empty, invokes hfsc_qlen_notify() -> update_vf(cl, 0, 0) and turns the class passive (cl_nactive is decremented up the hierarchy).
2. hfsc_dequeue() then calls update_vf(cl, qdisc_pkt_len(skb), cur_time) to charge the dequeued bytes.
On the second call the class is already passive, but its child qdisc is still empty, so update_vf() arms go_passive again:
if (cl->qdisc->q.qlen == 0 && cl->cl_flags & HFSC_FSC)
go_passive = 1;The leaf is then skipped by the cl_nactive == 0 check inside the loop, which does not clear go_passive, so the stale go_passive propagates to the parent and decrements its cl_nactive a second time. A parent that still has other active children is driven to cl_nactive == 0 and removed from the vttree, even though those siblings are still backlogged. They are never dequeued again and the qdisc stalls.
Fix this by only arming go_passive when the class is actually active, so an already-passive class no longer triggers a second passive transition. The byte accounting (cl->cl_total += len) still runs for every ancestor, so dequeued bytes continue to be counted exactly once.
--- net/sched/sch_hfsc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_hfsc.c +1 -1
@@ -753,7 +753,7 @@ update_vf(struct hfsc_class *cl, unsigned int len, u64 cur_time)u64 f;/* , myf_bound, delta; */ int go_passive =0 ; -if (cl->qdisc->q.qlen ==0 && cl->cl_flags &HFSC_FSC ) +if (cl->qdisc->q.qlen ==0 && cl->cl_flags &HFSC_FSC && cl->cl_nactive) go_passive =1 ;for (; cl->cl_parent !=NULL ; cl = cl->cl_parent) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 488/1611 tipc: require net admin for TIPCv2 netlink mutators
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 86b0c540e2ea397cde021eecd24145f7c16a3d4e ]
TIPCv2 registers mutating generic-netlink operations without admin permission flags. Generic netlink only checks CAP_NET_ADMIN when an operation sets GENL_ADMIN_PERM or GENL_UNS_ADMIN_PERM, so a local unprivileged process can currently change TIPC state through commands such as TIPC_NL_NET_SET, TIPC_NL_KEY_SET, TIPC_NL_KEY_FLUSH, and bearer enable/disable.
The legacy TIPC netlink API already checks netlink_net_capable(..., CAP_NET_ADMIN) for administrative commands. Give the TIPCv2 mutators the equivalent generic-netlink gate. Use GENL_UNS_ADMIN_PERM, which maps to the same namespace-aware CAP_NET_ADMIN check that netlink_net_capable() performs, so the behaviour matches the legacy path and keeps working for CAP_NET_ADMIN holders in a non-initial user namespace (containers).
A QEMU/KASAN repro run as uid/gid 65534 with zero effective capabilities previously succeeded in changing the network id and node identity, setting and flushing key material, and enabling/disabling a UDP bearer. With this patch applied the same operations fail with -EPERM.
--- net/tipc/netlink.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/tipc/netlink.c +12 -0
@@ -152,11 +152,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_BEARER_DISABLE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_disable, }, { .cmd = TIPC_NL_BEARER_ENABLE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_enable, }, {
@@ -168,11 +170,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_BEARER_ADD, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_add, }, { .cmd = TIPC_NL_BEARER_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_bearer_set, }, {
@@ -197,11 +201,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_LINK_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_set_link, }, { .cmd = TIPC_NL_LINK_RESET_STATS, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_reset_link_stats, }, {
@@ -213,6 +219,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_MEDIA_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_media_set, }, {
@@ -228,6 +235,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_NET_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_net_set, }, {
@@ -238,6 +246,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_MON_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_set_monitor, }, {
@@ -255,6 +264,7 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_PEER_REMOVE, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_peer_rm, },#ifdef CONFIG_TIPC_MEDIA_UDP
@@ -269,11 +279,13 @@ static const struct genl_ops tipc_genl_v2_ops[] = { { .cmd = TIPC_NL_KEY_SET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_set_key, }, { .cmd = TIPC_NL_KEY_FLUSH, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, + .flags = GENL_UNS_ADMIN_PERM, .doit = tipc_nl_node_flush_key, }, #endif
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 489/1611 tipc: prevent snt_unacked underflow on CONN_ACK
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit ab3e10b44ba5411779aac7afd2477917dd77750f ]
tipc_sk_conn_proto_rcv() subtracts the peer-supplied connection ack count from the unsigned 16-bit send counter snt_unacked without checking that it does not exceed the number of messages actually outstanding:
tsk->snt_unacked -= msg_conn_ack(hdr);
msg_conn_ack() is read straight from a received CONN_MANAGER/CONN_ACK message. If the ack count is larger than snt_unacked, the subtraction wraps to a near-maximum value, leaving tsk_conn_cong() permanently true and starving the connection of further transmits.
Validate the ACK count at the start of the CONN_ACK block and drop the message if it acknowledges more messages than are outstanding. A peer (or, for a local connection, the connected peer socket) can otherwise wedge a TIPC connection's send side by sending an oversized connection ack.
--- net/tipc/socket.c | 3 +++ 1 file changed, 3 insertions(+)
net/tipc/socket.c +3 -0
@@ -1362,6 +1362,9 @@ static void tipc_sk_conn_proto_rcv(struct tipc_sock *tsk, struct sk_buff *skb,__skb_queue_tail (xmitq, skb);return ; }else if (mtyp ==CONN_ACK ) { +if (tsk->snt_unacked <msg_conn_ack (hdr)) + goto exit; + was_cong =tsk_conn_cong (tsk);tipc_sk_push_backlog (tsk,msg_nagle_ack (hdr)); tsk->snt_unacked -=msg_conn_ack (hdr);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 490/1611 tipc: reject inverted service ranges from peer bindings
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Bommarito <[email protected]>
[ Upstream commit 2afb648f7b99216c687db1f89739c995e1144153 ]
tipc_update_nametbl() inserts a binding advertised by a peer node using the lower and upper service-range bounds taken directly from the wire, without checking that lower <= upper. The local bind path validates the ordering (tipc_uaddr_valid()), but the name-distribution path does not.
A binding with lower > upper is inserted at the far end of the service-range rbtree (keyed on lower) where no lookup or withdrawal can ever match it (service_range_foreach_match() requires sr->lower <= end). The publication, its service_range node and the augmented rbtree entry are then leaked for the lifetime of the namespace, and there is no per-peer cap equivalent to TIPC_MAX_PUBL on locally created bindings.
Reject inverted ranges in the network path as well. A peer node can otherwise leak unbounded binding-table memory by sending PUBLICATION items with lower > upper.
--- net/tipc/name_distr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
net/tipc/name_distr.c +11 -2
@@ -280,12 +280,21 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i, u32 node, u32 dtype) {struct publication *p =NULL ; +u32 lower =ntohl (i->lower); +u32 upper =ntohl (i->upper);struct tipc_socket_addr sk; -struct tipc_uaddr ua;u32 key =ntohl (i->key); +struct tipc_uaddr ua; + +/* A peer-advertised binding with lower > upper can never be matched +* or withdrawn and would leak the publication; the local bind path +* rejects such ranges, so reject ranges learned from the network too. +*/ +if (lower > upper) +return false;tipc_uaddr (&ua,TIPC_SERVICE_RANGE ,TIPC_CLUSTER_SCOPE , -ntohl (i->type),ntohl (i->lower),ntohl (i->upper)); +ntohl (i->type), lower, upper); sk.ref =ntohl (i->port); sk.node = node;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 491/1611 cxl/test: Unregister cxl_acpi in cxl_test_init() error path
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit 50cc34be04a0ea7522b739c9c7a71367cfbc489c ]
In cxl_test_init(), Once cxl_mock_platform_device_add() succeeds, all error paths after needs to call platform_device_unregister() instead of platform_device_put() to clean up.
--- tools/testing/cxl/test/cxl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/cxl/test/cxl.c +1 -1
@@ -1526,7 +1526,7 @@ static __init int cxl_test_init(void)return 0 ; err_root: -platform_device_put (cxl_acpi); +platform_device_unregister (cxl_acpi); err_rch:cxl_rch_topo_exit (); err_single:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 492/1611 cxl/test: Add check after kzalloc() memory in alloc_mock_res()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Jiang <[email protected]>
[ Upstream commit dfe28c8592538152e9611341dae6f7be1735b3f1 ]
alloc_mock_res() calls kzalloc() without checking the return value. Add scope based resource management to deal with the allocated memory cleanly.
--- tools/testing/cxl/test/cxl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/cxl/test/cxl.c +6 -2
@@ -403,12 +403,16 @@ static void depopulate_all_mock_resources(void)static struct cxl_mock_res *alloc_mock_res (resource_size_t size,int align) { -struct cxl_mock_res *res =kzalloc (sizeof (*res),GFP_KERNEL );struct genpool_data_align data = { .align = align, };unsigned long phys; + struct cxl_mock_res *res __free(kfree) = kzalloc(sizeof(*res), +GFP_KERNEL ); +if (!res) +return NULL ; +INIT_LIST_HEAD (&res->list); phys =gen_pool_alloc_algo (cxl_mock_pool, size, gen_pool_first_fit_align, &data);
@@ -423,7 +427,7 @@ static struct cxl_mock_res *alloc_mock_res(resource_size_t size, int align)list_add (&res->list, &mock_res);mutex_unlock (&mock_res_lock); -return res; +return no_free_ptr (res); }static int populate_cedt (void )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 493/1611 crypto: marvell/octeontx - fix DMA cleanup using wrong loop index
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 7891c64c0520519782470ba29bac8a5761e295d8 ]
The sg_cleanup path used list[i] instead of list[j] when unmapping DMA buffers, leaking successfully mapped entries and repeatedly unmapping the failed one.
--- drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/marvell/octeontx/otx_cptvf_reqmgr.c +2 -2
@@ -157,8 +157,8 @@ static inline int setup_sgio_components(struct pci_dev *pdev, sg_cleanup:for (j =0 ; j < i; j++) {if (list[j].dma_addr) { -dma_unmap_single (&pdev->dev, list[i].dma_addr, - list[i].size,DMA_BIDIRECTIONAL ); +dma_unmap_single (&pdev->dev, list[j].dma_addr, + list[j].size,DMA_BIDIRECTIONAL ); } list[j].dma_addr =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 494/1611 crypto: cavium/cpt - fix DMA cleanup using wrong loop index
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felix Gu <[email protected]>
[ Upstream commit 9dbf173bd32d5f81b005008b682bfb50aa093455 ]
The sg_cleanup error path used list[i] instead of list[j] when unmapping DMA buffers, leaking successfully mapped entries and repeatedly unmapping the failed one.
--- drivers/crypto/cavium/cpt/cptvf_reqmanager.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/cavium/cpt/cptvf_reqmanager.c +2 -2
@@ -108,8 +108,8 @@ static int setup_sgio_components(struct cpt_vf *cptvf, struct buf_ptr *list, sg_cleanup:for (j =0 ; j < i; j++) {if (list[j].dma_addr) { -dma_unmap_single (&pdev->dev, list[i].dma_addr, - list[i].size,DMA_BIDIRECTIONAL ); +dma_unmap_single (&pdev->dev, list[j].dma_addr, + list[j].size,DMA_BIDIRECTIONAL ); } list[j].dma_addr =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 495/1611 crypto: rng - Free default RNG on module exit
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 606ba888b98e0d26a2c4e5c8dc0542e3ad8f0f3a ]
When the rng module is removed the default RNG will be leaked. Call crypto_del_default_rng to free it if possible.
--- crypto/rng.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
crypto/rng.c +11 -0
@@ -226,5 +226,16 @@ void crypto_unregister_rngs(struct rng_alg *algs, int count) }EXPORT_SYMBOL_GPL (crypto_unregister_rngs); +static void __exit rng_exit(void) +{ +int err; + + err =crypto_del_default_rng (); +if (err) +pr_err ("Failed delete default RNG: %d\n" , err); +} + +module_exit (rng_exit); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Random Number Generator" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 496/1611 ALSA: usb-audio: qcom: Guard sideband endpoint removal
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cássio Gabriel <[email protected]>
[ Upstream commit 2773023abb381e36ce02d364022d901f6f7a416d ]
qmi_stop_session() conditionally looks up the cached data and sync endpoints, but removes each endpoint unconditionally.
The data endpoint is always present for an active offload stream, while the sync endpoint is optional. When no sync endpoint exists, ep still refers to the data endpoint and the code attempts to remove that endpoint a second time. The current sideband implementation rejects the duplicate removal, but the teardown path should not pass an unrelated endpoint for an absent sync endpoint.
Only look up and remove an endpoint when its cached pipe exists, check the lookup result, and clear the cached pipe after handling it. This matches the normal stream-disable path.
--- sound/usb/qcom/qc_audio_offload.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
sound/usb/qcom/qc_audio_offload.c +12 -4
@@ -794,15 +794,23 @@ static void qmi_stop_session(void)continue ; }/* Release XHCI endpoints */ -if (info->data_ep_pipe) +if (info->data_ep_pipe) { ep =usb_pipe_endpoint (uadev[pcm_card_num].udev, info->data_ep_pipe); -xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, ep); +if (ep) +xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, + ep); + info->data_ep_pipe =0 ; + } -if (info->sync_ep_pipe) +if (info->sync_ep_pipe) { ep =usb_pipe_endpoint (uadev[pcm_card_num].udev, info->sync_ep_pipe); -xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, ep); +if (ep) +xhci_sideband_remove_endpoint (uadev[pcm_card_num].sb, + ep); + info->sync_ep_pipe =0 ; + }disable_audio_stream (subs); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 497/1611 ALSA: seq: Fix kernel heap address leak in bounce_error_event()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: HanQuan <[email protected]>
[ Upstream commit efc86691e4d8083d9e380ea95042c2cf679f65fd ]
The comment above bounce_error_event() documents that user clients should receive SNDRV_SEQ_EVENT_BOUNCE with the original event embedded as variable-length data, while kernel clients should receive SNDRV_SEQ_EVENT_KERNEL_ERROR with a quoted kernel pointer.
However, the implementation unconditionally uses SNDRV_SEQ_EVENT_KERNEL_ERROR with data.quote.event set to the raw struct snd_seq_event pointer for all clients. When a bounce error event is delivered to a USER_CLIENT via snd_seq_read(), the kernel heap address in data.quote.event is exposed to userspace through copy_to_user() in the fixed-length branch.
This is a distinct leak path from the one addressed by commit 705dd6dcbc0e ("ALSA: seq: Clear variable event pointer on read"), which sanitizes data.ext.ptr in the variable-length branch of snd_seq_read(). The bounce_error_event() leak uses fixed-length events that take the else branch where no sanitization occurs.
Differentiate the bounce event by client type. For USER_CLIENT, send SNDRV_SEQ_EVENT_BOUNCE with SNDRV_SEQ_EVENT_LENGTH_VARIABLE and data.ext pointing to the original event. The variable-length path in snd_seq_event_dup() copies the event data into chained cells, and snd_seq_expand_var_event() copies only the content -- never the pointer -- to userspace. For KERNEL_CLIENT, keep the existing SNDRV_SEQ_EVENT_KERNEL_ERROR behavior with the quoted pointer.
--- sound/core/seq/seq_clientmgr.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)
sound/core/seq/seq_clientmgr.c +27 -5
@@ -538,16 +538,38 @@ static int bounce_error_event(struct snd_seq_client *client,/* set up quoted error */ memset (&bounce_ev,0 ,sizeof (bounce_ev)); - bounce_ev.type =SNDRV_SEQ_EVENT_KERNEL_ERROR ; - bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_FIXED ; + +if (client->type ==USER_CLIENT ) { +/* +* For user clients, send SNDRV_SEQ_EVENT_BOUNCE with the +* original event embedded as variable-length data. This +* avoids exposing data.quote.event (a kernel pointer) to +* userspace. The variable-length path in snd_seq_event_dup() +* copies the event data from data.ext.ptr into chained cells, +* and snd_seq_expand_var_event() copies only the data content +* -- never the pointer -- to userspace. +*/ + bounce_ev.type =SNDRV_SEQ_EVENT_BOUNCE ; + bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_VARIABLE ; + bounce_ev.data.ext.len =sizeof (struct snd_seq_event ); + bounce_ev.data.ext.ptr = (char *)event; + }else { +/* +* For kernel clients, quote the event pointer directly. +* Kernel consumers can safely dereference the pointer. +*/ + bounce_ev.type =SNDRV_SEQ_EVENT_KERNEL_ERROR ; + bounce_ev.flags =SNDRV_SEQ_EVENT_LENGTH_FIXED ; + bounce_ev.data.quote.origin = event->dest; + bounce_ev.data.quote.event = event; + bounce_ev.data.quote.value = -err;/* use positive value */ + } + bounce_ev.queue =SNDRV_SEQ_QUEUE_DIRECT ; bounce_ev.source.client =SNDRV_SEQ_CLIENT_SYSTEM ; bounce_ev.source.port =SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE ; bounce_ev.dest.client = client->number; bounce_ev.dest.port = event->source.port; - bounce_ev.data.quote.origin = event->dest; - bounce_ev.data.quote.event = event; - bounce_ev.data.quote.value = -err;/* use positive value */ result =snd_seq_deliver_single_event (NULL , &bounce_ev, atomic, hop +1 );if (result <0 ) { client->event_lost++;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 498/1611 spi: xilinx: use FIFO occupancy register to determine buffer size
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars Pöschel <[email protected]>
[ Upstream commit 47f3b5365536e8c38f264824ab15fdb74454e066 ]
The method the driver uses to determine the size of the FIFO has a problem. What it currently does is this:
It stops the SPI hardware and writes to the TX FIFO register until TX FIFO FULL asserts in the status register. But the hardware does not only have the FIFO, it also has a shift register which can hold a byte. This can be seen, when writing a byte to the FIFO (while the SPI hardware is stopped,) the TX FIFO EMPTY is still empty. So, if we have a FIFO size of 16 for example, the current method returns a 17.
This is a problem, at least when using the driver in irq mode. The same size determined for the TX FIFO is also assumed for the RX FIFO. When a SPI transaction wants to write the amount of the FIFO size or more bytes, the following happens, for example with 16 bytes FIFO size:
The driver stops the SPI hardware and writes 17 bytes to the TX FIFO and starts the SPI hardware and goes sleep.
The hardware then shifts out 17 bytes (FIFO + shift register) and simultaneously reads bytes into the RX FIFO, but it only has 16 places, so it looses one byte. Then TX FIFO empty asserts, wakes the driver again, which has a fast path and reads 16 bytes from the RX FIFO, but before reading the last 17th byte (which is lost) it does this:
sr = xspi->read_fn(xspi->regs + XSPI_SR_OFFSET);
if (!(sr & XSPI_SR_RX_EMPTY_MASK)) {
xilinx_spi_rx(xspi);
rx_words--;
}It reads the status register and checks if the RX FIFO is not empty. But it is empty in our case. So this check spins in a while loop forever locking the driver.
This patch fixes the logic to determine the FIFO size.
--- drivers/spi/spi-xilinx.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/spi/spi-xilinx.c +9 -2
@@ -371,11 +371,18 @@ static int xilinx_spi_find_buffer_size(struct xilinx_spi *xspi) xspi->regs + XIPIF_V123B_RESETR_OFFSET);/* Fill the Tx FIFO with as many words as possible */ -do { +while (1 ) { xspi->write_fn (0 , xspi->regs +XSPI_TXD_OFFSET ); sr = xspi->read_fn (xspi->regs +XSPI_SR_OFFSET ); +if (sr &XSPI_SR_TX_FULL_MASK ) +break ; + n_words++; - }while (!(sr &XSPI_SR_TX_FULL_MASK )); + } + +/* Handle the NO FIFO case separately */ +if (!n_words) +return 1 ;return n_words; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 499/1611 iommu: Avoid copying the user array twice in the full-array copy helper
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicolin Chen <[email protected]>
[ Upstream commit e28bee5b445178390d63f7a93a5a219063c6434e ]
iommu_copy_struct_from_full_user_array() copies a whole user array into a kernel buffer. In the common case, where user entry_len equals destination entry size, it takes a fast path and copies the whole array with a single copy_from_user().
That fast path does not return, so it falls through into the item-by-item copy_struct_from_user() loop and copies every entry a second time. For an equal entry_len that loop is just a copy_from_user() of the same bytes, so the whole array is copied twice for no benefit.
Return right after the bulk copy. The per-item loop then runs only on the slow path, where entry_len differs and each entry needs size adaption.
--- include/linux/iommu.h | 1 + 1 file changed, 1 insertion(+)
include/linux/iommu.h +1 -0
@@ -544,6 +544,7 @@ iommu_copy_struct_from_full_user_array(void *kdst, size_t kdst_entry_size, user_array->entry_num * user_array->entry_len)) return -EFAULT; +return 0 ; }/* Copy item by item */
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 500/1611 ASoC: adau1372: Clear PLL_EN on failed PLL lock without reset GPIO
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guangshuo Li <[email protected]>
[ Upstream commit 69b4141b428bcf2cf7a863950c0d6e5c5ae89ac1 ]
The PLL lock failure path in adau1372_set_power() unwinds by putting the regmap back in cache-only mode, asserting the optional power-down GPIO and disabling mclk.
adau1372_enable_pll() enables CLK_CTRL.PLL_EN before polling the PLL lock bit. If the lock fails on a board without a power-down GPIO, the error path disables mclk and returns an error, but leaves PLL_EN set in the hardware register. The normal power-off path already handles the no-GPIO case by explicitly clearing PLL_EN.
Mirror that cleanup in the PLL lock failure path and clear PLL_EN while the regmap is still live, before switching it back to cache-only mode.
--- sound/soc/codecs/adau1372.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/soc/codecs/adau1372.c +5 -0
@@ -813,6 +813,11 @@ static int adau1372_set_power(struct adau1372 *adau1372, bool enable)if (adau1372->use_pll) { ret =adau1372_enable_pll (adau1372);if (ret) { +if (!adau1372->pd_gpio) +regmap_update_bits (adau1372->regmap, +ADAU1372_REG_CLK_CTRL , +ADAU1372_CLK_CTRL_PLL_EN , +0 );regcache_cache_only (adau1372->regmap, true);if (adau1372->pd_gpio)gpiod_set_value (adau1372->pd_gpio,1 );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 501/1611 power: supply: core: fix supplied_from allocations
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lucas Tsai <[email protected]>
[ Upstream commit ba61aed9a34671222d1149acfc2f0179a9ce7e80 ]
If dts property power-supplies has multiple values, then accessing to psy->supplied_from[i-1] in __power_supply_populate_supplied_from will overrun supplied_from array.
--- drivers/power/supply/power_supply_core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/power/supply/power_supply_core.c +3 -8
@@ -292,18 +292,13 @@ static int power_supply_check_supplies(struct power_supply *psy)if (cnt ==1 )return 0 ; -/* All supplies found, allocate char ** array for filling */ - psy->supplied_from =devm_kzalloc (&psy->dev,sizeof (*psy->supplied_from), +/* All supplies found, allocate char * array for filling */ + psy->supplied_from =devm_kcalloc (&psy->dev, + cnt -1 ,sizeof (*psy->supplied_from),GFP_KERNEL );if (!psy->supplied_from)return -ENOMEM ; - *psy->supplied_from =devm_kcalloc (&psy->dev, - cnt -1 ,sizeof (**psy->supplied_from), -GFP_KERNEL ); -if (!*psy->supplied_from) -return -ENOMEM ; - return power_supply_populate_supplied_from(psy); }#else
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 502/1611 handshake: Require admin permission for DONE command
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chuck Lever <[email protected]>
[ Upstream commit 81246a65303d9635266b1334490142caaf86a11f ]
ACCEPT and DONE are the two downcalls of the handshake genl family, both intended for use by the trusted handshake agent (tlshd). ACCEPT already requires GENL_ADMIN_PERM; DONE has no privilege check at all.
The fd-lookup in handshake_nl_done_doit() only confirms that some pending handshake request exists for the supplied sockfd; it does not authenticate the sender. An unprivileged process that guesses or observes a valid sockfd can therefore submit a DONE with HANDSHAKE_A_DONE_STATUS == 0, leaving the kernel consumer to proceed as if the handshake succeeded. A non-zero status on a forged DONE tears down a legitimate in-flight handshake before tlshd can report its real result.
--- Documentation/netlink/specs/handshake.yaml | 1 + net/handshake/genl.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Documentation/netlink/specs/handshake.yaml +1 -0
@@ -125,6 +125,7 @@ operations: name: done doc: Handler reports handshake completion attribute-set: done + flags: [admin-perm] do: request: attributes:
net/handshake/genl.c +1 -1
@@ -37,7 +37,7 @@ static const struct genl_split_ops handshake_nl_ops[] = { .doit = handshake_nl_done_doit, .policy = handshake_done_nl_policy, .maxattr = HANDSHAKE_A_DONE_REMOTE_AUTH, - .flags = GENL_CMD_CAP_DO, + .flags = GENL_ADMIN_PERM | GENL_CMD_CAP_DO, }, };
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 503/1611 tcp: clear sock_ops cb flags before force-closing a child socket
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sechang Lim <[email protected]>
[ Upstream commit 990348e5bb457697c2f1f7f7b65154a3334d9d2b ]
A child socket inherits the listener's bpf_sock_ops_cb_flags via sk_clone_lock(). If its setup fails in tcp_v4_syn_recv_sock() / tcp_v6_syn_recv_sock(), the child is freed through put_and_exit, where inet_csk_prepare_forced_close() drops the socket lock and tcp_done() runs without it.
If BPF_SOCK_OPS_STATE_CB_FLAG was inherited, tcp_done() -> tcp_set_state() calls tcp_call_bpf(), which expects the lock and trips sock_owned_by_me():
WARNING: include/net/sock.h:1799 at tcp_set_state+0x433/0x550 RIP: 0010:tcp_set_state+0x433/0x550 include/net/sock.h:1799 Call Trace: <IRQ> tcp_done+0xba/0x250 net/ipv4/tcp.c:5095 tcp_v4_syn_recv_sock+0x850/0xa50 net/ipv4/tcp_ipv4.c:1787 tcp_check_req+0xf30/0x1360 net/ipv4/tcp_minisocks.c:926 tcp_v4_rcv+0x1047/0x1b50 net/ipv4/tcp_ipv4.c:2164 </IRQ>
The child is freed before it is ever established, so it should run no sock_ops callback. Clear its cb flags in inet_csk_prepare_for_destroy_sock(), the common point for the IPv4, IPv6 and chtls forced-close paths and for the MPTCP ->syn_recv_sock() failure path (dispose_child), which reaches tcp_done() on a child that was never established too.
--- include/net/tcp.h | 9 +++++++++ net/ipv4/inet_connection_sock.c | 1 + 2 files changed, 10 insertions(+)
include/net/tcp.h +9 -0
@@ -2863,6 +2863,11 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2, return tcp_call_bpf(sk, op, 3, args); } +static inline void tcp_clear_sock_ops_cb_flags (struct sock *sk) +{ +tcp_sk (sk)->bpf_sock_ops_cb_flags =0 ; +} +#else static inline int tcp_call_bpf (struct sock *sk,int op,u32 nargs,u32 *args) {
@@ -2880,6 +2885,10 @@ static inline int tcp_call_bpf_3arg(struct sock *sk, int op, u32 arg1, u32 arg2, return -EPERM; } +static inline void tcp_clear_sock_ops_cb_flags (struct sock *sk) +{ +} +#endif static inline u32 tcp_timeout_init (struct sock *sk)
net/ipv4/inet_connection_sock.c +1 -0
@@ -1301,6 +1301,7 @@ EXPORT_SYMBOL(inet_csk_destroy_sock);void inet_csk_prepare_for_destroy_sock (struct sock *sk) {/* The below has to be done to allow calling inet_csk_destroy_sock */ +tcp_clear_sock_ops_cb_flags (sk);sock_set_flag (sk,SOCK_DEAD );tcp_orphan_count_inc (); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 504/1611 virtio_net: do not allow tunnel csum offload for non GSO packets
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paolo Abeni <[email protected]>
[ Upstream commit 86c51f0f23136ea5ef5541f607287e07150cd23f ]
Fiona reports broken connectivity for virtio net setup using UDP tunnel inside the guest and NIC with not UDP tunnel TSO support in the host.
Currently the virtio_net driver exposes csum offload for UDP-tunneled, TCP non GSO packets. Such packet reach the host as CSUM_PARTIAL ones with the 'encapsulation' flag cleared, as the virtio specification do not support this specific kind of offload.
HW NICs with UDP tunnel TSO support - and those drivers directly accessing skb->csum_start/csum_offset - are still capable of computing the needed csum correctly, but otherwise the packets reach the wire with bad csum on both the inner and outer transport header.
Address the issue explicitly disabling csum offload for UDP tunneled, non GSO packets via the ndo_features_check op.
--- drivers/net/virtio_net.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
drivers/net/virtio_net.c +14 -1
@@ -6280,6 +6280,19 @@ static void virtnet_free_irq_moder(struct virtnet_info *vi)rtnl_unlock (); } +static netdev_features_t virtnet_features_check (struct sk_buff *skb, +struct net_device *dev, +netdev_features_t features) +{ +/* Inner csum offload is only available for GSO packets. */ +if (skb->encapsulation && + (!skb_is_gso (skb) ||netif_needs_gso (skb, features))) +return features & ~NETIF_F_CSUM_MASK ; + +/* Passthru. */ +return features; +} +static const struct net_device_ops virtnet_netdev = { .ndo_open = virtnet_open, .ndo_stop = virtnet_close,
@@ -6293,7 +6306,7 @@ static const struct net_device_ops virtnet_netdev = { .ndo_bpf = virtnet_xdp, .ndo_xdp_xmit = virtnet_xdp_xmit, .ndo_xsk_wakeup = virtnet_xsk_wakeup, - .ndo_features_check = passthru_features_check, + .ndo_features_check = virtnet_features_check, .ndo_get_phys_port_name = virtnet_get_phys_port_name, .ndo_set_features = virtnet_set_features, .ndo_tx_timeout = virtnet_tx_timeout,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 505/1611 net/sched: sch_fq_codel: Do not call qdisc_tree_reduce_backlog during peek before restoring qlen
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 097f6fc7b1ae362dd7a9444b2572162fda73b284 ]
Whenever fq_codel drops packets during peek, it calls qdisc_tree_reduce_backlog. An issue arises because it calls qdisc_tree_reduce_backlog before it reincrements the qlen. If qlen drops to zero, but peek returns an skb, the parent's qlen_notify callback will be executed even though fq_codel still has 1 packet on the queue and, thus, will mistakenly deactivate the parent's class causing issues like a recent report [1] and a wild memory access in qfq:
[ 29.371146][ T360] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000024: 0000 [#1] SMP KASAN NOPTI [ 29.371666][ T360] KASAN: maybe wild-memory-access in range [0xdead000000000120-0xdead000000000127] [ 29.371987][ T360] CPU: 6 UID: 0 PID: 360 Comm: tc Not tainted 7.1.0-rc5-00285-gc530e5b2dbc6-dirty #82 PREEMPT(full) [ 29.372384][ T360] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 29.372620][ T360] RIP: 0010:qfq_deactivate_agg (include/linux/list.h:1029 (discriminator 2) include/linux/list.h:1043 (discriminator 2) net/sched/sch_qfq.c:1369 (discriminator 2) net/sched/sch_qfq.c:1395 (discriminator 2)) sch_qfq [ 29.373544][ T360] RSP: 0018:ffff888102417370 EFLAGS: 00010216 [ 29.373800][ T360] RAX: 0000000000000000 RBX: ffff88811224d568 RCX: dffffc0000000000 [ 29.374079][ T360] RDX: 1ffff11021fe1543 RSI: ffff88810ff0aa00 RDI: dffffc0000000000 [ 29.374368][ T360] RBP: ffff88811224c280 R08: dead000000000122 R09: 1bd5a00000000024 [ 29.374649][ T360] R10: fffffbfff7940329 R11: fffffbfff7940329 R12: 0000000000000000 [ 29.374926][ T360] R13: dead000000000100 R14: ffff88811224d580 R15: ffff88811224d578 [ 29.375207][ T360] FS: 00007f5b794e5780(0000) GS:ffff88815d1e9000(0000) knlGS:0000000000000000 [ 29.375545][ T360] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 29.375823][ T360] CR2: 000055ffb091f000 CR3: 000000010a305000 CR4: 0000000000750ef0 [ 29.376103][ T360] PKRU: 55555554 [ 29.376258][ T360] Call Trace: [ 29.376401][ T360] <TASK> ... [ 29.376885][ T360] qfq_reset_qdisc (net/sched/sch_qfq.c:357 net/sched/sch_qfq.c:1487) sch_qfq [ 29.377074][ T360] qdisc_reset (net/sched/sch_generic.c:1057) [ 29.377414][ T360] __qdisc_destroy (net/sched/sch_generic.c:1096) [ 29.377600][ T360] qdisc_graft (net/sched/sch_api.c:1062 net/sched/sch_api.c:1053 net/sched/sch_api.c:1159) [ 29.378593][ T360] tc_get_qdisc (net/sched/sch_api.c:1528 net/sched/sch_api.c:1556)
Fix this by only calling qdisc_tree_reduce_backlog in peek after the qlen is restored.
[1] http://lore.kernel.org/netdev/CAN2cbVe79oj0O9==m4+4x3v+O+qzRagA=2=wkrp9i9=CqYvyZA@mail.gmail.com/
--- net/sched/sch_fq_codel.c | 41 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
net/sched/sch_fq_codel.c +39 -2
@@ -279,7 +279,7 @@ static void drop_func(struct sk_buff *skb, void *ctx)qdisc_qstats_drop (sch); } -static struct sk_buff *fq_codel_dequeue (struct Qdisc *sch) +static struct sk_buff *__fq_codel_dequeue (struct Qdisc *sch) {struct fq_codel_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;
@@ -316,12 +316,49 @@ static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch)qdisc_bstats_update (sch, skb); flow->deficit -=qdisc_pkt_len (skb); +return skb; +} + +static void fq_codel_dequeue_drop (struct Qdisc *sch) +{ +struct fq_codel_sched_data *q =qdisc_priv (sch); +if (q->cstats.drop_count) {qdisc_tree_reduce_backlog (sch, q->cstats.drop_count, q->cstats.drop_len); q->cstats.drop_count =0 ; q->cstats.drop_len =0 ; } +} + +static struct sk_buff *fq_codel_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb; + + skb =__fq_codel_dequeue (sch); + +fq_codel_dequeue_drop (sch); + +return skb; +} + +static struct sk_buff *fq_codel_peek (struct Qdisc *sch) +{ +struct sk_buff *skb =skb_peek (&sch->gso_skb); + +if (!skb) { + skb =__fq_codel_dequeue (sch); + +if (skb) { +__skb_queue_head (&sch->gso_skb, skb); +/* it's still part of the queue */ +qdisc_qstats_backlog_inc (sch, skb); + sch->q.qlen++; + } + +fq_codel_dequeue_drop (sch); + } +return skb; }
@@ -723,7 +760,7 @@ static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { .priv_size = sizeof(struct fq_codel_sched_data), .enqueue = fq_codel_enqueue, .dequeue = fq_codel_dequeue, - .peek = qdisc_peek_dequeued, + .peek = fq_codel_peek, .init = fq_codel_init, .reset = fq_codel_reset, .destroy = fq_codel_destroy,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 506/1611 net/sched: sch_codel: Do not call qdisc_tree_reduce_backlog during peek before restoring qlen
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 52f1da34c9f4d5bdc1e8b44242da5c7ba8db85f3 ]
Whenever codel drops packets during peek, it calls qdisc_tree_reduce_backlog. An issue arises because it calls qdisc_tree_reduce_backlog before it reincrements the qlen. If qlen drops to zero, but peek returns an skb, the parent's qlen_notify callback will be executed even though codel still has 1 packet on the queue and, thus, will mistakenly deactivate the parent's class causing issues like a wild memory access when qfq has codel as a child:
[ 36.339843][ T370] Oops: general protection fault, probably for non-canonical address 0xfbd59c0000000024: 0000 [#1] SMP KASAN NOPTI [ 36.340408][ T370] KASAN: maybe wild-memory-access in range [0xdead000000000120-0xdead000000000127] [ 36.340737][ T370] CPU: 2 UID: 0 PID: 370 Comm: tc Not tainted 7.1.0-rc5-00287-g66e13b626592 #87 PREEMPT(full) [ 36.341113][ T370] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 36.341357][ T370] RIP: 0010:qfq_deactivate_agg (include/linux/list.h:1029 (discriminator 2) include/linux/list.h:1043 (discriminator 2) net/sched/sch_qfq.c:1369 (discriminator 2) net/sched/sch_qfq.c:1395 (discriminator 2)) sch_qfq [ 36.342221][ T370] RSP: 0018:ffff8881100ef370 EFLAGS: 00010216 [ 36.342422][ T370] RAX: 0000000000000000 RBX: ffff8881058a9568 RCX: dffffc0000000000 [ 36.342664][ T370] RDX: 1ffff11021064dc3 RSI: ffff888108326e00 RDI: dffffc0000000000 [ 36.342905][ T370] RBP: ffff8881058a8280 R08: dead000000000122 R09: 1bd5a00000000024 [ 36.343140][ T370] R10: fffffbfff2940329 R11: fffffbfff2940329 R12: 0000000000000000 [ 36.343383][ T370] R13: dead000000000100 R14: ffff8881058a9580 R15: ffff8881058a9578 [ 36.343631][ T370] FS: 00007fc04b0ca780(0000) GS:ffff888184fef000(0000) knlGS:0000000000000000 [ 36.343911][ T370] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 36.344116][ T370] CR2: 0000557c02c02000 CR3: 000000010e0ba000 CR4: 0000000000750ef0 [ 36.344359][ T370] PKRU: 55555554 [ 36.344481][ T370] Call Trace: ... [ 36.345054][ T370] qfq_reset_qdisc (net/sched/sch_qfq.c:357 net/sched/sch_qfq.c:1487) sch_qfq [ 36.345222][ T370] qdisc_reset (net/sched/sch_generic.c:1057) [ 36.345503][ T370] __qdisc_destroy (net/sched/sch_generic.c:1096) [ 36.345677][ T370] qdisc_graft (net/sched/sch_api.c:1062 net/sched/sch_api.c:1053 net/sched/sch_api.c:1159) [ 36.346335][ T370] tc_get_qdisc (net/sched/sch_api.c:1528 net/sched/sch_api.c:1556)
Fix this by only calling qdisc_tree_reduce_backlog in peek after the qlen is restored.
--- net/sched/sch_codel.c | 48 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-)
net/sched/sch_codel.c +43 -5
@@ -56,7 +56,7 @@ static void drop_func(struct sk_buff *skb, void *ctx)qdisc_qstats_drop (sch); } -static struct sk_buff *codel_qdisc_dequeue (struct Qdisc *sch) +static struct sk_buff *__codel_qdisc_dequeue (struct Qdisc *sch) {struct codel_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;
@@ -65,13 +65,51 @@ static struct sk_buff *codel_qdisc_dequeue(struct Qdisc *sch) &q->stats, qdisc_pkt_len, codel_get_enqueue_time, drop_func, dequeue_func); +if (skb) +qdisc_bstats_update (sch, skb); +return skb; +} + +static void codel_dequeue_drop (struct Qdisc *sch) +{ +struct codel_sched_data *q =qdisc_priv (sch); +if (q->stats.drop_count) { -qdisc_tree_reduce_backlog (sch, q->stats.drop_count, q->stats.drop_len); +qdisc_tree_reduce_backlog (sch, q->stats.drop_count, + q->stats.drop_len); q->stats.drop_count =0 ; q->stats.drop_len =0 ; } -if (skb) -qdisc_bstats_update (sch, skb); +} + +static struct sk_buff *codel_qdisc_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb; + + skb =__codel_qdisc_dequeue (sch); + +codel_dequeue_drop (sch); + +return skb; +} + +static struct sk_buff *codel_peek (struct Qdisc *sch) +{ +struct sk_buff *skb =skb_peek (&sch->gso_skb); + +if (!skb) { + skb =__codel_qdisc_dequeue (sch); + +if (skb) { +__skb_queue_head (&sch->gso_skb, skb); +/* it's still part of the queue */ +qdisc_qstats_backlog_inc (sch, skb); + sch->q.qlen++; + } + +codel_dequeue_drop (sch); + } +return skb; }
@@ -256,7 +294,7 @@ static struct Qdisc_ops codel_qdisc_ops __read_mostly = { .enqueue = codel_qdisc_enqueue, .dequeue = codel_qdisc_dequeue, - .peek = qdisc_peek_dequeued, + .peek = codel_peek, .init = codel_init, .reset = codel_reset, .change = codel_change,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 507/1611 net/sched: sch_dualpi2: Do not call qdisc_tree_reduce_backlog during peek before restoring qlen
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit 15cd0c93bf4f892d66bc7a93667e2357b5673365 ]
Whenever dualpi2 drops packets during peek, it calls qdisc_tree_reduce_backlog. An issue arises because it calls qdisc_tree_reduce_backlog before it reincrements the qlen. If qlen drops to zero, but peek returns an skb, the parent's qlen_notify callback will be executed even though dualpi2 still has 1 packet on the queue and, thus, mistakenly deactivates the parent's class which leads to a null-ptr-deref:
[ 101.427314][ T599] Oops: general protection fault, probably for non-canonical address 0xdffffc0000000009: 0000 [#1] SMP KASAN NOPTI [ 101.427755][ T599] KASAN: null-ptr-deref in range [0x0000000000000048-0x000000000000004f] [ 101.428048][ T599] CPU: 2 UID: 0 PID: 599 Comm: ping Not tainted 7.1.0-rc5-00284-gbce53c430ed7 #102 PREEMPT(full) [ 101.428400][ T599] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011 [ 101.428608][ T599] RIP: 0010:qfq_dequeue (net/sched/sch_qfq.c:1150) sch_qfq [ 101.428821][ T599] Code: 00 fc ff df 80 3c 02 00 0f 85 46 0c 00 00 4c 8d 73 48 48 89 9d b8 02 00 00 48 b8 00 00 00 00 00 fc ff df 4c 89 f2 48 c1 ea 03 <80> 3c 02 00 0f 85 2d 0c 00 00 48 b8 00 00 00 00 00 fc ff df 4c 8b All code [ 101.429348][ T599] RSP: 0018:ffff8881110df4f0 EFLAGS: 00010216 [ 101.429541][ T599] RAX: dffffc0000000000 RBX: 0000000000000000 RCX: dffffc0000000000 [ 101.429763][ T599] RDX: 0000000000000009 RSI: 00000024c0000000 RDI: ffff88811436c2b0 [ 101.429985][ T599] RBP: ffff88811436c000 R08: ffff88811436c280 R09: 1ffff11021277523 [ 101.430206][ T599] R10: 1ffff11021277526 R11: 1ffff11021277527 R12: 00000024c0000000 [ 101.430423][ T599] R13: ffff88811436c2b8 R14: 0000000000000048 R15: 0000000020000000 [ 101.430642][ T599] FS: 00007f61813e1c40(0000) GS:ffff8881691ef000(0000) knlGS:0000000000000000 [ 101.430913][ T599] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 101.431100][ T599] CR2: 00005651650850a8 CR3: 000000010ca0b000 CR4: 0000000000750ef0 [ 101.431320][ T599] PKRU: 55555554 [ 101.431433][ T599] Call Trace: [ 101.431544][ T599] <TASK> [ 101.431628][ T599] __qdisc_run (net/sched/sch_generic.c:322 net/sched/sch_generic.c:427 net/sched/sch_generic.c:445) [ 101.431792][ T599] ? dev_qdisc_enqueue (./include/trace/events/qdisc.h:49 (discriminator 22) net/core/dev.c:4176 (discriminator 22)) [ 101.431941][ T599] __dev_queue_xmit (./include/net/pkt_sched.h:120 ./include/net/pkt_sched.h:117 net/core/dev.c:4292 net/core/dev.c:4831)
Fix this by only calling qdisc_tree_reduce_backlog in peek after the qlen is restored.
--- net/sched/sch_dualpi2.c | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-)
net/sched/sch_dualpi2.c +39 -2
@@ -579,7 +579,7 @@ static void drop_and_retry(struct dualpi2_sched_data *q, struct sk_buff *skb,qdisc_qstats_drop (sch); } -static struct sk_buff *dualpi2_qdisc_dequeue (struct Qdisc *sch) +static struct sk_buff *__dualpi2_qdisc_dequeue (struct Qdisc *sch) {struct dualpi2_sched_data *q =qdisc_priv (sch);struct sk_buff *skb;
@@ -607,12 +607,49 @@ static struct sk_buff *dualpi2_qdisc_dequeue(struct Qdisc *sch)break ; } +return skb; +} + +static void dualpi2_dequeue_drop (struct Qdisc *sch) +{ +struct dualpi2_sched_data *q =qdisc_priv (sch); +if (q->deferred_drops_cnt) {qdisc_tree_reduce_backlog (sch, q->deferred_drops_cnt, q->deferred_drops_len); q->deferred_drops_cnt =0 ; q->deferred_drops_len =0 ; } +} + +static struct sk_buff *dualpi2_qdisc_dequeue (struct Qdisc *sch) +{ +struct sk_buff *skb; + + skb =__dualpi2_qdisc_dequeue (sch); + +dualpi2_dequeue_drop (sch); + +return skb; +} + +static struct sk_buff *dualpi2_peek (struct Qdisc *sch) +{ +struct sk_buff *skb =skb_peek (&sch->gso_skb); + +if (!skb) { + skb =__dualpi2_qdisc_dequeue (sch); + +if (skb) { +__skb_queue_head (&sch->gso_skb, skb); +/* it's still part of the queue */ +qdisc_qstats_backlog_inc (sch, skb); + sch->q.qlen++; + } + +dualpi2_dequeue_drop (sch); + } +return skb; }
@@ -1165,7 +1202,7 @@ static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { .priv_size = sizeof(struct dualpi2_sched_data), .enqueue = dualpi2_qdisc_enqueue, .dequeue = dualpi2_qdisc_dequeue, - .peek = qdisc_peek_dequeued, + .peek = dualpi2_peek, .init = dualpi2_init, .destroy = dualpi2_destroy, .reset = dualpi2_reset,
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 508/1611 net: mana: initialize gdma queue id to INVALID_QUEUE_ID
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Garg <[email protected]>
[ Upstream commit 5985474e1cb4034680fac2145497a94b0860be50 ]
mana_gd_create_mana_wq_cq() leaves queue->id as 0 (from kzalloc_obj()) until mana_create_wq_obj() assigns the firmware-returned id. If creation fails before that, cleanup calls mana_gd_destroy_cq() with id 0, NULLing gc->cq_table[0] and silently breaking whichever real CQ owns that slot.
Initialize queue->id to INVALID_QUEUE_ID right after allocation, matching mana_gd_create_eq(). The existing (id >= max_num_cqs) guard then short-circuits cleanly.
--- drivers/net/ethernet/microsoft/mana/gdma_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/ethernet/microsoft/mana/gdma_main.c +2 -0
@@ -1119,6 +1119,8 @@ int mana_gd_create_mana_wq_cq(struct gdma_dev *gd,if (!queue)return -ENOMEM ; + queue->id =INVALID_QUEUE_ID ; + gmi = &queue->mem_info; err =mana_gd_alloc_memory (gc, spec->queue_size, gmi);if (err) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 509/1611 net: mana: guard TX wq object destroy with INVALID_MANA_HANDLE check
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aditya Garg <[email protected]>
[ Upstream commit f8fd56977eeea3d6939b1a9cd8bd36f1779b3ad0 ]
mana_create_txq() has several error paths (after mana_alloc_queues() or mana_create_wq_obj() failure) where tx_qp[i].tx_object stays as the INVALID_MANA_HANDLE sentinel set at allocation. mana_destroy_txq() then unconditionally calls mana_destroy_wq_obj() with (u64)-1, which firmware rejects and logs an error.
Mirror the RX-side pattern in mana_destroy_rxq() and skip the destroy when the handle is still INVALID_MANA_HANDLE.
--- drivers/net/ethernet/microsoft/mana/mana_en.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/microsoft/mana/mana_en.c +2 -1
@@ -2304,7 +2304,8 @@ static void mana_destroy_txq(struct mana_port_context *apc)netif_napi_del_locked (napi); apc->tx_qp[i].txq.napi_initialized = false; } -mana_destroy_wq_obj (apc,GDMA_SQ , apc->tx_qp[i].tx_object); +if (apc->tx_qp[i].tx_object !=INVALID_MANA_HANDLE ) +mana_destroy_wq_obj (apc,GDMA_SQ , apc->tx_qp[i].tx_object);mana_deinit_cq (apc, &apc->tx_qp[i].tx_cq);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 510/1611 net: watchdog: fix refcount tracking races
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 8eed5519e496b7a07f441a0f579cb228a33189f7 ]
Blamed commit converted the untracked dev_hold()/dev_put() calls in the watchdog code to use the tracked dev_hold_track()/dev_put_track() (which were later renamed/interfaced to netdev_hold() and netdev_put()).
By introducing dev->watchdog_dev_tracker to store the reference tracking information without adding synchronization between netdev_watchdog_up() and dev_watchdog(), it enabled the race condition where this pointer could be overwritten or freed concurrently, leading to the list corruption crash syzbot reported:
list_del corruption, ffff888114a18c00->next is NULL
kernel BUG at lib/list_debug.c:52 !
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI CPU: 1 UID: 0 PID: 91 Comm: kworker/u8:5 Not tainted syzkaller #0 PREEMPT(lazy) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/09/2026 Workqueue: events_unbound linkwatch_event RIP: 0010:__list_del_entry_valid_or_report.cold+0x22/0x2a lib/list_debug.c:52 Call Trace: <TASK> __list_del_entry_valid include/linux/list.h:132 [inline] __list_del_entry include/linux/list.h:246 [inline] list_move_tail include/linux/list.h:341 [inline] ref_tracker_free+0x1a7/0x6c0 lib/ref_tracker.c:329 netdev_tracker_free include/linux/netdevice.h:4491 [inline] netdev_put include/linux/netdevice.h:4508 [inline] netdev_put include/linux/netdevice.h:4504 [inline] netdev_watchdog_down net/sched/sch_generic.c:600 [inline] dev_deactivate_many+0x28c/0xfe0 net/sched/sch_generic.c:1363 dev_deactivate+0x109/0x1d0 net/sched/sch_generic.c:1397 linkwatch_do_dev net/core/link_watch.c:184 [inline] linkwatch_do_dev+0xd3/0x120 net/core/link_watch.c:166 __linkwatch_run_queue+0x3a5/0x810 net/core/link_watch.c:240 linkwatch_event+0x8f/0xc0 net/core/link_watch.c:314 process_one_work+0xa0e/0x1980 kernel/workqueue.c:3314 process_scheduled_works kernel/workqueue.c:3397 [inline] worker_thread+0x5ef/0xe50 kernel/workqueue.c:3478 kthread+0x370/0x450 kernel/kthread.c:436 ret_from_fork+0x69a/0xc80 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
This patch has three coordinated parts:
1) Add dev->watchdog_lock and dev->watchdog_ref_held to serialize watchdog operations.
2) Remove netdev_watchdog_up() call from netif_carrier_on():
This ensures netdev_watchdog_up() is only called from process/BH context (via linkwatch workqueue dev_activate()), allowing us to use spin_lock_bh() for synchronization.
3) Synchronize watchdog up and watchdog timer:
Protect netdev_watchdog_up() with tx_global_lock and watchdog_lock. Only allocate a new tracker in netdev_watchdog_up() if one is not already present.
In dev_watchdog(), ensure we don't release the tracker if the timer was rescheduled either by dev_watchdog() itself or concurrently by netdev_watchdog_up().
--- include/linux/netdevice.h | 4 ++++ net/core/dev.c | 3 ++- net/sched/sch_generic.c | 44 +++++++++++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 12 deletions(-)
include/linux/netdevice.h +4 -0
@@ -1949,6 +1949,8 @@ enum netdev_reg_state {* @qdisc_hash: qdisc hash table * @watchdog_timeo: Represents the timeout that is used by * the watchdog (see dev_watchdog()) +* @watchdog_lock: protect watchdog_ref_held +* @watchdog_ref_held: True if the watchdog device ref is taken. * @watchdog_timer: List of timers * * @proto_down_reason: reason a netdev interface is held down
@@ -2360,6 +2362,8 @@ struct net_device {/* These may be needed for future network-power-down code. */ struct timer_list watchdog_timer;int watchdog_timeo; +spinlock_t watchdog_lock; +bool watchdog_ref_held;u32 proto_down_reason;
net/core/dev.c +2 -1
@@ -11138,7 +11138,8 @@ static int netif_alloc_netdev_queues(struct net_device *dev)netdev_for_each_tx_queue (dev, netdev_init_one_queue,NULL );spin_lock_init (&dev->tx_global_lock); - +spin_lock_init (&dev->watchdog_lock); + dev->watchdog_ref_held = false;return 0 ; }
net/sched/sch_generic.c +33 -11
75 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 511/1611 net: ethernet: mtk_wed: fix loading WO firmware for MT7986
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhi-Jun You <[email protected]>
[ Upstream commit 9192a18f6de2f5e3eb3813ecd2895ac0f5c008a9 ]
MT7986 requires a different mask for second WO firmware. Without this, WO would timeout after loading FW.
The correct mask was removed when adding WED for MT7988. Add it back and add a WED version check to fix it.
This can be reproduced with a MT7986 + MT7916 board.
--- drivers/net/ethernet/mediatek/mtk_wed_mcu.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_mcu.c +6 -2
@@ -367,8 +367,12 @@ mtk_wed_mcu_load_firmware(struct mtk_wed_wo *wo)/* wo firmware reset */ wo_w32 (MTK_WO_MCU_CFG_LS_WF_MCCR_CLR_ADDR ,0xc00 ); - val =wo_r32 (MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR ) | -MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK ; + val =wo_r32 (MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR ); + +if (!mtk_wed_is_v3_or_greater (wo->hw) && wo->hw->index) + val |=MTK_WO_MCU_CFG_LS_WF_WM_WA_WA_CPU_RSTB_MASK ; +else + val |=MTK_WO_MCU_CFG_LS_WF_WM_WA_WM_CPU_RSTB_MASK ;wo_w32 (MTK_WO_MCU_CFG_LS_WF_MCU_CFG_WM_WA_ADDR , val); out:release_firmware (fw);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 512/1611 net/sched: sch_dualpi2: Add missing module alias
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Victor Nogueira <[email protected]>
[ Upstream commit ee1ba0add3fbd5a28fa5423be373acd147f1e344 ]
When a qdisc is added by name, the kernel tries to autoload its module via request_qdisc_module(), which calls:
request_module(NET_SCH_ALIAS_PREFIX "%s", name);
i.e. it asks modprobe to resolve the "net-sch-<kind>" alias (e.g. "net-sch-dualpi2") rather than the module's file name. Since dualpi2 was shipped without this alias, the autoload fails:
tc qdisc add dev lo root handle 1: dualpi2
Error: Specified qdisc kind is unknown.
Fix this by adding the missing alias so the qdisc is autoloaded on demand like the others.
--- net/sched/sch_dualpi2.c | 1 + 1 file changed, 1 insertion(+)
net/sched/sch_dualpi2.c +1 -0
@@ -1211,6 +1211,7 @@ static struct Qdisc_ops dualpi2_qdisc_ops __read_mostly = { .dump_stats = dualpi2_dump_stats, .owner = THIS_MODULE, }; +MODULE_ALIAS_NET_SCH ("dualpi2" );static int __init dualpi2_module_init (void ) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 513/1611 bpf: Run generic devmap egress prog on private skb
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sun Jian <[email protected]>
[ Upstream commit 6001896f00984d317fb75160ba05c4a885fbe2a0 ]
Generic XDP devmap multi redirect uses skb_clone() for intermediate destinations and sends the last destination with the original skb. This can leave multiple destinations sharing the same packet data.
This becomes visible after generic devmap egress-program support was
added: a devmap egress program may mutate packet data, and another destination sharing the same data can observe that mutation.
Native XDP broadcast redirect does not have this issue because xdpf_clone() copies the frame data for each destination. Generic XDP should provide the same per-destination isolation before running a devmap egress program.
Fix this by making cloned skbs private before running the generic devmap egress program. Use skb_copy() instead of skb_unshare() so allocation failure does not consume the skb and the existing caller error paths keep their ownership semantics.
--- kernel/bpf/devmap.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
kernel/bpf/devmap.c +12 -0
@@ -710,6 +710,18 @@ int dev_map_generic_redirect(struct bpf_dtab_netdev *dst, struct sk_buff *skb,if (unlikely (err))return err; +if (dst->xdp_prog &&skb_cloned (skb)) { +struct sk_buff *nskb; + + nskb =skb_copy (skb,GFP_ATOMIC ); +if (!nskb) +return -ENOMEM ; + + nskb->mac_len = skb->mac_len; +consume_skb (skb); + skb = nskb; + } +/* Redirect has already succeeded semantically at this point, so we just * return 0 even if packet is dropped. Helper below takes care of * freeing skb.
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 514/1611 net/mlx5: Check max_macs devlink param value against max capability
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dragos Tatulea <[email protected]>
[ Upstream commit d7b0413b35715d7b32cb12d4d424613eff85ed2b ]
The max_macs devlink param is checked against the FW max value only at param register time (driver load) and inside the validate callback (devlink param set). The stored DRIVERINIT value persists across FW resets and devlink reloads without any further checks against the max.
If the FW link type changes from Ethernet to IB and a FW reset happens, the MAX cap for log_max_current_uc_list will become zero, but the previously stored max_macs value remains and is unconditionally programmed into the HCA caps in handle_hca_cap(). FW will then return a syndrome during SET_HCA_CAP:
mlx5_cmd_out_err:839:(pid 3831): SET_HCA_CAP(0x109) op_mod(0x0) failed, status bad parameter(0x3), syndrome (0x537801), err(-22) set_hca_cap:907:(pid 3831): handle_hca_cap failed
This results in a failure to register the RDMA device.
This patch skips programming log_max_current_uc_list when the MAX capability is 0 (in case of IB).
--- drivers/net/ethernet/mellanox/mlx5/core/main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/main.c +7 -5
@@ -580,7 +580,6 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx) {struct mlx5_profile *prof = &dev->profile;void *set_hca_cap; -int max_uc_list;int err; err =mlx5_core_get_caps (dev,MLX5_CAP_GENERAL );
@@ -663,10 +662,13 @@ static int handle_hca_cap(struct mlx5_core_dev *dev, void *set_ctx)MLX5_SET (cmd_hca_cap, set_hca_cap, roce,mlx5_is_roce_on (dev)); - max_uc_list =max_uc_list_get_devlink_param (dev); -if (max_uc_list >0 ) -MLX5_SET (cmd_hca_cap, set_hca_cap, log_max_current_uc_list, -ilog2 (max_uc_list)); +if (MLX5_CAP_GEN_MAX (dev, log_max_current_uc_list)) { +int max_uc_list =max_uc_list_get_devlink_param (dev); + +if (max_uc_list >0 ) +MLX5_SET (cmd_hca_cap, set_hca_cap, + log_max_current_uc_list,ilog2 (max_uc_list)); + }/* enable absolute native port num */ if (MLX5_CAP_GEN_MAX (dev, abs_native_port_num))
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 515/1611 bpf: Fix setting retval to -EPERM for cgroup hooks not returning errno
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xu Kuohai <[email protected]>
[ Upstream commit 4c71303c837449158815c521fcee4ec3b8721dbd ]
When a cgroup BPF program exits with 0, bpf_prog_run_array_cg() sets the hook return value to -EPERM if it is not a valid errno. This is correct for errno-based hooks, which return 0 on success and negative errno on failure, but wrong for boolean and void LSM hooks. Boolean LSM hooks should only return true or false, and void LSM hooks have no return value at all.
Fix it by skipping setting -EPERM for hooks not returning errno.
--- include/linux/bpf_lsm.h | 6 ++++++ kernel/bpf/bpf_lsm.c | 20 ++++++++++++++++++ kernel/bpf/cgroup.c | 47 +++++++++++++++++++++++++++++------------ 3 files changed, 60 insertions(+), 13 deletions(-)
include/linux/bpf_lsm.h +6 -0
@@ -52,6 +52,7 @@ int bpf_set_dentry_xattr_locked(struct dentry *dentry, const char *name__str, const struct bpf_dynptr *value_p, int flags);int bpf_remove_dentry_xattr_locked (struct dentry *dentry,const char *name__str);bool bpf_lsm_has_d_inode_locked (const struct bpf_prog *prog); +bool bpf_lsm_hook_returns_errno (u32 btf_id);#else /* !CONFIG_BPF_LSM */
@@ -104,6 +105,11 @@ static inline bool bpf_lsm_has_d_inode_locked(const struct bpf_prog *prog) {return false; } + +static inline bool bpf_lsm_hook_returns_errno (u32 btf_id) +{ +return true; +}#endif /* CONFIG_BPF_LSM */ #endif /* _LINUX_BPF_LSM_H */
kernel/bpf/bpf_lsm.c +20 -0
@@ -421,6 +421,26 @@ BTF_ID(func, bpf_lsm_audit_rule_known) BTF_ID(func, bpf_lsm_inode_xattr_skipcap)BTF_SET_END (bool_lsm_hooks) +/* hooks returning void */ +#define LSM_HOOK_void (DEFAULT ,NAME , ...) BTF_ID(func, bpf_lsm_##NAME) +#define LSM_HOOK_int (DEFAULT ,NAME , ...)/* nothing */ +#define LSM_HOOK (RET ,DEFAULT ,NAME , ...) LSM_HOOK_##RET(DEFAULT, NAME, __VA_ARGS__) +BTF_SET_START(void_lsm_hooks) +#include <linux/lsm_hook_defs.h> +#undef LSM_HOOK +#undef LSM_HOOK_void +#undef LSM_HOOK_int +BTF_SET_END (void_lsm_hooks) + +bool bpf_lsm_hook_returns_errno(u32 btf_id) +{ +if (btf_id_set_contains (&bool_lsm_hooks, btf_id)) +return false; +if (btf_id_set_contains (&void_lsm_hooks, btf_id)) +return false; +return true; +} +int bpf_lsm_get_retval_range (const struct bpf_prog *prog,struct bpf_retval_range *retval_range) {
kernel/bpf/cgroup.c +34 -13
78 lines not on this page · raw message
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 516/1611 octeontx2-af: npc: Fix size of entry2cntr_map
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ratheesh Kannoth <[email protected]>
[ Upstream commit f9cd6fabe0e7c7f6fc30c6c192c7ed72aba37232 ]
KASAN prints below splat. This is caused by allocating counter for reserved mcam entry for cpt 2nd pass entry. But mcam->entry2cntr_map is not allocated for reserved entries.
BUG: KASAN: slab-out-of-bounds in npc_map_mcam_entry_and_cntr+0xb0/0x1a0 Write of size 2 at addr ffff0001033e7ffe by task kworker/0:1/14 CPU: 0 PID: 14 Comm: kworker/0:1 Not tainted 6.1.67 #1 Hardware name: Marvell CN106XX board (DT) Workqueue: events work_for_cpu_fn Call trace: dump_backtrace.part.0+0xe4/0xf0 show_stack+0x18/0x30 dump_stack_lvl+0x88/0xb4 print_report+0x154/0x458 kasan_report+0xb8/0x194 __asan_store2+0x7c/0xa0 npc_map_mcam_entry_and_cntr+0xb0/0x1a0 rvu_mbox_handler_npc_mcam_write_entry+0x268/0x280 npc_install_flow+0x840/0xfe0 rvu_npc_install_cpt_pass2_entry+0x138/0x190 rvu_nix_init+0x148c/0x2880 rvu_probe+0x1800/0x30b0 local_pci_probe+0x78/0xe0 work_for_cpu_fn+0x30/0x50 process_one_work+0x4cc/0x97c worker_thread+0x360/0x630 kthread+0x1a0/0x1b0 ret_from_fork+0x10/0x20
--- .../ethernet/marvell/octeontx2/af/rvu_npc.c | 40 +++++++------------ 1 file changed, 15 insertions(+), 25 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c +15 -25
@@ -1921,7 +1921,7 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)/* Alloc memory for MCAM entry to counter mapping and for tracking * counter's reference count. */ - mcam->entry2cntr_map =kcalloc (mcam->bmap_entries,sizeof (u16), + mcam->entry2cntr_map =kcalloc (mcam->total_entries,sizeof (u16),GFP_KERNEL );if (!mcam->entry2cntr_map) goto free_cntr_map;
@@ -1937,10 +1937,11 @@ int npc_mcam_rsrcs_init(struct rvu *rvu, int blkaddr)if (!mcam->entry2target_pffunc) goto free_cntr_refcnt; -for (index =0 ; index < mcam->bmap_entries; index++) { +for (index =0 ; index < mcam->bmap_entries; index++) mcam->entry2pfvf_map[index] =NPC_MCAM_INVALID_MAP ; + +for (index =0 ; index < mcam->total_entries; index++) mcam->entry2cntr_map[index] =NPC_MCAM_INVALID_MAP ; - }for (cntr =0 ; cntr < mcam->counters.max; cntr++) mcam->cntr2pfvf_map[cntr] =NPC_MCAM_INVALID_MAP ;
@@ -3090,7 +3091,7 @@ static int __npc_mcam_free_counter(struct rvu *rvu, struct msg_rsp *rsp) {struct npc_mcam *mcam = &rvu->hw->mcam; -u16 index, entry =0 ; +u16 index;int blkaddr, err; blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 );
@@ -3106,20 +3107,16 @@ static int __npc_mcam_free_counter(struct rvu *rvu, mcam->cntr2pfvf_map[req->cntr] =NPC_MCAM_INVALID_MAP ;rvu_free_rsrc (&mcam->counters, req->cntr); -/* Disable all MCAM entry's stats which are using this counter */ -while (entry < mcam->bmap_entries) { +/* Disable all MCAM entry's stats which are using this counter. +* Scan the full MCAM index range: AF-reserved rules (e.g. CPT pass-2) +*/ +for (index =0 ; index < mcam->total_entries; index++) {if (!mcam->cntr_refcnt[req->cntr])break ; - - index =find_next_bit (mcam->bmap, mcam->bmap_entries, entry); -if (index >= mcam->bmap_entries) -break ; - entry = index +1 ;if (mcam->entry2cntr_map[index] != req->cntr)continue ; - -npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, - index, req->cntr); +npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, index, + req->cntr); }return 0 ;
@@ -3186,7 +3183,7 @@ int rvu_mbox_handler_npc_mcam_unmap_counter(struct rvu *rvu, struct npc_mcam_unmap_counter_req *req, struct msg_rsp *rsp) { struct npc_mcam *mcam = &rvu->hw->mcam; -u16 index, entry =0 ; +u16 index;int blkaddr, rc; blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPC ,0 );
@@ -3209,20 +3206,13 @@ int rvu_mbox_handler_npc_mcam_unmap_counter(struct rvu *rvu, }/* Disable all MCAM entry's stats which are using this counter */ -while (entry < mcam->bmap_entries) { +for (index =0 ; index < mcam->total_entries; index++) {if (!mcam->cntr_refcnt[req->cntr])break ; - - index =find_next_bit (mcam->bmap, mcam->bmap_entries, entry); -if (index >= mcam->bmap_entries) -break ; - entry = index +1 ; -if (mcam->entry2cntr_map[index] != req->cntr)continue ; - -npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, - index, req->cntr); +npc_unmap_mcam_entry_and_cntr (rvu, mcam, blkaddr, index, + req->cntr); } exit:mutex_unlock (&mcam->lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 517/1611 net: ethernet: mtk_wed: debugfs: correct index in wed_amsdu_show()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wentao Guan <[email protected]>
[ Upstream commit 14a8bc41ce9edae42d56466063a7f2c84a16c45c ]
WED_MON_AMSDU_ENG_CNT point to different entry by 'base+n*offset' mode, correct the wed amsdu entry number in wed_amsdu_show().
--- drivers/net/ethernet/mediatek/mtk_wed_debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_debugfs.c +3 -3
@@ -310,9 +310,9 @@ wed_amsdu_show(struct seq_file *s, void *data) WED_AMSDU_ENG_MAX_QGPP_CNT),DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (1 ),WED_AMSDU_ENG_CUR_ENTRY ), -DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (2 ), +DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (1 ),WED_AMSDU_ENG_MAX_BUF_MERGED ), -DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (2 ), +DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (1 ),WED_AMSDU_ENG_MAX_MSDU_MERGED ), DUMP_STR("WED AMDSU ENG2 INFO"),
@@ -414,7 +414,7 @@ wed_amsdu_show(struct seq_file *s, void *data) WED_AMSDU_ENG_CUR_ENTRY),DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (7 ),WED_AMSDU_ENG_MAX_BUF_MERGED ), -DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (4 ), +DUMP_WED_MASK (WED_MON_AMSDU_ENG_CNT9 (7 ),WED_AMSDU_ENG_MAX_MSDU_MERGED ), DUMP_STR("WED AMDSU ENG8 INFO"),
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 518/1611 net: wwan: t7xx: check skb_clone in control TX
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ruoyu Wang <[email protected]>
[ Upstream commit 05f789fa90d95d5771230e78453cedff2486039d ]
t7xx_port_ctrl_tx() clones each skb fragment before passing it to the port transmit path. The clone is used immediately to set cloned->len, so an skb_clone() failure results in a NULL pointer dereference.
Check the clone before using it. If previous fragments were already queued, preserve the driver's existing partial-write behavior by returning the number of bytes submitted so far.
--- drivers/net/wwan/t7xx/t7xx_port_wwan.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/wwan/t7xx/t7xx_port_wwan.c +2 -0
@@ -106,6 +106,8 @@ static int t7xx_port_ctrl_tx(struct t7xx_port *port, struct sk_buff *skb)while (cur) { cloned =skb_clone (cur,GFP_KERNEL ); +if (!cloned) +return cnt ? cnt : -ENOMEM ; cloned->len =skb_headlen (cur); ret =t7xx_port_send_skb (port, cloned,0 ,0 );if (ret) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 519/1611 dpll: Support dynamic pin index allocation
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Vecera <[email protected]>
[ Upstream commit 711696b3e168cea4165e7b7f051f3f442a347430 ]
Allow drivers to register DPLL pins without manually specifying a pin index.
Currently, drivers must provide a unique pin index when calling dpll_pin_get(). This works well for hardware-mapped pins but creates friction for drivers handling virtual pins or those without a strict hardware indexing scheme.
Introduce DPLL_PIN_IDX_UNSPEC (U32_MAX). When a driver passes this value as the pin index:
1. The core allocates a unique index using an IDA
2. The allocated index is mapped to a range starting above INT_MAX
This separation ensures that dynamically allocated indices never collide with standard driver-provided hardware indices, which are assumed to be within the 0 to INT_MAX range. The index is automatically freed when the pin is released in dpll_pin_put().
Stable-dep-of: 32239d600236 ("dpll: fix stale iteration in dpll_pin_on_pin_unregister()")
--- drivers/dpll/dpll_core.c | 48 ++++++++++++++++++++++++++++++++++++++-- include/linux/dpll.h | 2 ++ 2 files changed, 48 insertions(+), 2 deletions(-)
drivers/dpll/dpll_core.c +46 -2
@@ -10,6 +10,7 @@#include <linux/device.h> #include <linux/err.h> +#include <linux/idr.h> #include <linux/property.h> #include <linux/slab.h> #include <linux/string.h>
@@ -24,6 +25,7 @@ DEFINE_XARRAY_FLAGS(dpll_device_xa, XA_FLAGS_ALLOC);DEFINE_XARRAY_FLAGS (dpll_pin_xa,XA_FLAGS_ALLOC );static RAW_NOTIFIER_HEAD (dpll_notifier_chain); +static DEFINE_IDA (dpll_pin_idx_ida);static u32 dpll_device_xa_id;static u32 dpll_pin_xa_id;
@@ -464,6 +466,36 @@ void dpll_device_unregister(struct dpll_device *dpll, }EXPORT_SYMBOL_GPL (dpll_device_unregister); +static int dpll_pin_idx_alloc (u32 *pin_idx) +{ +int ret; + +if (!pin_idx) +return -EINVAL ; + +/* Alloc unique number from IDA. Number belongs to <0, INT_MAX> range */ + ret =ida_alloc (&dpll_pin_idx_ida,GFP_KERNEL ); +if (ret <0 ) +return ret; + +/* Map the value to dynamic pin index range <INT_MAX+1, U32_MAX> */ + *pin_idx = (u32 )ret +INT_MAX +1 ; + +return 0 ; +} + +static void dpll_pin_idx_free (u32 pin_idx) +{ +if (pin_idx <=INT_MAX ) +return ;/* Not a dynamic pin index */ + +/* Map the index value from dynamic pin index range to IDA range and +* free it. +*/ + pin_idx -= (u32 )INT_MAX +1 ; +ida_free (&dpll_pin_idx_ida, pin_idx); +} +static void dpll_pin_prop_free (struct dpll_pin_properties *prop) {kfree (prop->package_label);
@@ -521,9 +553,18 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,struct dpll_pin *pin;int ret; +if (pin_idx ==DPLL_PIN_IDX_UNSPEC ) { + ret =dpll_pin_idx_alloc (&pin_idx); +if (ret) +return ERR_PTR (ret); + }else if (pin_idx >INT_MAX ) { +return ERR_PTR (-EINVAL ); + } pin =kzalloc (sizeof (*pin),GFP_KERNEL ); -if (!pin) -return ERR_PTR (-ENOMEM ); +if (!pin) { + ret = -ENOMEM ; + goto err_pin_alloc; + } pin->pin_idx = pin_idx; pin->clock_id = clock_id; pin->module = module;
@@ -551,6 +592,8 @@ dpll_pin_alloc(u64 clock_id, u32 pin_idx, struct module *module,dpll_pin_prop_free (&pin->prop); err_pin_prop:kfree (pin); +err_pin_alloc: +dpll_pin_idx_free (pin_idx);return ERR_PTR (ret); }
@@ -654,6 +697,7 @@ void dpll_pin_put(struct dpll_pin *pin)xa_destroy (&pin->ref_sync_pins);dpll_pin_prop_free (&pin->prop);fwnode_handle_put (pin->fwnode); +dpll_pin_idx_free (pin->pin_idx);kfree_rcu (pin, rcu); }mutex_unlock (&dpll_lock);
include/linux/dpll.h +2 -0
@@ -235,6 +235,8 @@ int dpll_device_register(struct dpll_device *dpll, enum dpll_type type,void dpll_device_unregister (struct dpll_device *dpll,const struct dpll_device_ops *ops,void *priv); +#define DPLL_PIN_IDX_UNSPEC U32_MAX +struct dpll_pin *dpll_pin_get (u64 clock_id,u32 dev_driver_id,struct module *module,const struct dpll_pin_properties *prop);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 520/1611 dpll: Enhance and consolidate reference counting logic
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Vecera <[email protected]>
[ Upstream commit 729f5e0153bda8c0423fb7c5795865b6b77ca050 ]
Refactor the reference counting mechanism for DPLL devices and pins to improve consistency and prevent potential lifetime issues.
Introduce internal helpers __dpll_{device,pin}_{hold,put}() to centralize reference management.
Update the internal XArray reference helpers (dpll_xa_ref_*) to automatically grab a reference to the target object when it is added to a list, and release it when removed. This ensures that objects linked internally (e.g., pins referenced by parent pins) are properly kept alive without relying on the caller to manually manage the count.
Consequently, remove the now redundant manual refcount_inc/dec calls in dpll_pin_on_pin_{,un}register()`, as ownership is now correctly handled by the dpll_xa_ref_* functions.
Additionally, ensure that dpll_device_{,un}register()` takes/releases a reference to the device, ensuring the device object remains valid for the duration of its registration.
Stable-dep-of: 32239d600236 ("dpll: fix stale iteration in dpll_pin_on_pin_unregister()")
--- drivers/dpll/dpll_core.c | 74 +++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 24 deletions(-)
drivers/dpll/dpll_core.c +50 -24
@@ -83,6 +83,45 @@ void dpll_pin_notify(struct dpll_pin *pin, unsigned long action)call_dpll_notifiers (action, &info); } +static void __dpll_device_hold (struct dpll_device *dpll) +{ +refcount_inc (&dpll->refcount); +} + +static void __dpll_device_put (struct dpll_device *dpll) +{ +if (refcount_dec_and_test (&dpll->refcount)) { +ASSERT_DPLL_NOT_REGISTERED (dpll); +WARN_ON_ONCE (!xa_empty (&dpll->pin_refs)); +xa_destroy (&dpll->pin_refs); +xa_erase (&dpll_device_xa, dpll->id); +WARN_ON (!list_empty (&dpll->registration_list)); +kfree (dpll); + } +} + +static void __dpll_pin_hold (struct dpll_pin *pin) +{ +refcount_inc (&pin->refcount); +} + +static void dpll_pin_idx_free (u32 pin_idx); +static void dpll_pin_prop_free (struct dpll_pin_properties *prop); + +static void __dpll_pin_put (struct dpll_pin *pin) +{ +if (refcount_dec_and_test (&pin->refcount)) { +xa_erase (&dpll_pin_xa, pin->id); +xa_destroy (&pin->dpll_refs); +xa_destroy (&pin->parent_refs); +xa_destroy (&pin->ref_sync_pins); +dpll_pin_prop_free (&pin->prop); +fwnode_handle_put (pin->fwnode); +dpll_pin_idx_free (pin->pin_idx); +kfree_rcu (pin, rcu); + } +} +struct dpll_device *dpll_device_get_by_id (int id) {if (xa_get_mark (&dpll_device_xa, id,DPLL_REGISTERED ))
@@ -152,6 +191,7 @@ dpll_xa_ref_pin_add(struct xarray *xa_pins, struct dpll_pin *pin, reg->ops = ops; reg->priv = priv; reg->cookie = cookie; +__dpll_pin_hold (pin);if (ref_exists)refcount_inc (&ref->refcount);list_add_tail (®->list, &ref->registration_list);
@@ -174,6 +214,7 @@ static int dpll_xa_ref_pin_del(struct xarray *xa_pins, struct dpll_pin *pin,if (WARN_ON (!reg))return -EINVAL ;list_del (®->list); +__dpll_pin_put (pin);kfree (reg);if (refcount_dec_and_test (&ref->refcount)) {xa_erase (xa_pins, i);
@@ -231,6 +272,7 @@ dpll_xa_ref_dpll_add(struct xarray *xa_dplls, struct dpll_device *dpll, reg->ops = ops; reg->priv = priv; reg->cookie = cookie; +__dpll_device_hold (dpll);if (ref_exists)refcount_inc (&ref->refcount);list_add_tail (®->list, &ref->registration_list);
@@ -253,6 +295,7 @@ dpll_xa_ref_dpll_del(struct xarray *xa_dplls, struct dpll_device *dpll,if (WARN_ON (!reg))return ;list_del (®->list); +__dpll_device_put (dpll);kfree (reg);if (refcount_dec_and_test (&ref->refcount)) {xa_erase (xa_dplls, i);
@@ -323,8 +366,8 @@ dpll_device_get(u64 clock_id, u32 device_idx, struct module *module)if (dpll->clock_id == clock_id && dpll->device_idx == device_idx && dpll->module == module) { +__dpll_device_hold (dpll); ret = dpll; -refcount_inc (&ret->refcount);break ; } }
@@ -347,14 +390,7 @@ EXPORT_SYMBOL_GPL(dpll_device_get);void dpll_device_put (struct dpll_device *dpll) {mutex_lock (&dpll_lock); -if (refcount_dec_and_test (&dpll->refcount)) { -ASSERT_DPLL_NOT_REGISTERED (dpll); -WARN_ON_ONCE (!xa_empty (&dpll->pin_refs)); -xa_destroy (&dpll->pin_refs); -xa_erase (&dpll_device_xa, dpll->id); -WARN_ON (!list_empty (&dpll->registration_list)); -kfree (dpll); - } +__dpll_device_put (dpll);mutex_unlock (&dpll_lock); }EXPORT_SYMBOL_GPL (dpll_device_put);
@@ -416,6 +452,7 @@ int dpll_device_register(struct dpll_device *dpll, enum dpll_type type, reg->ops = ops; reg->priv = priv; dpll->type = type; +__dpll_device_hold (dpll); first_registration =list_empty (&dpll->registration_list);list_add_tail (®->list, &dpll->registration_list);if (!first_registration) {
@@ -455,6 +492,7 @@ void dpll_device_unregister(struct dpll_device *dpll,return ; }list_del (®->list); +__dpll_device_put (dpll);kfree (reg);if (!list_empty (&dpll->registration_list)) {
@@ -666,8 +704,8 @@ dpll_pin_get(u64 clock_id, u32 pin_idx, struct module *module,if (pos->clock_id == clock_id && pos->pin_idx == pin_idx && pos->module == module) { +__dpll_pin_hold (pos); ret = pos; -refcount_inc (&ret->refcount);break ; } }
@@ -690,16 +728,7 @@ EXPORT_SYMBOL_GPL(dpll_pin_get);void dpll_pin_put (struct dpll_pin *pin) {mutex_lock (&dpll_lock); -if (refcount_dec_and_test (&pin->refcount)) { -xa_erase (&dpll_pin_xa, pin->id); -xa_destroy (&pin->dpll_refs); -xa_destroy (&pin->parent_refs); -xa_destroy (&pin->ref_sync_pins); -dpll_pin_prop_free (&pin->prop); -fwnode_handle_put (pin->fwnode); -dpll_pin_idx_free (pin->pin_idx); -kfree_rcu (pin, rcu); - } +__dpll_pin_put (pin);mutex_unlock (&dpll_lock); }EXPORT_SYMBOL_GPL (dpll_pin_put);
@@ -740,8 +769,8 @@ struct dpll_pin *fwnode_dpll_pin_find(struct fwnode_handle *fwnode)mutex_lock (&dpll_lock);xa_for_each (&dpll_pin_xa, index, pin) {if (pin->fwnode == fwnode) { +__dpll_pin_hold (pin); ret = pin; -refcount_inc (&ret->refcount);break ; } }
@@ -893,7 +922,6 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin, ret =dpll_xa_ref_pin_add (&pin->parent_refs, parent, ops, priv, pin);if (ret) goto unlock; -refcount_inc (&pin->refcount);xa_for_each (&parent->dpll_refs, i, ref) { ret =__dpll_pin_register (ref->dpll, pin, ops, priv, parent);if (ret) {
@@ -913,7 +941,6 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin, parent);dpll_pin_delete_ntf (pin); } -refcount_dec (&pin->refcount);dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin); unlock:mutex_unlock (&dpll_lock);
@@ -940,7 +967,6 @@ void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,mutex_lock (&dpll_lock);dpll_pin_delete_ntf (pin);dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin); -refcount_dec (&pin->refcount);xa_for_each (&pin->dpll_refs, i, ref)__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent);mutex_unlock (&dpll_lock);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 521/1611 dpll: fix stale iteration in dpll_pin_on_pin_unregister()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit 32239d600236a986c8e6d16aa814d3d91066b244 ]
Neither parent->dpll_refs nor pin->dpll_refs on its own is a correct iteration target at unregister time:
- pin->dpll_refs includes DPLLs the child was registered against via a different parent or directly; blind unregister WARNs on the cookie miss in dpll_xa_ref_pin_del().
- parent->dpll_refs reflects the parent's current attachments, not those at child-register time. Another driver may have (un)reg'd the parent against additional DPLLs in the meantime, so we miss registrations that exist and visit DPLLs that have none.
Walk pin->dpll_refs and use dpll_pin_registration_find() to filter to entries whose cookie is this parent. Symmetric with dpll_pin_on_pin_register(), correct under any subsequent change to parent->dpll_refs.
--- drivers/dpll/dpll_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/dpll/dpll_core.c +6 -1
@@ -961,14 +961,19 @@ EXPORT_SYMBOL_GPL(dpll_pin_on_pin_register);void dpll_pin_on_pin_unregister (struct dpll_pin *parent,struct dpll_pin *pin,const struct dpll_pin_ops *ops,void *priv) { +struct dpll_pin_registration *reg;struct dpll_pin_ref *ref;unsigned long i;mutex_lock (&dpll_lock);dpll_pin_delete_ntf (pin);dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin); -xa_for_each (&pin->dpll_refs, i, ref) +xa_for_each (&pin->dpll_refs, i, ref) { + reg =dpll_pin_registration_find (ref, ops, priv, parent); +if (!reg) +continue ;__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent); + }mutex_unlock (&dpll_lock); }EXPORT_SYMBOL_GPL (dpll_pin_on_pin_unregister);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 522/1611 dpll: send delete notification before unregister in on-pin rollback
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit e83b403eb142be18d223fc599c0ac45519053671 ]
The rollback path in dpll_pin_on_pin_register() called __dpll_pin_unregister() before dpll_pin_delete_ntf(). When the unregister dropped the pin's last DPLL reference it cleared the DPLL_REGISTERED mark in dpll_pin_xa, so the subsequent dpll_pin_event_send() failed dpll_pin_available() and aborted with -ENODEV. As a result userspace was never notified of the rollback deletion and remained out of sync with the kernel.
Send the delete notification first, matching the order used by dpll_pin_unregister() and dpll_pin_on_pin_unregister().
--- drivers/dpll/dpll_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dpll/dpll_core.c +1 -1
@@ -937,9 +937,9 @@ int dpll_pin_on_pin_register(struct dpll_pin *parent, struct dpll_pin *pin, dpll_unregister:xa_for_each (&parent->dpll_refs, i, ref)if (i < stop) { +dpll_pin_delete_ntf (pin);__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent); -dpll_pin_delete_ntf (pin); }dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin); unlock:
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 523/1611 dpll: emit per-dpll delete notifications in dpll_pin_on_pin_unregister()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit df0ba51ccf873e533669578104981109217d8201 ]
dpll_pin_on_pin_register() emits a creation notification for every parent->dpll_refs entry, but dpll_pin_on_pin_unregister() emitted only one deletion notification outside the loop. When a pin is registered against multiple parent dplls, userspace sees N creates but a single delete and leaks per-dpll state.
Move dpll_pin_delete_ntf() into the loop and call it before __dpll_pin_unregister() so the DPLL_REGISTERED mark is still set when dpll_pin_available() is consulted.
--- drivers/dpll/dpll_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dpll/dpll_core.c +2 -2
@@ -966,14 +966,14 @@ void dpll_pin_on_pin_unregister(struct dpll_pin *parent, struct dpll_pin *pin,unsigned long i;mutex_lock (&dpll_lock); -dpll_pin_delete_ntf (pin); -dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin);xa_for_each (&pin->dpll_refs, i, ref) { reg =dpll_pin_registration_find (ref, ops, priv, parent);if (!reg)continue ; +dpll_pin_delete_ntf (pin);__dpll_pin_unregister (ref->dpll, pin, ops, priv, parent); } +dpll_xa_ref_pin_del (&pin->parent_refs, parent, ops, priv, pin);mutex_unlock (&dpll_lock); }EXPORT_SYMBOL_GPL (dpll_pin_on_pin_unregister);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 524/1611 dpll: guard sync-pair removal on full pin unregister
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit 0a5c720a7d57d2287d5566c4ad93ee26b7c06845 ]
__dpll_pin_unregister() wiped the global sync-pair state on every (dpll, ops, priv, cookie) tuple removed from a pin. When a pin is registered multiple times and only one registration is being torn down, this dropped sync-pair pairings still in use by the surviving registrations.
Move dpll_pin_ref_sync_pair_del() inside the xa_empty(&pin->dpll_refs) branch so it only runs when the last registration is gone, alongside clearing the DPLL_REGISTERED mark.
--- drivers/dpll/dpll_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/dpll/dpll_core.c +3 -2
@@ -856,11 +856,12 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, const struct dpll_pin_ops *ops, void *priv, void *cookie) {ASSERT_DPLL_PIN_REGISTERED (pin ); -dpll_pin_ref_sync_pair_del (pin->id);dpll_xa_ref_pin_del (&dpll->pin_refs, pin, ops, priv, cookie);dpll_xa_ref_dpll_del (&pin->dpll_refs, dpll, ops, priv, cookie); -if (xa_empty (&pin->dpll_refs)) +if (xa_empty (&pin->dpll_refs)) { +dpll_pin_ref_sync_pair_del (pin->id);xa_clear_mark (&dpll_pin_xa, pin->id,DPLL_REGISTERED ); + } }/**
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 525/1611 dpll: balance create/delete notifications in __dpll_pin_(un)register
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Grzegorz Nitka <[email protected]>
[ Upstream commit 1a2292101c0dc422466c673031de03d2e871adbe ]
__dpll_pin_register() emits dpll_pin_create_ntf() internally, but __dpll_pin_unregister() left the matching delete to its callers. The counts then diverge on dpll_pin_on_pin_register() rollback and on dpll_pin_on_pin_unregister(), leaking stale notifications.
Emit dpll_pin_delete_ntf() inside __dpll_pin_unregister() and drop the now-redundant call in dpll_pin_unregister().
--- drivers/dpll/dpll_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dpll/dpll_core.c +1 -1
@@ -856,6 +856,7 @@ __dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin, const struct dpll_pin_ops *ops, void *priv, void *cookie) {ASSERT_DPLL_PIN_REGISTERED (pin ); +dpll_pin_delete_ntf (pin);dpll_xa_ref_pin_del (&dpll->pin_refs, pin, ops, priv, cookie);dpll_xa_ref_dpll_del (&pin->dpll_refs, dpll, ops, priv, cookie);if (xa_empty (&pin->dpll_refs)) {
@@ -883,7 +884,6 @@ void dpll_pin_unregister(struct dpll_device *dpll, struct dpll_pin *pin,return ;mutex_lock (&dpll_lock); -dpll_pin_delete_ntf (pin);__dpll_pin_unregister (dpll, pin, ops, priv,NULL );mutex_unlock (&dpll_lock); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 526/1611 landlock: Fix unmarked concurrent access to socket family
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matthieu Buffet <[email protected]>
[ Upstream commit 0ce4243509d1580349dd0d50624036d6b097e958 ]
Socket family is read (twice) in a context where the socket is not locked, so another thread can setsockopt(IPV6_ADDRFORM) to write it concurrently. Add needed READ_ONCE() annotation.
Use the proper macro to access __sk_common.skc_family like everywhere else.
[mic: Squash two patches, move variable to ease backport, fix comment formatting]
--- security/landlock/net.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
security/landlock/net.c +9 -2
@@ -46,6 +46,7 @@ static int current_check_access_socket(struct socket *const sock,const int addrlen, access_mask_t access_request) { + unsigned short sock_family;__be16 port;layer_mask_t layer_masks[LANDLOCK_NUM_ACCESS_NET ] = {};const struct landlock_rule *rule;
@@ -69,6 +70,12 @@ static int current_check_access_socket(struct socket *const sock,if (addrlen <offsetofend (typeof (*address), sa_family))return -EINVAL ; +/* +* The socket is not locked, so sk_family can change concurrently due to +* e.g. setsockopt(IPV6_ADDRFORM). +*/ + sock_family =READ_ONCE (sock->sk->sk_family); +switch (address->sa_family) {case AF_UNSPEC :if (access_request ==LANDLOCK_ACCESS_NET_CONNECT_TCP ) {
@@ -105,7 +112,7 @@ static int current_check_access_socket(struct socket *const sock,* these checks, but it is safer to return a proper * error and test consistency thanks to kselftest. */ -if (sock->sk->__sk_common.skc_family ==AF_INET ) { +if (sock_family ==AF_INET ) {const struct sockaddr_in *const sockaddr = (struct sockaddr_in *)address;
@@ -183,7 +190,7 @@ static int current_check_access_socket(struct socket *const sock,* check, but it is safer to return a proper error and test * consistency thanks to kselftest. */ -if (address->sa_family != sock->sk->__sk_common.skc_family && +if (address->sa_family != sock_family && address->sa_family !=AF_UNSPEC )return -EINVAL ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 527/1611 net: bcmgenet: Use weighted round-robin TX DMA arbitration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit fd615abd53110f0f815984e99e7cc51ca6b7d979 ]
Under heavy network traffic, we observed sporadic TX queue timeouts on the Raspberry Pi 4. The timeouts can be reproduced by stress testing the TX path with multiple concurrent iperf UDP streams:
iperf3 -c <ip> -u -b0 -P16 -t60
NETDEV WATCHDOG: CPU: 0: transmit queue 0 timed out 2044 ms NETDEV WATCHDOG: CPU: 3: transmit queue 0 timed out 2004 ms
Investigation showed that the timeouts are caused by the priority-based arbiter. Under heavy load the highest priority queue starves the lower priority ones, causing timeouts. The TX strict priority arbiter is not suitable for the default use case where all the traffic gets spread across all the TX queues.
Therefore, to fix this, switch the TX DMA arbiter to Weighted Round-Robin, which services all queues, so they do not stall. The weights were chosen to follow the existing priority scheme: q0 gets the smallest weight, while q1-4 get the bulk of the TX bandwidth.
--- .../net/ethernet/broadcom/genet/bcmgenet.c | 23 +++++++------------ 1 file changed, 8 insertions(+), 15 deletions(-)
drivers/net/ethernet/broadcom/genet/bcmgenet.c +8 -15
@@ -41,9 +41,8 @@#include "bcmgenet.h" -/* Default highest priority queue for multi queue support */ -#define GENET_Q1_PRIORITY 0 -#define GENET_Q0_PRIORITY 1 +#define GENET_Q0_WEIGHT 1 +#define GENET_Q1_WEIGHT 4#define GENET_Q0_RX_BD_CNT \ (TOTAL_DESC - priv->hw_params->rx_queues * priv->hw_params->rx_bds_per_q)
@@ -2125,13 +2124,6 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev)int i; index =skb_get_queue_mapping (skb); -/* Mapping strategy: -* queue_mapping = 0, unclassified, packet xmited through ring 0 -* queue_mapping = 1, goes to ring 1. (highest priority queue) -* queue_mapping = 2, goes to ring 2. -* queue_mapping = 3, goes to ring 3. -* queue_mapping = 4, goes to ring 4. -*/ ring = &priv->tx_rings[index]; txq =netdev_get_tx_queue (dev, index);
@@ -2877,8 +2869,9 @@ static int bcmgenet_rdma_disable(struct bcmgenet_priv *priv)/* Initialize Tx queues * -* Queues 1-4 are priority-based, each one has 32 descriptors, -* with queue 1 being the highest priority queue. +* Queues 1-4 are the priority queues, each one has 32 descriptors. +* The weighted round-robin arbiter gives them a larger share of TX +* bandwidth than the default queue 0. * * Queue 0 is the default Tx queue with * GENET_Q0_TX_BD_CNT = 256 - 4 * 32 = 128 descriptors.
@@ -2896,8 +2889,8 @@ static void bcmgenet_init_tx_queues(struct net_device *dev)unsigned int start =0 , end =GENET_Q0_TX_BD_CNT ;u32 i, ring_mask, dma_priority[3 ] = {0 ,0 ,0 }; -/* Enable strict priority arbiter mode */ -bcmgenet_tdma_writel (priv,DMA_ARBITER_SP ,DMA_ARB_CTRL ); +/* Enable Weighted Round-Robin arbiter mode */ +bcmgenet_tdma_writel (priv,DMA_ARBITER_WRR ,DMA_ARB_CTRL );/* Initialize Tx priority queues */ for (i =0 ; i <= priv->hw_params->tx_queues; i++) {
@@ -2905,7 +2898,7 @@ static void bcmgenet_init_tx_queues(struct net_device *dev) start = end; end += priv->hw_params->tx_bds_per_q; dma_priority[DMA_PRIO_REG_INDEX (i)] |= - (i ?GENET_Q1_PRIORITY :GENET_Q0_PRIORITY ) + (i ?GENET_Q1_WEIGHT :GENET_Q0_WEIGHT ) <<DMA_PRIO_REG_SHIFT (i); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 528/1611 net: airoha: Fix register index for Tx-fwd counter configuration
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayen.Yan <[email protected]>
[ Upstream commit 1402ecccf5630a0b7fa4749d7d2e72abc3f3d73d ]
In airoha_qdma_init_qos_stats(), the Tx-fwd counter configuration register uses the same index (i << 1) as the Tx-cpu counter, which overwrites the Tx-cpu configuration. The Tx-fwd counter value register correctly uses (i << 1) + 1, so the configuration register should use the same index.
Fix the REG_CNTR_CFG index from (i << 1) to ((i << 1) + 1) so that the Tx-fwd counter is properly configured instead of clobbering the Tx-cpu counter config.
--- drivers/net/ethernet/airoha/airoha_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/airoha/airoha_eth.c +1 -1
@@ -1275,7 +1275,7 @@ static void airoha_qdma_init_qos_stats(struct airoha_qdma *qdma) FIELD_PREP(CNTR_CHAN_MASK, i));/* Tx-fwd transferred count */ airoha_qdma_wr (qdma,REG_CNTR_VAL ((i <<1 ) +1 ),0 ); - airoha_qdma_wr(qdma, REG_CNTR_CFG(i << 1), + airoha_qdma_wr(qdma, REG_CNTR_CFG((i << 1) + 1), CNTR_EN_MASK | CNTR_ALL_QUEUE_EN_MASK | CNTR_ALL_DSCP_RING_EN_MASK | FIELD_PREP(CNTR_SRC_MASK, 1) |
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 529/1611 net: airoha: Fix debugfs new-tuple display for IPv4 ROUTE entries
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wayen.Yan <[email protected]>
[ Upstream commit 1c3a77471afbb3981af28f7f7c8b2487558e4b00 ]
In airoha_ppe_debugfs_foe_show(), the second switch statement falls through from PPE_PKT_TYPE_IPV4_HNAPT/DSLITE to PPE_PKT_TYPE_IPV4_ROUTE, accessing hwe->ipv4.new_tuple for all three types. However, IPv4 ROUTE (3-tuple) entries do not contain a valid new_tuple — this field is only meaningful for NATted flows (HNAPT/DSLITE). For ROUTE entries, the memory at the new_tuple offset holds routing information, not NAT data, so displaying "new=" produces garbage output.
Display new_tuple only for HNAPT and DSLITE, and let IPV4_ROUTE fall through to the default case.
--- drivers/net/ethernet/airoha/airoha_ppe_debugfs.c | 2 -- 1 file changed, 2 deletions(-)
drivers/net/ethernet/airoha/airoha_ppe_debugfs.c +0 -2
@@ -121,8 +121,6 @@ static int airoha_ppe_debugfs_foe_show(struct seq_file *m, void *private,case PPE_PKT_TYPE_IPV4_DSLITE : src_port = &hwe->ipv4.new_tuple.src_port; dest_port = &hwe->ipv4.new_tuple.dest_port; - fallthrough; -case PPE_PKT_TYPE_IPV4_ROUTE : src_addr = &hwe->ipv4.new_tuple.src_ip; dest_addr = &hwe->ipv4.new_tuple.dest_ip;seq_puts (m," new=" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 530/1611 kcm: use WRITE_ONCE() when changing lower socket callbacks
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Runyu Xiao <[email protected]>
[ Upstream commit 47186409c092cd7dd70350999186c700233e854d ]
kcm_attach() replaces a live lower TCP socket's sk_data_ready and sk_write_space callbacks with KCM handlers, and kcm_unattach() restores them later. Those callback-pointer updates are still plain stores even though the same fields can be read and invoked concurrently on other CPUs.
If another CPU observes an older callback snapshot after the live field has already been restored, callback execution can run with a mismatched target and sk_user_data state, leading to stale or misdirected wakeups.
Use WRITE_ONCE() for the callback replacement and restore operations so these shared callback fields follow the same visibility contract already established by the earlier 4022 fixes.
--- net/kcm/kcmsock.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
net/kcm/kcmsock.c +4 -4
@@ -1304,8 +1304,8 @@ static int kcm_attach(struct socket *sock, struct socket *csock, psock->save_write_space = csk->sk_write_space; psock->save_state_change = csk->sk_state_change; csk->sk_user_data = psock; - csk->sk_data_ready = psock_data_ready; - csk->sk_write_space = psock_write_space; +WRITE_ONCE (csk->sk_data_ready, psock_data_ready); +WRITE_ONCE (csk->sk_write_space, psock_write_space); csk->sk_state_change = psock_state_change;write_unlock_bh (&csk->sk_callback_lock);
@@ -1381,8 +1381,8 @@ static void kcm_unattach(struct kcm_psock *psock)*/ write_lock_bh (&csk->sk_callback_lock); csk->sk_user_data =NULL ; - csk->sk_data_ready = psock->save_data_ready; - csk->sk_write_space = psock->save_write_space; +WRITE_ONCE (csk->sk_data_ready, psock->save_data_ready); +WRITE_ONCE (csk->sk_write_space, psock->save_write_space); csk->sk_state_change = psock->save_state_change;strp_stop (&psock->strp);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 531/1611 ALSA: seq: oss: Serialize readq reset state with q->lock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit 49ce92d207820f588b0406add82f053decfbe5d9 ]
snd_seq_oss_readq_clear() resets qlen, head, and tail without q->lock even though the normal reader and producer paths serialize the same ring state under that spinlock. A reset can therefore race snd_seq_oss_readq_free() or snd_seq_oss_readq_put_event() and leave stale records in the queue, drop freshly queued ones, or report the wrong readiness after wakeup. KCSAN reports a data race between snd_seq_oss_readq_clear() and snd_seq_oss_readq_free().
Take q->lock while clearing the ring and resetting input_time. Factor the enqueue logic into a caller-locked helper so snd_seq_oss_readq_put_timestamp() updates its suppression state under the same lock instead of racing the reset path.
The buggy scenario involves two paths, with each column showing the order within that path:
reset path: locked readq updater:
1. snd_seq_oss_reset() or 1. A reader or callback producer
release reaches takes q->lock on the same queue.
snd_seq_oss_readq_clear().
2. snd_seq_oss_readq_clear() 2. The updater tests or modifies
resets qlen, head, tail, qlen, head, and tail.
and input_time.
3. snd_seq_oss_readq_clear() 3. The updater completes its
wakes sleepers on read-modify-write sequence.
q->midi_sleep.
4. Without q->lock, the reset 4. The resulting ring state drives
can overlap the locked later reads and readiness.
update.
KCSAN reports:
BUG: KCSAN: data-race in snd_seq_oss_readq_clear /
snd_seq_oss_readq_free
write to 0xffff8881069fe608 of 4 bytes by task 120516 on cpu 0:
snd_seq_oss_readq_free+0x6c/0x80 snd_seq_oss_read+0xcb/0x250 odev_read+0x38/0x60 vfs_read+0xff/0x600 ksys_read+0xb4/0x140 __x64_sys_read+0x46/0x60 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
read to 0xffff8881069fe608 of 4 bytes by task 120517 on cpu 1:
snd_seq_oss_readq_clear+0x1f/0x90 snd_seq_oss_reset+0xa7/0xf0 snd_seq_oss_ioctl+0x6f6/0x7e0 odev_ioctl+0x56/0xc0 __x64_sys_ioctl+0xd1/0x120 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
value changed: 0x00000001 -> 0x00000000
--- sound/core/seq/oss/seq_oss_readq.c | 77 ++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 25 deletions(-)
sound/core/seq/oss/seq_oss_readq.c +52 -25
@@ -73,13 +73,17 @@ snd_seq_oss_readq_delete(struct seq_oss_readq *q)void snd_seq_oss_readq_clear (struct seq_oss_readq *q) { -if (q->qlen) { - q->qlen =0 ; - q->head = q->tail =0 ; + scoped_guard(spinlock_irqsave, &q->lock) { +if (q->qlen) { + q->qlen =0 ; + q->head =0 ; + q->tail =0 ; + } + q->input_time = (unsigned long )-1 ; } +/* if someone sleeping, wake'em up */ wake_up (&q->midi_sleep); - q->input_time = (unsigned long )-1 ; }/*
@@ -136,11 +140,11 @@ int snd_seq_oss_readq_sysex(struct seq_oss_readq *q, int dev,/* * copy an event to input queue: * return zero if enqueued +* caller must hold lock */ -int -snd_seq_oss_readq_put_event (struct seq_oss_readq *q,union evrec *ev) +static int snd_seq_oss_readq_put_event_locked (struct seq_oss_readq *q, +union evrec *ev) { -guard (spinlock_irqsave)(&q->lock);if (q->qlen >= q->maxlen -1 )return -ENOMEM ;
@@ -148,12 +152,27 @@ snd_seq_oss_readq_put_event(struct seq_oss_readq *q, union evrec *ev) q->tail = (q->tail +1 ) % q->maxlen; q->qlen++; -/* wake up sleeper */ -wake_up (&q->midi_sleep); -return 0 ; } +/* +* copy an event to input queue: +* return zero if enqueued +*/ +int +snd_seq_oss_readq_put_event (struct seq_oss_readq *q,union evrec *ev) +{ +int rc; + + scoped_guard(spinlock_irqsave, &q->lock) { + rc =snd_seq_oss_readq_put_event_locked (q, ev); +if (!rc) +wake_up (&q->midi_sleep); + } + +return rc; +} +/* * pop queue
@@ -209,23 +228,31 @@ snd_seq_oss_readq_poll(struct seq_oss_readq *q, struct file *file, poll_table *wint snd_seq_oss_readq_put_timestamp (struct seq_oss_readq *q,unsigned long curt,int seq_mode) { -if (curt != q->input_time) { -union evrec rec; -memset (&rec,0 ,sizeof (rec)); -switch (seq_mode) { -case SNDRV_SEQ_OSS_MODE_SYNTH : - rec.echo = (curt <<8 ) |SEQ_WAIT ; -snd_seq_oss_readq_put_event (q, &rec); -break ; -case SNDRV_SEQ_OSS_MODE_MUSIC : - rec.t.code =EV_TIMING ; - rec.t.cmd =TMR_WAIT_ABS ; - rec.t.time = curt; -snd_seq_oss_readq_put_event (q, &rec); -break ; +int queued =0 ; + + scoped_guard(spinlock_irqsave, &q->lock) { +if (curt != q->input_time) { +union evrec rec; + +memset (&rec,0 ,sizeof (rec)); +switch (seq_mode) { +case SNDRV_SEQ_OSS_MODE_SYNTH : + rec.echo = (curt <<8 ) |SEQ_WAIT ; + queued = !snd_seq_oss_readq_put_event_locked (q, &rec); +break ; +case SNDRV_SEQ_OSS_MODE_MUSIC : + rec.t.code =EV_TIMING ; + rec.t.cmd =TMR_WAIT_ABS ; + rec.t.time = curt; + queued = !snd_seq_oss_readq_put_event_locked (q, &rec); +break ; + } + q->input_time = curt; } - q->input_time = curt; } +if (queued) +wake_up (&q->midi_sleep); +return 0 ; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 532/1611 ALSA: seq: avoid stale FIFO cells during resize
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cen Zhang <[email protected]>
[ Upstream commit e546128291f8d688dcb931827e2efd2aa6c0734d ]
snd_seq_fifo_resize() still needs to publish the replacement pool before it waits for FIFO users. A blocking snd_seq_read() holds f->use_lock while it sleeps, so concurrent senders must be able to queue to the new pool and wake that reader instead of failing against a closing old pool.
However, snd_seq_fifo_event_in() duplicates an event before it takes f->lock, and snd_seq_read() can dequeue a cell and later call snd_seq_fifo_cell_putback() if copy_to_user() or snd_seq_expand_var_event() fails. If resize swaps f->pool and detaches oldhead in between, either path can relink an old-pool cell after the snapshot. That stale cell sits outside the drained oldhead list, keeps oldpool->counter elevated, and can leave snd_seq_pool_delete() waiting for the retired pool to drain.
Keep the existing swap-before-wait ordering in snd_seq_fifo_resize(), but reject stale cells before any FIFO relink. Revalidate event-in cells under f->lock and retry them against the published replacement pool, and free stale putback cells instead of linking them back into the FIFO.
The buggy scenario involves two paths, with each column showing the order within that path:
resize path: relink path:
1. Allocate newpool. 1. Take f->use_lock.
2. Swap f->pool to newpool and 2. Duplicate or dequeue an old-pool
detach oldhead. cell before oldpool closes.
3. Mark oldpool closing and 3. Reach a later relink point after
wait for FIFO users. resize published newpool.
4. Free oldhead and delete 4. Relink the old-pool cell after
oldpool. resize detached oldhead.
5. Drop f->use_lock.
The reproducer reports a resize ioctl blocked in the expected pool teardown path:
signal: resize iteration=98 target_pool=4 exceeded 250ms
(elapsed=251ms) diagnostic: resize_tid=651 wchan=snd_seq_pool_done diagnostic: resize_tid=651 stack= snd_seq_pool_done+0x5b/0x140 snd_seq_pool_delete+0x7a/0x90 snd_seq_fifo_resize+0x193/0x1e0 snd_seq_ioctl_set_client_pool+0x214/0x260 snd_seq_ioctl+0x119/0x540 __x64_sys_ioctl+0xd1/0x120 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
A second run with larger pools hit the same target path:
signal: resize iteration=32 target_pool=64 exceeded 250ms
(elapsed=251ms) diagnostic: resize_tid=663 wchan=snd_seq_pool_done diagnostic: resize_tid=663 stack= snd_seq_pool_done+0x5b/0x140 snd_seq_pool_delete+0x7a/0x90 snd_seq_fifo_resize+0x193/0x1e0 snd_seq_ioctl_set_client_pool+0x214/0x260 snd_seq_ioctl+0x119/0x540 __x64_sys_ioctl+0xd1/0x120 do_syscall_64+0xbb/0x2f0 entry_SYSCALL_64_after_hwframe+0x77/0x7f
--- sound/core/seq/seq_fifo.c | 52 ++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 15 deletions(-)
sound/core/seq/seq_fifo.c +37 -15
@@ -101,13 +101,17 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f, struct snd_seq_event *event) {struct snd_seq_event_cell *cell; +struct snd_seq_pool *pool; +bool linked;int err;if (snd_BUG_ON (!f))return -EINVAL ;guard (snd_seq_fifo)(f); - err =snd_seq_event_dup (f->pool, event, &cell,1 ,NULL ,NULL );/* always non-blocking */ +retry: + pool =READ_ONCE (f->pool); + err =snd_seq_event_dup (pool, event, &cell,1 ,NULL ,NULL );/* always non-blocking */ if (err <0 ) {if ((err == -ENOMEM ) || (err == -EAGAIN ))atomic_inc (&f->overflow);
@@ -115,14 +119,24 @@ int snd_seq_fifo_event_in(struct snd_seq_fifo *f, }/* append new cells to fifo */ + linked = false; scoped_guard(spinlock_irqsave, &f->lock) { -if (f->tail !=NULL ) - f->tail->next = cell; - f->tail = cell; -if (f->head ==NULL ) - f->head = cell; - cell->next =NULL ; - f->cells++; +if (cell->pool == f->pool) { +if (f->tail) + f->tail->next = cell; + f->tail = cell; +if (!f->head) + f->head = cell; + cell->next =NULL ; + f->cells++; + linked = true; + } + } + +if (!linked) { +/* Retry against the replacement pool after resize publishes it. */ +snd_seq_cell_free (cell); + goto retry; }/* wakeup client */
@@ -194,13 +208,21 @@ int snd_seq_fifo_cell_out(struct snd_seq_fifo *f,void snd_seq_fifo_cell_putback (struct snd_seq_fifo *f,struct snd_seq_event_cell *cell) { +bool linked = false; +if (cell) { -guard (spinlock_irqsave)(&f->lock); - cell->next = f->head; - f->head = cell; -if (!f->tail) - f->tail = cell; - f->cells++; + scoped_guard(spinlock_irqsave, &f->lock) { +if (cell->pool == f->pool) { + cell->next = f->head; + f->head = cell; +if (!f->tail) + f->tail = cell; + f->cells++; + linked = true; + } + } +if (!linked) +snd_seq_cell_free (cell); } }
@@ -237,7 +259,7 @@ int snd_seq_fifo_resize(struct snd_seq_fifo *f, int poolsize) oldpool = f->pool; oldhead = f->head;/* exchange pools */ - f->pool = newpool; +WRITE_ONCE (f->pool, newpool); f->head =NULL ; f->tail =NULL ; f->cells =0 ;
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 533/1611 netfilter: nf_conncount: callers must hold rcu read lock
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit 64d7d5abe2160bba369b4a8f06bdf5630573bab0 ]
rcu_derefence_raw() should not have been used here, it concealed this bug. Its used because struct rb_node lacks __rcu annotated pointers, so plain rcu_derefence causes sparse warnings.
The major tradeoff is that rcu_derefence_raw() doesn't warn when the caller isn't in a rcu read section.
Extend the rcu read lock scope accordingly and cause sparse warnings, those warnings are the lesser evil.
--- net/netfilter/nf_conncount.c | 6 +++--- net/openvswitch/conntrack.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
net/netfilter/nf_conncount.c +3 -3
@@ -499,7 +499,7 @@ count_tree(struct net *net, hash =jhash2 (key, data->keylen, conncount_rnd) %CONNCOUNT_SLOTS ; root = &data->root[hash]; - parent =rcu_dereference_raw (root->rb_node); + parent =rcu_dereference (root->rb_node);while (parent) {int diff;
@@ -507,9 +507,9 @@ count_tree(struct net *net, diff =key_diff (key, rbconn->key, data->keylen);if (diff <0 ) { - parent =rcu_dereference_raw (parent->rb_left); + parent =rcu_dereference (parent->rb_left); }else if (diff >0 ) { - parent =rcu_dereference_raw (parent->rb_right); + parent =rcu_dereference (parent->rb_right); }else {int ret;
net/openvswitch/conntrack.c +1 -1
@@ -1800,10 +1800,10 @@ static int ovs_ct_limit_get_zone_limit(struct net *net, }else {rcu_read_lock (); limit =ct_limit_get (info, zone); -rcu_read_unlock (); err =__ovs_ct_limit_get_zone_limit ( net, info->data, zone, limit, reply); +rcu_read_unlock ();if (err)return err; }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 534/1611 ALSA: core: Fix unintuitive behavior of snd_power_ref_and_wait()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takashi Iwai <[email protected]>
[ Upstream commit b113a891252c3fa4fab11ec8c2894a22ecaf278c ]
snd_power_ref_and_wait() takes the power refcount and doesn't leave it no matter whether it returns an error or not. However, the majority of callers don't expect but just returns without unreferencing in the caller side upon errors.
For addressing the potential refcount unbalance, rather correct the behavior of snd_power_ref_wait() to unreference upon returning an error.
Note that the problem above is likely negligible; the function returns an error only when the sound card is being shutdown, hence it doesn't matter about the power refcount any longer at such a state.
--- sound/core/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
sound/core/init.c +8 -3
@@ -1131,7 +1131,7 @@ EXPORT_SYMBOL(snd_card_file_remove);* typically around calling control ops. * * The caller needs to pull down the refcount via snd_power_unref() later -* no matter whether the error is returned from this function or not. +* when this function returns 0. * * Return: Zero if successful, or a negative error code. */
@@ -1144,7 +1144,11 @@ int snd_power_ref_and_wait(struct snd_card *card) card->shutdown ||snd_power_get_state (card) ==SNDRV_CTL_POWER_D0 , snd_power_unref(card), snd_power_ref(card)); -return card->shutdown ? -ENODEV :0 ; +if (card->shutdown) { +snd_power_unref (card); +return -ENODEV ; + } +return 0 ; }EXPORT_SYMBOL_GPL (snd_power_ref_and_wait);
@@ -1161,7 +1165,8 @@ int snd_power_wait(struct snd_card *card)int ret; ret =snd_power_ref_and_wait (card); -snd_power_unref (card); +if (!ret) +snd_power_unref (card);return ret; }EXPORT_SYMBOL (snd_power_wait);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 535/1611 cifs: remove all cifs files before kill super
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jian Zhang <[email protected]>
[ Upstream commit 6d9a4aaaa8b2612b5ef9d581e2f286a458b71ee1 ]
Cifs files may be put into fileinfo_put_wq during umounting cifs. After umount done, cifsFileInfo_put_final is called, which cause following BUG:
BUG: kernel NULL pointer dereference, address: 0000000000000000 ... [ 134.222152] list_lru_add+0x64/0x1a0 [ 134.222399] ? cifs_put_tcon+0x171/0x340 [cifs] [ 134.222772] d_lru_add+0x44/0x60 [ 134.222997] dput+0x1fc/0x210 [ 134.223213] cifsFileInfo_put_final+0x11a/0x140 [cifs] [ 134.223576] process_one_work+0x17c/0x320 [ 134.223843] worker_thread+0x188/0x280 [ 134.224084] ? __pfx_worker_thread+0x10/0x10 [ 134.224366] kthread+0xcc/0x100 [ 134.224576] ? __pfx_kthread+0x10/0x10 [ 134.224827] ret_from_fork+0x30/0x50 [ 134.225063] ? __pfx_kthread+0x10/0x10 [ 134.225328] ret_from_fork_asm+0x1b/0x30
This can be reproduce by following:
unshare -n bash -c "
mkdir -p ${CIFS_MNT}
ip netns attach root 1
ip link add eth0 type veth peer veth0 netns root
ip link set eth0 up
ip -n root link set veth0 up
ip addr add 192.168.0.2/24 dev eth0
ip -n root addr add 192.168.0.1/24 dev veth0
ip route add default via 192.168.0.1 dev eth0
ip netns exec root sysctl net.ipv4.ip_forward=1
ip netns exec root iptables -t nat -A POSTROUTING -s 192.168.0.2 -o
${DEV} -j MASQUERADE
mount -t cifs ${CIFS_PATH} ${CIFS_MNT} -o vers=3.0,sec=ntlmssp,credentials=${CIFS_CRED},rsize=65536,wsize=65536,cache=none,echo_interval=1 touch ${CIFS_MNT}/a.txt
ip netns exec root iptables -t nat -D POSTROUTING -s 192.168.0.2 -o
${DEV} -j MASQUERADE
"
umount ${CIFS_MNT}
--- fs/smb/client/connect.c | 3 +++ 1 file changed, 3 insertions(+)
fs/smb/client/connect.c +3 -0
@@ -4170,6 +4170,9 @@ cifs_umount(struct cifs_sb_info *cifs_sb) }spin_unlock (&cifs_sb->tlink_tree_lock); +flush_workqueue (serverclose_wq); +flush_workqueue (fileinfo_put_wq); +kfree (cifs_sb->prepath);call_rcu (&cifs_sb->rcu, delayed_free); }
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 536/1611 smb/client: always return a value for FS_IOC_GETFLAGS
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Huiwen He <[email protected]>
[ Upstream commit 7acbaa16b99edaf8ef432229d4b7a6f3b666767d ]
Currently, repeated lsattr calls on a regular CIFS file without the compressed attribute may show random flags:
$ touch test.bin $ lsattr test.bin s-S-ia-A-EjI---------m test.bin $ lsattr test.bin ------d-cEjI---------m test.bin
The lsattr reproducer depends on the previous contents of its userspace buffer, so it may not reproduce on every setup. A deterministic reproducer is to initialize the ioctl argument before FS_IOC_GETFLAGS on a file without the compressed attribute:
int flags = 0x7fffffff;
ioctl(fd, FS_IOC_GETFLAGS, &flags);On an affected kernel, flags remains 0x7fffffff. With the fix, it is set to 0.
This happens because when the cached inode does not have the compressed bit set, the CIFS fallback path in FS_IOC_GETFLAGS returns success without calling put_user() to write the zero flags value into the user buffer. As a result, the caller observes stale contents from its own buffer.
Fix this by always writing the visible flags value back to the user buffer before returning success, even when the value is zero.
--- fs/smb/client/ioctl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
fs/smb/client/ioctl.c +5 -7
@@ -393,13 +393,11 @@ long cifs_ioctl(struct file *filep, unsigned int command, unsigned long arg) }#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ #endif /* CONFIG_CIFS_POSIX */ - rc =0 ; -if (CIFS_I (inode)->cifsAttrs &ATTR_COMPRESSED ) { -/* add in the compressed bit */ - ExtAttrBits =FS_COMPR_FL ; - rc =put_user (ExtAttrBits &FS_FL_USER_VISIBLE , - (int __user *)arg); - } +if (CIFS_I (inode)->cifsAttrs &FILE_ATTRIBUTE_COMPRESSED ) + ExtAttrBits |=FS_COMPR_FL ; + + rc =put_user (ExtAttrBits &FS_FL_USER_VISIBLE , + (int __user *)arg);break ;case FS_IOC_SETFLAGS :if (pSMBFile ==NULL )
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 537/1611 selftests/bpf: Fix typo in verify_umulti_link_info
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiri Olsa <[email protected]>
[ Upstream commit df29003c55115737a8fb4f8a60c6c2bba4c4a484 ]
We verify info.uprobe_multi.flags against wrong kprobe-multi flag (BPF_F_KPROBE_MULTI_RETURN). It's the same value as the correct flag (BPF_F_UPROBE_MULTI_RETURN), so there's not functional change.
--- tools/testing/selftests/bpf/prog_tests/fill_link_info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/bpf/prog_tests/fill_link_info.c +1 -1
@@ -469,7 +469,7 @@ verify_umulti_link_info(int fd, bool retprobe, __u64 *offsets,ASSERT_EQ (info.uprobe_multi.pid,getpid (),"info.uprobe_multi.pid" );ASSERT_EQ (info.uprobe_multi.count,3 ,"info.uprobe_multi.count" ); -ASSERT_EQ (info.uprobe_multi.flags &BPF_F_KPROBE_MULTI_RETURN , +ASSERT_EQ (info.uprobe_multi.flags &BPF_F_UPROBE_MULTI_RETURN , retprobe,"info.uprobe_multi.flags.retprobe" );ASSERT_EQ (info.uprobe_multi.path_size,strlen (path) +1 ,"info.uprobe_multi.path_size" );ASSERT_STREQ (path_buf, path,"info.uprobe_multi.path" );
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 538/1611 selftests/bpf: Initialize operation name before use
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 55ffbe8a15b1254f44d56952fb425a10e3f15c31 ]
ASAN reports stack-buffer-overflow due to the uninitialized op_name.
Initialize it to fix the issue.
--- tools/testing/selftests/bpf/prog_tests/verifier_log.c | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/prog_tests/verifier_log.c +1 -0
@@ -317,6 +317,7 @@ static void verif_btf_log_subtest(bool bad_btf) res =load_btf (&opts, true);ASSERT_EQ (res, -ENOSPC ,"half_log_fd" );ASSERT_EQ (strlen (logs.buf),24 ,"log_fixed_25" ); +strscpy (op_name,"log_fixed" ,sizeof (op_name));ASSERT_STRNEQ (logs.buf, logs.reference,24 , op_name);/* validate rolling verifier log logic: try all variations of log buf
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 539/1611 bpf: Fix bpf_get/setsockopt to tos for ipv4-mapped ipv6 socket
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Hwang <[email protected]>
[ Upstream commit ca0f587c029afa66227f7b932450b1c417403394 ]
When TCP over IPv4 via INET6 API, bpf_get/setsockopt with ipv4 will fail, because sk->sk_family is AF_INET6. With ipv6 will success, not take effect, because inet_csk(sk)->icsk_af_ops is ipv6_mapped and use ip_queue_xmit, inet_sk(sk)->tos.
To relax this restriction, allow getting/setting tos for those possible ipv4-mapped ipv6 sockets.
--- net/core/filter.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
net/core/filter.c +14 -1
@@ -5562,11 +5562,24 @@ static int sol_tcp_sockopt(struct sock *sk, int optname, KERNEL_SOCKPTR(optval), *optlen); } +static bool sk_allows_sol_ip_sockopt (struct sock *sk) +{ +switch (sk->sk_family) { +case AF_INET : +return true; +case AF_INET6 : +/* Allow getting/setting sockopt for possible ipv4-mapped ipv6 socket. */ +return sk->sk_type !=SOCK_RAW && !ipv6_only_sock (sk); +default : +return false; + } +} +static int sol_ip_sockopt (struct sock *sk,int optname,char *optval,int *optlen,bool getopt) { -if (sk->sk_family !=AF_INET ) +if (!sk_allows_sol_ip_sockopt (sk))return -EINVAL ;switch (optname) {
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 540/1611 udf: fix nls leak on udf_fill_super() failure
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
[ Upstream commit 462bdd08fbdf41db223c6117d907c8fd68d666ea ]
On all failure exits that go to error_out there we have already moved the nls reference from uopt->nls_map to sbi->s_nls_map, leaving NULL behind.
--- fs/udf/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/udf/super.c +1 -1
@@ -2329,7 +2329,7 @@ static int udf_fill_super(struct super_block *sb, struct fs_context *fc) error_out:iput (sbi->s_vat_inode); -unload_nls (uopt->nls_map); +unload_nls (sbi->s_nls_map);if (lvid_open)udf_close_lvid (sb);brelse (sbi->s_lvid_bh);
Signature · 1 line
2.53.0
Greg Kroah-Hartman
maintainerPATCH 541/1611 bpf, sockmap: reject overflowing copy + len in bpf_msg_push_data()
In reply to Greg Kroah-Hartman6.18-stable review patch. If anyone has any objections, please let me know.
------------------
From: Weiming Shi <[email protected]>
[ Upstream commit 0c0a8ed85349dae298712d79cb276acfeb794d82 ]
When the scatterlist ring is full or nearly full, bpf_msg_push_data() enters a copy fallback path and computes copy + len for the page allocation size. Since len comes from BPF with arg3_type = ARG_ANYTHING and both are u32, a crafted len can wrap the sum to a small value, causing an undersized allocation followed by an out-of-bounds memcpy.
BUG: unable to handle page fault for address: ffffed104089a402 Oops: Oops: 0000 [#1] SMP KASAN NOPTI Call Trace: __asan_memcpy (mm/kasan/shadow.c:105) bpf_msg_push_data (net/core/filter.c:2852 net/core/filter.c:2788) bpf_prog_9ed8b5711920a7d7+0x2e/0x36 sk_psock_msg_verdict (net/core/skmsg.c:934) tcp_bpf_sendmsg (net/ipv4/tcp_bpf.c:421 net/ipv4/tcp_bpf.c:584) __sys_sendto (net/socket.c:2206) do_syscall_64 (arch/x86/entry/syscall_64.c:94) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130)
Add an overflow check before the allocation.
--- net/core/filter.c | 3 +++ 1 file changed, 3 insertions(+)
net/core/filter.c +3 -0
@@ -2833,6 +2833,9 @@ BPF_CALL_4(bpf_msg_push_data, struct sk_msg *, msg, u32, start,if (!space || (space ==1 && start != offset)) copy = msg->sg.data[i].length; +if (unlikely (copy + len < copy)) +return -EINVAL ; + page =alloc_pages (__GFP_NOWARN |GFP_ATOMIC | __GFP_COMP,get_order (copy + len));if (unlikely (!page))
Signature · 1 line
2.53.0