6.16.1-rc1 review
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 249/627 wifi: brcmfmac: cyw: Fix __counted_by to be LE variant
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 204bb852863bf14f343a0801b15bc2173bc318f9 ]
In brcmf_cyw_mgmt_tx() the "len" counter of the struct brcmf_mf_params_le::data flexible array is stored as little-endian via cpu_to_le16() so the __counted_by_le() variant must be used:
struct brcmf_mf_params_le *mf_params;
...
mf_params_len = offsetof(struct brcmf_mf_params_le, data) +
(len - DOT11_MGMT_HDR_LEN);
mf_params = kzalloc(mf_params_len, GFP_KERNEL);
...
mf_params->len = cpu_to_le16(len - DOT11_MGMT_HDR_LEN);--- .../net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/fwil_types.h +1 -1
@@ -80,7 +80,7 @@ struct brcmf_mf_params_le {u8 da[ETH_ALEN ];u8 bssid[ETH_ALEN ];__le32 packet_id; - u8 data[] __counted_by(len); + u8 data[] __counted_by_le(len); };#endif /* CYW_FWIL_TYPES_H_ */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 250/627 wifi: mac80211: fix WARN_ON for monitor mode on some devices
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
[ Upstream commit c57e5b9819dfd16d709bcd6cb633301ed0829a66 ]
On devices without WANT_MONITOR_VIF (and probably without channel context support) we get a WARN_ON for changing the per-link setting of a monitor interface.
Since we already skip AP_VLAN interfaces and MONITOR with WANT_MONITOR_VIF and/or NO_VIRTUAL_MONITOR should update the settings, catch this in the link change code instead of the warning.
--- net/mac80211/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
net/mac80211/main.c +12 -1
@@ -407,9 +407,20 @@ void ieee80211_link_info_change_notify(struct ieee80211_sub_if_data *sdata,WARN_ON_ONCE (changed &BSS_CHANGED_VIF_CFG_FLAGS ); -if (!changed || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN ) +if (!changed)return ; +switch (sdata->vif.type) { +case NL80211_IFTYPE_AP_VLAN : +return ; +case NL80211_IFTYPE_MONITOR : +if (!ieee80211_hw_check (&local->hw,WANT_MONITOR_VIF )) +return ; +break ; +default : +break ; + } +if (!check_sdata_in_driver (sdata))return ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 251/627 arm64/gcs: task_gcs_el0_enable() should use passed task
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jeremy Linton <[email protected]>
[ Upstream commit cbbcfb94c55c02a8c4ce52b5da0770b5591a314c ]
Mark Rutland noticed that the task parameter is ignored and 'current' is being used instead. Since this is usually what its passed, it hasn't yet been causing problems but likely will as the code gets more testing.
But, once this is fixed, it creates a new bug in copy_thread_gcs() since the gcs_el_mode isn't yet set for the task before its being checked. Move gcs_alloc_thread_stack() after the new task's gcs_el0_mode initialization to avoid this.
--- arch/arm64/include/asm/gcs.h | 2 +- arch/arm64/kernel/process.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm64/include/asm/gcs.h +1 -1
@@ -58,7 +58,7 @@ static inline u64 gcsss2(void)static inline bool task_gcs_el0_enabled (struct task_struct *task) { -return current->thread.gcs_el0_mode &PR_SHADOW_STACK_ENABLE ; +return task->thread.gcs_el0_mode &PR_SHADOW_STACK_ENABLE ; }void gcs_set_el0_mode (struct task_struct *task);
arch/arm64/kernel/process.c +3 -3
@@ -307,13 +307,13 @@ static int copy_thread_gcs(struct task_struct *p, p->thread.gcs_base =0 ; p->thread.gcs_size =0 ; + p->thread.gcs_el0_mode = current->thread.gcs_el0_mode; + p->thread.gcs_el0_locked = current->thread.gcs_el0_locked; + gcs =gcs_alloc_thread_stack (p, args);if (IS_ERR_VALUE (gcs))return PTR_ERR ((void *)gcs); - p->thread.gcs_el0_mode = current->thread.gcs_el0_mode; - p->thread.gcs_el0_locked = current->thread.gcs_el0_locked; -return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 252/627 wifi: iwlwifi: mld: decode EOF bit for AMPDUs
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Benjamin Berg <[email protected]>
[ Upstream commit bc404dfddbf6817cae9b170c34556dc72ea975e5 ]
Only the EOF bit handling for single frames was ported to the MLD driver. The code to handle AMPDUs correctly was forgotten. Add it back so that the bit is reported in the radiotap headers again.
--- drivers/net/wireless/intel/iwlwifi/mld/rx.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/net/wireless/intel/iwlwifi/mld/rx.c +9 -0
@@ -1039,6 +1039,15 @@ static void iwl_mld_rx_eht(struct iwl_mld *mld, struct sk_buff *skb, rx_status->flag |=RX_FLAG_AMPDU_EOF_BIT ; } +/* update aggregation data for monitor sake on default queue */ +if (!queue && (phy_info &IWL_RX_MPDU_PHY_TSF_OVERLOAD ) && + (phy_info &IWL_RX_MPDU_PHY_AMPDU ) && phy_data->first_subframe) { + rx_status->flag |=RX_FLAG_AMPDU_EOF_BIT_KNOWN ; +if (phy_data->data0 & +cpu_to_le32 (IWL_RX_PHY_DATA0_EHT_DELIM_EOF )) + rx_status->flag |=RX_FLAG_AMPDU_EOF_BIT ; + } +if (phy_info &IWL_RX_MPDU_PHY_TSF_OVERLOAD )iwl_mld_decode_eht_phy_data (mld, phy_data, rx_status, eht, usig);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 253/627 iommu/vt-d: Fix UAF on sva unbind with pending IOPFs
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lu Baolu <[email protected]>
[ Upstream commit f0b9d31c6edd50a6207489cd1bd4ddac814b9cd2 ]
Commit 17fce9d2336d ("iommu/vt-d: Put iopf enablement in domain attach path") disables IOPF on device by removing the device from its IOMMU's IOPF queue when the last IOPF-capable domain is detached from the device. Unfortunately, it did this in a wrong place where there are still pending IOPFs. As a result, a use-after-free error is potentially triggered and eventually a kernel panic with a kernel trace similar to the following:
refcount_t: underflow; use-after-free.
WARNING: CPU: 3 PID: 313 at lib/refcount.c:28 refcount_warn_saturate+0xd8/0xe0 Workqueue: iopf_queue/dmar0-iopfq iommu_sva_handle_iopf Call Trace: <TASK> iopf_free_group+0xe/0x20 process_one_work+0x197/0x3d0 worker_thread+0x23a/0x350 ? rescuer_thread+0x4a0/0x4a0 kthread+0xf8/0x230 ? finish_task_switch.isra.0+0x81/0x260 ? kthreads_online_cpu+0x110/0x110 ? kthreads_online_cpu+0x110/0x110 ret_from_fork+0x13b/0x170 ? kthreads_online_cpu+0x110/0x110 ret_from_fork_asm+0x11/0x20 </TASK> ---[ end trace 0000000000000000 ]---
The intel_pasid_tear_down_entry() function is responsible for blocking hardware from generating new page faults and flushing all in-flight ones. Therefore, moving iopf_for_domain_remove() after this function should resolve this.
--- drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +1 -1
@@ -3999,8 +3999,8 @@ static int blocking_domain_set_dev_pasid(struct iommu_domain *domain, {struct device_domain_info *info =dev_iommu_priv_get (dev); -iopf_for_domain_remove (old, dev);intel_pasid_tear_down_entry (info->iommu, dev, pasid, false); +iopf_for_domain_remove (old, dev);domain_remove_dev_pasid (old, dev, pasid);return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 254/627 wifi: brcmfmac: fix EXTSAE WPA3 connection failure due to AUTH TX failure
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ting-Ying Li <[email protected]>
[ Upstream commit f2d7c3c380bf0c38c395d50de3a7c1a6275983cb ]
For WPA3-SAE Connection in EXTSAE mode, the userspace daemon is allowed to generate the SAE Auth frames. The driver uses the "mgmt_frame" FW IOVAR to transmit this MGMT frame.
Before sending the IOVAR, the Driver is incorrectly treating the channel number read from the FW as a frequency value and again attempts to convert this into a channel number using ieee80211_frequency_to_channel().
This added an invalid channel number as part of the IOVAR request to the FW And some FW which strictly expects a valid channel would return BAD_CHAN error, while failing to transmit the driver requested SAE Auth MGMT frame.
Fix this in the CYW vendor specific MGMT TX cfg80211 ops handler, by not treating the channel number read from the FW as frequency value and skip the attempt to convert it again into a channel number.
Also fix this in the generic MGMT TX cfg80211 ops handler.
--- .../broadcom/brcm80211/brcmfmac/cfg80211.c | 30 ++++++++++++------- .../broadcom/brcm80211/brcmfmac/cyw/core.c | 26 +++++++++------- 2 files changed, 35 insertions(+), 21 deletions(-)
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +19 -11
@@ -5527,8 +5527,7 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,struct brcmf_fil_action_frame_le *action_frame;struct brcmf_fil_af_params_le *af_params;bool ack; -s32 chan_nr; -u32 freq; +__le32 hw_ch;brcmf_dbg (TRACE ,"Enter\n" );
@@ -5589,25 +5588,34 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,/* Add the channel. Use the one specified as parameter if any or * the current one (got from the firmware) otherwise */ -if (chan) - freq = chan->center_freq; -else -brcmf_fil_cmd_int_get (vif->ifp,BRCMF_C_GET_CHANNEL , - &freq); - chan_nr =ieee80211_frequency_to_channel (freq); - af_params->channel =cpu_to_le32 (chan_nr); +if (chan) { + hw_ch =cpu_to_le32 (chan->hw_value); + }else { + err =brcmf_fil_cmd_data_get (vif->ifp, +BRCMF_C_GET_CHANNEL , + &hw_ch,sizeof (hw_ch)); +if (err) { +bphy_err (drvr, +"unable to get current hw channel\n" ); + goto free; + } + } + af_params->channel = hw_ch; + af_params->dwell_time =cpu_to_le32 (params->wait);memcpy (action_frame->data, &buf[DOT11_MGMT_HDR_LEN ],le16_to_cpu (action_frame->len)); -brcmf_dbg (TRACE ,"Action frame, cookie=%lld, len=%d, freq=%d\n" , - *cookie,le16_to_cpu (action_frame->len), freq); +brcmf_dbg (TRACE ,"Action frame, cookie=%lld, len=%d, channel=%d\n" , + *cookie,le16_to_cpu (action_frame->len), +le32_to_cpu (af_params->channel)); ack =brcmf_p2p_send_action_frame (cfg,cfg_to_ndev (cfg), af_params);cfg80211_mgmt_tx_status (wdev, *cookie, buf, len, ack,GFP_KERNEL ); +free:kfree (af_params); }else {brcmf_dbg (TRACE ,"Unhandled, fc=%04x!!\n" , mgmt->frame_control);
drivers/net/wireless/broadcom/brcm80211/brcmfmac/cyw/core.c +16 -10
@@ -112,8 +112,7 @@ int brcmf_cyw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,struct brcmf_cfg80211_vif *vif;s32 err =0 ;bool ack = false; -s32 chan_nr; -u32 freq; +__le16 hw_ch;struct brcmf_mf_params_le *mf_params;u32 mf_params_len;s32 ready;
@@ -143,13 +142,18 @@ int brcmf_cyw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, mf_params->len =cpu_to_le16 (len -DOT11_MGMT_HDR_LEN ); mf_params->frame_control = mgmt->frame_control; -if (chan) - freq = chan->center_freq; -else -brcmf_fil_cmd_int_get (vif->ifp,BRCMF_C_GET_CHANNEL , - &freq); - chan_nr =ieee80211_frequency_to_channel (freq); - mf_params->channel =cpu_to_le16 (chan_nr); +if (chan) { + hw_ch =cpu_to_le16 (chan->hw_value); + }else { + err =brcmf_fil_cmd_data_get (vif->ifp,BRCMF_C_GET_CHANNEL , + &hw_ch,sizeof (hw_ch)); +if (err) { +bphy_err (drvr,"unable to get current hw channel\n" ); + goto free; + } + } + mf_params->channel = hw_ch; +memcpy (&mf_params->da[0 ], &mgmt->da[0 ],ETH_ALEN );memcpy (&mf_params->bssid[0 ], &mgmt->bssid[0 ],ETH_ALEN ); mf_params->packet_id =cpu_to_le32 (*cookie);
@@ -159,7 +163,8 @@ int brcmf_cyw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev,brcmf_dbg (TRACE ,"Auth frame, cookie=%d, fc=%04x, len=%d, channel=%d\n" ,le32_to_cpu (mf_params->packet_id),le16_to_cpu (mf_params->frame_control), -le16_to_cpu (mf_params->len), chan_nr); +le16_to_cpu (mf_params->len), +le16_to_cpu (mf_params->channel)); vif->mgmt_tx_id =le32_to_cpu (mf_params->packet_id);set_bit (BRCMF_MGMT_TX_SEND_FRAME , &vif->mgmt_tx_status);
@@ -185,6 +190,7 @@ int brcmf_cyw_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, tx_status:cfg80211_mgmt_tx_status (wdev, *cookie, buf, len, ack,GFP_KERNEL ); +free:kfree (mf_params);return err; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 255/627 Bluetooth: btusb: Fix potential NULL dereference on kmalloc failure
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhongqiu Han <[email protected]>
[ Upstream commit b505902c66a282dcb01bcdc015aa1fdfaaa075db ]
Avoid potential NULL pointer dereference by checking the return value of kmalloc and handling allocation failure properly.
--- drivers/bluetooth/btusb.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/bluetooth/btusb.c +2 -0
@@ -3802,6 +3802,8 @@ static int btusb_hci_drv_supported_altsettings(struct hci_dev *hdev, void *data,/* There are at most 7 alt (0 - 6) */ rp =kmalloc (sizeof (*rp) +7 ,GFP_KERNEL ); +if (!rp) +return -ENOMEM ; rp->num =0 ;if (!drvdata->isoc)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 256/627 Bluetooth: hci_sync: fix double free in hci_discovery_filter_clear()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arseniy Krasnov <[email protected]>
[ Upstream commit 2935e556850e9c94d7a00adf14d3cd7fe406ac03 ]
Function 'hci_discovery_filter_clear()' frees 'uuids' array and then sets it to NULL. There is a tiny chance of the following race:
'hci_cmd_sync_work()'
'update_passive_scan_sync()'
'hci_update_passive_scan_sync()'
'hci_discovery_filter_clear()'
kfree(uuids);
<-------------------------preempted-------------------------------->
'start_service_discovery()'
'hci_discovery_filter_clear()'
kfree(uuids); // DOUBLE FREE
<-------------------------preempted-------------------------------->
uuids = NULL;To fix it let's add locking around 'kfree()' call and NULL pointer assignment. Otherwise the following backtrace fires:
[ ] ------------[ cut here ]------------
[ ] kernel BUG at mm/slub.c:547!
[ ] Internal error: Oops - BUG: 00000000f2000800 [#1] PREEMPT SMP [ ] CPU: 3 UID: 0 PID: 246 Comm: bluetoothd Tainted: G O 6.12.19-kernel #1 [ ] Tainted: [O]=OOT_MODULE
[ ] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ ] pc : __slab_free+0xf8/0x348
[ ] lr : __slab_free+0x48/0x348
...
[ ] Call trace:
[ ] __slab_free+0xf8/0x348 [ ] kfree+0x164/0x27c [ ] start_service_discovery+0x1d0/0x2c0 [ ] hci_sock_sendmsg+0x518/0x924 [ ] __sock_sendmsg+0x54/0x60 [ ] sock_write_iter+0x98/0xf8 [ ] do_iter_readv_writev+0xe4/0x1c8 [ ] vfs_writev+0x128/0x2b0 [ ] do_writev+0xfc/0x118 [ ] __arm64_sys_writev+0x20/0x2c [ ] invoke_syscall+0x68/0xf0 [ ] el0_svc_common.constprop.0+0x40/0xe0 [ ] do_el0_svc+0x1c/0x28 [ ] el0_svc+0x30/0xd0 [ ] el0t_64_sync_handler+0x100/0x12c [ ] el0t_64_sync+0x194/0x198
[ ] Code: 8b0002e6 eb17031f 54fffbe1 d503201f (d4210000) [ ] ---[ end trace 0000000000000000 ]---
--- include/net/bluetooth/hci_core.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/net/bluetooth/hci_core.h +6 -0
@@ -29,6 +29,7 @@#include <linux/idr.h> #include <linux/leds.h> #include <linux/rculist.h> +#include <linux/spinlock.h> #include <linux/srcu.h> #include <net/bluetooth/hci.h>
@@ -94,6 +95,7 @@ struct discovery_state {u16 uuid_count;u8 (*uuids)[16 ];unsigned long name_resolve_timeout; +spinlock_t lock; };#define SUSPEND_NOTIFIER_TIMEOUT msecs_to_jiffies(2000)/* 2 seconds */
@@ -889,6 +891,7 @@ static inline void iso_recv(struct hci_conn *hcon, struct sk_buff *skb,static inline void discovery_init (struct hci_dev *hdev) { +spin_lock_init (&hdev->discovery.lock); hdev->discovery.state =DISCOVERY_STOPPED ;INIT_LIST_HEAD (&hdev->discovery.all);INIT_LIST_HEAD (&hdev->discovery.unknown);
@@ -903,8 +906,11 @@ static inline void hci_discovery_filter_clear(struct hci_dev *hdev) hdev->discovery.report_invalid_rssi = true; hdev->discovery.rssi =HCI_RSSI_INVALID ; hdev->discovery.uuid_count =0 ; + +spin_lock (&hdev->discovery.lock);kfree (hdev->discovery.uuids); hdev->discovery.uuids =NULL ; +spin_unlock (&hdev->discovery.lock); }bool hci_discovery_active (struct hci_dev *hdev);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 257/627 Bluetooth: hci_devcd_dump: fix out-of-bounds via dev_coredumpv
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Pravdin <[email protected]>
[ Upstream commit 7af4d7b53502286c6cf946d397ab183e76d14820 ]
Currently both dev_coredumpv and skb_put_data in hci_devcd_dump use hdev->dump.head. However, dev_coredumpv can free the buffer. From dev_coredumpm_timeout documentation, which is used by dev_coredumpv:
Quoted 4 lines
Creates a new device coredump for the given device. If a previous one hasn't been read yet, the new coredump is discarded. The data lifetime is determined by the device coredump framework and when it is no longer needed the @free function will be called to free the data.
If the data has not been read by the userspace yet, dev_coredumpv will discard new buffer, freeing hdev->dump.head. This leads to vmalloc-out-of-bounds error when skb_put_data tries to access hdev->dump.head.
A crash report from syzbot illustrates this:
==================================================================
BUG: KASAN: vmalloc-out-of-bounds in skb_put_data
include/linux/skbuff.h:2752 [inline]
BUG: KASAN: vmalloc-out-of-bounds in hci_devcd_dump+0x142/0x240
net/bluetooth/coredump.c:258
Read of size 140 at addr ffffc90004ed5000 by task kworker/u9:2/5844
CPU: 1 UID: 0 PID: 5844 Comm: kworker/u9:2 Not tainted
6.14.0-syzkaller-10892-g4e82c87058f4 #0 PREEMPT(full)
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 02/12/2025
Workqueue: hci0 hci_devcd_timeout
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:94 [inline]
dump_stack_lvl+0x116/0x1f0 lib/dump_stack.c:120
print_address_description mm/kasan/report.c:408 [inline]
print_report+0xc3/0x670 mm/kasan/report.c:521
kasan_report+0xe0/0x110 mm/kasan/report.c:634
check_region_inline mm/kasan/generic.c:183 [inline]
kasan_check_range+0xef/0x1a0 mm/kasan/generic.c:189
__asan_memcpy+0x23/0x60 mm/kasan/shadow.c:105
skb_put_data include/linux/skbuff.h:2752 [inline]
hci_devcd_dump+0x142/0x240 net/bluetooth/coredump.c:258
hci_devcd_timeout+0xb5/0x2e0 net/bluetooth/coredump.c:413
process_one_work+0x9cc/0x1b70 kernel/workqueue.c:3238
process_scheduled_works kernel/workqueue.c:3319 [inline]
worker_thread+0x6c8/0xf10 kernel/workqueue.c:3400
kthread+0x3c2/0x780 kernel/kthread.c:464
ret_from_fork+0x45/0x80 arch/x86/kernel/process.c:153
ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:245
</TASK>
The buggy address ffffc90004ed5000 belongs to a vmalloc virtual mapping
Memory state around the buggy address:
ffffc90004ed4f00: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc90004ed4f80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
>ffffc90004ed5000: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
^
ffffc90004ed5080: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
ffffc90004ed5100: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
==================================================================To avoid this issue, reorder dev_coredumpv to be called after skb_put_data that does not free the data.
--- net/bluetooth/coredump.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/bluetooth/coredump.c +3 -3
@@ -249,15 +249,15 @@ static void hci_devcd_dump(struct hci_dev *hdev) size = hdev->dump.tail - hdev->dump.head; -/* Emit a devcoredump with the available data */ -dev_coredumpv (&hdev->dev, hdev->dump.head, size,GFP_KERNEL ); -/* Send a copy to monitor as a diagnostic packet */ skb =bt_skb_alloc (size,GFP_ATOMIC );if (skb) {skb_put_data (skb, hdev->dump.head, size);hci_recv_diag (hdev, skb); } + +/* Emit a devcoredump with the available data */ +dev_coredumpv (&hdev->dev, hdev->dump.head, size,GFP_KERNEL ); } static void hci_devcd_handle_pkt_complete(struct hci_dev *hdev,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 258/627 Bluetooth: btintel: Define a macro for Intel Reset vendor command
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit 15843c7fdba65568704245fd3ea2aa3aa2d50825 ]
Use macro for Intel Reset command (0xfc01) instead of hard coded value.
Stable-dep-of: 69b3d3acf3db ("Bluetooth: btintel_pcie: Make driver wait for alive interrupt")
--- drivers/bluetooth/btintel.c | 4 ++-- drivers/bluetooth/btintel.h | 2 ++ drivers/bluetooth/btintel_pcie.c | 12 ++++++------ drivers/bluetooth/btusb.c | 8 ++++---- drivers/bluetooth/hci_intel.c | 10 +++++----- 5 files changed, 19 insertions(+), 17 deletions(-)
drivers/bluetooth/btintel.c +2 -2
@@ -889,7 +889,7 @@ int btintel_send_intel_reset(struct hci_dev *hdev, u32 boot_param) params.boot_param =cpu_to_le32 (boot_param); - skb =__hci_cmd_sync (hdev,0xfc01 ,sizeof (params), ¶ms, + skb =__hci_cmd_sync (hdev,BTINTEL_HCI_OP_RESET ,sizeof (params), ¶ms,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) {bt_dev_err (hdev,"Failed to send Intel Reset command" );
@@ -1287,7 +1287,7 @@ static void btintel_reset_to_bootloader(struct hci_dev *hdev) params.boot_option =0x00 ; params.boot_param =cpu_to_le32 (0x00000000 ); - skb =__hci_cmd_sync (hdev,0xfc01 ,sizeof (params), + skb =__hci_cmd_sync (hdev,BTINTEL_HCI_OP_RESET ,sizeof (params), ¶ms,HCI_INIT_TIMEOUT );if (IS_ERR (skb)) { bt_dev_err(hdev, "FW download error recovery failed (%ld)",
drivers/bluetooth/btintel.h +2 -0
@@ -52,6 +52,8 @@ struct intel_tlv {u8 val[]; } __packed; +#define BTINTEL_HCI_OP_RESET 0xfc01 +#define BTINTEL_CNVI_BLAZARI 0x900#define BTINTEL_CNVI_BLAZARIW 0x901#define BTINTEL_CNVI_GAP 0x910
drivers/bluetooth/btintel_pcie.c +6 -6
@@ -1955,12 +1955,12 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,struct hci_command_hdr *cmd = (void *)skb->data;__u16 opcode =le16_to_cpu (cmd->opcode); -/* When the 0xfc01 command is issued to boot into -* the operational firmware, it will actually not -* send a command complete event. To keep the flow +/* When the BTINTEL_HCI_OP_RESET command is issued to +* boot into the operational firmware, it will actually +* not send a command complete event. To keep the flow * control working inject that event here. */ -if (opcode ==0xfc01 ) +if (opcode ==BTINTEL_HCI_OP_RESET )btintel_pcie_inject_cmd_complete (hdev, opcode); }/* Firmware raises alive interrupt on HCI_OP_RESET */
@@ -1995,10 +1995,10 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev, }if (type ==BTINTEL_PCIE_HCI_CMD_PKT && - (opcode ==HCI_OP_RESET || opcode ==0xfc01 )) { + (opcode ==HCI_OP_RESET || opcode ==BTINTEL_HCI_OP_RESET )) { old_ctxt = data->alive_intr_ctxt; data->alive_intr_ctxt = - (opcode ==0xfc01 ?BTINTEL_PCIE_INTEL_HCI_RESET1 : + (opcode ==BTINTEL_HCI_OP_RESET ?BTINTEL_PCIE_INTEL_HCI_RESET1 :BTINTEL_PCIE_HCI_RESET ); bt_dev_dbg(data->hdev, "sent cmd: 0x%4.4x alive context changed: %s -> %s", opcode, btintel_pcie_alivectxt_state2str(old_ctxt),
drivers/bluetooth/btusb.c +4 -4
@@ -2594,12 +2594,12 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)else urb =alloc_ctrl_urb (hdev, skb); -/* When the 0xfc01 command is issued to boot into -* the operational firmware, it will actually not -* send a command complete event. To keep the flow +/* When the BTINTEL_HCI_OP_RESET command is issued to +* boot into the operational firmware, it will actually +* not send a command complete event. To keep the flow * control working inject that event here. */ -if (opcode ==0xfc01 ) +if (opcode ==BTINTEL_HCI_OP_RESET )inject_cmd_complete (hdev, opcode); }else { urb =alloc_ctrl_urb (hdev, skb);
drivers/bluetooth/hci_intel.c +5 -5
@@ -1029,12 +1029,12 @@ static struct sk_buff *intel_dequeue(struct hci_uart *hu)struct hci_command_hdr *cmd = (void *)skb->data;__u16 opcode =le16_to_cpu (cmd->opcode); -/* When the 0xfc01 command is issued to boot into -* the operational firmware, it will actually not -* send a command complete event. To keep the flow -* control working inject that event here. +/* When the BTINTEL_HCI_OP_RESET command is issued to boot into +* the operational firmware, it will actually not send a command +* complete event. To keep the flow control working inject that +* event here. */ -if (opcode ==0xfc01 ) +if (opcode ==BTINTEL_HCI_OP_RESET )inject_cmd_complete (hu->hdev, opcode); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 259/627 Bluetooth: btintel_pcie: Make driver wait for alive interrupt
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kiran K <[email protected]>
[ Upstream commit 69b3d3acf3dba21e2abad863c80c7114eb110b3d ]
The firmware raises an alive interrupt upon receiving the HCI_RESET or BTINTEL_HCI_OP_RESET (Intel reset - 0xfc01) command. This change fixes the driver to properly wait for the alive interrupt to avoid driver sending commands to firmware before it is ready to process.
For details on the handshake between the driver and firmware, refer to commit 05c200c8f029 ("Bluetooth: btintel_pcie: Add handshake between driver and firmware").
As the driver needs to handle two interrupts for HCI_OP_RESET and BTINTEL_HCI_OP_RESET, the firmware ensures that the TX completion interrupt is always followed by the alive interrupt.
--- drivers/bluetooth/btintel_pcie.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/bluetooth/btintel_pcie.c +17 -13
@@ -928,11 +928,13 @@ static void btintel_pcie_msix_gp0_handler(struct btintel_pcie_data *data)case BTINTEL_PCIE_INTEL_HCI_RESET1 :if (btintel_pcie_in_op (data)) { submit_rx = true; + signal_waitq = true;break ; }if (btintel_pcie_in_iml (data)) { submit_rx = true; + signal_waitq = true; data->alive_intr_ctxt =BTINTEL_PCIE_FW_DL ;break ; }
@@ -1963,8 +1965,11 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,if (opcode ==BTINTEL_HCI_OP_RESET )btintel_pcie_inject_cmd_complete (hdev, opcode); } -/* Firmware raises alive interrupt on HCI_OP_RESET */ -if (opcode ==HCI_OP_RESET ) + +/* Firmware raises alive interrupt on HCI_OP_RESET or +* BTINTEL_HCI_OP_RESET +*/ +if (opcode ==HCI_OP_RESET || opcode ==BTINTEL_HCI_OP_RESET ) data->gp0_received = false; hdev->stat.cmd_tx++;
@@ -2003,17 +2008,16 @@ static int btintel_pcie_send_frame(struct hci_dev *hdev,bt_dev_dbg (data->hdev,"sent cmd: 0x%4.4x alive context changed: %s -> %s" , opcode,btintel_pcie_alivectxt_state2str (old_ctxt),btintel_pcie_alivectxt_state2str (data->alive_intr_ctxt)); -if (opcode ==HCI_OP_RESET ) { - ret =wait_event_timeout (data->gp0_wait_q, - data->gp0_received, -msecs_to_jiffies (BTINTEL_DEFAULT_INTR_TIMEOUT_MS )); -if (!ret) { - hdev->stat.err_tx++; -bt_dev_err (hdev,"No alive interrupt received for %s" , -btintel_pcie_alivectxt_state2str (data->alive_intr_ctxt)); - ret = -ETIME ; - goto exit_error; - } + ret =wait_event_timeout (data->gp0_wait_q, + data->gp0_received, +msecs_to_jiffies (BTINTEL_DEFAULT_INTR_TIMEOUT_MS )); +if (!ret) { + hdev->stat.err_tx++; +bt_dev_err (hdev,"Timeout on alive interrupt (%u ms). Alive context: %s" , +BTINTEL_DEFAULT_INTR_TIMEOUT_MS , +btintel_pcie_alivectxt_state2str (data->alive_intr_ctxt)); + ret = -ETIME ; + goto exit_error; } } hdev->stat.byte_tx += skb->len;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 260/627 Bluetooth: hci_event: Mask data status from LE ext adv reports
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Chris Down <[email protected]>
[ Upstream commit 0cadf8534f2a727bc3a01e8c583b085d25963ee0 ]
The Event_Type field in an LE Extended Advertising Report uses bits 5 and 6 for data status (e.g. truncation or fragmentation), not the PDU type itself.
The ext_evt_type_to_legacy() function fails to mask these status bits before evaluation. This causes valid advertisements with status bits set (e.g. a truncated non-connectable advertisement, which ends up showing as PDU type 0x40) to be misclassified as unknown and subsequently dropped. This is okay for most checks which use bitwise AND on the relevant event type bits, but it doesn't work for non-connectable types, which are checked with '== LE_EXT_ADV_NON_CONN_IND' (that is, zero).
In terms of behaviour, first the device sends a truncated report:
Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 26
LE Extended Advertising Report (0x0d)
Entry 0
Event type: 0x0040
Data status: Incomplete, data truncated, no more to come
Address type: Random (0x01)
Address: 1D:12:46:FA:F8:6E (Non-Resolvable)
SID: 0x03
RSSI: -98 dBm (0x9e)
Data length: 0x00Then, a few seconds later, it sends the subsequent complete report:
Quoted 1 line
HCI Event: LE Meta Event (
0x3e) plen 122
LE Extended Advertising Report (0x0d)
Entry 0
Event type: 0x0000
Data status: Complete
Address type: Random (0x01)
Address: 1D:12:46:FA:F8:6E (Non-Resolvable)
SID: 0x03
RSSI: -97 dBm (0x9f)
Data length: 0x60
Service Data: Google (0xfef3)
Data[92]: ...These devices often send multiple truncated reports per second.
This patch introduces a PDU type mask to ensure only the relevant bits are evaluated, allowing for the correct translation of all valid extended advertising packets.
--- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_event.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-)
include/net/bluetooth/hci.h +1 -0
@@ -2634,6 +2634,7 @@ struct hci_ev_le_conn_complete {#define LE_EXT_ADV_DIRECT_IND 0x0004#define LE_EXT_ADV_SCAN_RSP 0x0008#define LE_EXT_ADV_LEGACY_PDU 0x0010 +#define LE_EXT_ADV_DATA_STATUS_MASK 0x0060#define LE_EXT_ADV_EVT_TYPE_MASK 0x007f#define ADDR_LE_DEV_PUBLIC 0x00
net/bluetooth/hci_event.c +6 -2
@@ -6239,6 +6239,11 @@ static void hci_le_adv_report_evt(struct hci_dev *hdev, void *data,static u8 ext_evt_type_to_legacy (struct hci_dev *hdev,u16 evt_type) { +u16 pdu_type = evt_type & ~LE_EXT_ADV_DATA_STATUS_MASK ; + +if (!pdu_type) +return LE_ADV_NONCONN_IND ; +if (evt_type &LE_EXT_ADV_LEGACY_PDU ) {switch (evt_type) {case LE_LEGACY_ADV_IND :
@@ -6270,8 +6275,7 @@ static u8 ext_evt_type_to_legacy(struct hci_dev *hdev, u16 evt_type)if (evt_type &LE_EXT_ADV_SCAN_IND )return LE_ADV_SCAN_IND ; -if (evt_type ==LE_EXT_ADV_NON_CONN_IND || - evt_type &LE_EXT_ADV_DIRECT_IND ) +if (evt_type &LE_EXT_ADV_DIRECT_IND )return LE_ADV_NONCONN_IND ; invalid:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 261/627 bpf: Disable migration in nf_hook_run_bpf().
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 17ce3e5949bc37557305ad46316f41c7875d6366 ]
syzbot reported that the netfilter bpf prog can be called without migration disabled in xmit path.
Then the assertion in __bpf_prog_run() fails, triggering the splat below. [0]
Let's use bpf_prog_run_pin_on_cpu() in nf_hook_run_bpf().
[0]:
BUG: assuming non migratable context at ./include/linux/filter.h:703
in_atomic(): 0, irqs_disabled(): 0, migration_disabled() 0 pid: 5829, name: sshd-session
3 locks held by sshd-session/5829:
#0: ffff88807b4e4218 (sk_lock-AF_INET){+.+.}-{0:0}, at: lock_sock include/net/sock.h:1667 [inline] #0: ffff88807b4e4218 (sk_lock-AF_INET){+.+.}-{0:0}, at: tcp_sendmsg+0x20/0x50 net/ipv4/tcp.c:1395 #1: ffffffff8e5c4e00 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline] #1: ffffffff8e5c4e00 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:841 [inline] #1: ffffffff8e5c4e00 (rcu_read_lock){....}-{1:3}, at: __ip_queue_xmit+0x69/0x26c0 net/ipv4/ip_output.c:470 #2: ffffffff8e5c4e00 (rcu_read_lock){....}-{1:3}, at: rcu_lock_acquire include/linux/rcupdate.h:331 [inline] #2: ffffffff8e5c4e00 (rcu_read_lock){....}-{1:3}, at: rcu_read_lock include/linux/rcupdate.h:841 [inline] #2: ffffffff8e5c4e00 (rcu_read_lock){....}-{1:3}, at: nf_hook+0xb2/0x680 include/linux/netfilter.h:241
CPU: 0 UID: 0 PID: 5829 Comm: sshd-session Not tainted 6.16.0-rc6-syzkaller-00002-g155a3c003e55 #0 PREEMPT(full) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 05/07/2025 Call Trace: <TASK> __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0x16c/0x1f0 lib/dump_stack.c:120 __cant_migrate kernel/sched/core.c:8860 [inline] __cant_migrate+0x1c7/0x250 kernel/sched/core.c:8834 __bpf_prog_run include/linux/filter.h:703 [inline] bpf_prog_run include/linux/filter.h:725 [inline] nf_hook_run_bpf+0x83/0x1e0 net/netfilter/nf_bpf_link.c:20 nf_hook_entry_hookfn include/linux/netfilter.h:157 [inline] nf_hook_slow+0xbb/0x200 net/netfilter/core.c:623 nf_hook+0x370/0x680 include/linux/netfilter.h:272 NF_HOOK_COND include/linux/netfilter.h:305 [inline] ip_output+0x1bc/0x2a0 net/ipv4/ip_output.c:433 dst_output include/net/dst.h:459 [inline] ip_local_out net/ipv4/ip_output.c:129 [inline] __ip_queue_xmit+0x1d7d/0x26c0 net/ipv4/ip_output.c:527 __tcp_transmit_skb+0x2686/0x3e90 net/ipv4/tcp_output.c:1479 tcp_transmit_skb net/ipv4/tcp_output.c:1497 [inline] tcp_write_xmit+0x1274/0x84e0 net/ipv4/tcp_output.c:2838 __tcp_push_pending_frames+0xaf/0x390 net/ipv4/tcp_output.c:3021 tcp_push+0x225/0x700 net/ipv4/tcp.c:759 tcp_sendmsg_locked+0x1870/0x42b0 net/ipv4/tcp.c:1359 tcp_sendmsg+0x2e/0x50 net/ipv4/tcp.c:1396 inet_sendmsg+0xb9/0x140 net/ipv4/af_inet.c:851 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg net/socket.c:727 [inline] sock_write_iter+0x4aa/0x5b0 net/socket.c:1131 new_sync_write fs/read_write.c:593 [inline] vfs_write+0x6c7/0x1150 fs/read_write.c:686 ksys_write+0x1f8/0x250 fs/read_write.c:738 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline] do_syscall_64+0xcd/0x4c0 arch/x86/entry/syscall_64.c:94 entry_SYSCALL_64_after_hwframe+0x77/0x7f RIP: 0033:0x7fe7d365d407 Code: 48 89 fa 4c 89 df e8 38 aa 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
RSP:
--- net/netfilter/nf_bpf_link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/nf_bpf_link.c +1 -1
@@ -17,7 +17,7 @@ static unsigned int nf_hook_run_bpf(void *bpf_prog, struct sk_buff *skb, .skb = skb, }; -return bpf_prog_run (prog, &ctx); +return bpf_prog_run_pin_on_cpu (prog, &ctx); }struct bpf_nf_link {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 262/627 bpf: Reject narrower access to pointer ctx fields
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Chaignon <[email protected]>
[ Upstream commit e09299225d5ba3916c91ef70565f7d2187e4cca0 ]
The following BPF program, simplified from a syzkaller repro, causes a kernel warning:
r0 = *(u8 *)(r1 + 169);
exit;With pointer field sk being at offset 168 in __sk_buff. This access is detected as a narrower read in bpf_skb_is_valid_access because it doesn't match offsetof(struct __sk_buff, sk). It is therefore allowed and later proceeds to bpf_convert_ctx_access. Note that for the "is_narrower_load" case in the convert_ctx_accesses(), the insn->off is aligned, so the cnt may not be 0 because it matches the offsetof(struct __sk_buff, sk) in the bpf_convert_ctx_access. However, the target_size stays 0 and the verifier errors with a kernel warning:
verifier bug: error during ctx access conversion(1)
This patch fixes that to return a proper "invalid bpf_context access off=X size=Y" error on the load instruction.
The same issue affects multiple other fields in context structures that allow narrow access. Some other non-affected fields (for sk_msg, sk_lookup, and sockopt) were also changed to use bpf_ctx_range_ptr for consistency.
Note this syzkaller crash was reported in the "Closes" link below, which used to be about a different bug, fixed in
commit fce7bd8e385a ("bpf/verifier: Handle BPF_LOAD_ACQ instructions in insn_def_regno()"). Because syzbot somehow confused the two bugs, the new crash and repro didn't get reported to the mailing list.
--- kernel/bpf/cgroup.c | 8 ++++---- net/core/filter.c | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-)
kernel/bpf/cgroup.c +4 -4
@@ -2440,22 +2440,22 @@ static bool cg_sockopt_is_valid_access(int off, int size, }switch (off) { -case offsetof(struct bpf_sockopt , sk): + case bpf_ctx_range_ptr(struct bpf_sockopt, sk):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_SOCKET ;break ; -case offsetof(struct bpf_sockopt , optval): + case bpf_ctx_range_ptr(struct bpf_sockopt, optval):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_PACKET ;break ; -case offsetof(struct bpf_sockopt , optval_end): + case bpf_ctx_range_ptr(struct bpf_sockopt, optval_end):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_PACKET_END ;break ; -case offsetof(struct bpf_sockopt , retval): + case bpf_ctx_range(struct bpf_sockopt, retval):if (size != size_default)return false;return prog->expected_attach_type ==BPF_CGROUP_GETSOCKOPT ;
net/core/filter.c +10 -10
@@ -8690,7 +8690,7 @@ static bool bpf_skb_is_valid_access(int off, int size, enum bpf_access_type typeif (size !=sizeof (__u64))return false;break ; -case offsetof(struct __sk_buff , sk): + case bpf_ctx_range_ptr(struct __sk_buff, sk):if (type ==BPF_WRITE || size !=sizeof (__u64))return false; info->reg_type =PTR_TO_SOCK_COMMON_OR_NULL ;
@@ -9268,7 +9268,7 @@ static bool sock_addr_is_valid_access(int off, int size,return false; }break ; -case offsetof(struct bpf_sock_addr , sk): + case bpf_ctx_range_ptr(struct bpf_sock_addr, sk):if (type !=BPF_READ )return false;if (size !=sizeof (__u64))
@@ -9318,17 +9318,17 @@ static bool sock_ops_is_valid_access(int off, int size,if (size !=sizeof (__u64))return false;break ; -case offsetof(struct bpf_sock_ops , sk): + case bpf_ctx_range_ptr(struct bpf_sock_ops, sk):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_SOCKET_OR_NULL ;break ; -case offsetof(struct bpf_sock_ops , skb_data): + case bpf_ctx_range_ptr(struct bpf_sock_ops, skb_data):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_PACKET ;break ; -case offsetof(struct bpf_sock_ops , skb_data_end): + case bpf_ctx_range_ptr(struct bpf_sock_ops, skb_data_end):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_PACKET_END ;
@@ -9337,7 +9337,7 @@ static bool sock_ops_is_valid_access(int off, int size,bpf_ctx_record_field_size (info, size_default);return bpf_ctx_narrow_access_ok (off, size, size_default); -case offsetof(struct bpf_sock_ops , skb_hwtstamp): + case bpf_ctx_range(struct bpf_sock_ops, skb_hwtstamp):if (size !=sizeof (__u64))return false;break ;
@@ -9407,17 +9407,17 @@ static bool sk_msg_is_valid_access(int off, int size,return false;switch (off) { -case offsetof(struct sk_msg_md , data): + case bpf_ctx_range_ptr(struct sk_msg_md, data): info->reg_type =PTR_TO_PACKET ;if (size !=sizeof (__u64))return false;break ; -case offsetof(struct sk_msg_md , data_end): + case bpf_ctx_range_ptr(struct sk_msg_md, data_end): info->reg_type =PTR_TO_PACKET_END ;if (size !=sizeof (__u64))return false;break ; -case offsetof(struct sk_msg_md , sk): + case bpf_ctx_range_ptr(struct sk_msg_md, sk):if (size !=sizeof (__u64))return false; info->reg_type =PTR_TO_SOCKET ;
@@ -11623,7 +11623,7 @@ static bool sk_lookup_is_valid_access(int off, int size,return false;switch (off) { -case offsetof(struct bpf_sk_lookup , sk): + case bpf_ctx_range_ptr(struct bpf_sk_lookup, sk): info->reg_type =PTR_TO_SOCKET_OR_NULL ;return size ==sizeof (__u64);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 263/627 tools/rv: Do not skip idle in trace
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Monaco <[email protected]>
[ Upstream commit f60227f3448911b682c45041c3fbd94f6d3b15a2 ]
Currently, the userspace RV tool skips trace events triggered by the RV tool itself, this can be changed by passing the parameter -s, which sets the variable config_my_pid to 0 (instead of the tool's PID). This has the side effect of skipping events generated by idle (PID 0).
Set config_my_pid to -1 (an invalid pid) to avoid skipping idle.
--- tools/verification/rv/src/in_kernel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/verification/rv/src/in_kernel.c +2 -2
@@ -431,7 +431,7 @@ ikm_event_handler(struct trace_seq *s, struct tep_record *record,if (config_has_id && (config_my_pid == id))return 0 ; -else if (config_my_pid && (config_my_pid == pid)) +else if (config_my_pid == pid)return 0 ; tep_print_event(trace_event->tep, s, record, "%16s-%-8d [%.3d] ",
@@ -734,7 +734,7 @@ static int parse_arguments(char *monitor_name, int argc, char **argv) config_reactor = optarg;break ;case 's' : - config_my_pid =0 ; + config_my_pid =-1 ;break ;case 't' : config_trace =1 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 264/627 selftests: drv-net: Fix remote command checking in require_cmd()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gal Pressman <[email protected]>
[ Upstream commit b4d52c698210ae1a3ceb487b189701bc70551a48 ]
The require_cmd() method was checking for command availability locally even when remote=True was specified, due to a missing host parameter.
Fix by passing host=self.remote when checking remote command availability, ensuring commands are verified on the correct host.
--- tools/testing/selftests/drivers/net/lib/py/env.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/drivers/net/lib/py/env.py +1 -1
@@ -259,7 +259,7 @@ class NetDrvEpEnv(NetDrvEnvBase): if not self._require_cmd(comm, "local"): raise KsftSkipEx("Test requires command: " + comm) if remote: - if not self._require_cmd(comm, "remote"): + if not self._require_cmd(comm, "remote", host=self.remote): raise KsftSkipEx("Test requires (remote) command: " + comm) def wait_hw_stats_settle(self):
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 265/627 selftests: drv-net: tso: enable test cases based on hw_features
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Zahka <[email protected]>
[ Upstream commit 266b835e5e84a0f8fec7fd988ee81925890e8d89 ]
tso.py uses the active features at the time of test execution as the set of available gso features to test. This means if a gso feature is supported but toggled off at test start, the test will be skipped with a "Device does not support {feature}" message.
Instead, we can enumerate the set of toggleable features by capturing the driver's hw_features bitmap. To avoid configuration side-effects from running the test, we also snapshot the wanted_features flag set before making any feature changes, and then attempt to restore the same set of wanted_features before test exit.
--- tools/testing/selftests/drivers/net/hw/tso.py | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-)
tools/testing/selftests/drivers/net/hw/tso.py +40 -12
@@ -119,15 +119,30 @@ def build_tunnel(cfg, outer_ipver, tun_info): return remote_v4, remote_v6 +def restore_wanted_features(cfg): + features_cmd = "" + for feature in cfg.hw_features: + setting = "on" if feature in cfg.wanted_features else "off" + features_cmd += f" {feature} {setting}" + try: + ethtool(f"-K {cfg.ifname} {features_cmd}") + except Exception as e: + ksft_pr(f"WARNING: failure restoring wanted features: {e}") + + def test_builder(name, cfg, outer_ipver, feature, tun=None, inner_ipver=None): """Construct specific tests from the common template.""" def f(cfg): cfg.require_ipver(outer_ipver) + defer(restore_wanted_features, cfg) if not cfg.have_stat_super_count and \ not cfg.have_stat_wire_count: raise KsftSkipEx(f"Device does not support LSO queue stats") + if feature not in cfg.hw_features: + raise KsftSkipEx(f"Device does not support {feature}") + ipver = outer_ipver if tun: remote_v4, remote_v6 = build_tunnel(cfg, ipver, tun)
@@ -138,12 +153,12 @@ def test_builder(name, cfg, outer_ipver, feature, tun=None, inner_ipver=None): tun_partial = tun and tun[1] # Tunnel which can silently fall back to gso-partial - has_gso_partial = tun and 'tx-gso-partial' in cfg.features + has_gso_partial = tun and 'tx-gso-partial' in cfg.hw_features # For TSO4 via partial we need mangleid if ipver == "4" and feature in cfg.partial_features: ksft_pr("Testing with mangleid enabled") - if 'tx-tcp-mangleid-segmentation' not in cfg.features: + if 'tx-tcp-mangleid-segmentation' not in cfg.hw_features: ethtool(f"-K {cfg.ifname} tx-tcp-mangleid-segmentation on") defer(ethtool, f"-K {cfg.ifname} tx-tcp-mangleid-segmentation off")
@@ -161,11 +176,8 @@ def test_builder(name, cfg, outer_ipver, feature, tun=None, inner_ipver=None): should_lso=tun_partial) # Full feature enabled. - if feature in cfg.features: - ethtool(f"-K {cfg.ifname} {feature} on") - run_one_stream(cfg, ipver, remote_v4, remote_v6, should_lso=True) - else: - raise KsftXfailEx(f"Device does not support {feature}") + ethtool(f"-K {cfg.ifname} {feature} on") + run_one_stream(cfg, ipver, remote_v4, remote_v6, should_lso=True) f.__name__ = name + ((outer_ipver + "_") if tun else "") + "ipv" + inner_ipver return f
@@ -176,23 +188,39 @@ def query_nic_features(cfg) -> None: cfg.have_stat_super_count = False cfg.have_stat_wire_count = False - cfg.features = set() features = cfg.ethnl.features_get({"header": {"dev-index": cfg.ifindex}}) - for f in features["active"]["bits"]["bit"]: - cfg.features.add(f["name"]) + + cfg.wanted_features = set() + for f in features["wanted"]["bits"]["bit"]: + cfg.wanted_features.add(f["name"]) + + cfg.hw_features = set() + hw_all_features_cmd = "" + for f in features["hw"]["bits"]["bit"]: + if f.get("value", False): + feature = f["name"] + cfg.hw_features.add(feature) + hw_all_features_cmd += f" {feature} on" + try: + ethtool(f"-K {cfg.ifname} {hw_all_features_cmd}") + except Exception as e: + ksft_pr(f"WARNING: failure enabling all hw features: {e}") + ksft_pr("partial gso feature detection may be impacted") # Check which features are supported via GSO partial cfg.partial_features = set() - if 'tx-gso-partial' in cfg.features: + if 'tx-gso-partial' in cfg.hw_features: ethtool(f"-K {cfg.ifname} tx-gso-partial off") no_partial = set() features = cfg.ethnl.features_get({"header": {"dev-index": cfg.ifindex}}) for f in features["active"]["bits"]["bit"]: no_partial.add(f["name"]) - cfg.partial_features = cfg.features - no_partial + cfg.partial_features = cfg.hw_features - no_partial ethtool(f"-K {cfg.ifname} tx-gso-partial on") + restore_wanted_features(cfg) + stats = cfg.netnl.qstats_get({"ifindex": cfg.ifindex}, dump=True) if stats: if 'tx-hw-gso-packets' in stats[0]:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 266/627 selftests: drv-net: tso: fix vxlan tunnel flags to get correct gso_type
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Zahka <[email protected]>
[ Upstream commit 2cfbcc5d8af9199823151c21f740e476b223dd2e ]
When vxlan is used with ipv6 as the outer network header, the correct ip link parameters for acheiving the SKB_GSO_UDP_TUNNEL gso type is "udp6zerocsumtx udp6zerocsumrx". Otherwise the gso type will be SKB_GSO_UDP_TUNNEL_CSUM.
This bug was the reason for the second of the three possible invocations of run_one_stream() invocations, so that can be deleted as well. We only need to test with the feature off and on.
--- tools/testing/selftests/drivers/net/hw/tso.py | 37 +++++++------------ 1 file changed, 13 insertions(+), 24 deletions(-)
tools/testing/selftests/drivers/net/hw/tso.py +13 -24
@@ -102,7 +102,7 @@ def build_tunnel(cfg, outer_ipver, tun_info): remote_addr = cfg.remote_addr_v[outer_ipver] tun_type = tun_info[0] - tun_arg = tun_info[2] + tun_arg = tun_info[1] ip(f"link add {tun_type}-ksft type {tun_type} {tun_arg} local {local_addr} remote {remote_addr} dev {cfg.ifname}") defer(ip, f"link del {tun_type}-ksft") ip(f"link set dev {tun_type}-ksft up")
@@ -151,29 +151,17 @@ def test_builder(name, cfg, outer_ipver, feature, tun=None, inner_ipver=None): remote_v4 = cfg.remote_addr_v["4"] remote_v6 = cfg.remote_addr_v["6"] - tun_partial = tun and tun[1] - # Tunnel which can silently fall back to gso-partial - has_gso_partial = tun and 'tx-gso-partial' in cfg.hw_features - - # For TSO4 via partial we need mangleid - if ipver == "4" and feature in cfg.partial_features: - ksft_pr("Testing with mangleid enabled") - if 'tx-tcp-mangleid-segmentation' not in cfg.hw_features: - ethtool(f"-K {cfg.ifname} tx-tcp-mangleid-segmentation on") - defer(ethtool, f"-K {cfg.ifname} tx-tcp-mangleid-segmentation off") - # First test without the feature enabled. ethtool(f"-K {cfg.ifname} {feature} off") - if has_gso_partial: - ethtool(f"-K {cfg.ifname} tx-gso-partial off") run_one_stream(cfg, ipver, remote_v4, remote_v6, should_lso=False) - # Now test with the feature enabled. - # For compatible tunnels only - just GSO partial, not specific feature. - if has_gso_partial: + ethtool(f"-K {cfg.ifname} tx-gso-partial off") + ethtool(f"-K {cfg.ifname} tx-tcp-mangleid-segmentation off") + if feature in cfg.partial_features: ethtool(f"-K {cfg.ifname} tx-gso-partial on") - run_one_stream(cfg, ipver, remote_v4, remote_v6, - should_lso=tun_partial) + if ipver == "4": + ksft_pr("Testing with mangleid enabled") + ethtool(f"-K {cfg.ifname} tx-tcp-mangleid-segmentation on") # Full feature enabled. ethtool(f"-K {cfg.ifname} {feature} on")
@@ -239,13 +227,14 @@ def main() -> None: query_nic_features(cfg) test_info = ( - # name, v4/v6 ethtool_feature tun:(type, partial, args) + # name, v4/v6 ethtool_feature tun:(type, args) ("", "4", "tx-tcp-segmentation", None), ("", "6", "tx-tcp6-segmentation", None), - ("vxlan", "", "tx-udp_tnl-segmentation", ("vxlan", True, "id 100 dstport 4789 noudpcsum")), - ("vxlan_csum", "", "tx-udp_tnl-csum-segmentation", ("vxlan", False, "id 100 dstport 4789 udpcsum")), - ("gre", "4", "tx-gre-segmentation", ("gre", False, "")), - ("gre", "6", "tx-gre-segmentation", ("ip6gre", False, "")), + ("vxlan", "4", "tx-udp_tnl-segmentation", ("vxlan", "id 100 dstport 4789 noudpcsum")), + ("vxlan", "6", "tx-udp_tnl-segmentation", ("vxlan", "id 100 dstport 4789 udp6zerocsumtx udp6zerocsumrx")), + ("vxlan_csum", "", "tx-udp_tnl-csum-segmentation", ("vxlan", "id 100 dstport 4789 udpcsum")), + ("gre", "4", "tx-gre-segmentation", ("gre", "")), + ("gre", "6", "tx-gre-segmentation", ("ip6gre", "")), ) cases = []
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 267/627 selftests: drv-net: tso: fix non-tunneled tso6 test case name
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Zahka <[email protected]>
[ Upstream commit b25b44cd178cc54277f2dc0ff3b3d5a37ae4b26b ]
The non-tunneled tso6 test case was showing up as:
ok 8 tso.ipv4
This is because of the way test_builder() uses the inner_ipver arg in test naming, and how test_info is iterated over in main(). Given that some tunnels not supported yet, e.g. ipip or sit, only support ipv4 or ipv6 as the inner network protocol, I think the best fix here is to call test_builder() in separate branches for tunneled and non-tunneled tests, and to make supported inner l3 types an explicit attribute of tunnel test cases.
# Detected qstat for LSO wire-packets
TAP version 13
1..14
ok 1 tso.ipv4
# Testing with mangleid enabled
ok 2 tso.vxlan4_ipv4
ok 3 tso.vxlan4_ipv6
# Testing with mangleid enabled
ok 4 tso.vxlan_csum4_ipv4
ok 5 tso.vxlan_csum4_ipv6
# Testing with mangleid enabled
ok 6 tso.gre4_ipv4
ok 7 tso.gre4_ipv6
ok 8 tso.ipv6
# Testing with mangleid enabled
ok 9 tso.vxlan6_ipv4
ok 10 tso.vxlan6_ipv6
# Testing with mangleid enabled
ok 11 tso.vxlan_csum6_ipv4
ok 12 tso.vxlan_csum6_ipv6
# Testing with mangleid enabled
ok 13 tso.gre6_ipv4
ok 14 tso.gre6_ipv6
# Totals: pass:14 fail:0 xfail:0 xpass:0 skip:0 error:0
--- tools/testing/selftests/drivers/net/hw/tso.py | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-)
tools/testing/selftests/drivers/net/hw/tso.py +14 -12
@@ -227,14 +227,14 @@ def main() -> None: query_nic_features(cfg) test_info = ( - # name, v4/v6 ethtool_feature tun:(type, args) - ("", "4", "tx-tcp-segmentation", None), - ("", "6", "tx-tcp6-segmentation", None), - ("vxlan", "4", "tx-udp_tnl-segmentation", ("vxlan", "id 100 dstport 4789 noudpcsum")), - ("vxlan", "6", "tx-udp_tnl-segmentation", ("vxlan", "id 100 dstport 4789 udp6zerocsumtx udp6zerocsumrx")), - ("vxlan_csum", "", "tx-udp_tnl-csum-segmentation", ("vxlan", "id 100 dstport 4789 udpcsum")), - ("gre", "4", "tx-gre-segmentation", ("gre", "")), - ("gre", "6", "tx-gre-segmentation", ("ip6gre", "")), + # name, v4/v6 ethtool_feature tun:(type, args, inner ip versions) + ("", "4", "tx-tcp-segmentation", None), + ("", "6", "tx-tcp6-segmentation", None), + ("vxlan", "4", "tx-udp_tnl-segmentation", ("vxlan", "id 100 dstport 4789 noudpcsum", ("4", "6"))), + ("vxlan", "6", "tx-udp_tnl-segmentation", ("vxlan", "id 100 dstport 4789 udp6zerocsumtx udp6zerocsumrx", ("4", "6"))), + ("vxlan_csum", "", "tx-udp_tnl-csum-segmentation", ("vxlan", "id 100 dstport 4789 udpcsum", ("4", "6"))), + ("gre", "4", "tx-gre-segmentation", ("gre", "", ("4", "6"))), + ("gre", "6", "tx-gre-segmentation", ("ip6gre","", ("4", "6"))), ) cases = []
@@ -244,11 +244,13 @@ def main() -> None: if info[1] and outer_ipver != info[1]: continue - cases.append(test_builder(info[0], cfg, outer_ipver, info[2], - tun=info[3], inner_ipver="4")) if info[3]: - cases.append(test_builder(info[0], cfg, outer_ipver, info[2], - tun=info[3], inner_ipver="6")) + cases += [ + test_builder(info[0], cfg, outer_ipver, info[2], info[3], inner_ipver) + for inner_ipver in info[3][2] + ] + else: + cases.append(test_builder(info[0], cfg, outer_ipver, info[2], None, outer_ipver)) ksft_run(cases=cases, args=(cfg, )) ksft_exit()
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 268/627 can: peak_usb: fix USB FD devices potential malfunction
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephane Grosjean <[email protected]>
[ Upstream commit 788199b73b6efe4ee2ade4d7457b50bb45493488 ]
The latest firmware versions of USB CAN FD interfaces export the EP numbers to be used to dialog with the device via the "type" field of a response to a vendor request structure, particularly when its value is greater than or equal to 2.
Correct the driver's test of this field.
--- drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/net/can/usb/peak_usb/pcan_usb_fd.c +9 -8
@@ -49,7 +49,7 @@ struct __packed pcan_ufd_fw_info {__le32 ser_no;/* S/N */ __le32 flags;/* special functions */ -/* extended data when type == PCAN_USBFD_TYPE_EXT */ +/* extended data when type >= PCAN_USBFD_TYPE_EXT */ u8 cmd_out_ep;/* ep for cmd */ u8 cmd_in_ep;/* ep for replies */ u8 data_out_ep[2 ];/* ep for CANx TX */
@@ -982,10 +982,11 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev) dev->can.ctrlmode |=CAN_CTRLMODE_FD_NON_ISO ; } -/* if vendor rsp is of type 2, then it contains EP numbers to -* use for cmds pipes. If not, then default EP should be used. +/* if vendor rsp type is greater than or equal to 2, then it +* contains EP numbers to use for cmds pipes. If not, then +* default EP should be used. */ -if (fw_info->type !=cpu_to_le16 (PCAN_USBFD_TYPE_EXT )) { +if (le16_to_cpu (fw_info->type) <PCAN_USBFD_TYPE_EXT ) { fw_info->cmd_out_ep =PCAN_USBPRO_EP_CMDOUT ; fw_info->cmd_in_ep =PCAN_USBPRO_EP_CMDIN ; }
@@ -1018,11 +1019,11 @@ static int pcan_usb_fd_init(struct peak_usb_device *dev) dev->can_channel_id =le32_to_cpu (pdev->usb_if->fw_info.dev_id[dev->ctrl_idx]); -/* if vendor rsp is of type 2, then it contains EP numbers to -* use for data pipes. If not, then statically defined EP are used -* (see peak_usb_create_dev()). +/* if vendor rsp type is greater than or equal to 2, then it contains EP +* numbers to use for data pipes. If not, then statically defined EP are +* used (see peak_usb_create_dev()). */ -if (fw_info->type ==cpu_to_le16 (PCAN_USBFD_TYPE_EXT )) { +if (le16_to_cpu (fw_info->type) >=PCAN_USBFD_TYPE_EXT ) { dev->ep_msg_in = fw_info->data_in_ep; dev->ep_msg_out = fw_info->data_out_ep[dev->ctrl_idx]; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 269/627 can: tscan1: Kconfig: add COMPILE_TEST
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vincent Mailhol <[email protected]>
[ Upstream commit 5323af351e7524497930b7793153ff68ee5c0ec1 ]
tscan1 depends on ISA. It also has a hidden dependency on HAS_IOPORT as reported by the kernel test bot [1]. That dependency is implied by ISA which explains why this was not an issue so far.
Add both COMPILE_TEST and HAS_IOPORT to the dependency list so that this driver can also be built on other platforms.
[1] https://lore.kernel.org/linux-can/[email protected]/
Stable-dep-of: b7d012e59627 ("can: tscan1: CAN_TSCAN1 can depend on PC104")
--- drivers/net/can/sja1000/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/sja1000/Kconfig +1 -1
@@ -105,7 +105,7 @@ config CAN_SJA1000_PLATFORM config CAN_TSCAN1 tristate "TS-CAN1 PC104 boards" - depends on ISA + depends on ISA || (COMPILE_TEST && HAS_IOPORT) help This driver is for Technologic Systems' TSCAN-1 PC104 boards. https://www.embeddedts.com/products/TS-CAN1
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 270/627 can: tscan1: CAN_TSCAN1 can depend on PC104
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <[email protected]>
[ Upstream commit b7d012e59627c1d1bb2ad5d71efc69a070ef767d ]
Add a dependency on PC104 to limit (restrict) this driver kconfig prompt to kernel configs that have PC104 set.
Add COMPILE_TEST as a possibility for more complete build coverage. I tested this build config on x86_64 5 times without problems.
--- drivers/net/can/sja1000/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/can/sja1000/Kconfig +1 -1
@@ -105,7 +105,7 @@ config CAN_SJA1000_PLATFORM config CAN_TSCAN1 tristate "TS-CAN1 PC104 boards" - depends on ISA || (COMPILE_TEST && HAS_IOPORT) + depends on (ISA && PC104) || (COMPILE_TEST && HAS_IOPORT) help This driver is for Technologic Systems' TSCAN-1 PC104 boards. https://www.embeddedts.com/products/TS-CAN1
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 271/627 can: kvaser_pciefd: Store device channel index
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
[ Upstream commit d54b16b40ddadb7d0a77fff48af7b319a0cd6aae ]
Store device channel index in netdev.dev_port.
--- drivers/net/can/kvaser_pciefd.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/kvaser_pciefd.c +1 -0
@@ -982,6 +982,7 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie) can->completed_tx_bytes =0 ; can->bec.txerr =0 ; can->bec.rxerr =0 ; + can->can.dev->dev_port = i;init_completion (&can->start_comp);init_completion (&can->flush_comp);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 272/627 can: kvaser_usb: Assign netdev.dev_port based on device channel index
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jimmy Assarsson <[email protected]>
[ Upstream commit c151b06a087a61c7a1790b75ee2f1d6edb6a8a45 ]
Assign netdev.dev_port based on the device channel index, to indicate the port number of the network device.
While this driver already uses netdev.dev_id for that purpose, dev_port is more appropriate. However, retain dev_id to avoid potential regressions.
--- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +1 -0
@@ -852,6 +852,7 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel) netdev->ethtool_ops = &kvaser_usb_ethtool_ops;SET_NETDEV_DEV (netdev, &dev->intf->dev); netdev->dev_id = channel; + netdev->dev_port = channel; dev->nets[channel] = priv;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 273/627 netfilter: xt_nfacct: dont assume acct name is null-terminated
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Florian Westphal <[email protected]>
[ Upstream commit bf58e667af7d96c8eb9411f926a0a0955f41ce21 ]
BUG: KASAN: slab-out-of-bounds in .. lib/vsprintf.c:721 Read of size 1 at addr ffff88801eac95c8 by task syz-executor183/5851 [..] string+0x231/0x2b0 lib/vsprintf.c:721 vsnprintf+0x739/0xf00 lib/vsprintf.c:2874 [..] nfacct_mt_checkentry+0xd2/0xe0 net/netfilter/xt_nfacct.c:41 xt_check_match+0x3d1/0xab0 net/netfilter/x_tables.c:523
nfnl_acct_find_get() handles non-null input, but the error printk relied on its presence.
--- net/netfilter/xt_nfacct.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/xt_nfacct.c +2 -2
@@ -38,8 +38,8 @@ nfacct_mt_checkentry(const struct xt_mtchk_param *par) nfacct =nfnl_acct_find_get (par->net, info->name);if (nfacct ==NULL ) { -pr_info_ratelimited ("accounting object `%s' does not exists\n" , - info->name); +pr_info_ratelimited ("accounting object `%.*s' does not exist\n" , +NFACCT_NAME_MAX , info->name);return -ENOENT ; } info->nfacct = nfacct;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 274/627 selftests: netfilter: Ignore tainted kernels in interface stress test
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Phil Sutter <[email protected]>
[ Upstream commit 8d1c91850d064944ab214b2fbfffb7fc08a11d65 ]
Complain about kernel taint value only if it wasn't set at start already.
--- .../testing/selftests/net/netfilter/nft_interface_stress.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/net/netfilter/nft_interface_stress.sh +4 -1
@@ -10,6 +10,8 @@ source lib.sh checktool "nft --version" "run test without nft tool" checktool "iperf3 --version" "run test without iperf3 tool" +read kernel_tainted < /proc/sys/kernel/tainted + # how many seconds to torture the kernel? # default to 80% of max run time but don't exceed 48s TEST_RUNTIME=$((${kselftest_timeout:-60} * 8 / 10))
@@ -135,7 +137,8 @@ else wait fi -[[ $(</proc/sys/kernel/tainted) -eq 0 ]] || { + +[[ $kernel_tainted -eq 0 && $(</proc/sys/kernel/tainted) -ne 0 ]] && { echo "FAIL: Kernel is tainted!" exit $ksft_fail }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 275/627 selftests: netfilter: ipvs.sh: Explicity disable rp_filter on interface tunl0
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yi Chen <[email protected]>
[ Upstream commit 8b4a1a46e84a17f5d6fde5c506cc6bb141a24772 ]
Although setup_ns() set net.ipv4.conf.default.rp_filter=0,
loading certain module such as ipip will automatically create a tunl0 interface in all netns including new created ones. In the script, this is before than default.rp_filter=0 applied, as a result tunl0.rp_filter remains set to 1 which causes the test report FAIL when ipip module is preloaded.
Before fix:
Testing DR mode...
Testing NAT mode...
Testing Tunnel mode...ipvs.sh: FAIL
After fix:
Testing DR mode...
Testing NAT mode...
Testing Tunnel mode...ipvs.sh: PASS
--- tools/testing/selftests/net/netfilter/ipvs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/netfilter/ipvs.sh +2 -2
@@ -151,7 +151,7 @@ test_nat() { test_tun() { ip netns exec "${ns0}" ip route add "${vip_v4}" via "${gip_v4}" dev br0 - ip netns exec "${ns1}" modprobe -q ipip + modprobe -q ipip ip netns exec "${ns1}" ip link set tunl0 up ip netns exec "${ns1}" sysctl -qw net.ipv4.ip_forward=0 ip netns exec "${ns1}" sysctl -qw net.ipv4.conf.all.send_redirects=0
@@ -160,10 +160,10 @@ test_tun() { ip netns exec "${ns1}" ipvsadm -a -i -t "${vip_v4}:${port}" -r ${rip_v4}:${port} ip netns exec "${ns1}" ip addr add ${vip_v4}/32 dev lo:1 - ip netns exec "${ns2}" modprobe -q ipip ip netns exec "${ns2}" ip link set tunl0 up ip netns exec "${ns2}" sysctl -qw net.ipv4.conf.all.arp_ignore=1 ip netns exec "${ns2}" sysctl -qw net.ipv4.conf.all.arp_announce=2 + ip netns exec "${ns2}" sysctl -qw net.ipv4.conf.tunl0.rp_filter=0 ip netns exec "${ns2}" ip addr add "${vip_v4}/32" dev lo:1 test_service
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 276/627 net/mlx5e: Clear Read-Only port buffer size in PBMC before update
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexei Lazar <[email protected]>
[ Upstream commit fd4b97246a23c1149479b88490946bcfbd28de63 ]
When updating the PBMC register, we read its current value, modify desired fields, then write it back.
The port_buffer_size field within PBMC is Read-Only (RO). If this RO field contains a non-zero value when read, attempting to write it back will cause the entire PBMC register update to fail.
This commit ensures port_buffer_size is explicitly cleared to zero after reading the PBMC register but before writing back the modified value.
This allows updates to other fields in the PBMC register to succeed.
--- drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en/port_buffer.c +3 -0
@@ -331,6 +331,9 @@ static int port_set_buffer(struct mlx5e_priv *priv,if (err) goto out; +/* RO bits should be set to 0 on write */ +MLX5_SET (pbmc_reg, in, port_buffer_size,0 ); + err =mlx5e_port_set_pbmc (mdev, in); out:kfree (in);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 277/627 net/mlx5e: Remove skb secpath if xfrm state is not found
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jianbo Liu <[email protected]>
[ Upstream commit 6d19c44b5c6dd72f9a357d0399604ec16a77de3c ]
Hardware returns a unique identifier for a decrypted packet's xfrm state, this state is looked up in an xarray. However, the state might have been freed by the time of this lookup.
Currently, if the state is not found, only a counter is incremented. The secpath (sp) extension on the skb is not removed, resulting in sp->len becoming 0.
Subsequently, functions like __xfrm_policy_check() attempt to access fields such as xfrm_input_state(skb)->xso.type (which dereferences sp->xvec[sp->len - 1]) without first validating sp->len. This leads to a crash when dereferencing an invalid state pointer.
This patch prevents the crash by explicitly removing the secpath extension from the skb if the xfrm state is not found after hardware decryption. This ensures downstream functions do not operate on a zero-length secpath.
BUG: unable to handle page fault for address: ffffffff000002c8 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 282e067 P4D 282e067 PUD 0 Oops: Oops: 0000 [#1] SMP CPU: 12 UID: 0 PID: 0 Comm: swapper/12 Not tainted 6.15.0-rc7_for_upstream_min_debug_2025_05_27_22_44 #1 NONE Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014 RIP: 0010:__xfrm_policy_check+0x61a/0xa30 Code: b6 77 7f 83 e6 02 74 14 4d 8b af d8 00 00 00 41 0f b6 45 05 c1 e0 03 48 98 49 01 c5 41 8b 45 00 83 e8 01 48 98 49 8b 44 c5 10 <0f> b6 80 c8 02 00 00 83 e0 0c 3c 04 0f 84 0c 02 00 00 31 ff 80 fa RSP: 0018:ffff88885fb04918 EFLAGS: 00010297 RAX: ffffffff00000000 RBX: 0000000000000002 RCX: 0000000000000000 RDX: 0000000000000002 RSI: 0000000000000002 RDI: 0000000000000000 RBP: ffffffff8311af80 R08: 0000000000000020 R09: 00000000c2eda353 R10: ffff88812be2bbc8 R11: 000000001faab533 R12: ffff88885fb049c8 R13: ffff88812be2bbc8 R14: 0000000000000000 R15: ffff88811896ae00 FS: 0000000000000000(0000) GS:ffff8888dca82000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffff000002c8 CR3: 0000000243050002 CR4: 0000000000372eb0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <IRQ> ? try_to_wake_up+0x108/0x4c0 ? udp4_lib_lookup2+0xbe/0x150 ? udp_lib_lport_inuse+0x100/0x100 ? __udp4_lib_lookup+0x2b0/0x410 __xfrm_policy_check2.constprop.0+0x11e/0x130 udp_queue_rcv_one_skb+0x1d/0x530 udp_unicast_rcv_skb+0x76/0x90 __udp4_lib_rcv+0xa64/0xe90 ip_protocol_deliver_rcu+0x20/0x130 ip_local_deliver_finish+0x75/0xa0 ip_local_deliver+0xc1/0xd0 ? ip_protocol_deliver_rcu+0x130/0x130 ip_sublist_rcv+0x1f9/0x240 ? ip_rcv_finish_core+0x430/0x430 ip_list_rcv+0xfc/0x130 __netif_receive_skb_list_core+0x181/0x1e0 netif_receive_skb_list_internal+0x200/0x360 ? mlx5e_build_rx_skb+0x1bc/0xda0 [mlx5_core] gro_receive_skb+0xfd/0x210 mlx5e_handle_rx_cqe_mpwrq+0x141/0x280 [mlx5_core] mlx5e_poll_rx_cq+0xcc/0x8e0 [mlx5_core] ? mlx5e_handle_rx_dim+0x91/0xd0 [mlx5_core] mlx5e_napi_poll+0x114/0xab0 [mlx5_core] __napi_poll+0x25/0x170 net_rx_action+0x32d/0x3a0 ? mlx5_eq_comp_int+0x8d/0x280 [mlx5_core] ? notifier_call_chain+0x33/0xa0 handle_softirqs+0xda/0x250 irq_exit_rcu+0x6d/0xc0 common_interrupt+0x81/0xa0 </IRQ>
--- drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec_rxtx.c +4 -0
@@ -327,6 +327,10 @@ void mlx5e_ipsec_offload_handle_rx_skb(struct net_device *netdev,if (unlikely (!sa_entry)) {rcu_read_unlock ();atomic64_inc (&ipsec->sw_stats.ipsec_rx_drop_sadb_miss); +/* Clear secpath to prevent invalid dereference +* in downstream XFRM policy checks. +*/ +secpath_reset (skb);return ; }xfrm_state_hold (sa_entry->x);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 278/627 net/mlx5e: Fix potential deadlock by deferring RX timeout recovery
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shahar Shitrit <[email protected]>
[ Upstream commit e80d65561571db5024fbdd5ec3f5472cfc485d21 ]
mlx5e_reporter_rx_timeout() is currently invoked synchronously in the driver's open error flow. This causes the thread holding priv->state_lock to attempt acquiring the devlink lock, which can result in a circular dependency with other devlink operations.
For example:
- Devlink health diagnose flow:
- __devlink_nl_pre_doit() acquires the devlink lock.
- devlink_nl_health_reporter_diagnose_doit() invokes the driver's diagnose callback.
- mlx5e_rx_reporter_diagnose() then attempts to acquire
priv->state_lock.
- Driver open flow:
- mlx5e_open() acquires priv->state_lock.
- If an error occurs, devlink_health_reporter may be called, attempting to acquire the devlink lock.
To prevent this circular locking scenario, defer the RX timeout recovery by scheduling it via a workqueue. This ensures that the recovery work acquires locks in a consistent order: first the devlink lock, then priv->state_lock.
Additionally, make the recovery work acquire the netdev instance lock to safely synchronize with the open/close channel flows, similar to mlx5e_tx_timeout_work. Repeatedly attempt to acquire the netdev instance lock until it is taken or the target RQ is no longer active, as indicated by the MLX5E_STATE_CHANNELS_ACTIVE bit.
--- drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + .../mellanox/mlx5/core/en/reporter_rx.c | 7 +++++ .../net/ethernet/mellanox/mlx5/core/en_main.c | 26 ++++++++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx5/core/en.h +1 -0
@@ -728,6 +728,7 @@ struct mlx5e_rq {struct xsk_buff_pool *xsk_pool;struct work_struct recover_work; +struct work_struct rx_timeout_work;/* control */ struct mlx5_wq_ctrl wq_ctrl;
drivers/net/ethernet/mellanox/mlx5/core/en/reporter_rx.c +7 -0
@@ -170,16 +170,23 @@ static int mlx5e_rx_reporter_err_rq_cqe_recover(void *ctx)static int mlx5e_rx_reporter_timeout_recover (void *ctx) {struct mlx5_eq_comp *eq; +struct mlx5e_priv *priv;struct mlx5e_rq *rq;int err; rq = ctx; + priv = rq->priv; + +mutex_lock (&priv->state_lock); + eq = rq->cq.mcq.eq; err =mlx5e_health_channel_eq_recover (rq->netdev, eq, rq->cq.ch_stats);if (err && rq->icosq)clear_bit (MLX5E_SQ_STATE_ENABLED , &rq->icosq->state); +mutex_unlock (&priv->state_lock); +return err; }
drivers/net/ethernet/mellanox/mlx5/core/en_main.c +25 -1
@@ -707,6 +707,27 @@ static void mlx5e_rq_err_cqe_work(struct work_struct *recover_work)mlx5e_reporter_rq_cqe_err (rq); } +static void mlx5e_rq_timeout_work (struct work_struct *timeout_work) +{ +struct mlx5e_rq *rq =container_of (timeout_work, + struct mlx5e_rq, + rx_timeout_work); + +/* Acquire netdev instance lock to synchronize with channel close and +* reopen flows. Either successfully obtain the lock, or detect that +* channels are closing for another reason, making this work no longer +* necessary. +*/ +while (!netdev_trylock (rq->netdev)) { +if (!test_bit (MLX5E_STATE_CHANNELS_ACTIVE , &rq->priv->state)) +return ; +msleep (20 ); + } + +mlx5e_reporter_rx_timeout (rq); +netdev_unlock (rq->netdev); +} +static int mlx5e_alloc_mpwqe_rq_drop_page (struct mlx5e_rq *rq) { rq->wqe_overflow.page =alloc_page (GFP_KERNEL );
@@ -830,6 +851,7 @@ static int mlx5e_alloc_rq(struct mlx5e_params *params, rqp->wq.db_numa_node = node;INIT_WORK (&rq->recover_work, mlx5e_rq_err_cqe_work); +INIT_WORK (&rq->rx_timeout_work, mlx5e_rq_timeout_work);if (params->xdp_prog)bpf_prog_inc (params->xdp_prog);
@@ -1204,7 +1226,8 @@ int mlx5e_wait_for_min_rx_wqes(struct mlx5e_rq *rq, int wait_time)netdev_warn (rq->netdev,"Failed to get min RX wqes on Channel[%d] RQN[0x%x] wq cur_sz(%d) min_rx_wqes(%d)\n" , rq->ix, rq->rqn,mlx5e_rqwq_get_cur_sz (rq), min_wqes); -mlx5e_reporter_rx_timeout (rq); +queue_work (rq->priv->wq, &rq->rx_timeout_work); +return -ETIMEDOUT ; }
@@ -1375,6 +1398,7 @@ void mlx5e_close_rq(struct mlx5e_rq *rq)if (rq->dim)cancel_work_sync (&rq->dim->work);cancel_work_sync (&rq->recover_work); +cancel_work_sync (&rq->rx_timeout_work);mlx5e_destroy_rq (rq);mlx5e_free_rx_descs (rq);mlx5e_free_rq (rq);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 279/627 macsec: set IFF_UNICAST_FLT priv flag
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit 0349659fd72f662c054ff20d432559bfaa228ce4 ]
Cosmin reports the following locking issue:
# BUG: sleeping function called from invalid context at kernel/locking/mutex.c:275
# dump_stack_lvl+0x4f/0x60 # __might_resched+0xeb/0x140 # mutex_lock+0x1a/0x40 # dev_set_promiscuity+0x26/0x90 # __dev_set_promiscuity+0x85/0x170 # __dev_set_rx_mode+0x69/0xa0 # dev_uc_add+0x6d/0x80 # vlan_dev_open+0x5f/0x120 [8021q] # __dev_open+0x10c/0x2a0 # __dev_change_flags+0x1a4/0x210 # netif_change_flags+0x22/0x60 # do_setlink.isra.0+0xdb0/0x10f0 # rtnl_newlink+0x797/0xb00 # rtnetlink_rcv_msg+0x1cb/0x3f0 # netlink_rcv_skb+0x53/0x100 # netlink_unicast+0x273/0x3b0 # netlink_sendmsg+0x1f2/0x430
Which is similar to recent syzkaller reports in [0] and [1] and triggers because macsec does not advertise IFF_UNICAST_FLT although it has proper ndo_set_rx_mode callback that takes care of pushing uc/mc addresses down to the real device.
In general, dev_uc_add call path is problematic for stacking non-IFF_UNICAST_FLT because we might grab netdev instance lock under addr_list_lock spinlock, so this is not a systemic fix.
0: https://lore.kernel.org/netdev/[email protected]
1: https://lore.kernel.org/netdev/[email protected]/
--- drivers/net/macsec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/macsec.c +1 -1
@@ -3868,7 +3868,7 @@ static void macsec_setup(struct net_device *dev)ether_setup (dev); dev->min_mtu =0 ; dev->max_mtu =ETH_MAX_MTU ; - dev->priv_flags |=IFF_NO_QUEUE ; + dev->priv_flags |=IFF_NO_QUEUE |IFF_UNICAST_FLT ; dev->netdev_ops = &macsec_netdev_ops; dev->needs_free_netdev = true; dev->priv_destructor = macsec_free_netdev;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 280/627 net: dsa: microchip: Fix wrong rx drop MIB counter for KSZ8863
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tristram Ha <[email protected]>
[ Upstream commit 165a7f5db919ab68a45ae755cceb751e067273ef ]
When KSZ8863 support was first added to KSZ driver the RX drop MIB counter was somehow defined as 0x105. The TX drop MIB counter starts at 0x100 for port 1, 0x101 for port 2, and 0x102 for port 3, so the RX drop MIB counter should start at 0x103 for port 1, 0x104 for port 2, and 0x105 for port 3.
There are 5 ports for KSZ8895, so its RX drop MIB counter starts at 0x105.
--- drivers/net/dsa/microchip/ksz8.c | 3 +++ drivers/net/dsa/microchip/ksz8_reg.h | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-)
drivers/net/dsa/microchip/ksz8.c +3 -0
@@ -371,6 +371,9 @@ static void ksz8863_r_mib_pkt(struct ksz_device *dev, int port, u16 addr, addr -= dev->info->reg_mib_cnt; ctrl_addr = addr ?KSZ8863_MIB_PACKET_DROPPED_TX_0 :KSZ8863_MIB_PACKET_DROPPED_RX_0 ; +if (ksz_is_8895_family (dev) && + ctrl_addr ==KSZ8863_MIB_PACKET_DROPPED_RX_0 ) + ctrl_addr =KSZ8895_MIB_PACKET_DROPPED_RX_0 ; ctrl_addr += port; ctrl_addr |=IND_ACC_TABLE (TABLE_MIB |TABLE_READ );
drivers/net/dsa/microchip/ksz8_reg.h +3 -1
@@ -784,7 +784,9 @@#define KSZ8795_MIB_TOTAL_TX_1 0x105#define KSZ8863_MIB_PACKET_DROPPED_TX_0 0x100 -#define KSZ8863_MIB_PACKET_DROPPED_RX_0 0x105 +#define KSZ8863_MIB_PACKET_DROPPED_RX_0 0x103 + +#define KSZ8895_MIB_PACKET_DROPPED_RX_0 0x105#define MIB_PACKET_DROPPED 0x0000FFFF
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 281/627 neighbour: Fix null-ptr-deref in neigh_flush_dev().
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kuniyuki Iwashima <[email protected]>
[ Upstream commit 1bbb76a899486827394530916f01214d049931b3 ]
kernel test robot reported null-ptr-deref in neigh_flush_dev(). [0]
The cited commit introduced per-netdev neighbour list and converted neigh_flush_dev() to use it instead of the global hash table.
One thing we missed is that neigh_table_clear() calls neigh_ifdown() with NULL dev.
Let's restore the hash table iteration.
Note that IPv6 module is no longer unloadable, so neigh_table_clear() is called only when IPv6 fails to initialise, which is unlikely to happen.
[0]:
IPv6: Attempt to unregister permanent protocol 136
IPv6: Attempt to unregister permanent protocol 17
Oops: general protection fault, probably for non-canonical address 0xdffffc00000001a0: 0000 [#1] SMP KASAN KASAN: null-ptr-deref in range [0x0000000000000d00-0x0000000000000d07] CPU: 1 UID: 0 PID: 1 Comm: systemd Tainted: G T 6.12.0-rc6-01246-gf7f52738637f #1 Tainted: [T]=RANDSTRUCT Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014 RIP: 0010:neigh_flush_dev.llvm.6395807810224103582+0x52/0x570 Code: c1 e8 03 42 8a 04 38 84 c0 0f 85 15 05 00 00 31 c0 41 83 3e 0a 0f 94 c0 48 8d 1c c3 48 81 c3 f8 0c 00 00 48 89 d8 48 c1 e8 03 <42> 80 3c 38 00 74 08 48 89 df e8 f7 49 93 fe 4c 8b 3b 4d 85 ff 0f RSP: 0000:ffff88810026f408 EFLAGS: 00010206 RAX: 00000000000001a0 RBX: 0000000000000d00 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffffffc0631640 RBP: ffff88810026f470 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: ffffffffc0625250 R14: ffffffffc0631640 R15: dffffc0000000000 FS: 00007f575cb83940(0000) GS:ffff8883aee00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007f575db40008 CR3: 00000002bf936000 CR4: 00000000000406f0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 Call Trace: <TASK> __neigh_ifdown.llvm.6395807810224103582+0x44/0x390 neigh_table_clear+0xb1/0x268 ndisc_cleanup+0x21/0x38 [ipv6] init_module+0x2f5/0x468 [ipv6] do_one_initcall+0x1ba/0x628 do_init_module+0x21a/0x530 load_module+0x2550/0x2ea0 __se_sys_finit_module+0x3d2/0x620 __x64_sys_finit_module+0x76/0x88 x64_sys_call+0x7ff/0xde8 do_syscall_64+0xfb/0x1e8 entry_SYSCALL_64_after_hwframe+0x67/0x6f RIP: 0033:0x7f575d6f2719 Code: 08 89 e8 5b 5d c3 66 2e 0f 1f 84 00 00 00 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d b7 06 0d 00 f7 d8 64 89 01 48 RSP: 002b:00007fff82a2a268 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 0000557827b45310 RCX: 00007f575d6f2719 RDX: 0000000000000000 RSI: 00007f575d584efd RDI: 0000000000000004 RBP: 00007f575d584efd R08: 0000000000000000 R09: 0000557827b47b00 R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000020000 R13: 0000000000000000 R14: 0000557827b470e0 R15: 00007f575dbb4270 </TASK> Modules linked in: ipv6(+)
--- net/core/neighbour.c | 88 ++++++++++++++++++++++++++++++-------------- 1 file changed, 61 insertions(+), 27 deletions(-)
net/core/neighbour.c +61 -27
@@ -368,6 +368,43 @@ static void pneigh_queue_purge(struct sk_buff_head *list, struct net *net, } } +static void neigh_flush_one (struct neighbour *n) +{ +hlist_del_rcu (&n->hash); +hlist_del_rcu (&n->dev_list); + +write_lock (&n->lock); + +neigh_del_timer (n); +neigh_mark_dead (n); + +if (refcount_read (&n->refcnt) !=1 ) { +/* The most unpleasant situation. +* We must destroy neighbour entry, +* but someone still uses it. +* +* The destroy will be delayed until +* the last user releases us, but +* we must kill timers etc. and move +* it to safe state. +*/ +__skb_queue_purge (&n->arp_queue); + n->arp_queue_len_bytes =0 ; +WRITE_ONCE (n->output, neigh_blackhole); + +if (n->nud_state &NUD_VALID ) + n->nud_state =NUD_NOARP ; +else + n->nud_state =NUD_NONE ; + +neigh_dbg (2 ,"neigh %p is stray\n" , n); + } + +write_unlock (&n->lock); + +neigh_cleanup_and_release (n); +} +static void neigh_flush_dev (struct neigh_table *tbl,struct net_device *dev,bool skip_perm) {
@@ -381,32 +418,24 @@ static void neigh_flush_dev(struct neigh_table *tbl, struct net_device *dev,if (skip_perm && n->nud_state &NUD_PERMANENT )continue ; -hlist_del_rcu (&n->hash); -hlist_del_rcu (&n->dev_list); -write_lock (&n->lock); -neigh_del_timer (n); -neigh_mark_dead (n); -if (refcount_read (&n->refcnt) !=1 ) { -/* The most unpleasant situation. -* We must destroy neighbour entry, -* but someone still uses it. -* -* The destroy will be delayed until -* the last user releases us, but -* we must kill timers etc. and move -* it to safe state. -*/ -__skb_queue_purge (&n->arp_queue); - n->arp_queue_len_bytes =0 ; -WRITE_ONCE (n->output, neigh_blackhole); -if (n->nud_state &NUD_VALID ) - n->nud_state =NUD_NOARP ; -else - n->nud_state =NUD_NONE ; -neigh_dbg (2 ,"neigh %p is stray\n" , n); - } -write_unlock (&n->lock); -neigh_cleanup_and_release (n); +neigh_flush_one (n); + } +} + +static void neigh_flush_table (struct neigh_table *tbl) +{ +struct neigh_hash_table *nht; +int i; + + nht =rcu_dereference_protected (tbl->nht, +lockdep_is_held (&tbl->lock)); + +for (i =0 ; i < (1 << nht->hash_shift); i++) { +struct hlist_node *tmp; +struct neighbour *n; + +neigh_for_each_in_bucket_safe (n, tmp, &nht->hash_heads[i]) +neigh_flush_one (n); } }
@@ -422,7 +451,12 @@ static int __neigh_ifdown(struct neigh_table *tbl, struct net_device *dev, bool skip_perm) {write_lock_bh (&tbl->lock); -neigh_flush_dev (tbl, dev, skip_perm); +if (likely (dev)) { +neigh_flush_dev (tbl, dev, skip_perm); + }else { +DEBUG_NET_WARN_ON_ONCE (skip_perm); +neigh_flush_table (tbl); + }pneigh_ifdown_and_unlock (tbl, dev);pneigh_queue_purge (&tbl->proxy_queue, dev ?dev_net (dev) :NULL , tbl->family);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 282/627 stmmac: xsk: fix negative overflow of budget in zerocopy mode
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Xing <[email protected]>
[ Upstream commit 2764ab51d5f0e8c7d3b7043af426b1883e3bde1d ]
A negative overflow can happen when the budget number of descs are consumed. as long as the budget is decreased to zero, it will again go into while (budget-- > 0) statement and get decreased by one, so the overflow issue can happen. It will lead to returning true whereas the expected value should be false.
In this case where all the budget is used up, it means zc function should return false to let the poll run again because normally we might have more data to process. Without this patch, zc function would return true instead.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -1
@@ -2596,7 +2596,7 @@ static bool stmmac_xdp_xmit_zc(struct stmmac_priv *priv, u32 queue, u32 budget) budget =min (budget,stmmac_tx_avail (priv, queue)); -while (budget-- >0 ) { +for (; budget >0 ; budget--) {struct stmmac_metadata_request meta_req;struct xsk_tx_metadata *meta =NULL ;dma_addr_t dma_addr;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 283/627 igb: xsk: solve negative overflow of nb_pkts in zerocopy mode
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jason Xing <[email protected]>
[ Upstream commit 3b7c13dfdcc26a78756cc17a23cdf4310c5a24a9 ]
There is no break time in the while() loop, so every time at the end of igb_xmit_zc(), negative overflow of nb_pkts will occur, which renders the return value always false. But theoretically, the result should be set after calling xsk_tx_peek_release_desc_batch(). We can take i40e_xmit_zc() as a good example.
Returning false means we're not done with transmission and we need one more poll, which is exactly what igb_xmit_zc() always did before this patch. After this patch, the return value depends on the nb_pkts value. Two cases might happen then:
1. if (nb_pkts < budget), it means we process all the possible data, so return true and no more necessary poll will be triggered because of this.
2. if (nb_pkts == budget), it means we might have more data, so return false to let another poll run again.
--- drivers/net/ethernet/intel/igb/igb_xsk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/igb_xsk.c +1 -2
@@ -482,7 +482,7 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool)if (!nb_pkts)return true; -while (nb_pkts-- >0 ) { +for (; i < nb_pkts; i++) { dma =xsk_buff_raw_get_dma (xsk_pool, descs[i].addr);xsk_buff_raw_dma_sync_for_device (xsk_pool, dma, descs[i].len);
@@ -512,7 +512,6 @@ bool igb_xmit_zc(struct igb_ring *tx_ring, struct xsk_buff_pool *xsk_pool) total_bytes += descs[i].len; - i++; tx_ring->next_to_use++; tx_buffer_info->next_to_watch = tx_desc;if (tx_ring->next_to_use == tx_ring->count)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 284/627 selftests: rtnetlink.sh: remove esp4_offload after test
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Xiumei Mu <[email protected]>
[ Upstream commit 5b32321fdaf3fd1a92ec726af18765e225b0ee2b ]
The esp4_offload module, loaded during IPsec offload tests, should be reset to its default settings after testing.
Otherwise, leaving it enabled could unintentionally affect subsequence test cases by keeping offload active.
Without this fix:
$ lsmod | grep offload; ./rtnetlink.sh -t kci_test_ipsec_offload ; lsmod | grep offload; PASS: ipsec_offload esp4_offload 12288 0 esp4 32768 1 esp4_offload
With this fix:
$ lsmod | grep offload; ./rtnetlink.sh -t kci_test_ipsec_offload ; lsmod | grep offload; PASS: ipsec_offload
--- tools/testing/selftests/net/rtnetlink.sh | 6 ++++++ 1 file changed, 6 insertions(+)
tools/testing/selftests/net/rtnetlink.sh +6 -0
@@ -673,6 +673,11 @@ kci_test_ipsec_offload() sysfsf=$sysfsd/ipsec sysfsnet=/sys/bus/netdevsim/devices/netdevsim0/net/ probed=false + esp4_offload_probed_default=false + + if lsmod | grep -q esp4_offload; then + esp4_offload_probed_default=true + fi if ! mount | grep -q debugfs; then mount -t debugfs none /sys/kernel/debug/ &> /dev/null
@@ -766,6 +771,7 @@ EOF fi # clean up any leftovers + ! "$esp4_offload_probed_default" && lsmod | grep -q esp4_offload && rmmod esp4_offload echo 0 > /sys/bus/netdevsim/del_device $probed && rmmod netdevsim
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 285/627 vrf: Drop existing dst reference in vrf_ip6_input_dst
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stanislav Fomichev <[email protected]>
[ Upstream commit f388f807eca1de9e6e70f9ffb1a573c3811c4215 ]
Commit ff3fbcdd4724 ("selftests: tc: Add generic erspan_opts matching support for tc-flower") started triggering the following kmemleak warning:
unreferenced object 0xffff888015fb0e00 (size 512):
comm "softirq", pid 0, jiffies 4294679065 hex dump (first 32 bytes):
00 00 00 00 00 00 00 00 40 d2 85 9e ff ff ff ff ........@.......
41 69 59 9d ff ff ff ff 00 00 00 00 00 00 00 00 AiY.............
backtrace (crc 30b71e8b):
__kmalloc_noprof+0x359/0x460
metadata_dst_alloc+0x28/0x490
erspan_rcv+0x4f1/0x1160 [ip_gre]
gre_rcv+0x217/0x240 [ip_gre]
gre_rcv+0x1b8/0x400 [gre]
ip_protocol_deliver_rcu+0x31d/0x3a0
ip_local_deliver_finish+0x37d/0x620
ip_local_deliver+0x174/0x460
ip_rcv+0x52b/0x6b0
__netif_receive_skb_one_core+0x149/0x1a0
process_backlog+0x3c8/0x1390
__napi_poll.constprop.0+0xa1/0x390
net_rx_action+0x59b/0xe00
handle_softirqs+0x22b/0x630
do_softirq+0xb1/0xf0
__local_bh_enable_ip+0x115/0x150vrf_ip6_input_dst unconditionally sets skb dst entry, add a call to skb_dst_drop to drop any existing entry.
--- drivers/net/vrf.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/net/vrf.c +2 -0
@@ -1302,6 +1302,8 @@ static void vrf_ip6_input_dst(struct sk_buff *skb, struct net_device *vrf_dev,struct net *net =dev_net (vrf_dev);struct rt6_info *rt6; +skb_dst_drop (skb); + rt6 =vrf_ip6_route_lookup (net, vrf_dev, &fl6, ifindex, skb,RT6_LOOKUP_F_HAS_SADDR |RT6_LOOKUP_F_IFACE );if (unlikely (!rt6))
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 286/627 ipv6: add a retry logic in net6_rt_notify()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit ea2f921db7a483a526058c5b5b8162edd88dabe5 ]
inet6_rt_notify() can be called under RCU protection only. This means the route could be changed concurrently and rt6_fill_node() could return -EMSGSIZE.
Re-size the skb when this happens and retry, removing one WARN_ON() that syzbot was able to trigger:
WARNING: CPU: 3 PID: 6291 at net/ipv6/route.c:6342 inet6_rt_notify+0x475/0x4b0 net/ipv6/route.c:6342 Modules linked in: CPU: 3 UID: 0 PID: 6291 Comm: syz.0.77 Not tainted 6.16.0-rc7-syzkaller #0 PREEMPT(full) Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014 RIP: 0010:inet6_rt_notify+0x475/0x4b0 net/ipv6/route.c:6342 Code: fc ff ff e8 6d 52 ea f7 e9 47 fc ff ff 48 8b 7c 24 08 4c 89 04 24 e8 5a 52 ea f7 4c 8b 04 24 e9 94 fd ff ff e8 9c fe 84 f7 90 <0f> 0b 90 e9 bd fd ff ff e8 6e 52 ea f7 e9 bb fb ff ff 48 89 df e8 RSP: 0018:ffffc900035cf1d8 EFLAGS: 00010293 RAX: 0000000000000000 RBX: ffffc900035cf540 RCX: ffffffff8a36e790 RDX: ffff88802f7e8000 RSI: ffffffff8a36e9d4 RDI: 0000000000000005 RBP: ffff88803c230f00 R08: 0000000000000005 R09: 00000000ffffffa6 R10: 00000000ffffffa6 R11: 0000000000000001 R12: 00000000ffffffa6 R13: 0000000000000900 R14: ffff888032ea4100 R15: 0000000000000000 FS: 00007fac7b89a6c0(0000) GS:ffff8880d6a20000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 00007fac7b899f98 CR3: 0000000034b3f000 CR4: 0000000000352ef0 Call Trace: <TASK> ip6_route_mpath_notify+0xde/0x280 net/ipv6/route.c:5356 ip6_route_multipath_add+0x1181/0x1bd0 net/ipv6/route.c:5536 inet6_rtm_newroute+0xe4/0x1a0 net/ipv6/route.c:5647 rtnetlink_rcv_msg+0x95e/0xe90 net/core/rtnetlink.c:6944 netlink_rcv_skb+0x155/0x420 net/netlink/af_netlink.c:2552 netlink_unicast_kernel net/netlink/af_netlink.c:1320 [inline] netlink_unicast+0x58d/0x850 net/netlink/af_netlink.c:1346 netlink_sendmsg+0x8d1/0xdd0 net/netlink/af_netlink.c:1896 sock_sendmsg_nosec net/socket.c:712 [inline] __sock_sendmsg net/socket.c:727 [inline] ____sys_sendmsg+0xa95/0xc70 net/socket.c:2566 ___sys_sendmsg+0x134/0x1d0 net/socket.c:2620
--- net/ipv6/route.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
net/ipv6/route.c +10 -5
@@ -6321,8 +6321,9 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,void inet6_rt_notify (int event,struct fib6_info *rt,struct nl_info *info,unsigned int nlm_flags) { -struct sk_buff *skb;struct net *net = info->nl_net; +struct sk_buff *skb; +size_t sz;u32 seq;int err;
@@ -6330,17 +6331,21 @@ void inet6_rt_notify(int event, struct fib6_info *rt, struct nl_info *info, seq = info->nlh ? info->nlh->nlmsg_seq :0 ;rcu_read_lock (); - - skb =nlmsg_new (rt6_nlmsg_size (rt),GFP_ATOMIC ); + sz =rt6_nlmsg_size (rt); +retry: + skb =nlmsg_new (sz,GFP_ATOMIC );if (!skb) goto errout; err =rt6_fill_node (net, skb, rt,NULL ,NULL ,NULL ,0 , event, info->portid, seq, nlm_flags);if (err <0 ) { -/* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ -WARN_ON (err == -EMSGSIZE );kfree_skb (skb); +/* -EMSGSIZE implies needed space grew under us. */ +if (err == -EMSGSIZE ) { + sz =max (rt6_nlmsg_size (rt), sz <<1 ); + goto retry; + } goto errout; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 287/627 ipv6: prevent infinite loop in rt6_nlmsg_size()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 54e6fe9dd3b0e7c481c2228782c9494d653546da ]
While testing prior patch, I was able to trigger an infinite loop in rt6_nlmsg_size() in the following place:
list_for_each_entry_rcu(sibling, &f6i->fib6_siblings,
fib6_siblings) {
rt6_nh_nlmsg_size(sibling->fib6_nh, &nexthop_len);
}This is because fib6_del_route() and fib6_add_rt2node() uses list_del_rcu(), which can confuse rcu readers, because they might no longer see the head of the list.
Restart the loop if f6i->fib6_nsiblings is zero.
--- net/ipv6/ip6_fib.c | 4 ++-- net/ipv6/route.c | 34 ++++++++++++++++++---------------- 2 files changed, 20 insertions(+), 18 deletions(-)
net/ipv6/ip6_fib.c +2 -2
@@ -1265,7 +1265,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, &rt->fib6_siblings, fib6_siblings) sibling->fib6_nsiblings--; - rt->fib6_nsiblings =0 ; +WRITE_ONCE (rt->fib6_nsiblings,0 );list_del_rcu (&rt->fib6_siblings);rcu_read_lock ();rt6_multipath_rebalance (next_sibling);
@@ -2015,7 +2015,7 @@ static void fib6_del_route(struct fib6_table *table, struct fib6_node *fn,list_for_each_entry_safe (sibling, next_sibling, &rt->fib6_siblings, fib6_siblings) sibling->fib6_nsiblings--; - rt->fib6_nsiblings =0 ; +WRITE_ONCE (rt->fib6_nsiblings,0 );list_del_rcu (&rt->fib6_siblings);rt6_multipath_rebalance (next_sibling); }
net/ipv6/route.c +18 -16
@@ -5670,32 +5670,34 @@ static int rt6_nh_nlmsg_size(struct fib6_nh *nh, void *arg)static size_t rt6_nlmsg_size (struct fib6_info *f6i) { +struct fib6_info *sibling; +struct fib6_nh *nh;int nexthop_len;if (f6i->nh) { nexthop_len =nla_total_size (4 );/* RTA_NH_ID */ nexthop_for_each_fib6_nh (f6i->nh, rt6_nh_nlmsg_size, &nexthop_len); - }else { -struct fib6_nh *nh = f6i->fib6_nh; -struct fib6_info *sibling; - - nexthop_len =0 ; -if (f6i->fib6_nsiblings) { -rt6_nh_nlmsg_size (nh, &nexthop_len); - -rcu_read_lock (); + goto common; + } -list_for_each_entry_rcu (sibling, &f6i->fib6_siblings, - fib6_siblings) { -rt6_nh_nlmsg_size (sibling->fib6_nh, &nexthop_len); - } +rcu_read_lock (); +retry: + nh = f6i->fib6_nh; + nexthop_len =0 ; +if (READ_ONCE (f6i->fib6_nsiblings)) { +rt6_nh_nlmsg_size (nh, &nexthop_len); -rcu_read_unlock (); +list_for_each_entry_rcu (sibling, &f6i->fib6_siblings, + fib6_siblings) { +rt6_nh_nlmsg_size (sibling->fib6_nh, &nexthop_len); +if (!READ_ONCE (f6i->fib6_nsiblings)) + goto retry; } - nexthop_len +=lwtunnel_get_encap_size (nh->fib_nh_lws); } - +rcu_read_unlock (); + nexthop_len +=lwtunnel_get_encap_size (nh->fib_nh_lws); +common:return NLMSG_ALIGN (sizeof (struct rtmsg )) +nla_total_size (16 )/* RTA_SRC */ +nla_total_size (16 )/* RTA_DST */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 288/627 ipv6: fix possible infinite loop in fib6_info_uses_dev()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit f8d8ce1b515a0a6af72b30502670a406cfb75073 ]
fib6_info_uses_dev() seems to rely on RCU without an explicit protection.
Like the prior fix in rt6_nlmsg_size(),
we need to make sure fib6_del_route() or fib6_add_rt2node() have not removed the anchor from the list, or we risk an infinite loop.
--- net/ipv6/route.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/ipv6/route.c +11 -6
@@ -5958,16 +5958,21 @@ static bool fib6_info_uses_dev(const struct fib6_info *f6i,if (f6i->fib6_nh->fib_nh_dev == dev)return true; -if (f6i->fib6_nsiblings) { -struct fib6_info *sibling, *next_sibling; +if (READ_ONCE (f6i->fib6_nsiblings)) { +const struct fib6_info *sibling; -list_for_each_entry_safe (sibling, next_sibling, - &f6i->fib6_siblings, fib6_siblings) { -if (sibling->fib6_nh->fib_nh_dev == dev) +rcu_read_lock (); +list_for_each_entry_rcu (sibling, &f6i->fib6_siblings, + fib6_siblings) { +if (sibling->fib6_nh->fib_nh_dev == dev) { +rcu_read_unlock ();return true; + } +if (!READ_ONCE (f6i->fib6_nsiblings)) +break ; } +rcu_read_unlock (); } -return false; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 289/627 ipv6: annotate data-races around rt->fib6_nsiblings
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
[ Upstream commit 31d7d67ba1274f42494256d52e86da80ed09f3cb ]
rt->fib6_nsiblings can be read locklessly, add corresponding READ_ONCE() and WRITE_ONCE() annotations.
--- net/ipv6/ip6_fib.c | 20 +++++++++++++------- net/ipv6/route.c | 5 +++-- 2 files changed, 16 insertions(+), 9 deletions(-)
net/ipv6/ip6_fib.c +13 -7
@@ -445,15 +445,17 @@ struct fib6_dump_arg {static int fib6_rt_dump (struct fib6_info *rt,struct fib6_dump_arg *arg) {enum fib_event_type fib_event =FIB_EVENT_ENTRY_REPLACE ; +unsigned int nsiblings;int err;if (!rt || rt == arg->net->ipv6.fib6_null_entry)return 0 ; -if (rt->fib6_nsiblings) + nsiblings =READ_ONCE (rt->fib6_nsiblings); +if (nsiblings) err =call_fib6_multipath_entry_notifier (arg->nb, fib_event, rt, - rt->fib6_nsiblings, + nsiblings, arg->extack);else err = call_fib6_entry_notifier(arg->nb, fib_event, rt,
@@ -1138,7 +1140,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,if (rt6_duplicate_nexthop (iter, rt)) {if (rt->fib6_nsiblings) - rt->fib6_nsiblings =0 ; +WRITE_ONCE (rt->fib6_nsiblings,0 );if (!(iter->fib6_flags &RTF_EXPIRES ))return -EEXIST ;if (!(rt->fib6_flags &RTF_EXPIRES )) {
@@ -1167,7 +1169,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,*/ if (rt_can_ecmp &&rt6_qualify_for_ecmp (iter)) - rt->fib6_nsiblings++; +WRITE_ONCE (rt->fib6_nsiblings, + rt->fib6_nsiblings +1 ); }if (iter->fib6_metric > rt->fib6_metric)
@@ -1217,7 +1220,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, fib6_nsiblings =0 ;list_for_each_entry_safe (sibling, temp_sibling, &rt->fib6_siblings, fib6_siblings) { - sibling->fib6_nsiblings++; +WRITE_ONCE (sibling->fib6_nsiblings, + sibling->fib6_nsiblings +1 );BUG_ON (sibling->fib6_nsiblings != rt->fib6_nsiblings); fib6_nsiblings++; }
@@ -1264,7 +1268,8 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,list_for_each_entry_safe (sibling, next_sibling, &rt->fib6_siblings, fib6_siblings) - sibling->fib6_nsiblings--; +WRITE_ONCE (sibling->fib6_nsiblings, + sibling->fib6_nsiblings -1 );WRITE_ONCE (rt->fib6_nsiblings,0 );list_del_rcu (&rt->fib6_siblings);rcu_read_lock ();
@@ -2014,7 +2019,8 @@ static void fib6_del_route(struct fib6_table *table, struct fib6_node *fn, notify_del = true;list_for_each_entry_safe (sibling, next_sibling, &rt->fib6_siblings, fib6_siblings) - sibling->fib6_nsiblings--; +WRITE_ONCE (sibling->fib6_nsiblings, + sibling->fib6_nsiblings -1 );WRITE_ONCE (rt->fib6_nsiblings,0 );list_del_rcu (&rt->fib6_siblings);rt6_multipath_rebalance (next_sibling);
net/ipv6/route.c +3 -2
@@ -5346,7 +5346,8 @@ static void ip6_route_mpath_notify(struct fib6_info *rt,*/ rcu_read_lock (); -if ((nlflags &NLM_F_APPEND ) && rt_last && rt_last->fib6_nsiblings) { +if ((nlflags &NLM_F_APPEND ) && rt_last && +READ_ONCE (rt_last->fib6_nsiblings)) { rt =list_first_or_null_rcu (&rt_last->fib6_siblings, struct fib6_info, fib6_siblings);
@@ -5856,7 +5857,7 @@ static int rt6_fill_node(struct net *net, struct sk_buff *skb,if (dst->lwtstate &&lwtunnel_fill_encap (skb, dst->lwtstate,RTA_ENCAP ,RTA_ENCAP_TYPE ) <0 ) goto nla_put_failure; - }else if (rt->fib6_nsiblings) { + }else if (READ_ONCE (rt->fib6_nsiblings)) {struct fib6_info *sibling;struct nlattr *mp;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 290/627 bpf/preload: Dont select USERMODE_DRIVER
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Weißschuh <[email protected]>
[ Upstream commit 2b03164eee20eac7ce0fe3aa4fbda7efc1e5427a ]
The usermode driver framework is not used anymore by the BPF preload code.
--- kernel/bpf/preload/Kconfig | 1 - 1 file changed, 1 deletion(-)
kernel/bpf/preload/Kconfig +0 -1
@@ -10,7 +10,6 @@ menuconfig BPF_PRELOAD # The dependency on !COMPILE_TEST prevents it from being enabled # in allmodconfig or allyesconfig configurations depends on !COMPILE_TEST - select USERMODE_DRIVER help This builds kernel module with several embedded BPF programs that are pinned into BPF FS mount point as human readable files that are
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 291/627 bpf, arm64: Fix fp initialization for exception boundary
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Puranjay Mohan <[email protected]>
[ Upstream commit b114fcee766d5101eada1aca7bb5fd0a86c89b35 ]
In the ARM64 BPF JIT when prog->aux->exception_boundary is set for a BPF program, find_used_callee_regs() is not called because for a program acting as exception boundary, all callee saved registers are saved. find_used_callee_regs() sets ctx->fp_used = true; when it sees FP being used in any of the instructions.
For programs acting as exception boundary, ctx->fp_used remains false even if frame pointer is used by the program and therefore, FP is not set-up for such programs in the prologue. This can cause the kernel to crash due to a pagefault.
Fix it by setting ctx->fp_used = true for exception boundary programs as fp is always saved in such programs.
--- arch/arm64/net/bpf_jit_comp.c | 1 + 1 file changed, 1 insertion(+)
arch/arm64/net/bpf_jit_comp.c +1 -0
@@ -412,6 +412,7 @@ static void push_callee_regs(struct jit_ctx *ctx)emit (A64_PUSH (A64_R (23 ),A64_R (24 ),A64_SP ), ctx);emit (A64_PUSH (A64_R (25 ),A64_R (26 ),A64_SP ), ctx);emit (A64_PUSH (A64_R (27 ),A64_R (28 ),A64_SP ), ctx); + ctx->fp_used = true; }else {find_used_callee_regs (ctx);for (i =0 ; i +1 < ctx->nr_used_callee_reg; i +=2 ) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 292/627 RISC-V: KVM: Fix inclusion of Smnpm in the guest ISA bitmap
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Samuel Holland <[email protected]>
[ Upstream commit 7826c8f37220daabf90c09fcd9a835d6763f1372 ]
The Smnpm extension requires special handling because the guest ISA extension maps to a different extension (Ssnpm) on the host side. commit 1851e7836212 ("RISC-V: KVM: Allow Smnpm and Ssnpm extensions for guests") missed that the vcpu->arch.isa bit is based only on the host extension, so currently both KVM_RISCV_ISA_EXT_{SMNPM,SSNPM} map to vcpu->arch.isa[RISCV_ISA_EXT_SSNPM]. This does not cause any problems for the guest, because both extensions are force-enabled anyway when the host supports Ssnpm, but prevents checking for (guest) Smnpm in the SBI FWFT logic.
Redefine kvm_isa_ext_arr to look up the guest extension, since only the guest -> host mapping is unambiguous. Factor out the logic for checking for host support of an extension, so this special case only needs to be handled in one place, and be explicit about which variables hold a host vs a guest ISA extension.
--- arch/riscv/kvm/vcpu_onereg.c | 83 +++++++++++++++++++++++------------- 1 file changed, 53 insertions(+), 30 deletions(-)
arch/riscv/kvm/vcpu_onereg.c +53 -30
@@ -23,7 +23,7 @@#define KVM_ISA_EXT_ARR (ext) \ [KVM_RISCV_ISA_EXT_##ext] = RISCV_ISA_EXT_##ext -/* Mapping between KVM ISA Extension ID & Host ISA extension ID */ +/* Mapping between KVM ISA Extension ID & guest ISA extension ID */ static const unsigned long kvm_isa_ext_arr[] = {/* Single letter extensions (alphabetically sorted) */ [KVM_RISCV_ISA_EXT_A ] = RISCV_ISA_EXT_a,
@@ -35,7 +35,7 @@ static const unsigned long kvm_isa_ext_arr[] = { [KVM_RISCV_ISA_EXT_M] = RISCV_ISA_EXT_m, [KVM_RISCV_ISA_EXT_V] = RISCV_ISA_EXT_v,/* Multi letter extensions (alphabetically sorted) */ - [KVM_RISCV_ISA_EXT_SMNPM] = RISCV_ISA_EXT_SSNPM, +KVM_ISA_EXT_ARR (SMNPM ),KVM_ISA_EXT_ARR (SMSTATEEN ),KVM_ISA_EXT_ARR (SSAIA ), KVM_ISA_EXT_ARR(SSCOFPMF),
@@ -112,6 +112,36 @@ static unsigned long kvm_riscv_vcpu_base2isa_ext(unsigned long base_ext)return KVM_RISCV_ISA_EXT_MAX ; } +static int kvm_riscv_vcpu_isa_check_host (unsigned long kvm_ext,unsigned long *guest_ext) +{ +unsigned long host_ext; + +if (kvm_ext >=KVM_RISCV_ISA_EXT_MAX || + kvm_ext >=ARRAY_SIZE (kvm_isa_ext_arr)) +return -ENOENT ; + + *guest_ext = kvm_isa_ext_arr[kvm_ext]; +switch (*guest_ext) { +case RISCV_ISA_EXT_SMNPM : +/* +* Pointer masking effective in (H)S-mode is provided by the +* Smnpm extension, so that extension is reported to the guest, +* even though the CSR bits for configuring VS-mode pointer +* masking on the host side are part of the Ssnpm extension. +*/ + host_ext =RISCV_ISA_EXT_SSNPM ; +break ; +default : + host_ext = *guest_ext; +break ; + } + +if (!__riscv_isa_extension_available (NULL , host_ext)) +return -ENOENT ; + +return 0 ; +} +static bool kvm_riscv_vcpu_isa_enable_allowed (unsigned long ext) {switch (ext) {
@@ -219,13 +249,13 @@ static bool kvm_riscv_vcpu_isa_disable_allowed(unsigned long ext)void kvm_riscv_vcpu_setup_isa (struct kvm_vcpu *vcpu) { -unsigned long host_isa, i; +unsigned long guest_ext, i;for (i =0 ; i <ARRAY_SIZE (kvm_isa_ext_arr); i++) { - host_isa = kvm_isa_ext_arr[i]; -if (__riscv_isa_extension_available (NULL , host_isa) && -kvm_riscv_vcpu_isa_enable_allowed (i)) -set_bit (host_isa, vcpu->arch.isa); +if (kvm_riscv_vcpu_isa_check_host (i, &guest_ext)) +continue ; +if (kvm_riscv_vcpu_isa_enable_allowed (i)) +set_bit (guest_ext, vcpu->arch.isa); } }
@@ -607,18 +637,15 @@ static int riscv_vcpu_get_isa_ext_single(struct kvm_vcpu *vcpu,unsigned long reg_num, unsigned long *reg_val) { - unsigned long host_isa_ext; - -if (reg_num >=KVM_RISCV_ISA_EXT_MAX || - reg_num >=ARRAY_SIZE (kvm_isa_ext_arr)) -return -ENOENT ; + unsigned long guest_ext; +int ret; - host_isa_ext = kvm_isa_ext_arr[reg_num]; -if (!__riscv_isa_extension_available (NULL , host_isa_ext)) -return -ENOENT ; + ret =kvm_riscv_vcpu_isa_check_host (reg_num, &guest_ext); +if (ret) +return ret; *reg_val =0 ; -if (__riscv_isa_extension_available (vcpu->arch.isa, host_isa_ext)) +if (__riscv_isa_extension_available (vcpu->arch.isa, guest_ext)) *reg_val =1 ;/* Mark the given extension as available */ return 0 ;
@@ -628,17 +655,14 @@ static int riscv_vcpu_set_isa_ext_single(struct kvm_vcpu *vcpu, unsigned long reg_num, unsigned long reg_val) { -unsigned long host_isa_ext; - -if (reg_num >=KVM_RISCV_ISA_EXT_MAX || - reg_num >=ARRAY_SIZE (kvm_isa_ext_arr)) -return -ENOENT ; +unsigned long guest_ext; +int ret; - host_isa_ext = kvm_isa_ext_arr[reg_num]; -if (!__riscv_isa_extension_available (NULL , host_isa_ext)) -return -ENOENT ; + ret =kvm_riscv_vcpu_isa_check_host (reg_num, &guest_ext); +if (ret) +return ret; -if (reg_val ==test_bit (host_isa_ext, vcpu->arch.isa)) +if (reg_val ==test_bit (guest_ext, vcpu->arch.isa))return 0 ;if (!vcpu->arch.ran_atleast_once) {
@@ -648,10 +672,10 @@ static int riscv_vcpu_set_isa_ext_single(struct kvm_vcpu *vcpu,*/ if (reg_val ==1 &&kvm_riscv_vcpu_isa_enable_allowed (reg_num)) -set_bit (host_isa_ext, vcpu->arch.isa); +set_bit (guest_ext, vcpu->arch.isa);else if (!reg_val &&kvm_riscv_vcpu_isa_disable_allowed (reg_num)) -clear_bit (host_isa_ext, vcpu->arch.isa); +clear_bit (guest_ext, vcpu->arch.isa);else return -EINVAL ;kvm_riscv_vcpu_fp_reset (vcpu);
@@ -1009,16 +1033,15 @@ static int copy_fp_d_reg_indices(const struct kvm_vcpu *vcpu,static int copy_isa_ext_reg_indices (const struct kvm_vcpu *vcpu,u64 __user *uindices) { +unsigned long guest_ext;unsigned int n =0 ; -unsigned long isa_ext;for (int i =0 ; i <KVM_RISCV_ISA_EXT_MAX ; i++) {u64 size =IS_ENABLED (CONFIG_32BIT ) ?KVM_REG_SIZE_U32 :KVM_REG_SIZE_U64 ;u64 reg =KVM_REG_RISCV | size |KVM_REG_RISCV_ISA_EXT | i; - isa_ext = kvm_isa_ext_arr[i]; -if (!__riscv_isa_extension_available (NULL , isa_ext)) +if (kvm_riscv_vcpu_isa_check_host (i, &guest_ext))continue ;if (uindices) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 293/627 Remove trailing whitespace from tracepoint string
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Monaco <[email protected]>
[ Upstream commit 7b70ac4cad2b20eaf415276bbaa0d9df9abb428c ]
RV event tracepoints print a line with the format:
"event_xyz: S0 x event -> S1 "
"event_xyz: S1 x event -> S0 (final)"While printing an event leading to a non-final state, the line has a trailing white space (visible above before the closing ").
Adapt the format string not to print the trailing whitespace if we are not printing "(final)".
Stable-dep-of: 7f904ff6e58d ("rv: Use strings in da monitors tracepoints")
--- kernel/trace/rv/rv_trace.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/trace/rv/rv_trace.h +4 -4
@@ -29,11 +29,11 @@ DECLARE_EVENT_CLASS(event_da_monitor, __entry->final_state = final_state; ), -TP_printk ("%s x %s -> %s %s" , +TP_printk ("%s x %s -> %s%s" , __entry->state, __entry->event, __entry->next_state, - __entry->final_state ?"(final)" :"" ) + __entry->final_state ?" (final)" :"" ) ); DECLARE_EVENT_CLASS(error_da_monitor,
@@ -90,12 +90,12 @@ DECLARE_EVENT_CLASS(event_da_monitor_id, __entry->final_state = final_state; ), -TP_printk ("%d: %s x %s -> %s %s" , +TP_printk ("%d: %s x %s -> %s%s" , __entry->id, __entry->state, __entry->event, __entry->next_state, - __entry->final_state ?"(final)" :"" ) + __entry->final_state ?" (final)" :"" ) ); DECLARE_EVENT_CLASS(error_da_monitor_id,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 294/627 Use strings in da monitors tracepoints
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Monaco <[email protected]>
[ Upstream commit 7f904ff6e58d398c4336f3c19c42b338324451f7 ]
Using DA monitors tracepoints with KASAN enabled triggers the following warning:
BUG: KASAN: global-out-of-bounds in do_trace_event_raw_event_event_da_monitor+0xd6/0x1a0 Read of size 32 at addr ffffffffaada8980 by task ... Call Trace: <TASK> [...] do_trace_event_raw_event_event_da_monitor+0xd6/0x1a0 ? __pfx_do_trace_event_raw_event_event_da_monitor+0x10/0x10 ? trace_event_sncid+0x83/0x200 trace_event_sncid+0x163/0x200 [...] The buggy address belongs to the variable: automaton_snep+0x4e0/0x5e0
This is caused by the tracepoints reading 32 bytes __array instead of __string from the automata definition. Such strings are literals and reading 32 bytes ends up in out of bound memory accesses (e.g. the next automaton's data in this case).
The error is harmless as, while printing the string, we stop at the null terminator, but it should still be fixed.
Use the __string facilities while defining the tracepoints to avoid reading out of bound memory.
--- kernel/trace/rv/rv_trace.h | 76 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-)
kernel/trace/rv/rv_trace.h +38 -38
@@ -16,23 +16,23 @@ DECLARE_EVENT_CLASS(event_da_monitor, TP_ARGS(state, event, next_state, final_state),TP_STRUCT__entry ( -__array (char ,state ,MAX_DA_NAME_LEN ) -__array ( char, event,MAX_DA_NAME_LEN ) -__array ( char, next_state,MAX_DA_NAME_LEN ) -__field ( bool, final_state ) +__string (state ,state ) +__string ( event, event ) +__string ( next_state, next_state ) +__field ( bool, final_state ) ),TP_fast_assign ( - memcpy(__entry->state, state, MAX_DA_NAME_LEN); -memcpy (__entry->event, event,MAX_DA_NAME_LEN ); -memcpy (__entry->next_state, next_state,MAX_DA_NAME_LEN ); - __entry->final_state = final_state; + __assign_str(state); +__assign_str (event); +__assign_str (next_state); + __entry->final_state = final_state; ),TP_printk ("%s x %s -> %s%s" , - __entry->state, - __entry->event, - __entry->next_state, +__get_str (state), +__get_str (event), +__get_str (next_state), __entry->final_state ?" (final)" :"" ) );
@@ -43,18 +43,18 @@ DECLARE_EVENT_CLASS(error_da_monitor,TP_ARGS (state, event),TP_STRUCT__entry ( - __array( char, state, MAX_DA_NAME_LEN ) -__array ( char, event,MAX_DA_NAME_LEN ) + __string( state, state ) +__string ( event, event ) ),TP_fast_assign ( - memcpy(__entry->state, state, MAX_DA_NAME_LEN); -memcpy (__entry->event, event,MAX_DA_NAME_LEN ); + __assign_str(state); +__assign_str (event); ),TP_printk ("event %s not expected in the state %s" , - __entry->event, - __entry->state) +__get_str (event), +__get_str (state)) );#include <monitors/wip/wip_trace.h>
@@ -75,26 +75,26 @@ DECLARE_EVENT_CLASS(event_da_monitor_id, TP_ARGS(id, state, event, next_state, final_state),TP_STRUCT__entry ( -__field (int ,id ) -__array ( char, state,MAX_DA_NAME_LEN ) -__array ( char, event,MAX_DA_NAME_LEN ) -__array ( char, next_state,MAX_DA_NAME_LEN ) -__field ( bool, final_state ) +__field (int ,id ) +__string ( state, state ) +__string ( event, event ) +__string ( next_state, next_state ) +__field ( bool, final_state ) ),TP_fast_assign ( - memcpy(__entry->state, state, MAX_DA_NAME_LEN); -memcpy (__entry->event, event,MAX_DA_NAME_LEN ); -memcpy (__entry->next_state, next_state,MAX_DA_NAME_LEN ); - __entry->id = id; - __entry->final_state = final_state; + __assign_str(state); +__assign_str (event); +__assign_str (next_state); + __entry->id = id; + __entry->final_state = final_state; ),TP_printk ("%d: %s x %s -> %s%s" , __entry->id, - __entry->state, - __entry->event, - __entry->next_state, +__get_str (state), +__get_str (event), +__get_str (next_state), __entry->final_state ?" (final)" :"" ) );
@@ -105,21 +105,21 @@ DECLARE_EVENT_CLASS(error_da_monitor_id, TP_ARGS(id, state, event),TP_STRUCT__entry ( -__field (int ,id ) -__array ( char, state,MAX_DA_NAME_LEN ) -__array ( char, event,MAX_DA_NAME_LEN ) +__field (int ,id ) +__string ( state, state ) +__string ( event, event ) ),TP_fast_assign ( - memcpy(__entry->state, state, MAX_DA_NAME_LEN); -memcpy (__entry->event, event,MAX_DA_NAME_LEN ); - __entry->id = id; + __assign_str(state); +__assign_str (event); + __entry->id = id; ),TP_printk ("%d: event %s not expected in the state %s" , __entry->id, - __entry->event, - __entry->state) +__get_str (event), +__get_str (state)) );#include <monitors/wwnr/wwnr_trace.h>
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 295/627 Adjust monitor dependencies
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gabriele Monaco <[email protected]>
[ Upstream commit 79de661707a4a2dc695fd3e00529a14b4f5ec50d ]
RV monitors relying on the preemptirqs tracepoints are set as dependent on PREEMPT_TRACER and IRQSOFF_TRACER. In fact, those configurations do enable the tracepoints but are not the minimal configurations enabling them, which are TRACE_PREEMPT_TOGGLE and TRACE_IRQFLAGS (not selectable manually).
Set TRACE_PREEMPT_TOGGLE and TRACE_IRQFLAGS as dependencies for monitors.
--- kernel/trace/rv/monitors/scpd/Kconfig | 2 +- kernel/trace/rv/monitors/sncid/Kconfig | 2 +- kernel/trace/rv/monitors/snep/Kconfig | 2 +- kernel/trace/rv/monitors/wip/Kconfig | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
kernel/trace/rv/monitors/scpd/Kconfig +1 -1
@@ -2,7 +2,7 @@ # config RV_MON_SCPD depends on RV - depends on PREEMPT_TRACER + depends on TRACE_PREEMPT_TOGGLE depends on RV_MON_SCHED default y select DA_MON_EVENTS_IMPLICIT
kernel/trace/rv/monitors/sncid/Kconfig +1 -1
@@ -2,7 +2,7 @@ # config RV_MON_SNCID depends on RV - depends on IRQSOFF_TRACER + depends on TRACE_IRQFLAGS depends on RV_MON_SCHED default y select DA_MON_EVENTS_IMPLICIT
kernel/trace/rv/monitors/snep/Kconfig +1 -1
@@ -2,7 +2,7 @@ # config RV_MON_SNEP depends on RV - depends on PREEMPT_TRACER + depends on TRACE_PREEMPT_TOGGLE depends on RV_MON_SCHED default y select DA_MON_EVENTS_IMPLICIT
kernel/trace/rv/monitors/wip/Kconfig +1 -1
@@ -2,7 +2,7 @@ # config RV_MON_WIP depends on RV - depends on PREEMPT_TRACER + depends on TRACE_PREEMPT_TOGGLE select DA_MON_EVENTS_IMPLICIT bool "wip monitor" help
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 296/627 staging: media: atomisp: Fix stack buffer overflow in gmin_get_var_int()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit ee4cf798202d285dcbe85e4467a094c44f5ed8e6 ]
When gmin_get_config_var() calls efi.get_variable() and the EFI variable is larger than the expected buffer size, two behaviors combine to create a stack buffer overflow:
1. gmin_get_config_var() does not return the proper error code when efi.get_variable() fails. It returns the stale 'ret' value from earlier operations instead of indicating the EFI failure.
2. When efi.get_variable() returns EFI_BUFFER_TOO_SMALL, it updates *out_len to the required buffer size but writes no data to the output buffer. However, due to bug #1, gmin_get_var_int() believes the call succeeded.
The caller gmin_get_var_int() then performs:
- Allocates val[CFG_VAR_NAME_MAX + 1] (65 bytes) on stack
- Calls gmin_get_config_var(dev, is_gmin, var, val, &len) with len=64
- If EFI variable is >64 bytes, efi.get_variable() sets len=required_size
- Due to bug #1, thinks call succeeded with len=required_size
- Executes val[len] = 0, writing past end of 65-byte stack buffer
This creates a stack buffer overflow when EFI variables are larger than 64 bytes. Since EFI variables can be controlled by firmware or system configuration, this could potentially be exploited for code execution.
Fix the bug by returning proper error codes from gmin_get_config_var() based on EFI status instead of stale 'ret' value.
The gmin_get_var_int() function is called during device initialization for camera sensor configuration on Intel Bay Trail and Cherry Trail platforms using the atomisp camera stack.
--- .../staging/media/atomisp/pci/atomisp_gmin_platform.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +5 -4
@@ -1272,14 +1272,15 @@ static int gmin_get_config_var(struct device *maindev,if (efi_rt_services_supported (EFI_RT_SUPPORTED_GET_VARIABLE )) status = efi.get_variable (var16, &GMIN_CFG_VAR_EFI_GUID ,NULL , (unsigned long *)out_len, out); -if (status ==EFI_SUCCESS ) +if (status ==EFI_SUCCESS ) {dev_info (maindev,"found EFI entry for '%s'\n" , var8); -else if (is_gmin) +return 0 ; + } +if (is_gmin)dev_info (maindev,"Failed to find EFI gmin variable %s\n" , var8);else dev_info (maindev,"Failed to find EFI variable %s\n" , var8); - -return ret; +return -ENOENT ; }int gmin_get_var_int (struct device *dev,bool is_gmin,const char *var,int def)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 297/627 fortify: Fix incorrect reporting of read buffer size
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
[ Upstream commit 94fd44648dae2a5b6149a41faa0b07928c3e1963 ]
When FORTIFY_SOURCE reports about a run-time buffer overread, the wrong buffer size was being shown in the error message. (The bounds checking was correct.)
--- include/linux/fortify-string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/fortify-string.h +1 -1
@@ -596,7 +596,7 @@ __FORTIFY_INLINE bool fortify_memcpy_chk(__kernel_size_t size,if (p_size !=SIZE_MAX && p_size < size)fortify_panic (func,FORTIFY_WRITE , p_size, size, true);else if (q_size !=SIZE_MAX && q_size < size) -fortify_panic (func,FORTIFY_READ , p_size, size, true); +fortify_panic (func,FORTIFY_READ , q_size, size, true);/* * Warn when writing beyond destination field size.
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 298/627 pinctrl: cirrus: madera-core: Use devm_pinctrl_register_mappings()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Richard <[email protected]>
[ Upstream commit 90256033c11028a57437b145449c0dab196183b9 ]
Use devm_pinctrl_register_mappings(), so the mappings are automatically unregistered by the core. If pinctrl_enable() failed during the probe, pinctrl_mappings were not freed. Now it is done by the core.
--- drivers/pinctrl/cirrus/pinctrl-madera-core.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/pinctrl/cirrus/pinctrl-madera-core.c +3 -11
@@ -1061,8 +1061,9 @@ static int madera_pin_probe(struct platform_device *pdev)/* if the configuration is provided through pdata, apply it */ if (pdata->gpio_configs) { - ret =pinctrl_register_mappings (pdata->gpio_configs, - pdata->n_gpio_configs); + ret =devm_pinctrl_register_mappings (priv->dev, + pdata->gpio_configs, + pdata->n_gpio_configs);if (ret)return dev_err_probe (priv->dev, ret,"Failed to register pdata mappings\n" );
@@ -1081,17 +1082,8 @@ static int madera_pin_probe(struct platform_device *pdev)return 0 ; } -static void madera_pin_remove (struct platform_device *pdev) -{ -struct madera_pin_private *priv =platform_get_drvdata (pdev); - -if (priv->madera->pdata.gpio_configs) -pinctrl_unregister_mappings (priv->madera->pdata.gpio_configs); -} -static struct platform_driver madera_pin_driver = { .probe = madera_pin_probe, - .remove = madera_pin_remove, .driver = { .name ="madera-pinctrl" , },
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 299/627 remoteproc: qcom: pas: Conclude the rename from adsp
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Andersson <[email protected]>
[ Upstream commit 2c0c883f895f16fd9d367ec2e64bccab907d8d87 ]
The change that renamed the driver from "adsp" to "pas" didn't change any of the implementation. The result is an aesthetic eyesore, and confusing to many.
Conclude the rename of the driver, by updating function, structures and variable names to match what the driver actually is. The "Hexagon v5" is also dropped from the name and Kconfig, as this isn't correct either.
No functional change.
--- drivers/remoteproc/Kconfig | 11 +- drivers/remoteproc/qcom_q6v5_pas.c | 621 ++++++++++++++--------------- 2 files changed, 313 insertions(+), 319 deletions(-)
drivers/remoteproc/Kconfig +5 -6
@@ -214,7 +214,7 @@ config QCOM_Q6V5_MSS handled by QCOM_Q6V5_PAS driver. config QCOM_Q6V5_PAS - tristate "Qualcomm Hexagon v5 Peripheral Authentication Service support" + tristate "Qualcomm Peripheral Authentication Service support" depends on OF && ARCH_QCOM depends on QCOM_SMEM depends on RPMSG_QCOM_SMD || RPMSG_QCOM_SMD=n
@@ -229,11 +229,10 @@ config QCOM_Q6V5_PAS select QCOM_RPROC_COMMON select QCOM_SCM help - Say y here to support the TrustZone based Peripheral Image Loader - for the Qualcomm Hexagon v5 based remote processors. This is commonly - used to control subsystems such as ADSP (Audio DSP), - CDSP (Compute DSP), MPSS (Modem Peripheral SubSystem), and - SLPI (Sensor Low Power Island). + Say y here to support the TrustZone based Peripheral Image Loader for + the Qualcomm remote processors. This is commonly used to control + subsystems such as ADSP (Audio DSP), CDSP (Compute DSP), MPSS (Modem + Peripheral SubSystem), and SLPI (Sensor Low Power Island). config QCOM_Q6V5_WCSS tristate "Qualcomm Hexagon based WCSS Peripheral Image Loader"
drivers/remoteproc/qcom_q6v5_pas.c +308 -313
1,235 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 300/627 PCI: rockchip-host: Fix "Unexpected Completion" log message
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Zhang <[email protected]>
[ Upstream commit fcc5f586c4edbcc10de23fb9b8c0972a84e945cd ]
Fix the debug message for the PCIE_CORE_INT_UCR interrupt to clearly indicate "Unexpected Completion" instead of a duplicate "malformed TLP" message.
--- drivers/pci/controller/pcie-rockchip-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/pcie-rockchip-host.c +1 -1
@@ -439,7 +439,7 @@ static irqreturn_t rockchip_pcie_subsys_irq_handler(int irq, void *arg)dev_dbg (dev,"malformed TLP received from the link\n" );if (sub_reg &PCIE_CORE_INT_UCR ) -dev_dbg (dev,"malformed TLP received from the link\n" ); +dev_dbg (dev,"Unexpected Completion received from the link\n" );if (sub_reg &PCIE_CORE_INT_FCE )dev_dbg (dev,"an error was observed in the flow control advertisements from the other side\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 301/627 clk: renesas: rzv2h: Fix missing CLK_SET_RATE_PARENT flag for ddiv clocks
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lad Prabhakar <[email protected]>
[ Upstream commit 715676d8418062f54d746451294ccce9786c1734 ]
Commit bc4d25fdfadf ("clk: renesas: rzv2h: Add support for dynamic switching divider clocks") missed setting the CLK_SET_RATE_PARENT flag when registering ddiv clocks.
Without this flag, rate changes to the divider clock do not propagate to its parent, potentially resulting in incorrect clock configurations.
Fix this by setting CLK_SET_RATE_PARENT in the clock init data.
--- drivers/clk/renesas/rzv2h-cpg.c | 1 + 1 file changed, 1 insertion(+)
drivers/clk/renesas/rzv2h-cpg.c +1 -0
@@ -381,6 +381,7 @@ rzv2h_cpg_ddiv_clk_register(const struct cpg_core_clk *core, init.ops = &rzv2h_ddiv_clk_divider_ops; init.parent_names = &parent_name; init.num_parents =1 ; + init.flags =CLK_SET_RATE_PARENT ; ddiv->priv = priv; ddiv->mon = cfg_ddiv.monbit;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 302/627 crypto: sun8i-ce - fix nents passed to dma_unmap_sg()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ovidiu Panait <[email protected]>
[ Upstream commit b6cd3cfb5afe49952f8f6be947aeeca9ba0faebb ]
In sun8i_ce_cipher_unprepare(), dma_unmap_sg() is incorrectly called with the number of entries returned by dma_map_sg(), rather than using the original number of entries passed when mapping the scatterlist.
To fix this, stash the original number of entries passed to dma_map_sg() in the request context.
--- drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/allwinner/sun8i-ce/sun8i-ce-cipher.c +2 -2
@@ -278,8 +278,8 @@ static int sun8i_ce_cipher_prepare(struct crypto_engine *engine, void *async_req } chan->timeout = areq->cryptlen; - rctx->nr_sgs = nr_sgs; - rctx->nr_sgd = nr_sgd; + rctx->nr_sgs = ns; + rctx->nr_sgd = nd;return 0 ; theend_sgs:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 303/627 crypto: qat - use unmanaged allocation for dc_data
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Kumar Chakraborty <[email protected]>
[ Upstream commit 4cc871ad0173e8bc22f80e3609e34d546d30ef1a ]
The dc_data structure holds data required for handling compression operations, such as overflow buffers. In this context, the use of managed memory allocation APIs (devm_kzalloc() and devm_kfree()) is not necessary, as these data structures are freed and re-allocated when a device is restarted in adf_dev_down() and adf_dev_up().
Additionally, managed APIs automatically handle memory cleanup when the device is detached, which can lead to conflicts with manual cleanup processes. Specifically, if a device driver invokes the adf_dev_down() function as part of the cleanup registered with devm_add_action_or_reset(), it may attempt to free memory that is also managed by the device's resource management system, potentially leading to a double-free.
This might result in a warning similar to the following when unloading the device specific driver, for example qat_6xxx.ko:
qat_free_dc_data+0x4f/0x60 [intel_qat]
qat_compression_event_handler+0x3d/0x1d0 [intel_qat]
adf_dev_shutdown+0x6d/0x1a0 [intel_qat]
adf_dev_down+0x32/0x50 [intel_qat]
devres_release_all+0xb8/0x110
device_unbind_cleanup+0xe/0x70
device_release_driver_internal+0x1c1/0x200
driver_detach+0x48/0x90
bus_remove_driver+0x74/0xf0
pci_unregister_driver+0x2e/0xb0Use unmanaged memory allocation APIs (kzalloc_node() and kfree()) for the dc_data structure. This ensures that memory is explicitly allocated and freed under the control of the driver code, preventing manual deallocation from interfering with automatic cleanup.
--- drivers/crypto/intel/qat/qat_common/qat_compression.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/crypto/intel/qat/qat_common/qat_compression.c +2 -2
@@ -196,7 +196,7 @@ static int qat_compression_alloc_dc_data(struct adf_accel_dev *accel_dev)struct adf_dc_data *dc_data =NULL ;u8 *obuff =NULL ; - dc_data =devm_kzalloc (dev,sizeof (*dc_data),GFP_KERNEL ); + dc_data =kzalloc_node (sizeof (*dc_data),GFP_KERNEL ,dev_to_node (dev));if (!dc_data) goto err;
@@ -234,7 +234,7 @@ static void qat_free_dc_data(struct adf_accel_dev *accel_dev)dma_unmap_single (dev, dc_data->ovf_buff_p, dc_data->ovf_buff_sz,DMA_FROM_DEVICE );kfree_sensitive (dc_data->ovf_buff); -devm_kfree (dev, dc_data); +kfree (dc_data); accel_dev->dc_data =NULL ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 304/627 crypto: marvell/cesa - Fix engine load inaccuracy
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 442134ab30e75b7229c4bfc1ac5641d245cffe27 ]
If an error occurs during queueing the engine load will never be decremented. Fix this by moving the engine load adjustment into the cleanup function.
--- drivers/crypto/marvell/cesa/cipher.c | 4 +++- drivers/crypto/marvell/cesa/hash.c | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/crypto/marvell/cesa/cipher.c +3 -1
@@ -75,9 +75,12 @@ mv_cesa_skcipher_dma_cleanup(struct skcipher_request *req)static inline void mv_cesa_skcipher_cleanup (struct skcipher_request *req) {struct mv_cesa_skcipher_req *creq =skcipher_request_ctx (req); +struct mv_cesa_engine *engine = creq->base.engine;if (mv_cesa_req_get_type (&creq->base) ==CESA_DMA_REQ )mv_cesa_skcipher_dma_cleanup (req); + +atomic_sub (req->cryptlen, &engine->load); }static void mv_cesa_skcipher_std_step (struct skcipher_request *req)
@@ -212,7 +215,6 @@ mv_cesa_skcipher_complete(struct crypto_async_request *req)struct mv_cesa_engine *engine = creq->base.engine;unsigned int ivsize; -atomic_sub (skreq->cryptlen, &engine->load); ivsize =crypto_skcipher_ivsize (crypto_skcipher_reqtfm (skreq));if (mv_cesa_req_get_type (&creq->base) ==CESA_DMA_REQ ) {
drivers/crypto/marvell/cesa/hash.c +3 -2
@@ -110,9 +110,12 @@ static inline void mv_cesa_ahash_dma_cleanup(struct ahash_request *req)static inline void mv_cesa_ahash_cleanup (struct ahash_request *req) {struct mv_cesa_ahash_req *creq =ahash_request_ctx (req); +struct mv_cesa_engine *engine = creq->base.engine;if (mv_cesa_req_get_type (&creq->base) ==CESA_DMA_REQ )mv_cesa_ahash_dma_cleanup (req); + +atomic_sub (req->nbytes, &engine->load); }static void mv_cesa_ahash_last_cleanup (struct ahash_request *req)
@@ -395,8 +398,6 @@ static void mv_cesa_ahash_complete(struct crypto_async_request *req) } } } - -atomic_sub (ahashreq->nbytes, &engine->load); } static void mv_cesa_ahash_prepare(struct crypto_async_request *req,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 305/627 crypto: s390/hmac - Fix counter in export state
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 1b39bc4a703a63a22c08232015540adfb31f22ba ]
The hmac export state needs to be one block-size bigger to account for the ipad.
--- arch/s390/crypto/hmac_s390.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/s390/crypto/hmac_s390.c +8 -4
@@ -290,6 +290,7 @@ static int s390_hmac_export(struct shash_desc *desc, void *out)struct s390_kmac_sha2_ctx *ctx =shash_desc_ctx (desc);unsigned int bs =crypto_shash_blocksize (desc->tfm);unsigned int ds = bs /2 ; +u64 lo = ctx->buflen[0 ];union {u8 *u8;u64 *u64;
@@ -301,9 +302,10 @@ static int s390_hmac_export(struct shash_desc *desc, void *out)else memcpy (p.u8, ctx->param, ds); p.u8 += ds; -put_unaligned (ctx->buflen[0 ], p.u64++); + lo += bs; +put_unaligned (lo, p.u64++);if (ds ==SHA512_DIGEST_SIZE ) -put_unaligned (ctx->buflen[1 ], p.u64); +put_unaligned (ctx->buflen[1 ] + (lo < bs), p.u64);return err; }
@@ -316,14 +318,16 @@ static int s390_hmac_import(struct shash_desc *desc, const void *in)const u8 *u8;const u64 *u64; } p = { .u8 = in }; +u64 lo;int err; err =s390_hmac_sha2_init (desc);memcpy (ctx->param, p.u8, ds); p.u8 += ds; - ctx->buflen[0 ] =get_unaligned (p.u64++); + lo =get_unaligned (p.u64++); + ctx->buflen[0 ] = lo - bs;if (ds ==SHA512_DIGEST_SIZE ) - ctx->buflen[1 ] =get_unaligned (p.u64); + ctx->buflen[1 ] =get_unaligned (p.u64) - (lo < bs);if (ctx->buflen[0 ] | ctx->buflen[1 ]) ctx->gr0.ikp =1 ;return err;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 306/627 crypto: s390/sha3 - Use cpu byte-order when exporting
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 73c2437109c3eab274258a6430ae5dafac1ef43e ]
The sha3 partial hash on s390 is in little-endian just like the final hash. However the generic implementation produces native or big-endian partial hashes.
Make s390 sha3 conform to that by doing the byte-swap on export and import.
--- arch/s390/crypto/sha.h | 3 +++ arch/s390/crypto/sha3_256_s390.c | 24 +++++++++++++++++------- arch/s390/crypto/sha3_512_s390.c | 25 +++++++++++++++++-------- 3 files changed, 37 insertions(+), 15 deletions(-)
arch/s390/crypto/sha.h +3 -0
@@ -27,6 +27,9 @@ struct s390_sha_ctx {u64 state[SHA512_DIGEST_SIZE /sizeof (u64)];u64 count_hi; } sha512; +struct { +__le64 state[SHA3_STATE_SIZE /sizeof (u64)]; + } sha3; };int func;/* KIMD function to use */ bool first_message_part;
arch/s390/crypto/sha3_256_s390.c +17 -7
@@ -35,23 +35,33 @@ static int sha3_256_init(struct shash_desc *desc)static int sha3_256_export (struct shash_desc *desc,void *out) {struct s390_sha_ctx *sctx =shash_desc_ctx (desc); -struct sha3_state *octx = out; +union { +u8 *u8; +u64 *u64; + } p = { .u8 = out }; +int i;if (sctx->first_message_part) { -memset (sctx->state,0 ,sizeof (sctx->state)); - sctx->first_message_part =0 ; +memset (out,0 ,SHA3_STATE_SIZE ); +return 0 ; } -memcpy (octx->st, sctx->state,sizeof (octx->st)); +for (i =0 ; i <SHA3_STATE_SIZE /8 ; i++) +put_unaligned (le64_to_cpu (sctx->sha3.state[i]), p.u64++);return 0 ; }static int sha3_256_import (struct shash_desc *desc,const void *in) {struct s390_sha_ctx *sctx =shash_desc_ctx (desc); -const struct sha3_state *ictx = in; - +union { +const u8 *u8; +const u64 *u64; + } p = { .u8 = in }; +int i; + +for (i =0 ; i <SHA3_STATE_SIZE /8 ; i++) + sctx->sha3.state[i] =cpu_to_le64 (get_unaligned (p.u64++)); sctx->count =0 ; -memcpy (sctx->state, ictx->st,sizeof (ictx->st)); sctx->first_message_part =0 ; sctx->func =CPACF_KIMD_SHA3_256 ;
arch/s390/crypto/sha3_512_s390.c +17 -8
@@ -34,24 +34,33 @@ static int sha3_512_init(struct shash_desc *desc)static int sha3_512_export (struct shash_desc *desc,void *out) {struct s390_sha_ctx *sctx =shash_desc_ctx (desc); -struct sha3_state *octx = out; - +union { +u8 *u8; +u64 *u64; + } p = { .u8 = out }; +int i;if (sctx->first_message_part) { -memset (sctx->state,0 ,sizeof (sctx->state)); - sctx->first_message_part =0 ; +memset (out,0 ,SHA3_STATE_SIZE ); +return 0 ; } -memcpy (octx->st, sctx->state,sizeof (octx->st)); +for (i =0 ; i <SHA3_STATE_SIZE /8 ; i++) +put_unaligned (le64_to_cpu (sctx->sha3.state[i]), p.u64++);return 0 ; }static int sha3_512_import (struct shash_desc *desc,const void *in) {struct s390_sha_ctx *sctx =shash_desc_ctx (desc); -const struct sha3_state *ictx = in; - +union { +const u8 *u8; +const u64 *u64; + } p = { .u8 = in }; +int i; + +for (i =0 ; i <SHA3_STATE_SIZE /8 ; i++) + sctx->sha3.state[i] =cpu_to_le64 (get_unaligned (p.u64++)); sctx->count =0 ; -memcpy (sctx->state, ictx->st,sizeof (ictx->st)); sctx->first_message_part =0 ; sctx->func =CPACF_KIMD_SHA3_512 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 307/627 padata: Fix pd UAF once and for all
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 71203f68c7749609d7fc8ae6ad054bdedeb24f91 ]
There is a race condition/UAF in padata_reorder that goes back to the initial commit. A reference count is taken at the start of the process in padata_do_parallel, and released at the end in padata_serial_worker.
This reference count is (and only is) required for padata_replace to function correctly. If padata_replace is never called then there is no issue.
In the function padata_reorder which serves as the core of padata, as soon as padata is added to queue->serial.list, and the associated spin lock released, that padata may be processed and the reference count on pd would go away.
Fix this by getting the next padata before the squeue->serial lock is released.
In order to make this possible, simplify padata_reorder by only calling it once the next padata arrives.
--- include/linux/padata.h | 3 - kernel/padata.c | 132 ++++++++++++----------------------------- 2 files changed, 37 insertions(+), 98 deletions(-)
include/linux/padata.h +0 -3
@@ -91,7 +91,6 @@ struct padata_cpumask {* @cpu: Next CPU to be processed. * @cpumask: The cpumasks in use for parallel and serial workers. * @reorder_work: work struct for reordering. -* @lock: Reorder lock. */ struct parallel_data {struct padata_shell *ps;
@@ -102,8 +101,6 @@ struct parallel_data {unsigned int processed;int cpu;struct padata_cpumask cpumask; -struct work_struct reorder_work; -spinlock_t ____cacheline_aligned lock; };/**
kernel/padata.c +37 -95
198 lines not on this page · raw message
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 308/627 crypto: ccp - Fix dereferencing uninitialized error pointer
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ashish Kalra <[email protected]>
[ Upstream commit 0fa766726c091ff0ec7d26874f6e4724d23ecb0e ]
Fix below smatch warnings:drivers/crypto/ccp/sev-dev.c:1312 __sev_platform_init_locked()
error: we previously assumed 'error' could be null
--- drivers/crypto/ccp/sev-dev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/crypto/ccp/sev-dev.c +5 -3
@@ -1276,9 +1276,11 @@ static int __sev_platform_init_handle_init_ex_path(struct sev_device *sev)static int __sev_platform_init_locked (int *error) { -int rc, psp_ret =SEV_RET_NO_FW_CALL ; +int rc, psp_ret, dfflush_error;struct sev_device *sev; + psp_ret = dfflush_error =SEV_RET_NO_FW_CALL ; +if (!psp_master || !psp_master->sev_data)return -ENODEV ;
@@ -1320,10 +1322,10 @@ static int __sev_platform_init_locked(int *error)/* Prepare for first SEV guest launch after INIT */ wbinvd_on_all_cpus (); - rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , error); + rc =__sev_do_cmd_locked (SEV_CMD_DF_FLUSH ,NULL , &dfflush_error);if (rc) {dev_err (sev->dev,"SEV: DF_FLUSH failed %#x, rc %d\n" , - *error, rc); + dfflush_error, rc);return rc; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 309/627 crypto: qat - allow enabling VFs in the absence of IOMMU
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ahsan Atta <[email protected]>
[ Upstream commit 53669ff591d4deb2d80eed4c07593ad0c0b45899 ]
The commit ca88a2bdd4dd ("crypto: qat - allow disabling SR-IOV VFs") introduced an unnecessary change that prevented enabling SR-IOV when IOMMU is disabled. In certain scenarios, it is desirable to enable SR-IOV even in the absence of IOMMU. Thus, restoring the previous functionality to allow VFs to be enumerated in the absence of IOMMU.
--- drivers/crypto/intel/qat/qat_common/adf_sriov.c | 1 - 1 file changed, 1 deletion(-)
drivers/crypto/intel/qat/qat_common/adf_sriov.c +0 -1
@@ -155,7 +155,6 @@ static int adf_do_enable_sriov(struct adf_accel_dev *accel_dev)if (!device_iommu_mapped (&GET_DEV (accel_dev))) {dev_warn (&GET_DEV (accel_dev),"IOMMU should be enabled for SR-IOV to work correctly\n" ); -return -EINVAL ; }if (adf_dev_started (accel_dev)) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 310/627 crypto: qat - fix state restore for banks with exceptions
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Svyatoslav Pankratov <[email protected]>
[ Upstream commit 254923ca8715f623704378266815b6d14eb26194 ]
Change the logic in the restore function to properly handle bank exceptions.
The check for exceptions in the saved state should be performed before conducting any other ringstat register checks.
If a bank was saved with an exception, the ringstat will have the appropriate rp_halt/rp_exception bits set, causing the driver to exit the restore process with an error. Instead, the restore routine should first check the ringexpstat register, and if any exception was raised, it should stop further checks and return without any error. In other words, if a ring pair is in an exception state at the source, it should be restored the same way at the destination but without raising an error.
Even though this approach might lead to losing the exception state during migration, the driver will log the exception from the saved state during the restore process.
--- .../intel/qat/qat_common/adf_gen4_hw_data.c | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-)
drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c +22 -7
@@ -581,6 +581,28 @@ static int bank_state_restore(struct adf_hw_csr_ops *ops, void __iomem *base, ops->write_csr_int_srcsel_w_val (base, bank, state->iaintflagsrcsel0); ops->write_csr_exp_int_en (base, bank, state->ringexpintenable); ops->write_csr_int_col_ctl (base, bank, state->iaintcolctl); + +/* +* Verify whether any exceptions were raised during the bank save process. +* If exceptions occurred, the status and exception registers cannot +* be directly restored. Consequently, further restoration is not +* feasible, and the current state of the ring should be maintained. +*/ + val = state->ringexpstat; +if (val) { +pr_info ("QAT: Bank %u state not fully restored due to exception in saved state (%#x)\n" , + bank, val); +return 0 ; + } + +/* Ensure that the restoration process completed without exceptions */ + tmp_val = ops->read_csr_exp_stat (base, bank); +if (tmp_val) { +pr_err ("QAT: Bank %u restored with exception: %#x\n" , + bank, tmp_val); +return -EFAULT ; + } + ops->write_csr_ring_srv_arb_en (base, bank, state->ringsrvarben);/* Check that all ring statuses match the saved state. */
@@ -614,13 +636,6 @@ static int bank_state_restore(struct adf_hw_csr_ops *ops, void __iomem *base,if (ret)return ret; - tmp_val = ops->read_csr_exp_stat (base, bank); - val = state->ringexpstat; -if (tmp_val && !val) { -pr_err ("QAT: Bank was restored with exception: 0x%x\n" , val); -return -EINVAL ; - } -return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 311/627 mtd: fix possible integer overflow in erase_xfer()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ivan Stepchenko <[email protected]>
[ Upstream commit 9358bdb9f9f54d94ceafc650deffefd737d19fdd ]
The expression '1 << EraseUnitSize' is evaluated in int, which causes a negative result when shifting by 31 - the upper bound of the valid range [10, 31], enforced by scan_header(). This leads to incorrect extension when storing the result in 'erase->len' (uint64_t), producing a large unexpected value.
Found by Linux Verification Center (linuxtesting.org) with Svace.
--- drivers/mtd/ftl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ftl.c +1 -1
@@ -344,7 +344,7 @@ static int erase_xfer(partition_t *part,return -ENOMEM ; erase->addr = xfer->Offset; - erase->len =1 << part->header.EraseUnitSize; + erase->len =1ULL << part->header.EraseUnitSize; ret =mtd_erase (part->mbd.mtd, erase);if (!ret) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 312/627 clk: davinci: Add NULL check in davinci_lpsc_clk_register()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Henry Martin <[email protected]>
[ Upstream commit 13de464f445d42738fe18c9a28bab056ba3a290a ]
devm_kasprintf() returns NULL when memory allocation fails. Currently, davinci_lpsc_clk_register() does not check for this case, which results in a NULL pointer dereference.
Add NULL check after devm_kasprintf() to prevent this issue and ensuring no resources are left allocated.
--- drivers/clk/davinci/psc.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/clk/davinci/psc.c +5 -0
@@ -277,6 +277,11 @@ davinci_lpsc_clk_register(struct device *dev, const char *name, lpsc->pm_domain.name =devm_kasprintf (dev,GFP_KERNEL ,"%s: %s" ,best_dev_name (dev), name); +if (!lpsc->pm_domain.name) { +clk_hw_unregister (&lpsc->hw); +kfree (lpsc); +return ERR_PTR (-ENOMEM ); + } lpsc->pm_domain.attach_dev = davinci_psc_genpd_attach_dev; lpsc->pm_domain.detach_dev = davinci_psc_genpd_detach_dev; lpsc->pm_domain.flags =GENPD_FLAG_PM_CLK ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 313/627 media: imx-jpeg: Account for data_offset when getting image address
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ming Qian <[email protected]>
[ Upstream commit 51ad3b570ea7b1916ff4db993f1aa22bb48fdac6 ]
Applications may set data_offset when it refers to an output queue. So driver need to account for it when getting the start address of input image in the plane.
Meanwhile the mxc-jpeg codec requires the address (plane address + data_offset) to be 16-aligned.
--- .../media/platform/nxp/imx-jpeg/mxc-jpeg.c | 47 ++++++++++++++----- .../media/platform/nxp/imx-jpeg/mxc-jpeg.h | 1 + 2 files changed, 37 insertions(+), 11 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +36 -11
@@ -598,6 +598,27 @@ static void _bswap16(u16 *a) *a = ((*a &0x00FF ) <<8 ) | ((*a &0xFF00 ) >>8 ); } +static dma_addr_t mxc_jpeg_get_plane_dma_addr (struct vb2_buffer *buf,unsigned int plane_no) +{ +if (plane_no >= buf->num_planes) +return 0 ; +return vb2_dma_contig_plane_dma_addr (buf, plane_no) + buf->planes[plane_no].data_offset; +} + +static void *mxc_jpeg_get_plane_vaddr (struct vb2_buffer *buf,unsigned int plane_no) +{ +if (plane_no >= buf->num_planes) +return NULL ; +return vb2_plane_vaddr (buf, plane_no) + buf->planes[plane_no].data_offset; +} + +static unsigned long mxc_jpeg_get_plane_payload (struct vb2_buffer *buf,unsigned int plane_no) +{ +if (plane_no >= buf->num_planes) +return 0 ; +return vb2_get_plane_payload (buf, plane_no) - buf->planes[plane_no].data_offset; +} +static void print_mxc_buf (struct mxc_jpeg_dev *jpeg,struct vb2_buffer *buf,unsigned long len) {
@@ -610,11 +631,11 @@ static void print_mxc_buf(struct mxc_jpeg_dev *jpeg, struct vb2_buffer *buf,return ;for (plane_no =0 ; plane_no < buf->num_planes; plane_no++) { - payload =vb2_get_plane_payload (buf, plane_no); + payload =mxc_jpeg_get_plane_payload (buf, plane_no);if (len ==0 ) len = payload; - dma_addr =vb2_dma_contig_plane_dma_addr (buf, plane_no); - vaddr =vb2_plane_vaddr (buf, plane_no); + dma_addr =mxc_jpeg_get_plane_dma_addr (buf, plane_no); + vaddr =mxc_jpeg_get_plane_vaddr (buf, plane_no);v4l2_dbg (3 , debug, &jpeg->v4l2_dev,"plane %d (vaddr=%p dma_addr=%x payload=%ld):" , plane_no, vaddr, dma_addr, payload);
@@ -712,16 +733,15 @@ static void mxc_jpeg_addrs(struct mxc_jpeg_desc *desc,struct mxc_jpeg_q_data *q_data; q_data =mxc_jpeg_get_q_data (ctx, raw_buf->type); - desc->buf_base0 =vb2_dma_contig_plane_dma_addr (raw_buf,0 ); + desc->buf_base0 =mxc_jpeg_get_plane_dma_addr (raw_buf,0 ); desc->buf_base1 =0 ;if (img_fmt ==STM_CTRL_IMAGE_FORMAT (MXC_JPEG_YUV420 )) {if (raw_buf->num_planes ==2 ) - desc->buf_base1 =vb2_dma_contig_plane_dma_addr (raw_buf,1 ); + desc->buf_base1 =mxc_jpeg_get_plane_dma_addr (raw_buf,1 );else desc->buf_base1 = desc->buf_base0 + q_data->sizeimage[0 ]; } - desc->stm_bufbase =vb2_dma_contig_plane_dma_addr (jpeg_buf,0 ) + - offset; + desc->stm_bufbase =mxc_jpeg_get_plane_dma_addr (jpeg_buf,0 ) + offset; }static bool mxc_jpeg_is_extended_sequential (const struct mxc_jpeg_fmt *fmt)
@@ -1029,8 +1049,8 @@ static irqreturn_t mxc_jpeg_dec_irq(int irq, void *priv)vb2_set_plane_payload (&dst_buf->vb2_buf,1 , payload); }dev_dbg (dev,"Decoding finished, payload size: %ld + %ld\n" , -vb2_get_plane_payload (&dst_buf->vb2_buf,0 ), -vb2_get_plane_payload (&dst_buf->vb2_buf,1 )); +mxc_jpeg_get_plane_payload (&dst_buf->vb2_buf,0 ), +mxc_jpeg_get_plane_payload (&dst_buf->vb2_buf,1 )); }/* short preview of the results */
@@ -1889,8 +1909,8 @@ static int mxc_jpeg_parse(struct mxc_jpeg_ctx *ctx, struct vb2_buffer *vb)struct mxc_jpeg_sof *psof =NULL ;struct mxc_jpeg_sos *psos =NULL ;struct mxc_jpeg_src_buf *jpeg_src_buf =vb2_to_mxc_buf (vb); -u8 *src_addr = (u8 *)vb2_plane_vaddr (vb,0 ); -u32 size =vb2_get_plane_payload (vb,0 ); +u8 *src_addr = (u8 *)mxc_jpeg_get_plane_vaddr (vb,0 ); +u32 size =mxc_jpeg_get_plane_payload (vb,0 );int ret;memset (&header,0 ,sizeof (header));
@@ -2027,6 +2047,11 @@ static int mxc_jpeg_buf_prepare(struct vb2_buffer *vb) i, vb2_plane_size(vb, i), sizeimage);return -EINVAL ; } +if (!IS_ALIGNED (mxc_jpeg_get_plane_dma_addr (vb, i),MXC_JPEG_ADDR_ALIGNMENT )) { +dev_err (dev,"planes[%d] address is not %d aligned\n" , + i,MXC_JPEG_ADDR_ALIGNMENT ); +return -EINVAL ; + } }if (V4L2_TYPE_IS_CAPTURE (vb->vb2_queue->type)) {vb2_set_plane_payload (vb,0 ,0 );
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +1 -0
@@ -30,6 +30,7 @@#define MXC_JPEG_MAX_PLANES 2#define MXC_JPEG_PATTERN_WIDTH 128#define MXC_JPEG_PATTERN_HEIGHT 64 +#define MXC_JPEG_ADDR_ALIGNMENT 16enum mxc_jpeg_enc_state {MXC_JPEG_ENCODING =0 ,/* jpeg encode phase */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 314/627 media: v4l2-ctrls: Fix H264 SEPARATE_COLOUR_PLANE check
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Cowgill <[email protected]>
[ Upstream commit 803b9eabc649c778986449eb0596e5ffeb7a8aed ]
The separate_colour_plane_flag element is only present in the SPS if chroma_format_idc == 3, so the corresponding flag should be disabled whenever that is not the case and not just on profiles where chroma_format_idc is not present.
--- drivers/media/v4l2-core/v4l2-ctrls-core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/media/v4l2-core/v4l2-ctrls-core.c +4 -4
@@ -968,12 +968,12 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx, p_h264_sps->flags &= ~V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS ; - -if (p_h264_sps->chroma_format_idc <3 ) - p_h264_sps->flags &= - ~V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE ; } +if (p_h264_sps->chroma_format_idc <3 ) + p_h264_sps->flags &= + ~V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE ; +if (p_h264_sps->flags &V4L2_H264_SPS_FLAG_FRAME_MBS_ONLY ) p_h264_sps->flags &= ~V4L2_H264_SPS_FLAG_MB_ADAPTIVE_FRAME_FIELD ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 315/627 perf parse-events: Set default GH modifier properly
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit dcbe6e51a0bb80a40f9a8c87750c291c2364573d ]
Commit 7b100989b4f6bce7 ("perf evlist: Remove __evlist__add_default") changed to use "cycles:P" as a default event. But the problem is it cannot set other default modifiers correctly.
perf kvm needs to set attr.exclude_host by default but it didn't work because of the logic in the parse_events__modifier_list(). Also the exclude_GH_default was applied only if ":u" modifier was specified - which is strange. Move it out after handling the ":GH" and check perf_host and perf_guest properly.
Before:
$ ./perf kvm record -vv true |& grep exclude (nothing)
But specifying an event (without a modifier) works:
$ ./perf kvm record -vv -e cycles true |& grep exclude
exclude_host 1After:
It now works for the both cases:
$ ./perf kvm record -vv true |& grep exclude
exclude_host 1 $ ./perf kvm record -vv -e cycles true |& grep exclude
exclude_host 1--- tools/perf/util/parse-events.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
tools/perf/util/parse-events.c +8 -3
@@ -1829,13 +1829,11 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state,int eH = group ? evsel->core.attr.exclude_host :0 ;int eG = group ? evsel->core.attr.exclude_guest :0 ;int exclude = eu | ek | eh; -int exclude_GH = group ? evsel->exclude_GH :0 ; +int exclude_GH = eG | eH;if (mod.user) {if (!exclude) exclude = eu = ek = eh =1 ; -if (!exclude_GH && !perf_guest && exclude_GH_default) - eG =1 ; eu =0 ; }if (mod.kernel) {
@@ -1858,6 +1856,13 @@ static int parse_events__modifier_list(struct parse_events_state *parse_state, exclude_GH = eG = eH =1 ; eH =0 ; } +if (!exclude_GH && exclude_GH_default) { +if (perf_host) + eG =1 ; +else if (perf_guest) + eH =1 ; + } + evsel->core.attr.exclude_user = eu; evsel->core.attr.exclude_kernel = ek; evsel->core.attr.exclude_hv = eh;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 316/627 clk: xilinx: vcu: unregister pll_post only if registered correctly
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rohit Visavalia <[email protected]>
[ Upstream commit 3b0abc443ac22f7d4f61ddbbbbc5dbb06c87139d ]
If registration of pll_post is failed, it will be set to NULL or ERR, unregistering same will fail with following call trace:
Unable to handle kernel NULL pointer dereference at virtual address 008 pc : clk_hw_unregister+0xc/0x20 lr : clk_hw_unregister_fixed_factor+0x18/0x30 sp : ffff800011923850 ... Call trace: clk_hw_unregister+0xc/0x20 clk_hw_unregister_fixed_factor+0x18/0x30 xvcu_unregister_clock_provider+0xcc/0xf4 [xlnx_vcu] xvcu_probe+0x2bc/0x53c [xlnx_vcu]
--- drivers/clk/xilinx/xlnx_vcu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/xilinx/xlnx_vcu.c +2 -2
@@ -587,8 +587,8 @@ static void xvcu_unregister_clock_provider(struct xvcu_device *xvcu)xvcu_clk_hw_unregister_leaf (hws[CLK_XVCU_ENC_MCU ]);if (!IS_ERR_OR_NULL (hws[CLK_XVCU_ENC_CORE ]))xvcu_clk_hw_unregister_leaf (hws[CLK_XVCU_ENC_CORE ]); - -clk_hw_unregister_fixed_factor (xvcu->pll_post); +if (!IS_ERR_OR_NULL (xvcu->pll_post)) +clk_hw_unregister_fixed_factor (xvcu->pll_post); }/**
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 317/627 power: supply: cpcap-charger: Fix null check for power_supply_get_by_name
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit d9fa3aae08f99493e67fb79413c0e95d30fca5e9 ]
In the cpcap_usb_detect() function, the power_supply_get_by_name() function may return NULL instead of an error pointer. To prevent potential null pointer dereferences, Added a null check.
--- drivers/power/supply/cpcap-charger.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/power/supply/cpcap-charger.c +2 -3
@@ -689,9 +689,8 @@ static void cpcap_usb_detect(struct work_struct *work)struct power_supply *battery; battery =power_supply_get_by_name ("battery" ); -if (IS_ERR_OR_NULL (battery)) { -dev_err (ddata->dev,"battery power_supply not available %li\n" , -PTR_ERR (battery)); +if (!battery) { +dev_err (ddata->dev,"battery power_supply not available\n" );return ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 318/627 power: reset: POWER_RESET_TORADEX_EC should depend on ARCH_MXC
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 22e4d29f081df8a10f1c062d3d952bb876eb9bdc ]
The Toradex Embedded Controller is currently only present on Toradex SMARC iMX8MP and iMX95 SoMs. Hence add a dependency on ARCH_MXC, to prevent asking the user about this driver when configuring a kernel without NXP i.MX SoC family support.
--- drivers/power/reset/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/power/reset/Kconfig +1 -0
@@ -218,6 +218,7 @@ config POWER_RESET_ST config POWER_RESET_TORADEX_EC tristate "Toradex Embedded Controller power-off and reset driver" + depends on ARCH_MXC || COMPILE_TEST depends on I2C select REGMAP_I2C help
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 319/627 power: supply: max14577: Handle NULL pdata when CONFIG_OF is not set
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Han <[email protected]>
[ Upstream commit 2937f5d2e24eefef8cb126244caec7fe3307f724 ]
When the kernel is not configured CONFIG_OF, the max14577_charger_dt_init function returns NULL. Fix the max14577_charger_probe functionby returning -ENODATA instead of potentially passing a NULL pointer to PTR_ERR.
This fixes the below smatch warning:max14577_charger_probe() warn: passing zero to 'PTR_ERR'
--- drivers/power/supply/max14577_charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/max14577_charger.c +2 -2
@@ -501,7 +501,7 @@ static struct max14577_charger_platform_data *max14577_charger_dt_init(static struct max14577_charger_platform_data *max14577_charger_dt_init (struct platform_device *pdev) { -return NULL ; +return ERR_PTR (-ENODATA ); }#endif /* CONFIG_OF */
@@ -572,7 +572,7 @@ static int max14577_charger_probe(struct platform_device *pdev) chg->max14577 = max14577; chg->pdata =max14577_charger_dt_init (pdev); -if (IS_ERR_OR_NULL (chg->pdata)) +if (IS_ERR (chg->pdata))return PTR_ERR (chg->pdata); ret =max14577_charger_reg_init (chg);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 320/627 power: supply: qcom_pmi8998_charger: fix wakeirq
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Casey Connolly <[email protected]>
[ Upstream commit 6c5393771c50fac30f08dfb6d2f65f4f2cfeb8c7 ]
Unloading and reloading the driver (e.g. when built as a module) currently leads to errors trying to enable wake IRQ since it's already enabled.
Use devm to manage this for us so it correctly gets disabled when removing the driver.
Additionally, call device_init_wakeup() so that charger attach/remove will trigger a wakeup by default.
--- drivers/power/supply/qcom_pmi8998_charger.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/power/supply/qcom_pmi8998_charger.c +3 -1
@@ -1016,7 +1016,9 @@ static int smb2_probe(struct platform_device *pdev)if (rc <0 )return rc; - rc =dev_pm_set_wake_irq (chip->dev, chip->cable_irq); +devm_device_init_wakeup (chip->dev); + + rc =devm_pm_set_wake_irq (chip->dev, chip->cable_irq);if (rc <0 )return dev_err_probe (chip->dev, rc,"Couldn't set wake irq\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 321/627 power: supply: max1720x correct capacity computation
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Antoine <[email protected]>
[ Upstream commit 58ae036172b5f051a19a32eba94a3e5eb37bf47e ]
Quoted 1 line
From the datasheet of the MAX17201/17205, the LSB should be "5.0μVh/RSENSE".
The current computation sets it at 0.5mAh=5.0μVh/10mOhm, which does not take into account the value of rsense (which is in 10µV steps) which can be different from 10mOhm.
Change the computation to fit the specs.
--- drivers/power/supply/max1720x_battery.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
drivers/power/supply/max1720x_battery.c +6 -5
@@ -288,9 +288,10 @@ static int max172xx_voltage_to_ps(unsigned int reg)return reg *1250 ;/* in uV */ } -static int max172xx_capacity_to_ps (unsigned int reg) +static int max172xx_capacity_to_ps (unsigned int reg, +struct max1720x_device_info *info) { -return reg *500 ;/* in uAh */ +return reg * (500000 / info->rsense);/* in uAh */ }/*
@@ -394,11 +395,11 @@ static int max1720x_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN : ret =regmap_read (info->regmap,MAX172XX_DESIGN_CAP , ®_val); - val->intval =max172xx_capacity_to_ps (reg_val); + val->intval =max172xx_capacity_to_ps (reg_val, info);break ;case POWER_SUPPLY_PROP_CHARGE_AVG : ret =regmap_read (info->regmap,MAX172XX_REPCAP , ®_val); - val->intval =max172xx_capacity_to_ps (reg_val); + val->intval =max172xx_capacity_to_ps (reg_val, info);break ;case POWER_SUPPLY_PROP_TIME_TO_EMPTY_AVG : ret =regmap_read (info->regmap,MAX172XX_TTE , ®_val);
@@ -422,7 +423,7 @@ static int max1720x_battery_get_property(struct power_supply *psy,break ;case POWER_SUPPLY_PROP_CHARGE_FULL : ret =regmap_read (info->regmap,MAX172XX_FULL_CAP , ®_val); - val->intval =max172xx_capacity_to_ps (reg_val); + val->intval =max172xx_capacity_to_ps (reg_val, info);break ;case POWER_SUPPLY_PROP_MODEL_NAME : ret =regmap_read (info->regmap,MAX172XX_DEV_NAME , ®_val);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 322/627 crypto: arm/aes-neonbs - work around gcc-15 warning
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit d5fa96dc5590915f060fee3209143313e4f5b03b ]
I get a very rare -Wstringop-overread warning with gcc-15 for one function in aesbs_ctr_encrypt():
arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:212:1446: error: '__builtin_memcpy' offset [17, 2147483647] is out of the bounds [0, 16] of object 'buf' with type 'u8[16]' {aka 'unsigned char[16]'} [-Werror=array-bounds=]
212 | src = dst = memcpy(buf + sizeof(buf) - bytes,arch/arm/crypto/aes-neonbs-glue.c: In function 'ctr_encrypt':arch/arm/crypto/aes-neonbs-glue.c:218:17: error: 'aesbs_ctr_encrypt' reading 1 byte from a region of size 0 [-Werror=stringop-overread]
218 | aesbs_ctr_encrypt(dst, src, ctx->rk, ctx->rounds, bytes, walk.iv);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 2 of type 'const u8[0]' {aka 'const unsigned char[]'} arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 3 of type 'const u8[0]' {aka 'const unsigned char[]'} arch/arm/crypto/aes-neonbs-glue.c:218:17: note: referencing argument 6 of type 'u8[0]' {aka 'unsigned char[]'} arch/arm/crypto/aes-neonbs-glue.c:36:17: note: in a call to function 'aesbs_ctr_encrypt'
36 | asmlinkage void aesbs_ctr_encrypt(u8 out[], u8 const in[], u8 const rk[],
This could happen in theory if walk.nbytes is larger than INT_MAX and gets converted to a negative local variable.
Keep the type unsigned like the orignal nbytes to be sure there is no integer overflow.
--- arch/arm/crypto/aes-neonbs-glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/crypto/aes-neonbs-glue.c +1 -1
@@ -206,7 +206,7 @@ static int ctr_encrypt(struct skcipher_request *req)while (walk.nbytes >0 ) {const u8 *src = walk.src.virt.addr;u8 *dst = walk.dst.virt.addr; -int bytes = walk.nbytes; +unsigned int bytes = walk.nbytes;if (unlikely (bytes <AES_BLOCK_SIZE )) src = dst = memcpy(buf + sizeof(buf) - bytes,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 323/627 crypto: ahash - Add support for drivers with no fallback
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 4ccd065a69df163cd9fe0dd8e0f609f1eeb4723d ]
Some drivers cannot have a fallback, e.g., because the key is held in hardware. Allow these to be used with ahash by adding the bit CRYPTO_ALG_NO_FALLBACK.
Stable-dep-of: 1e2b7fcd3f07 ("crypto: ahash - Stop legacy tfms from using the set_virt fallback path")
--- crypto/ahash.c | 10 +++++++++- include/linux/crypto.h | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-)
crypto/ahash.c +9 -1
@@ -347,6 +347,9 @@ static int ahash_do_req_chain(struct ahash_request *req,if (crypto_ahash_statesize (tfm) >HASH_MAX_STATESIZE )return -ENOSYS ; +if (!crypto_ahash_need_fallback (tfm)) +return -ENOSYS ; + {u8 state[HASH_MAX_STATESIZE ];
@@ -954,6 +957,10 @@ static int ahash_prepare_alg(struct ahash_alg *alg) base->cra_reqsize > MAX_SYNC_HASH_REQSIZE)return -EINVAL ; +if (base->cra_flags &CRYPTO_ALG_NEED_FALLBACK && + base->cra_flags &CRYPTO_ALG_NO_FALLBACK ) +return -EINVAL ; + err =hash_prepare_alg (&alg->halg);if (err)return err;
@@ -962,7 +969,8 @@ static int ahash_prepare_alg(struct ahash_alg *alg) base->cra_flags |=CRYPTO_ALG_TYPE_AHASH ;if ((base->cra_flags ^CRYPTO_ALG_REQ_VIRT ) & - (CRYPTO_ALG_ASYNC |CRYPTO_ALG_REQ_VIRT )) + (CRYPTO_ALG_ASYNC |CRYPTO_ALG_REQ_VIRT ) && + !(base->cra_flags &CRYPTO_ALG_NO_FALLBACK )) base->cra_flags |=CRYPTO_ALG_NEED_FALLBACK ;if (!alg->setkey)
include/linux/crypto.h +3 -0
@@ -136,6 +136,9 @@/* Set if the algorithm supports virtual addresses. */ #define CRYPTO_ALG_REQ_VIRT 0x00040000 +/* Set if the algorithm cannot have a fallback (e.g., phmac). */ +#define CRYPTO_ALG_NO_FALLBACK 0x00080000 +/* The high bits 0xff000000 are reserved for type-specific flags. */ /*
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 324/627 crypto: ahash - Stop legacy tfms from using the set_virt fallback path
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Herbert Xu <[email protected]>
[ Upstream commit 1e2b7fcd3f075ff8c5b0e4474fe145d1c685f54f ]
Ensure that drivers that have not been converted to the ahash API do not use the ahash_request_set_virt fallback path as they cannot use the software fallback.
--- crypto/ahash.c | 3 +++ include/crypto/internal/hash.h | 6 ++++++ 2 files changed, 9 insertions(+)
crypto/ahash.c +3 -0
@@ -350,6 +350,9 @@ static int ahash_do_req_chain(struct ahash_request *req,if (!crypto_ahash_need_fallback (tfm))return -ENOSYS ; +if (crypto_hash_no_export_core (tfm)) +return -ENOSYS ; + {u8 state[HASH_MAX_STATESIZE ];
include/crypto/internal/hash.h +6 -0
@@ -91,6 +91,12 @@ static inline bool crypto_hash_alg_needs_key(struct hash_alg_common *alg) !(alg->base.cra_flags &CRYPTO_ALG_OPTIONAL_KEY ); } +static inline bool crypto_hash_no_export_core (struct crypto_ahash *tfm) +{ +return crypto_hash_alg_common (tfm)->base.cra_flags & +CRYPTO_AHASH_ALG_NO_EXPORT_CORE ; +} +int crypto_grab_ahash (struct crypto_ahash_spawn *spawn,struct crypto_instance *inst,const char *name,u32 type,u32 mask);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 325/627 crypto: qat - restore ASYM service support for GEN6 devices
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Kumar Chakraborty <[email protected]>
[ Upstream commit 4e55a929ff4d973206879a997a47a188353b3cd6 ]
Support for asymmetric crypto services was not included in the qat_6xxx by explicitly setting the asymmetric capabilities to 0 to allow for additional testing.
Enable asymmetric crypto services on QAT GEN6 devices by setting the appropriate capability flags.
--- drivers/crypto/intel/qat/qat_6xxx/adf_6xxx_hw_data.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/crypto/intel/qat/qat_6xxx/adf_6xxx_hw_data.c +9 -1
@@ -627,7 +627,15 @@ static u32 get_accel_cap(struct adf_accel_dev *accel_dev) capabilities_sym &= ~ICP_ACCEL_CAPABILITIES_CIPHER ; } - capabilities_asym =0 ; + capabilities_asym =ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC | +ICP_ACCEL_CAPABILITIES_SM2 | +ICP_ACCEL_CAPABILITIES_ECEDMONT ; + +if (fusectl1 &ICP_ACCEL_GEN6_MASK_PKE_SLICE ) { + capabilities_asym &= ~ICP_ACCEL_CAPABILITIES_CRYPTO_ASYMMETRIC ; + capabilities_asym &= ~ICP_ACCEL_CAPABILITIES_SM2 ; + capabilities_asym &= ~ICP_ACCEL_CAPABILITIES_ECEDMONT ; + } capabilities_dc =ICP_ACCEL_CAPABILITIES_COMPRESSION | ICP_ACCEL_CAPABILITIES_LZ4_COMPRESSION |
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 326/627 PCI: endpoint: pci-epf-vntb: Return -ENOENT if pci_epc_get_next_free_bar() fails
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jerome Brunet <[email protected]>
[ Upstream commit 7ea488cce73263231662e426639dd3e836537068 ]
According the function documentation of epf_ntb_init_epc_bar(), the function should return an error code on error. However, it returns -1 when no BAR is available i.e., when pci_epc_get_next_free_bar() fails.
Return -ENOENT instead.
--- drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/endpoint/functions/pci-epf-vntb.c +1 -1
@@ -680,7 +680,7 @@ static int epf_ntb_init_epc_bar(struct epf_ntb *ntb) barno =pci_epc_get_next_free_bar (epc_features, barno);if (barno <0 ) {dev_err (dev,"Fail to get NTB function BAR\n" ); -return barno; +return -ENOENT ; } ntb->epf_ntb_bar[bar] = barno; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 327/627 pinctrl: sunxi: Fix memory leak on krealloc failure
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit e3507c56cbb208d4f160942748c527ef6a528ba1 ]
In sunxi_pctrl_dt_node_to_map(), when krealloc() fails to resize the pinctrl_map array, the function returns -ENOMEM directly without freeing the previously allocated *map buffer. This results in a memory leak of the original kmalloc_array allocation.
--- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/pinctrl/sunxi/pinctrl-sunxi.c +8 -3
@@ -408,6 +408,7 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,const char *function, *pin_prop;const char *group;int ret, npins, nmaps, configlen =0 , i =0 ; +struct pinctrl_map *new_map; *map =NULL ; *num_maps =0 ;
@@ -482,9 +483,13 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,* We know have the number of maps we need, we can resize our * map array */ - *map =krealloc (*map, i *sizeof (struct pinctrl_map ),GFP_KERNEL ); -if (!*map) -return -ENOMEM ; + new_map =krealloc (*map, i *sizeof (struct pinctrl_map ),GFP_KERNEL ); +if (!new_map) { + ret = -ENOMEM ; + goto err_free_map; + } + + *map = new_map;return 0 ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 328/627 pinctrl: berlin: fix memory leak in berlin_pinctrl_build_state()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yuan Chen <[email protected]>
[ Upstream commit 8f6f303551100291bf2c1e1ccc66b758fffb1168 ]
In the original implementation, krealloc() failure handling incorrectly assigned the original memory pointer to NULL after kfree(), causing a memory leak when reallocation failed.
--- drivers/pinctrl/berlin/berlin.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/pinctrl/berlin/berlin.c +6 -2
@@ -204,6 +204,7 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)const struct berlin_desc_group *desc_group;const struct berlin_desc_function *desc_function;int i, max_functions =0 ; +struct pinfunction *new_functions; pctrl->nfunctions =0 ;
@@ -229,12 +230,15 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) } } - pctrl->functions =krealloc (pctrl->functions, + new_functions =krealloc (pctrl->functions, pctrl->nfunctions *sizeof (*pctrl->functions),GFP_KERNEL ); -if (!pctrl->functions) +if (!new_functions) { +kfree (pctrl->functions);return -ENOMEM ; + } + pctrl->functions = new_functions;/* map functions to theirs groups */ for (i =0 ; i < pctrl->desc->ngroups; i++) { desc_group = pctrl->desc->groups + i;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 329/627 pinctrl: canaan: k230: add NULL check in DT parse
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ze Huang <[email protected]>
[ Upstream commit 65bd0be486390fc12a84eafaad78758c5e5a55e6 ]
Add a NULL check for the return value of of_get_property() when retrieving the "pinmux" property in the group parser. This avoids a potential NULL pointer dereference if the property is missing from the device tree node.
Also fix a typo ("sintenel") in the device ID match table comment, correcting it to "sentinel".
--- drivers/pinctrl/pinctrl-k230.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-k230.c +5 -1
@@ -477,6 +477,10 @@ static int k230_pinctrl_parse_groups(struct device_node *np, grp->name = np->name; list =of_get_property (np,"pinmux" , &size); +if (!list) { +dev_err (dev,"failed to get pinmux property\n" ); +return -EINVAL ; + } size /=sizeof (*list); grp->num_pins = size;
@@ -623,7 +627,7 @@ static int k230_pinctrl_probe(struct platform_device *pdev)static const struct of_device_id k230_dt_ids[] = { { .compatible ="canaan,k230-pinctrl" , }, - {/* sintenel */ } + {/* sentinel */ } };MODULE_DEVICE_TABLE (of, k230_dt_ids);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 330/627 pinctrl: canaan: k230: Fix order of DT parse and pinctrl register
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ze Huang <[email protected]>
[ Upstream commit d94a32ac688f953dc9a9f12b5b4139ecad841bbb ]
Move DT parse before pinctrl register. This ensures that device tree parsing is done before calling devm_pinctrl_register() to prevent using uninitialized pin resources.
--- drivers/pinctrl/pinctrl-k230.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/pinctrl/pinctrl-k230.c +5 -2
@@ -590,6 +590,7 @@ static int k230_pinctrl_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct k230_pinctrl *info;struct pinctrl_desc *pctl; +int ret; info =devm_kzalloc (dev,sizeof (*info),GFP_KERNEL );if (!info)
@@ -615,13 +616,15 @@ static int k230_pinctrl_probe(struct platform_device *pdev)return dev_err_probe (dev,PTR_ERR (info->regmap_base),"failed to init regmap\n" ); + ret =k230_pinctrl_parse_dt (pdev, info); +if (ret) +return ret; + info->pctl_dev =devm_pinctrl_register (dev, pctl, info);if (IS_ERR (info->pctl_dev))return dev_err_probe (dev,PTR_ERR (info->pctl_dev),"devm_pinctrl_register failed\n" ); -k230_pinctrl_parse_dt (pdev, info); -return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 331/627 PCI: Adjust the position of reading the Link Control 2 register
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jiwei Sun <[email protected]>
[ Upstream commit b85af48de3ece4e5bbdb2248a5360a409991cf67 ]
In a89c82249c37 ("PCI: Work around PCIe link training failures"), if the speed limit is set to 2.5 GT/s and the retraining is successful, an attempt will be made to lift the speed limit. One condition for lifting the speed limit is to check whether the link speed field of the Link Control 2 register is PCI_EXP_LNKCTL2_TLS_2_5GT.
However, since de9a6c8d5dbf ("PCI/bwctrl: Add pcie_set_target_speed() to set PCIe Link Speed"), the lnkctl2 local variable does not undergo any changes during the speed limit setting and retraining process. As a result, the code intended to lift the speed limit is not executed.
To address this issue, adjust the position of the Link Control 2 register read operation in the code and place it before its use.
--- drivers/pci/quirks.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/pci/quirks.c +4 -2
@@ -105,13 +105,13 @@ int pcie_failed_link_retrain(struct pci_dev *dev) !pcie_cap_has_lnkctl2(dev) || !dev->link_active_reporting)return ret; -pcie_capability_read_word (dev,PCI_EXP_LNKCTL2 , &lnkctl2);pcie_capability_read_word (dev,PCI_EXP_LNKSTA , &lnksta);if (!(lnksta &PCI_EXP_LNKSTA_DLLLA ) &&pcie_lbms_seen (dev, lnksta)) { -u16 oldlnkctl2 = lnkctl2; +u16 oldlnkctl2;pci_info (dev,"broken device, retraining non-functional downstream link at 2.5GT/s\n" ); +pcie_capability_read_word (dev,PCI_EXP_LNKCTL2 , &oldlnkctl2); ret =pcie_set_target_speed (dev,PCIE_SPEED_2_5GT , false);if (ret) {pci_info (dev,"retraining failed\n" );
@@ -123,6 +123,8 @@ int pcie_failed_link_retrain(struct pci_dev *dev)pcie_capability_read_word (dev,PCI_EXP_LNKSTA , &lnksta); } +pcie_capability_read_word (dev,PCI_EXP_LNKCTL2 , &lnkctl2); +if ((lnksta &PCI_EXP_LNKSTA_DLLLA ) && (lnkctl2 &PCI_EXP_LNKCTL2_TLS ) ==PCI_EXP_LNKCTL2_TLS_2_5GT &&pci_match_id (ids, dev)) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 332/627 PCI: Rename PCIE_RESET_CONFIG_DEVICE_WAIT_MS to PCIE_RESET_CONFIG_WAIT_MS
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 817f989700fddefa56e5e443e7d138018ca6709d ]
Rename PCIE_RESET_CONFIG_DEVICE_WAIT_MS to PCIE_RESET_CONFIG_WAIT_MS.
Stable-dep-of: c7eb9c5e1498 ("PCI: dw-rockchip: Wait PCIE_RESET_CONFIG_WAIT_MS after link-up IRQ")
--- drivers/pci/controller/plda/pcie-starfive.c | 2 +- drivers/pci/pci.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/pci/controller/plda/pcie-starfive.c +1 -1
@@ -368,7 +368,7 @@ static int starfive_pcie_host_init(struct plda_pcie_rp *plda)* of 100ms following exit from a conventional reset before * sending a configuration request to the device. */ -msleep (PCIE_RESET_CONFIG_DEVICE_WAIT_MS ); +msleep (PCIE_RESET_CONFIG_WAIT_MS );if (starfive_pcie_host_wait_for_link (pcie))dev_info (dev,"port link down\n" );
drivers/pci/pci.h +1 -1
@@ -61,7 +61,7 @@ struct pcie_tlp_log;* completes before sending a Configuration Request to the device * immediately below that Port." */ -#define PCIE_RESET_CONFIG_DEVICE_WAIT_MS 100 +#define PCIE_RESET_CONFIG_WAIT_MS 100/* Message Routing (r[2:0]); PCIe r6.0, sec 2.2.8 */ #define PCIE_MSG_TYPE_R_RC 0
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 333/627 PCI: dw-rockchip: Wait PCIE_RESET_CONFIG_WAIT_MS after link-up IRQ
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit c7eb9c5e1498882951b7583c56add0b77bfc162e ]
Per PCIe r6.0, sec 6.6.1, software must generally wait a minimum of 100ms (PCIE_RESET_CONFIG_WAIT_MS) after Link training completes before sending a Configuration Request.
Prior to ec9fd499b9c6 ("PCI: dw-rockchip: Don't wait for link since we can detect Link Up"), dw-rockchip used dw_pcie_wait_for_link(), which waited between 0 and 90ms after the link came up before we enumerate the bus, and this was apparently enough for most devices.
After ec9fd499b9c6, rockchip_pcie_rc_sys_irq_thread() started enumeration immediately when handling the link-up IRQ, and devices (e.g., Laszlo Fiat's PLEXTOR PX-256M8PeGN NVMe SSD) may not be ready to handle config requests yet.
Delay PCIE_RESET_CONFIG_WAIT_MS after the link-up IRQ before starting enumeration.
--- drivers/pci/controller/dwc/pcie-dw-rockchip.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pcie-dw-rockchip.c +1 -0
@@ -458,6 +458,7 @@ static irqreturn_t rockchip_pcie_rc_sys_irq_thread(int irq, void *arg)if (reg &PCIE_RDLH_LINK_UP_CHGED ) {if (rockchip_pcie_link_up (pci)) { +msleep (PCIE_RESET_CONFIG_WAIT_MS );dev_dbg (dev,"Received Link up event. Starting enumeration!\n" );/* Rescan the bus to enumerate endpoint devices */ pci_lock_rescan_remove ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 334/627 PCI: qcom: Wait PCIE_RESET_CONFIG_WAIT_MS after link-up IRQ
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Niklas Cassel <[email protected]>
[ Upstream commit 15b6b243cc2b1017cf89e2477aa0b4e1a306a82a ]
Per PCIe r6.0, sec 6.6.1, software must generally wait a minimum of 100ms (PCIE_RESET_CONFIG_WAIT_MS) after Link training completes before sending a Configuration Request.
Prior to 36971d6c5a9a ("PCI: qcom: Don't wait for link if we can detect Link Up"), qcom used dw_pcie_wait_for_link(), which waited between 0 and 90ms after the link came up before we enumerate the bus, and this was apparently enough for most devices.
After 36971d6c5a9a, qcom_pcie_global_irq_thread() started enumeration immediately when handling the link-up IRQ, and devices (e.g., Laszlo Fiat's PLEXTOR PX-256M8PeGN NVMe SSD) may not be ready to handle config requests yet.
Delay PCIE_RESET_CONFIG_WAIT_MS after the link-up IRQ before starting enumeration.
--- drivers/pci/controller/dwc/pcie-qcom.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/controller/dwc/pcie-qcom.c +1 -0
@@ -1564,6 +1564,7 @@ static irqreturn_t qcom_pcie_global_irq_thread(int irq, void *data)writel_relaxed (status, pcie->parf +PARF_INT_ALL_CLEAR );if (FIELD_GET (PARF_INT_ALL_LINK_UP , status)) { +msleep (PCIE_RESET_CONFIG_WAIT_MS );dev_dbg (dev,"Received Link up event. Starting enumeration!\n" );/* Rescan the bus to enumerate endpoint devices */ pci_lock_rescan_remove ();
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 335/627 soundwire: Correct some property names
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Charles Keepax <[email protected]>
[ Upstream commit ae6a0f5b8a5b0ca2e4bf1c0380267ad83aca8401 ]
The DisCo properties should be mipi-sdw-paging-supported and mipi-sdw-bank-delay-supported, with an 'ed' on the end. Correct the property names used in sdw_slave_read_prop().
The internal flag bank_delay_support is currently unimplemented, so that being read wrong does not currently affect anything. The two existing users for this helper and the paging_support flag rt1320-sdw.c and rt721-sdca-sdw.c both manually set the flag in their slave properties, thus are not affected by this bug either.
--- drivers/soundwire/mipi_disco.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/soundwire/mipi_disco.c +2 -2
@@ -451,10 +451,10 @@ int sdw_slave_read_prop(struct sdw_slave *slave) "mipi-sdw-highPHY-capable"); prop->paging_support =mipi_device_property_read_bool (dev, -"mipi-sdw-paging-support" ); +"mipi-sdw-paging-supported" ); prop->bank_delay_support =mipi_device_property_read_bool (dev, -"mipi-sdw-bank-delay-support" ); +"mipi-sdw-bank-delay-supported" );device_property_read_u32 (dev,"mipi-sdw-port15-read-behavior" , &prop->p15_behave);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 336/627 dmaengine: mmp: Fix again Wvoid-pointer-to-enum-cast warning
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Krzysztof Kozlowski <[email protected]>
[ Upstream commit a0b1589b62e2fcfb112996e0f4d5593bd2edf069 ]
This was fixed and re-introduced. 'type' is an enum, thus cast of pointer on 64-bit compile test with W=1 causes:
mmp_tdma.c:644:9: error: cast to smaller integer type 'enum mmp_tdma_type' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
--- drivers/dma/mmp_tdma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/mmp_tdma.c +1 -1
@@ -641,7 +641,7 @@ static int mmp_tdma_probe(struct platform_device *pdev)int chan_num =TDMA_CHANNEL_NUM ;struct gen_pool *pool =NULL ; - type = (enum mmp_tdma_type )device_get_match_data (&pdev->dev); + type = (kernel_ulong_t )device_get_match_data (&pdev->dev);/* always have couple channels */ tdev =devm_kzalloc (&pdev->dev,sizeof (*tdev),GFP_KERNEL );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 337/627 soundwire: debugfs: move debug statement outside of error handling
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rodrigo Gobbi <[email protected]>
[ Upstream commit 06f77ff9d852c9f2764659ea81489364d8a69a9c ]
The start_t and finish_t variables are not properly initialized if errors happens over request_firmware actions.
This was also detected by smatch:
drivers/soundwire/debugfs.c:301 cmd_go() error: uninitialized symbol 'finish_t'. drivers/soundwire/debugfs.c:301 cmd_go() error: uninitialized symbol 'start_t'.
Move the debug statement outside of firmware error handling.
--- drivers/soundwire/debugfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/soundwire/debugfs.c +3 -3
@@ -291,6 +291,9 @@ static int cmd_go(void *data, u64 value) finish_t =ktime_get (); +dev_dbg (&slave->dev,"command completed, num_byte %zu status %d, time %lld ms\n" , + num_bytes, ret,div_u64 (finish_t - start_t,NSEC_PER_MSEC )); + out:if (fw)release_firmware (fw);
@@ -298,9 +301,6 @@ static int cmd_go(void *data, u64 value)pm_runtime_mark_last_busy (&slave->dev);pm_runtime_put (&slave->dev); -dev_dbg (&slave->dev,"command completed, num_byte %zu status %d, time %lld ms\n" , - num_bytes, ret,div_u64 (finish_t - start_t,NSEC_PER_MSEC )); -return ret; } DEFINE_DEBUGFS_ATTRIBUTE(cmd_go_fops, NULL,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 338/627 phy: qualcomm: phy-qcom-eusb2-repeater: Dont zero-out registers
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luca Weiss <[email protected]>
[ Upstream commit 31bc94de76026c527f82c238f414539a14f0f3e6 ]
Zeroing out registers does not happen in the downstream kernel, and will "tune" the repeater in surely unexpected ways since most registers don't have a reset value of 0x0.
Stop doing that and instead just set the registers that are in the init sequence (though long term I don't think there's actually PMIC-specific init sequences, there's board specific tuning, but that's a story for another day).
--- .../phy/qualcomm/phy-qcom-eusb2-repeater.c | 87 +++++++------------ 1 file changed, 32 insertions(+), 55 deletions(-)
drivers/phy/qualcomm/phy-qcom-eusb2-repeater.c +32 -55
@@ -37,32 +37,13 @@#define EUSB2_TUNE_EUSB_EQU 0x5A#define EUSB2_TUNE_EUSB_HS_COMP_CUR 0x5B -enum eusb2_reg_layout { -TUNE_EUSB_HS_COMP_CUR , -TUNE_EUSB_EQU , -TUNE_EUSB_SLEW , -TUNE_USB2_HS_COMP_CUR , -TUNE_USB2_PREEM , -TUNE_USB2_EQU , -TUNE_USB2_SLEW , -TUNE_SQUELCH_U , -TUNE_HSDISC , -TUNE_RES_FSDIF , -TUNE_IUSB2 , -TUNE_USB2_CROSSOVER , -NUM_TUNE_FIELDS , - -FORCE_VAL_5 =NUM_TUNE_FIELDS , -FORCE_EN_5 , - -EN_CTL1 , - -RPTR_STATUS , -LAYOUT_SIZE , +struct eusb2_repeater_init_tbl_reg { +unsigned int reg; +unsigned int value; };struct eusb2_repeater_cfg { -const u32 *init_tbl; +const struct eusb2_repeater_init_tbl_reg *init_tbl;int init_tbl_num;const char *const *vreg_list;int num_vregs;
@@ -82,16 +63,16 @@ static const char * const pm8550b_vreg_l[] = { "vdd18", "vdd3", }; -static const u32 pm8550b_init_tbl[NUM_TUNE_FIELDS ] = { - [TUNE_IUSB2 ] =0x8 , - [TUNE_SQUELCH_U ] =0x3 , - [TUNE_USB2_PREEM ] =0x5 , +static const struct eusb2_repeater_init_tbl_reg pm8550b_init_tbl[] = { + {EUSB2_TUNE_IUSB2 ,0x8 }, + {EUSB2_TUNE_SQUELCH_U ,0x3 }, + {EUSB2_TUNE_USB2_PREEM ,0x5 }, }; -static const u32 smb2360_init_tbl[NUM_TUNE_FIELDS ] = { - [TUNE_IUSB2 ] =0x5 , - [TUNE_SQUELCH_U ] =0x3 , - [TUNE_USB2_PREEM ] =0x2 , +static const struct eusb2_repeater_init_tbl_reg smb2360_init_tbl[] = { + {EUSB2_TUNE_IUSB2 ,0x5 }, + {EUSB2_TUNE_SQUELCH_U ,0x3 }, + {EUSB2_TUNE_USB2_PREEM ,0x2 }, };static const struct eusb2_repeater_cfg pm8550b_eusb2_cfg = {
@@ -129,17 +110,10 @@ static int eusb2_repeater_init(struct phy *phy)struct eusb2_repeater *rptr =phy_get_drvdata (phy);struct device_node *np = rptr->dev->of_node;struct regmap *regmap = rptr->regmap; -const u32 *init_tbl = rptr->cfg->init_tbl; -u8 tune_usb2_preem = init_tbl[TUNE_USB2_PREEM ]; -u8 tune_hsdisc = init_tbl[TUNE_HSDISC ]; -u8 tune_iusb2 = init_tbl[TUNE_IUSB2 ];u32 base = rptr->base; -u32 val; +u32 poll_val;int ret; - -of_property_read_u8 (np,"qcom,tune-usb2-amplitude" , &tune_iusb2); -of_property_read_u8 (np,"qcom,tune-usb2-disc-thres" , &tune_hsdisc); -of_property_read_u8 (np,"qcom,tune-usb2-preem" , &tune_usb2_preem); +u8 val; ret =regulator_bulk_enable (rptr->cfg->num_vregs, rptr->vregs);if (ret)
@@ -147,21 +121,24 @@ static int eusb2_repeater_init(struct phy *phy)regmap_write (regmap, base +EUSB2_EN_CTL1 ,EUSB2_RPTR_EN ); -regmap_write (regmap, base +EUSB2_TUNE_EUSB_HS_COMP_CUR , init_tbl[TUNE_EUSB_HS_COMP_CUR ]); -regmap_write (regmap, base +EUSB2_TUNE_EUSB_EQU , init_tbl[TUNE_EUSB_EQU ]); -regmap_write (regmap, base +EUSB2_TUNE_EUSB_SLEW , init_tbl[TUNE_EUSB_SLEW ]); -regmap_write (regmap, base +EUSB2_TUNE_USB2_HS_COMP_CUR , init_tbl[TUNE_USB2_HS_COMP_CUR ]); -regmap_write (regmap, base +EUSB2_TUNE_USB2_EQU , init_tbl[TUNE_USB2_EQU ]); -regmap_write (regmap, base +EUSB2_TUNE_USB2_SLEW , init_tbl[TUNE_USB2_SLEW ]); -regmap_write (regmap, base +EUSB2_TUNE_SQUELCH_U , init_tbl[TUNE_SQUELCH_U ]); -regmap_write (regmap, base +EUSB2_TUNE_RES_FSDIF , init_tbl[TUNE_RES_FSDIF ]); -regmap_write (regmap, base +EUSB2_TUNE_USB2_CROSSOVER , init_tbl[TUNE_USB2_CROSSOVER ]); - -regmap_write (regmap, base +EUSB2_TUNE_USB2_PREEM , tune_usb2_preem); -regmap_write (regmap, base +EUSB2_TUNE_HSDISC , tune_hsdisc); -regmap_write (regmap, base +EUSB2_TUNE_IUSB2 , tune_iusb2); - - ret =regmap_read_poll_timeout (regmap, base +EUSB2_RPTR_STATUS , val, val &RPTR_OK ,10 ,5 ); +/* Write registers from init table */ +for (int i =0 ; i < rptr->cfg->init_tbl_num; i++) +regmap_write (regmap, base + rptr->cfg->init_tbl[i].reg, + rptr->cfg->init_tbl[i].value); + +/* Override registers from devicetree values */ +if (!of_property_read_u8 (np,"qcom,tune-usb2-amplitude" , &val)) +regmap_write (regmap, base +EUSB2_TUNE_USB2_PREEM , val); + +if (!of_property_read_u8 (np,"qcom,tune-usb2-disc-thres" , &val)) +regmap_write (regmap, base +EUSB2_TUNE_HSDISC , val); + +if (!of_property_read_u8 (np,"qcom,tune-usb2-preem" , &val)) +regmap_write (regmap, base +EUSB2_TUNE_IUSB2 , val); + +/* Wait for status OK */ + ret =regmap_read_poll_timeout (regmap, base +EUSB2_RPTR_STATUS , poll_val, + poll_val &RPTR_OK ,10 ,5 );if (ret)dev_err (rptr->dev,"initialization timed-out\n" );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 339/627 fanotify: sanitize handle_type values when reporting fid
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amir Goldstein <[email protected]>
[ Upstream commit 8631e01c2c5d1fe6705bcc0d733a0b7a17d3daac ]
Unlike file_handle, type and len of struct fanotify_fh are u8. Traditionally, filesystem return handle_type < 0xff, but there is no enforecement for that in vfs.
Add a sanity check in fanotify to avoid truncating handle_type if its value is > 0xff.
--- fs/notify/fanotify/fanotify.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/notify/fanotify/fanotify.c +7 -1
@@ -454,7 +454,13 @@ static int fanotify_encode_fh(struct fanotify_fh *fh, struct inode *inode, dwords = fh_len >>2 ; type =exportfs_encode_fid (inode, buf, &dwords); err = -EINVAL ; -if (type <=0 || type ==FILEID_INVALID || fh_len != dwords <<2 ) +/* +* Unlike file_handle, type and len of struct fanotify_fh are u8. +* Traditionally, filesystem return handle_type < 0xff, but there +* is no enforecement for that in vfs. +*/ +BUILD_BUG_ON (MAX_HANDLE_SZ >0xff ||FILEID_INVALID >0xff ); +if (type <=0 || type >=FILEID_INVALID || fh_len != dwords <<2 ) goto out_err; fh->type = type;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 340/627 clk: clk-axi-clkgen: fix fpfd_max frequency for zynq
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nuno Sá <[email protected]>
[ Upstream commit ce8a9096699500e2c5bca09dde27b16edda5f636 ]
The fpfd_max frequency should be set to 450 MHz instead of 300 MHz. Well, it actually depends on the platform speed grade but we are being conservative for ultrascale so let's be consistent. In a following change we will set these limits at runtime.
--- drivers/clk/clk-axi-clkgen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clk-axi-clkgen.c +1 -1
@@ -118,7 +118,7 @@ static const struct axi_clkgen_limits axi_clkgen_zynqmp_default_limits = {static const struct axi_clkgen_limits axi_clkgen_zynq_default_limits = { .fpfd_min =10000 , - .fpfd_max =300000 , + .fpfd_max =450000 , .fvco_min =600000 , .fvco_max =1200000 , };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 341/627 RDMA/ipoib: Use parent rdma device net namespace
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Bloch <[email protected]>
[ Upstream commit f1208b05574f63c52e88109d8c75afdf4fc6bf42 ]
Use the net namespace of the underlying rdma device. After honoring the rdma device's namespace, the ipoib netdev now also runs in the same net namespace of the rdma device.
Add an API to read the net namespace of the rdma device so that ULP such as IPoIB can use it to initialize its netdev.
Stable-dep-of: f458ccd2aa2c ("RDMA/uverbs: Check CAP_NET_RAW in user namespace for flow create")
--- drivers/infiniband/ulp/ipoib/ipoib_main.c | 2 ++ include/rdma/ib_verbs.h | 5 +++++ 2 files changed, 7 insertions(+)
drivers/infiniband/ulp/ipoib/ipoib_main.c +2 -0
@@ -2577,6 +2577,8 @@ static struct net_device *ipoib_add_port(const char *format, ndev->rtnl_link_ops =ipoib_get_link_ops (); +dev_net_set (ndev,rdma_dev_net (hca)); + result =register_netdev (ndev);if (result) { pr_warn("%s: couldn't register ipoib port %d; error %d\n",
include/rdma/ib_verbs.h +5 -0
@@ -4855,6 +4855,11 @@ static inline int ibdev_to_node(struct ib_device *ibdev)bool rdma_dev_access_netns (const struct ib_device *device,const struct net *net); +static inline struct net *rdma_dev_net (struct ib_device *device) +{ +return read_pnet (&device->coredev.rdma_net); +} +#define IB_ROCE_UDP_ENCAP_VALID_PORT_MIN (0xC000)#define IB_ROCE_UDP_ENCAP_VALID_PORT_MAX (0xFFFF)#define IB_GRH_FLOWLABEL_MASK (0x000FFFFF)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 342/627 RDMA/uverbs: Check CAP_NET_RAW in user namespace for flow create
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit f458ccd2aa2c5a6f0129a9b1548f2825071fdc6b ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to create the flow resource.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/core/device.c | 27 ++++++++++++++++++++++++++ drivers/infiniband/core/rdma_core.c | 29 ++++++++++++++++++++++++++++ drivers/infiniband/core/uverbs_cmd.c | 2 +- include/rdma/ib_verbs.h | 3 +++ 4 files changed, 60 insertions(+), 1 deletion(-)
drivers/infiniband/core/device.c +27 -0
@@ -145,6 +145,33 @@ bool rdma_dev_access_netns(const struct ib_device *dev, const struct net *net) }EXPORT_SYMBOL (rdma_dev_access_netns); +/** +* rdma_dev_has_raw_cap() - Returns whether a specified rdma device has +* CAP_NET_RAW capability or not. +* +* @dev: Pointer to rdma device whose capability to be checked +* +* Returns true if a rdma device's owning user namespace has CAP_NET_RAW +* capability, otherwise false. When rdma subsystem is in legacy shared network, +* namespace mode, the default net namespace is considered. +*/ +bool rdma_dev_has_raw_cap (const struct ib_device *dev) +{ +const struct net *net; + +/* Network namespace is the resource whose user namespace +* to be considered. When in shared mode, there is no reliable +* network namespace resource, so consider the default net namespace. +*/ +if (ib_devices_shared_netns) + net = &init_net; +else + net =read_pnet (&dev->coredev.rdma_net); + +return ns_capable (net->user_ns,CAP_NET_RAW ); +} +EXPORT_SYMBOL (rdma_dev_has_raw_cap); +/* * xarray has this behavior where it won't iterate over NULL values stored in * allocated arrays. So we need our own iterator to see all values stored in
drivers/infiniband/core/rdma_core.c +29 -0
@@ -1019,3 +1019,32 @@ void uverbs_finalize_object(struct ib_uobject *uobj,WARN_ON (true); } } + +/** +* rdma_uattrs_has_raw_cap() - Returns whether a rdma device linked to the +* uverbs attributes file has CAP_NET_RAW +* capability or not. +* +* @attrs: Pointer to uverbs attributes +* +* Returns true if a rdma device's owning user namespace has CAP_NET_RAW +* capability, otherwise false. +*/ +bool rdma_uattrs_has_raw_cap (const struct uverbs_attr_bundle *attrs) +{ +struct ib_uverbs_file *ufile = attrs->ufile; +struct ib_ucontext *ucontext; +bool has_cap = false; +int srcu_key; + + srcu_key =srcu_read_lock (&ufile->device->disassociate_srcu); + ucontext =ib_uverbs_get_ucontext_file (ufile); +if (IS_ERR (ucontext)) + goto out; + has_cap =rdma_dev_has_raw_cap (ucontext->device); + +out: +srcu_read_unlock (&ufile->device->disassociate_srcu, srcu_key); +return has_cap; +} +EXPORT_SYMBOL (rdma_uattrs_has_raw_cap);
drivers/infiniband/core/uverbs_cmd.c +1 -1
@@ -3225,7 +3225,7 @@ static int ib_uverbs_ex_create_flow(struct uverbs_attr_bundle *attrs)if (cmd.comp_mask)return -EINVAL ; -if (!capable (CAP_NET_RAW )) +if (!rdma_uattrs_has_raw_cap (attrs))return -EPERM ;if (cmd.flow_attr.flags >=IB_FLOW_ATTR_FLAGS_RESERVED )
include/rdma/ib_verbs.h +3 -0
@@ -4801,6 +4801,8 @@ static inline int uverbs_destroy_def_handler(struct uverbs_attr_bundle *attrs) }#endif +bool rdma_uattrs_has_raw_cap (const struct uverbs_attr_bundle *attrs); + struct net_device *rdma_alloc_netdev(struct ib_device *device, u32 port_num, enum rdma_netdev_t type, const char *name, unsigned char name_assign_type,
@@ -4855,6 +4857,7 @@ static inline int ibdev_to_node(struct ib_device *ibdev)bool rdma_dev_access_netns (const struct ib_device *device,const struct net *net); +bool rdma_dev_has_raw_cap (const struct ib_device *dev);static inline struct net *rdma_dev_net (struct ib_device *device) {return read_pnet (&device->coredev.rdma_net);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 343/627 RDMA/mlx5: Check CAP_NET_RAW in user namespace for flow create
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit 95a89ec304c38f7447cdbf271f2d1cbad4c3bf81 ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to create the flow.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/hw/mlx5/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/fs.c +1 -1
@@ -2458,7 +2458,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(struct mlx5_ib_dev *dev;u32 flags; -if (!capable (CAP_NET_RAW )) +if (!rdma_uattrs_has_raw_cap (attrs))return -EPERM ; fs_matcher = uverbs_attr_get_obj(attrs,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 344/627 RDMA/mlx5: Check CAP_NET_RAW in user namespace for anchor create
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit 14957e8125e767bfd40a3ac61b1d6b8e62ee0a98 ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to create the anchor.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/hw/mlx5/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/fs.c +1 -1
@@ -2989,7 +2989,7 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_STEERING_ANCHOR_CREATE)(u32 ft_id;int err; -if (!capable (CAP_NET_RAW )) +if (!rdma_dev_has_raw_cap (&dev->ib_dev))return -EPERM ; err = uverbs_get_const(&ib_uapi_ft_type, attrs,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 345/627 RDMA/uverbs: Check CAP_NET_RAW in user namespace for QP create
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit 0498c2d9984ed2ad75b1cd5ba6abfa1226742df5 ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to create the QP.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/core/uverbs_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_cmd.c +1 -1
@@ -1451,7 +1451,7 @@ static int create_qp(struct uverbs_attr_bundle *attrs, }if (attr.create_flags &IB_QP_CREATE_SOURCE_QPN ) { -if (!capable (CAP_NET_RAW )) { +if (!rdma_uattrs_has_raw_cap (attrs)) { ret = -EPERM ; goto err_put; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 346/627 RDMA/uverbs: Check CAP_NET_RAW in user namespace for RAW QP create
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit a6dca091ba7646ff5304af660c94fa51b6696476 ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to create the QP.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/core/uverbs_std_types_qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/uverbs_std_types_qp.c +1 -1
@@ -133,7 +133,7 @@ static int UVERBS_HANDLER(UVERBS_METHOD_QP_CREATE)( device = xrcd->device;break ;case IB_UVERBS_QPT_RAW_PACKET : -if (!capable (CAP_NET_RAW )) +if (!rdma_uattrs_has_raw_cap (attrs))return -EPERM ; fallthrough;case IB_UVERBS_QPT_RC :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 347/627 leds: tps6131x: Add V4L2_FLASH_LED_CLASS dependency
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit c3c38e80016548685e439b23999b4f0bd0ad7e05 ]
This driver can optionally use the v4l2_flash infrastructure, but fails to link built=in if that is in a loadable module:
ld.lld-21: error: undefined symbol: v4l2_flash_release
Quoted 1 line
Quoted 1 line
Quoted 1 line
referenced by leds-tps6131x.c:792 (
drivers/leds/flash/leds-tps6131x.c:792)
Add the usual Kconfig dependency for it, still allowing it to be built when CONFIG_V4L2_FLASH_LED_CLASS is disabled.
--- drivers/leds/flash/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/leds/flash/Kconfig +1 -0
@@ -136,6 +136,7 @@ config LEDS_TPS6131X tristate "LED support for TI TPS6131x flash LED driver" depends on I2C && OF depends on GPIOLIB + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS select REGMAP_I2C help This option enables support for Texas Instruments TPS61310/TPS61311
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 348/627 RDMA/mlx5: Check CAP_NET_RAW in user namespace for devx create
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit bd82467f17e0940c6f6a5396278cda586c9cb6fd ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to create the devx object.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/hw/mlx5/devx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx5/devx.c +1 -1
@@ -159,7 +159,7 @@ int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user, u64 req_ucaps) uctx =MLX5_ADDR_OF (create_uctx_in, in, uctx);if (is_user && (MLX5_CAP_GEN (dev->mdev, uctx_cap) &MLX5_UCTX_CAP_RAW_TX ) && -capable (CAP_NET_RAW )) +rdma_dev_has_raw_cap (&dev->ib_dev)) cap |=MLX5_UCTX_CAP_RAW_TX ; if (is_user && (MLX5_CAP_GEN(dev->mdev, uctx_cap) &
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 349/627 RDMA/nldev: Check CAP_NET_RAW in user namespace for QP modify
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit 28ea058a2979f063d4b756c5d82d885fc16f5ca2 ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails. Due to this when a process is running using Podman, it fails to modify the QP.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/core/nldev.c | 2 +- drivers/infiniband/core/uverbs_cmd.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/core/nldev.c +1 -1
@@ -255,7 +255,7 @@ EXPORT_SYMBOL(rdma_nl_put_driver_u64_hex);bool rdma_nl_get_privileged_qkey (void ) { -return privileged_qkey ||capable (CAP_NET_RAW ); +return privileged_qkey; }EXPORT_SYMBOL (rdma_nl_get_privileged_qkey);
drivers/infiniband/core/uverbs_cmd.c +2 -1
@@ -1877,7 +1877,8 @@ static int modify_qp(struct uverbs_attr_bundle *attrs, attr->path_mig_state = cmd->base.path_mig_state;if (cmd->base.attr_mask &IB_QP_QKEY ) {if (cmd->base.qkey &IB_QP_SET_QKEY && - !rdma_nl_get_privileged_qkey ()) { + !(rdma_nl_get_privileged_qkey () || +rdma_uattrs_has_raw_cap (attrs))) { ret = -EPERM ; goto release_qp; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 350/627 RDMA/counter: Check CAP_NET_RAW check in user namespace for RDMA counters
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Parav Pandit <[email protected]>
[ Upstream commit 449728196d65fce513dbacf4d3696764be1c6524 ]
Currently, the capability check is done in the default init_user_ns user namespace. When a process runs in a non default user namespace, such check fails.
Since the RDMA device is a resource within a network namespace, use the network namespace associated with the RDMA device to determine its owning user namespace.
--- drivers/infiniband/core/counters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/counters.c +1 -1
@@ -461,7 +461,7 @@ static struct ib_qp *rdma_counter_get_qp(struct ib_device *dev, u32 qp_num)return NULL ; qp = container_of(res, struct ib_qp, res); -if (qp->qp_type ==IB_QPT_RAW_PACKET && !capable (CAP_NET_RAW )) +if (qp->qp_type ==IB_QPT_RAW_PACKET && !rdma_dev_has_raw_cap (dev)) goto err;return qp;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 351/627 Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 1db50f7b7a793670adcf062df9ff27798829d963 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/infiniband/hw/erdma/erdma_verbs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/infiniband/hw/erdma/erdma_verbs.c +2 -1
@@ -629,7 +629,8 @@ static struct erdma_mtt *erdma_create_cont_mtt(struct erdma_dev *dev,static void erdma_destroy_mtt_buf_sg (struct erdma_dev *dev,struct erdma_mtt *mtt) { -dma_unmap_sg (&dev->pdev->dev, mtt->sglist, mtt->nsg,DMA_TO_DEVICE ); +dma_unmap_sg (&dev->pdev->dev, mtt->sglist, +DIV_ROUND_UP (mtt->size,PAGE_SIZE ),DMA_TO_DEVICE );vfree (mtt->sglist); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 352/627 leds: pca955x: Avoid potential overflow when filling default_label (take 2)
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
[ Upstream commit 239afba8b9f3b0fcfd464d5ffeaed0ed4441c5a4 ]
GCC compiler v8.5.0 is not happy about printing into a too short buffer (when build with make W=1):
drivers/leds/leds-pca955x.c:696:5: note: 'snprintf' output between 2 and 11 bytes into a destination of size 8
Unfortunately this is a false positive from the old GCC versions, but we may still improve the code by using '%hhu' format specifier and reduce buffer size by 4 bytes.
--- drivers/leds/leds-pca955x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/leds/leds-pca955x.c +2 -2
@@ -587,7 +587,7 @@ static int pca955x_probe(struct i2c_client *client)struct pca955x_platform_data *pdata;bool keep_psc0 = false;bool set_default_label = false; -char default_label[8 ]; +char default_label[4 ];int bit, err, reg; chip =i2c_get_match_data (client);
@@ -693,7 +693,7 @@ static int pca955x_probe(struct i2c_client *client) }if (set_default_label) { -snprintf (default_label,sizeof (default_label),"%u" , i); +snprintf (default_label,sizeof (default_label),"%hhu" , i); init_data.default_label = default_label; }else { init_data.default_label =NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 353/627 gitignore: allow .pylintrc to be tracked
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: WangYuli <[email protected]>
[ Upstream commit 38d573a624a54ccde1384ead8af0780fe4005c2b ]
The .pylintrc file was introduced by commit 02df8e3b333c ("docs: add a .pylintrc file with sys path for docs scripts") to provide Python path configuration for documentation scripts. However, the generic ".*" rule in .gitignore causes this tracked file to be ignored, leading to warnings during kernel builds.
Add !.pylintrc to the exception list to explicitly allow this configuration file to be tracked by git, consistent with other development tool configuration files like .clang-format and .rustfmt.toml.
This resolves the build warning:
.pylintrc: warning: ignored by one of the .gitignore files
--- .gitignore | 1 + 1 file changed, 1 insertion(+)
.gitignore +1 -0
@@ -114,6 +114,7 @@ modules.order !.gitignore !.kunitconfig !.mailmap +!.pylintrc !.rustfmt.toml #
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 354/627 perf tools: Fix use-after-free in help_unknown_cmd()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 1fdf938168c4d26fa279d4f204768690d1f9c4ae ]
Currently perf aborts when it finds an invalid command. I guess it depends on the environment as I have some custom commands in the path.
$ perf bad-command perf: 'bad-command' is not a perf-command. See 'perf --help'. Aborted (core dumped)
It's because the exclude_cmds() in libsubcmd has a use-after-free when it removes some entries. After copying one to another entry, it keeps the pointer in the both position. And the next copy operation will free the later one but it's the same entry in the previous one.
For example, let's say cmds = { A, B, C, D, E } and excludes = { B, E }.
ci cj ei cmds-name excludes
-----------+--------------------
0 0 0 | A B : cmp < 0, ci == cj 1 1 0 | B B : cmp == 0 2 1 1 | C E : cmp < 0, ci != cj
At this point, it frees cmds->names[1] and cmds->names[1] is assigned to cmds->names[2].
3 2 1 | D E : cmp < 0, ci != cj
Now it frees cmds->names[2] but it's the same as cmds->names[1]. So accessing cmds->names[1] will be invalid.
This makes the subcmd tests succeed.
$ perf test subcmd 69: libsubcmd help tests : 69.1: Load subcmd names : Ok 69.2: Uniquify subcmd names : Ok 69.3: Exclude duplicate subcmd names : Ok
--- tools/lib/subcmd/help.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
tools/lib/subcmd/help.c +7 -5
@@ -9,6 +9,7 @@#include <sys/stat.h> #include <unistd.h> #include <dirent.h> +#include <assert.h> #include "subcmd-util.h" #include "help.h" #include "exec-cmd.h"
@@ -82,10 +83,11 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) ci++; cj++; }else { -zfree (&cmds->names[cj]); - cmds->names[cj++] = cmds->names[ci++]; + cmds->names[cj++] = cmds->names[ci]; + cmds->names[ci++] =NULL ; } }else if (cmp ==0 ) { +zfree (&cmds->names[ci]); ci++; ei++; }else if (cmp >0 ) {
@@ -94,12 +96,12 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes) }if (ci != cj) {while (ci < cmds->cnt) { -zfree (&cmds->names[cj]); - cmds->names[cj++] = cmds->names[ci++]; + cmds->names[cj++] = cmds->names[ci]; + cmds->names[ci++] =NULL ; } }for (ci = cj; ci < cmds->cnt; ci++) -zfree (&cmds->names[ci]); +assert (cmds->names[ci] ==NULL ); cmds->cnt = cj; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 355/627 perf dso: Add missed dso__put to dso__load_kcore
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 63a088e999de3f431f87d9a367933da894ddb613 ]
The kcore loading creates a set of list nodes that have reference counted references to maps of the kcore. The list node freeing in the success path wasn't releasing the maps, add the missing puts. It is unclear why this leak was being missed by leak sanitizer.
--- tools/perf/util/symbol.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/symbol.c +1 -0
@@ -1422,6 +1422,7 @@ static int dso__load_kcore(struct dso *dso, struct map *map, goto out_err; } } +map__zput (new_node->map);free (new_node); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 356/627 mtd: spi-nor: spansion: Fixup params->set_4byte_addr_mode for SEMPER
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Takahiro Kuwano <[email protected]>
[ Upstream commit a45ab839f52f3f00ac3dae18a50e902efd216de2 ]
Infineon SEMPER flash family does not support E9h opcode as Exit 4-byte mode (EX4B). Therefore, params->set_4byte_addr_mode is not determined by BFPT parse. Fixup it up by introducing vendor specific EX4B opcode (B8h) and function.
--- drivers/mtd/spi-nor/spansion.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/mtd/spi-nor/spansion.c +31 -0
@@ -17,6 +17,7 @@#define SPINOR_OP_CLSR 0x30/* Clear status register 1 */ #define SPINOR_OP_CLPEF 0x82/* Clear program/erase failure flags */ +#define SPINOR_OP_CYPRESS_EX4B 0xB8/* Exit 4-byte address mode */ #define SPINOR_OP_CYPRESS_DIE_ERASE 0x61/* Chip (die) erase */ #define SPINOR_OP_RD_ANY_REG 0x65/* Read any register */ #define SPINOR_OP_WR_ANY_REG 0x71/* Write any register */
@@ -58,6 +59,13 @@ SPI_MEM_OP_DUMMY(ndummy, 0), \ SPI_MEM_OP_DATA_IN(1, buf, 0)) +#define CYPRESS_NOR_EN4B_EX4B_OP (enable) \ + SPI_MEM_OP(SPI_MEM_OP_CMD(enable ? SPINOR_OP_EN4B : \ + SPINOR_OP_CYPRESS_EX4B, 0), \ + SPI_MEM_OP_NO_ADDR, \ + SPI_MEM_OP_NO_DUMMY, \ + SPI_MEM_OP_NO_DATA) +#define SPANSION_OP (opcode) \ SPI_MEM_OP(SPI_MEM_OP_CMD(opcode, 0), \ SPI_MEM_OP_NO_ADDR, \
@@ -356,6 +364,20 @@ static int cypress_nor_quad_enable_volatile(struct spi_nor *nor)return 0 ; } +static int cypress_nor_set_4byte_addr_mode (struct spi_nor *nor,bool enable) +{ +int ret; +struct spi_mem_op op =CYPRESS_NOR_EN4B_EX4B_OP (enable); + +spi_nor_spimem_setup_op (nor, &op, nor->reg_proto); + + ret =spi_mem_exec_op (nor->spimem, &op); +if (ret) +dev_dbg (nor->dev,"error %d setting 4-byte mode\n" , ret); + +return ret; +} +/** * cypress_nor_determine_addr_mode_by_sr1() - Determine current address mode * (3 or 4-byte) by querying status
@@ -526,6 +548,9 @@ s25fs256t_post_bfpt_fixup(struct spi_nor *nor,struct spi_mem_op op;int ret; +/* Assign 4-byte address mode method that is not determined in BFPT */ + nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode; + ret =cypress_nor_set_addr_mode_nbytes (nor);if (ret)return ret;
@@ -591,6 +616,9 @@ s25hx_t_post_bfpt_fixup(struct spi_nor *nor, {int ret; +/* Assign 4-byte address mode method that is not determined in BFPT */ + nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode; + ret =cypress_nor_set_addr_mode_nbytes (nor);if (ret)return ret;
@@ -718,6 +746,9 @@ static int s28hx_t_post_bfpt_fixup(struct spi_nor *nor,const struct sfdp_parameter_header *bfpt_header, const struct sfdp_bfpt *bfpt) { +/* Assign 4-byte address mode method that is not determined in BFPT */ + nor->params->set_4byte_addr_mode = cypress_nor_set_4byte_addr_mode; +return cypress_nor_set_addr_mode_nbytes (nor); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 357/627 perf sched: Make sure it frees the usage string
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 10d9b89203765fb776512742c13af8dd92821842 ]
The parse_options_subcommand() allocates the usage string based on the given subcommands. So it should reach the end of the function to free the string to prevent memory leaks.
--- tools/perf/builtin-sched.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)
tools/perf/builtin-sched.c +13 -12
@@ -3902,9 +3902,9 @@ int cmd_sched(int argc, const char **argv)* Aliased to 'perf script' for now: */ if (!strcmp (argv[0 ],"script" )) { -return cmd_script (argc, argv); + ret =cmd_script (argc, argv); }else if (strlen (argv[0 ]) >2 &&strstarts ("record" , argv[0 ])) { -return __cmd_record (argc, argv); + ret =__cmd_record (argc, argv); }else if (strlen (argv[0 ]) >2 &&strstarts ("latency" , argv[0 ])) { sched.tp_handler = &lat_ops;if (argc >1 ) {
@@ -3913,7 +3913,7 @@ int cmd_sched(int argc, const char **argv)usage_with_options (latency_usage, latency_options); }setup_sorting (&sched, latency_options, latency_usage); -return perf_sched__lat (&sched); + ret =perf_sched__lat (&sched); }else if (!strcmp (argv[0 ],"map" )) {if (argc) { argc =parse_options (argc, argv, map_options, map_usage,0 );
@@ -3924,13 +3924,14 @@ int cmd_sched(int argc, const char **argv) sched.map.task_names =strlist__new (sched.map.task_name,NULL );if (sched.map.task_names ==NULL ) {fprintf (stderr,"Failed to parse task names\n" ); -return -1 ; + ret =-1 ; + goto out; } } } sched.tp_handler = &map_ops;setup_sorting (&sched, latency_options, latency_usage); -return perf_sched__map (&sched); + ret =perf_sched__map (&sched); }else if (strlen (argv[0 ]) >2 &&strstarts ("replay" , argv[0 ])) { sched.tp_handler = &replay_ops;if (argc) {
@@ -3938,7 +3939,7 @@ int cmd_sched(int argc, const char **argv)if (argc)usage_with_options (replay_usage, replay_options); } -return perf_sched__replay (&sched); + ret =perf_sched__replay (&sched); }else if (!strcmp (argv[0 ],"timehist" )) {if (argc) { argc = parse_options(argc, argv, timehist_options,
@@ -3954,19 +3955,19 @@ int cmd_sched(int argc, const char **argv)parse_options_usage (NULL , timehist_options,"w" , true);if (sched.show_next)parse_options_usage (NULL , timehist_options,"n" , true); -return -EINVAL ; + ret = -EINVAL ; + goto out; } ret =symbol__validate_sym_arguments (); -if (ret) -return ret; - -return perf_sched__timehist (&sched); +if (!ret) + ret =perf_sched__timehist (&sched); }else {usage_with_options (sched_usage, sched_options); } +out:/* free usage string allocated by parse_options_subcommand */ free ((void *)sched_usage[0 ]); -return 0 ; +return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 358/627 perf sched: Free thread->priv using priv_destructor
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit aa9fdd106bab8c478d37eba5703c0950ad5c0d4f ]
In many perf sched subcommand saves priv data structure in the thread but it forgot to free them. As it's an opaque type with 'void *', it needs to register that knows how to free the data. In this case, just regular 'free()' is fine.
--- tools/perf/builtin-sched.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/builtin-sched.c +2 -0
@@ -3898,6 +3898,8 @@ int cmd_sched(int argc, const char **argv)if (!argc)usage_with_options (sched_usage, sched_options); +thread__set_priv_destructor (free); +/* * Aliased to 'perf script' for now: */
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 359/627 perf sched: Fix memory leaks in perf sched map
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit dc3a80c98884d86389b3b572c50ccc7f502cd41b ]
It maintains per-cpu pointers for the current thread but it doesn't release the refcounts.
--- tools/perf/builtin-sched.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-)
tools/perf/builtin-sched.c +20 -11
@@ -1634,6 +1634,7 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,const char *color =PERF_COLOR_NORMAL ;char stimestamp[32 ];const char *str; +int ret =-1 ;BUG_ON (this_cpu.cpu >=MAX_CPUS || this_cpu.cpu <0 );
@@ -1664,17 +1665,20 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel, sched_in =map__findnew_thread (sched, machine,-1 , next_pid); sched_out =map__findnew_thread (sched, machine,-1 , prev_pid);if (sched_in ==NULL || sched_out ==NULL ) -return -1 ; + goto out; tr =thread__get_runtime (sched_in); -if (tr ==NULL ) { -thread__put (sched_in); -return -1 ; - } +if (tr ==NULL ) + goto out; + +thread__put (sched->curr_thread[this_cpu.cpu]); +thread__put (sched->curr_out_thread[this_cpu.cpu]); sched->curr_thread[this_cpu.cpu] =thread__get (sched_in); sched->curr_out_thread[this_cpu.cpu] =thread__get (sched_out); + ret =0 ; + str =thread__comm_str (sched_in); new_shortname =0 ;if (!tr->shortname[0 ]) {
@@ -1769,12 +1773,10 @@ static int map_switch_event(struct perf_sched *sched, struct evsel *evsel,color_fprintf (stdout, color,"\n" ); out: -if (sched->map.task_name) -thread__put (sched_out); - +thread__put (sched_out);thread__put (sched_in); -return 0 ; +return ret; } static int process_sched_switch_event(const struct perf_tool *tool,
@@ -3556,10 +3558,10 @@ static int perf_sched__map(struct perf_sched *sched) sched->curr_out_thread =calloc (MAX_CPUS ,sizeof (*(sched->curr_out_thread)));if (!sched->curr_out_thread) -return rc; + goto out_free_curr_thread;if (setup_cpus_switch_event (sched)) - goto out_free_curr_thread; + goto out_free_curr_out_thread;if (setup_map_cpus (sched)) goto out_free_cpus_switch_event;
@@ -3590,7 +3592,14 @@ static int perf_sched__map(struct perf_sched *sched) out_free_cpus_switch_event:free_cpus_switch_event (sched); +out_free_curr_out_thread: +for (int i =0 ; i <MAX_CPUS ; i++) +thread__put (sched->curr_out_thread[i]); +zfree (&sched->curr_out_thread); + out_free_curr_thread: +for (int i =0 ; i <MAX_CPUS ; i++) +thread__put (sched->curr_thread[i]);zfree (&sched->curr_thread);return rc; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 360/627 perf sched: Fix thread leaks in perf sched timehist
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit e2eb59260c4f6bac403491d0112891766b8650d1 ]
Add missing thread__put() after machine__findnew_thread() or timehist_get_thread(). Also idle threads' last_thread should be refcounted properly.
--- tools/perf/builtin-sched.c | 48 +++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 11 deletions(-)
tools/perf/builtin-sched.c +37 -11
@@ -2313,8 +2313,10 @@ static void save_task_callchain(struct perf_sched *sched,return ; } -if (!sched->show_callchain || sample->callchain ==NULL ) +if (!sched->show_callchain || sample->callchain ==NULL ) { +thread__put (thread);return ; + } cursor =get_tls_callchain_cursor ();
@@ -2323,10 +2325,12 @@ static void save_task_callchain(struct perf_sched *sched,if (verbose >0 )pr_err ("Failed to resolve callchain. Skipping\n" ); +thread__put (thread);return ; }callchain_cursor_commit (cursor); +thread__put (thread);while (true) {struct callchain_cursor_node *node;
@@ -2403,8 +2407,17 @@ static void free_idle_threads(void)return ;for (i =0 ; i < idle_max_cpu; ++i) { -if ((idle_threads[i])) -thread__delete (idle_threads[i]); +struct thread *idle = idle_threads[i]; + +if (idle) { +struct idle_thread_runtime *itr; + + itr =thread__priv (idle); +if (itr) +thread__put (itr->last_thread); + +thread__delete (idle); + } }free (idle_threads);
@@ -2441,7 +2454,7 @@ static struct thread *get_idle_thread(int cpu) } } -return idle_threads[cpu]; +return thread__get (idle_threads[cpu]); } static void save_idle_callchain(struct perf_sched *sched,
@@ -2496,7 +2509,8 @@ static struct thread *timehist_get_thread(struct perf_sched *sched,if (itr ==NULL )return NULL ; - itr->last_thread = thread; +thread__put (itr->last_thread); + itr->last_thread =thread__get (thread);/* copy task callchain when entering to idle */ if (evsel__intval (evsel, sample,"next_pid" ) ==0 )
@@ -2567,6 +2581,7 @@ static void timehist_print_wakeup_event(struct perf_sched *sched,/* show wakeup unless both awakee and awaker are filtered */ if (timehist_skip_sample (sched, thread, evsel, sample) &&timehist_skip_sample (sched, awakened, evsel, sample)) { +thread__put (thread);return ; }
@@ -2583,6 +2598,8 @@ static void timehist_print_wakeup_event(struct perf_sched *sched,printf ("awakened: %s" ,timehist_get_commstr (awakened));printf ("\n" ); + +thread__put (thread); } static int timehist_sched_wakeup_ignore(const struct perf_tool *tool __maybe_unused,
@@ -2611,8 +2628,10 @@ static int timehist_sched_wakeup_event(const struct perf_tool *tool,return -1 ; tr =thread__get_runtime (thread); -if (tr ==NULL ) +if (tr ==NULL ) { +thread__put (thread);return -1 ; + }if (tr->ready_to_run ==0 ) tr->ready_to_run = sample->time;
@@ -2622,6 +2641,7 @@ static int timehist_sched_wakeup_event(const struct perf_tool *tool, !perf_time__skip_sample(&sched->ptime, sample->time))timehist_print_wakeup_event (sched, evsel, sample, machine, thread); +thread__put (thread);return 0 ; }
@@ -2649,6 +2669,7 @@ static void timehist_print_migration_event(struct perf_sched *sched,if (timehist_skip_sample (sched, thread, evsel, sample) &&timehist_skip_sample (sched, migrated, evsel, sample)) { +thread__put (thread);return ; }
@@ -2676,6 +2697,7 @@ static void timehist_print_migration_event(struct perf_sched *sched,printf (" cpu %d => %d" , ocpu, dcpu);printf ("\n" ); +thread__put (thread); } static int timehist_migrate_task_event(const struct perf_tool *tool,
@@ -2695,8 +2717,10 @@ static int timehist_migrate_task_event(const struct perf_tool *tool,return -1 ; tr =thread__get_runtime (thread); -if (tr ==NULL ) +if (tr ==NULL ) { +thread__put (thread);return -1 ; + } tr->migrations++; tr->migrated = sample->time;
@@ -2706,6 +2730,7 @@ static int timehist_migrate_task_event(const struct perf_tool *tool,timehist_print_migration_event (sched, evsel, sample, machine, thread); } +thread__put (thread);return 0 ; }
@@ -2728,10 +2753,10 @@ static void timehist_update_task_prio(struct evsel *evsel,return ; tr =thread__get_runtime (thread); -if (tr ==NULL ) -return ; +if (tr !=NULL ) + tr->prio = next_prio; - tr->prio = next_prio; +thread__put (thread); } static int timehist_sched_change_event(const struct perf_tool *tool,
@@ -2743,7 +2768,7 @@ static int timehist_sched_change_event(const struct perf_tool *tool, struct perf_sched *sched = container_of(tool, struct perf_sched, tool);struct perf_time_interval *ptime = &sched->ptime;struct addr_location al; -struct thread *thread; +struct thread *thread =NULL ;struct thread_runtime *tr =NULL ;u64 tprev, t = sample->time;int rc =0 ;
@@ -2867,6 +2892,7 @@ static int timehist_sched_change_event(const struct perf_tool *tool,evsel__save_time (evsel, sample->time, sample->cpu); +thread__put (thread);addr_location__exit (&al);return rc; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 361/627 perf sched: Fix memory leaks for evsel->priv in timehist
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 117e5c33b1c44037af016d77ce6c0b086d55535f ]
It uses evsel->priv to save per-cpu timing information. It should be freed when the evsel is released.
Add the priv destructor for evsel same as thread to handle that.
--- tools/perf/builtin-sched.c | 12 ++++++++++++ tools/perf/util/evsel.c | 11 +++++++++++ tools/perf/util/evsel.h | 2 ++ 3 files changed, 25 insertions(+)
tools/perf/builtin-sched.c +12 -0
@@ -2020,6 +2020,16 @@ static u64 evsel__get_time(struct evsel *evsel, u32 cpu)return r->last_time[cpu]; } +static void timehist__evsel_priv_destructor (void *priv) +{ +struct evsel_runtime *r = priv; + +if (r) { +free (r->last_time); +free (r); + } +} +static int comm_width =30 ;static char *timehist_get_commstr (struct thread *thread)
@@ -3314,6 +3324,8 @@ static int perf_sched__timehist(struct perf_sched *sched)setup_pager (); +evsel__set_priv_destructor (timehist__evsel_priv_destructor); +/* prefer sched_waking if it is captured */ if (evlist__find_tracepoint_by_name (session->evlist,"sched:sched_waking" )) handlers[1 ].handler = timehist_sched_wakeup_ignore;
tools/perf/util/evsel.c +11 -0
@@ -1656,6 +1656,15 @@ static void evsel__free_config_terms(struct evsel *evsel)free_config_terms (&evsel->config_terms); } +static void (*evsel__priv_destructor)(void *priv); + +void evsel__set_priv_destructor (void (*destructor)(void *priv)) +{ +assert (evsel__priv_destructor ==NULL ); + + evsel__priv_destructor = destructor; +} +void evsel__exit (struct evsel *evsel) {assert (list_empty (&evsel->core.node));
@@ -1686,6 +1695,8 @@ void evsel__exit(struct evsel *evsel)hashmap__free (evsel->per_pkg_mask); evsel->per_pkg_mask =NULL ;zfree (&evsel->metric_events); +if (evsel__priv_destructor) +evsel__priv_destructor (evsel->priv); perf_evsel__object.fini (evsel);if (evsel__tool_event (evsel) ==TOOL_PMU__EVENT_SYSTEM_TIME ||evsel__tool_event (evsel) ==TOOL_PMU__EVENT_USER_TIME )
tools/perf/util/evsel.h +2 -0
@@ -280,6 +280,8 @@ void evsel__init(struct evsel *evsel, struct perf_event_attr *attr, int idx);void evsel__exit (struct evsel *evsel);void evsel__delete (struct evsel *evsel); +void evsel__set_priv_destructor (void (*destructor)(void *priv)); +struct callchain_param ; void evsel__config(struct evsel *evsel, struct record_opts *opts,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 362/627 perf sched: Use RC_CHK_EQUAL() to compare pointers
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit 7a4002ec9e0fced907179da94f67c3082d7b4162 ]
So that it can check two pointers to the same object properly when REFCNT_CHECKING is on.
--- tools/perf/builtin-sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-sched.c +1 -1
@@ -994,7 +994,7 @@ thread_atoms_search(struct rb_root_cached *root, struct thread *thread,else if (cmp <0 ) node = node->rb_right;else { -BUG_ON (thread != atoms->thread); +BUG_ON (!RC_CHK_EQUAL (thread, atoms->thread));return atoms; } }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 363/627 perf sched: Fix memory leaks in perf sched latency
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Namhyung Kim <[email protected]>
[ Upstream commit e68b1c0098b959cb88afce5c93dd6a9324e6da78 ]
The work_atoms should be freed after use. Add free_work_atoms() to make sure to release all. It should use list_splice_init() when merging atoms to prevent accessing invalid pointers.
--- tools/perf/builtin-sched.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-)
tools/perf/builtin-sched.c +24 -3
@@ -1111,6 +1111,21 @@ add_sched_in_event(struct work_atoms *atoms, u64 timestamp) atoms->nb_atoms++; } +static void free_work_atoms (struct work_atoms *atoms) +{ +struct work_atom *atom, *tmp; + +if (atoms ==NULL ) +return ; + +list_for_each_entry_safe (atom, tmp, &atoms->work_list, list) { +list_del (&atom->list); +free (atom); + } +thread__zput (atoms->thread); +free (atoms); +} + static int latency_switch_event(struct perf_sched *sched, struct evsel *evsel, struct perf_sample *sample,
@@ -3426,13 +3441,13 @@ static void __merge_work_atoms(struct rb_root_cached *root, struct work_atoms *d this->total_runtime += data->total_runtime; this->nb_atoms += data->nb_atoms; this->total_lat += data->total_lat; -list_splice (&data->work_list, &this->work_list); +list_splice_init (&data->work_list, &this->work_list);if (this->max_lat < data->max_lat) { this->max_lat = data->max_lat; this->max_lat_start = data->max_lat_start; this->max_lat_end = data->max_lat_end; } -zfree (&data); +free_work_atoms (data);return ; } }
@@ -3511,7 +3526,6 @@ static int perf_sched__lat(struct perf_sched *sched) work_list = rb_entry(next, struct work_atoms, node);output_lat_thread (sched, work_list); next =rb_next (next); -thread__zput (work_list->thread); }printf (" -----------------------------------------------------------------------------------------------------------------\n" );
@@ -3525,6 +3539,13 @@ static int perf_sched__lat(struct perf_sched *sched) rc =0 ; +while ((next =rb_first_cached (&sched->sorted_atom_root))) { +struct work_atoms *data; + + data = rb_entry(next, struct work_atoms, node); +rb_erase_cached (next, &sched->sorted_atom_root); +free_work_atoms (data); + } out_free_cpus_switch_event:free_cpus_switch_event (sched);return rc;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 364/627 clk: spacemit: mark K1 pll1_d8 as critical
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Elder <[email protected]>
[ Upstream commit 7554729de27daf6d54bcf8689d863bbe267828bf ]
The pll1_d8 clock is enabled by the boot loader, and is ultimately a parent for numerous clocks, including those used by APB and AXI buses. Guodong Xu discovered that this clock got disabled while responding to getting -EPROBE_DEFER when requesting a reset controller.
The needed clock (CLK_DMA, along with its parents) had already been enabled. To respond to the probe deferral return, the CLK_DMA clock was disabled, and this led to parent clocks also reducing their enable count. When the enable count for pll1_d8 was decremented it became 0, which caused it to be disabled. This led to a system hang.
Marking that clock critical resolves this by preventing it from being disabled.
Define a new macro CCU_FACTOR_GATE_DEFINE() to allow clock flags to be supplied for a CCU_FACTOR_GATE clock.
--- drivers/clk/spacemit/ccu-k1.c | 3 ++- drivers/clk/spacemit/ccu_mix.h | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-)
drivers/clk/spacemit/ccu-k1.c +2 -1
@@ -170,7 +170,8 @@ CCU_FACTOR_GATE_DEFINE(pll1_d4, CCU_PARENT_HW(pll1), APBS_PLL1_SWCR2, BIT(3), 4,CCU_FACTOR_GATE_DEFINE (pll1_d5,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (4 ),5 ,1 );CCU_FACTOR_GATE_DEFINE (pll1_d6,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (5 ),6 ,1 );CCU_FACTOR_GATE_DEFINE (pll1_d7,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (6 ),7 ,1 ); -CCU_FACTOR_GATE_DEFINE (pll1_d8,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (7 ),8 ,1 ); +CCU_FACTOR_GATE_FLAGS_DEFINE (pll1_d8,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (7 ),8 ,1 , +CLK_IS_CRITICAL );CCU_FACTOR_GATE_DEFINE (pll1_d11_223p4,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (15 ),11 ,1 );CCU_FACTOR_GATE_DEFINE (pll1_d13_189,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (16 ),13 ,1 );CCU_FACTOR_GATE_DEFINE (pll1_d23_106p8,CCU_PARENT_HW (pll1),APBS_PLL1_SWCR2 ,BIT (20 ),23 ,1 );
drivers/clk/spacemit/ccu_mix.h +8 -3
@@ -101,17 +101,22 @@ static struct ccu_mix _name = { \ } \ } -#define CCU_FACTOR_GATE_DEFINE (_name, _parent, _reg_ctrl, _mask_gate, _div, \ - _mul) \ +#define CCU_FACTOR_GATE_FLAGS_DEFINE (_name, _parent, _reg_ctrl, _mask_gate, _div, \ + _mul, _flags) \ static struct ccu_mix _name = { \ .gate = CCU_GATE_INIT(_mask_gate), \ .factor = CCU_FACTOR_INIT(_div, _mul), \ .common = { \ .reg_ctrl = _reg_ctrl, \ - CCU_MIX_INITHW(_name, _parent, spacemit_ccu_factor_gate_ops, 0) \ + CCU_MIX_INITHW(_name, _parent, spacemit_ccu_factor_gate_ops, _flags) \ } \ } +#define CCU_FACTOR_GATE_DEFINE (_name, _parent, _reg_ctrl, _mask_gate, _div, \ + _mul) \ + CCU_FACTOR_GATE_FLAGS_DEFINE(_name, _parent, _reg_ctrl, _mask_gate, _div, \ + _mul, 0) +#define CCU_MUX_GATE_DEFINE (_name, _parents, _reg_ctrl, _shift, _width, \ _mask_gate, _flags) \ static struct ccu_mix _name = { \
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 365/627 RDMA/hns: Fix double destruction of rsv_qp
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: wenglianfa <[email protected]>
[ Upstream commit c6957b95ecc5b63c5a4bb4ecc28af326cf8f6dc8 ]
rsv_qp may be double destroyed in error flow, first in free_mr_init(), and then in hns_roce_exit(). Fix it by moving the free_mr_init() call into hns_roce_v2_init().
list_del corruption, ffff589732eb9b50->next is LIST_POISON1 (dead000000000100)
WARNING: CPU: 8 PID: 1047115 at lib/list_debug.c:53 __list_del_entry_valid+0x148/0x240 ... Call trace: __list_del_entry_valid+0x148/0x240 hns_roce_qp_remove+0x4c/0x3f0 [hns_roce_hw_v2] hns_roce_v2_destroy_qp_common+0x1dc/0x5f4 [hns_roce_hw_v2] hns_roce_v2_destroy_qp+0x22c/0x46c [hns_roce_hw_v2] free_mr_exit+0x6c/0x120 [hns_roce_hw_v2] hns_roce_v2_exit+0x170/0x200 [hns_roce_hw_v2] hns_roce_exit+0x118/0x350 [hns_roce_hw_v2] __hns_roce_hw_v2_init_instance+0x1c8/0x304 [hns_roce_hw_v2] hns_roce_hw_v2_reset_notify_init+0x170/0x21c [hns_roce_hw_v2] hns_roce_hw_v2_reset_notify+0x6c/0x190 [hns_roce_hw_v2] hclge_notify_roce_client+0x6c/0x160 [hclge] hclge_reset_rebuild+0x150/0x5c0 [hclge] hclge_reset+0x10c/0x140 [hclge] hclge_reset_subtask+0x80/0x104 [hclge] hclge_reset_service_task+0x168/0x3ac [hclge] hclge_service_task+0x50/0x100 [hclge] process_one_work+0x250/0x9a0 worker_thread+0x324/0x990 kthread+0x190/0x210 ret_from_fork+0x10/0x18
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 25 +++++++++++----------- drivers/infiniband/hw/hns/hns_roce_main.c | 6 +++--- 2 files changed, 16 insertions(+), 15 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +13 -12
@@ -2986,14 +2986,22 @@ static int hns_roce_v2_init(struct hns_roce_dev *hr_dev) {int ret; +if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 ) { + ret =free_mr_init (hr_dev); +if (ret) { +dev_err (hr_dev->dev,"failed to init free mr!\n" ); +return ret; + } + } +/* The hns ROCEE requires the extdb info to be cleared before using */ ret =hns_roce_clear_extdb_list_info (hr_dev);if (ret) -return ret; + goto err_clear_extdb_failed; ret =get_hem_table (hr_dev);if (ret) -return ret; + goto err_clear_extdb_failed;if (hr_dev->is_vf)return 0 ;
@@ -3008,6 +3016,9 @@ static int hns_roce_v2_init(struct hns_roce_dev *hr_dev) err_llm_init_failed:put_hem_table (hr_dev); +err_clear_extdb_failed: +if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 ) +free_mr_exit (hr_dev);return ret; }
@@ -7044,21 +7055,11 @@ static int __hns_roce_hw_v2_init_instance(struct hnae3_handle *handle) goto error_failed_roce_init; } -if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 ) { - ret =free_mr_init (hr_dev); -if (ret) { -dev_err (hr_dev->dev,"failed to init free mr!\n" ); - goto error_failed_free_mr_init; - } - } handle->priv = hr_dev;return 0 ; -error_failed_free_mr_init: -hns_roce_exit (hr_dev); - error_failed_roce_init:kfree (hr_dev->priv);
drivers/infiniband/hw/hns/hns_roce_main.c +3 -3
@@ -965,6 +965,9 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)spin_lock_init (&hr_dev->sm_lock); +INIT_LIST_HEAD (&hr_dev->qp_list); +spin_lock_init (&hr_dev->qp_list_lock); +if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_CQ_RECORD_DB || hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_QP_RECORD_DB ) {INIT_LIST_HEAD (&hr_dev->pgdir_list);
@@ -1132,9 +1135,6 @@ int hns_roce_init(struct hns_roce_dev *hr_dev) } } -INIT_LIST_HEAD (&hr_dev->qp_list); -spin_lock_init (&hr_dev->qp_list_lock); - ret =hns_roce_register_device (hr_dev);if (ret) goto error_failed_register_device;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 366/627 RDMA/hns: Fix HW configurations not cleared in error flow
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: wenglianfa <[email protected]>
[ Upstream commit 998b41cb20b02c4e28ac558e4e7f8609d659ec05 ]
hns_roce_clear_extdb_list_info() will eventually do some HW configurations through FW, and they need to be cleared by calling hns_roce_function_clear() when the initialization fails.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +3 -1
@@ -3001,7 +3001,7 @@ static int hns_roce_v2_init(struct hns_roce_dev *hr_dev) ret =get_hem_table (hr_dev);if (ret) - goto err_clear_extdb_failed; + goto err_get_hem_table_failed;if (hr_dev->is_vf)return 0 ;
@@ -3016,6 +3016,8 @@ static int hns_roce_v2_init(struct hns_roce_dev *hr_dev) err_llm_init_failed:put_hem_table (hr_dev); +err_get_hem_table_failed: +hns_roce_function_clear (hr_dev); err_clear_extdb_failed:if (hr_dev->pci_dev->revision ==PCI_REVISION_ID_HIP08 )free_mr_exit (hr_dev);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 367/627 crypto: ccp - Fix locking on alloc failure handling
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alexey Kardashevskiy <[email protected]>
[ Upstream commit b4abeccb8d39db7d9b51cb0098d6458760b30a75 ]
The __snp_alloc_firmware_pages() helper allocates pages in the firmware state (alloc + rmpupdate). In case of failed rmpupdate, it tries reclaiming pages with already changed state. This requires calling the PSP firmware and since there is sev_cmd_mutex to guard such calls, the helper takes a "locked" parameter so specify if the lock needs to be held.
Most calls happen from snp_alloc_firmware_page() which executes without the lock. However
commit 24512afa4336 ("crypto: ccp: Handle the legacy TMR allocation when SNP is enabled")
switched sev_fw_alloc() from alloc_pages() (which does not call the PSP) to __snp_alloc_firmware_pages() (which does) but did not account for the fact that sev_fw_alloc() is called from __sev_platform_init_locked() (via __sev_platform_init_handle_tmr()) and executes with the lock held.
Add a "locked" parameter to __snp_alloc_firmware_pages().
Make sev_fw_alloc() use the new parameter to prevent potential deadlock in rmp_mark_pages_firmware() if rmpupdate() failed.
--- drivers/crypto/ccp/sev-dev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/crypto/ccp/sev-dev.c +4 -4
@@ -434,7 +434,7 @@ static int rmp_mark_pages_firmware(unsigned long paddr, unsigned int npages, booreturn rc; } -static struct page *__snp_alloc_firmware_pages (gfp_t gfp_mask,int order) +static struct page *__snp_alloc_firmware_pages (gfp_t gfp_mask,int order,bool locked) {unsigned long npages =1ul << order, paddr;struct sev_device *sev;
@@ -453,7 +453,7 @@ static struct page *__snp_alloc_firmware_pages(gfp_t gfp_mask, int order)return page; paddr =__pa ((unsigned long )page_address (page)); -if (rmp_mark_pages_firmware (paddr, npages, false)) +if (rmp_mark_pages_firmware (paddr, npages, locked))return NULL ;return page;
@@ -463,7 +463,7 @@ void *snp_alloc_firmware_page(gfp_t gfp_mask) {struct page *page; - page =__snp_alloc_firmware_pages (gfp_mask,0 ); + page =__snp_alloc_firmware_pages (gfp_mask,0 , false);return page ?page_address (page) :NULL ; }
@@ -498,7 +498,7 @@ static void *sev_fw_alloc(unsigned long len) {struct page *page; - page =__snp_alloc_firmware_pages (GFP_KERNEL ,get_order (len)); + page =__snp_alloc_firmware_pages (GFP_KERNEL ,get_order (len), true);if (!page)return NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 368/627 crypto: inside-secure - Fix `dma_unmap_sg()` nents value
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit cb7fa6b6fc71e0c801e271aa498e2f19e6df2931 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/crypto/inside-secure/safexcel_hash.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/crypto/inside-secure/safexcel_hash.c +6 -2
@@ -249,7 +249,9 @@ static int safexcel_handle_req_result(struct safexcel_crypto_priv *priv,safexcel_complete (priv, ring);if (sreq->nents) { -dma_unmap_sg (priv->dev, areq->src, sreq->nents,DMA_TO_DEVICE ); +dma_unmap_sg (priv->dev, areq->src, +sg_nents_for_len (areq->src, areq->nbytes), +DMA_TO_DEVICE ); sreq->nents =0 ; }
@@ -497,7 +499,9 @@ static int safexcel_ahash_send_req(struct crypto_async_request *async, int ring, DMA_FROM_DEVICE); unmap_sg:if (req->nents) { -dma_unmap_sg (priv->dev, areq->src, req->nents,DMA_TO_DEVICE ); +dma_unmap_sg (priv->dev, areq->src, +sg_nents_for_len (areq->src, areq->nbytes), +DMA_TO_DEVICE ); req->nents =0 ; } cdesc_rollback:
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 369/627 crypto: ccp - Fix crash when rebind ccp device for ccp.ko
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mengbiao Xiong <[email protected]>
[ Upstream commit 181698af38d3f93381229ad89c09b5bd0496661a ]
When CONFIG_CRYPTO_DEV_CCP_DEBUGFS is enabled, rebinding the ccp device causes the following crash:
$ echo '0000:0a:00.2' > /sys/bus/pci/drivers/ccp/unbind $ echo '0000:0a:00.2' > /sys/bus/pci/drivers/ccp/bind
[ 204.976930] BUG: kernel NULL pointer dereference, address: 0000000000000098 [ 204.978026] #PF: supervisor write access in kernel mode [ 204.979126] #PF: error_code(0x0002) - not-present page [ 204.980226] PGD 0 P4D 0 [ 204.981317] Oops: Oops: 0002 [#1] SMP NOPTI ... [ 204.997852] Call Trace: [ 204.999074] <TASK> [ 205.000297] start_creating+0x9f/0x1c0 [ 205.001533] debugfs_create_dir+0x1f/0x170 [ 205.002769] ? srso_return_thunk+0x5/0x5f [ 205.004000] ccp5_debugfs_setup+0x87/0x170 [ccp] [ 205.005241] ccp5_init+0x8b2/0x960 [ccp] [ 205.006469] ccp_dev_init+0xd4/0x150 [ccp] [ 205.007709] sp_init+0x5f/0x80 [ccp] [ 205.008942] sp_pci_probe+0x283/0x2e0 [ccp] [ 205.010165] ? srso_return_thunk+0x5/0x5f [ 205.011376] local_pci_probe+0x4f/0xb0 [ 205.012584] pci_device_probe+0xdb/0x230 [ 205.013810] really_probe+0xed/0x380 [ 205.015024] __driver_probe_device+0x7e/0x160 [ 205.016240] device_driver_attach+0x2f/0x60 [ 205.017457] bind_store+0x7c/0xb0 [ 205.018663] drv_attr_store+0x28/0x40 [ 205.019868] sysfs_kf_write+0x5f/0x70 [ 205.021065] kernfs_fop_write_iter+0x145/0x1d0 [ 205.022267] vfs_write+0x308/0x440 [ 205.023453] ksys_write+0x6d/0xe0 [ 205.024616] __x64_sys_write+0x1e/0x30 [ 205.025778] x64_sys_call+0x16ba/0x2150 [ 205.026942] do_syscall_64+0x56/0x1e0 [ 205.028108] entry_SYSCALL_64_after_hwframe+0x76/0x7e [ 205.029276] RIP: 0033:0x7fbc36f10104 [ 205.030420] Code: 89 02 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 8d 05 e1 08 2e 00 8b 00 85 c0 75 13 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 54 f3 c3 66 90 41 54 55 49 89 d4 53 48 89 f5
This patch sets ccp_debugfs_dir to NULL after destroying it in ccp5_debugfs_destroy, allowing the directory dentry to be recreated when rebinding the ccp device.
Tested on AMD Ryzen 7 1700X.
--- drivers/crypto/ccp/ccp-debugfs.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/crypto/ccp/ccp-debugfs.c +3 -0
@@ -319,5 +319,8 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)void ccp5_debugfs_destroy (void ) { +mutex_lock (&ccp_debugfs_lock);debugfs_remove_recursive (ccp_debugfs_dir); + ccp_debugfs_dir =NULL ; +mutex_unlock (&ccp_debugfs_lock); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 370/627 RDMA/hns: Get message length of ack_req from FW
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 2c2ec0106c0f1f12d4eefd11de318ac47557a750 ]
ACK_REQ_FREQ indicates the number of packets (after MTU fragmentation) HW sends before setting an ACK request. When MTU is greater than or equal to 1024, the current ACK_REQ_FREQ value causes HW to request an ACK for every MTU fragment. The processing of a large number of ACKs severely impacts HW performance when sending large size payloads.
Get message length of ack_req from FW so that we can adjust this parameter according to different situations. There are several constraints for ACK_REQ_FREQ:
1. mtu * (2 ^ ACK_REQ_FREQ) should not be too large, otherwise it may cause some unexpected retries when sending large payload.
2. ACK_REQ_FREQ should be larger than or equal to LP_PKTN_INI.
3. ACK_REQ_FREQ must be equal to LP_PKTN_INI when using LDCP or HC3 congestion control algorithm.
--- drivers/infiniband/hw/hns/hns_roce_device.h | 1 + drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 45 ++++++++++++++++----- drivers/infiniband/hw/hns/hns_roce_hw_v2.h | 8 +++- 3 files changed, 43 insertions(+), 11 deletions(-)
drivers/infiniband/hw/hns/hns_roce_device.h +1 -0
@@ -856,6 +856,7 @@ struct hns_roce_caps {u16 default_ceq_arm_st;u8 cong_cap;enum hns_roce_cong_type default_cong_type; +u32 max_ack_req_msg_len; };enum hns_roce_device_state {
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +35 -10
100 lines not on this page · raw message
drivers/infiniband/hw/hns/hns_roce_hw_v2.h +7 -1
@@ -1168,7 +1168,8 @@ struct hns_roce_cfg_gmv_tb_b {#define GMV_TB_B_SMAC_H GMV_TB_B_FIELD_LOC(47, 32)#define GMV_TB_B_SGID_IDX GMV_TB_B_FIELD_LOC(71, 64) -#define HNS_ROCE_QUERY_PF_CAPS_CMD_NUM 5 +#define HNS_ROCE_QUERY_PF_CAPS_CMD_NUM_HIP08 5 +#define HNS_ROCE_QUERY_PF_CAPS_CMD_NUM 6struct hns_roce_query_pf_caps_a {u8 number_ports;u8 local_ca_ack_delay;
@@ -1280,6 +1281,11 @@ struct hns_roce_query_pf_caps_e {__le16 aeq_period; }; +struct hns_roce_query_pf_caps_f { +__le32 max_ack_req_msg_len; +__le32 rsv[5 ]; +}; +#define PF_CAPS_E_FIELD_LOC (h, l) \ FIELD_LOC(struct hns_roce_query_pf_caps_e, h, l)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 371/627 RDMA/hns: Fix accessing uninitialized resources
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 278c18a4a78a9a6bf529ef45ccde512a5686ea9d ]
hr_dev->pgdir_list and hr_dev->pgdir_mutex won't be initialized if CQ/QP record db are not enabled, but they are also needed when using SRQ with SRQ record db enabled. Simplified the logic by always initailizing the reosurces.
--- drivers/infiniband/hw/hns/hns_roce_main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/infiniband/hw/hns/hns_roce_main.c +4 -12
@@ -947,10 +947,7 @@ static int hns_roce_init_hem(struct hns_roce_dev *hr_dev)static void hns_roce_teardown_hca (struct hns_roce_dev *hr_dev) {hns_roce_cleanup_bitmap (hr_dev); - -if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_CQ_RECORD_DB || - hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_QP_RECORD_DB ) -mutex_destroy (&hr_dev->pgdir_mutex); +mutex_destroy (&hr_dev->pgdir_mutex); }/**
@@ -968,11 +965,8 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev)INIT_LIST_HEAD (&hr_dev->qp_list);spin_lock_init (&hr_dev->qp_list_lock); -if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_CQ_RECORD_DB || - hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_QP_RECORD_DB ) { -INIT_LIST_HEAD (&hr_dev->pgdir_list); -mutex_init (&hr_dev->pgdir_mutex); - } +INIT_LIST_HEAD (&hr_dev->pgdir_list); +mutex_init (&hr_dev->pgdir_mutex);hns_roce_init_uar_table (hr_dev);
@@ -1004,9 +998,7 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev) err_uar_table_free:ida_destroy (&hr_dev->uar_ida.ida); -if (hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_CQ_RECORD_DB || - hr_dev->caps.flags &HNS_ROCE_CAP_FLAG_QP_RECORD_DB ) -mutex_destroy (&hr_dev->pgdir_mutex); +mutex_destroy (&hr_dev->pgdir_mutex);return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 372/627 RDMA/hns: Drop GFP_NOWARN
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 5338abb299f0cd764edf78a7e71a0b746af35030 ]
GFP_NOWARN silences all warnings on dma_alloc_coherent() failure, which might otherwise help with troubleshooting.
--- drivers/infiniband/hw/hns/hns_roce_hem.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hem.c +5 -13
@@ -249,15 +249,12 @@ int hns_roce_calc_hem_mhop(struct hns_roce_dev *hr_dev, }static struct hns_roce_hem *hns_roce_alloc_hem (struct hns_roce_dev *hr_dev, -unsigned long hem_alloc_size, -gfp_t gfp_mask) +unsigned long hem_alloc_size) {struct hns_roce_hem *hem;int order;void *buf; -WARN_ON (gfp_mask & __GFP_HIGHMEM); - order =get_order (hem_alloc_size);if (PAGE_SIZE << order != hem_alloc_size) { dev_err(hr_dev->dev, "invalid hem_alloc_size: %lu!\n",
@@ -265,13 +262,12 @@ static struct hns_roce_hem *hns_roce_alloc_hem(struct hns_roce_dev *hr_dev,return NULL ; } - hem =kmalloc (sizeof (*hem), - gfp_mask & ~(__GFP_HIGHMEM | __GFP_NOWARN)); + hem =kmalloc (sizeof (*hem),GFP_KERNEL );if (!hem)return NULL ; buf =dma_alloc_coherent (hr_dev->dev, hem_alloc_size, - &hem->dma, gfp_mask); + &hem->dma,GFP_KERNEL );if (!buf) goto fail;
@@ -378,7 +374,6 @@ static int alloc_mhop_hem(struct hns_roce_dev *hr_dev, {u32 bt_size = mhop->bt_chunk_size;struct device *dev = hr_dev->dev; -gfp_t flag;u64 bt_ba;u32 size;int ret;
@@ -417,8 +412,7 @@ static int alloc_mhop_hem(struct hns_roce_dev *hr_dev,* alloc bt space chunk for MTT/CQE. */ size = table->type <HEM_TYPE_MTT ? mhop->buf_chunk_size : bt_size; - flag =GFP_KERNEL | __GFP_NOWARN; - table->hem[index->buf] =hns_roce_alloc_hem (hr_dev, size, flag); + table->hem[index->buf] =hns_roce_alloc_hem (hr_dev, size);if (!table->hem[index->buf]) { ret = -ENOMEM ; goto err_alloc_hem;
@@ -546,9 +540,7 @@ int hns_roce_table_get(struct hns_roce_dev *hr_dev, goto out; } - table->hem[i] =hns_roce_alloc_hem (hr_dev, - table->table_chunk_size, -GFP_KERNEL | __GFP_NOWARN); + table->hem[i] =hns_roce_alloc_hem (hr_dev, table->table_chunk_size);if (!table->hem[i]) { ret = -ENOMEM ; goto out;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 373/627 RDMA/hns: Fix -Wframe-larger-than issue
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Junxian Huang <[email protected]>
[ Upstream commit 79d56805c5068f2bc81518043e043c3dedd1c82a ]
Fix -Wframe-larger-than issue by allocating memory for qpc struct with kzalloc() instead of using stack memory.
--- drivers/infiniband/hw/hns/hns_roce_hw_v2.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/infiniband/hw/hns/hns_roce_hw_v2.c +10 -5
@@ -5387,11 +5387,10 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, {struct hns_roce_dev *hr_dev =to_hr_dev (ibqp->device);struct hns_roce_qp *hr_qp =to_hr_qp (ibqp); -struct hns_roce_v2_qp_context ctx[2 ]; -struct hns_roce_v2_qp_context *context = ctx; -struct hns_roce_v2_qp_context *qpc_mask = ctx +1 ; +struct hns_roce_v2_qp_context *context; +struct hns_roce_v2_qp_context *qpc_mask;struct ib_device *ibdev = &hr_dev->ib_dev; -int ret; +int ret = -ENOMEM ;if (attr_mask & ~IB_QP_ATTR_STANDARD_BITS )return -EOPNOTSUPP ;
@@ -5402,7 +5401,11 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,* we should set all bits of the relevant fields in context mask to * 0 at the same time, else set them to 0x1. */ -memset (context,0 , hr_dev->caps.qpc_sz); + context =kvzalloc (sizeof (*context),GFP_KERNEL ); + qpc_mask =kvzalloc (sizeof (*qpc_mask),GFP_KERNEL ); +if (!context || !qpc_mask) + goto out; +memset (qpc_mask,0xff , hr_dev->caps.qpc_sz); ret = hns_roce_v2_set_abs_fields(ibqp, attr, attr_mask, cur_state,
@@ -5444,6 +5447,8 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,clear_qp (hr_qp); out: +kvfree (qpc_mask); +kvfree (context);return ret; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 374/627 tracing: Use queue_rcu_work() to free filters
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steven Rostedt <[email protected]>
[ Upstream commit 3aceaa539cfe3a2e62bd92e6697d9fae1c20c0be ]
Freeing of filters requires to wait for both an RCU grace period as well as a RCU task trace wait period after they have been detached from their lists. The trace task period can be quite large so the freeing of the filters was moved to use the call_rcu*() routines. The problem with that is that the callback functions of call_rcu*() is done from a soft irq and can cause latencies if the callback takes a bit of time.
The filters are freed per event in a system and the syscalls system contains an event per system call, which can be over 700 events. Freeing 700 filters in a bottom half is undesirable.
Instead, move the freeing to use queue_rcu_work() which is done in task context.
--- kernel/trace/trace_events_filter.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-)
kernel/trace/trace_events_filter.c +20 -8
@@ -1344,13 +1344,14 @@ struct filter_list {struct filter_head {struct list_head list; -struct rcu_head rcu; +union { +struct rcu_head rcu; +struct rcu_work rwork; + }; }; - -static void free_filter_list (struct rcu_head *rhp) +static void free_filter_list (struct filter_head *filter_list) { - struct filter_head *filter_list = container_of(rhp, struct filter_head, rcu);struct filter_list *filter_item, *tmp;list_for_each_entry_safe (filter_item, tmp, &filter_list->list, list) {
@@ -1361,9 +1362,20 @@ static void free_filter_list(struct rcu_head *rhp)kfree (filter_list); } +static void free_filter_list_work (struct work_struct *work) +{ +struct filter_head *filter_list; + + filter_list = container_of(to_rcu_work(work), struct filter_head, rwork); +free_filter_list (filter_list); +} +static void free_filter_list_tasks (struct rcu_head *rhp) { -call_rcu (rhp, free_filter_list); + struct filter_head *filter_list = container_of(rhp, struct filter_head, rcu); + +INIT_RCU_WORK (&filter_list->rwork, free_filter_list_work); +queue_rcu_work (system_wq, &filter_list->rwork); }/*
@@ -1460,7 +1472,7 @@ static void filter_free_subsystem_filters(struct trace_subsystem_dir *dir,tracepoint_synchronize_unregister ();if (head) -free_filter_list (&head->rcu); +free_filter_list (head);list_for_each_entry (file, &tr->events, list) {if (file->system != dir || !file->filter)
@@ -2305,7 +2317,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,return 0 ; fail:/* No call succeeded */ -free_filter_list (&filter_list->rcu); +free_filter_list (filter_list);parse_error (pe,FILT_ERR_BAD_SUBSYS_FILTER ,0 );return -EINVAL ; fail_mem:
@@ -2315,7 +2327,7 @@ static int process_system_preds(struct trace_subsystem_dir *dir,if (!fail)delay_free_filter (filter_list);else -free_filter_list (&filter_list->rcu); +free_filter_list (filter_list);return -ENOMEM ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 375/627 kernel: trace: preemptirq_delay_test: use offstack cpu mask
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
[ Upstream commit adc353c0bfb243ebfd29b6222fa3bf149169a6de ]
A CPU mask on the stack is broken for large values of CONFIG_NR_CPUS:
kernel/trace/preemptirq_delay_test.c: In function ‘preemptirq_delay_run’:kernel/trace/preemptirq_delay_test.c:143:1: error: the frame size of 8512 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]
Fall back to dynamic allocation here.
--- kernel/trace/preemptirq_delay_test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
kernel/trace/preemptirq_delay_test.c +9 -4
@@ -117,12 +117,15 @@ static int preemptirq_delay_run(void *data) {int i;int s =MIN (burst_size,NR_TEST_FUNCS ); -struct cpumask cpu_mask; +cpumask_var_t cpu_mask; + +if (!alloc_cpumask_var (&cpu_mask,GFP_KERNEL )) +return -ENOMEM ;if (cpu_affinity >-1 ) { -cpumask_clear (&cpu_mask); -cpumask_set_cpu (cpu_affinity, &cpu_mask); -if (set_cpus_allowed_ptr (current, &cpu_mask)) +cpumask_clear (cpu_mask); +cpumask_set_cpu (cpu_affinity, cpu_mask); +if (set_cpus_allowed_ptr (current, cpu_mask))pr_err ("cpu_affinity:%d, failed\n" , cpu_affinity); }
@@ -139,6 +142,8 @@ static int preemptirq_delay_run(void *data)__set_current_state (TASK_RUNNING ); +free_cpumask_var (cpu_mask); +return 0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 376/627 RDMA/uverbs: Add empty rdma_uattrs_has_raw_cap() declaration
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leon Romanovsky <[email protected]>
[ Upstream commit 98269398c02ab20eb9ed6d77416023a2627049d8 ]
The call to rdma_uattrs_has_raw_cap() is placed in mlx5 fs.c file, which is compiled without relation to CONFIG_INFINIBAND_USER_ACCESS.
Despite the check is used only in flows with CONFIG_INFINIBAND_USER_ACCESS=y|m, the compilers generate the following error for CONFIG_INFINIBAND_USER_ACCESS=n builds.
Quoted 1 line
Quoted 1 line
ERROR: modpost: "
rdma_uattrs_has_raw_cap" [drivers/infiniband/hw/mlx5/mlx5_ib.ko] undefined!
--- include/rdma/ib_verbs.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
include/rdma/ib_verbs.h +6 -2
@@ -4794,15 +4794,19 @@ struct ib_ucontext *ib_uverbs_get_ucontext_file(struct ib_uverbs_file *ufile);#if IS_ENABLED (CONFIG_INFINIBAND_USER_ACCESS )int uverbs_destroy_def_handler (struct uverbs_attr_bundle *attrs); +bool rdma_uattrs_has_raw_cap (const struct uverbs_attr_bundle *attrs);#else static inline int uverbs_destroy_def_handler (struct uverbs_attr_bundle *attrs) {return 0 ; } +static inline bool +rdma_uattrs_has_raw_cap (const struct uverbs_attr_bundle *attrs) +{ +return false; +}#endif -bool rdma_uattrs_has_raw_cap (const struct uverbs_attr_bundle *attrs); - struct net_device *rdma_alloc_netdev(struct ib_device *device, u32 port_num, enum rdma_netdev_t type, const char *name, unsigned char name_assign_type,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 377/627 proc: use the same treatment to check proc_lseek as ones for proc_read_iter et.al
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: wangzijie <[email protected]>
[ Upstream commit ff7ec8dc1b646296f8d94c39339e8d3833d16c05 ]
Check pde->proc_ops->proc_lseek directly may cause UAF in rmmod scenario. It's a gap in proc_reg_open() after commit 654b33ada4ab("proc: fix UAF in proc_get_inode()"). Followed by AI Viro's suggestion, fix it in same manner.
--- fs/proc/generic.c | 2 ++ fs/proc/inode.c | 2 +- fs/proc/internal.h | 5 +++++ include/linux/proc_fs.h | 1 + 4 files changed, 9 insertions(+), 1 deletion(-)
fs/proc/generic.c +2 -0
@@ -569,6 +569,8 @@ static void pde_set_flags(struct proc_dir_entry *pde)if (pde->proc_ops->proc_compat_ioctl) pde->flags |= PROC_ENTRY_proc_compat_ioctl;#endif +if (pde->proc_ops->proc_lseek) + pde->flags |= PROC_ENTRY_proc_lseek; } struct proc_dir_entry *proc_create_data(const char *name, umode_t mode,
fs/proc/inode.c +1 -1
@@ -473,7 +473,7 @@ static int proc_reg_open(struct inode *inode, struct file *file) typeof_member(struct proc_ops, proc_open) open;struct pde_opener *pdeo; -if (!pde->proc_ops->proc_lseek) +if (!pde_has_proc_lseek (pde)) file->f_mode &= ~FMODE_LSEEK ;if (pde_is_permanent (pde)) {
fs/proc/internal.h +5 -0
@@ -99,6 +99,11 @@ static inline bool pde_has_proc_compat_ioctl(const struct proc_dir_entry *pde)#endif } +static inline bool pde_has_proc_lseek (const struct proc_dir_entry *pde) +{ +return pde->flags & PROC_ENTRY_proc_lseek; +} +extern struct kmem_cache *proc_dir_entry_cache;void pde_free (struct proc_dir_entry *pde);
include/linux/proc_fs.h +1 -0
@@ -27,6 +27,7 @@ enum { PROC_ENTRY_proc_read_iter =1U <<1 , PROC_ENTRY_proc_compat_ioctl =1U <<2 , + PROC_ENTRY_proc_lseek = 1U << 3, }; struct proc_ops {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 378/627 cxl/core: Introduce a new helper cxl_resource_contains_addr()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
[ Upstream commit 5b6031c832c2747d58d3f0130098d965ef050b9a ]
In CXL subsystem, many functions need to check an address availability by checking if the resource range contains the address. Providing a new helper function cxl_resource_contains_addr() to check if the resource range contains the input address.
Stable-dep-of: 03ff65c02559 ("cxl/edac: Fix wrong dpa checking for PPR operation")
--- drivers/cxl/core/core.h | 1 + drivers/cxl/core/hdm.c | 7 +++++++ 2 files changed, 8 insertions(+)
drivers/cxl/core/core.h +1 -0
@@ -80,6 +80,7 @@ int cxl_dpa_alloc(struct cxl_endpoint_decoder *cxled, u64 size);int cxl_dpa_free (struct cxl_endpoint_decoder *cxled);resource_size_t cxl_dpa_size (struct cxl_endpoint_decoder *cxled);resource_size_t cxl_dpa_resource_start (struct cxl_endpoint_decoder *cxled); +bool cxl_resource_contains_addr (const struct resource *res,const resource_size_t addr);enum cxl_rcrb {CXL_RCRB_DOWNSTREAM ,
drivers/cxl/core/hdm.c +7 -0
@@ -547,6 +547,13 @@ resource_size_t cxl_dpa_resource_start(struct cxl_endpoint_decoder *cxled)return base; } +bool cxl_resource_contains_addr (const struct resource *res,const resource_size_t addr) +{ +struct resource _addr =DEFINE_RES_MEM (addr,1 ); + +return resource_contains (res, &_addr); +} +int cxl_dpa_free (struct cxl_endpoint_decoder *cxled) {struct cxl_port *port =cxled_to_port (cxled);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 379/627 cxl/edac: Fix wrong dpa checking for PPR operation
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Li Ming <[email protected]>
[ Upstream commit 03ff65c02559e8da32be231d7f10fe899233ceae ]
Per Table 8-143. "Get Partition Info Output Payload" in CXL r3.2 section 8.2.10.9.2.1 "Get Partition Info(Opcode 4100h)", DPA 0 is a valid address of a CXL device. However, cxl_do_ppr() considers it as an invalid address, so that user will get an -EINVAL when user calls the sysfs interface of the edac driver to trigger a Post Package Repair(PPR) operation for DPA 0 on a CXL device. The correct implementation should be checking if the input DPA is in the DPA range of the CXL device.
--- drivers/cxl/core/edac.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/cxl/core/edac.c +4 -1
@@ -1923,8 +1923,11 @@ static int cxl_ppr_set_nibble_mask(struct device *dev, void *drv_data,static int cxl_do_ppr (struct device *dev,void *drv_data,u32 val) {struct cxl_ppr_context *cxl_ppr_ctx = drv_data; +struct cxl_memdev *cxlmd = cxl_ppr_ctx->cxlmd; +struct cxl_dev_state *cxlds = cxlmd->cxlds; -if (!cxl_ppr_ctx->dpa || val !=EDAC_DO_MEM_REPAIR ) +if (val !=EDAC_DO_MEM_REPAIR || + !cxl_resource_contains_addr (&cxlds->dpa_res, cxl_ppr_ctx->dpa))return -EINVAL ;return cxl_mem_perform_ppr (cxl_ppr_ctx);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 380/627 pinmux: fix race causing mux_owner NULL with active mux_usecount
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mukesh Ojha <[email protected]>
[ Upstream commit 0b075c011032f88d1cfde3b45d6dcf08b44140eb ]
commit 5a3e85c3c397 ("pinmux: Use sequential access to access desc->pinmux data") tried to address the issue when two client of the same gpio calls pinctrl_select_state() for the same functionality, was resulting in NULL pointer issue while accessing desc->mux_owner. However, issue was not completely fixed due to the way it was handled and it can still result in the same NULL pointer.
The issue occurs due to the following interleaving:
cpu0 (process A) cpu1 (process B)
pin_request() { pin_free() {
mutex_lock()
desc->mux_usecount--; //becomes 0
..
mutex_unlock()mutex_lock(desc->mux) desc->mux_usecount++; // becomes 1 desc->mux_owner = owner; mutex_unlock(desc->mux)
mutex_lock(desc->mux)
desc->mux_owner = NULL;
mutex_unlock(desc->mux)This sequence leads to a state where the pin appears to be in use (mux_usecount == 1) but has no owner (mux_owner == NULL), which can cause NULL pointer on next pin_request on the same pin.
Ensure that updates to mux_usecount and mux_owner are performed atomically under the same lock. Only clear mux_owner when mux_usecount reaches zero and no new owner has been assigned.
--- drivers/pinctrl/pinmux.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/pinctrl/pinmux.c +9 -11
@@ -236,18 +236,7 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin,if (desc->mux_usecount)return NULL ; } - } - -/* -* If there is no kind of request function for the pin we just assume -* we got it by default and proceed. -*/ -if (gpio_range && ops->gpio_disable_free) - ops->gpio_disable_free (pctldev, gpio_range, pin); -else if (ops->free) - ops->free (pctldev, pin); - scoped_guard(mutex, &desc->mux_lock) {if (gpio_range) { owner = desc->gpio_owner; desc->gpio_owner =NULL ;
@@ -258,6 +247,15 @@ static const char *pin_free(struct pinctrl_dev *pctldev, int pin, } } +/* +* If there is no kind of request function for the pin we just assume +* we got it by default and proceed. +*/ +if (gpio_range && ops->gpio_disable_free) + ops->gpio_disable_free (pctldev, gpio_range, pin); +else if (ops->free) + ops->free (pctldev, pin); +module_put (pctldev->owner);return owner;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 381/627 perf tests bp_account: Fix leaked file descriptor
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Leo Yan <[email protected]>
[ Upstream commit 4a6cdecaa1497f1fbbd1d5307a225b6ca5a62a90 ]
Since the commit e9846f5ead26 ("perf test: In forked mode add check that fds aren't leaked"), the test "Breakpoint accounting" reports the error:
# perf test -vvv "Breakpoint accounting" 20: Breakpoint accounting: --- start --- test child forked, pid 373 failed opening event 0 failed opening event 0 watchpoints count 4, breakpoints count 6, has_ioctl 1, share 0 wp 0 created wp 1 created wp 2 created wp 3 created wp 0 modified to bp wp max created ---- end(0) ---- Leak of file descriptor 7 that opened: 'anon_inode:[perf_event]'
A watchpoint's file descriptor was not properly released. This patch fixes the leak.
--- tools/perf/tests/bp_account.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/bp_account.c +1 -0
@@ -104,6 +104,7 @@ static int bp_accounting(int wp_cnt, int share) fd_wp =wp_event ((void *)&the_var, &attr_new);TEST_ASSERT_VAL ("failed to create max wp\n" , fd_wp !=-1 );pr_debug ("wp max created\n" ); +close (fd_wp); }for (i =0 ; i < wp_cnt; i++)
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 382/627 perf hwmon_pmu: Avoid shortening hwmon PMU name
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 28f5aa8184c9c9b8eab35fa3884c416fe75e88e4 ]
Long names like ucsi_source_psy_USBC000:001 when prefixed with hwmon_ exceed the buffer size and the last digit is lost. This causes confusion with similar names like ucsi_source_psy_USBC000:002. Extend the buffer size to avoid this.
--- tools/perf/util/hwmon_pmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/hwmon_pmu.c +1 -1
@@ -344,7 +344,7 @@ static int hwmon_pmu__read_events(struct hwmon_pmu *pmu)struct perf_pmu *hwmon_pmu__new (struct list_head *pmus,int hwmon_dir,const char *sysfs_name,const char *name) { -char buf[32 ]; +char buf[64 ];struct hwmon_pmu *hwm;__u32 type =PERF_PMU_TYPE_HWMON_START +strtoul (sysfs_name +5 ,NULL ,10 );
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 383/627 perf python: Fix thread check in pyrf_evsel__read
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 64ec9b997f3a9462901a404ad60f452f76dd2d6e ]
The CPU index is incorrectly checked rather than the thread index.
--- tools/perf/util/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/python.c +1 -1
@@ -909,7 +909,7 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel,return NULL ; } thread_idx =perf_thread_map__idx (evsel->core.threads, thread); -if (cpu_idx <0 ) { +if (thread_idx <0 ) {PyErr_Format (PyExc_TypeError,"Thread %d is not part of evsel's threads" , thread);return NULL ;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 384/627 perf python: Correct pyrf_evsel__read for tool PMUs
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ian Rogers <[email protected]>
[ Upstream commit 6183afcba9c1c810656ddb36170106aaf3cf778c ]
Tool PMUs assume that stat's process_counter_values is being used to read the counters. Specifically they hold onto old values in evsel->prev_raw_counts and give the cumulative count based off of this value. Update pyrf_evsel__read to allocate counts and prev_raw_counts, use evsel__read_counter rather than perf_evsel__read so tool PMUs are read from not just perf_event_open events, make the returned pyrf_counts_values contain the delta value rather than the cumulative value.
--- tools/perf/util/python.c | 47 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-)
tools/perf/util/python.c +44 -3
@@ -10,6 +10,7 @@#endif #include <perf/mmap.h> #include "callchain.h" +#include "counts.h" #include "evlist.h" #include "evsel.h" #include "event.h"
@@ -888,12 +889,38 @@ static PyObject *pyrf_evsel__threads(struct pyrf_evsel *pevsel)return (PyObject *)pthread_map; } +/* +* Ensure evsel's counts and prev_raw_counts are allocated, the latter +* used by tool PMUs to compute the cumulative count as expected by +* stat's process_counter_values. +*/ +static int evsel__ensure_counts (struct evsel *evsel) +{ +int nthreads, ncpus; + +if (evsel->counts !=NULL ) +return 0 ; + + nthreads =perf_thread_map__nr (evsel->core.threads); + ncpus =perf_cpu_map__nr (evsel->core.cpus); + + evsel->counts =perf_counts__new (ncpus, nthreads); +if (evsel->counts ==NULL ) +return -ENOMEM ; + + evsel->prev_raw_counts =perf_counts__new (ncpus, nthreads); +if (evsel->prev_raw_counts ==NULL ) +return -ENOMEM ; + +return 0 ; +} +static PyObject *pyrf_evsel__read (struct pyrf_evsel *pevsel,PyObject *args,PyObject *kwargs) {struct evsel *evsel = &pevsel->evsel;int cpu =0 , cpu_idx, thread =0 , thread_idx; -struct perf_counts_values counts; +struct perf_counts_values *old_count, *new_count; struct pyrf_counts_values *count_values = PyObject_New(struct pyrf_counts_values, &pyrf_counts_values__type);
@@ -914,8 +941,22 @@ static PyObject *pyrf_evsel__read(struct pyrf_evsel *pevsel, thread);return NULL ; } -perf_evsel__read (&(evsel->core), cpu_idx, thread_idx, &counts); - count_values->values = counts; + +if (evsel__ensure_counts (evsel)) +return PyErr_NoMemory (); + +/* Set up pointers to the old and newly read counter values. */ + old_count =perf_counts (evsel->prev_raw_counts, cpu_idx, thread_idx); + new_count =perf_counts (evsel->counts, cpu_idx, thread_idx); +/* Update the value in evsel->counts. */ +evsel__read_counter (evsel, cpu_idx, thread_idx); +/* Copy the value and turn it into the delta from old_count. */ + count_values->values = *new_count; + count_values->values.val -= old_count->val; + count_values->values.ena -= old_count->ena; + count_values->values.run -= old_count->run; +/* Save the new count over the old_count for the next read. */ + *old_count = *new_count;return (PyObject *)count_values; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 385/627 RDMA/mana_ib: Fix DSCP value in modify QP
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shiraz Saleem <[email protected]>
[ Upstream commit 62de0e67328e9503459a24b9343c3358937cdeef ]
Convert the traffic_class in GRH to a DSCP value as required by the HW.
--- drivers/infiniband/hw/mana/qp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mana/qp.c +1 -1
@@ -772,7 +772,7 @@ static int mana_ib_gd_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, req.ah_attr.dest_port =ROCE_V2_UDP_DPORT ; req.ah_attr.src_port =rdma_get_udp_sport (attr->ah_attr.grh.flow_label, ibqp->qp_num, attr->dest_qp_num); - req.ah_attr.traffic_class = attr->ah_attr.grh.traffic_class; + req.ah_attr.traffic_class = attr->ah_attr.grh.traffic_class >>2 ; req.ah_attr.hop_limit = attr->ah_attr.grh.hop_limit; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 386/627 clk: thead: th1520-ap: Correctly refer the parent of osc_12m
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Yao Zi <[email protected]>
[ Upstream commit d274c77ffa202b70ad01d579f33b73b4de123375 ]
The "osc_12m" fixed factor clock refers the external oscillator by setting clk_parent_data.fw_name to osc_24m, which is obviously wrong since no clock-names property is allowed for compatible thead,th1520-clk-ap.
Refer the oscillator as parent by index instead.
--- drivers/clk/thead/clk-th1520-ap.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/clk/thead/clk-th1520-ap.c +8 -1
@@ -582,7 +582,14 @@ static const struct clk_parent_data peri2sys_apb_pclk_pd[] = { { .hw = &peri2sys_apb_pclk.common.hw } }; -static CLK_FIXED_FACTOR_FW_NAME(osc12m_clk, "osc_12m", "osc_24m", 2, 1, 0); +static struct clk_fixed_factor osc12m_clk = { + .div =2 , + .mult =1 , + .hw.init =CLK_HW_INIT_PARENTS_DATA ("osc_12m" , + osc_24m_clk, + &clk_fixed_factor_ops, +0 ), +};static const char *const out_parents[] = {"osc_24m" ,"osc_12m" };
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 387/627 ext4: correct the reserved credits for extent conversion
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 95ad8ee45cdbc321c135a2db895d48b374ef0f87 ]
Now, we reserve journal credits for converting extents in only one page to written state when the I/O operation is complete. This is insufficient when large folio is enabled.
Fix this by reserving credits for converting up to one extent per block in the largest 2MB folio, this calculation should only involve extents index and leaf blocks, so it should not estimate too many credits.
--- fs/ext4/inode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/ext4/inode.c +3 -3
@@ -2771,12 +2771,12 @@ static int ext4_do_writepages(struct mpage_da_data *mpd) mpd->journalled_more_data =0 ;if (ext4_should_dioread_nolock (inode)) { +int bpf =ext4_journal_blocks_per_folio (inode);/* * We may need to convert up to one extent per block in -* the page and we may dirty the inode. +* the folio and we may dirty the inode. */ - rsv_blocks =1 +ext4_chunk_trans_blocks (inode, -PAGE_SIZE >> inode->i_blkbits); + rsv_blocks =1 +ext4_ext_index_trans_blocks (inode, bpf); }if (wbc->range_start ==0 && wbc->range_end ==LLONG_MAX )
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 388/627 ext4: fix insufficient credits calculation in ext4_meta_trans_blocks()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhang Yi <[email protected]>
[ Upstream commit 5137d6c8906b55b3c7b5d1aa5a549753ec8520f5 ]
The calculation of journal credits in ext4_meta_trans_blocks() should include pextents, as each extent separately may be allocated from a different group and thus need to update different bitmap and group descriptor block.
--- fs/ext4/inode.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext4/inode.c +2 -2
@@ -6139,7 +6139,7 @@ int ext4_meta_trans_blocks(struct inode *inode, int lblocks, int pextents)int ret;/* -* How many index and lead blocks need to touch to map @lblocks +* How many index and leaf blocks need to touch to map @lblocks * logical blocks to @pextents physical extents? */ idxblocks =ext4_index_trans_blocks (inode, lblocks, pextents);
@@ -6148,7 +6148,7 @@ int ext4_meta_trans_blocks(struct inode *inode, int lblocks, int pextents)* Now let's see how many group bitmaps and group descriptors need * to account */ - groups = idxblocks; + groups = idxblocks + pextents; gdpblocks = groups;if (groups > ngroups) groups = ngroups;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 389/627 clk: sunxi-ng: v3s: Fix de clock definition
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Kocialkowski <[email protected]>
[ Upstream commit e8ab346f9907a1a3aa2f0e5decf849925c06ae2e ]
The de clock is marked with CLK_SET_RATE_PARENT, which is really not necessary (as confirmed from experimentation) and significantly restricts flexibility for other clocks using the same parent.
In addition the source selection (parent) field is marked as using 2 bits, when it the documentation reports that it uses 3.
Fix both issues in the de clock definition.
--- drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clk/sunxi-ng/ccu-sun8i-v3s.c +1 -2
@@ -347,8 +347,7 @@ static SUNXI_CCU_GATE(dram_ohci_clk, "dram-ohci", "dram",static const char *const de_parents[] = {"pll-video" ,"pll-periph0" }; static SUNXI_CCU_M_WITH_MUX_GATE(de_clk, "de", de_parents, -0x104 ,0 ,4 ,24 ,2 ,BIT (31 ), - CLK_SET_RATE_PARENT); + 0x104, 0, 4, 24, 3, BIT(31), 0);static const char *const tcon_parents[] = {"pll-video" ,"pll-periph0" }; static SUNXI_CCU_M_WITH_MUX_GATE(tcon_clk, "tcon", tcon_parents,
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 390/627 scsi: ibmvscsi_tgt: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 023a293b9cd0bb86a9b50cd7688a3d9d266826db ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/ibmvscsi_tgt/libsrp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/ibmvscsi_tgt/libsrp.c +4 -2
@@ -184,7 +184,8 @@ static int srp_direct_data(struct ibmvscsis_cmd *cmd, struct srp_direct_buf *md, err =rdma_io (cmd, sg, nsg, md,1 , dir, len);if (dma_map) -dma_unmap_sg (iue->target->dev, sg, nsg,DMA_BIDIRECTIONAL ); +dma_unmap_sg (iue->target->dev, sg, cmd->se_cmd.t_data_nents, +DMA_BIDIRECTIONAL );return err; }
@@ -256,7 +257,8 @@ static int srp_indirect_data(struct ibmvscsis_cmd *cmd, struct srp_cmd *srp_cmd, err =rdma_io (cmd, sg, nsg, md, nmd, dir, len);if (dma_map) -dma_unmap_sg (iue->target->dev, sg, nsg,DMA_BIDIRECTIONAL ); +dma_unmap_sg (iue->target->dev, sg, cmd->se_cmd.t_data_nents, +DMA_BIDIRECTIONAL ); free_mem:if (token && dma_map) {
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 391/627 scsi: core: Fix kernel doc for scsi_track_queue_full()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bagas Sanjaya <[email protected]>
[ Upstream commit 6070bd558aee1eb5114e1676165bf0ccaa08240a ]
Sphinx reports indentation warning on scsi_track_queue_full() return values:
Documentation/driver-api/scsi:101: ./drivers/scsi/scsi.c:247: ERROR: Unexpected indentation. [docutils]
Fix the warning by making the return values listing a bullet list.
--- drivers/scsi/scsi.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/scsi/scsi.c +5 -3
@@ -242,9 +242,11 @@ EXPORT_SYMBOL(scsi_change_queue_depth);* specific SCSI device to determine if and when there is a * need to adjust the queue depth on the device. * -* Returns: 0 - No change needed, >0 - Adjust queue depth to this new depth, -* -1 - Drop back to untagged operation using host->cmd_per_lun -* as the untagged command depth +* Returns: +* * 0 - No change needed +* * >0 - Adjust queue depth to this new depth, +* * -1 - Drop back to untagged operation using host->cmd_per_lun as the +* untagged command depth * * Lock Status: None held on entry *
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 392/627 scsi: elx: efct: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 3a988d0b65d7d1713ce7596eae288a293f3b938e ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/elx/efct/efct_lio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/elx/efct/efct_lio.c +1 -1
@@ -382,7 +382,7 @@ efct_lio_sg_unmap(struct efct_io *io)return ;dma_unmap_sg (&io->efct->pci->dev, cmd->t_data_sg, - ocp->seg_map_cnt, cmd->data_direction); + cmd->t_data_nents, cmd->data_direction); ocp->seg_map_cnt =0 ; }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 393/627 scsi: mvsas: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 0141618727bc929fe868153d21797f10ce5bef3f ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/mvsas/mv_sas.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/mvsas/mv_sas.c +2 -2
@@ -818,7 +818,7 @@ static int mvs_task_prep(struct sas_task *task, struct mvs_info *mvi, int is_tmfdev_printk (KERN_ERR , mvi->dev,"mvsas prep failed[%d]!\n" , rc);if (!sas_protocol_ata (task->task_proto))if (n_elem) -dma_unmap_sg (mvi->dev, task->scatter, n_elem, +dma_unmap_sg (mvi->dev, task->scatter, task->num_scatter, task->data_dir); prep_out:return rc;
@@ -864,7 +864,7 @@ static void mvs_slot_task_free(struct mvs_info *mvi, struct sas_task *task,if (!sas_protocol_ata (task->task_proto))if (slot->n_elem)dma_unmap_sg (mvi->dev, task->scatter, - slot->n_elem, task->data_dir); + task->num_scatter, task->data_dir);switch (task->task_proto) {case SAS_PROTOCOL_SMP :
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 394/627 scsi: isci: Fix dma_unmap_sg() nents value
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Fourier <[email protected]>
[ Upstream commit 063bec4444d54e5f35d11949c5c90eaa1ff84c11 ]
The dma_unmap_sg() functions should be called with the same nents as the dma_map_sg(), not the value the map function returned.
--- drivers/scsi/isci/request.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/isci/request.c +1 -1
@@ -2904,7 +2904,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost, task->total_xfer_len, task->data_dir); else /* unmap the sgl dma addresses */ dma_unmap_sg(&ihost->pdev->dev, task->scatter, - request->num_sg_entries, task->data_dir); + task->num_scatter, task->data_dir);break ;case SAS_PROTOCOL_SMP : {struct scatterlist *sg = &task->smp_task.smp_req;
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 395/627 PCI: Fix driver_managed_dma check
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Murphy <[email protected]>
[ Upstream commit 78447d4545b2ea76ee04f4e46d473639483158b2 ]
Since it's not currently safe to take device_lock() in the IOMMU probe path, that can race against really_probe() setting dev->driver before attempting to bind. The race itself isn't so bad, since we're only concerned with dereferencing dev->driver itself anyway, but sadly my attempt to implement the check with minimal churn leads to a kind of Time-of-Check to Time-of-Use (TOCTOU) issue, where dev->driver becomes valid after to_pci_driver(NULL) is already computed, and thus the check fails to work as intended.
Will and I both hit this with the platform bus, but the pattern here is the same, so fix it for correctness too.
--- drivers/pci/pci-driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pci/pci-driver.c +3 -3
@@ -1628,7 +1628,7 @@ static int pci_bus_num_vf(struct device *dev)*/ static int pci_dma_configure (struct device *dev) { -struct pci_driver *driver =to_pci_driver (dev->driver); +const struct device_driver *drv =READ_ONCE (dev->driver);struct device *bridge;int ret =0 ;
@@ -1645,8 +1645,8 @@ static int pci_dma_configure(struct device *dev)pci_put_host_bridge_device (bridge); -/* @driver may not be valid when we're called from the IOMMU layer */ -if (!ret && dev->driver && !driver->driver_managed_dma) { +/* @drv may not be valid when we're called from the IOMMU layer */ +if (!ret && drv && !to_pci_driver (drv)->driver_managed_dma) { ret =iommu_device_use_default_domain (dev);if (ret)arch_teardown_dma_ops (dev);
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerPATCH 396/627 watchdog: ziirave_wdt: check record length in ziirave_firm_verify()
In reply to Greg Kroah-Hartman6.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
[ Upstream commit 8b61d8ca751bc15875b50e0ff6ac3ba0cf95a529 ]
The "rec->len" value comes from the firmware. We generally do trust firmware, but it's always better to double check. If the length value is too large it would lead to memory corruption when we set "data[i] = ret;"
--- drivers/watchdog/ziirave_wdt.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/watchdog/ziirave_wdt.c +3 -0
@@ -302,6 +302,9 @@ static int ziirave_firm_verify(struct watchdog_device *wdd,const u16 len =be16_to_cpu (rec->len);const u32 addr =be32_to_cpu (rec->addr); +if (len >sizeof (data)) +return -EINVAL ; +if (ziirave_firm_addr_readonly (addr))continue ;
Signature · 1 line
2.39.5